From nicholas at mxc.ca Mon Nov 30 01:02:19 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 30 Nov 2009 07:02:19 -0000 Subject: [llvm-commits] [llvm] r90112 - /llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll Message-ID: <200911300702.nAU72J2Y015655@zion.cs.uiuc.edu> Author: nicholas Date: Mon Nov 30 01:02:18 2009 New Revision: 90112 URL: http://llvm.org/viewvc/llvm-project?rev=90112&view=rev Log: Add a testcase for the current llvm-gcc build failure. Added: llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll Added: llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll?rev=90112&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll (added) +++ llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll Mon Nov 30 01:02:18 2009 @@ -0,0 +1,33 @@ +; RUN: opt -gvn -disable-output %s + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" +target triple = "i386-pc-linux-gnu" + +%struct.attribute_spec = type { i8*, i32, i32, i8, i8, i8 } + + at attribute_tables = external global [4 x %struct.attribute_spec*] ; <[4 x %struct.attribute_spec*]*> [#uses=2] + +define void @decl_attributes() nounwind { +entry: + br label %bb69.i + +bb69.i: ; preds = %bb57.i.preheader + %tmp4 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] + %tmp5 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] + %tmp3 = load %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1] + br label %bb65.i + +bb65.i: ; preds = %bb65.i.preheader, %bb64.i + %storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; [#uses=3] + %scevgep14 = getelementptr inbounds %struct.attribute_spec* %tmp3, i32 %storemerge6.i, i32 0 ; [#uses=1] + %tmp2 = load i8** %scevgep14, align 4 ; [#uses=0] + %tmp = load %struct.attribute_spec** %tmp5, align 4 ; <%struct.attribute_spec*> [#uses=1] + %scevgep1516 = getelementptr inbounds %struct.attribute_spec* %tmp, i32 %storemerge6.i, i32 0 ; [#uses=0] + unreachable + +bb64.i: ; Unreachable + br label %bb65.i + +bb66.i: ; Unreachable + br label %bb69.i +} From nicholas at mxc.ca Mon Nov 30 01:05:52 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 30 Nov 2009 07:05:52 -0000 Subject: [llvm-commits] [llvm] r90113 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200911300705.nAU75qsb015777@zion.cs.uiuc.edu> Author: nicholas Date: Mon Nov 30 01:05:51 2009 New Revision: 90113 URL: http://llvm.org/viewvc/llvm-project?rev=90113&view=rev Log: Revert r90107, fixing test/Transforms/GVN/2009-11-29-ReverseMap.ll and the llvm-gcc build. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90113&r1=90112&r2=90113&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Nov 30 01:05:51 2009 @@ -1156,21 +1156,8 @@ // that predecessor. We can still do PRE of the load, which would insert // a computation of the pointer in this predecessor. if (PredPtr == 0) { - // Add the entry to the Result list. - NonLocalDepEntry Entry(Pred, - MemDepResult::getClobber(Pred->getTerminator())); - Result.push_back(Entry); - - // Add it to the cache for this CacheKey so that subsequent queries get - // this result. - Cache = &NonLocalPointerDeps[CacheKey].second; - MemoryDependenceAnalysis::NonLocalDepInfo::iterator It = - std::upper_bound(Cache->begin(), Cache->end(), Entry); - Cache->insert(It, Entry); - Cache = 0; - - // Add it to the reverse map next. - ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey); + Result.push_back(NonLocalDepEntry(Pred, + MemDepResult::getClobber(Pred->getTerminator()))); continue; } From echristo at apple.com Mon Nov 30 02:03:53 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 30 Nov 2009 08:03:53 -0000 Subject: [llvm-commits] [llvm] r90116 - /llvm/trunk/docs/LangRef.html Message-ID: <200911300803.nAU83rpF017729@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 02:03:53 2009 New Revision: 90116 URL: http://llvm.org/viewvc/llvm-project?rev=90116&view=rev Log: First pass at llvm.objectsize documentation. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=90116&r1=90115&r2=90116&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Nov 30 02:03:53 2009 @@ -291,6 +291,8 @@ 'llvm.trap' Intrinsic
  • 'llvm.stackprotector' Intrinsic
  • +
  • + 'llvm.objectsize' Intrinsic
  • @@ -7246,6 +7248,41 @@ + + + +
    + +
    Syntax:
    +
    +  declare i32 @llvm.objectsize.i32( i8* <ptr>, i32 <type> )
    +  declare i64 @llvm.objectsize.i64( i8* <ptr>, i32 <type> )
    +
    + +
    Overview:
    +

    The llvm.objectsize intrinsic returns the constant number of bytes + from ptr to the end of the object ptr points to if it + can deduce this at compile time. If there are any side-effects in evaluating + the argument or it cannot deduce which objects ptr points to at compile + time the intrinsic returns (size_t) -1 for type 0 + or 1 and (size_t) 0 for type 2 or 3.

    + +
    Arguments:
    +

    The llvm.objectsize intrinsic takes two arguments. The first + argument is a pointer to the object ptr and an integer type. + type is an integer ranging from 0 to 3. The lsb corresponds to + a return value based on whole objects, the second bit whether or not we + return the maximum or minimum remaining bytes computed.

    + +
    Semantics:
    +

    The llvm.objectsize intrinsic is lowered to either a constant + representing the size of the object concerned or (size_t) -1 if + it cannot be determined at compile time.

    + +
    +
    From echristo at apple.com Mon Nov 30 02:04:32 2009 From: echristo at apple.com (Eric Christopher) Date: Mon, 30 Nov 2009 00:04:32 -0800 Subject: [llvm-commits] [llvm] r85189 - in /llvm/trunk: include/llvm/Intrinsics.td lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: <4AE67A8C.6070403@mxc.ca> References: <200910270052.n9R0qPfC015484@zion.cs.uiuc.edu> <4AE67A8C.6070403@mxc.ca> Message-ID: On Oct 26, 2009, at 9:43 PM, Nick Lewycky wrote: > Please document this in the LangRef. Finally did this. Sorry for the delay :) -eric From wendling at apple.com Mon Nov 30 04:09:52 2009 From: wendling at apple.com (Bill Wendling) Date: Mon, 30 Nov 2009 02:09:52 -0800 Subject: [llvm-commits] [llvm] r90116 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200911300803.nAU83rpF017729@zion.cs.uiuc.edu> References: <200911300803.nAU83rpF017729@zion.cs.uiuc.edu> Message-ID: :-) > +
    Syntax:
    > +
    > +  declare i32 @llvm.objectsize.i32( i8* <ptr>, i32 <type> )
    > +  declare i64 @llvm.objectsize.i64( i8* <ptr>, i32 <type> )
    > +
    > + > +
    Overview:
    > +

    The llvm.objectsize intrinsic returns the constant number of bytes > + from ptr to the end of the object ptr points to if it "points to if" -> "points to, if" > + can deduce this at compile time. If there are any side-effects in evaluating > + the argument or it cannot deduce which objects ptr points to at compile > + time the intrinsic returns (size_t) -1 for type 0 "time the" -> "time, the" It may be a good idea to put the "for" clauses within commas too, but that's probably not as necessary. > + or 1 and (size_t) 0 for type 2 or 3.

    > + > +
    Arguments:
    > +

    The llvm.objectsize intrinsic takes two arguments. The first > + argument is a pointer to the object ptr and an integer type. "ptr" and an integer" -> "ptr. The second argument is an integer" > + type is an integer ranging from 0 to 3. The lsb corresponds to You can elide "is an integer ranging" and just put "ranges" instead. Also, what does "lsb" mean here? I assume "least significant bit", but it might be good to spell it out. (IMHO, I'd much rather have the documentation present me with redundant information instead of hoping that I know what it's talking about.) > + a return value based on whole objects, the second bit whether or not we "objects, the second" -> "objects, and the second" > + return the maximum or minimum remaining bytes computed.

    > + > +
    Semantics:
    > +

    The llvm.objectsize intrinsic is lowered to either a constant > + representing the size of the object concerned or (size_t) -1 if > + it cannot be determined at compile time.

    > + Does "size_t" have any meaning in LLVM IR? It's a C construct, and at this point we're not dealing with C. Maybe using the equivalent LLVM type would be more appropriate. Also, it would be good to present a few examples. :-) -bw From grosser at fim.uni-passau.de Mon Nov 30 05:55:28 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 11:55:28 -0000 Subject: [llvm-commits] [llvm] r90129 - /llvm/trunk/include/llvm/Analysis/CFGPrinter.h Message-ID: <200911301155.nAUBtSaF008005@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 05:55:24 2009 New Revision: 90129 URL: http://llvm.org/viewvc/llvm-project?rev=90129&view=rev Log: Remove ":" after BB name in -view-cfg-only Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=90129&r1=90128&r2=90129&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Mon Nov 30 05:55:24 2009 @@ -32,7 +32,7 @@ const Function *Graph, bool ShortNames) { if (ShortNames && !Node->getName().empty()) - return Node->getNameStr() + ":"; + return Node->getNameStr(); std::string Str; raw_string_ostream OS(Str); From grosser at fim.uni-passau.de Mon Nov 30 06:06:38 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 12:06:38 -0000 Subject: [llvm-commits] [llvm] r90130 - in /llvm/trunk: include/llvm/Analysis/PostDominators.h lib/Analysis/DomPrinter.cpp Message-ID: <200911301206.nAUC6cG3008483@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 06:06:37 2009 New Revision: 90130 URL: http://llvm.org/viewvc/llvm-project?rev=90130&view=rev Log: Small PostDominatorTree improvements * Do not SEGFAULT if tree entryNode() is NULL * Print function names in dotty printer Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h llvm/trunk/lib/Analysis/DomPrinter.cpp Modified: llvm/trunk/include/llvm/Analysis/PostDominators.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PostDominators.h?rev=90130&r1=90129&r2=90130&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/PostDominators.h (original) +++ llvm/trunk/include/llvm/Analysis/PostDominators.h Mon Nov 30 06:06:37 2009 @@ -81,7 +81,10 @@ } static nodes_iterator nodes_begin(PostDominatorTree *N) { - return df_begin(getEntryNode(N)); + if (getEntryNode(N)) + return df_begin(getEntryNode(N)); + else + return df_end(getEntryNode(N)); } static nodes_iterator nodes_end(PostDominatorTree *N) { Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=90130&r1=90129&r2=90130&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DomPrinter.cpp (original) +++ llvm/trunk/lib/Analysis/DomPrinter.cpp Mon Nov 30 06:06:37 2009 @@ -85,9 +85,11 @@ virtual bool runOnFunction(Function &F) { Analysis *Graph; - + std::string Title, GraphName; Graph = &getAnalysis(); - ViewGraph(Graph, Name, OnlyBBS); + GraphName = DOTGraphTraits::getGraphName(Graph); + Title = GraphName + " for '" + F.getNameStr() + "' function"; + ViewGraph(Graph, Name, OnlyBBS, Title); return false; } @@ -163,8 +165,12 @@ raw_fd_ostream File(Filename.c_str(), ErrorInfo); Graph = &getAnalysis(); + std::string Title, GraphName; + GraphName = DOTGraphTraits::getGraphName(Graph); + Title = GraphName + " for '" + F.getNameStr() + "' function"; + if (ErrorInfo.empty()) - WriteGraph(File, Graph, OnlyBBS); + WriteGraph(File, Graph, OnlyBBS, Name, Title); else errs() << " error opening file for writing!"; errs() << "\n"; From grosser at fim.uni-passau.de Mon Nov 30 06:24:41 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 12:24:41 -0000 Subject: [llvm-commits] [llvm] r90131 - /llvm/trunk/include/llvm/Support/GraphWriter.h Message-ID: <200911301224.nAUCOfd1009023@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 06:24:40 2009 New Revision: 90131 URL: http://llvm.org/viewvc/llvm-project?rev=90131&view=rev Log: Only print edgeSourceLabels if they are not empty Graphviz can layout the graphs better if a node does not contain source ports. Therefore only print the ports if the source ports are useful, that means are not labeled with the empty string "". This patch also simplifies graphs without any edgeSourceLabels e.g. the dominance trees. Modified: llvm/trunk/include/llvm/Support/GraphWriter.h Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90131&r1=90130&r2=90131&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 06:24:40 2009 @@ -59,6 +59,34 @@ typedef typename GTraits::NodeType NodeType; typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; + + // Writes the edge labels of the node to O and returns true if there are any + // edge labels not equal to the empty string "". + bool getEdgeSourceLabels(raw_ostream &O, NodeType *Node) { + child_iterator EI = GTraits::child_begin(Node); + child_iterator EE = GTraits::child_end(Node); + bool hasEdgeSourceLabels = false; + + for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { + std::string label = DOTTraits::getEdgeSourceLabel(Node, EI); + + if (label == "") + continue; + + hasEdgeSourceLabels = true; + + if (i) + O << "|"; + + O << "" << DOTTraits::getEdgeSourceLabel(Node, EI); + } + + if (EI != EE && hasEdgeSourceLabels) + O << "|truncated..."; + + return hasEdgeSourceLabels; + } + public: GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g), ShortNames(SN) {} @@ -119,21 +147,15 @@ O << "|" << (void*)Node; } - // Print out the fields of the current node... - child_iterator EI = GTraits::child_begin(Node); - child_iterator EE = GTraits::child_end(Node); - if (EI != EE) { + std::string edgeSourceLabels; + raw_string_ostream::raw_string_ostream EdgeSourceLabels(edgeSourceLabels); + bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node); + + if (hasEdgeSourceLabels) { if (!DOTTraits::renderGraphFromBottomUp()) O << "|"; - O << "{"; - for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - if (i) O << "|"; - O << "" << DOTTraits::getEdgeSourceLabel(Node, EI); - } + O << "{" << EdgeSourceLabels.str() << "}"; - if (EI != EE) - O << "|truncated..."; - O << "}"; if (DOTTraits::renderGraphFromBottomUp()) O << "|"; } @@ -162,7 +184,8 @@ O << "}\"];\n"; // Finish printing the "node" line // Output all of the edges now - EI = GTraits::child_begin(Node); + child_iterator EI = GTraits::child_begin(Node); + child_iterator EE = GTraits::child_end(Node); for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) writeEdge(Node, i, EI); for (; EI != EE; ++EI) @@ -181,6 +204,9 @@ DestPort = static_cast(Offset); } + if (DOTTraits::getEdgeSourceLabel(Node, EI) == "") + edgeidx = -1; + emitEdge(static_cast(Node), edgeidx, static_cast(TargetNode), DestPort, DOTTraits::getEdgeAttributes(Node, EI)); From baldrick at free.fr Mon Nov 30 06:28:44 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 30 Nov 2009 13:28:44 +0100 Subject: [llvm-commits] [llvm] r90109 - /llvm/trunk/test/CodeGen/X86/scalar_widen_div.ll In-Reply-To: <200911300242.nAU2gRq5004305@zion.cs.uiuc.edu> References: <200911300242.nAU2gRq5004305@zion.cs.uiuc.edu> Message-ID: <4B13BA7C.4010502@free.fr> Hi, > +; Verify when widening a divide/remainder operation, we only generate a > +; divide/rem per element since divide/remainder can trap. you could also ensure that the widened divisor always has 1 in the extra elements. This is analogous to integer promotion where the extra bits are "undef" in general, but need to be constrained to certain values (usually zero or one) in some cases. Ciao, Duncan. From baldrick at free.fr Mon Nov 30 06:33:24 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 30 Nov 2009 13:33:24 +0100 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> Message-ID: <4B13BB94.1090803@free.fr> Hi Mon Ping, > Added support to allow clients to custom widen. For X86, custom widen vectors for > divide/remainder since these operations can trap by unroll them and adding undefs > for the resulting vector. does this really have anything to do with unrolling? After all, even if you don't unroll then the additional vector elements might contain anything (since they are "undef") and "anything" might be zero if you get unlucky. Will that trap with vector division (or does it slow the division down?) Wouldn't it be better to ensure that the extra elements in the denominator of the division contain 1 or some other thing sure to be non-zero. Ciao, Duncan. From grosser at fim.uni-passau.de Mon Nov 30 06:37:40 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 12:37:40 -0000 Subject: [llvm-commits] [llvm] r90132 - /llvm/trunk/include/llvm/Support/GraphWriter.h Message-ID: <200911301237.nAUCbeh3009434@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 06:37:39 2009 New Revision: 90132 URL: http://llvm.org/viewvc/llvm-project?rev=90132&view=rev Log: Do not point edge heads to source labels If no destination label is available, just point to the node itself instead of pointing to some source label. Source and destination labels are not related in any way. Modified: llvm/trunk/include/llvm/Support/GraphWriter.h Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90132&r1=90131&r2=90132&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 06:37:39 2009 @@ -247,12 +247,8 @@ if (SrcNodePort >= 0) O << ":s" << SrcNodePort; O << " -> Node" << DestNodeID; - if (DestNodePort >= 0) { - if (DOTTraits::hasEdgeDestLabels()) - O << ":d" << DestNodePort; - else - O << ":s" << DestNodePort; - } + if (DestNodePort >= 0 && DOTTraits::hasEdgeDestLabels()) + O << ":d" << DestNodePort; if (!Attrs.empty()) O << "[" << Attrs << "]"; From grosser at fim.uni-passau.de Mon Nov 30 06:38:13 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 12:38:13 -0000 Subject: [llvm-commits] [llvm] r90133 - in /llvm/trunk: include/llvm/Analysis/CFGPrinter.h include/llvm/Support/DOTGraphTraits.h include/llvm/Support/GraphWriter.h lib/Analysis/DomPrinter.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/ScheduleDAGPrinter.cpp lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp tools/opt/GraphPrinters.cpp Message-ID: <200911301238.nAUCcD5U009475@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 06:38:13 2009 New Revision: 90133 URL: http://llvm.org/viewvc/llvm-project?rev=90133&view=rev Log: Instantiate DefaultDOTGraphTraits Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h llvm/trunk/include/llvm/Support/DOTGraphTraits.h llvm/trunk/include/llvm/Support/GraphWriter.h llvm/trunk/lib/Analysis/DomPrinter.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp llvm/trunk/tools/opt/GraphPrinters.cpp Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Mon Nov 30 06:38:13 2009 @@ -24,6 +24,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static std::string getGraphName(const Function *F) { return "CFG for '" + F->getNameStr() + "' function"; } Modified: llvm/trunk/include/llvm/Support/DOTGraphTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DOTGraphTraits.h?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DOTGraphTraits.h (original) +++ llvm/trunk/include/llvm/Support/DOTGraphTraits.h Mon Nov 30 06:38:13 2009 @@ -27,6 +27,17 @@ /// implementations. /// struct DefaultDOTGraphTraits { +private: + bool IsSimple; + +protected: + bool isSimple() { + return IsSimple; + } + +public: + DefaultDOTGraphTraits (bool simple=false) : IsSimple (simple) {} + /// getGraphName - Return the label for the graph as a whole. Printed at the /// top of the graph. /// @@ -135,7 +146,9 @@ /// from DefaultDOTGraphTraits if you don't need to override everything. /// template -struct DOTGraphTraits : public DefaultDOTGraphTraits {}; +struct DOTGraphTraits : public DefaultDOTGraphTraits { + DOTGraphTraits (bool simple=false) : DefaultDOTGraphTraits (simple) {} +}; } // End llvm namespace Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 06:38:13 2009 @@ -59,6 +59,7 @@ typedef typename GTraits::NodeType NodeType; typedef typename GTraits::nodes_iterator node_iterator; typedef typename GTraits::ChildIteratorType child_iterator; + DOTTraits DTraits; // Writes the edge labels of the node to O and returns true if there are any // edge labels not equal to the empty string "". @@ -68,7 +69,7 @@ bool hasEdgeSourceLabels = false; for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - std::string label = DOTTraits::getEdgeSourceLabel(Node, EI); + std::string label = DTraits.getEdgeSourceLabel(Node, EI); if (label == "") continue; @@ -78,7 +79,7 @@ if (i) O << "|"; - O << "" << DOTTraits::getEdgeSourceLabel(Node, EI); + O << "" << DTraits.getEdgeSourceLabel(Node, EI); } if (EI != EE && hasEdgeSourceLabels) @@ -89,10 +90,12 @@ public: GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : - O(o), G(g), ShortNames(SN) {} + O(o), G(g), ShortNames(SN) { + DTraits = DOTTraits(SN); +} void writeHeader(const std::string &Name) { - std::string GraphName = DOTTraits::getGraphName(G); + std::string GraphName = DTraits.getGraphName(G); if (!Name.empty()) O << "digraph \"" << DOT::EscapeString(Name) << "\" {\n"; @@ -101,14 +104,14 @@ else O << "digraph unnamed {\n"; - if (DOTTraits::renderGraphFromBottomUp()) + if (DTraits.renderGraphFromBottomUp()) O << "\trankdir=\"BT\";\n"; if (!Name.empty()) O << "\tlabel=\"" << DOT::EscapeString(Name) << "\";\n"; else if (!GraphName.empty()) O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n"; - O << DOTTraits::getGraphProperties(G); + O << DTraits.getGraphProperties(G); O << "\n"; } @@ -133,17 +136,17 @@ } void writeNode(NodeType *Node) { - std::string NodeAttributes = DOTTraits::getNodeAttributes(Node, G); + std::string NodeAttributes = DTraits.getNodeAttributes(Node, G); O << "\tNode" << static_cast(Node) << " [shape=record,"; if (!NodeAttributes.empty()) O << NodeAttributes << ","; O << "label=\"{"; - if (!DOTTraits::renderGraphFromBottomUp()) { - O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G, ShortNames)); + if (!DTraits.renderGraphFromBottomUp()) { + O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames)); // If we should include the address of the node in the label, do so now. - if (DOTTraits::hasNodeAddressLabel(Node, G)) + if (DTraits.hasNodeAddressLabel(Node, G)) O << "|" << (void*)Node; } @@ -152,28 +155,28 @@ bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node); if (hasEdgeSourceLabels) { - if (!DOTTraits::renderGraphFromBottomUp()) O << "|"; + if (!DTraits.renderGraphFromBottomUp()) O << "|"; O << "{" << EdgeSourceLabels.str() << "}"; - if (DOTTraits::renderGraphFromBottomUp()) O << "|"; + if (DTraits.renderGraphFromBottomUp()) O << "|"; } - if (DOTTraits::renderGraphFromBottomUp()) { - O << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G, ShortNames)); + if (DTraits.renderGraphFromBottomUp()) { + O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames)); // If we should include the address of the node in the label, do so now. - if (DOTTraits::hasNodeAddressLabel(Node, G)) + if (DTraits.hasNodeAddressLabel(Node, G)) O << "|" << (void*)Node; } - if (DOTTraits::hasEdgeDestLabels()) { + if (DTraits.hasEdgeDestLabels()) { O << "|{"; - unsigned i = 0, e = DOTTraits::numEdgeDestLabels(Node); + unsigned i = 0, e = DTraits.numEdgeDestLabels(Node); for (; i != e && i != 64; ++i) { if (i) O << "|"; - O << "" << DOTTraits::getEdgeDestLabel(Node, i); + O << "" << DTraits.getEdgeDestLabel(Node, i); } if (i != e) @@ -195,8 +198,8 @@ void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { if (NodeType *TargetNode = *EI) { int DestPort = -1; - if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { - child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); + if (DTraits.edgeTargetsEdgeSource(Node, EI)) { + child_iterator TargetIt = DTraits.getEdgeTarget(Node, EI); // Figure out which edge this targets... unsigned Offset = @@ -204,12 +207,12 @@ DestPort = static_cast(Offset); } - if (DOTTraits::getEdgeSourceLabel(Node, EI) == "") + if (DTraits.getEdgeSourceLabel(Node, EI) == "") edgeidx = -1; emitEdge(static_cast(Node), edgeidx, static_cast(TargetNode), DestPort, - DOTTraits::getEdgeAttributes(Node, EI)); + DTraits.getEdgeAttributes(Node, EI)); } } @@ -247,7 +250,7 @@ if (SrcNodePort >= 0) O << ":s" << SrcNodePort; O << " -> Node" << DestNodeID; - if (DestNodePort >= 0 && DOTTraits::hasEdgeDestLabels()) + if (DestNodePort >= 0 && DTraits.hasEdgeDestLabels()) O << ":d" << DestNodePort; if (!Attrs.empty()) Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DomPrinter.cpp (original) +++ llvm/trunk/lib/Analysis/DomPrinter.cpp Mon Nov 30 06:38:13 2009 @@ -30,6 +30,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph, bool ShortNames) { @@ -46,6 +49,9 @@ template<> struct DOTGraphTraits : public DOTGraphTraits { + DOTGraphTraits (bool isSimple=false) + : DOTGraphTraits(isSimple) {} + static std::string getGraphName(DominatorTree *DT) { return "Dominator tree"; } @@ -61,6 +67,10 @@ template<> struct DOTGraphTraits : public DOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) + : DOTGraphTraits(isSimple) {} + static std::string getGraphName(PostDominatorTree *DT) { return "Post dominator tree"; } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Nov 30 06:38:13 2009 @@ -359,6 +359,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static std::string getGraphName(const MachineFunction *F) { return "CFG for '" + F->getFunction()->getNameStr() + "' function"; } Modified: llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp Mon Nov 30 06:38:13 2009 @@ -32,6 +32,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static std::string getGraphName(const ScheduleDAG *G) { return G->MF.getFunction()->getName(); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Nov 30 06:38:13 2009 @@ -35,6 +35,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static bool hasEdgeDestLabels() { return true; } @@ -48,8 +51,8 @@ } /// edgeTargetsEdgeSource - This method returns true if this outgoing edge - /// should actually target another edge source, not a node. If this method is - /// implemented, getEdgeTarget should be implemented. + /// should actually target another edge source, not a node. If this method + /// is implemented, getEdgeTarget should be implemented. template static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) { return true; Modified: llvm/trunk/tools/opt/GraphPrinters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/GraphPrinters.cpp?rev=90133&r1=90132&r2=90133&view=diff ============================================================================== --- llvm/trunk/tools/opt/GraphPrinters.cpp (original) +++ llvm/trunk/tools/opt/GraphPrinters.cpp Mon Nov 30 06:38:13 2009 @@ -46,6 +46,9 @@ namespace llvm { template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { + + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + static std::string getGraphName(CallGraph *F) { return "Call Graph"; } From grosser at fim.uni-passau.de Mon Nov 30 06:38:47 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 12:38:47 -0000 Subject: [llvm-commits] [llvm] r90134 - in /llvm/trunk: include/llvm/Analysis/CFGPrinter.h include/llvm/Support/DOTGraphTraits.h include/llvm/Support/GraphWriter.h lib/Analysis/DomPrinter.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/ScheduleDAGPrinter.cpp lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp tools/opt/GraphPrinters.cpp Message-ID: <200911301238.nAUCclwf009512@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 06:38:47 2009 New Revision: 90134 URL: http://llvm.org/viewvc/llvm-project?rev=90134&view=rev Log: Remove ShortNames from getNodeLabel in DOTGraphTraits Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h llvm/trunk/include/llvm/Support/DOTGraphTraits.h llvm/trunk/include/llvm/Support/GraphWriter.h llvm/trunk/lib/Analysis/DomPrinter.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp llvm/trunk/tools/opt/GraphPrinters.cpp Modified: llvm/trunk/include/llvm/Analysis/CFGPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/CFGPrinter.h?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/CFGPrinter.h (original) +++ llvm/trunk/include/llvm/Analysis/CFGPrinter.h Mon Nov 30 06:38:47 2009 @@ -31,19 +31,22 @@ return "CFG for '" + F->getNameStr() + "' function"; } - static std::string getNodeLabel(const BasicBlock *Node, - const Function *Graph, - bool ShortNames) { - if (ShortNames && !Node->getName().empty()) + static std::string getSimpleNodeLabel(const BasicBlock *Node, + const Function *Graph) { + if (!Node->getName().empty()) return Node->getNameStr(); std::string Str; raw_string_ostream OS(Str); - if (ShortNames) { - WriteAsOperand(OS, Node, false); - return OS.str(); - } + WriteAsOperand(OS, Node, false); + return OS.str(); + } + + static std::string getCompleteNodeLabel(const BasicBlock *Node, + const Function *Graph) { + std::string Str; + raw_string_ostream OS(Str); if (Node->getName().empty()) { WriteAsOperand(OS, Node, false); @@ -68,6 +71,14 @@ return OutStr; } + std::string getNodeLabel(const BasicBlock *Node, + const Function *Graph) { + if (isSimple()) + return getSimpleNodeLabel(Node, Graph); + else + return getCompleteNodeLabel(Node, Graph); + } + static std::string getEdgeSourceLabel(const BasicBlock *Node, succ_const_iterator I) { // Label source of conditional branches with "T" or "F" Modified: llvm/trunk/include/llvm/Support/DOTGraphTraits.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DOTGraphTraits.h?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DOTGraphTraits.h (original) +++ llvm/trunk/include/llvm/Support/DOTGraphTraits.h Mon Nov 30 06:38:47 2009 @@ -62,8 +62,7 @@ /// getNodeLabel - Given a node and a pointer to the top level graph, return /// the label to print in the node. template - static std::string getNodeLabel(const void *Node, - const GraphType& Graph, bool ShortNames) { + std::string getNodeLabel(const void *Node, const GraphType& Graph) { return ""; } Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 06:38:47 2009 @@ -52,7 +52,6 @@ class GraphWriter { raw_ostream &O; const GraphType &G; - bool ShortNames; typedef DOTGraphTraits DOTTraits; typedef GraphTraits GTraits; @@ -89,8 +88,7 @@ } public: - GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : - O(o), G(g), ShortNames(SN) { + GraphWriter(raw_ostream &o, const GraphType &g, bool SN) : O(o), G(g) { DTraits = DOTTraits(SN); } @@ -143,7 +141,7 @@ O << "label=\"{"; if (!DTraits.renderGraphFromBottomUp()) { - O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames)); + O << DOT::EscapeString(DTraits.getNodeLabel(Node, G)); // If we should include the address of the node in the label, do so now. if (DTraits.hasNodeAddressLabel(Node, G)) @@ -163,7 +161,7 @@ } if (DTraits.renderGraphFromBottomUp()) { - O << DOT::EscapeString(DTraits.getNodeLabel(Node, G, ShortNames)); + O << DOT::EscapeString(DTraits.getNodeLabel(Node, G)); // If we should include the address of the node in the label, do so now. if (DTraits.hasNodeAddressLabel(Node, G)) Modified: llvm/trunk/lib/Analysis/DomPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DomPrinter.cpp?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DomPrinter.cpp (original) +++ llvm/trunk/lib/Analysis/DomPrinter.cpp Mon Nov 30 06:38:47 2009 @@ -31,18 +31,23 @@ template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { - DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + DOTGraphTraits (bool isSimple=false) + : DefaultDOTGraphTraits(isSimple) {} - static std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph, - bool ShortNames) { + std::string getNodeLabel(DomTreeNode *Node, DomTreeNode *Graph) { BasicBlock *BB = Node->getBlock(); if (!BB) return "Post dominance root node"; - return DOTGraphTraits::getNodeLabel(BB, BB->getParent(), - ShortNames); + + if (isSimple()) + return DOTGraphTraits + ::getSimpleNodeLabel(BB, BB->getParent()); + else + return DOTGraphTraits + ::getCompleteNodeLabel(BB, BB->getParent()); } }; @@ -56,11 +61,8 @@ return "Dominator tree"; } - static std::string getNodeLabel(DomTreeNode *Node, - DominatorTree *G, - bool ShortNames) { - return DOTGraphTraits::getNodeLabel(Node, G->getRootNode(), - ShortNames); + std::string getNodeLabel(DomTreeNode *Node, DominatorTree *G) { + return DOTGraphTraits::getNodeLabel(Node, G->getRootNode()); } }; @@ -74,12 +76,9 @@ static std::string getGraphName(PostDominatorTree *DT) { return "Post dominator tree"; } - static std::string getNodeLabel(DomTreeNode *Node, - PostDominatorTree *G, - bool ShortNames) { - return DOTGraphTraits::getNodeLabel(Node, - G->getRootNode(), - ShortNames); + + std::string getNodeLabel(DomTreeNode *Node, PostDominatorTree *G ) { + return DOTGraphTraits::getNodeLabel(Node, G->getRootNode()); } }; } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Nov 30 06:38:47 2009 @@ -366,10 +366,9 @@ return "CFG for '" + F->getFunction()->getNameStr() + "' function"; } - static std::string getNodeLabel(const MachineBasicBlock *Node, - const MachineFunction *Graph, - bool ShortNames) { - if (ShortNames && Node->getBasicBlock() && + std::string getNodeLabel(const MachineBasicBlock *Node, + const MachineFunction *Graph) { + if (isSimple () && Node->getBasicBlock() && !Node->getBasicBlock()->getName().empty()) return Node->getBasicBlock()->getNameStr() + ":"; @@ -377,7 +376,7 @@ { raw_string_ostream OSS(OutStr); - if (ShortNames) + if (isSimple()) OSS << Node->getNumber() << ':'; else Node->print(OSS); Modified: llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGPrinter.cpp Mon Nov 30 06:38:47 2009 @@ -60,9 +60,7 @@ } - static std::string getNodeLabel(const SUnit *Node, - const ScheduleDAG *Graph, - bool ShortNames); + std::string getNodeLabel(const SUnit *Node, const ScheduleDAG *Graph); static std::string getNodeAttributes(const SUnit *N, const ScheduleDAG *Graph) { return "shape=Mrecord"; @@ -76,8 +74,7 @@ } std::string DOTGraphTraits::getNodeLabel(const SUnit *SU, - const ScheduleDAG *G, - bool ShortNames) { + const ScheduleDAG *G) { return G->getGraphNodeLabel(SU); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Nov 30 06:38:47 2009 @@ -96,9 +96,16 @@ } - static std::string getNodeLabel(const SDNode *Node, - const SelectionDAG *Graph, - bool ShortNames); + static std::string getSimpleNodeLabel(const SDNode *Node, + const SelectionDAG *G) { + std::string Result = Node->getOperationName(G); + { + raw_string_ostream OS(Result); + Node->print_details(OS, G); + } + return Result; + } + std::string getNodeLabel(const SDNode *Node, const SelectionDAG *Graph); static std::string getNodeAttributes(const SDNode *N, const SelectionDAG *Graph) { #ifndef NDEBUG @@ -124,14 +131,8 @@ } std::string DOTGraphTraits::getNodeLabel(const SDNode *Node, - const SelectionDAG *G, - bool ShortNames) { - std::string Result = Node->getOperationName(G); - { - raw_string_ostream OS(Result); - Node->print_details(OS, G); - } - return Result; + const SelectionDAG *G) { + DOTGraphTraits::getSimpleNodeLabel (Node, G); } @@ -272,8 +273,8 @@ for (SDNode *N = SU->getNode(); N; N = N->getFlaggedNode()) FlaggedNodes.push_back(N); while (!FlaggedNodes.empty()) { - O << DOTGraphTraits::getNodeLabel(FlaggedNodes.back(), - DAG, false); + O << DOTGraphTraits + ::getSimpleNodeLabel(FlaggedNodes.back(), DAG); FlaggedNodes.pop_back(); if (!FlaggedNodes.empty()) O << "\n "; Modified: llvm/trunk/tools/opt/GraphPrinters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/GraphPrinters.cpp?rev=90134&r1=90133&r2=90134&view=diff ============================================================================== --- llvm/trunk/tools/opt/GraphPrinters.cpp (original) +++ llvm/trunk/tools/opt/GraphPrinters.cpp Mon Nov 30 06:38:47 2009 @@ -53,8 +53,7 @@ return "Call Graph"; } - static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph, - bool ShortNames) { + static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) { if (Node->getFunction()) return ((Value*)Node->getFunction())->getName(); else From grosser at fim.uni-passau.de Mon Nov 30 07:14:14 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 13:14:14 -0000 Subject: [llvm-commits] [llvm] r90135 - in /llvm/trunk: include/llvm/ADT/Trie.h lib/CompilerDriver/CompilationGraph.cpp Message-ID: <200911301314.nAUDEEDY010658@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 07:14:13 2009 New Revision: 90135 URL: http://llvm.org/viewvc/llvm-project?rev=90135&view=rev Log: Remove forgotten ShortNames in Trie and CompilationGraph Modified: llvm/trunk/include/llvm/ADT/Trie.h llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Modified: llvm/trunk/include/llvm/ADT/Trie.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Trie.h?rev=90135&r1=90134&r2=90135&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Trie.h (original) +++ llvm/trunk/include/llvm/ADT/Trie.h Mon Nov 30 07:14:13 2009 @@ -309,8 +309,7 @@ return "Trie"; } - static std::string getNodeLabel(NodeType* Node, const Trie& T, - bool ShortNames) { + static std::string getNodeLabel(NodeType* Node, const Trie& T) { if (T.getRoot() == Node) return ""; else Modified: llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp?rev=90135&r1=90134&r2=90135&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp (original) +++ llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Mon Nov 30 07:14:13 2009 @@ -473,8 +473,7 @@ { template - static std::string getNodeLabel(const Node* N, const GraphType&, - bool ShortNames) + static std::string getNodeLabel(const Node* N, const GraphType&) { if (N->ToolPtr) if (N->ToolPtr->IsJoin()) From grosser at fim.uni-passau.de Mon Nov 30 07:34:51 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 13:34:51 -0000 Subject: [llvm-commits] [llvm] r90136 - in /llvm/trunk/lib: CodeGen/SelectionDAG/SelectionDAGPrinter.cpp CompilerDriver/CompilationGraph.cpp Message-ID: <200911301334.nAUDYpRQ011329@zion.cs.uiuc.edu> Author: grosser Date: Mon Nov 30 07:34:51 2009 New Revision: 90136 URL: http://llvm.org/viewvc/llvm-project?rev=90136&view=rev Log: Fix last DOTGraphTraits problems in CompilationGraph. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90136&r1=90135&r2=90136&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Mon Nov 30 07:34:51 2009 @@ -132,7 +132,7 @@ std::string DOTGraphTraits::getNodeLabel(const SDNode *Node, const SelectionDAG *G) { - DOTGraphTraits::getSimpleNodeLabel (Node, G); + return DOTGraphTraits::getSimpleNodeLabel (Node, G); } Modified: llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp?rev=90136&r1=90135&r2=90136&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp (original) +++ llvm/trunk/lib/CompilerDriver/CompilationGraph.cpp Mon Nov 30 07:34:51 2009 @@ -471,6 +471,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { + DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} template static std::string getNodeLabel(const Node* N, const GraphType&) From benny.kra at googlemail.com Mon Nov 30 09:52:29 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 30 Nov 2009 15:52:29 -0000 Subject: [llvm-commits] [llvm] r90138 - /llvm/trunk/include/llvm/Support/GraphWriter.h Message-ID: <200911301552.nAUFqTg4016534@zion.cs.uiuc.edu> Author: d0k Date: Mon Nov 30 09:52:29 2009 New Revision: 90138 URL: http://llvm.org/viewvc/llvm-project?rev=90138&view=rev Log: Fix odd declaration. Modified: llvm/trunk/include/llvm/Support/GraphWriter.h Modified: llvm/trunk/include/llvm/Support/GraphWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GraphWriter.h?rev=90138&r1=90137&r2=90138&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GraphWriter.h (original) +++ llvm/trunk/include/llvm/Support/GraphWriter.h Mon Nov 30 09:52:29 2009 @@ -149,7 +149,7 @@ } std::string edgeSourceLabels; - raw_string_ostream::raw_string_ostream EdgeSourceLabels(edgeSourceLabels); + raw_string_ostream EdgeSourceLabels(edgeSourceLabels); bool hasEdgeSourceLabels = getEdgeSourceLabels(EdgeSourceLabels, Node); if (hasEdgeSourceLabels) { From grosser at fim.uni-passau.de Mon Nov 30 10:02:12 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 30 Nov 2009 17:02:12 +0100 Subject: [llvm-commits] [llvm] r90138 - /llvm/trunk/include/llvm/Support/GraphWriter.h In-Reply-To: <4074_1259596404_4B13EA74_4074_34_1_200911301552.nAUFqTg4016534@zion.cs.uiuc.edu> References: <4074_1259596404_4B13EA74_4074_34_1_200911301552.nAUFqTg4016534@zion.cs.uiuc.edu> Message-ID: <1259596932.18675.74.camel@tobilaptop.fritz.box> On Mon, 2009-11-30 at 15:52 +0000, Benjamin Kramer wrote: > Author: d0k > Date: Mon Nov 30 09:52:29 2009 > New Revision: 90138 > > URL: http://llvm.org/viewvc/llvm-project?rev=90138&view=rev > Log: > Fix odd declaration. Thanks. Tobias From bob.wilson at apple.com Mon Nov 30 11:47:19 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 30 Nov 2009 17:47:19 -0000 Subject: [llvm-commits] [llvm] r90141 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <200911301747.nAUHlJRA020864@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 30 11:47:19 2009 New Revision: 90141 URL: http://llvm.org/viewvc/llvm-project?rev=90141&view=rev Log: Fix some more ARM unified syntax warnings. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=90141&r1=90140&r2=90141&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Nov 30 11:47:19 2009 @@ -600,19 +600,19 @@ [(set GPR:$dst, (load addrmodepc:$addr))]>; def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), - Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}h\t$dst, $addr", + Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrh${p}\t$dst, $addr", [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>; def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), - Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}b\t$dst, $addr", + Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrb${p}\t$dst, $addr", [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>; def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), - Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sh\t$dst, $addr", + Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsh${p}\t$dst, $addr", [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>; def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), - Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sb\t$dst, $addr", + Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldrsb${p}\t$dst, $addr", [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>; } let AddedComplexity = 10 in { From devang.patel at gmail.com Mon Nov 30 11:54:48 2009 From: devang.patel at gmail.com (Devang Patel) Date: Mon, 30 Nov 2009 09:54:48 -0800 Subject: [llvm-commits] [PATCH] LTO code generator options In-Reply-To: <4B0EFE1E.3000000@mxc.ca> References: <04F6B1512E264B27AEE607542FCDD113@andreic6e7fe55> <38a0d8450911200722i5efa690ci6ab671d71b5f40dc@mail.gmail.com> <38a0d8450911231309t6f37e2a0ga7c9eaa50d495c60@mail.gmail.com> <2E9E5BD4D91C4B32850CD83726EFE19B@andreic6e7fe55> <352a1fb20911241558o4131950di5e3bac9db3a31e30@mail.gmail.com> <3780A335BCB5498984B6E0408C2EDB0D@andreic6e7fe55> <352a1fb20911250925q4d4b8b9fwae1ac454f4c0341c@mail.gmail.com> <4B0EFE1E.3000000@mxc.ca> Message-ID: <352a1fb20911300954n295bfcdeme0156f15e8e0cb6b@mail.gmail.com> On Thu, Nov 26, 2009 at 2:15 PM, Nick Lewycky wrote: > Devang Patel wrote: >> >> 3 - It is quite reasonable for some to put two copies of a function, >> one for SSE3 machines, one for non-SSE machines, in one bitcode file >> and let code generator generate appropriate code for each functions so >> that the user can select desired function at run time. At Apple, we >> supported similar requirements for Altivec vs. non-Altivec code. This >> can be achieved if subtarget features like SSE3 are encoded in bitcode >> files. > > Now that's an interesting idea. There's one obvious major issue with it, > which is that we would end up with two different function definitions with > the same name. Name does not need to match to generate CPU specific code for each function in one object file! If user is inserting runtime check to invoke specific function then user took care of function names. If the compiler is inserting runtime check to invoke optimized function the compiler should do the right thing. > Assuming we can overcome that, we then run into issues with > (for example) the inliner being unable to inline a function because it > doesn't know what the subtarget is. We discussed at length (may be I am understating this :), what inliner should do. Summary, when such functino attributes are introduced, the inliner must be updated to do the right thing. - Devang From bob.wilson at apple.com Mon Nov 30 12:35:03 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 30 Nov 2009 18:35:03 -0000 Subject: [llvm-commits] [llvm] r90144 - in /llvm/trunk: include/llvm/Target/TargetInstrInfo.h lib/CodeGen/TailDuplication.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/PowerPC/PPCInstrInfo.h lib/Target/X86/X86InstrInfo.h Message-ID: <200911301835.nAUIZ4Km022612@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 30 12:35:03 2009 New Revision: 90144 URL: http://llvm.org/viewvc/llvm-project?rev=90144&view=rev Log: Remove isProfitableToDuplicateIndirectBranch target hook. It is profitable for all the processors where I have tried it, and even when it might not help performance, the cost is quite low. The opportunities for duplicating indirect branches are limited by other factors so code size does not change much due to tail duplicating indirect branches aggressively. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/CodeGen/TailDuplication.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Mon Nov 30 12:35:03 2009 @@ -543,10 +543,6 @@ /// length. virtual unsigned getInlineAsmLength(const char *Str, const MCAsmInfo &MAI) const; - - /// isProfitableToDuplicateIndirectBranch - Returns true if tail duplication - /// is especially profitable for indirect branches. - virtual bool isProfitableToDuplicateIndirectBranch() const { return false; } }; /// TargetInstrInfoImpl - This is the default implementation of Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Mon Nov 30 12:35:03 2009 @@ -118,8 +118,7 @@ unsigned MaxDuplicateCount; if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) MaxDuplicateCount = 1; - else if (TII->isProfitableToDuplicateIndirectBranch() && - !TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) + else if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Mon Nov 30 12:35:03 2009 @@ -1027,12 +1027,6 @@ return TargetInstrInfoImpl::isIdentical(MI0, MI1, MRI); } -bool ARMBaseInstrInfo::isProfitableToDuplicateIndirectBranch() const { - // If the target processor can predict indirect branches, it is highly - // desirable to duplicate them, since it can often make them predictable. - return getSubtarget().hasBranchTargetBuffer(); -} - /// getInstrPredicate - If instruction is predicated, returns its predicate /// condition, otherwise returns AL. It also returns the condition code /// register by reference. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Mon Nov 30 12:35:03 2009 @@ -290,8 +290,6 @@ virtual bool isIdentical(const MachineInstr *MI, const MachineInstr *Other, const MachineRegisterInfo *MRI) const; - - virtual bool isProfitableToDuplicateIndirectBranch() const; }; static inline Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Mon Nov 30 12:35:03 2009 @@ -114,8 +114,6 @@ if (UseNEONFP.getPosition() == 0) UseNEONForSinglePrecisionFP = true; } - HasBranchTargetBuffer = (CPUString == "cortex-a8" || - CPUString == "cortex-a9"); } /// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Nov 30 12:35:03 2009 @@ -50,9 +50,6 @@ /// determine if NEON should actually be used. bool UseNEONForSinglePrecisionFP; - /// HasBranchTargetBuffer - True if processor can predict indirect branches. - bool HasBranchTargetBuffer; - /// IsThumb - True if we are in thumb mode, false if in ARM mode. bool IsThumb; @@ -130,8 +127,6 @@ bool isThumb2() const { return IsThumb && (ThumbMode == Thumb2); } bool hasThumb2() const { return ThumbMode >= Thumb2; } - bool hasBranchTargetBuffer() const { return HasBranchTargetBuffer; } - bool isR9Reserved() const { return IsR9Reserved; } bool useMovt() const { return UseMovt && hasV6T2Ops(); } Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h Mon Nov 30 12:35:03 2009 @@ -151,8 +151,6 @@ /// instruction may be. This returns the maximum number of bytes. /// virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const; - - virtual bool isProfitableToDuplicateIndirectBranch() const { return true; } }; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=90144&r1=90143&r2=90144&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Nov 30 12:35:03 2009 @@ -632,8 +632,6 @@ /// unsigned getGlobalBaseReg(MachineFunction *MF) const; - virtual bool isProfitableToDuplicateIndirectBranch() const { return true; } - private: MachineInstr* foldMemoryOperandImpl(MachineFunction &MF, MachineInstr* MI, From bob.wilson at apple.com Mon Nov 30 12:56:45 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 30 Nov 2009 18:56:45 -0000 Subject: [llvm-commits] [llvm] r90147 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <200911301856.nAUIuj6R023699@zion.cs.uiuc.edu> Author: bwilson Date: Mon Nov 30 12:56:45 2009 New Revision: 90147 URL: http://llvm.org/viewvc/llvm-project?rev=90147&view=rev Log: Reprioritize tests for tail duplication to be aggressive about indirect branches even when optimizing for code size. Unless we find evidence to the contrary in the future, the special treatment for indirect branches does not have a significant effect on code size, and performance still matters with -Os. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90147&r1=90146&r2=90147&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Mon Nov 30 12:56:45 2009 @@ -116,14 +116,14 @@ // duplicate only one, because one branch instruction can be eliminated to // compensate for the duplication. unsigned MaxDuplicateCount; - if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) - MaxDuplicateCount = 1; - else if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) + if (!TailBB->empty() && TailBB->back().getDesc().isIndirectBranch()) // If the target has hardware branch prediction that can handle indirect // branches, duplicating them can often make them predictable when there // are common paths through the code. The limit needs to be high enough // to allow undoing the effects of tail merging. MaxDuplicateCount = 20; + else if (MF.getFunction()->hasFnAttr(Attribute::OptimizeForSize)) + MaxDuplicateCount = 1; else MaxDuplicateCount = TailDuplicateSize; From baldrick at free.fr Mon Nov 30 14:00:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 30 Nov 2009 20:00:11 -0000 Subject: [llvm-commits] [dragonegg] r90150 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200911302000.nAUK0B67026138@zion.cs.uiuc.edu> Author: baldrick Date: Mon Nov 30 14:00:11 2009 New Revision: 90150 URL: http://llvm.org/viewvc/llvm-project?rev=90150&view=rev Log: Always handle VIEW_CONVERT_EXPR via load-of-lvalue rather than trying to do it directly. This deletes a bunch of code for little (maybe no) cost. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90150&r1=90149&r2=90150&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Mon Nov 30 14:00:11 2009 @@ -1181,15 +1181,16 @@ //FIXME case FILTER_EXPR: Result = EmitFILTER_EXPR(exp); break; // Expressions - case VAR_DECL: - case PARM_DECL: - case RESULT_DECL: - case INDIRECT_REF: case ARRAY_REF: case ARRAY_RANGE_REF: - case COMPONENT_REF: case BIT_FIELD_REF: + case COMPONENT_REF: + case INDIRECT_REF: + case PARM_DECL: + case RESULT_DECL: case STRING_CST: + case VAR_DECL: + case VIEW_CONVERT_EXPR: Result = EmitLoadOfLValue(exp, DestLoc); break; case SSA_NAME: Result = EmitSSA_NAME(exp); break; @@ -1199,7 +1200,6 @@ // Unary Operators case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break; case IMAGPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 1); break; - case VIEW_CONVERT_EXPR: Result = EmitVIEW_CONVERT_EXPR(exp, DestLoc); break; case CONSTRUCTOR: Result = EmitCONSTRUCTOR(exp, DestLoc); break; // Complex Math Expressions. @@ -1247,7 +1247,6 @@ /// EmitLV - Convert the specified l-value tree node to LLVM code, returning /// the address of the result. LValue TreeToLLVM::EmitLV(tree exp) { - // Needs to be in sync with EmitVIEW_CONVERT_EXPR. LValue LV; switch (TREE_CODE(exp)) { @@ -3026,98 +3025,6 @@ return CastToAnyType(Emit(op, 0), OpIsSigned, ConvertType(type), ExpIsSigned); } -Value *TreeToLLVM::EmitVIEW_CONVERT_EXPR(tree exp, const MemRef *DestLoc) { - tree Op = TREE_OPERAND(exp, 0); - - if (AGGREGATE_TYPE_P(TREE_TYPE(Op))) { - MemRef Target; - if (DestLoc) - // This is an aggregate-to-agg VIEW_CONVERT_EXPR, just evaluate in place. - Target = *DestLoc; - else - // This is an aggregate-to-scalar VIEW_CONVERT_EXPR, evaluate, then load. - Target = CreateTempLoc(ConvertType(TREE_TYPE(exp))); - - // Make the destination look like the source type. - const Type *OpTy = ConvertType(TREE_TYPE(Op)); - Target.Ptr = Builder.CreateBitCast(Target.Ptr, OpTy->getPointerTo()); - - // Needs to be in sync with EmitLV. - switch (TREE_CODE(Op)) { - default: { - Value *OpVal = Emit(Op, &Target); - (void)OpVal; - assert(OpVal == 0 && "Expected an aggregate operand!"); - break; - } - - // Lvalues - case VAR_DECL: - case PARM_DECL: - case RESULT_DECL: - case INDIRECT_REF: - case ARRAY_REF: - case ARRAY_RANGE_REF: - case COMPONENT_REF: - case BIT_FIELD_REF: - case STRING_CST: - case REALPART_EXPR: - case IMAGPART_EXPR: - // Same as EmitLoadOfLValue but taking the size from TREE_TYPE(exp), since - // the size of TREE_TYPE(Op) may not be available. - LValue LV = EmitLV(Op); - assert(!LV.isBitfield() && "Expected an aggregate operand!"); - bool isVolatile = TREE_THIS_VOLATILE(Op); - unsigned Alignment = LV.getAlignment(); - - EmitAggregateCopy(Target, MemRef(LV.Ptr, Alignment, isVolatile), - TREE_TYPE(exp)); - break; - } - - if (DestLoc) - return 0; - - // Target holds the temporary created above. - const Type *ExpTy = ConvertType(TREE_TYPE(exp)); - return Builder.CreateLoad(Builder.CreateBitCast(Target.Ptr, - ExpTy->getPointerTo())); - } - - if (DestLoc) { - // The input is a scalar the output is an aggregate, just eval the input, - // then store into DestLoc. - Value *OpVal = Emit(Op, 0); - assert(OpVal && "Expected a scalar result!"); - Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, - PointerType::getUnqual(OpVal->getType())); - StoreInst *St = Builder.CreateStore(OpVal, Ptr, DestLoc->Volatile); - St->setAlignment(DestLoc->getAlignment()); - return 0; - } - - // Otherwise, this is a scalar to scalar conversion. - Value *OpVal = Emit(Op, 0); - assert(OpVal && "Expected a scalar result!"); - const Type *DestTy = ConvertType(TREE_TYPE(exp)); - - // If the source is a pointer, use ptrtoint to get it to something - // bitcast'able. This supports things like v_c_e(foo*, float). - if (isa(OpVal->getType())) { - if (isa(DestTy)) // ptr->ptr is a simple bitcast. - return Builder.CreateBitCast(OpVal, DestTy); - // Otherwise, ptrtoint to intptr_t first. - OpVal = Builder.CreatePtrToInt(OpVal, TD.getIntPtrType(Context)); - } - - // If the destination type is a pointer, use inttoptr. - if (isa(DestTy)) - return Builder.CreateIntToPtr(OpVal, DestTy); - - // Otherwise, use a bitcast. - return Builder.CreateBitCast(OpVal, DestTy); -} - Value *TreeToLLVM::EmitNEGATE_EXPR(tree op) { Value *V = Emit(op, 0); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90150&r1=90149&r2=90150&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Mon Nov 30 14:00:11 2009 @@ -636,7 +636,6 @@ const AttrListPtr &PAL); Value *EmitNOP_EXPR(tree_node *type, tree_node *op, const MemRef *DestLoc); Value *EmitCONVERT_EXPR(tree_node *type, tree_node *op); - Value *EmitVIEW_CONVERT_EXPR(tree_node *exp, const MemRef *DestLoc); Value *EmitNEGATE_EXPR(tree_node *op); Value *EmitCONJ_EXPR(tree_node *op); Value *EmitABS_EXPR(tree_node *op); From gohman at apple.com Mon Nov 30 14:43:30 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 12:43:30 -0800 Subject: [llvm-commits] [llvm] r89017 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp In-Reply-To: <09153601-5501-4785-A425-36C9F665A22F@apple.com> References: <200911170047.nAH0lNDT014760@zion.cs.uiuc.edu> <09153601-5501-4785-A425-36C9F665A22F@apple.com> Message-ID: <62C655D3-558C-4A97-968A-15B164A6D60B@apple.com> On Nov 22, 2009, at 7:03 AM, Chris Lattner wrote: > > On Nov 16, 2009, at 4:47 PM, Dan Gohman wrote: > >> Author: djg >> Date: Mon Nov 16 18:47:23 2009 >> New Revision: 89017 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89017&view=rev >> Log: >> Remove the optimizations that convert BRCOND and BR_CC into >> unconditional branches or fallthroghes. Instcombine/SimplifyCFG >> should be simplifying branches with known conditions. >> >> This fixes some problems caused by these transformations not >> updating the MachineBasicBlock CFG. > > Did you verify that this change doesn't result in any codegen change on something large like 403.gcc? It would also be useful to check something like crafty on x86-32 and ppc32. I had checked a bunch of stuff, though not 403.gcc, and it turns out 403.gcc had a missed ConstantExpr folding opportunity. I fixed that in r89659. Dan From wangmp at apple.com Mon Nov 30 14:44:18 2009 From: wangmp at apple.com (Mon Ping Wang) Date: Mon, 30 Nov 2009 12:44:18 -0800 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> Message-ID: If the machine supported a vector divide, it would be more efficient to copy the last value to the 4th element and then do the divide. For X86, there is no vector divide so it seems cleaner to me to do it this way. -- Mon Ping On Nov 29, 2009, at 8:21 PM, Chris Lattner wrote: > > On Nov 29, 2009, at 6:42 PM, Mon P Wang wrote: > >> Author: wangmp >> Date: Sun Nov 29 20:42:02 2009 >> New Revision: 90108 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90108&view=rev >> Log: >> Added support to allow clients to custom widen. For X86, custom widen vectors for >> divide/remainder since these operations can trap by unroll them and adding undefs >> for the resulting vector. > > Hi Mon Ping, > > For a vec3 divide, wouldn't it be more efficient to shuffle one of the three valid elements of the divisor into the fourth element, then do a vec4 divide? I'd think that one vec4 divide + shuffle would be faster than a bunch of extracts, scalar divs then reconstructions. > > -Chris > > >> >> Modified: >> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h >> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> >> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Sun Nov 29 20:42:02 2009 >> @@ -882,6 +882,14 @@ >> /// element of the result of the vector shuffle. >> SDValue getShuffleScalarElt(const ShuffleVectorSDNode *N, unsigned Idx); >> >> + /// UnrollVectorOp - Utility function used by legalize and lowering to >> + /// "unroll" a vector operation by splitting out the scalars and operating >> + /// on each element individually. If the ResNE is 0, fully unroll the vector >> + /// op. If ResNE is less than the width of the vector op, unroll up to ResNE. >> + /// If the ResNE is greater than the width of the vector op, unroll the >> + /// vector op and fill the end of the resulting vector with UNDEFS. >> + SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0); >> + >> private: >> bool RemoveNodeFromCSEMaps(SDNode *N); >> void AddModifiedNodeToCSEMaps(SDNode *N, DAGUpdateListener *UpdateListener); >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Sun Nov 29 20:42:02 2009 >> @@ -907,6 +907,29 @@ >> return true; >> } >> >> + >> +/// CustomWidenLowerNode - Widen the node's results with custom code provided >> +/// by the target and return "true", or do nothing and return "false". >> +bool DAGTypeLegalizer::CustomWidenLowerNode(SDNode *N, EVT VT) { >> + // See if the target wants to custom lower this node. >> + if (TLI.getOperationAction(N->getOpcode(), VT) != TargetLowering::Custom) >> + return false; >> + >> + SmallVector Results; >> + TLI.ReplaceNodeResults(N, Results, DAG); >> + >> + if (Results.empty()) >> + // The target didn't want to custom widen lower its result after all. >> + return false; >> + >> + // Update the widening map. >> + assert(Results.size() == N->getNumValues() && >> + "Custom lowering returned the wrong number of results!"); >> + for (unsigned i = 0, e = Results.size(); i != e; ++i) >> + SetWidenedVector(SDValue(N, i), Results[i]); >> + return true; >> +} >> + >> /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type >> /// which is split into two not necessarily identical pieces. >> void DAGTypeLegalizer::GetSplitDestVTs(EVT InVT, EVT &LoVT, EVT &HiVT) { >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Sun Nov 29 20:42:02 2009 >> @@ -188,6 +188,7 @@ >> SDValue BitConvertVectorToIntegerVector(SDValue Op); >> SDValue CreateStackStoreLoad(SDValue Op, EVT DestVT); >> bool CustomLowerNode(SDNode *N, EVT VT, bool LegalizeResult); >> + bool CustomWidenLowerNode(SDNode *N, EVT VT); >> SDValue GetVectorElementPointer(SDValue VecPtr, EVT EltVT, SDValue Index); >> SDValue JoinIntegers(SDValue Lo, SDValue Hi); >> SDValue LibCallify(RTLIB::Libcall LC, SDNode *N, bool isSigned); >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Sun Nov 29 20:42:02 2009 >> @@ -54,9 +54,6 @@ >> SDValue LegalizeOp(SDValue Op); >> // Assuming the node is legal, "legalize" the results >> SDValue TranslateLegalizeResults(SDValue Op, SDValue Result); >> - // Implements unrolling a generic vector operation, i.e. turning it into >> - // scalar operations. >> - SDValue UnrollVectorOp(SDValue Op); >> // Implements unrolling a VSETCC. >> SDValue UnrollVSETCC(SDValue Op); >> // Implements expansion for FNEG; falls back to UnrollVectorOp if FSUB >> @@ -211,7 +208,7 @@ >> else if (Node->getOpcode() == ISD::VSETCC) >> Result = UnrollVSETCC(Op); >> else >> - Result = UnrollVectorOp(Op); >> + Result = DAG.UnrollVectorOp(Op.getNode()); >> break; >> } >> >> @@ -256,7 +253,7 @@ >> return DAG.getNode(ISD::FSUB, Op.getDebugLoc(), Op.getValueType(), >> Zero, Op.getOperand(0)); >> } >> - return UnrollVectorOp(Op); >> + return DAG.UnrollVectorOp(Op.getNode()); >> } >> >> SDValue VectorLegalizer::UnrollVSETCC(SDValue Op) { >> @@ -282,56 +279,6 @@ >> return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Ops[0], NumElems); >> } >> >> -/// UnrollVectorOp - We know that the given vector has a legal type, however >> -/// the operation it performs is not legal, and the target has requested that >> -/// the operation be expanded. "Unroll" the vector, splitting out the scalars >> -/// and operating on each element individually. >> -SDValue VectorLegalizer::UnrollVectorOp(SDValue Op) { >> - EVT VT = Op.getValueType(); >> - assert(Op.getNode()->getNumValues() == 1 && >> - "Can't unroll a vector with multiple results!"); >> - unsigned NE = VT.getVectorNumElements(); >> - EVT EltVT = VT.getVectorElementType(); >> - DebugLoc dl = Op.getDebugLoc(); >> - >> - SmallVector Scalars; >> - SmallVector Operands(Op.getNumOperands()); >> - for (unsigned i = 0; i != NE; ++i) { >> - for (unsigned j = 0; j != Op.getNumOperands(); ++j) { >> - SDValue Operand = Op.getOperand(j); >> - EVT OperandVT = Operand.getValueType(); >> - if (OperandVT.isVector()) { >> - // A vector operand; extract a single element. >> - EVT OperandEltVT = OperandVT.getVectorElementType(); >> - Operands[j] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, >> - OperandEltVT, >> - Operand, >> - DAG.getConstant(i, MVT::i32)); >> - } else { >> - // A scalar operand; just use it as is. >> - Operands[j] = Operand; >> - } >> - } >> - >> - switch (Op.getOpcode()) { >> - default: >> - Scalars.push_back(DAG.getNode(Op.getOpcode(), dl, EltVT, >> - &Operands[0], Operands.size())); >> - break; >> - case ISD::SHL: >> - case ISD::SRA: >> - case ISD::SRL: >> - case ISD::ROTL: >> - case ISD::ROTR: >> - Scalars.push_back(DAG.getNode(Op.getOpcode(), dl, EltVT, Operands[0], >> - DAG.getShiftAmountOperand(Operands[1]))); >> - break; >> - } >> - } >> - >> - return DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &Scalars[0], Scalars.size()); >> -} >> - >> } >> >> bool SelectionDAG::LegalizeVectors() { >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Sun Nov 29 20:42:02 2009 >> @@ -1118,8 +1118,12 @@ >> DEBUG(errs() << "Widen node result " << ResNo << ": "; >> N->dump(&DAG); >> errs() << "\n"); >> - SDValue Res = SDValue(); >> >> + // See if the target wants to custom widen this node. >> + if (CustomWidenLowerNode(N, N->getValueType(ResNo))) >> + return; >> + >> + SDValue Res = SDValue(); >> switch (N->getOpcode()) { >> default: >> #ifndef NDEBUG >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Nov 29 20:42:02 2009 >> @@ -5807,6 +5807,66 @@ >> N->dump(G); >> } >> >> +SDValue SelectionDAG::UnrollVectorOp(SDNode *N, unsigned ResNE) { >> + assert(N->getNumValues() == 1 && >> + "Can't unroll a vector with multiple results!"); >> + >> + EVT VT = N->getValueType(0); >> + unsigned NE = VT.getVectorNumElements(); >> + EVT EltVT = VT.getVectorElementType(); >> + DebugLoc dl = N->getDebugLoc(); >> + >> + SmallVector Scalars; >> + SmallVector Operands(N->getNumOperands()); >> + >> + // If ResNE is 0, fully unroll the vector op. >> + if (ResNE == 0) >> + ResNE = NE; >> + else if (NE > ResNE) >> + NE = ResNE; >> + >> + unsigned i; >> + for (i= 0; i != NE; ++i) { >> + for (unsigned j = 0; j != N->getNumOperands(); ++j) { >> + SDValue Operand = N->getOperand(j); >> + EVT OperandVT = Operand.getValueType(); >> + if (OperandVT.isVector()) { >> + // A vector operand; extract a single element. >> + EVT OperandEltVT = OperandVT.getVectorElementType(); >> + Operands[j] = getNode(ISD::EXTRACT_VECTOR_ELT, dl, >> + OperandEltVT, >> + Operand, >> + getConstant(i, MVT::i32)); >> + } else { >> + // A scalar operand; just use it as is. >> + Operands[j] = Operand; >> + } >> + } >> + >> + switch (N->getOpcode()) { >> + default: >> + Scalars.push_back(getNode(N->getOpcode(), dl, EltVT, >> + &Operands[0], Operands.size())); >> + break; >> + case ISD::SHL: >> + case ISD::SRA: >> + case ISD::SRL: >> + case ISD::ROTL: >> + case ISD::ROTR: >> + Scalars.push_back(getNode(N->getOpcode(), dl, EltVT, Operands[0], >> + getShiftAmountOperand(Operands[1]))); >> + break; >> + } >> + } >> + >> + for (; i < ResNE; ++i) >> + Scalars.push_back(getUNDEF(EltVT)); >> + >> + return getNode(ISD::BUILD_VECTOR, dl, >> + EVT::getVectorVT(*getContext(), EltVT, ResNE), >> + &Scalars[0], Scalars.size()); >> +} >> + >> void SelectionDAG::dump() const { >> errs() << "SelectionDAG has " << AllNodes.size() << " nodes:"; >> >> @@ -5962,3 +6022,4 @@ >> return false; >> return true; >> } >> + >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=90108&r1=90107&r2=90108&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Nov 29 20:42:02 2009 >> @@ -975,6 +975,19 @@ >> >> computeRegisterProperties(); >> >> + // Divide and reminder operations have no vector equivalent and can >> + // trap. Do a custom widening for these operations in which we never >> + // generate more divides/remainder than the original vector width. >> + for (unsigned VT = (unsigned)MVT::FIRST_VECTOR_VALUETYPE; >> + VT <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++VT) { >> + if (!isTypeLegal((MVT::SimpleValueType)VT)) { >> + setOperationAction(ISD::SDIV, (MVT::SimpleValueType) VT, Custom); >> + setOperationAction(ISD::UDIV, (MVT::SimpleValueType) VT, Custom); >> + setOperationAction(ISD::SREM, (MVT::SimpleValueType) VT, Custom); >> + setOperationAction(ISD::UREM, (MVT::SimpleValueType) VT, Custom); >> + } >> + } >> + >> // FIXME: These should be based on subtarget info. Plus, the values should >> // be smaller when we are in optimizing for size mode. >> maxStoresPerMemset = 16; // For @llvm.memset -> sequence of stores >> @@ -7170,6 +7183,14 @@ >> Results.push_back(edx.getValue(1)); >> return; >> } >> + case ISD::SDIV: >> + case ISD::UDIV: >> + case ISD::SREM: >> + case ISD::UREM: { >> + EVT WidenVT = getTypeToTransformTo(*DAG.getContext(), N->getValueType(0)); >> + Results.push_back(DAG.UnrollVectorOp(N, WidenVT.getVectorNumElements())); >> + return; >> + } >> case ISD::ATOMIC_CMP_SWAP: { >> EVT T = N->getValueType(0); >> assert (T == MVT::i64 && "Only know how to expand i64 Cmp and Swap"); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From clattner at apple.com Mon Nov 30 15:02:40 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 30 Nov 2009 13:02:40 -0800 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> Message-ID: <21F3CA3E-3FC7-4327-8177-95AB4A7FE6E2@apple.com> On Nov 30, 2009, at 12:44 PM, Mon Ping Wang wrote: > > If the machine supported a vector divide, it would be more efficient > to copy the last value to the 4th element and then do the divide. > For X86, there is no vector divide so it seems cleaner to me to do > it this way. Oh ok, thanks! -Chris From baldrick at free.fr Mon Nov 30 15:07:09 2009 From: baldrick at free.fr (Duncan Sands) Date: Mon, 30 Nov 2009 22:07:09 +0100 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> Message-ID: <4B1433FD.9070408@free.fr> Hi Mon Ping, > If the machine supported a vector divide, it would be more efficient to copy thlast value to the 4th element and then do the divide. For X86, there is no vector divide so it seems cleaner to me to do it this way. is this problem really x86 specific? Ciao, Duncan. From wangmp at apple.com Mon Nov 30 15:17:56 2009 From: wangmp at apple.com (Mon Ping Wang) Date: Mon, 30 Nov 2009 13:17:56 -0800 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <4B13BB94.1090803@free.fr> References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> <4B13BB94.1090803@free.fr> Message-ID: <54F6CA9A-559C-4513-B4C4-604E6379D926@apple.com> Hi Duncan, On X86, dividing by zero will generate an exception. Since on X86, we would unroll any vector division to scalars elements and rebuild the vector, it seemed cleaner to me that we custom widen by doing the scalar division on the elements on the original vector, and widen the result with undefs. I agree with you for architectures whose divide traps on zero but has a vector division, it would probably be more efficient for widening to copy the last element (or place 1s) across the vector. For architectures that do not trap on division, the normal widening code would handle it correctly. -- Mon Ping On Nov 30, 2009, at 4:33 AM, Duncan Sands wrote: > Hi Mon Ping, > >> Added support to allow clients to custom widen. For X86, custom widen vectors for >> divide/remainder since these operations can trap by unroll them and adding undefs >> for the resulting vector. > > does this really have anything to do with unrolling? After all, even if you > don't unroll then the additional vector elements might contain anything (since > they are "undef") and "anything" might be zero if you get unlucky. Will that > trap with vector division (or does it slow the division down?) Wouldn't it > be better to ensure that the extra elements in the denominator of the division > contain 1 or some other thing sure to be non-zero. > > Ciao, > > Duncan. From gohman at apple.com Mon Nov 30 15:23:57 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 13:23:57 -0800 Subject: [llvm-commits] [llvm] r89667 - in /llvm/trunk/lib/CodeGen/SelectionDAG: FunctionLoweringInfo.cpp FunctionLoweringInfo.h SelectionDAGBuild.cpp SelectionDAGBuild.h SelectionDAGISel.cpp In-Reply-To: <5C9DE571-FF75-4AAE-94BC-49AEBB87DBF7@apple.com> References: <200911231716.nANHGNlI031330@zion.cs.uiuc.edu> <5C9DE571-FF75-4AAE-94BC-49AEBB87DBF7@apple.com> Message-ID: On Nov 23, 2009, at 10:22 AM, Chris Lattner wrote: > > On Nov 23, 2009, at 9:16 AM, Dan Gohman wrote: > >> Author: djg >> Date: Mon Nov 23 11:16:22 2009 >> New Revision: 89667 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89667&view=rev >> Log: >> Move the FunctionLoweringInfo class and some related utility functions out >> of SelectionDAGBuild.h/cpp into its own files, to help separate >> general lowering logic from SelectionDAG-specific lowering logic. > > Hi Dan, > > Would it make sense to split TargetLowering into TargetLowering and SDLowering classes? The former would live in libtarget and the later in lib/codegen/selectiondag? Yes. TargetLowering could be split into about four classes probably. Dan From wangmp at apple.com Mon Nov 30 15:26:07 2009 From: wangmp at apple.com (Mon Ping Wang) Date: Mon, 30 Nov 2009 13:26:07 -0800 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <4B1433FD.9070408@free.fr> References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> <4B1433FD.9070408@free.fr> Message-ID: <7FC3ADB7-9B05-4207-8947-AB715B904267@apple.com> Hi Duncan, The solution for divide by unrolling is X86 specific. Widening the divisor by 1 would always safe but could lead to an extra scalar divide being generated for this case. -- Mon Ping On Nov 30, 2009, at 1:07 PM, Duncan Sands wrote: > Hi Mon Ping, > >> If the machine supported a vector divide, it would be more efficient to copy thlast value to the 4th element and then do the divide. For X86, there is no vector divide so it seems cleaner to me to do it this way. > > is this problem really x86 specific? > > Ciao, > > Duncan. On Nov 30, 2009, at 4:28 AM, Duncan Sands wrote: > Hi, > >> +; Verify when widening a divide/remainder operation, we only generate a >> +; divide/rem per element since divide/remainder can trap. > > you could also ensure that the widened divisor always has 1 in the extra > elements. This is analogous to integer promotion where the extra bits are > "undef" in general, but need to be constrained to certain values (usually > zero or one) in some cases. > > Ciao, > > Duncan. From isanbard at gmail.com Mon Nov 30 16:23:30 2009 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 30 Nov 2009 22:23:30 -0000 Subject: [llvm-commits] [llvm] r90160 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC++/m64-ptr.cpp FrontendC/2009-02-17-BitField-dbg.c Message-ID: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> Author: void Date: Mon Nov 30 16:23:29 2009 New Revision: 90160 URL: http://llvm.org/viewvc/llvm-project?rev=90160&view=rev Log: Debug info is disabled on PPC Darwin. Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp llvm/trunk/test/FrontendC++/m64-ptr.cpp llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-Pubnames.cpp?rev=90160&r1=90159&r2=90160&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp Mon Nov 30 16:23:29 2009 @@ -7,7 +7,11 @@ // RUN: %llvmdsymutil %t.exe // RUN: echo {break main\nrun\np Pubnames::pubname} > %t.in // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | grep {\$1 = 10} -// XFAIL: alpha,arm +// +// XFAIL: alpha,arm,powerpc-apple-darwin +// FIXME: This doesn't work for PPC Darwin because we turned off debugging on +// that platform. + struct Pubnames { static int pubname; }; Modified: llvm/trunk/test/FrontendC++/m64-ptr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/m64-ptr.cpp?rev=90160&r1=90159&r2=90160&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/m64-ptr.cpp (original) +++ llvm/trunk/test/FrontendC++/m64-ptr.cpp Mon Nov 30 16:23:29 2009 @@ -1,4 +1,5 @@ // RUN: %llvmgxx %s -S -o - | FileCheck %s + // Make sure pointers are passed as pointers, not converted to int. // The first load should be of type i8** in either 32 or 64 bit mode. // This formerly happened on x86-64, 7375899. Modified: llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c?rev=90160&r1=90159&r2=90160&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Mon Nov 30 16:23:29 2009 @@ -5,6 +5,10 @@ // RUN: echo {ptype mystruct} > %t2 // RUN: gdb -q -batch -n -x %t2 2009-02-17-BitField-dbg.o | \ // RUN: tee 2009-02-17-BitField-dbg.out | grep "int a : 4" +// +// XFAIL: powerpc-apple-darwin +// FIXME: This doesn't work for PPC Darwin because we turned off debugging on +// that platform. struct { int a:4; From gohman at apple.com Mon Nov 30 16:26:52 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 14:26:52 -0800 Subject: [llvm-commits] [llvm] r89659 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll test/Transforms/InstCombine/cast.ll test/Transforms/InstCombine/shufflevec-constant.ll In-Reply-To: References: <200911231622.nANGMLiD029357@zion.cs.uiuc.edu> Message-ID: On Nov 29, 2009, at 11:42 AM, Chris Lattner wrote: > > On Nov 23, 2009, at 8:22 AM, Dan Gohman wrote: > >> Author: djg >> Date: Mon Nov 23 10:22:21 2009 >> New Revision: 89659 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89659&view=rev >> Log: >> Make ConstantFoldConstantExpression recursively visit the entire >> ConstantExpr, not just the top-level operator. This allows it to >> fold many more constants. >> >> Also, make GlobalOpt call ConstantFoldConstantExpression on >> GlobalVariable initializers. > > Hi Dan, > > My recollection is that instcombine uses this function, so making it more expensive is potentially bad. Have you looked for any compile time impact of this? I don't expect to see a compile-time impact in normal cases, because the new code is only significant when it encounters elaborate nested unfoldable ConstantExprs, which don't happen very often, and because instcombine uses a SmallPtrSet to avoid calling ConstantFoldConstantExpr multiple times on the same constant within a run. It's probably possible to construct a testcase which would see a difference, but compile time still wouldn't be worse than proportional to the size of the program. Dan From stoklund at 2pi.dk Mon Nov 30 16:55:55 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 30 Nov 2009 22:55:55 -0000 Subject: [llvm-commits] [llvm] r90163 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/X86/2008-08-05-SpillerBug.ll Message-ID: <200911302255.nAUMttMs032661@zion.cs.uiuc.edu> Author: stoklund Date: Mon Nov 30 16:55:54 2009 New Revision: 90163 URL: http://llvm.org/viewvc/llvm-project?rev=90163&view=rev Log: New virtual registers created for spill intervals should inherit allocation hints from the original register. This helps us avoid silly copies when rematting values that are copied to a physical register: leaq _.str44(%rip), %rcx movq %rcx, %rsi call _strcmp becomes: leaq _.str44(%rip), %rsi call _strcmp The coalescer will not touch the movq because that would tie down the physical register. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=90163&r1=90162&r2=90163&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Nov 30 16:55:54 2009 @@ -1095,6 +1095,12 @@ NewVReg = mri_->createVirtualRegister(rc); vrm.grow(); CreatedNewVReg = true; + + // The new virtual register should get the same allocation hints as the + // old one. + std::pair Hint = mri_->getRegAllocationHint(Reg); + if (Hint.first || Hint.second) + mri_->setRegAllocationHint(NewVReg, Hint.first, Hint.second); } if (!TryFold) Modified: llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll?rev=90163&r1=90162&r2=90163&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-08-05-SpillerBug.ll Mon Nov 30 16:55:54 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 59 +; RUN: llc < %s -mtriple=i386-apple-darwin -disable-fp-elim -stats |& grep asm-printer | grep 58 ; PR2568 @g_3 = external global i16 ; [#uses=1] From gohman at apple.com Mon Nov 30 17:30:43 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 23:30:43 -0000 Subject: [llvm-commits] [llvm] r90164 - /llvm/trunk/include/llvm/Metadata.h Message-ID: <200911302330.nAUNUhC0001453@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 30 17:30:43 2009 New Revision: 90164 URL: http://llvm.org/viewvc/llvm-project?rev=90164&view=rev Log: Fix typos in comments. Modified: llvm/trunk/include/llvm/Metadata.h Modified: llvm/trunk/include/llvm/Metadata.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Metadata.h?rev=90164&r1=90163&r2=90164&view=diff ============================================================================== --- llvm/trunk/include/llvm/Metadata.h (original) +++ llvm/trunk/include/llvm/Metadata.h Mon Nov 30 17:30:43 2009 @@ -91,7 +91,7 @@ MDNode(const MDNode &); // DO NOT IMPLEMENT friend class ElementVH; - // Use CallbackVH to hold MDNOde elements. + // Use CallbackVH to hold MDNode elements. struct ElementVH : public CallbackVH { MDNode *Parent; ElementVH() {} @@ -264,7 +264,7 @@ /// the same metadata to In2. void copyMD(Instruction *In1, Instruction *In2); - /// getHandlerNames - Populate client supplied smallvector using custome + /// getHandlerNames - Populate client supplied smallvector using custom /// metadata name and ID. void getHandlerNames(SmallVectorImpl >&) const; From gohman at apple.com Mon Nov 30 17:33:38 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 23:33:38 -0000 Subject: [llvm-commits] [llvm] r90165 - /llvm/trunk/lib/Target/X86/X86Instr64bit.td Message-ID: <200911302333.nAUNXc82001539@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 30 17:33:37 2009 New Revision: 90165 URL: http://llvm.org/viewvc/llvm-project?rev=90165&view=rev Log: Fix a minor inconsistency. Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td Modified: llvm/trunk/lib/Target/X86/X86Instr64bit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Instr64bit.td?rev=90165&r1=90164&r2=90165&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Instr64bit.td (original) +++ llvm/trunk/lib/Target/X86/X86Instr64bit.td Mon Nov 30 17:33:37 2009 @@ -1663,7 +1663,7 @@ (TCRETURNri64 GR64:$dst, imm:$off)>; def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), - (TCRETURNdi64 texternalsym:$dst, imm:$off)>; + (TCRETURNdi64 tglobaladdr:$dst, imm:$off)>; def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), (TCRETURNdi64 texternalsym:$dst, imm:$off)>; From gohman at apple.com Mon Nov 30 17:33:53 2009 From: gohman at apple.com (Dan Gohman) Date: Mon, 30 Nov 2009 23:33:53 -0000 Subject: [llvm-commits] [llvm] r90166 - in /llvm/trunk/lib/Target/X86: X86InstrInfo.td X86RegisterInfo.cpp Message-ID: <200911302333.nAUNXrLS001557@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 30 17:33:53 2009 New Revision: 90166 URL: http://llvm.org/viewvc/llvm-project?rev=90166&view=rev Log: Minor whitespace fixes. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=90166&r1=90165&r2=90166&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Nov 30 17:33:53 2009 @@ -718,7 +718,6 @@ []>; let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in - def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL", []>; let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=90166&r1=90165&r2=90166&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Mon Nov 30 17:33:53 2009 @@ -1262,7 +1262,7 @@ else if (RetOpcode== X86::TCRETURNri64) BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr64), JumpTarget.getReg()); else - BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr), JumpTarget.getReg()); + BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr), JumpTarget.getReg()); // Delete the pseudo instruction TCRETURN. MBB.erase(MBBI); From ofv at wanadoo.es Mon Nov 30 17:48:51 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 30 Nov 2009 23:48:51 -0000 Subject: [llvm-commits] [llvm] r90169 - /llvm/trunk/cmake/modules/LLVMLibDeps.cmake Message-ID: <200911302348.nAUNmpLD002141@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 30 17:48:51 2009 New Revision: 90169 URL: http://llvm.org/viewvc/llvm-project?rev=90169&view=rev Log: * cmake/modules/LLVMLibDeps.cmake: Updated library dependencies. Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=90169&r1=90168&r2=90169&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Mon Nov 30 17:48:51 2009 @@ -2,7 +2,7 @@ set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMARMInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMARMInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAlphaCodeGen LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMAlphaCodeGen LLVMAlphaInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMAlphaInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget) @@ -11,12 +11,12 @@ set(MSVC_LIB_DEPS_LLVMAsmPrinter LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport LLVMSystem) -set(MSVC_LIB_DEPS_LLVMBlackfinAsmPrinter LLVMAsmPrinter LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMBlackfinAsmPrinter LLVMAsmPrinter LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMBlackfinInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCBackendInfo LLVMCodeGen LLVMCore LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa) set(MSVC_LIB_DEPS_LLVMCBackendInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMCellSPUInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMMC LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils) @@ -31,7 +31,7 @@ set(MSVC_LIB_DEPS_LLVMMC LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMMSIL LLVMAnalysis LLVMCodeGen LLVMCore LLVMMSILInfo LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa) set(MSVC_LIB_DEPS_LLVMMSILInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430CodeGen LLVMMSP430Info LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430Info LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMMSP430CodeGen LLVMCodeGen LLVMCore LLVMMC LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMMSP430Info LLVMSupport) set(MSVC_LIB_DEPS_LLVMMipsAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsCodeGen LLVMMipsInfo LLVMSupport LLVMSystem LLVMTarget) @@ -40,17 +40,17 @@ set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPIC16 LLVMPIC16Info LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16Info LLVMSupport) -set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCCodeGen LLVMPowerPCInfo LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCInfo LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils) set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMSystem LLVMTarget) -set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSparcCodeGen LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget) +set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMSparcInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMSystem ) -set(MSVC_LIB_DEPS_LLVMSystemZAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMSystemZCodeGen LLVMSystemZInfo LLVMTarget) +set(MSVC_LIB_DEPS_LLVMSystemZAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMSystemZInfo LLVMTarget) set(MSVC_LIB_DEPS_LLVMSystemZCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystemZInfo LLVMTarget) set(MSVC_LIB_DEPS_LLVMSystemZInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMMC LLVMSupport LLVMSystem) @@ -58,9 +58,10 @@ set(MSVC_LIB_DEPS_LLVMX86AsmParser LLVMMC LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget LLVMX86CodeGen LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMX86Info) +set(MSVC_LIB_DEPS_LLVMX86Disassembler LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Info LLVMSupport) set(MSVC_LIB_DEPS_LLVMXCore LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMXCoreInfo) -set(MSVC_LIB_DEPS_LLVMXCoreAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget LLVMXCore LLVMXCoreInfo) +set(MSVC_LIB_DEPS_LLVMXCoreAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMipo LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa) From ofv at wanadoo.es Mon Nov 30 17:50:15 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 30 Nov 2009 23:50:15 -0000 Subject: [llvm-commits] [llvm] r90170 - /llvm/trunk/CMakeLists.txt Message-ID: <200911302350.nAUNoFdL002202@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 30 17:50:14 2009 New Revision: 90170 URL: http://llvm.org/viewvc/llvm-project?rev=90170&view=rev Log: * CMakeLists.txt: Adds warnings flags for g++. Fixes PR 5647. Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90170&r1=90169&r2=90170&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Mon Nov 30 17:50:14 2009 @@ -226,6 +226,8 @@ add_llvm_definitions("/${LLVM_USE_CRT}") message(STATUS "Using VC++ CRT: ${LLVM_USE_CRT}") endif (NOT ${LLVM_USE_CRT} STREQUAL "") +elseif( CMAKE_COMPILER_IS_GNUCXX ) + add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) endif( MSVC ) include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) From dpatel at apple.com Mon Nov 30 17:56:56 2009 From: dpatel at apple.com (Devang Patel) Date: Mon, 30 Nov 2009 23:56:56 -0000 Subject: [llvm-commits] [llvm] r90172 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200911302356.nAUNuuND002581@zion.cs.uiuc.edu> Author: dpatel Date: Mon Nov 30 17:56:56 2009 New Revision: 90172 URL: http://llvm.org/viewvc/llvm-project?rev=90172&view=rev Log: If pointer type has a name then do not ignore the name. 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=90172&r1=90171&r2=90172&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Nov 30 17:56:56 2009 @@ -815,7 +815,7 @@ addType(DW_Unit, &Buffer, FromTy); // Add name if not anonymous or intermediate type. - if (!Name.empty() && Tag != dwarf::DW_TAG_pointer_type) + if (!Name.empty()) addString(&Buffer, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); // Add size if non-zero (derived types might be zero-sized.) From johnny.chen at apple.com Mon Nov 30 18:02:02 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 01 Dec 2009 00:02:02 -0000 Subject: [llvm-commits] [llvm] r90173 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200912010002.nB1022oV002774@zion.cs.uiuc.edu> Author: johnny Date: Mon Nov 30 18:02:02 2009 New Revision: 90173 URL: http://llvm.org/viewvc/llvm-project?rev=90173&view=rev Log: For VMOV (immediate), make some of the encoding bits (cmode and op) unspecified. For VMOVv*i[16,32], op bit is don't care, and some cmode bits vary depending on the immediate values. Ref: Table A7-15 Modified immediate values for Advanced SIMD instructions. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=90173&r1=90172&r2=90173&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Mon Nov 30 18:02:02 2009 @@ -2582,20 +2582,20 @@ "vmov", "i8", "$dst, $SIMM", "", [(set QPR:$dst, (v16i8 vmovImm8:$SIMM))]>; -def VMOVv4i16 : N1ModImm<1, 0b000, 0b1000, 0, 0, 0, 1, (outs DPR:$dst), +def VMOVv4i16 : N1ModImm<1, 0b000, {1,0,?,?}, 0, 0, {?}, 1, (outs DPR:$dst), (ins h16imm:$SIMM), IIC_VMOVImm, "vmov", "i16", "$dst, $SIMM", "", [(set DPR:$dst, (v4i16 vmovImm16:$SIMM))]>; -def VMOVv8i16 : N1ModImm<1, 0b000, 0b1000, 0, 1, 0, 1, (outs QPR:$dst), +def VMOVv8i16 : N1ModImm<1, 0b000, {1,0,?,?}, 0, 1, {?}, 1, (outs QPR:$dst), (ins h16imm:$SIMM), IIC_VMOVImm, "vmov", "i16", "$dst, $SIMM", "", [(set QPR:$dst, (v8i16 vmovImm16:$SIMM))]>; -def VMOVv2i32 : N1ModImm<1, 0b000, 0b0000, 0, 0, 0, 1, (outs DPR:$dst), +def VMOVv2i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 0, {?}, 1, (outs DPR:$dst), (ins h32imm:$SIMM), IIC_VMOVImm, "vmov", "i32", "$dst, $SIMM", "", [(set DPR:$dst, (v2i32 vmovImm32:$SIMM))]>; -def VMOVv4i32 : N1ModImm<1, 0b000, 0b0000, 0, 1, 0, 1, (outs QPR:$dst), +def VMOVv4i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 1, {?}, 1, (outs QPR:$dst), (ins h32imm:$SIMM), IIC_VMOVImm, "vmov", "i32", "$dst, $SIMM", "", [(set QPR:$dst, (v4i32 vmovImm32:$SIMM))]>; From dpatel at apple.com Mon Nov 30 18:12:27 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 00:12:27 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90175 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200912010012.nB10CRLO003116@zion.cs.uiuc.edu> Author: dpatel Date: Mon Nov 30 18:12:27 2009 New Revision: 90175 URL: http://llvm.org/viewvc/llvm-project?rev=90175&view=rev Log: If pointer type has a name (e.g. "id" in objc) then use the name in the debug info. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=90175&r1=90174&r2=90175&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Mon Nov 30 18:12:27 2009 @@ -497,17 +497,36 @@ unsigned Flags = 0; if (type_is_block_byref_struct(type)) Flags |= llvm::DIType::FlagBlockByrefStruct; + expanded_location Loc = GetNodeLocation(type); + // Check if this pointer type has a name. + if (tree TyName = TYPE_NAME(type)) + if (TREE_CODE(TyName) == TYPE_DECL && !DECL_ORIGINAL_TYPE(TyName)) { + expanded_location TypeNameLoc = GetNodeLocation(TyName); + DIType Ty = DebugFactory.CreateDerivedType(Tag, findRegion(TyName), + GetNodeName(TyName), + getOrCreateCompileUnit(TypeNameLoc.file), + TypeNameLoc.line, + 0 /*size*/, + 0 /*align*/, + 0 /*offset */, + 0 /*flags*/, + FromTy); + TypeCache[TyName] = WeakVH(Ty.getNode()); + return Ty; + } + StringRef PName = FromTy.getName(); - return DebugFactory.CreateDerivedType(Tag, findRegion(type), PName, - getOrCreateCompileUnit(NULL), - 0 /*line no*/, - NodeSizeInBits(type), - NodeAlignInBits(type), - 0 /*offset */, - Flags, - FromTy); + DIType PTy = DebugFactory.CreateDerivedType(Tag, findRegion(type), PName, + getOrCreateCompileUnit(NULL), + 0 /*line no*/, + NodeSizeInBits(type), + NodeAlignInBits(type), + 0 /*offset */, + Flags, + FromTy); + return PTy; } /// createArrayType - Create ArrayType. From dpatel at apple.com Mon Nov 30 18:13:07 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 00:13:07 -0000 Subject: [llvm-commits] [llvm] r90176 - /llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m Message-ID: <200912010013.nB10D7Mo003144@zion.cs.uiuc.edu> Author: dpatel Date: Mon Nov 30 18:13:06 2009 New Revision: 90176 URL: http://llvm.org/viewvc/llvm-project?rev=90176&view=rev Log: Test case for r90175. Added: llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m Added: llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m?rev=90176&view=auto ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m (added) +++ llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m Mon Nov 30 18:13:06 2009 @@ -0,0 +1,14 @@ +// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: llc --disable-fp-elim -o %t.s -O0 +// RUN: grep id %t.s | grep DW_AT_name + at interface A +-(id) blah; + at end + + at implementation A +-(id)blah { + int i = 1; + i++; + return i; +} + at end From evan.cheng at apple.com Mon Nov 30 18:44:46 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 01 Dec 2009 00:44:46 -0000 Subject: [llvm-commits] [llvm] r90180 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll Message-ID: <200912010044.nB10ik7w004280@zion.cs.uiuc.edu> Author: evancheng Date: Mon Nov 30 18:44:45 2009 New Revision: 90180 URL: http://llvm.org/viewvc/llvm-project?rev=90180&view=rev Log: Fix PR5614: parts of a physical register def may be killed the rest. Added: llvm/trunk/test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h llvm/trunk/lib/CodeGen/LiveVariables.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=90180&r1=90179&r2=90180&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Mon Nov 30 18:44:45 2009 @@ -163,8 +163,13 @@ SmallVector &Defs); void UpdatePhysRegDefs(MachineInstr *MI, SmallVector &Defs); - /// FindLastPartialDef - Return the last partial def of the specified register. - /// Also returns the sub-registers that're defined by the instruction. + /// FindLastRefOrPartRef - Return the last reference or partial reference of + /// the specified register. + MachineInstr *FindLastRefOrPartRef(unsigned Reg); + + /// FindLastPartialDef - Return the last partial def of the specified + /// register. Also returns the sub-registers that're defined by the + /// instruction. MachineInstr *FindLastPartialDef(unsigned Reg, SmallSet &PartDefRegs); Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=90180&r1=90179&r2=90180&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Mon Nov 30 18:44:45 2009 @@ -279,6 +279,43 @@ PhysRegUse[SubReg] = MI; } +/// FindLastRefOrPartRef - Return the last reference or partial reference of +/// the specified register. +MachineInstr *LiveVariables::FindLastRefOrPartRef(unsigned Reg) { + MachineInstr *LastDef = PhysRegDef[Reg]; + MachineInstr *LastUse = PhysRegUse[Reg]; + if (!LastDef && !LastUse) + return false; + + MachineInstr *LastRefOrPartRef = LastUse ? LastUse : LastDef; + unsigned LastRefOrPartRefDist = DistanceMap[LastRefOrPartRef]; + MachineInstr *LastPartDef = 0; + unsigned LastPartDefDist = 0; + for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); + unsigned SubReg = *SubRegs; ++SubRegs) { + MachineInstr *Def = PhysRegDef[SubReg]; + if (Def && Def != LastDef) { + // There was a def of this sub-register in between. This is a partial + // def, keep track of the last one. + unsigned Dist = DistanceMap[Def]; + if (Dist > LastPartDefDist) { + LastPartDefDist = Dist; + LastPartDef = Def; + } + continue; + } + if (MachineInstr *Use = PhysRegUse[SubReg]) { + unsigned Dist = DistanceMap[Use]; + if (Dist > LastRefOrPartRefDist) { + LastRefOrPartRefDist = Dist; + LastRefOrPartRef = Use; + } + } + } + + return LastRefOrPartRef; +} + bool LiveVariables::HandlePhysRegKill(unsigned Reg, MachineInstr *MI) { MachineInstr *LastDef = PhysRegDef[Reg]; MachineInstr *LastUse = PhysRegUse[Reg]; @@ -373,7 +410,16 @@ if (NeedDef) PhysRegDef[Reg]->addOperand(MachineOperand::CreateReg(SubReg, true/*IsDef*/, true/*IsImp*/)); - LastRefOrPartRef->addRegisterKilled(SubReg, TRI, true); + MachineInstr *LastSubRef = FindLastRefOrPartRef(SubReg); + if (LastSubRef) + LastSubRef->addRegisterKilled(SubReg, TRI, true); + else { + LastRefOrPartRef->addRegisterKilled(SubReg, TRI, true); + PhysRegUse[SubReg] = LastRefOrPartRef; + for (const unsigned *SSRegs = TRI->getSubRegisters(SubReg); + unsigned SSReg = *SSRegs; ++SSRegs) + PhysRegUse[SSReg] = LastRefOrPartRef; + } for (const unsigned *SS = TRI->getSubRegisters(SubReg); *SS; ++SS) PartUses.erase(*SS); } Added: llvm/trunk/test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll?rev=90180&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-11-30-LiveVariablesBug.ll Mon Nov 30 18:44:45 2009 @@ -0,0 +1,41 @@ +; RUN: llc -mtriple=armv7-eabi -mcpu=cortex-a8 < %s +; PR5614 + +%"als" = type { i32 (...)** } +%"av" = type { %"als" } +%"c" = type { %"lsm", %"Vec3", %"av"*, float, i8, float, %"lsm", i8, %"Vec3", %"Vec3", %"Vec3", float, float, float, %"Vec3", %"Vec3" } +%"lsm" = type { %"als", %"Vec3", %"Vec3", %"Vec3", %"Vec3" } +%"Vec3" = type { float, float, float } + +define arm_aapcs_vfpcc void @foo(%"c"* %this, %"Vec3"* nocapture %adjustment) { +entry: + switch i32 undef, label %return [ + i32 1, label %bb + i32 2, label %bb72 + i32 3, label %bb31 + i32 4, label %bb79 + i32 5, label %bb104 + ] + +bb: ; preds = %entry + ret void + +bb31: ; preds = %entry + %0 = call arm_aapcs_vfpcc %"Vec3" undef(%"lsm"* undef) ; <%"Vec3"> [#uses=1] + %mrv_gr69 = extractvalue %"Vec3" %0, 1 ; [#uses=1] + %1 = fsub float %mrv_gr69, undef ; [#uses=1] + store float %1, float* undef, align 4 + ret void + +bb72: ; preds = %entry + ret void + +bb79: ; preds = %entry + ret void + +bb104: ; preds = %entry + ret void + +return: ; preds = %entry + ret void +} From gohman at apple.com Mon Nov 30 18:45:56 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Dec 2009 00:45:56 -0000 Subject: [llvm-commits] [llvm] r90181 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200912010045.nB10jubt004344@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 30 18:45:56 2009 New Revision: 90181 URL: http://llvm.org/viewvc/llvm-project?rev=90181&view=rev Log: Devang pointed out that this code should use DIScope instead of DICompileUnit. This code now prints debug filenames successfully. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90181&r1=90180&r2=90181&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Mon Nov 30 18:45:56 2009 @@ -1148,10 +1148,10 @@ // TODO: print InlinedAtLoc information DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); - DICompileUnit CU(DLT.Scope); + DIScope Scope(DLT.Scope); OS << " dbg:"; - if (!CU.isNull()) - OS << CU.getDirectory() << '/' << CU.getFilename() << ":"; + if (!Scope.isNull()) + OS << Scope.getDirectory() << ':' << Scope.getFilename() << ':'; OS << DLT.Line << ":" << DLT.Col; } From isanbard at gmail.com Mon Nov 30 18:53:11 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 01 Dec 2009 00:53:11 -0000 Subject: [llvm-commits] [llvm] r90182 - /llvm/trunk/docs/SourceLevelDebugging.html Message-ID: <200912010053.nB10rBa0004556@zion.cs.uiuc.edu> Author: void Date: Mon Nov 30 18:53:11 2009 New Revision: 90182 URL: http://llvm.org/viewvc/llvm-project?rev=90182&view=rev Log: Some formatting and spelling fixes. Modified: llvm/trunk/docs/SourceLevelDebugging.html Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=90182&r1=90181&r2=90182&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Mon Nov 30 18:53:11 2009 @@ -780,18 +780,18 @@
    -

    In many languages, the local variables in functions can have their lifetime - or scope limited to a subset of a function. In the C family of languages, +

    In many languages, the local variables in functions can have their lifetimes + or scopes limited to a subset of a function. In the C family of languages, for example, variables are only live (readable and writable) within the source block that they are defined in. In functional languages, values are only readable after they have been defined. Though this is a very obvious - concept, it is also non-trivial to model in LLVM, because it has no notion of + concept, it is non-trivial to model in LLVM, because it has no notion of scoping in this sense, and does not want to be tied to a language's scoping rules.

    -

    In order to handle this, the LLVM debug format uses the metadata attached - with llvm instructions to encode line nuber and scoping information. - Consider the following C fragment, for example:

    +

    In order to handle this, the LLVM debug format uses the metadata attached to + llvm instructions to encode line nuber and scoping information. Consider the + following C fragment, for example:

    @@ -811,7 +811,7 @@
     
     
    -nounwind ssp {
    +define void @foo() nounwind ssp {
     entry:
       %X = alloca i32, align 4                        ;  [#uses=4]
       %Y = alloca i32, align 4                        ;  [#uses=4]
    @@ -867,68 +867,74 @@
     
    -

    This example illustrates a few important details about the LLVM debugging - information. In particular, it shows how the llvm.dbg.declare intrinsic - and location information, attached with an instruction, are applied - together to allow a debugger to analyze the relationship between statements, - variable definitions, and the code used to implement the function.

    - -
    -
     
    -     call void @llvm.dbg.declare({ }* %0, metadata !0), !dbg !7   
    -   
    -
    -

    This first intrinsic +

    This example illustrates a few important details about LLVM debugging + information. In particular, it shows how the llvm.dbg.declare + intrinsic and location information, which are attached to an instruction, + are applied together to allow a debugger to analyze the relationship between + statements, variable definitions, and the code used to implement the + function.

    + +
    +
     
    +call void @llvm.dbg.declare({ }* %0, metadata !0), !dbg !7   
    +
    +
    + +

    The first intrinsic %llvm.dbg.declare - encodes debugging information for variable X. The metadata, - !dbg !7 attached with the intrinsic provides scope information for - the variable X.

    -
    -
    -     !7 = metadata !{i32 2, i32 7, metadata !1, null}
    -     !1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ]
    -     !2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"foo", 
    -                     metadata !"foo", metadata !"foo", metadata !3, i32 1, 
    -                     metadata !4, i1 false, i1 true}; [DW_TAG_subprogram ]   
    -   
    -
    - -

    Here !7 is a metadata providing location information. It has four - fields : line number, column number, scope and original scope. The original - scope represents inline location if this instruction is inlined inside - a caller. It is null otherwise. In this example scope is encoded by + encodes debugging information for the variable X. The metadata + !dbg !7 attached to the intrinsic provides scope information for the + variable X.

    + +
    +
    +!7 = metadata !{i32 2, i32 7, metadata !1, null}
    +!1 = metadata !{i32 458763, metadata !2}; [DW_TAG_lexical_block ]
    +!2 = metadata !{i32 458798, i32 0, metadata !3, metadata !"foo", 
    +                metadata !"foo", metadata !"foo", metadata !3, i32 1, 
    +                metadata !4, i1 false, i1 true}; [DW_TAG_subprogram ]   
    +
    +
    + +

    Here !7 is metadata providing location information. It has four + fields: line number, column number, scope, and original scope. The original + scope represents inline location if this instruction is inlined inside a + caller, and is null otherwise. In this example, scope is encoded by !1. !1 represents a lexical block inside the scope !2, where !2 is a - subprogram descriptor. - This way the location information attched with the intrinsics indicates - that the variable X is declared at line number 2 at a function level - scope in function foo.

    + subprogram descriptor. This way the + location information attached to the intrinsics indicates that the + variable X is declared at line number 2 at a function level scope in + function foo.

    Now lets take another example.

    -
    -
     
    -     call void @llvm.dbg.declare({ }* %2, metadata !12), !dbg !14
    -   
    -
    -

    This intrinsic +

    +
     
    +call void @llvm.dbg.declare({ }* %2, metadata !12), !dbg !14
    +
    +
    + +

    The second intrinsic %llvm.dbg.declare - encodes debugging information for variable Z. The metadata, - !dbg !14 attached with the intrinsic provides scope information for - the variable Z.

    -
    -
    -     !13 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ]
    -     !14 = metadata !{i32 5, i32 9, metadata !13, null}
    -   
    -
    - -

    Here !14 indicates that Z is declaread at line number 5, - column number 9 inside a lexical scope !13. This lexical scope - itself resides inside lexcial scope !1 described above.

    + encodes debugging information for variable Z. The metadata + !dbg !14 attached to the intrinsic provides scope information for + the variable Z.

    + +
    +
    +!13 = metadata !{i32 458763, metadata !1}; [DW_TAG_lexical_block ]
    +!14 = metadata !{i32 5, i32 9, metadata !13, null}
    +
    +
    + +

    Here !14 indicates that Z is declaread at line number 5 and + column number 9 inside of lexical scope !13. The lexical scope + itself resides inside of lexical scope !1 described above.

    + +

    The scope information attached with each instruction provides a + straightforward way to find instructions covered by a scope.

    -

    The scope information attached with each instruction provides a straight - forward way to find instructions covered by a scope.

    From isanbard at gmail.com Mon Nov 30 18:59:59 2009 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 01 Dec 2009 00:59:59 -0000 Subject: [llvm-commits] [llvm] r90184 - /llvm/trunk/docs/SourceLevelDebugging.html Message-ID: <200912010059.nB10xxO9004815@zion.cs.uiuc.edu> Author: void Date: Mon Nov 30 18:59:58 2009 New Revision: 90184 URL: http://llvm.org/viewvc/llvm-project?rev=90184&view=rev Log: Remove some validation errors. Modified: llvm/trunk/docs/SourceLevelDebugging.html Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=90184&r1=90183&r2=90184&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Mon Nov 30 18:59:58 2009 @@ -813,23 +813,23 @@
     define void @foo() nounwind ssp {
     entry:
    -  %X = alloca i32, align 4                        ;  [#uses=4]
    -  %Y = alloca i32, align 4                        ;  [#uses=4]
    -  %Z = alloca i32, align 4                        ;  [#uses=3]
    -  %0 = bitcast i32* %X to { }*                    ; <{ }*> [#uses=1]
    +  %X = alloca i32, align 4                        ; <i32*> [#uses=4]
    +  %Y = alloca i32, align 4                        ; <i32*> [#uses=4]
    +  %Z = alloca i32, align 4                        ; <i32*> [#uses=3]
    +  %0 = bitcast i32* %X to { }*                    ; <{ }*> [#uses=1]
       call void @llvm.dbg.declare({ }* %0, metadata !0), !dbg !7
       store i32 21, i32* %X, !dbg !8
    -  %1 = bitcast i32* %Y to { }*                    ; <{ }*> [#uses=1]
    +  %1 = bitcast i32* %Y to { }*                    ; <{ }*> [#uses=1]
       call void @llvm.dbg.declare({ }* %1, metadata !9), !dbg !10
       store i32 22, i32* %Y, !dbg !11
    -  %2 = bitcast i32* %Z to { }*                    ; <{ }*> [#uses=1]
    +  %2 = bitcast i32* %Z to { }*                    ; <{ }*> [#uses=1]
       call void @llvm.dbg.declare({ }* %2, metadata !12), !dbg !14
       store i32 23, i32* %Z, !dbg !15
    -  %tmp = load i32* %X, !dbg !16                   ;  [#uses=1]
    -  %tmp1 = load i32* %Y, !dbg !16                  ;  [#uses=1]
    -  %add = add nsw i32 %tmp, %tmp1, !dbg !16        ;  [#uses=1]
    +  %tmp = load i32* %X, !dbg !16                   ; <i32> [#uses=1]
    +  %tmp1 = load i32* %Y, !dbg !16                  ; <i32> [#uses=1]
    +  %add = add nsw i32 %tmp, %tmp1, !dbg !16        ; <i32> [#uses=1]
       store i32 %add, i32* %Z, !dbg !16
    -  %tmp2 = load i32* %Y, !dbg !17                  ;  [#uses=1]
    +  %tmp2 = load i32* %Y, !dbg !17                  ; <i32> [#uses=1]
       store i32 %tmp2, i32* %X, !dbg !17
       ret void, !dbg !18
     }
    @@ -875,7 +875,7 @@
        function.

    -
     
    +
     call void @llvm.dbg.declare({ }* %0, metadata !0), !dbg !7   
     
    @@ -910,7 +910,7 @@

    Now lets take another example.

    -
     
    +
     call void @llvm.dbg.declare({ }* %2, metadata !12), !dbg !14
     
    From gohman at apple.com Mon Nov 30 19:38:10 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Dec 2009 01:38:10 -0000 Subject: [llvm-commits] [llvm] r90185 - /llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll Message-ID: <200912010138.nB11cA9A006134@zion.cs.uiuc.edu> Author: djg Date: Mon Nov 30 19:38:10 2009 New Revision: 90185 URL: http://llvm.org/viewvc/llvm-project?rev=90185&view=rev Log: Add a comment about A[i+(j+1)]. Modified: llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll Modified: llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll?rev=90185&r1=90184&r2=90185&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/scev-aa.ll Mon Nov 30 19:38:10 2009 @@ -2,7 +2,7 @@ ; RUN: |& FileCheck %s ; At the time of this writing, -basicaa only misses the example of the form -; A[i+(j+1)] != A[i+j]. However, it does get A[(i+j)+1] != A[i+j]. +; A[i+(j+1)] != A[i+j], which can arise from multi-dimensional array references. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" From clattner at apple.com Mon Nov 30 19:45:20 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 30 Nov 2009 17:45:20 -0800 Subject: [llvm-commits] [llvm] r89659 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/constantfold-initializers.ll test/Transforms/InstCombine/cast.ll test/Transforms/InstCombine/shufflevec-constant.ll In-Reply-To: References: <200911231622.nANGMLiD029357@zion.cs.uiuc.edu> Message-ID: On Nov 30, 2009, at 2:26 PM, Dan Gohman wrote: >> My recollection is that instcombine uses this function, so making >> it more expensive is potentially bad. Have you looked for any >> compile time impact of this? > > I don't expect to see a compile-time impact in normal cases, because > the new code is only significant when it encounters elaborate nested > unfoldable ConstantExprs, which don't happen very often, and because > instcombine uses a SmallPtrSet to avoid calling > ConstantFoldConstantExpr > multiple times on the same constant within a run. It's probably > possible > to construct a testcase which would see a difference, but compile time > still wouldn't be worse than proportional to the size of the program. Aha, ok, I forgot that we had the smallptrset, thanks! -Chris From clattner at apple.com Mon Nov 30 19:45:37 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 30 Nov 2009 17:45:37 -0800 Subject: [llvm-commits] [llvm] r90160 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC++/m64-ptr.cpp FrontendC/2009-02-17-BitField-dbg.c In-Reply-To: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> References: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> Message-ID: On Nov 30, 2009, at 2:23 PM, Bill Wendling wrote: > Author: void > Date: Mon Nov 30 16:23:29 2009 > New Revision: 90160 > > URL: http://llvm.org/viewvc/llvm-project?rev=90160&view=rev > Log: > Debug info is disabled on PPC Darwin. Why is debug info disabled on ppc darwin? -Chris > > Modified: > llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp > llvm/trunk/test/FrontendC++/m64-ptr.cpp > llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c > > Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-Pubnames.cpp?rev=90160&r1=90159&r2=90160&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp (original) > +++ llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp Mon Nov 30 > 16:23:29 2009 > @@ -7,7 +7,11 @@ > // RUN: %llvmdsymutil %t.exe > // RUN: echo {break main\nrun\np Pubnames::pubname} > %t.in > // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | grep {\$1 = > 10} > -// XFAIL: alpha,arm > +// > +// XFAIL: alpha,arm,powerpc-apple-darwin > +// FIXME: This doesn't work for PPC Darwin because we turned off > debugging on > +// that platform. > + > struct Pubnames { > static int pubname; > }; > > Modified: llvm/trunk/test/FrontendC++/m64-ptr.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/m64-ptr.cpp?rev=90160&r1=90159&r2=90160&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/FrontendC++/m64-ptr.cpp (original) > +++ llvm/trunk/test/FrontendC++/m64-ptr.cpp Mon Nov 30 16:23:29 2009 > @@ -1,4 +1,5 @@ > // RUN: %llvmgxx %s -S -o - | FileCheck %s > + > // Make sure pointers are passed as pointers, not converted to int. > // The first load should be of type i8** in either 32 or 64 bit mode. > // This formerly happened on x86-64, 7375899. > > Modified: llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c?rev=90160&r1=90159&r2=90160&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) > +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Mon Nov 30 > 16:23:29 2009 > @@ -5,6 +5,10 @@ > // RUN: echo {ptype mystruct} > %t2 > // RUN: gdb -q -batch -n -x %t2 2009-02-17-BitField-dbg.o | \ > // RUN: tee 2009-02-17-BitField-dbg.out | grep "int a : 4" > +// > +// XFAIL: powerpc-apple-darwin > +// FIXME: This doesn't work for PPC Darwin because we turned off > debugging on > +// that platform. > > struct { > int a:4; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Nov 30 19:56:27 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 01:56:27 -0000 Subject: [llvm-commits] [llvm] r90186 - /llvm/trunk/examples/Fibonacci/fibonacci.cpp Message-ID: <200912010156.nB11uR8s006715@zion.cs.uiuc.edu> Author: lattner Date: Mon Nov 30 19:56:27 2009 New Revision: 90186 URL: http://llvm.org/viewvc/llvm-project?rev=90186&view=rev Log: fix PR5649 by making fib use the JIT instead of the interpreter, patch by Perry Lorier! Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp Modified: llvm/trunk/examples/Fibonacci/fibonacci.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Fibonacci/fibonacci.cpp?rev=90186&r1=90185&r2=90186&view=diff ============================================================================== --- llvm/trunk/examples/Fibonacci/fibonacci.cpp (original) +++ llvm/trunk/examples/Fibonacci/fibonacci.cpp Mon Nov 30 19:56:27 2009 @@ -34,6 +34,7 @@ #include "llvm/ExecutionEngine/Interpreter.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetSelect.h" using namespace llvm; static Function *CreateFibFunction(Module *M, LLVMContext &Context) { @@ -92,6 +93,7 @@ int main(int argc, char **argv) { int n = argc > 1 ? atol(argv[1]) : 24; + InitializeNativeTarget(); LLVMContext Context; // Create some module to put our function into it. @@ -101,7 +103,13 @@ Function *FibF = CreateFibFunction(M, Context); // Now we going to create JIT - ExecutionEngine *EE = EngineBuilder(M).create(); + std::string errStr; + ExecutionEngine *EE = EngineBuilder(M).setErrorStr(&errStr).setEngineKind(EngineKind::JIT).create(); + + if (!EE) { + errs() << argv[0] << ": Failed to construct ExecutionEngine: " << errStr << "\n"; + return 1; + } errs() << "verifying... "; if (verifyModule(*M)) { From clattner at apple.com Mon Nov 30 20:00:24 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 30 Nov 2009 18:00:24 -0800 Subject: [llvm-commits] [llvm] r90113 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp In-Reply-To: <200911300705.nAU75qsb015777@zion.cs.uiuc.edu> References: <200911300705.nAU75qsb015777@zion.cs.uiuc.edu> Message-ID: <55965E74-9225-4FC5-A8AB-BDB9FB392168@apple.com> On Nov 29, 2009, at 11:05 PM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Nov 30 01:05:51 2009 > New Revision: 90113 > > URL: http://llvm.org/viewvc/llvm-project?rev=90113&view=rev > Log: > Revert r90107, fixing test/Transforms/GVN/2009-11-29-ReverseMap.ll > and the > llvm-gcc build. Uh, no it's not. You're thinking of the previous patch? -Chris > > Modified: > llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp > > Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90113&r1=90112&r2=90113&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) > +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Nov 30 > 01:05:51 2009 > @@ -1156,21 +1156,8 @@ > // that predecessor. We can still do PRE of the load, which > would insert > // a computation of the pointer in this predecessor. > if (PredPtr == 0) { > - // Add the entry to the Result list. > - NonLocalDepEntry Entry(Pred, > - MemDepResult::getClobber(Pred- > >getTerminator())); > - Result.push_back(Entry); > - > - // Add it to the cache for this CacheKey so that subsequent > queries get > - // this result. > - Cache = &NonLocalPointerDeps[CacheKey].second; > - MemoryDependenceAnalysis::NonLocalDepInfo::iterator It = > - std::upper_bound(Cache->begin(), Cache->end(), Entry); > - Cache->insert(It, Entry); > - Cache = 0; > - > - // Add it to the reverse map next. > - ReverseNonLocalPtrDeps[Pred- > >getTerminator()].insert(CacheKey); > + Result.push_back(NonLocalDepEntry(Pred, > + MemDepResult::getClobber(Pred- > >getTerminator()))); > continue; > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Mon Nov 30 20:01:35 2009 From: clattner at apple.com (Chris Lattner) Date: Mon, 30 Nov 2009 18:01:35 -0800 Subject: [llvm-commits] [llvm] r89017 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp In-Reply-To: <62C655D3-558C-4A97-968A-15B164A6D60B@apple.com> References: <200911170047.nAH0lNDT014760@zion.cs.uiuc.edu> <09153601-5501-4785-A425-36C9F665A22F@apple.com> <62C655D3-558C-4A97-968A-15B164A6D60B@apple.com> Message-ID: On Nov 30, 2009, at 12:43 PM, Dan Gohman wrote: >>> This fixes some problems caused by these transformations not >>> updating the MachineBasicBlock CFG. >> >> Did you verify that this change doesn't result in any codegen >> change on something large like 403.gcc? It would also be useful to >> check something like crafty on x86-32 and ppc32. > > I had checked a bunch of stuff, though not 403.gcc, and it turns out > 403.gcc > had a missed ConstantExpr folding opportunity. I fixed that in r89659. Thanks! From ofv at wanadoo.es Mon Nov 30 20:21:51 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 01 Dec 2009 02:21:51 -0000 Subject: [llvm-commits] [llvm] r90188 - in /llvm/trunk: CMakeLists.txt docs/CMake.html Message-ID: <200912010221.nB12Lp72007605@zion.cs.uiuc.edu> Author: ofv Date: Mon Nov 30 20:21:51 2009 New Revision: 90188 URL: http://llvm.org/viewvc/llvm-project?rev=90188&view=rev Log: Add two CMake flags LLVM_ENABLE_PEDANTIC and LLVM_ENABLE_WERROR, PEDANTIC defaults to ON and WERROR default to off. Also add MSVC warnings. To disable warnings add the flags LLVM_ENABLE_WARNINGS (default on). Patch by Tobias Grosser! Modified: llvm/trunk/CMakeLists.txt llvm/trunk/docs/CMake.html Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90188&r1=90187&r2=90188&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Mon Nov 30 20:21:51 2009 @@ -191,6 +191,10 @@ add_llvm_definitions( -D__STDC_LIMIT_MACROS ) add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) +option(LLVM_ENABLE_PEDANTIC "Enable compiler warnings." ON) +option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) +option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) + if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) # TODO: support other platforms and toolchains. option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF) @@ -226,8 +230,27 @@ add_llvm_definitions("/${LLVM_USE_CRT}") message(STATUS "Using VC++ CRT: ${LLVM_USE_CRT}") endif (NOT ${LLVM_USE_CRT} STREQUAL "") + + # Enable warnings + if (LLVM_ENABLE_WARNINGS) + add_llvm_definitions( /W4 /Wall ) + if (LLVM_ENABLE_PEDANTIC) + # No MSVC equivalent available + endif (LLVM_ENABLE_PEDANTIC) + endif (LLVM_ENABLE_WARNINGS) + if (LLVM_ENABLE_WERROR) + add_llvm_definitions( /WX ) + endif (LLVM_ENABLE_WERROR) elseif( CMAKE_COMPILER_IS_GNUCXX ) - add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) + if (LLVM_ENABLE_WARNINGS) + add_llvm_definitions( -Wall -W -Wno-unused-parameter -Wwrite-strings ) + if (LLVM_ENABLE_PEDANTIC) + add_llvm_definitions( -pedantic -Wno-long-long ) + endif (LLVM_ENABLE_PEDANTIC) + endif (LLVM_ENABLE_WARNINGS) + if (LLVM_ENABLE_WERROR) + add_llvm_definitions( -Werror ) + endif (LLVM_ENABLE_WERROR) endif( MSVC ) include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) Modified: llvm/trunk/docs/CMake.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.html?rev=90188&r1=90187&r2=90188&view=diff ============================================================================== --- llvm/trunk/docs/CMake.html (original) +++ llvm/trunk/docs/CMake.html Mon Nov 30 20:21:51 2009 @@ -274,10 +274,21 @@ compiler supports this flag. Some systems, like Windows, do not need this flag. Defaults to ON. +
    LLVM_ENABLE_WARNINGS:BOOL
    +
    Enable all compiler warnings. Defaults to ON.
    + +
    LLVM_ENABLE_PEDANTIC:BOOL
    +
    Enable pedantic mode. This disable compiler specific extensions, is + possible. Defaults to ON.
    + +
    LLVM_ENABLE_WERROR:BOOL
    +
    Stop and fail build, if a compiler warning is + triggered. Defaults to OFF.
    +
    LLVM_BUILD_32_BITS:BOOL
    Build 32-bits executables and libraries on 64-bits systems. This - option is available only on some 64-bits unix systems. Defaults to - OFF.
    + option is available only on some 64-bits unix systems. Defaults to + OFF.
    LLVM_TARGET_ARCH:STRING
    LLVM target to use for native code generation. This is required From echristo at apple.com Mon Nov 30 20:26:01 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 02:26:01 -0000 Subject: [llvm-commits] [llvm] r90189 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <200912010226.nB12Q1eB007771@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 20:26:01 2009 New Revision: 90189 URL: http://llvm.org/viewvc/llvm-project?rev=90189&view=rev Log: Add a soft link so that in an apple style build we can find libLTO.dylib. Modified: llvm/trunk/utils/buildit/build_llvm Modified: llvm/trunk/utils/buildit/build_llvm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/build_llvm?rev=90189&r1=90188&r2=90189&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Mon Nov 30 20:26:01 2009 @@ -341,6 +341,14 @@ find $DEST_DIR -name html.tar.gz -exec rm {} \; ################################################################################ +# symlinks so that B&I can find things + +cd $DEST_DIR +mkdir -p ./usr/lib/ +cd usr/lib +ln -s ../../Developer/usr/lib/libLTO.dylib ./libLTO.dylib + +################################################################################ # w00t! Done! exit 0 From echristo at apple.com Mon Nov 30 20:29:55 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 02:29:55 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90190 - /llvm-gcc-4.2/trunk/config/mh-x86-darwin Message-ID: <200912010229.nB12TtQj007899@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 20:29:55 2009 New Revision: 90190 URL: http://llvm.org/viewvc/llvm-project?rev=90190&view=rev Log: Build without pie by default. Modified: llvm-gcc-4.2/trunk/config/mh-x86-darwin Modified: llvm-gcc-4.2/trunk/config/mh-x86-darwin URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/config/mh-x86-darwin?rev=90190&r1=90189&r2=90190&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/config/mh-x86-darwin (original) +++ llvm-gcc-4.2/trunk/config/mh-x86-darwin Mon Nov 30 20:29:55 2009 @@ -3,3 +3,8 @@ # position-independent-code -- the usual default on Darwin. BOOT_CFLAGS=-g -O2 -mdynamic-no-pic + +# LLVM LOCAL +# For hosts after darwin10 we want to pass in -no-pie +BOOT_LDFLAGS=`case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;` +LDFLAGS=$(BOOT_LDFLAGS) From nicholas at mxc.ca Mon Nov 30 20:41:51 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 30 Nov 2009 18:41:51 -0800 Subject: [llvm-commits] [llvm] r90113 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp In-Reply-To: <55965E74-9225-4FC5-A8AB-BDB9FB392168@apple.com> References: <200911300705.nAU75qsb015777@zion.cs.uiuc.edu> <55965E74-9225-4FC5-A8AB-BDB9FB392168@apple.com> Message-ID: <4B14826F.8020909@mxc.ca> Chris Lattner wrote: > > On Nov 29, 2009, at 11:05 PM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Mon Nov 30 01:05:51 2009 >> New Revision: 90113 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90113&view=rev >> Log: >> Revert r90107, fixing test/Transforms/GVN/2009-11-29-ReverseMap.ll and >> the >> llvm-gcc build. > > Uh, no it's not. You're thinking of the previous patch? Yes it is. It's a revert of r90107: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091123/091931.html Nick > > -Chris > >> >> Modified: >> llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp >> >> Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90113&r1=90112&r2=90113&view=diff >> >> >> ============================================================================== >> >> --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) >> +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Nov 30 >> 01:05:51 2009 >> @@ -1156,21 +1156,8 @@ >> // that predecessor. We can still do PRE of the load, which would insert >> // a computation of the pointer in this predecessor. >> if (PredPtr == 0) { >> - // Add the entry to the Result list. >> - NonLocalDepEntry Entry(Pred, >> - MemDepResult::getClobber(Pred->getTerminator())); >> - Result.push_back(Entry); >> - >> - // Add it to the cache for this CacheKey so that subsequent queries get >> - // this result. >> - Cache = &NonLocalPointerDeps[CacheKey].second; >> - MemoryDependenceAnalysis::NonLocalDepInfo::iterator It = >> - std::upper_bound(Cache->begin(), Cache->end(), Entry); >> - Cache->insert(It, Entry); >> - Cache = 0; >> - >> - // Add it to the reverse map next. >> - ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey); >> + Result.push_back(NonLocalDepEntry(Pred, >> + MemDepResult::getClobber(Pred->getTerminator()))); >> continue; >> } >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From stoklund at 2pi.dk Mon Nov 30 21:03:00 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Dec 2009 03:03:00 -0000 Subject: [llvm-commits] [llvm] r90194 - in /llvm/trunk: lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll Message-ID: <200912010303.nB1330FT009415@zion.cs.uiuc.edu> Author: stoklund Date: Mon Nov 30 21:03:00 2009 New Revision: 90194 URL: http://llvm.org/viewvc/llvm-project?rev=90194&view=rev Log: Use CFG connectedness as a secondary sort key when deciding the order of copy coalescing. This means that well connected blocks are copy coalesced before the less connected blocks. Connected blocks are more difficult to coalesce because intervals are more complicated, so handling them first gives a greater chance of success. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=90194&r1=90193&r2=90194&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Nov 30 21:03:00 2009 @@ -2371,9 +2371,19 @@ struct DepthMBBCompare { typedef std::pair DepthMBBPair; bool operator()(const DepthMBBPair &LHS, const DepthMBBPair &RHS) const { - if (LHS.first > RHS.first) return true; // Deeper loops first - return LHS.first == RHS.first && - LHS.second->getNumber() < RHS.second->getNumber(); + // Deeper loops first + if (LHS.first != RHS.first) + return LHS.first > RHS.first; + + // Prefer blocks that are more connected in the CFG. This takes care of + // the most difficult copies first while intervals are short. + unsigned cl = LHS.second->pred_size() + LHS.second->succ_size(); + unsigned cr = RHS.second->pred_size() + RHS.second->succ_size(); + if (cl != cr) + return cl > cr; + + // As a last resort, sort by block number. + return LHS.second->getNumber() < RHS.second->getNumber(); } }; } Modified: llvm/trunk/test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll?rev=90194&r1=90193&r2=90194&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-09-19-SchedCustomLoweringBug.ll Mon Nov 30 21:03:00 2009 @@ -10,6 +10,7 @@ bb: ; preds = %bb1, %entry ; CHECK: addl $1 +; CHECK-NEXT: movl %e ; CHECK-NEXT: adcl $0 %i.0 = phi i64 [ 0, %entry ], [ %0, %bb1 ] ; [#uses=1] %0 = add nsw i64 %i.0, 1 ; [#uses=2] From echristo at apple.com Mon Nov 30 21:18:26 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 03:18:26 -0000 Subject: [llvm-commits] [llvm] r90199 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 21:18:26 2009 New Revision: 90199 URL: http://llvm.org/viewvc/llvm-project?rev=90199&view=rev Log: Remove the gcc builtins from the intrinsics, we'll lower them explicitly so we can check arguments. Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=90199&r1=90198&r2=90199&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Mon Nov 30 21:18:26 2009 @@ -671,10 +671,10 @@ // Align ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_ssse3_palign_r : GCCBuiltin<"__builtin_ia32_palignr">, + def int_x86_ssse3_palign_r : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty, llvm_i8_ty], [IntrNoMem]>; - def int_x86_ssse3_palign_r_128 : GCCBuiltin<"__builtin_ia32_palignr128">, + def int_x86_ssse3_palign_r_128 : Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>; } From echristo at apple.com Mon Nov 30 21:19:40 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 03:19:40 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90200 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200912010319.nB13Jeq8010008@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 21:19:40 2009 New Revision: 90200 URL: http://llvm.org/viewvc/llvm-project?rev=90200&view=rev Log: Lower these explicitly and check for an invalid argument. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=90200&r1=90199&r2=90200&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Nov 30 21:19:40 2009 @@ -606,6 +606,20 @@ Result = Builder.CreateLoad(Ptr); return true; } + case IX86_BUILTIN_PALIGNR: + case IX86_BUILTIN_PALIGNR128: { + if (ConstantInt *Elt = dyn_cast(Ops[2])) { + Function *palignr = + Intrinsic::getDeclaration(TheModule, Intrinsic::x86_ssse3_palign_r_128); + Value *CallOps[3] = { Ops[0], Ops[1], Ops[2] }; + Result = Builder.CreateCall(palignr, CallOps, CallOps+3); + return true; + } else { + error("%Hmask must be an immediate", &EXPR_LOCATION(exp)); + Result = Ops[0]; + return true; + } + } } return false; From echristo at apple.com Mon Nov 30 22:48:09 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 04:48:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90206 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200912010448.nB14mA9W012789@zion.cs.uiuc.edu> Author: echristo Date: Mon Nov 30 22:48:03 2009 New Revision: 90206 URL: http://llvm.org/viewvc/llvm-project?rev=90206&view=rev Log: Use both intrinsics, instead of just the one. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=90206&r1=90205&r2=90206&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Nov 30 22:48:03 2009 @@ -610,7 +610,9 @@ case IX86_BUILTIN_PALIGNR128: { if (ConstantInt *Elt = dyn_cast(Ops[2])) { Function *palignr = - Intrinsic::getDeclaration(TheModule, Intrinsic::x86_ssse3_palign_r_128); + Intrinsic::getDeclaration(TheModule, FnCode == IX86_BUILTIN_PALIGNR ? + Intrinsic::x86_ssse3_palign_r : + Intrinsic::x86_ssse3_palign_r_128); Value *CallOps[3] = { Ops[0], Ops[1], Ops[2] }; Result = Builder.CreateCall(palignr, CallOps, CallOps+3); return true; From sabre at nondot.org Mon Nov 30 23:30:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 30 Nov 2009 23:30:11 -0600 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/index.html Message-ID: <200912010530.nB15UBvl014256@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: index.html updated: 1.30 -> 1.31 --- Log message: no point to list the welcome anymore. --- Diffs of the changes: (+1 -13) index.html | 14 +------------- 1 files changed, 1 insertion(+), 13 deletions(-) Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.30 llvm-www/devmtg/2009-10/index.html:1.31 --- llvm-www/devmtg/2009-10/index.html:1.30 Mon Nov 30 23:29:08 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Nov 30 23:29:47 2009 @@ -53,18 +53,6 @@ - - - - - - - @@ -127,7 +127,7 @@ @@ -197,7 +197,7 @@ @@ -220,7 +220,7 @@ @@ -282,7 +282,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!">Valid HTML 4.01! -
    Last modified: $Date: 2009/10/30 16:27:40 $ +
    Last modified: $Date: 2009/12/01 05:29:08 $ From foldr at codedgers.com Mon Nov 30 23:59:55 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 01 Dec 2009 05:59:55 -0000 Subject: [llvm-commits] [llvm] r90210 - in /llvm/trunk: docs/CommandGuide/llvmc.pod tools/llvmc/plugins/Base/Base.td.in Message-ID: <200912010559.nB15xtUU015492@zion.cs.uiuc.edu> Author: foldr Date: Mon Nov 30 23:59:55 2009 New Revision: 90210 URL: http://llvm.org/viewvc/llvm-project?rev=90210&view=rev Log: Support -[weak_]framework and -F in llvmc. Modified: llvm/trunk/docs/CommandGuide/llvmc.pod llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Modified: llvm/trunk/docs/CommandGuide/llvmc.pod URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CommandGuide/llvmc.pod?rev=90210&r1=90209&r2=90210&view=diff ============================================================================== --- llvm/trunk/docs/CommandGuide/llvmc.pod (original) +++ llvm/trunk/docs/CommandGuide/llvmc.pod Mon Nov 30 23:59:55 2009 @@ -126,24 +126,31 @@ =item B<-I> I -Add a directory to the header file search path. This option can be -repeated. +Add a directory to the header file search path. =item B<-L> I -Add I to the library search path. This option can be -repeated. +Add I to the library search path. + +=item B<-F> I + +Add I to the framework search path. =item B<-l>I Link in the library libI.[bc | a | so]. This library should be a bitcode library. +=item B<-framework> I + +Link in the library libI.[bc | a | so]. This library should +be a bitcode library. + =item B<-emit-llvm> -Make the output be LLVM bitcode (with B<-c>) or assembly (with B<-S>) instead -of native object (or assembly). If B<-emit-llvm> is given without either B<-c> -or B<-S> it has no effect. +Output LLVM bitcode (with B<-c>) or assembly (with B<-S>) instead of native +object (or assembly). If B<-emit-llvm> is given without either B<-c> or B<-S> +it has no effect. =item B<-Wa> @@ -157,6 +164,10 @@ Pass options to opt. +=item B<-Wllc> + +Pass options to llc (code generator). + =back =head1 EXIT STATUS Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90210&r1=90209&r2=90210&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Mon Nov 30 23:59:55 2009 @@ -47,6 +47,12 @@ (hidden)), (parameter_list_option "include", (help "Include the named file prior to preprocessing")), + (parameter_list_option "framework", + (help "Specifies a framework to link against")), + (parameter_list_option "weak_framework", + (help "Specifies a framework to weakly link against"), (hidden)), + (prefix_list_option "F", + (help "Add a directory to framework search path")), (prefix_list_option "I", (help "Add a directory to include path")), (prefix_list_option "D", @@ -106,6 +112,7 @@ (switch_on "fsyntax-only"), (stop_compilation), (not_empty "include"), (forward "include"), (not_empty "I"), (forward "I"), + (not_empty "F"), (forward "F"), (not_empty "D"), (forward "D"), (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), @@ -175,6 +182,9 @@ (actions (case (switch_on "pthread"), (append_cmd "-lpthread"), (not_empty "L"), (forward "L"), + (not_empty "F"), (forward "F"), + (not_empty "framework"), (forward "framework"), + (not_empty "weak_framework"), (forward "weak_framework"), (not_empty "l"), (forward "l"), (not_empty "Wl,"), (forward "Wl,"))) ]>; From sabre at nondot.org Tue Dec 1 00:04:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 06:04:43 -0000 Subject: [llvm-commits] [llvm] r90211 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll Message-ID: <200912010604.nB164hW4015653@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 00:04:43 2009 New Revision: 90211 URL: http://llvm.org/viewvc/llvm-project?rev=90211&view=rev Log: fix PR5640 by tracking whether a block is the header of a loop more precisely, which prevents us from infinitely peeling the loop. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=90211&r1=90210&r2=90211&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Dec 1 00:04:43 2009 @@ -158,12 +158,18 @@ if (BBI->isTerminator()) { // Since TryToSimplifyUncondBranchFromEmptyBlock may delete the // block, we have to make sure it isn't in the LoopHeaders set. We - // reinsert afterward in the rare case when the block isn't deleted. + // reinsert afterward if needed. bool ErasedFromLoopHeaders = LoopHeaders.erase(BB); + BasicBlock *Succ = BI->getSuccessor(0); - if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) + if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) { Changed = true; - else if (ErasedFromLoopHeaders) + // If we deleted BB and BB was the header of a loop, then the + // successor is now the header of the loop. + BB = Succ; + } + + if (ErasedFromLoopHeaders) LoopHeaders.insert(BB); } } Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=90211&r1=90210&r2=90211&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Tue Dec 1 00:04:43 2009 @@ -192,3 +192,23 @@ ret void } + +; PR5640 +define fastcc void @test6(i1 %tmp, i1 %tmp1) nounwind ssp { +entry: + br i1 %tmp, label %bb12, label %bb14 + +bb12: + br label %bb14 + +bb14: + %A = phi i1 [ %A, %bb13 ], [ true, %bb12 ], [%tmp1, %entry] + br label %bb13 + +bb13: + br i1 %A, label %bb14, label %bb61 + + +bb61: + ret void +} From sabre at nondot.org Tue Dec 1 00:22:10 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 06:22:10 -0000 Subject: [llvm-commits] [llvm] r90212 - in /llvm/trunk/test/Transforms/GVN: 2009-11-29-ReverseMap.ll crash.ll Message-ID: <200912010622.nB16MABV016196@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 00:22:10 2009 New Revision: 90212 URL: http://llvm.org/viewvc/llvm-project?rev=90212&view=rev Log: merge 2009-11-29-ReverseMap.ll into crash.ll Removed: llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll Modified: llvm/trunk/test/Transforms/GVN/crash.ll Removed: llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll?rev=90211&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll (original) +++ llvm/trunk/test/Transforms/GVN/2009-11-29-ReverseMap.ll (removed) @@ -1,33 +0,0 @@ -; RUN: opt -gvn -disable-output %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" -target triple = "i386-pc-linux-gnu" - -%struct.attribute_spec = type { i8*, i32, i32, i8, i8, i8 } - - at attribute_tables = external global [4 x %struct.attribute_spec*] ; <[4 x %struct.attribute_spec*]*> [#uses=2] - -define void @decl_attributes() nounwind { -entry: - br label %bb69.i - -bb69.i: ; preds = %bb57.i.preheader - %tmp4 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] - %tmp5 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] - %tmp3 = load %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1] - br label %bb65.i - -bb65.i: ; preds = %bb65.i.preheader, %bb64.i - %storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; [#uses=3] - %scevgep14 = getelementptr inbounds %struct.attribute_spec* %tmp3, i32 %storemerge6.i, i32 0 ; [#uses=1] - %tmp2 = load i8** %scevgep14, align 4 ; [#uses=0] - %tmp = load %struct.attribute_spec** %tmp5, align 4 ; <%struct.attribute_spec*> [#uses=1] - %scevgep1516 = getelementptr inbounds %struct.attribute_spec* %tmp, i32 %storemerge6.i, i32 0 ; [#uses=0] - unreachable - -bb64.i: ; Unreachable - br label %bb65.i - -bb66.i: ; Unreachable - br label %bb69.i -} Modified: llvm/trunk/test/Transforms/GVN/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/crash.ll?rev=90212&r1=90211&r2=90212&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/crash.ll (original) +++ llvm/trunk/test/Transforms/GVN/crash.ll Tue Dec 1 00:22:10 2009 @@ -59,3 +59,37 @@ } declare i32* @parse_object(i8*) + + + + + + +%struct.attribute_spec = type { i8*, i32, i32, i8, i8, i8 } + + at attribute_tables = external global [4 x %struct.attribute_spec*] ; <[4 x %struct.attribute_spec*]*> [#uses=2] + +define void @decl_attributes() nounwind { +entry: + br label %bb69.i + +bb69.i: ; preds = %bb57.i.preheader + %tmp4 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] + %tmp5 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] + %tmp3 = load %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1] + br label %bb65.i + +bb65.i: ; preds = %bb65.i.preheader, %bb64.i + %storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; [#uses=3] + %scevgep14 = getelementptr inbounds %struct.attribute_spec* %tmp3, i32 %storemerge6.i, i32 0 ; [#uses=1] + %tmp2 = load i8** %scevgep14, align 4 ; [#uses=0] + %tmp = load %struct.attribute_spec** %tmp5, align 4 ; <%struct.attribute_spec*> [#uses=1] + %scevgep1516 = getelementptr inbounds %struct.attribute_spec* %tmp, i32 %storemerge6.i, i32 0 ; [#uses=0] + unreachable + +bb64.i: ; Unreachable + br label %bb65.i + +bb66.i: ; Unreachable + br label %bb69.i +} From foldr at codedgers.com Tue Dec 1 00:51:30 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 01 Dec 2009 06:51:30 -0000 Subject: [llvm-commits] [llvm] r90214 - in /llvm/trunk: tools/llvmc/plugins/Base/Base.td.in utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <200912010651.nB16pUZW017137@zion.cs.uiuc.edu> Author: foldr Date: Tue Dec 1 00:51:30 2009 New Revision: 90214 URL: http://llvm.org/viewvc/llvm-project?rev=90214&view=rev Log: Forward -save-temps to llvm-gcc. Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90214&r1=90213&r2=90214&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Tue Dec 1 00:51:30 2009 @@ -111,6 +111,7 @@ (and (switch_on "emit-llvm"), (switch_on "c")), (stop_compilation), (switch_on "fsyntax-only"), (stop_compilation), (not_empty "include"), (forward "include"), + (not_empty "save-temps"), (append_cmd "-save-temps"), (not_empty "I"), (forward "I"), (not_empty "F"), (forward "F"), (not_empty "D"), (forward "D"), Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=90214&r1=90213&r2=90214&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Tue Dec 1 00:51:30 2009 @@ -1155,6 +1155,9 @@ if (OptName == "o") { O << Neg << "OutputFilename.empty()"; } + else if (OptName == "save-temps") { + O << Neg << "(SaveTemps == SaveTempsEnum::Unset)"; + } else { const OptionDescription& OptDesc = OptDescs_.FindListOrParameter(OptName); O << Neg << OptDesc.GenVariableName() << ".empty()"; From sabre at nondot.org Tue Dec 1 01:30:01 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 07:30:01 -0000 Subject: [llvm-commits] [llvm] r90216 - /llvm/trunk/test/Transforms/GVN/crash.ll Message-ID: <200912010730.nB17U1CI018330@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 01:30:01 2009 New Revision: 90216 URL: http://llvm.org/viewvc/llvm-project?rev=90216&view=rev Log: minimize this a bit more. Modified: llvm/trunk/test/Transforms/GVN/crash.ll Modified: llvm/trunk/test/Transforms/GVN/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/crash.ll?rev=90216&r1=90215&r2=90216&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/crash.ll (original) +++ llvm/trunk/test/Transforms/GVN/crash.ll Tue Dec 1 01:30:01 2009 @@ -75,7 +75,6 @@ bb69.i: ; preds = %bb57.i.preheader %tmp4 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] - %tmp5 = getelementptr inbounds [4 x %struct.attribute_spec*]* @attribute_tables, i32 0, i32 undef ; <%struct.attribute_spec**> [#uses=1] %tmp3 = load %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1] br label %bb65.i @@ -83,7 +82,7 @@ %storemerge6.i = phi i32 [ 1, %bb64.i ], [ 0, %bb69.i ] ; [#uses=3] %scevgep14 = getelementptr inbounds %struct.attribute_spec* %tmp3, i32 %storemerge6.i, i32 0 ; [#uses=1] %tmp2 = load i8** %scevgep14, align 4 ; [#uses=0] - %tmp = load %struct.attribute_spec** %tmp5, align 4 ; <%struct.attribute_spec*> [#uses=1] + %tmp = load %struct.attribute_spec** %tmp4, align 4 ; <%struct.attribute_spec*> [#uses=1] %scevgep1516 = getelementptr inbounds %struct.attribute_spec* %tmp, i32 %storemerge6.i, i32 0 ; [#uses=0] unreachable From sabre at nondot.org Tue Dec 1 01:33:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 07:33:33 -0000 Subject: [llvm-commits] [llvm] r90217 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200912010733.nB17XXmK018462@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 01:33:32 2009 New Revision: 90217 URL: http://llvm.org/viewvc/llvm-project?rev=90217&view=rev Log: fix 255.vortex again, third time's the charm. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90217&r1=90216&r2=90217&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Dec 1 01:33:32 2009 @@ -1156,8 +1156,41 @@ // that predecessor. We can still do PRE of the load, which would insert // a computation of the pointer in this predecessor. if (PredPtr == 0) { - Result.push_back(NonLocalDepEntry(Pred, - MemDepResult::getClobber(Pred->getTerminator()))); + // Add the entry to the Result list. + NonLocalDepEntry Entry(Pred, + MemDepResult::getClobber(Pred->getTerminator())); + Result.push_back(Entry); + + // Add it to the cache for this CacheKey so that subsequent queries get + // this result. + Cache = &NonLocalPointerDeps[CacheKey].second; + MemoryDependenceAnalysis::NonLocalDepInfo::iterator It = + std::upper_bound(Cache->begin(), Cache->end(), Entry); + + if (It != Cache->begin() && prior(It)->first == Pred) + --It; + + if (It == Cache->end() || It->first != Pred) { + Cache->insert(It, Entry); + // Add it to the reverse map. + ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey); + } else if (!It->second.isDirty()) { + // noop + } else if (It->second.getInst() == Pred->getTerminator()) { + // Same instruction, clear the dirty marker. + It->second = Entry.second; + } else if (It->second.getInst() == 0) { + // Dirty, with no instruction, just add this. + It->second = Entry.second; + ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey); + } else { + // Otherwise, dirty with a different instruction. + RemoveFromReverseMap(ReverseNonLocalPtrDeps, It->second.getInst(), + CacheKey); + It->second = Entry.second; + ReverseNonLocalPtrDeps[Pred->getTerminator()].insert(CacheKey); + } + Cache = 0; continue; } From grosser at fim.uni-passau.de Tue Dec 1 02:44:29 2009 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 01 Dec 2009 08:44:29 -0000 Subject: [llvm-commits] [llvm] r90220 - /llvm/trunk/CMakeLists.txt Message-ID: <200912010844.nB18iUSw025406@zion.cs.uiuc.edu> Author: grosser Date: Tue Dec 1 02:43:33 2009 New Revision: 90220 URL: http://llvm.org/viewvc/llvm-project?rev=90220&view=rev Log: Fix copy paste bug Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90220&r1=90219&r2=90220&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Dec 1 02:43:33 2009 @@ -191,7 +191,7 @@ add_llvm_definitions( -D__STDC_LIMIT_MACROS ) add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) -option(LLVM_ENABLE_PEDANTIC "Enable compiler warnings." ON) +option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) From baldrick at free.fr Tue Dec 1 02:50:39 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 09:50:39 +0100 Subject: [llvm-commits] [llvm] r90199 - /llvm/trunk/include/llvm/IntrinsicsX86.td In-Reply-To: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> References: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> Message-ID: <4B14D8DF.1050600@free.fr> Hi Eric, > Remove the gcc builtins from the intrinsics, we'll lower them > explicitly so we can check arguments. I think the gcc builtin is also used by the C backend to go from the LLVM intrinsic to the gcc intrinsic. Instead of doing this, how about flipping the logic in EmitBuiltinCall so it only checks getIntrinsicForGCCBuiltin if EmitFrontendExpandedBuiltinCall fails, rather than the other way round like now. Ciao, Duncan. From baldrick at free.fr Tue Dec 1 02:51:57 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 09:51:57 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r90200 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp In-Reply-To: <200912010319.nB13Jeq8010008@zion.cs.uiuc.edu> References: <200912010319.nB13Jeq8010008@zion.cs.uiuc.edu> Message-ID: <4B14D92D.907@free.fr> > Lower these explicitly and check for an invalid argument. Testcase? Ciao, Duncan. From echristo at apple.com Tue Dec 1 02:52:11 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 1 Dec 2009 00:52:11 -0800 Subject: [llvm-commits] [llvm] r90199 - /llvm/trunk/include/llvm/IntrinsicsX86.td In-Reply-To: <4B14D8DF.1050600@free.fr> References: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> <4B14D8DF.1050600@free.fr> Message-ID: <118435E1-59F4-48C5-8F5D-8991E4D71A41@apple.com> On Dec 1, 2009, at 12:50 AM, Duncan Sands wrote: > Hi Eric, > >> Remove the gcc builtins from the intrinsics, we'll lower them >> explicitly so we can check arguments. > > I think the gcc builtin is also used by the C backend to go from the > LLVM intrinsic to the gcc intrinsic. Instead of doing this, how about > flipping the logic in EmitBuiltinCall so it only checks > getIntrinsicForGCCBuiltin if EmitFrontendExpandedBuiltinCall fails, > rather than the other way round like now. Seems like a rather good plan. I'll need to do that for clang as well. I'll get to it in the next day or so. -eric From foldr at codedgers.com Tue Dec 1 03:19:10 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 01 Dec 2009 09:19:10 -0000 Subject: [llvm-commits] [llvm] r90221 - /llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Message-ID: <200912010919.nB19JAQM003641@zion.cs.uiuc.edu> Author: foldr Date: Tue Dec 1 03:19:09 2009 New Revision: 90221 URL: http://llvm.org/viewvc/llvm-project?rev=90221&view=rev Log: Typo. Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Modified: llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst?rev=90221&r1=90220&r2=90221&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst (original) +++ llvm/trunk/tools/llvmc/doc/LLVMC-Reference.rst Tue Dec 1 03:19:09 2009 @@ -448,7 +448,7 @@ - ``element_in_list`` - Returns true if a command-line parameter list contains a given value. - Example: ``(parameter_in_list "l", "pthread")``. + Example: ``(element_in_list "l", "pthread")``. - ``input_languages_contain`` - Returns true if a given language belongs to the current input language set. From foldr at codedgers.com Tue Dec 1 03:47:12 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 01 Dec 2009 09:47:12 -0000 Subject: [llvm-commits] [llvm] r90222 - /llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Message-ID: <200912010947.nB19lCo0004619@zion.cs.uiuc.edu> Author: foldr Date: Tue Dec 1 03:47:11 2009 New Revision: 90222 URL: http://llvm.org/viewvc/llvm-project?rev=90222&view=rev Log: Add relocation model options. Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90222&r1=90221&r2=90222&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Tue Dec 1 03:47:11 2009 @@ -38,6 +38,10 @@ (help "Compile and assemble, but do not link")), (switch_option "pthread", (help "Enable threads")), + (switch_option "fPIC", + (help "Relocation model: PIC"), (hidden)), + (switch_option "mdynamic-no-pic", + (help "Relocation model: dynamic-no-pic"), (hidden)), (parameter_option "linker", (help "Choose linker (possible values: gcc, g++)")), (parameter_option "MF", @@ -118,6 +122,8 @@ (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), (switch_on "O3"), (forward "O3"), + (switch_on "fPIC"), (forward "fPIC"), + (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"), (not_empty "MF"), (forward "MF"), (not_empty "MT"), (forward "MT"))), (sink) @@ -170,6 +176,9 @@ (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), (switch_on "O3"), (forward "O3"), + (switch_on "fPIC"), (append_cmd "-relocation-model=pic"), + (switch_on "mdynamic-no-pic"), + (append_cmd "-relocation-model=dynamic-no-pic"), (not_empty "Wllc,"), (unpack_values "Wllc,"))) ]>; From baldrick at free.fr Tue Dec 1 03:58:03 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 09:58:03 -0000 Subject: [llvm-commits] [dragonegg] r90224 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912010958.nB19w3Kp005144@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 03:58:02 2009 New Revision: 90224 URL: http://llvm.org/viewvc/llvm-project?rev=90224&view=rev Log: Use EmitGimpleReg in many more places, in fact almost everywhere that Emit(XYZ, 0) was used. 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=90224&r1=90223&r2=90224&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 03:58:02 2009 @@ -1180,32 +1180,43 @@ //FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(exp); break; //FIXME case FILTER_EXPR: Result = EmitFILTER_EXPR(exp); break; - // Expressions + // References (tcc_reference). case ARRAY_REF: case ARRAY_RANGE_REF: case BIT_FIELD_REF: case COMPONENT_REF: case INDIRECT_REF: + case VIEW_CONVERT_EXPR: + Result = EmitLoadOfLValue(exp, DestLoc); + break; + + case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break + case IMAGPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 1); break; + + // Declarations (tcc_declaration). case PARM_DECL: case RESULT_DECL: - case STRING_CST: case VAR_DECL: - case VIEW_CONVERT_EXPR: Result = EmitLoadOfLValue(exp, DestLoc); break; - case SSA_NAME: Result = EmitSSA_NAME(exp); break; - case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(exp); break; - case ADDR_EXPR: Result = EmitADDR_EXPR(exp); break; - - // Unary Operators - case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break; - case IMAGPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 1); break; - case CONSTRUCTOR: Result = EmitCONSTRUCTOR(exp, DestLoc); break; - // Complex Math Expressions. - case COMPLEX_CST: Result = TreeConstantToLLVM::ConvertCOMPLEX_CST(exp); break; + // Constants (tcc_constant). + case STRING_CST: + Result = EmitLoadOfLValue(exp, DestLoc); + break; - // Constant Expressions + // Expressions (tcc_expression). + case ADDR_EXPR: Result = EmitADDR_EXPR(exp); break; + case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(exp); break; + + // Exceptional (tcc_exceptional). + case CONSTRUCTOR: Result = EmitCONSTRUCTOR(exp, DestLoc); break; + case SSA_NAME: Result = EmitSSA_NAME(exp); break; + + // Constants (tcc_constant). + case COMPLEX_CST: + Result = TreeConstantToLLVM::ConvertCOMPLEX_CST(exp); + break; case INTEGER_CST: Result = TreeConstantToLLVM::ConvertINTEGER_CST(exp); break; @@ -1536,7 +1547,7 @@ } } - Value *TypeSize = Emit(TYPE_SIZE_UNIT(type), 0); + Value *TypeSize = EmitGimpleReg(TYPE_SIZE_UNIT(type)); EmitMemCpy(DestLoc.Ptr, SrcLoc.Ptr, TypeSize, std::min(DestLoc.getAlignment(), SrcLoc.getAlignment())); } @@ -1589,7 +1600,7 @@ } EmitMemSet(DestLoc.Ptr, ConstantInt::get(Type::getInt8Ty(Context), 0), - Emit(TYPE_SIZE_UNIT(type), 0), DestLoc.getAlignment()); + EmitGimpleReg(TYPE_SIZE_UNIT(type)), DestLoc.getAlignment()); } Value *TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, @@ -1746,7 +1757,7 @@ Ty = ConvertType(type); } else { // Compute the variable's size in bytes. - Size = Emit(DECL_SIZE_UNIT(decl), 0); + Size = EmitGimpleReg(DECL_SIZE_UNIT(decl)); Ty = Type::getInt8Ty(Context); Size = Builder.CreateIntCast(Size, Type::getInt32Ty(Context), /*isSigned*/false); @@ -1898,7 +1909,7 @@ //FIXME // Add the type infos. //FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { //FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(Emit(TType, 0)); +//FIXME Args.push_back(EmitGimpleReg(TType)); //FIXME } //FIXME } else if (RegionKind > 0) { //FIXME // Catch. @@ -1913,7 +1924,7 @@ //FIXME // Add the type infos. //FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { //FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(Emit(TType, 0)); +//FIXME Args.push_back(EmitGimpleReg(TType)); //FIXME } //FIXME } //FIXME } @@ -1937,7 +1948,7 @@ //FIXME Type::getInt8PtrTy(Context)); //FIXME else //FIXME // This language has a type that catches all others. -//FIXME CatchAll = Emit(catch_all_type, 0); +//FIXME CatchAll = EmitGimpleReg(catch_all_type); //FIXME } //FIXME Args.push_back(CatchAll); //FIXME } @@ -1997,7 +2008,7 @@ //FIXME //FIXME Value *Cond = NULL; //FIXME for (; TypeList; TypeList = TREE_CHAIN (TypeList)) { -//FIXME Value *TType = Emit(lookup_type_for_runtime(TREE_VALUE(TypeList)), 0); +//FIXME Value *TType = EmitGimpleReg(lookup_type_for_runtime(TREE_VALUE(TypeList))); //FIXME TType = Builder.CreateBitCast(TType, //FIXME Type::getInt8PtrTy(Context)); //FIXME @@ -2492,7 +2503,7 @@ } Value *TreeToLLVM::EmitOBJ_TYPE_REF(tree exp) { - return Builder.CreateBitCast(Emit(OBJ_TYPE_REF_EXPR(exp), 0), + return Builder.CreateBitCast(EmitGimpleReg(OBJ_TYPE_REF_EXPR(exp)), ConvertType(TREE_TYPE(exp))); } @@ -2514,7 +2525,7 @@ && "Not calling a function pointer?"); tree function_type = TREE_TYPE(TREE_TYPE (call_expr)); - Value *Callee = Emit(call_expr, 0); + Value *Callee = EmitGimpleReg(call_expr); CallingConv::ID CallingConv; AttrListPtr PAL; @@ -2866,7 +2877,7 @@ // Pass the static chain, if any, as the first parameter. if (gimple_call_chain(stmt)) - CallOperands.push_back(Emit(gimple_call_chain(stmt), 0)); + CallOperands.push_back(EmitGimpleReg(gimple_call_chain(stmt))); // Loop over the arguments, expanding them and adding them to the op list. std::vector ScalarArgs; @@ -2878,7 +2889,7 @@ // Push the argument. if (ArgTy->isSingleValueType()) { // A scalar - push the value. - Client.pushValue(Emit(arg, 0)); + Client.pushValue(EmitGimpleReg(arg)); } else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, ArgTy)) { if (AGGREGATE_TYPE_P(type)) { // Pass the aggregate as a first class value. @@ -2886,7 +2897,7 @@ Client.pushValue(Builder.CreateLoad(ArgVal.Ptr)); } else { // Already first class (eg: a complex number) - push the value. - Client.pushValue(Emit(arg, 0)); + Client.pushValue(EmitGimpleReg(arg)); } } else { if (AGGREGATE_TYPE_P(type)) { @@ -2898,7 +2909,7 @@ // A first class value (eg: a complex number). Push the address of a // temporary copy. Value *Copy = CreateTemporary(ArgTy); - Builder.CreateStore(Emit(arg, 0), Copy); + Builder.CreateStore(EmitGimpleReg(arg), Copy); Client.pushAddress(Copy); } } @@ -2999,7 +3010,7 @@ // Scalar to scalar copy. assert(!AGGREGATE_TYPE_P(TREE_TYPE(op)) && "Aggregate to scalar nop_expr!"); - return CastToAnyType(Emit(op, 0), OpIsSigned, Ty, ExpIsSigned); + return CastToAnyType(EmitGimpleReg(op), OpIsSigned, Ty, ExpIsSigned); } else if (AGGREGATE_TYPE_P(TREE_TYPE(op))) { // Aggregate to aggregate copy. MemRef NewLoc = *DestLoc; @@ -3011,7 +3022,7 @@ } // Scalar to aggregate copy. - Value *OpVal = Emit(op, 0); + Value *OpVal = EmitGimpleReg(op); Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, PointerType::getUnqual(OpVal->getType())); StoreInst *St = Builder.CreateStore(OpVal, Ptr, DestLoc->Volatile); @@ -3022,11 +3033,12 @@ Value *TreeToLLVM::EmitCONVERT_EXPR(tree type, tree op) { bool OpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op)); bool ExpIsSigned = !TYPE_UNSIGNED(type); - return CastToAnyType(Emit(op, 0), OpIsSigned, ConvertType(type), ExpIsSigned); + return CastToAnyType(EmitGimpleReg(op), OpIsSigned, ConvertType(type), + ExpIsSigned); } Value *TreeToLLVM::EmitNEGATE_EXPR(tree op) { - Value *V = Emit(op, 0); + Value *V = EmitGimpleReg(op); if (TREE_CODE(TREE_TYPE(op)) != COMPLEX_TYPE) { if (V->getType()->isFPOrFPVector()) @@ -3050,7 +3062,7 @@ Value *TreeToLLVM::EmitCONJ_EXPR(tree op) { // ~(a+ib) = a + i*-b Value *R, *I; - SplitComplex(Emit(op, 0), R, I); + SplitComplex(EmitGimpleReg(op), R, I); if (I->getType()->isFloatingPoint()) I = Builder.CreateFNeg(I); else @@ -4145,7 +4157,7 @@ Emit(OpVal, &OpLoc); Operands.push_back(Builder.CreateLoad(OpLoc.Ptr)); } else { - Operands.push_back(Emit(OpVal, 0)); + Operands.push_back(EmitGimpleReg(OpVal)); } } @@ -4178,8 +4190,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4203,9 +4215,9 @@ TreeToLLVM::BuildCmpAndSwapAtomicBuiltin(gimple stmt, tree type, bool isBool) { const Type *ResultTy = ConvertType(type); Value* C[3] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0), - Emit(gimple_call_arg(stmt, 2), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)), + EmitGimpleReg(gimple_call_arg(stmt, 2)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4352,8 +4364,8 @@ } Value* Args[] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; // Grab the current return type. @@ -4377,7 +4389,7 @@ case BUILT_IN_CLZ: // These GCC builtins always return int. case BUILT_IN_CLZL: case BUILT_IN_CLZLL: { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctlz); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4389,7 +4401,7 @@ case BUILT_IN_CTZ: // These GCC builtins always return int. case BUILT_IN_CTZL: case BUILT_IN_CTZLL: { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::cttz); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4401,7 +4413,7 @@ case BUILT_IN_PARITYLL: case BUILT_IN_PARITYL: case BUILT_IN_PARITY: { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctpop); Result = Builder.CreateBinOp(Instruction::And, Result, ConstantInt::get(Result->getType(), 1)); @@ -4410,7 +4422,7 @@ case BUILT_IN_POPCOUNT: // These GCC builtins always return int. case BUILT_IN_POPCOUNTL: case BUILT_IN_POPCOUNTLL: { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctpop); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4421,7 +4433,7 @@ } case BUILT_IN_BSWAP32: case BUILT_IN_BSWAP64: { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::bswap); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4457,7 +4469,7 @@ case BUILT_IN_LOGL: // If errno math has been disabled, expand these to llvm.log calls. if (!flag_errno_math) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4468,7 +4480,7 @@ case BUILT_IN_LOG2L: // If errno math has been disabled, expand these to llvm.log2 calls. if (!flag_errno_math) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log2); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4479,7 +4491,7 @@ case BUILT_IN_LOG10L: // If errno math has been disabled, expand these to llvm.log10 calls. if (!flag_errno_math) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log10); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4490,7 +4502,7 @@ case BUILT_IN_EXPL: // If errno math has been disabled, expand these to llvm.exp calls. if (!flag_errno_math) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::exp); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4501,7 +4513,7 @@ case BUILT_IN_EXP2L: // If errno math has been disabled, expand these to llvm.exp2 calls. if (!flag_errno_math) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::exp2); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4512,7 +4524,7 @@ case BUILT_IN_FFSLL: { // FFS(X) -> (x == 0 ? 0 : CTTZ(x)+1) // The argument and return type of cttz should match the argument type of // the ffs, but should ignore the return type of ffs. - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::cttz); Result = Builder.CreateAdd(Result, ConstantInt::get(Result->getType(), 1)); @@ -4553,9 +4565,9 @@ //TODO //TODO // Get arguments. //TODO tree arglist = CALL_EXPR_ARGS(stmt); -//TODO Value *ExprVal = Emit(gimple_call_arg(stmt, 0), 0); +//TODO Value *ExprVal = EmitGimpleReg(gimple_call_arg(stmt, 0)); //TODO const Type *Ty = ExprVal->getType(); -//TODO Value *StrVal = Emit(gimple_call_arg(stmt, 1), 0); +//TODO Value *StrVal = EmitGimpleReg(gimple_call_arg(stmt, 1)); //TODO //TODO SmallVector Args; //TODO Args.push_back(ExprVal); @@ -4716,8 +4728,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4756,8 +4768,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4796,8 +4808,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4836,8 +4848,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4876,8 +4888,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4916,8 +4928,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - Emit(gimple_call_arg(stmt, 0), 0), - Emit(gimple_call_arg(stmt, 1), 0) + EmitGimpleReg(gimple_call_arg(stmt, 0)), + EmitGimpleReg(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4969,7 +4981,7 @@ case BUILT_IN_LOCK_RELEASE_8: Ty = Type::getInt64Ty(Context); break; } - Value *Ptr = Emit(gimple_call_arg(stmt, 0), 0); + Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); Ptr = Builder.CreateBitCast(Ptr, Ty->getPointerTo()); Builder.CreateStore(Constant::getNullValue(Ty), Ptr, true); Result = 0; @@ -4985,7 +4997,7 @@ tree value = gimple_call_arg(stmt, 1); if (TREE_CODE(value) != INTEGER_CST || - cast(Emit(value, 0))->getValue() != 1) { + cast(EmitGimpleReg(value))->getValue() != 1) { error ("%<__builtin_longjmp%> second argument must be 1"); return false; } @@ -5029,7 +5041,7 @@ } Value *TreeToLLVM::EmitBuiltinSQRT(gimple stmt) { - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); const Type* Ty = Amt->getType(); return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -5041,8 +5053,8 @@ if (!validate_gimple_arglist(stmt, REAL_TYPE, INTEGER_TYPE, VOID_TYPE)) return 0; - Value *Val = Emit(gimple_call_arg(stmt, 0), 0); - Value *Pow = Emit(gimple_call_arg(stmt, 1), 0); + Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Pow = EmitGimpleReg(gimple_call_arg(stmt, 1)); const Type *Ty = Val->getType(); Pow = Builder.CreateIntCast(Pow, Type::getInt32Ty(Context), /*isSigned*/true); @@ -5058,8 +5070,8 @@ if (!validate_gimple_arglist(stmt, REAL_TYPE, REAL_TYPE, VOID_TYPE)) return 0; - Value *Val = Emit(gimple_call_arg(stmt, 0), 0); - Value *Pow = Emit(gimple_call_arg(stmt, 1), 0); + Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Pow = EmitGimpleReg(gimple_call_arg(stmt, 1)); const Type *Ty = Val->getType(); SmallVector Args; @@ -5077,7 +5089,7 @@ bool TreeToLLVM::EmitBuiltinExtendPointer(gimple stmt, Value *&Result) { tree arg0 = gimple_call_arg(stmt, 0); - Value *Amt = Emit(arg0, 0); + Value *Amt = EmitGimpleReg(arg0); bool AmtIsSigned = !TYPE_UNSIGNED(TREE_TYPE(arg0)); bool ExpIsSigned = !TYPE_UNSIGNED(gimple_call_return_type(stmt)); Result = CastToAnyType(Amt, AmtIsSigned, @@ -5133,12 +5145,12 @@ unsigned SrcAlign = getPointerAlignment(Src); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = Emit(Dst, 0); - Value *SrcV = Emit(Src, 0); - Value *Len = Emit(gimple_call_arg(stmt, 2), 0); + Value *DstV = EmitGimpleReg(Dst); + Value *SrcV = EmitGimpleReg(Src); + Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 2)); if (SizeCheck) { tree SizeArg = gimple_call_arg(stmt, 3); - Value *Size = Emit(SizeArg, 0); + Value *Size = EmitGimpleReg(SizeArg); if (!OptimizeIntoPlainBuiltIn(stmt, Len, Size)) return false; } @@ -5163,12 +5175,12 @@ tree Dst = gimple_call_arg(stmt, 0); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = Emit(Dst, 0); - Value *Val = Emit(gimple_call_arg(stmt, 1), 0); - Value *Len = Emit(gimple_call_arg(stmt, 2), 0); + Value *DstV = EmitGimpleReg(Dst); + Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 2)); if (SizeCheck) { tree SizeArg = gimple_call_arg(stmt, 3); - Value *Size = Emit(SizeArg, 0); + Value *Size = EmitGimpleReg(SizeArg); if (!OptimizeIntoPlainBuiltIn(stmt, Len, Size)) return false; } @@ -5183,9 +5195,9 @@ tree Dst = gimple_call_arg(stmt, 0); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = Emit(Dst, 0); + Value *DstV = EmitGimpleReg(Dst); Value *Val = Constant::getNullValue(Type::getInt32Ty(Context)); - Value *Len = Emit(gimple_call_arg(stmt, 1), 0); + Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 1)); EmitMemSet(DstV, Val, Len, DstAlign); return true; } @@ -5194,12 +5206,12 @@ if (!validate_gimple_arglist(stmt, POINTER_TYPE, 0)) return false; - Value *Ptr = Emit(gimple_call_arg(stmt, 0), 0); + Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); Value *ReadWrite = 0; Value *Locality = 0; if (gimple_call_num_args(stmt) > 1) { // Args 1/2 are optional - ReadWrite = Emit(gimple_call_arg(stmt, 1), 0); + ReadWrite = EmitGimpleReg(gimple_call_arg(stmt, 1)); if (!isa(ReadWrite)) { error("second argument to %<__builtin_prefetch%> must be a constant"); ReadWrite = 0; @@ -5214,7 +5226,7 @@ } if (gimple_call_num_args(stmt) > 2) { - Locality = Emit(gimple_call_arg(stmt, 2), 0); + Locality = EmitGimpleReg(gimple_call_arg(stmt, 2)); if (!isa(Locality)) { error("third argument to %<__builtin_prefetch%> must be a constant"); Locality = 0; @@ -5251,7 +5263,7 @@ return false; ConstantInt *Level = - dyn_cast(Emit(gimple_call_arg(stmt, 0), 0)); + dyn_cast(EmitGimpleReg(gimple_call_arg(stmt, 0))); if (!Level) { if (isFrame) error("invalid argument to %<__builtin_frame_address%>"); @@ -5269,7 +5281,7 @@ } bool TreeToLLVM::EmitBuiltinExtractReturnAddr(gimple stmt, Value *&Result) { - Value *Ptr = Emit(gimple_call_arg(stmt, 0), 0); + Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); // FIXME: Actually we should do something like this: // @@ -5284,7 +5296,7 @@ } bool TreeToLLVM::EmitBuiltinFrobReturnAddr(gimple stmt, Value *&Result) { - Value *Ptr = Emit(gimple_call_arg(stmt, 0), 0); + Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); // FIXME: Actually we should do something like this: // @@ -5389,8 +5401,8 @@ return false; const Type *IntPtr = TD.getIntPtrType(Context); - Value *Offset = Emit(gimple_call_arg(stmt, 0), 0); - Value *Handler = Emit(gimple_call_arg(stmt, 1), 0); + Value *Offset = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Handler = EmitGimpleReg(gimple_call_arg(stmt, 1)); Intrinsic::ID IID = (IntPtr == Type::getInt32Ty(Context) ? Intrinsic::eh_return_i32 : Intrinsic::eh_return_i64); @@ -5424,7 +5436,7 @@ } Value *Addr = - Builder.CreateBitCast(Emit(gimple_call_arg(stmt, 0), 0), + Builder.CreateBitCast(EmitGimpleReg(gimple_call_arg(stmt, 0)), Type::getInt8PtrTy(Context)); Constant *Size, *Idx; @@ -5489,7 +5501,7 @@ if (!validate_gimple_arglist(stmt, POINTER_TYPE, VOID_TYPE)) return false; - Value *Ptr = Emit(gimple_call_arg(stmt, 0), 0); + Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -5501,7 +5513,7 @@ bool TreeToLLVM::EmitBuiltinAlloca(gimple stmt, Value *&Result) { if (!validate_gimple_arglist(stmt, INTEGER_TYPE, VOID_TYPE)) return false; - Value *Amt = Emit(gimple_call_arg(stmt, 0), 0); + Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); Amt = Builder.CreateIntCast(Amt, Type::getInt32Ty(Context), /*isSigned*/true); Result = Builder.CreateAlloca(Type::getInt8Ty(Context), Amt); return true; @@ -5532,14 +5544,14 @@ } Constant *va_start = Intrinsic::getDeclaration(TheModule, Intrinsic::vastart); - Value *ArgVal = Emit(gimple_call_arg(stmt, 0), 0); + Value *ArgVal = EmitGimpleReg(gimple_call_arg(stmt, 0)); ArgVal = Builder.CreateBitCast(ArgVal, Type::getInt8PtrTy(Context)); Builder.CreateCall(va_start, ArgVal); return true; } bool TreeToLLVM::EmitBuiltinVAEnd(gimple stmt) { - Value *Arg = Emit(gimple_call_arg(stmt, 0), 0); + Value *Arg = EmitGimpleReg(gimple_call_arg(stmt, 0)); Arg = Builder.CreateBitCast(Arg, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::vaend), Arg); @@ -5550,19 +5562,19 @@ tree Arg1T = gimple_call_arg(stmt, 0); tree Arg2T = gimple_call_arg(stmt, 1); - Value *Arg1 = Emit(Arg1T, 0); // Emit the address of the destination. + Value *Arg1 = EmitGimpleReg(Arg1T); // Emit the address of the destination. // The second arg of llvm.va_copy is a pointer to a valist. Value *Arg2; if (!AGGREGATE_TYPE_P(va_list_type_node)) { // Emit it as a value, then store it to a temporary slot. - Value *V2 = Emit(Arg2T, 0); + Value *V2 = EmitGimpleReg(Arg2T); Arg2 = CreateTemporary(V2->getType()); Builder.CreateStore(V2, Arg2); } else { // If the target has aggregate valists, then the second argument // from GCC is the address of the source valist and we don't // need to do anything special. - Arg2 = Emit(Arg2T, 0); + Arg2 = EmitGimpleReg(Arg2T); } static const Type *VPTy = Type::getInt8PtrTy(Context); @@ -5623,8 +5635,8 @@ TrampTmp->setAlignment(TRAMPOLINE_ALIGNMENT); TrampTmp->setName("TRAMP"); - Value *Func = Emit(gimple_call_arg(stmt, 1), 0); - Value *Chain = Emit(gimple_call_arg(stmt, 2), 0); + Value *Func = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Chain = EmitGimpleReg(gimple_call_arg(stmt, 2)); Value *Ops[3] = { Builder.CreateBitCast(TrampTmp, VPTy), @@ -5639,7 +5651,7 @@ // Store the llvm.init.trampoline result to the GCC trampoline storage. assert(TD.getPointerSize() <= TRAMPOLINE_SIZE && "Trampoline smaller than a pointer!"); - Value *Tramp = Emit(gimple_call_arg(stmt, 0), 0); + Value *Tramp = EmitGimpleReg(gimple_call_arg(stmt, 0)); Tramp = Builder.CreateBitCast(Tramp, Adjusted->getType()->getPointerTo()); StoreInst *Store = Builder.CreateStore(Adjusted, Tramp); @@ -5676,7 +5688,7 @@ } Value *TreeToLLVM::EmitCOMPLEX_EXPR(tree op0, tree op1) { - return CreateComplex(Emit(op0, 0), Emit(op1, 0)); + return CreateComplex(EmitGimpleReg(op0), EmitGimpleReg(op1)); } // EmitComplexBinOp - Note that this operates on binops like ==/!=, which return @@ -5684,9 +5696,9 @@ Value *TreeToLLVM::EmitComplexBinOp(tree type, tree_code code, tree op0, tree op1) { Value *LHSr, *LHSi; - SplitComplex(Emit(op0, 0), LHSr, LHSi); + SplitComplex(EmitGimpleReg(op0), LHSr, LHSi); Value *RHSr, *RHSi; - SplitComplex(Emit(op1, 0), RHSr, RHSi); + SplitComplex(EmitGimpleReg(op1), RHSr, RHSi); Value *DSTr, *DSTi; switch (code) { @@ -5835,12 +5847,12 @@ unsigned ArrayAlign; // First subtract the lower bound, if any, in the type of the index. - Value *IndexVal = Emit(Index, 0); + Value *IndexVal = EmitGimpleReg(Index); tree LowerBound = array_ref_low_bound(exp); if (!integer_zerop(LowerBound)) IndexVal = TYPE_UNSIGNED(TREE_TYPE(Index)) ? - Builder.CreateSub(IndexVal, Emit(LowerBound, 0)) : - Builder.CreateNSWSub(IndexVal, Emit(LowerBound, 0)); + Builder.CreateSub(IndexVal, EmitGimpleReg(LowerBound)) : + Builder.CreateNSWSub(IndexVal, EmitGimpleReg(LowerBound)); LValue ArrayAddrLV = EmitLV(Array); assert(!ArrayAddrLV.isBitfield() && "Arrays cannot be bitfields!"); @@ -5883,7 +5895,7 @@ assert(TREE_OPERAND(exp, 3) && "Size missing for variable sized element!"); // ScaleFactor is the size of the element type in units divided by (exactly) // TYPE_ALIGN_UNIT(ElementType). - Value *ScaleFactor = Builder.CreateIntCast(Emit(TREE_OPERAND(exp, 3), 0), + Value *ScaleFactor = Builder.CreateIntCast(EmitGimpleReg(TREE_OPERAND(exp, 3)), IntPtrTy, /*isSigned*/false); assert(isPowerOf2_32(TYPE_ALIGN(ElementType)) && "Alignment not a power of two!"); @@ -6245,9 +6257,9 @@ LValue TreeToLLVM::EmitLV_INDIRECT_REF(tree exp) { // The lvalue is just the address. - LValue LV = LValue(Emit(TREE_OPERAND(exp, 0), 0), expr_align(exp) / 8); - // Correct for implicit type conversion: INDIRECT_REF can be applied to a - // void*, resulting in a non-void type. + LValue LV = LValue(EmitGimpleReg(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); + // May need a useless type conversion (useless_type_conversion_p), for example + // when INDIRECT_REF is applied to a void*, resulting in a non-void type. LV.Ptr = Builder.CreateBitCast(LV.Ptr, ConvertType(TREE_TYPE(exp))->getPointerTo()); return LV; @@ -6267,7 +6279,7 @@ // TODO: Check the VCE is being used as an rvalue, see EmitLoadOfLValue. // If the input is a scalar, emit to a temporary. Value *Dest = CreateTemporary(ConvertType(TREE_TYPE(Op))); - Builder.CreateStore(Emit(Op, 0), Dest); + Builder.CreateStore(EmitGimpleReg(Op), Dest); // The type is the type of the expression. Dest = Builder.CreateBitCast(Dest, PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); @@ -6547,7 +6559,7 @@ // should be a bit in the label identifying it as in an asm. Op = getLabelDeclBlock(TREE_OPERAND(Val, 0)); } else - Op = Emit(Val, 0); + Op = EmitGimpleReg(Val); } else { LValue LV = EmitLV(Val); assert(!LV.isBitfield() && "Inline asm can't have bitfield operand"); @@ -6851,7 +6863,7 @@ MemRef DestLoc(DECL_LOCAL(result), 1, false); // FIXME: What alignment? Emit(retval, &DestLoc); } else { - Value *Val = Builder.CreateBitCast(Emit(retval, 0), + Value *Val = Builder.CreateBitCast(EmitGimpleReg(retval), ConvertType(TREE_TYPE(result))); Builder.CreateStore(Val, DECL_LOCAL(result)); } @@ -6863,7 +6875,7 @@ void TreeToLLVM::RenderGIMPLE_SWITCH(gimple stmt) { // Emit the condition. - Value *Index = Emit(gimple_switch_index(stmt), 0); + Value *Index = EmitGimpleReg(gimple_switch_index(stmt)); bool IndexIsSigned = !TYPE_UNSIGNED(TREE_TYPE(gimple_switch_index(stmt))); // Create the switch instruction. @@ -6878,7 +6890,7 @@ BasicBlock *Dest = getLabelDeclBlock(CASE_LABEL(label)); // Convert the integer to the right type. - Value *Val = Emit(CASE_LOW(label), 0); + Value *Val = EmitGimpleReg(CASE_LOW(label)); Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(CASE_LOW(label))), Index->getType(), IndexIsSigned); ConstantInt *LowC = cast(Val); @@ -6889,7 +6901,7 @@ } // Otherwise, we have a range, like 'case 1 ... 17'. - Val = Emit(CASE_HIGH(label), 0); + Val = EmitGimpleReg(CASE_HIGH(label)); // Make sure the case value is the same type as the switch expression Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(CASE_HIGH(label))), Index->getType(), IndexIsSigned); @@ -6945,7 +6957,7 @@ unsigned HOST_WIDE_INT idx; tree value; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) { - Value *Elt = Emit(value, 0); + Value *Elt = EmitGimpleReg(value); if (const VectorType *EltTy = dyn_cast(Elt->getType())) { // GCC allows vectors to be built up from vectors. Extract all of the @@ -7004,7 +7016,7 @@ assert(V == 0 && "Aggregate value returned in a register?"); } else { // Scalar value. Evaluate to a register, then do the store. - Value *V = Emit(tree_value, 0); + Value *V = EmitGimpleReg(tree_value); Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, PointerType::getUnqual(V->getType())); StoreInst *St = Builder.CreateStore(V, Ptr, DestLoc->Volatile); From baldrick at free.fr Tue Dec 1 04:36:58 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 10:36:58 -0000 Subject: [llvm-commits] [dragonegg] r90225 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912011036.nB1AawWH006952@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 04:36:57 2009 New Revision: 90225 URL: http://llvm.org/viewvc/llvm-project?rev=90225&view=rev Log: Fix compile failure due to last second edit... 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=90225&r1=90224&r2=90225&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 04:36:57 2009 @@ -1190,7 +1190,7 @@ Result = EmitLoadOfLValue(exp, DestLoc); break; - case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break + case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break; case IMAGPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 1); break; // Declarations (tcc_declaration). From baldrick at free.fr Tue Dec 1 04:41:10 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 10:41:10 -0000 Subject: [llvm-commits] [dragonegg] r90226 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912011041.nB1AfACg007137@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 04:41:10 2009 New Revision: 90226 URL: http://llvm.org/viewvc/llvm-project?rev=90226&view=rev Log: A gimple invariant address is always given by ADDR_EXPR. Call EmitADDR_EXPR directly, rather than going via Emit. Also, change the parameter name of EmitGimpleInvariantAddress while there, and tweak an assertion message. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90226&r1=90225&r2=90226&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 04:41:10 2009 @@ -2196,10 +2196,10 @@ /// EmitGimpleInvariantAddress - The given address is constant in this function. /// Return the corresponding LLVM value. Only creates code in the entry block. -Value *TreeToLLVM::EmitGimpleInvariantAddress(tree reg) { - assert(is_gimple_invariant_address(reg) && +Value *TreeToLLVM::EmitGimpleInvariantAddress(tree addr) { + assert(is_gimple_invariant_address(addr) && "Expected a locally constant address!"); - assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); + assert(is_gimple_reg_type(TREE_TYPE(addr)) && "Not of register type!"); // Any generated code goes in the entry block. BasicBlock *EntryBlock = SSAInsertionPoint->getParent(); @@ -2221,7 +2221,8 @@ Builder.SetInsertPoint(EntryBlock); // Calculate the address. - Value *Address = Emit(reg, 0); + assert(TREE_CODE(addr) == ADDR_EXPR && "Invariant address not ADDR_EXPR!"); + Value *Address = EmitADDR_EXPR(addr); // Restore the entry block terminator. if (Terminator) @@ -2231,7 +2232,7 @@ if (SavedInsertBB != EntryBlock) Builder.SetInsertPoint(SavedInsertBB, SavedInsertPoint); - assert(Address->getType() == ConvertType(TREE_TYPE(reg)) && + assert(Address->getType() == ConvertType(TREE_TYPE(addr)) && "Invariant address has wrong type!"); return Address; } @@ -2495,7 +2496,7 @@ Value *TreeToLLVM::EmitADDR_EXPR(tree exp) { LValue LV = EmitLV(TREE_OPERAND(exp, 0)); assert((!LV.isBitfield() || LV.BitStart == 0) && - "It is illegal to take the address of a bitfield"); + "It is illegal to take the address of a bitfield!"); // Perform a cast here if necessary. For example, GCC sometimes forms an // ADDR_EXPR where the operand is an array, and the ADDR_EXPR type is a // pointer to the first element. Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90226&r1=90225&r2=90226&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Dec 1 04:41:10 2009 @@ -525,7 +525,7 @@ /// EmitGimpleInvariantAddress - The given address is constant in this /// function. Return the corresponding LLVM value. Only creates code in /// the entry block. - Value *EmitGimpleInvariantAddress(tree_node *reg); + Value *EmitGimpleInvariantAddress(tree_node *addr); /// EmitGimpleConstant - Convert the given global constant of register type to /// an LLVM constant. Creates no code, only constants. From baldrick at free.fr Tue Dec 1 05:09:24 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 11:09:24 -0000 Subject: [llvm-commits] [dragonegg] r90227 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912011109.nB1B9OIb008179@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 05:09:24 2009 New Revision: 90227 URL: http://llvm.org/viewvc/llvm-project?rev=90227&view=rev Log: Make REALPART_EXPR and IMAGPART_EXPR go via lvalues, like all other expressions of class tcc_reference. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90227&r1=90226&r2=90227&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 05:09:24 2009 @@ -1185,14 +1185,13 @@ case ARRAY_RANGE_REF: case BIT_FIELD_REF: case COMPONENT_REF: + case IMAGPART_EXPR: case INDIRECT_REF: + case REALPART_EXPR: case VIEW_CONVERT_EXPR: Result = EmitLoadOfLValue(exp, DestLoc); break; - case REALPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 0); break; - case IMAGPART_EXPR: Result = EmitXXXXPART_EXPR(exp, 1); break; - // Declarations (tcc_declaration). case PARM_DECL: case RESULT_DECL: @@ -3590,10 +3589,6 @@ return Builder.CreateBitCast(GEP, ConvertType(type)); } -Value *TreeToLLVM::EmitXXXXPART_EXPR(tree exp, unsigned Idx) { - return Builder.CreateExtractValue(Emit(TREE_OPERAND(exp, 0), 0), Idx); -} - Value *TreeToLLVM::EmitPAREN_EXPR(tree op) { // TODO: Understand and correctly deal with this subtle expression. return EmitGimpleReg(op); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90227&r1=90226&r2=90227&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Dec 1 05:09:24 2009 @@ -658,7 +658,6 @@ Value *EmitROUND_DIV_EXPR(tree_node *type, tree_node *op0, tree_node *op1); Value *EmitFieldAnnotation(Value *FieldPtr, tree_node *FieldDecl); Value *EmitPOINTER_PLUS_EXPR(tree_node *type, tree_node *op0, tree_node *op1); - Value *EmitXXXXPART_EXPR(tree_node *exp, unsigned Idx); Value *EmitPAREN_EXPR(tree_node *exp); // Exception Handling. From baldrick at free.fr Tue Dec 1 06:33:40 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 12:33:40 -0000 Subject: [llvm-commits] [dragonegg] r90228 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912011233.nB1CXe5I011360@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 06:33:40 2009 New Revision: 90228 URL: http://llvm.org/viewvc/llvm-project?rev=90228&view=rev Log: Collapse a bunch of cases that are all handled by EmitGimpleReg. Output more information in EmitGimpleConstant if it sees an unexpected tree, since this is where you now end up if Emit is called with a tree we don't know about. 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=90228&r1=90227&r2=90228&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 06:33:40 2009 @@ -1172,9 +1172,7 @@ Value *Result = 0; switch (TREE_CODE(exp)) { - default: - debug_tree(exp); - llvm_unreachable("Unhandled expression!"); + default: Result = EmitGimpleReg(exp); break; // Exception handling. //FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(exp); break; @@ -1210,21 +1208,6 @@ // Exceptional (tcc_exceptional). case CONSTRUCTOR: Result = EmitCONSTRUCTOR(exp, DestLoc); break; - case SSA_NAME: Result = EmitSSA_NAME(exp); break; - - // Constants (tcc_constant). - case COMPLEX_CST: - Result = TreeConstantToLLVM::ConvertCOMPLEX_CST(exp); - break; - case INTEGER_CST: - Result = TreeConstantToLLVM::ConvertINTEGER_CST(exp); - break; - case REAL_CST: - Result = TreeConstantToLLVM::ConvertREAL_CST(exp); - break; - case VECTOR_CST: - Result = TreeConstantToLLVM::ConvertVECTOR_CST(exp); - break; } assert(((DestLoc && Result == 0) || DestLoc == 0) && @@ -2238,7 +2221,12 @@ /// EmitGimpleConstant - Return the LLVM constant for this global constant. Constant *TreeToLLVM::EmitGimpleConstant(tree reg) { - assert(is_gimple_constant(reg) && "Not a gimple constant!"); +#ifndef NDEBUG + if (!is_gimple_constant(reg)) { + debug_tree(reg); + llvm_unreachable("Not a gimple constant!"); + } +#endif assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); Constant *C; From ggreif at gmail.com Tue Dec 1 06:53:57 2009 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 01 Dec 2009 12:53:57 -0000 Subject: [llvm-commits] [llvm] r90230 - /llvm/trunk/include/llvm/ADT/StringSwitch.h Message-ID: <200912011253.nB1CrvM5012064@zion.cs.uiuc.edu> Author: ggreif Date: Tue Dec 1 06:53:56 2009 New Revision: 90230 URL: http://llvm.org/viewvc/llvm-project?rev=90230&view=rev Log: demonstrate usage of Cases() mapping several strings to the same value; remove trailing spaces Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringSwitch.h?rev=90230&r1=90229&r2=90230&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringSwitch.h (original) +++ llvm/trunk/include/llvm/ADT/StringSwitch.h Tue Dec 1 06:53:56 2009 @@ -18,7 +18,7 @@ #include namespace llvm { - + /// \brief A switch()-like statement whose cases are string literals. /// /// The StringSwitch class is a simple form of a switch() statement that @@ -35,48 +35,48 @@ /// .Case("green", Green) /// .Case("blue", Blue) /// .Case("indigo", Indigo) -/// .Case("violet", Violet) +/// .Cases("violet", "purple", Violet) /// .Default(UnknownColor); /// \endcode template class StringSwitch { /// \brief The string we are matching. StringRef Str; - + /// \brief The result of this switch statement, once known. T Result; - + /// \brief Set true when the result of this switch is already known; in this /// case, Result is valid. bool ResultKnown; - + public: - explicit StringSwitch(StringRef Str) + explicit StringSwitch(StringRef Str) : Str(Str), ResultKnown(false) { } - + template StringSwitch& Case(const char (&S)[N], const T& Value) { - if (!ResultKnown && N-1 == Str.size() && + if (!ResultKnown && N-1 == Str.size() && (std::memcmp(S, Str.data(), N-1) == 0)) { Result = Value; ResultKnown = true; } - + return *this; } - + template StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], const T& Value) { return Case(S0, Value).Case(S1, Value); } - + template StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], const char (&S2)[N2], const T& Value) { return Case(S0, Value).Case(S1, Value).Case(S2, Value); } - + template StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], const char (&S2)[N2], const char (&S3)[N3], @@ -87,18 +87,18 @@ template StringSwitch& Cases(const char (&S0)[N0], const char (&S1)[N1], const char (&S2)[N2], const char (&S3)[N3], - const char (&S4)[N4], const T& Value) { + const char (&S4)[N4], const T& Value) { return Case(S0, Value).Case(S1, Value).Case(S2, Value).Case(S3, Value) .Case(S4, Value); } - + T Default(const T& Value) { if (ResultKnown) return Result; - + return Value; } - + operator T() { assert(ResultKnown && "Fell off the end of a string-switch"); return Result; From baldrick at free.fr Tue Dec 1 07:34:20 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 13:34:20 -0000 Subject: [llvm-commits] [dragonegg] r90231 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912011334.nB1DYLhr013413@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 07:34:20 2009 New Revision: 90231 URL: http://llvm.org/viewvc/llvm-project?rev=90231&view=rev Log: The argument to builtin_expect is a scalar - use EmitGimpleReg rather than Emit with DestLoc. While there, return 0 if the builtin_expect has too few operands, like in gcc. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90231&r1=90230&r2=90231&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 07:34:20 2009 @@ -4288,7 +4288,7 @@ case BUILT_IN_CONSTANT_P: return EmitBuiltinConstantP(stmt, Result); case BUILT_IN_ALLOCA: return EmitBuiltinAlloca(stmt, Result); case BUILT_IN_EXTEND_POINTER: return EmitBuiltinExtendPointer(stmt, Result); - case BUILT_IN_EXPECT: return EmitBuiltinExpect(stmt, DestLoc, Result); + case BUILT_IN_EXPECT: return EmitBuiltinExpect(stmt, Result); case BUILT_IN_MEMCPY: return EmitBuiltinMemCopy(stmt, Result, false, false); case BUILT_IN_MEMCPY_CHK: return EmitBuiltinMemCopy(stmt, Result, @@ -5503,13 +5503,12 @@ return true; } -bool TreeToLLVM::EmitBuiltinExpect(gimple stmt, const MemRef *DestLoc, - Value *&Result) { +bool TreeToLLVM::EmitBuiltinExpect(gimple stmt, Value *&Result) { // Ignore the hint for now, just expand the expr. This is safe, but not // optimal. - if (gimple_call_num_args(stmt) < 2) - return true; - Result = Emit(gimple_call_arg(stmt, 0), DestLoc); + Result = gimple_call_num_args(stmt) < 2 ? + Constant::getNullValue(ConvertType(gimple_call_return_type(stmt))) : + EmitGimpleReg(gimple_call_arg(stmt, 0)); return true; } Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90231&r1=90230&r2=90231&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Dec 1 07:34:20 2009 @@ -689,7 +689,7 @@ bool EmitBuiltinConstantP(gimple stmt, Value *&Result); bool EmitBuiltinAlloca(gimple stmt, Value *&Result); - bool EmitBuiltinExpect(gimple stmt, const MemRef *DestLoc, Value *&Result); + bool EmitBuiltinExpect(gimple stmt, Value *&Result); bool EmitBuiltinExtendPointer(gimple stmt, Value *&Result); bool EmitBuiltinVAStart(gimple stmt); bool EmitBuiltinVAEnd(gimple stmt); From baldrick at free.fr Tue Dec 1 07:50:12 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 13:50:12 -0000 Subject: [llvm-commits] [dragonegg] r90232 - in /dragonegg/trunk: llvm-backend.cpp llvm-convert.cpp Message-ID: <200912011350.nB1DoChr014065@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 07:50:11 2009 New Revision: 90232 URL: http://llvm.org/viewvc/llvm-project?rev=90232&view=rev Log: Use !AGGREGATE_TYPE_P in preference to Ty->isSingleValueType() in a few places where making fewer assumptions on how types are converted seems wise. Modified: dragonegg/trunk/llvm-backend.cpp dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-backend.cpp?rev=90232&r1=90231&r2=90232&view=diff ============================================================================== --- dragonegg/trunk/llvm-backend.cpp (original) +++ dragonegg/trunk/llvm-backend.cpp Tue Dec 1 07:50:11 2009 @@ -1267,7 +1267,6 @@ /// false. bool ValidateRegisterVariable(tree decl) { int RegNumber = decode_reg_name(extractRegisterName(decl)); - const Type *Ty = ConvertType(TREE_TYPE(decl)); if (errorcount || sorrycount) return true; // Do not process broken code. @@ -1286,7 +1285,7 @@ #endif else if (DECL_INITIAL(decl) != 0 && TREE_STATIC(decl)) error("global register variable has initial value"); - else if (!Ty->isSingleValueType()) + else if (AGGREGATE_TYPE_P(TREE_TYPE(decl))) sorry("%JLLVM cannot handle register variable %qD, report a bug", decl, decl); else { Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90232&r1=90231&r2=90232&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 07:50:11 2009 @@ -6965,7 +6965,7 @@ return BuildVector(BuildVecOps); } - assert(!Ty->isSingleValueType() && "Constructor for scalar type??"); + assert(AGGREGATE_TYPE_P(type) && "Constructor for scalar type??"); // Start out with the value zero'd out. EmitAggregateZero(*DestLoc, type); @@ -6993,7 +6993,7 @@ if (!tree_purpose) return 0; // Not actually initialized? - if (!ConvertType(TREE_TYPE(tree_purpose))->isSingleValueType()) { + if (AGGREGATE_TYPE_P(TREE_TYPE(tree_purpose))) { Value *V = Emit(tree_value, DestLoc); (void)V; assert(V == 0 && "Aggregate value returned in a register?"); From baldrick at free.fr Tue Dec 1 08:03:05 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 14:03:05 -0000 Subject: [llvm-commits] [dragonegg] r90233 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912011403.nB1E36df014502@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 08:03:05 2009 New Revision: 90233 URL: http://llvm.org/viewvc/llvm-project?rev=90233&view=rev Log: There should be no instances of NON_LVALUE_EXPR after gimplification. 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=90233&r1=90232&r2=90233&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 08:03:05 2009 @@ -2283,8 +2283,6 @@ return EmitCONVERT_EXPR(type, rhs1); case NEGATE_EXPR: return EmitNEGATE_EXPR(rhs1); - case NON_LVALUE_EXPR: - return Emit(rhs1, DestLoc); case NOP_EXPR: return EmitNOP_EXPR(type, rhs1, DestLoc); case PAREN_EXPR: From baldrick at free.fr Tue Dec 1 08:34:48 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 14:34:48 -0000 Subject: [llvm-commits] [dragonegg] r90234 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912011434.nB1EYn4j015508@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 08:34:48 2009 New Revision: 90234 URL: http://llvm.org/viewvc/llvm-project?rev=90234&view=rev Log: Duplicate "Emit", with the second copy being for emitting gimple assign with a single RHS. In fact most of the emit logic is only live in this case, so this is preparatory to horribly hacking on the original "Emit". Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90234&r1=90233&r2=90234&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 08:34:48 2009 @@ -2256,9 +2256,63 @@ return C; } +Value *TreeToLLVM::EmitGimpleAssignSingleRHS(tree rhs, const MemRef *DestLoc) { + assert((AGGREGATE_TYPE_P(TREE_TYPE(rhs)) == (DestLoc != 0)) && + "DestLoc for aggregate types only!"); + + Value *Result = 0; + + switch (TREE_CODE(rhs)) { + default: Result = EmitGimpleReg(rhs); break; + + // Exception handling. +//FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(rhs); break; +//FIXME case FILTER_EXPR: Result = EmitFILTER_EXPR(rhs); break; + + // References (tcc_reference). + case ARRAY_REF: + case ARRAY_RANGE_REF: + case BIT_FIELD_REF: + case COMPONENT_REF: + case IMAGPART_EXPR: + case INDIRECT_REF: + case REALPART_EXPR: + case VIEW_CONVERT_EXPR: + Result = EmitLoadOfLValue(rhs, DestLoc); + break; + + // Declarations (tcc_declaration). + case PARM_DECL: + case RESULT_DECL: + case VAR_DECL: + Result = EmitLoadOfLValue(rhs, DestLoc); + break; + + // Constants (tcc_constant). + case STRING_CST: + Result = EmitLoadOfLValue(rhs, DestLoc); + break; + + // Expressions (tcc_expression). + case ADDR_EXPR: Result = EmitADDR_EXPR(rhs); break; + case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(rhs); break; + + // Exceptional (tcc_exceptional). + case CONSTRUCTOR: Result = EmitCONSTRUCTOR(rhs, DestLoc); break; + } + + assert(((DestLoc && Result == 0) || DestLoc == 0) && + "Expected a scalar or aggregate but got the wrong thing!"); + + // Check that the type of the result matches that of the tree node. + assert((Result == 0 || Result->getType() == ConvertType(TREE_TYPE(rhs))) && + "Value has wrong type!"); + return Result; +} + Value *TreeToLLVM::EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc) { if (get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS) - return Emit(gimple_assign_rhs1 (stmt), DestLoc); + return EmitGimpleAssignSingleRHS(gimple_assign_rhs1 (stmt), DestLoc); tree type = TREE_TYPE(gimple_assign_lhs(stmt)); tree_code code = gimple_assign_rhs_code(stmt); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90234&r1=90233&r2=90234&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Dec 1 08:34:48 2009 @@ -626,6 +626,7 @@ // characteristics. // Expressions. + Value *EmitGimpleAssignSingleRHS(tree_node *rhs, const MemRef *DestLoc); Value *EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc); Value *EmitGimpleCallRHS(gimple stmt, const MemRef *DestLoc); Value *EmitLoadOfLValue(tree_node *exp, const MemRef *DestLoc); From baldrick at free.fr Tue Dec 1 09:20:43 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 15:20:43 -0000 Subject: [llvm-commits] [dragonegg] r90235 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912011520.nB1FKhLs016966@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 09:20:42 2009 New Revision: 90235 URL: http://llvm.org/viewvc/llvm-project?rev=90235&view=rev Log: Eliminate Emit - it is no more. It was designed for a recursive world that doesn't really exist in gimple tuples land. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90235&r1=90234&r2=90235&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 09:20:42 2009 @@ -1165,64 +1165,14 @@ return FinishFunctionBody(); } -Value *TreeToLLVM::Emit(tree exp, const MemRef *DestLoc) { - assert((AGGREGATE_TYPE_P(TREE_TYPE(exp)) == (DestLoc != 0)) && - "Didn't pass DestLoc to an aggregate expr, or passed it to scalar!"); - - Value *Result = 0; - - switch (TREE_CODE(exp)) { - default: Result = EmitGimpleReg(exp); break; - - // Exception handling. -//FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(exp); break; -//FIXME case FILTER_EXPR: Result = EmitFILTER_EXPR(exp); break; - - // References (tcc_reference). - case ARRAY_REF: - case ARRAY_RANGE_REF: - case BIT_FIELD_REF: - case COMPONENT_REF: - case IMAGPART_EXPR: - case INDIRECT_REF: - case REALPART_EXPR: - case VIEW_CONVERT_EXPR: - Result = EmitLoadOfLValue(exp, DestLoc); - break; - - // Declarations (tcc_declaration). - case PARM_DECL: - case RESULT_DECL: - case VAR_DECL: - Result = EmitLoadOfLValue(exp, DestLoc); - break; - - // Constants (tcc_constant). - case STRING_CST: - Result = EmitLoadOfLValue(exp, DestLoc); - break; - - // Expressions (tcc_expression). - case ADDR_EXPR: Result = EmitADDR_EXPR(exp); break; - case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(exp); break; - - // Exceptional (tcc_exceptional). - case CONSTRUCTOR: Result = EmitCONSTRUCTOR(exp, DestLoc); break; - } - - assert(((DestLoc && Result == 0) || DestLoc == 0) && - "Expected a scalar or aggregate but got the wrong thing!"); - // Check that the type of the result matches that of the tree node. If the - // result is not used then GCC sometimes sets the tree type to VOID_TYPE, so - // don't take VOID_TYPE too seriously here. - assert((Result == 0 || VOID_TYPE_P(TREE_TYPE(exp)) || - // FIXME: The vector stuff isn't straight-forward. Sometimes X86 can - // pass it back as a scalar value. Disable checking if it's a - // vector. This should be made better, though. - isa(ConvertType(TREE_TYPE(exp))) || - Result->getType() == ConvertType(TREE_TYPE(exp))) && - "Value has wrong type!"); - return Result; +/// EmitAggregate - Store the specified tree node into the location given by +/// DestLoc. +void TreeToLLVM::EmitAggregate(tree exp, const MemRef &DestLoc) { + assert(AGGREGATE_TYPE_P(TREE_TYPE(exp)) && "Expected an aggregate type!"); + LValue LV = EmitLV(exp); + assert(!LV.isBitfield() && "Bitfields containing aggregates not supported!"); + EmitAggregateCopy(DestLoc, MemRef(LV.Ptr, LV.getAlignment(), + TREE_THIS_VOLATILE(exp)), TREE_TYPE(exp)); } /// get_constant_alignment - Return the alignment of constant EXP in bits. @@ -3055,9 +3005,7 @@ // Aggregate to aggregate copy. MemRef NewLoc = *DestLoc; NewLoc.Ptr = Builder.CreateBitCast(DestLoc->Ptr,Ty->getPointerTo()); - Value *OpVal = Emit(op, &NewLoc); - (void)OpVal; - assert(OpVal == 0 && "Shouldn't cast scalar to aggregate!"); + EmitAggregate(op, NewLoc); return 0; } @@ -4190,7 +4138,7 @@ tree OpVal = gimple_call_arg(stmt, i); if (AGGREGATE_TYPE_P(TREE_TYPE(OpVal))) { MemRef OpLoc = CreateTempLoc(ConvertType(TREE_TYPE(OpVal))); - Emit(OpVal, &OpLoc); + EmitAggregate(OpVal, OpLoc); Operands.push_back(Builder.CreateLoad(OpLoc.Ptr)); } else { Operands.push_back(EmitGimpleReg(OpVal)); @@ -6896,7 +6844,7 @@ // Store the return value to the function's DECL_RESULT. if (AGGREGATE_TYPE_P(TREE_TYPE(result))) { MemRef DestLoc(DECL_LOCAL(result), 1, false); // FIXME: What alignment? - Emit(retval, &DestLoc); + EmitAggregate(retval, DestLoc); } else { Value *Val = Builder.CreateBitCast(EmitGimpleReg(retval), ConvertType(TREE_TYPE(result))); @@ -7046,9 +6994,7 @@ return 0; // Not actually initialized? if (AGGREGATE_TYPE_P(TREE_TYPE(tree_purpose))) { - Value *V = Emit(tree_value, DestLoc); - (void)V; - assert(V == 0 && "Aggregate value returned in a register?"); + EmitAggregate(tree_value, *DestLoc); } else { // Scalar value. Evaluate to a register, then do the store. Value *V = EmitGimpleReg(tree_value); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90235&r1=90234&r2=90235&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Tue Dec 1 09:20:42 2009 @@ -494,6 +494,10 @@ /// GCC type specified by GCCType to know which elements to copy. void EmitAggregateCopy(MemRef DestLoc, MemRef SrcLoc, tree_node *GCCType); + /// EmitAggregate - Store the specified tree node into the location given by + /// DestLoc. + void EmitAggregate(tree_node *exp, const MemRef &DestLoc); + private: // Helper functions. /// StartFunctionBody - Start the emission of 'fndecl', outputing all @@ -551,12 +555,6 @@ return V; } - /// Emit - Convert the specified tree node to LLVM code. If the node is an - /// expression that fits into an LLVM scalar value, the result is returned. If - /// the result is an aggregate, it is stored into the location specified by - /// DestLoc. - Value *Emit(tree_node *exp, const MemRef *DestLoc); - /// EmitBlock - Add the specified basic block to the end of the function. If /// the previous block falls through into it, add an explicit branch. void EmitBlock(BasicBlock *BB); @@ -564,7 +562,7 @@ /// EmitAggregateZero - Zero the elements of DestLoc. /// void EmitAggregateZero(MemRef DestLoc, tree_node *GCCType); - + /// EmitMemCpy/EmitMemMove/EmitMemSet - Emit an llvm.memcpy/llvm.memmove or /// llvm.memset call with the specified operands. Returns DestPtr bitcast /// to i8*. @@ -622,9 +620,6 @@ void EmitTypeGcroot(Value *V, tree_node *decl); private: - // Emit* - These are delegates from Emit, and have the same parameter - // characteristics. - // Expressions. Value *EmitGimpleAssignSingleRHS(tree_node *rhs, const MemRef *DestLoc); Value *EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc); From ggreif at gmail.com Tue Dec 1 09:53:33 2009 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 01 Dec 2009 15:53:33 -0000 Subject: [llvm-commits] [llvm] r90236 - /llvm/trunk/include/llvm/ADT/StringSwitch.h Message-ID: <200912011553.nB1FrXSJ018012@zion.cs.uiuc.edu> Author: ggreif Date: Tue Dec 1 09:53:33 2009 New Revision: 90236 URL: http://llvm.org/viewvc/llvm-project?rev=90236&view=rev Log: typo Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h Modified: llvm/trunk/include/llvm/ADT/StringSwitch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringSwitch.h?rev=90236&r1=90235&r2=90236&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringSwitch.h (original) +++ llvm/trunk/include/llvm/ADT/StringSwitch.h Tue Dec 1 09:53:33 2009 @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===/ // // This file implements the StringSwitch template, which mimics a switch() -// statements whose cases are string literals. +// statement whose cases are string literals. // //===----------------------------------------------------------------------===/ #ifndef LLVM_ADT_STRINGSWITCH_H From baldrick at free.fr Tue Dec 1 10:49:52 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 16:49:52 -0000 Subject: [llvm-commits] [dragonegg] r90238 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912011649.nB1GnrfV020068@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 10:49:52 2009 New Revision: 90238 URL: http://llvm.org/viewvc/llvm-project?rev=90238&view=rev Log: The aggregate case of VIEW_CONVERT_EXPR actually handles all cases - the generic LV code can handle taking the address of a scalar. 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=90238&r1=90237&r2=90238&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 10:49:52 2009 @@ -6249,25 +6249,12 @@ } LValue TreeToLLVM::EmitLV_VIEW_CONVERT_EXPR(tree exp) { - tree Op = TREE_OPERAND(exp, 0); - - if (AGGREGATE_TYPE_P(TREE_TYPE(Op))) { - // If the input is an aggregate, the address is the address of the operand. - LValue LV = EmitLV(Op); - // The type is the type of the expression. - LV.Ptr = Builder.CreateBitCast(LV.Ptr, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); - return LV; - } else { - // TODO: Check the VCE is being used as an rvalue, see EmitLoadOfLValue. - // If the input is a scalar, emit to a temporary. - Value *Dest = CreateTemporary(ConvertType(TREE_TYPE(Op))); - Builder.CreateStore(EmitGimpleReg(Op), Dest); - // The type is the type of the expression. - Dest = Builder.CreateBitCast(Dest, - PointerType::getUnqual(ConvertType(TREE_TYPE(exp)))); - return LValue(Dest, 1); - } + // The address is the address of the operand. + LValue LV = EmitLV(TREE_OPERAND(exp, 0)); + // The type is the type of the expression. + LV.Ptr = Builder.CreateBitCast(LV.Ptr, + ConvertType(TREE_TYPE(exp))->getPointerTo()); + return LV; } LValue TreeToLLVM::EmitLV_WITH_SIZE_EXPR(tree exp) { From clattner at apple.com Tue Dec 1 11:04:37 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 01 Dec 2009 09:04:37 -0800 Subject: [llvm-commits] [llvm] r90199 - /llvm/trunk/include/llvm/IntrinsicsX86.td In-Reply-To: <4B14D8DF.1050600@free.fr> References: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> <4B14D8DF.1050600@free.fr> Message-ID: <812D35AA-0BFB-4B0D-97F9-252061AFE654@apple.com> I'm not worried about the CBE here, the goal is to eliminate the intrinsic completely and use a shuffle. -Chris On Dec 1, 2009, at 12:50 AM, Duncan Sands wrote: > Hi Eric, > >> Remove the gcc builtins from the intrinsics, we'll lower them >> explicitly so we can check arguments. > > I think the gcc builtin is also used by the C backend to go from the > LLVM intrinsic to the gcc intrinsic. Instead of doing this, how about > flipping the logic in EmitBuiltinCall so it only checks > getIntrinsicForGCCBuiltin if EmitFrontendExpandedBuiltinCall fails, > rather than the other way round like now. > > Ciao, > > Duncan. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Tue Dec 1 11:13:32 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 01 Dec 2009 17:13:32 -0000 Subject: [llvm-commits] [llvm] r90240 - in /llvm/trunk: include/llvm/CodeGen/LiveVariables.h lib/CodeGen/LiveVariables.cpp lib/CodeGen/PHIElimination.cpp lib/CodeGen/PHIElimination.h Message-ID: <200912011713.nB1HDWgf020887@zion.cs.uiuc.edu> Author: stoklund Date: Tue Dec 1 11:13:31 2009 New Revision: 90240 URL: http://llvm.org/viewvc/llvm-project?rev=90240&view=rev Log: Move PHIElimination::isLiveOut method to LiveVariables. We want LiveVariables clients to use methods rather than accessing the getVarInfo data structure directly. That way it will be possible to change the LiveVariables representation. Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h llvm/trunk/lib/CodeGen/LiveVariables.cpp llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PHIElimination.h Modified: llvm/trunk/include/llvm/CodeGen/LiveVariables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveVariables.h?rev=90240&r1=90239&r2=90240&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveVariables.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveVariables.h Tue Dec 1 11:13:31 2009 @@ -283,6 +283,11 @@ return getVarInfo(Reg).isLiveIn(MBB, Reg, *MRI); } + /// isLiveOut - Determine if Reg is live out from MBB, when not considering + /// PHI nodes. This means that Reg is either killed by a successor block or + /// passed through one. + bool isLiveOut(unsigned Reg, const MachineBasicBlock &MBB); + /// addNewBlock - Add a new basic block BB between DomBB and SuccBB. All /// variables that are live out of DomBB and live into SuccBB will be marked /// as passing live through BB. This method assumes that the machine code is Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=90240&r1=90239&r2=90240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Tue Dec 1 11:13:31 2009 @@ -720,6 +720,51 @@ return findKill(&MBB); } +bool LiveVariables::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB) { + LiveVariables::VarInfo &VI = getVarInfo(Reg); + + // Loop over all of the successors of the basic block, checking to see if + // the value is either live in the block, or if it is killed in the block. + std::vector OpSuccBlocks; + for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(), + E = MBB.succ_end(); SI != E; ++SI) { + MachineBasicBlock *SuccMBB = *SI; + + // Is it alive in this successor? + unsigned SuccIdx = SuccMBB->getNumber(); + if (VI.AliveBlocks.test(SuccIdx)) + return true; + OpSuccBlocks.push_back(SuccMBB); + } + + // Check to see if this value is live because there is a use in a successor + // that kills it. + switch (OpSuccBlocks.size()) { + case 1: { + MachineBasicBlock *SuccMBB = OpSuccBlocks[0]; + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) + if (VI.Kills[i]->getParent() == SuccMBB) + return true; + break; + } + case 2: { + MachineBasicBlock *SuccMBB1 = OpSuccBlocks[0], *SuccMBB2 = OpSuccBlocks[1]; + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) + if (VI.Kills[i]->getParent() == SuccMBB1 || + VI.Kills[i]->getParent() == SuccMBB2) + return true; + break; + } + default: + std::sort(OpSuccBlocks.begin(), OpSuccBlocks.end()); + for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) + if (std::binary_search(OpSuccBlocks.begin(), OpSuccBlocks.end(), + VI.Kills[i]->getParent())) + return true; + } + return false; +} + /// addNewBlock - Add a new basic block BB as an empty succcessor to DomBB. All /// variables that are live out of DomBB will be marked as passing live through /// BB. Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=90240&r1=90239&r2=90240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Tue Dec 1 11:13:31 2009 @@ -287,7 +287,7 @@ // Okay, if we now know that the value is not live out of the block, we can // add a kill marker in this block saying that it kills the incoming value! - if (!ValueIsUsed && !isLiveOut(SrcReg, opBlock, *LV)) { + if (!ValueIsUsed && !LV->isLiveOut(SrcReg, opBlock)) { // In our final twist, we have to decide which instruction kills the // register. In most cases this is the copy, however, the first // terminator instruction at the end of the block may also use the value. @@ -353,59 +353,13 @@ // We break edges when registers are live out from the predecessor block // (not considering PHI nodes). If the register is live in to this block // anyway, we would gain nothing from splitting. - if (!LV.isLiveIn(Reg, MBB) && isLiveOut(Reg, *PreMBB, LV)) + if (!LV.isLiveIn(Reg, MBB) && LV.isLiveOut(Reg, *PreMBB)) SplitCriticalEdge(PreMBB, &MBB); } } return true; } -bool llvm::PHIElimination::isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, - LiveVariables &LV) { - LiveVariables::VarInfo &VI = LV.getVarInfo(Reg); - - // Loop over all of the successors of the basic block, checking to see if - // the value is either live in the block, or if it is killed in the block. - std::vector OpSuccBlocks; - for (MachineBasicBlock::const_succ_iterator SI = MBB.succ_begin(), - E = MBB.succ_end(); SI != E; ++SI) { - MachineBasicBlock *SuccMBB = *SI; - - // Is it alive in this successor? - unsigned SuccIdx = SuccMBB->getNumber(); - if (VI.AliveBlocks.test(SuccIdx)) - return true; - OpSuccBlocks.push_back(SuccMBB); - } - - // Check to see if this value is live because there is a use in a successor - // that kills it. - switch (OpSuccBlocks.size()) { - case 1: { - MachineBasicBlock *SuccMBB = OpSuccBlocks[0]; - for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) - if (VI.Kills[i]->getParent() == SuccMBB) - return true; - break; - } - case 2: { - MachineBasicBlock *SuccMBB1 = OpSuccBlocks[0], *SuccMBB2 = OpSuccBlocks[1]; - for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) - if (VI.Kills[i]->getParent() == SuccMBB1 || - VI.Kills[i]->getParent() == SuccMBB2) - return true; - break; - } - default: - std::sort(OpSuccBlocks.begin(), OpSuccBlocks.end()); - for (unsigned i = 0, e = VI.Kills.size(); i != e; ++i) - if (std::binary_search(OpSuccBlocks.begin(), OpSuccBlocks.end(), - VI.Kills[i]->getParent())) - return true; - } - return false; -} - MachineBasicBlock *PHIElimination::SplitCriticalEdge(MachineBasicBlock *A, MachineBasicBlock *B) { assert(A && B && "Missing MBB end point"); Modified: llvm/trunk/lib/CodeGen/PHIElimination.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.h?rev=90240&r1=90239&r2=90240&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.h (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.h Tue Dec 1 11:13:31 2009 @@ -93,12 +93,6 @@ bool SplitPHIEdges(MachineFunction &MF, MachineBasicBlock &MBB, LiveVariables &LV); - /// isLiveOut - Determine if Reg is live out from MBB, when not - /// considering PHI nodes. This means that Reg is either killed by - /// a successor block or passed through one. - bool isLiveOut(unsigned Reg, const MachineBasicBlock &MBB, - LiveVariables &LV); - /// SplitCriticalEdge - Split a critical edge from A to B by /// inserting a new MBB. Update branches in A and PHI instructions /// in B. Return the new block. From chandlerc at google.com Tue Dec 1 11:33:53 2009 From: chandlerc at google.com (Chandler Carruth) Date: Tue, 1 Dec 2009 09:33:53 -0800 Subject: [llvm-commits] [patch] Implement no-canonical-prefixes. In-Reply-To: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> Message-ID: <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> This needs to be updated after Duncan's refactoring of the driver... Is it still relevant? Some parts of the driver now explicitly mention preserving symlinks. On Sun, Nov 29, 2009 at 8:34 AM, Rafael Espindola wrote: > Gcc's option -fno-canonical-prefixes is useful for the case where gcc > and cc1 are symbolic links to different directories. The same is true > for clang and clang-cc. For example, if ?we have > > bin/clang -> /foo/clang > bin/clang-cc /bar/clang-cc > > clang will fail to find clang-cc since it will look for /foo/clang-cc. > > The attached patch implements -no-canonical-prefixes in the driver. > > For more information see. > http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00110.html > > Cheers, > -- > Rafael ?vila de Esp?ndola > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From johnny.chen at apple.com Tue Dec 1 11:37:07 2009 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 01 Dec 2009 17:37:07 -0000 Subject: [llvm-commits] [llvm] r90243 - /llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Message-ID: <200912011737.nB1Hb7aY021783@zion.cs.uiuc.edu> Author: johnny Date: Tue Dec 1 11:37:06 2009 New Revision: 90243 URL: http://llvm.org/viewvc/llvm-project?rev=90243&view=rev Log: For VLDM/VSTM (Advanced SIMD), set encoding bits Inst{11-8} to 0b1011. Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=90243&r1=90242&r2=90243&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Tue Dec 1 11:37:06 2009 @@ -152,7 +152,7 @@ let Inst{24} = 0; // P bit let Inst{23} = 1; // U bit let Inst{20} = 1; - let Inst{11-9} = 0b101; + let Inst{11-8} = 0b1011; } // Use vstmia to store a Q register as a D register pair. @@ -164,7 +164,7 @@ let Inst{24} = 0; // P bit let Inst{23} = 1; // U bit let Inst{20} = 0; - let Inst{11-9} = 0b101; + let Inst{11-8} = 0b1011; } // VLD1 : Vector Load (multiple single elements) From devang.patel at gmail.com Tue Dec 1 11:43:05 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 1 Dec 2009 09:43:05 -0800 Subject: [llvm-commits] [llvm] r90160 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC++/m64-ptr.cpp FrontendC/2009-02-17-BitField-dbg.c In-Reply-To: References: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> Message-ID: <352a1fb20912010943m5dc07732hbc05ec94022d5555@mail.gmail.com> On Mon, Nov 30, 2009 at 5:45 PM, Chris Lattner wrote: > > On Nov 30, 2009, at 2:23 PM, Bill Wendling wrote: > >> Author: void >> Date: Mon Nov 30 16:23:29 2009 >> New Revision: 90160 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90160&view=rev >> Log: >> Debug info is disabled on PPC Darwin. > > Why is debug info disabled on ppc darwin? I think it happened accidently during MCAsmInfo transition. PPCMCAsmInfoDarwin() does not set SupportsDebugInformation. So, the PPC support has bit rotted little bit. There is one bug blocking llvm-gcc bootstrap because of debug info, which needs to be fixed before PPCMCAsmInfoDarwin() is updated to set SupportsDebugInformation. - Devang From grosbach at apple.com Tue Dec 1 12:10:36 2009 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 01 Dec 2009 18:10:36 -0000 Subject: [llvm-commits] [llvm] r90246 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMInstrFormats.td ARMInstrThumb.td Message-ID: <200912011810.nB1IAao4023392@zion.cs.uiuc.edu> Author: grosbach Date: Tue Dec 1 12:10:36 2009 New Revision: 90246 URL: http://llvm.org/viewvc/llvm-project?rev=90246&view=rev Log: Thumb1 exception handling setjmp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=90246&r1=90245&r2=90246&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Dec 1 12:10:36 2009 @@ -467,6 +467,8 @@ return MI->getOperand(2).getImm(); case ARM::Int_eh_sjlj_setjmp: return 24; + case ARM::tInt_eh_sjlj_setjmp: + return 22; case ARM::t2Int_eh_sjlj_setjmp: return 22; case ARM::BR_JTr: Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=90246&r1=90245&r2=90246&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Dec 1 12:10:36 2009 @@ -967,6 +967,17 @@ list Predicates = [IsThumb2]; } +class ThumbXI pattern> + : InstARM { + let OutOperandList = oops; + let InOperandList = iops; + let AsmString = asm; + let Pattern = pattern; + list Predicates = [IsThumb1Only]; +} + class T2I pattern> : Thumb2I; Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=90246&r1=90245&r2=90246&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Dec 1 12:10:36 2009 @@ -669,6 +669,35 @@ [(set R0, ARMthread_pointer)]>; } +// SJLJ Exception handling intrinsics +// eh_sjlj_setjmp() is an instruction sequence to store the return +// address and save #0 in R0 for the non-longjmp case. +// Since by its nature we may be coming from some other function to get +// here, and we're using the stack frame for the containing function to +// save/restore registers, we can't keep anything live in regs across +// the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon +// when we get here from a longjmp(). We force everthing out of registers +// except for our own input by listing the relevant registers in Defs. By +// doing so, we also cause the prologue/epilogue code to actively preserve +// all of the callee-saved resgisters, which is exactly what we want. +let Defs = + [ R0, R1, R2, R3, R4, R5, R6, R7, R12 ] in { + def tInt_eh_sjlj_setjmp : ThumbXI<(outs), (ins GPR:$src), + AddrModeNone, SizeSpecial, NoItinerary, + "mov\tr12, r1\t@ begin eh.setjmp\n" + "\tmov\tr1, sp\n" + "\tstr\tr1, [$src, #8]\n" + "\tadr\tr1, 0f\n" + "\tadds\tr1, #1\n" + "\tstr\tr1, [$src, #4]\n" + "\tmov\tr1, r12\n" + "\tmovs\tr0, #0\n" + "\tb\t1f\n" + ".align 2\n" + "0:\tmovs\tr0, #1\t@ end eh.setjmp\n" + "1:", "", + [(set R0, (ARMeh_sjlj_setjmp GPR:$src))]>; +} //===----------------------------------------------------------------------===// // Non-Instruction Patterns // From dpatel at apple.com Tue Dec 1 12:13:48 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 18:13:48 -0000 Subject: [llvm-commits] [llvm] r90247 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2009-12-01-CurrentFn.ll Message-ID: <200912011813.nB1IDm01023497@zion.cs.uiuc.edu> Author: dpatel Date: Tue Dec 1 12:13:48 2009 New Revision: 90247 URL: http://llvm.org/viewvc/llvm-project?rev=90247&view=rev Log: Clear function specific containers while processing end of a function, even if DW_TAG_subprogram for current function is not found. Added: llvm/trunk/test/DebugInfo/2009-12-01-CurrentFn.ll 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=90247&r1=90246&r2=90247&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Dec 1 12:13:48 2009 @@ -2092,17 +2092,15 @@ MMI->getFrameMoves())); // Clear debug info - if (CurrentFnDbgScope) { - CurrentFnDbgScope = NULL; - DbgScopeMap.clear(); - DbgScopeBeginMap.clear(); - DbgScopeEndMap.clear(); - ConcreteScopes.clear(); - AbstractScopesList.clear(); - } + CurrentFnDbgScope = NULL; + DbgScopeMap.clear(); + DbgScopeBeginMap.clear(); + DbgScopeEndMap.clear(); + ConcreteScopes.clear(); + AbstractScopesList.clear(); Lines.clear(); - + if (TimePassesIsEnabled) DebugTimer->stopTimer(); } Added: llvm/trunk/test/DebugInfo/2009-12-01-CurrentFn.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-12-01-CurrentFn.ll?rev=90247&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2009-12-01-CurrentFn.ll (added) +++ llvm/trunk/test/DebugInfo/2009-12-01-CurrentFn.ll Tue Dec 1 12:13:48 2009 @@ -0,0 +1,17 @@ +; RUN: llc < %s | grep "func_end1:" | count 1 + +declare void @foo() + +define void @bar(i32 %i) nounwind ssp { +entry: + tail call void @foo() nounwind, !dbg !0 + ret void, !dbg !0 +} + +!0 = metadata !{i32 9, i32 0, metadata !1, null} +!1 = metadata !{i32 458798, i32 0, metadata !2, metadata !"baz", metadata !"baz", metadata !"baz", metadata !2, i32 8, metadata !3, i1 true, i1 true}; [DW_TAG_subprogram ] +!2 = metadata !{i32 458769, i32 0, i32 1, metadata !"2007-12-VarArrayDebug.c", metadata !"/Volumes/Data/ddunbar/llvm/test/FrontendC", metadata !"4.2.1 (Based on Apple Inc. build 5653) (LLVM build)", i1 true, i1 true, metadata !"", i32 0}; [DW_TAG_compile_unit ] +!3 = metadata !{i32 458773, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0}; [DW_TAG_subroutine_type ] +!4 = metadata !{null, metadata !5} +!5 = metadata !{i32 458788, metadata !2, metadata !"int", metadata !2, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5}; [DW_TAG_base_type ] + From clattner at apple.com Tue Dec 1 12:46:56 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 10:46:56 -0800 Subject: [llvm-commits] [llvm] r90160 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC++/m64-ptr.cpp FrontendC/2009-02-17-BitField-dbg.c In-Reply-To: <352a1fb20912010943m5dc07732hbc05ec94022d5555@mail.gmail.com> References: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> <352a1fb20912010943m5dc07732hbc05ec94022d5555@mail.gmail.com> Message-ID: <36158F27-3794-46CB-A0FA-FE64D8866481@apple.com> On Dec 1, 2009, at 9:43 AM, Devang Patel wrote: > On Mon, Nov 30, 2009 at 5:45 PM, Chris Lattner > wrote: >> >> On Nov 30, 2009, at 2:23 PM, Bill Wendling wrote: >> >>> Author: void >>> Date: Mon Nov 30 16:23:29 2009 >>> New Revision: 90160 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=90160&view=rev >>> Log: >>> Debug info is disabled on PPC Darwin. >> >> Why is debug info disabled on ppc darwin? > > I think it happened accidently during MCAsmInfo transition. > PPCMCAsmInfoDarwin() does not set SupportsDebugInformation. So, the > PPC support has bit rotted little bit. There is one bug blocking > llvm-gcc bootstrap because of debug info, which needs to be fixed > before PPCMCAsmInfoDarwin() is updated to set > SupportsDebugInformation. Ah, that is unfortunate. Are you tracking down this problem? Thanks Devang, -Chris From devang.patel at gmail.com Tue Dec 1 12:57:32 2009 From: devang.patel at gmail.com (Devang Patel) Date: Tue, 1 Dec 2009 10:57:32 -0800 Subject: [llvm-commits] [llvm] r90160 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC++/m64-ptr.cpp FrontendC/2009-02-17-BitField-dbg.c In-Reply-To: <36158F27-3794-46CB-A0FA-FE64D8866481@apple.com> References: <200911302223.nAUMNUda031483@zion.cs.uiuc.edu> <352a1fb20912010943m5dc07732hbc05ec94022d5555@mail.gmail.com> <36158F27-3794-46CB-A0FA-FE64D8866481@apple.com> Message-ID: <352a1fb20912011057g7156a014ke7966aa73d983766@mail.gmail.com> On Tue, Dec 1, 2009 at 10:46 AM, Chris Lattner wrote: > > On Dec 1, 2009, at 9:43 AM, Devang Patel wrote: > >> On Mon, Nov 30, 2009 at 5:45 PM, Chris Lattner wrote: >>> >>> On Nov 30, 2009, at 2:23 PM, Bill Wendling wrote: >>> >>>> Author: void >>>> Date: Mon Nov 30 16:23:29 2009 >>>> New Revision: 90160 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=90160&view=rev >>>> Log: >>>> Debug info is disabled on PPC Darwin. >>> >>> Why is debug info disabled on ppc darwin? >> >> I think it happened accidently during MCAsmInfo transition. >> PPCMCAsmInfoDarwin() does not set SupportsDebugInformation. So, the >> PPC support has bit rotted little bit. There is one bug blocking >> llvm-gcc bootstrap because of debug info, which needs to be fixed >> before PPCMCAsmInfoDarwin() is updated to set >> SupportsDebugInformation. > > Ah, that is unfortunate. ?Are you tracking down this problem? ?Thanks Yes. - Devang From daniel at zuster.org Tue Dec 1 13:11:36 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 01 Dec 2009 19:11:36 -0000 Subject: [llvm-commits] [llvm] r90251 - /llvm/trunk/CMakeLists.txt Message-ID: <200912011911.nB1JBarC025525@zion.cs.uiuc.edu> Author: ddunbar Date: Tue Dec 1 13:11:36 2009 New Revision: 90251 URL: http://llvm.org/viewvc/llvm-project?rev=90251&view=rev Log: Don't default warnings to ON on MSVC, the spew is enough to triple the build time. :/ Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90251&r1=90250&r2=90251&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Dec 1 13:11:36 2009 @@ -191,7 +191,13 @@ add_llvm_definitions( -D__STDC_LIMIT_MACROS ) add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) -option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) +# MSVC has a gazillion warnings with this. +if( MSVC ) + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) +else( MSVC ) + option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) +endif() + option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) From gohman at apple.com Tue Dec 1 13:13:27 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Dec 2009 19:13:27 -0000 Subject: [llvm-commits] [llvm] r90252 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Message-ID: <200912011913.nB1JDRup025597@zion.cs.uiuc.edu> Author: djg Date: Tue Dec 1 13:13:27 2009 New Revision: 90252 URL: http://llvm.org/viewvc/llvm-project?rev=90252&view=rev Log: Trim an unnecessary #include. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90252&r1=90251&r2=90252&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Tue Dec 1 13:13:27 2009 @@ -29,7 +29,6 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" -#include using namespace llvm; namespace llvm { From gohman at apple.com Tue Dec 1 13:16:15 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Dec 2009 19:16:15 -0000 Subject: [llvm-commits] [llvm] r90253 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Message-ID: <200912011916.nB1JGFeb025743@zion.cs.uiuc.edu> Author: djg Date: Tue Dec 1 13:16:15 2009 New Revision: 90253 URL: http://llvm.org/viewvc/llvm-project?rev=90253&view=rev Log: Minor cleanups. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90253&r1=90252&r2=90253&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Tue Dec 1 13:16:15 2009 @@ -35,7 +35,8 @@ template<> struct DOTGraphTraits : public DefaultDOTGraphTraits { - DOTGraphTraits (bool isSimple=false) : DefaultDOTGraphTraits(isSimple) {} + explicit DOTGraphTraits(bool isSimple=false) : + DefaultDOTGraphTraits(isSimple) {} static bool hasEdgeDestLabels() { return true; @@ -75,12 +76,12 @@ static bool renderGraphFromBottomUp() { return true; } - + static bool hasNodeAddressLabel(const SDNode *Node, const SelectionDAG *Graph) { return true; } - + /// If you want to override the dot attributes printed for a particular /// edge, override this method. template @@ -93,7 +94,7 @@ return "color=blue,style=dashed"; return ""; } - + static std::string getSimpleNodeLabel(const SDNode *Node, const SelectionDAG *G) { @@ -131,7 +132,7 @@ std::string DOTGraphTraits::getNodeLabel(const SDNode *Node, const SelectionDAG *G) { - return DOTGraphTraits::getSimpleNodeLabel (Node, G); + return DOTGraphTraits::getSimpleNodeLabel(Node, G); } @@ -141,7 +142,7 @@ void SelectionDAG::viewGraph(const std::string &Title) { // This code is only for debugging! #ifndef NDEBUG - ViewGraph(this, "dag." + getMachineFunction().getFunction()->getNameStr(), + ViewGraph(this, "dag." + getMachineFunction().getFunction()->getNameStr(), false, Title); #else errs() << "SelectionDAG::viewGraph is only available in debug builds on " @@ -185,7 +186,7 @@ #ifndef NDEBUG std::map::const_iterator I = NodeGraphAttrs.find(N); - + if (I != NodeGraphAttrs.end()) return I->second; else @@ -251,8 +252,7 @@ // Visually mark that we hit the limit if (strcmp(Color, "red") == 0) { setSubgraphColorHelper(N, "blue", visited, 0, printed); - } - else if (strcmp(Color, "yellow") == 0) { + } else if (strcmp(Color, "yellow") == 0) { setSubgraphColorHelper(N, "green", visited, 0, printed); } } From gohman at apple.com Tue Dec 1 13:20:00 2009 From: gohman at apple.com (Dan Gohman) Date: Tue, 01 Dec 2009 19:20:00 -0000 Subject: [llvm-commits] [llvm] r90254 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Message-ID: <200912011920.nB1JK0oN025858@zion.cs.uiuc.edu> Author: djg Date: Tue Dec 1 13:20:00 2009 New Revision: 90254 URL: http://llvm.org/viewvc/llvm-project?rev=90254&view=rev Log: Add edge source labels to SelectionDAG graphs, now that the graph printing framework omits differentiated edge sources in the case where the labels are empty strings. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=90254&r1=90253&r2=90254&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Tue Dec 1 13:20:00 2009 @@ -2397,6 +2397,11 @@ SDNodeIterator operator++(int) { // Postincrement SDNodeIterator tmp = *this; ++*this; return tmp; } + size_t operator-(SDNodeIterator Other) const { + assert(Node == Other.Node && + "Cannot compare iterators of two different nodes!"); + return Operand - Other.Operand; + } static SDNodeIterator begin(SDNode *N) { return SDNodeIterator(N, 0); } static SDNodeIterator end (SDNode *N) { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp?rev=90254&r1=90253&r2=90254&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp Tue Dec 1 13:20:00 2009 @@ -50,6 +50,11 @@ return ((const SDNode *) Node)->getValueType(i).getEVTString(); } + template + static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) { + return itostr(I - SDNodeIterator::begin((SDNode *) Node)); + } + /// edgeTargetsEdgeSource - This method returns true if this outgoing edge /// should actually target another edge source, not a node. If this method /// is implemented, getEdgeTarget should be implemented. From dpatel at apple.com Tue Dec 1 14:06:39 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 20:06:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90256 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h Message-ID: <200912012006.nB1K6dg1027740@zion.cs.uiuc.edu> Author: dpatel Date: Tue Dec 1 14:06:38 2009 New Revision: 90256 URL: http://llvm.org/viewvc/llvm-project?rev=90256&view=rev Log: Do not ignore nameless records while emitting debug info. Keep track of scope for nested records. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp llvm-gcc-4.2/trunk/gcc/llvm-debug.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=90256&r1=90255&r2=90256&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Dec 1 14:06:38 2009 @@ -251,8 +251,8 @@ true /*definition*/); // Push function on region stack. - RegionStack.push_back(SP); - RegionMap[FnDecl] = SP; + RegionStack.push_back(WeakVH(SP.getNode())); + RegionMap[FnDecl] = WeakVH(SP.getNode()); } /// findRegion - Find tree_node N's region. @@ -260,9 +260,10 @@ if (Node == NULL_TREE) return getOrCreateCompileUnit(main_input_filename); - std::map::iterator I = RegionMap.find(Node); + std::map::iterator I = RegionMap.find(Node); if (I != RegionMap.end()) - return I->second; + if (MDNode *R = dyn_cast_or_null(I->second)) + return DIDescriptor(R); if (TYPE_P (Node)) { if (TYPE_CONTEXT (Node)) @@ -317,20 +318,21 @@ expanded_location Loc = GetNodeLocation(decl, false); // Construct variable. + DIScope VarScope = DIScope(cast(RegionStack.back())); llvm::DIVariable D = - DebugFactory.CreateVariable(Tag, RegionStack.back(), Name, - getOrCreateCompileUnit(Loc.file), + DebugFactory.CreateVariable(Tag, VarScope, + Name, getOrCreateCompileUnit(Loc.file), Loc.line, getOrCreateType(type)); // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); - llvm::DIDescriptor DR = RegionStack.back(); - llvm::DIScope DS = llvm::DIScope(DR.getNode()); +// llvm::DIDescriptor DR = RegionStack.back(); +// llvm::DIScope DS = llvm::DIScope(DR.getNode()); llvm::DILocation DO(NULL); llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); + DebugFactory.CreateLocation(CurLineNo, 0 /* column */, VarScope, DO); Builder.SetDebugLocation(Call, DL.getNode()); } @@ -381,7 +383,7 @@ if (RegionStack.empty()) return; - llvm::DIDescriptor DR = RegionStack.back(); + llvm::DIDescriptor DR(cast(RegionStack.back())); llvm::DIScope DS = llvm::DIScope(DR.getNode()); llvm::DILocation DO(NULL); llvm::DILocation DL = @@ -685,6 +687,10 @@ // Insert into the TypeCache so that recursive uses will find it. llvm::TrackingVH FwdDeclNode = FwdDecl.getNode(); TypeCache[type] = WeakVH(FwdDecl.getNode()); + + // Push the struct on region stack. + RegionStack.push_back(WeakVH(FwdDecl.getNode())); + RegionMap[type] = WeakVH(FwdDecl.getNode()); // Convert all the elements. llvm::SmallVector EltTys; @@ -720,7 +726,9 @@ continue; /* Ignore nameless fields. */ - if (DECL_NAME (Member) == NULL_TREE) + if (DECL_NAME (Member) == NULL_TREE + && !(TREE_CODE (TREE_TYPE (Member)) == UNION_TYPE + || TREE_CODE (TREE_TYPE (Member)) == RECORD_TYPE)) continue; // Get the location of the member. @@ -775,6 +783,11 @@ llvm::DIArray Elements = DebugFactory.GetOrCreateArray(EltTys.data(), EltTys.size()); + RegionStack.pop_back(); + std::map::iterator RI = RegionMap.find(type); + if (RI != RegionMap.end()) + RegionMap.erase(RI); + llvm::DICompositeType RealDecl = DebugFactory.CreateCompositeType(Tag, findRegion(type), GetNodeName(type), @@ -787,6 +800,7 @@ // Now that we have a real decl for the struct, replace anything using the // old decl with the new one. This will recursively update the debug info. llvm::DIDerivedType(FwdDeclNode).replaceAllUsesWith(RealDecl); + return RealDecl; } Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=90256&r1=90255&r2=90256&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue Dec 1 14:06:38 2009 @@ -65,10 +65,10 @@ std::map TypeCache; // Cache of previously constructed // Types. - std::vector RegionStack; + SmallVector RegionStack; // Stack to track declarative scopes. - std::map RegionMap; + std::map RegionMap; public: DebugInfo(Module *m); From baldrick at free.fr Tue Dec 1 14:42:43 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 21:42:43 +0100 Subject: [llvm-commits] [llvm] r90108 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <7FC3ADB7-9B05-4207-8947-AB715B904267@apple.com> References: <200911300242.nAU2g38a004283@zion.cs.uiuc.edu> <4B1433FD.9070408@free.fr> <7FC3ADB7-9B05-4207-8947-AB715B904267@apple.com> Message-ID: <4B157FC3.3010606@free.fr> Hi Mon Ping, > The solution for divide by unrolling is X86 specific. Widening the divisor by 1 would always safe but could lead to an extra scalar divide being generated for this case. yes, that might be so. However, the extra values generated by widening usually won't actually be used (at least I don't think so) so I would expect any such extra divisions to be discarded by the DAG combiner. Ciao, Duncan. From deeppatel1987 at gmail.com Tue Dec 1 15:07:31 2009 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 1 Dec 2009 21:07:31 +0000 Subject: [llvm-commits] [llvm] r90251 - /llvm/trunk/CMakeLists.txt In-Reply-To: <200912011911.nB1JBarC025525@zion.cs.uiuc.edu> References: <200912011911.nB1JBarC025525@zion.cs.uiuc.edu> Message-ID: <305d6f60912011307q3ded023ep3636137a596a93d0@mail.gmail.com> It seems a shame to lose all that information from another front-end. Perhaps an MSVC user could dump all the warnings into a bugzilla report? deep On Tue, Dec 1, 2009 at 7:11 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Tue Dec ?1 13:11:36 2009 > New Revision: 90251 > > URL: http://llvm.org/viewvc/llvm-project?rev=90251&view=rev > Log: > Don't default warnings to ON on MSVC, the spew is enough to triple the build time. :/ > > Modified: > ? ?llvm/trunk/CMakeLists.txt > > Modified: llvm/trunk/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=90251&r1=90250&r2=90251&view=diff > > ============================================================================== > --- llvm/trunk/CMakeLists.txt (original) > +++ llvm/trunk/CMakeLists.txt Tue Dec ?1 13:11:36 2009 > @@ -191,7 +191,13 @@ > ?add_llvm_definitions( -D__STDC_LIMIT_MACROS ) > ?add_llvm_definitions( -D__STDC_CONSTANT_MACROS ) > > -option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) > +# MSVC has a gazillion warnings with this. > +if( MSVC ) > + ?option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF) > +else( MSVC ) > + ?option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) > +endif() > + > ?option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) > ?option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Tue Dec 1 15:15:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 21:15:16 -0000 Subject: [llvm-commits] [llvm] r90257 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200912012115.nB1LFGlM029999@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 15:15:15 2009 New Revision: 90257 URL: http://llvm.org/viewvc/llvm-project?rev=90257&view=rev Log: tidy Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90257&r1=90256&r2=90257&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Dec 1 15:15:15 2009 @@ -183,7 +183,9 @@ if (invariantTag == Inst) { invariantTag = 0; continue; - } else if (IntrinsicInst *II = dyn_cast(Inst)) { + } + + if (IntrinsicInst *II = dyn_cast(Inst)) { // If we pass an invariant-end marker, then we've just entered an // invariant region and can start ignoring dependencies. if (II->getIntrinsicID() == Intrinsic::invariant_end) { From sabre at nondot.org Tue Dec 1 15:16:02 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 21:16:02 -0000 Subject: [llvm-commits] [llvm] r90258 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200912012116.nB1LG2DM030097@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 15:16:01 2009 New Revision: 90258 URL: http://llvm.org/viewvc/llvm-project?rev=90258&view=rev Log: rename some variables. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90258&r1=90257&r2=90258&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Dec 1 15:16:01 2009 @@ -172,7 +172,7 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB) { - Value *invariantTag = 0; + Value *InvariantTag = 0; // Walk backwards through the basic block, looking for dependencies. while (ScanIt != BB->begin()) { @@ -180,8 +180,8 @@ // If we're in an invariant region, no dependencies can be found before // we pass an invariant-begin marker. - if (invariantTag == Inst) { - invariantTag = 0; + if (InvariantTag == Inst) { + InvariantTag = 0; continue; } @@ -189,14 +189,14 @@ // If we pass an invariant-end marker, then we've just entered an // invariant region and can start ignoring dependencies. if (II->getIntrinsicID() == Intrinsic::invariant_end) { - uint64_t invariantSize = ~0ULL; + uint64_t InvariantSize = ~0ULL; if (ConstantInt *CI = dyn_cast(II->getOperand(2))) - invariantSize = CI->getZExtValue(); + InvariantSize = CI->getZExtValue(); AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(3), invariantSize, MemPtr, MemSize); + AA->alias(II->getOperand(3), InvariantSize, MemPtr, MemSize); if (R == AliasAnalysis::MustAlias) { - invariantTag = II->getOperand(1); + InvariantTag = II->getOperand(1); continue; } @@ -204,12 +204,12 @@ // because the value is undefined. } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || II->getIntrinsicID() == Intrinsic::lifetime_end) { - uint64_t invariantSize = ~0ULL; + uint64_t InvariantSize = ~0ULL; if (ConstantInt *CI = dyn_cast(II->getOperand(1))) - invariantSize = CI->getZExtValue(); + InvariantSize = CI->getZExtValue(); AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(2), invariantSize, MemPtr, MemSize); + AA->alias(II->getOperand(2), InvariantSize, MemPtr, MemSize); if (R == AliasAnalysis::MustAlias) return MemDepResult::getDef(II); } @@ -217,7 +217,7 @@ // If we're querying on a load and we're in an invariant region, we're done // at this point. Nothing a load depends on can live in an invariant region. - if (isLoad && invariantTag) continue; + if (isLoad && InvariantTag) continue; // Debug intrinsics don't cause dependences. if (isa(Inst)) continue; @@ -245,7 +245,7 @@ if (StoreInst *SI = dyn_cast(Inst)) { // There can't be stores to the value we care about inside an // invariant region. - if (invariantTag) continue; + if (InvariantTag) continue; // If alias analysis can tell that this store is guaranteed to not modify // the query pointer, ignore it. Use getModRefInfo to handle cases where @@ -294,7 +294,7 @@ case AliasAnalysis::Mod: // If we're in an invariant region, we can ignore calls that ONLY // modify the pointer. - if (invariantTag) continue; + if (InvariantTag) continue; return MemDepResult::getClobber(Inst); case AliasAnalysis::Ref: // If the call is known to never store to the pointer, and if this is a From baldrick at free.fr Tue Dec 1 15:18:10 2009 From: baldrick at free.fr (Duncan Sands) Date: Tue, 01 Dec 2009 21:18:10 -0000 Subject: [llvm-commits] [dragonegg] r90259 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912012118.nB1LIAxU030167@zion.cs.uiuc.edu> Author: baldrick Date: Tue Dec 1 15:18:10 2009 New Revision: 90259 URL: http://llvm.org/viewvc/llvm-project?rev=90259&view=rev Log: Since EmitLoadOfLValue, EmitADDR_EXPR, EmitOBJ_TYPE_REF and EmitCONSTRUCTOR now exist solely for the benefit of EmitGimpleAssignSingleRHS, move them to just before this method. (EmitADDR_EXPR is used in one other place, but philosophically it belongs here). 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=90259&r1=90258&r2=90259&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Tue Dec 1 15:18:10 2009 @@ -2206,6 +2206,210 @@ return C; } +/// EmitLoadOfLValue - When an l-value expression is used in a context that +/// requires an r-value, this method emits the lvalue computation, then loads +/// the result. +Value *TreeToLLVM::EmitLoadOfLValue(tree exp, const MemRef *DestLoc) { + if (canEmitRegisterVariable(exp)) + // If this is a register variable, EmitLV can't handle it (there is no + // l-value of a register variable). Emit an inline asm node that copies the + // value out of the specified register. + return EmitReadOfRegisterVariable(exp, DestLoc); + + LValue LV = EmitLV(exp); + bool isVolatile = TREE_THIS_VOLATILE(exp); + const Type *Ty = ConvertType(TREE_TYPE(exp)); + unsigned Alignment = LV.getAlignment(); + if (TREE_CODE(exp) == COMPONENT_REF) + if (const StructType *STy = + dyn_cast(ConvertType(TREE_TYPE(TREE_OPERAND(exp, 0))))) + if (STy->isPacked()) + // Packed struct members use 1 byte alignment + Alignment = 1; + + + if (!LV.isBitfield()) { + if (!DestLoc) { + // Scalar value: emit a load. + Value *Ptr = Builder.CreateBitCast(LV.Ptr, Ty->getPointerTo()); + LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); + LI->setAlignment(Alignment); + return LI; + } else { + EmitAggregateCopy(*DestLoc, MemRef(LV.Ptr, Alignment, isVolatile), + TREE_TYPE(exp)); + return 0; + } + } else { + // This is a bitfield reference. + if (!LV.BitSize) + return Constant::getNullValue(Ty); + + const Type *ValTy = cast(LV.Ptr->getType())->getElementType(); + unsigned ValSizeInBits = ValTy->getPrimitiveSizeInBits(); + + // The number of loads needed to read the entire bitfield. + unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; + + assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); + assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); + assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); + assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); + + Value *Result = NULL; + + for (unsigned I = 0; I < Strides; I++) { + unsigned Index = BYTES_BIG_ENDIAN ? I : Strides - I - 1; // MSB first + unsigned ThisFirstBit = Index * ValSizeInBits; + unsigned ThisLastBitPlusOne = ThisFirstBit + ValSizeInBits; + if (ThisFirstBit < LV.BitStart) + ThisFirstBit = LV.BitStart; + if (ThisLastBitPlusOne > LV.BitStart+LV.BitSize) + ThisLastBitPlusOne = LV.BitStart+LV.BitSize; + + Value *Ptr = Index ? + Builder.CreateGEP(LV.Ptr, + ConstantInt::get(Type::getInt32Ty(Context), Index)) : + LV.Ptr; + LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); + LI->setAlignment(Alignment); + Value *Val = LI; + + unsigned BitsInVal = ThisLastBitPlusOne - ThisFirstBit; + unsigned FirstBitInVal = ThisFirstBit % ValSizeInBits; + + if (BYTES_BIG_ENDIAN) + FirstBitInVal = ValSizeInBits-FirstBitInVal-BitsInVal; + + // Mask the bits out by shifting left first, then shifting right. The + // LLVM optimizer will turn this into an AND if this is an unsigned + // expression. + + if (FirstBitInVal+BitsInVal != ValSizeInBits) { + Value *ShAmt = ConstantInt::get(ValTy, ValSizeInBits - + (FirstBitInVal+BitsInVal)); + Val = Builder.CreateShl(Val, ShAmt); + } + + // Shift right required? + if (ValSizeInBits != BitsInVal) { + bool AddSignBits = !TYPE_UNSIGNED(TREE_TYPE(exp)) && !Result; + Value *ShAmt = ConstantInt::get(ValTy, ValSizeInBits-BitsInVal); + Val = AddSignBits ? + Builder.CreateAShr(Val, ShAmt) : Builder.CreateLShr(Val, ShAmt); + } + + if (Result) { + Value *ShAmt = ConstantInt::get(ValTy, BitsInVal); + Result = Builder.CreateShl(Result, ShAmt); + Result = Builder.CreateOr(Result, Val); + } else { + Result = Val; + } + } + + return Builder.CreateIntCast(Result, Ty, + /*isSigned*/!TYPE_UNSIGNED(TREE_TYPE(exp))); + } +} + +Value *TreeToLLVM::EmitADDR_EXPR(tree exp) { + LValue LV = EmitLV(TREE_OPERAND(exp, 0)); + assert((!LV.isBitfield() || LV.BitStart == 0) && + "It is illegal to take the address of a bitfield!"); + // Perform a cast here if necessary. For example, GCC sometimes forms an + // ADDR_EXPR where the operand is an array, and the ADDR_EXPR type is a + // pointer to the first element. + return Builder.CreateBitCast(LV.Ptr, ConvertType(TREE_TYPE(exp))); +} + +Value *TreeToLLVM::EmitOBJ_TYPE_REF(tree exp) { + return Builder.CreateBitCast(EmitGimpleReg(OBJ_TYPE_REF_EXPR(exp)), + ConvertType(TREE_TYPE(exp))); +} + +/// EmitCONSTRUCTOR - emit the constructor into the location specified by +/// DestLoc. +Value *TreeToLLVM::EmitCONSTRUCTOR(tree exp, const MemRef *DestLoc) { + tree type = TREE_TYPE(exp); + const Type *Ty = ConvertType(type); + if (const VectorType *VTy = dyn_cast(Ty)) { + assert(DestLoc == 0 && "Dest location for vector value?"); + std::vector BuildVecOps; + BuildVecOps.reserve(VTy->getNumElements()); + + // Insert all of the elements here. + unsigned HOST_WIDE_INT idx; + tree value; + FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) { + Value *Elt = EmitGimpleReg(value); + + if (const VectorType *EltTy = dyn_cast(Elt->getType())) { + // GCC allows vectors to be built up from vectors. Extract all of the + // vector elements and add them to the list of build vector operands. + for (unsigned i = 0, e = EltTy->getNumElements(); i != e; ++i) { + Value *Index = ConstantInt::get(llvm::Type::getInt32Ty(Context), i); + BuildVecOps.push_back(Builder.CreateExtractElement(Elt, Index)); + } + } else { + assert(Elt->getType() == VTy->getElementType() && + "Unexpected type for vector constructor!"); + BuildVecOps.push_back(Elt); + } + } + + // Insert zero for any unspecified values. + while (BuildVecOps.size() < VTy->getNumElements()) + BuildVecOps.push_back(Constant::getNullValue(VTy->getElementType())); + assert(BuildVecOps.size() == VTy->getNumElements() && + "Vector constructor specified too many values!"); + + return BuildVector(BuildVecOps); + } + + assert(AGGREGATE_TYPE_P(type) && "Constructor for scalar type??"); + + // Start out with the value zero'd out. + EmitAggregateZero(*DestLoc, type); + + VEC(constructor_elt, gc) *elt = CONSTRUCTOR_ELTS(exp); + switch (TREE_CODE(TREE_TYPE(exp))) { + case ARRAY_TYPE: + case RECORD_TYPE: + default: + if (elt && VEC_length(constructor_elt, elt)) { + // We don't handle elements yet. + + TODO(exp); + } + return 0; + case QUAL_UNION_TYPE: + case UNION_TYPE: + // Store each element of the constructor into the corresponding field of + // DEST. + if (!elt || VEC_empty(constructor_elt, elt)) return 0; // no elements + assert(VEC_length(constructor_elt, elt) == 1 + && "Union CONSTRUCTOR should have one element!"); + tree tree_purpose = VEC_index(constructor_elt, elt, 0)->index; + tree tree_value = VEC_index(constructor_elt, elt, 0)->value; + if (!tree_purpose) + return 0; // Not actually initialized? + + if (AGGREGATE_TYPE_P(TREE_TYPE(tree_purpose))) { + EmitAggregate(tree_value, *DestLoc); + } else { + // Scalar value. Evaluate to a register, then do the store. + Value *V = EmitGimpleReg(tree_value); + Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, + PointerType::getUnqual(V->getType())); + StoreInst *St = Builder.CreateStore(V, Ptr, DestLoc->Volatile); + St->setAlignment(DestLoc->getAlignment()); + } + break; + } + return 0; +} + Value *TreeToLLVM::EmitGimpleAssignSingleRHS(tree rhs, const MemRef *DestLoc) { assert((AGGREGATE_TYPE_P(TREE_TYPE(rhs)) == (DestLoc != 0)) && "DestLoc for aggregate types only!"); @@ -2375,128 +2579,6 @@ } } -/// EmitLoadOfLValue - When an l-value expression is used in a context that -/// requires an r-value, this method emits the lvalue computation, then loads -/// the result. -Value *TreeToLLVM::EmitLoadOfLValue(tree exp, const MemRef *DestLoc) { - if (canEmitRegisterVariable(exp)) - // If this is a register variable, EmitLV can't handle it (there is no - // l-value of a register variable). Emit an inline asm node that copies the - // value out of the specified register. - return EmitReadOfRegisterVariable(exp, DestLoc); - - LValue LV = EmitLV(exp); - bool isVolatile = TREE_THIS_VOLATILE(exp); - const Type *Ty = ConvertType(TREE_TYPE(exp)); - unsigned Alignment = LV.getAlignment(); - if (TREE_CODE(exp) == COMPONENT_REF) - if (const StructType *STy = - dyn_cast(ConvertType(TREE_TYPE(TREE_OPERAND(exp, 0))))) - if (STy->isPacked()) - // Packed struct members use 1 byte alignment - Alignment = 1; - - - if (!LV.isBitfield()) { - if (!DestLoc) { - // Scalar value: emit a load. - Value *Ptr = Builder.CreateBitCast(LV.Ptr, Ty->getPointerTo()); - LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); - LI->setAlignment(Alignment); - return LI; - } else { - EmitAggregateCopy(*DestLoc, MemRef(LV.Ptr, Alignment, isVolatile), - TREE_TYPE(exp)); - return 0; - } - } else { - // This is a bitfield reference. - if (!LV.BitSize) - return Constant::getNullValue(Ty); - - const Type *ValTy = cast(LV.Ptr->getType())->getElementType(); - unsigned ValSizeInBits = ValTy->getPrimitiveSizeInBits(); - - // The number of loads needed to read the entire bitfield. - unsigned Strides = 1 + (LV.BitStart + LV.BitSize - 1) / ValSizeInBits; - - assert(ValTy->isInteger() && "Invalid bitfield lvalue!"); - assert(ValSizeInBits > LV.BitStart && "Bad bitfield lvalue!"); - assert(ValSizeInBits >= LV.BitSize && "Bad bitfield lvalue!"); - assert(2*ValSizeInBits > LV.BitSize+LV.BitStart && "Bad bitfield lvalue!"); - - Value *Result = NULL; - - for (unsigned I = 0; I < Strides; I++) { - unsigned Index = BYTES_BIG_ENDIAN ? I : Strides - I - 1; // MSB first - unsigned ThisFirstBit = Index * ValSizeInBits; - unsigned ThisLastBitPlusOne = ThisFirstBit + ValSizeInBits; - if (ThisFirstBit < LV.BitStart) - ThisFirstBit = LV.BitStart; - if (ThisLastBitPlusOne > LV.BitStart+LV.BitSize) - ThisLastBitPlusOne = LV.BitStart+LV.BitSize; - - Value *Ptr = Index ? - Builder.CreateGEP(LV.Ptr, - ConstantInt::get(Type::getInt32Ty(Context), Index)) : - LV.Ptr; - LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); - LI->setAlignment(Alignment); - Value *Val = LI; - - unsigned BitsInVal = ThisLastBitPlusOne - ThisFirstBit; - unsigned FirstBitInVal = ThisFirstBit % ValSizeInBits; - - if (BYTES_BIG_ENDIAN) - FirstBitInVal = ValSizeInBits-FirstBitInVal-BitsInVal; - - // Mask the bits out by shifting left first, then shifting right. The - // LLVM optimizer will turn this into an AND if this is an unsigned - // expression. - - if (FirstBitInVal+BitsInVal != ValSizeInBits) { - Value *ShAmt = ConstantInt::get(ValTy, ValSizeInBits - - (FirstBitInVal+BitsInVal)); - Val = Builder.CreateShl(Val, ShAmt); - } - - // Shift right required? - if (ValSizeInBits != BitsInVal) { - bool AddSignBits = !TYPE_UNSIGNED(TREE_TYPE(exp)) && !Result; - Value *ShAmt = ConstantInt::get(ValTy, ValSizeInBits-BitsInVal); - Val = AddSignBits ? - Builder.CreateAShr(Val, ShAmt) : Builder.CreateLShr(Val, ShAmt); - } - - if (Result) { - Value *ShAmt = ConstantInt::get(ValTy, BitsInVal); - Result = Builder.CreateShl(Result, ShAmt); - Result = Builder.CreateOr(Result, Val); - } else { - Result = Val; - } - } - - return Builder.CreateIntCast(Result, Ty, - /*isSigned*/!TYPE_UNSIGNED(TREE_TYPE(exp))); - } -} - -Value *TreeToLLVM::EmitADDR_EXPR(tree exp) { - LValue LV = EmitLV(TREE_OPERAND(exp, 0)); - assert((!LV.isBitfield() || LV.BitStart == 0) && - "It is illegal to take the address of a bitfield!"); - // Perform a cast here if necessary. For example, GCC sometimes forms an - // ADDR_EXPR where the operand is an array, and the ADDR_EXPR type is a - // pointer to the first element. - return Builder.CreateBitCast(LV.Ptr, ConvertType(TREE_TYPE(exp))); -} - -Value *TreeToLLVM::EmitOBJ_TYPE_REF(tree exp) { - return Builder.CreateBitCast(EmitGimpleReg(OBJ_TYPE_REF_EXPR(exp)), - ConvertType(TREE_TYPE(exp))); -} - Value *TreeToLLVM::EmitGimpleCallRHS(gimple stmt, const MemRef *DestLoc) { // Check for a built-in function call. If we can lower it directly, do so // now. @@ -6913,88 +6995,6 @@ // ... Constant Expressions ... //===----------------------------------------------------------------------===// -/// EmitCONSTRUCTOR - emit the constructor into the location specified by -/// DestLoc. -Value *TreeToLLVM::EmitCONSTRUCTOR(tree exp, const MemRef *DestLoc) { - tree type = TREE_TYPE(exp); - const Type *Ty = ConvertType(type); - if (const VectorType *VTy = dyn_cast(Ty)) { - assert(DestLoc == 0 && "Dest location for vector value?"); - std::vector BuildVecOps; - BuildVecOps.reserve(VTy->getNumElements()); - - // Insert all of the elements here. - unsigned HOST_WIDE_INT idx; - tree value; - FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) { - Value *Elt = EmitGimpleReg(value); - - if (const VectorType *EltTy = dyn_cast(Elt->getType())) { - // GCC allows vectors to be built up from vectors. Extract all of the - // vector elements and add them to the list of build vector operands. - for (unsigned i = 0, e = EltTy->getNumElements(); i != e; ++i) { - Value *Index = ConstantInt::get(llvm::Type::getInt32Ty(Context), i); - BuildVecOps.push_back(Builder.CreateExtractElement(Elt, Index)); - } - } else { - assert(Elt->getType() == VTy->getElementType() && - "Unexpected type for vector constructor!"); - BuildVecOps.push_back(Elt); - } - } - - // Insert zero for any unspecified values. - while (BuildVecOps.size() < VTy->getNumElements()) - BuildVecOps.push_back(Constant::getNullValue(VTy->getElementType())); - assert(BuildVecOps.size() == VTy->getNumElements() && - "Vector constructor specified too many values!"); - - return BuildVector(BuildVecOps); - } - - assert(AGGREGATE_TYPE_P(type) && "Constructor for scalar type??"); - - // Start out with the value zero'd out. - EmitAggregateZero(*DestLoc, type); - - VEC(constructor_elt, gc) *elt = CONSTRUCTOR_ELTS(exp); - switch (TREE_CODE(TREE_TYPE(exp))) { - case ARRAY_TYPE: - case RECORD_TYPE: - default: - if (elt && VEC_length(constructor_elt, elt)) { - // We don't handle elements yet. - - TODO(exp); - } - return 0; - case QUAL_UNION_TYPE: - case UNION_TYPE: - // Store each element of the constructor into the corresponding field of - // DEST. - if (!elt || VEC_empty(constructor_elt, elt)) return 0; // no elements - assert(VEC_length(constructor_elt, elt) == 1 - && "Union CONSTRUCTOR should have one element!"); - tree tree_purpose = VEC_index(constructor_elt, elt, 0)->index; - tree tree_value = VEC_index(constructor_elt, elt, 0)->value; - if (!tree_purpose) - return 0; // Not actually initialized? - - if (AGGREGATE_TYPE_P(TREE_TYPE(tree_purpose))) { - EmitAggregate(tree_value, *DestLoc); - } else { - // Scalar value. Evaluate to a register, then do the store. - Value *V = EmitGimpleReg(tree_value); - Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, - PointerType::getUnqual(V->getType())); - StoreInst *St = Builder.CreateStore(V, Ptr, DestLoc->Volatile); - St->setAlignment(DestLoc->getAlignment()); - } - break; - } - return 0; -} - Constant *TreeConstantToLLVM::Convert(tree exp) { assert((TREE_CONSTANT(exp) || TREE_CODE(exp) == STRING_CST) && "Isn't a constant!"); From clattner at apple.com Tue Dec 1 15:35:54 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 13:35:54 -0800 Subject: [llvm-commits] [llvm] r90045 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/DeadStoreElimination/lifetime.ll In-Reply-To: <200911282127.nASLRoum025712@zion.cs.uiuc.edu> References: <200911282127.nASLRoum025712@zion.cs.uiuc.edu> Message-ID: On Nov 28, 2009, at 1:27 PM, Nick Lewycky wrote: > Author: nicholas > Date: Sat Nov 28 15:27:49 2009 > New Revision: 90045 > > URL: http://llvm.org/viewvc/llvm-project?rev=90045&view=rev > Log: > Teach memdep to look for memory use intrinsics during dependency > queries. Fixes > PR5574. Hi Nick, I'm just now catching up on all of the lifetime/invariant stuff you've added to memdep, here are some comments: memdep:188: if (IntrinsicInst *II = dyn_cast(Inst)) { // If we pass an invariant-end marker, then we've just entered an // invariant region and can start ignoring dependencies. if (II->getIntrinsicID() == Intrinsic::invariant_end) { uint64_t InvariantSize = ~0ULL; if (ConstantInt *CI = dyn_cast(II->getOperand(2))) InvariantSize = CI->getZExtValue(); Operand 2 is guaranteed to be a ConstantInt, this should use cast<>, however... AliasAnalysis::AliasResult R = AA->alias(II->getOperand(3), InvariantSize, MemPtr, MemSize); if (R == AliasAnalysis::MustAlias) { InvariantTag = II->getOperand(1); continue; } mustalias queries don't care about the size of the operands, so getting it is pointless. Either the pointers themselves mustalias or not. As such, this won't catch the case where you have a lifetime marker saying that a 20 byte object is live/dead but where you're accessing 4 bytes into the 20 byte object. I don't know if you care about this case, if so, please fix it somehow, otherwise remove the dead code and add a FIXME describing the issue. In the case when you do have a mustalias, why do you continue the scan at all? Can't you just look at the instruction that defines the Invariant tag and jump up to it? That would allow eliminating InvariantTag entirely. I really don't like how InvariantTag is scattered throughout getPointerDependencyFrom. } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || II->getIntrinsicID() == Intrinsic::lifetime_end) { This has the same problem as above, cast<> and mustalias. if (R == AliasAnalysis::MustAlias) return MemDepResult::getDef(II); Returning a def of the lifetime start/end is perfectly reasonable here, but please please document this case (the semantics of this case) in the comment above the MemDepResult::Def enum in MemDep.h. // Debug intrinsics don't cause dependences. if (isa(Inst)) continue; This can be hoisted into the 'if dyn_cast' block. memdep:378: switch (IntrinsicID) { case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: Please indent the case to the level of the switch, and add a break at the end of the default case. What does this code *do* anyway? Does someone actually call getDependency() on a lifetime/invariant intrinsic? bool isLoad = !QueryInst->mayWriteToMemory(); if (IntrinsicInst *II = dyn_cast(QueryInst)) { isLoad |= II->getIntrinsicID() == Intrinsic::lifetime_end; } This dance is gross. -Chris From bob.wilson at apple.com Tue Dec 1 15:41:29 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 1 Dec 2009 13:41:29 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> Message-ID: Hi Rafael, I've spent some time studying this more closely and comparing llvm-gcc's argument passing for x86, ppc, and arm, and I don't think your patch is the right way to go. x86 and ppc handle most aggregate arguments with either the "mixed regs" or "byval" hooks, and rarely if ever fall through to the "integer regs" code. (The x86-64 code is quite a bit more complicated than the others so I didn't try to follow all the paths through it, and it may use the "integer regs" code sometimes.) Instead, I think the ARM backend needs to handle "byval" arguments. That is how both x86 and ppc handle the testcase in pr5406. I don't think it is possible to fix the PassInIntegerRegisters code to correctly handle aggregates that are not a multiple of the register size, at least not without much more extensive changes. You either end up accessing memory past the end of the argument (as Dale pointed out earlier) or splitting the tail into pieces, which is wrong depending on whether each piece is in a separate register or in memory. Adding "byval" support to ARM should be straightforward, but it's not a quick fix. On Nov 25, 2009, at 8:18 PM, Rafael Espindola wrote: > 2009/11/12 Bob Wilson : >> It's breaking something on ARM, too. I'll revert it for now. >> >> I did run gcc's compat tests, but not on PPC. I guess I'll need to do >> that. > > Can you try the patch I attached to the bug? > > Is there an easy way to get just a pass/fail list from the test-suite? > I found the testcase in the bug report by doing > > gmake TEST=nightly report report.html > > in the SingleSource directory both with and without r86892 and > searching for FAIL in the output. > > Cheers, > -- > Rafael ?vila de Esp?ndola From clattner at apple.com Tue Dec 1 15:51:47 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 13:51:47 -0800 Subject: [llvm-commits] [llvm] r89279 - in /llvm/trunk/lib: CodeGen/AsmPrinter/DwarfException.cpp Target/TargetLoweringObjectFile.cpp In-Reply-To: <200911190009.nAJ09EsP022919@zion.cs.uiuc.edu> References: <200911190009.nAJ09EsP022919@zion.cs.uiuc.edu> Message-ID: <1251C188-9F3E-4A26-B4EF-E5C21CA6D270@apple.com> On Nov 18, 2009, at 4:09 PM, Bill Wendling wrote: > Author: void > Date: Wed Nov 18 18:09:14 2009 > New Revision: 89279 > > URL: http://llvm.org/viewvc/llvm-project?rev=89279&view=rev > Log: > The "ReadOnlyWithRel" enum seems to apply more to what Darwin does > with the EH > exception table than DataRel. Right, the __TEXT is read only, so this is definitely good: > +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Nov 18 > 18:09:14 2009 > @@ -784,7 +784,7 @@ > > // Exception Handling. > LSDASection = getMachOSection("__TEXT", "__gcc_except_tab", 0, > - SectionKind::getDataRel()); > + SectionKind::getReadOnlyWithRel()); > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Wed Nov 18 > 18:09:14 2009 > @@ -728,7 +728,7 @@ > // in target-independent code. > // > if ((LSDASection->getKind().isWriteable() && > - !LSDASection->getKind().isDataRel()) || > + !LSDASection->getKind().isReadOnlyWithRel()) || There is a huge comment above this that is now out of date with this change. Which is right? > > if (TI) { > - if (!LSDASection->getKind().isDataRel() && > + if (!LSDASection->getKind().isReadOnlyWithRel() && > (TTypeFormat == dwarf::DW_EH_PE_absptr || > TI->getLinkage() == GlobalValue::InternalLinkage)) { What is this doing? Can we get some comments explaining the logic here? -Chris From clattner at apple.com Tue Dec 1 15:52:25 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 13:52:25 -0800 Subject: [llvm-commits] [llvm] r89295 - /llvm/trunk/test/CodeGen/X86/unaligned-load.ll In-Reply-To: <200911190133.nAJ1XvIY026278@zion.cs.uiuc.edu> References: <200911190133.nAJ1XvIY026278@zion.cs.uiuc.edu> Message-ID: <3DE0E765-32EF-4669-8CD9-FF3E75CF3191@apple.com> On Nov 18, 2009, at 5:33 PM, Bill Wendling wrote: > Author: void > Date: Wed Nov 18 19:33:57 2009 > New Revision: 89295 > > URL: http://llvm.org/viewvc/llvm-project?rev=89295&view=rev > Log: > Test from Dhrystone to make sure that we're not emitting an aligned > load for a > string that's aligned at 8-bytes instead of 16-bytes. Why do you need the 'not grep'? Isn't the check for movups enough? -Chris > > Added: > llvm/trunk/test/CodeGen/X86/unaligned-load.ll > > Added: llvm/trunk/test/CodeGen/X86/unaligned-load.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unaligned-load.ll?rev=89295&view=auto > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/test/CodeGen/X86/unaligned-load.ll (added) > +++ llvm/trunk/test/CodeGen/X86/unaligned-load.ll Wed Nov 18 > 19:33:57 2009 > @@ -0,0 +1,28 @@ > +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation- > model=dynamic-no-pic | not grep {movaps\t_.str3} > +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation- > model=dynamic-no-pic | FileCheck %s > + > + at .str1 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, SOME > STRING\00", align 8 > + at .str3 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, 2'ND > STRING\00", align 8 > + > +define void @func() nounwind ssp { > +entry: > + %String2Loc = alloca [31 x i8], align 1 > + br label %bb > + > +bb: > + %String2Loc9 = getelementptr inbounds [31 x i8]* %String2Loc, i64 > 0, i64 0 > + call void @llvm.memcpy.i64(i8* %String2Loc9, i8* getelementptr > inbounds ([31 x i8]* @.str3, i64 0, i64 0), i64 31, i32 1) > +; CHECK: movups _.str3 > + br label %bb > + > +return: > + ret void > +} > + > +declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, > i32) nounwind > + > +; CHECK: .align 3 > +; CHECK-NEXT: _.str1: > +; CHECK-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" > +; CHECK-NEXT: .align 3 > +; CHECK-NEXT: _.str3: > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Tue Dec 1 15:53:52 2009 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 01 Dec 2009 21:53:52 -0000 Subject: [llvm-commits] [llvm] r90260 - /llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll Message-ID: <200912012153.nB1Lrq8j031601@zion.cs.uiuc.edu> Author: grosbach Date: Tue Dec 1 15:53:51 2009 New Revision: 90260 URL: http://llvm.org/viewvc/llvm-project?rev=90260&view=rev Log: test case for IV-Users simplification loop improvement Added: llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll Added: llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll?rev=90260&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2009-12-01-LoopIVUsers.ll Tue Dec 1 15:53:51 2009 @@ -0,0 +1,128 @@ +; RUN: opt < %s -std-compile-opts | \ +; RUN: llc -mtriple=thumbv7-apple-darwin10 -mattr=+neon | FileCheck %s + +define arm_apcscc void @fred(i32 %three_by_three, i8* %in, double %dt1, i32 %x_size, i32 %y_size, i8* %bp) nounwind { +entry: +; -- The loop following the load should only use a single add-literation +; instruction. +; CHECK: ldr.64 +; CHECK: adds r{{[0-9]+}}, #1 +; CHECK-NOT: adds r{{[0-9]+}}, #1 +; CHECK: subsections_via_symbols + + + %three_by_three_addr = alloca i32 ; [#uses=2] + %in_addr = alloca i8* ; [#uses=2] + %dt_addr = alloca float ; [#uses=4] + %x_size_addr = alloca i32 ; [#uses=2] + %y_size_addr = alloca i32 ; [#uses=1] + %bp_addr = alloca i8* ; [#uses=1] + %tmp_image = alloca i8* ; [#uses=0] + %out = alloca i8* ; [#uses=1] + %cp = alloca i8* ; [#uses=0] + %dpt = alloca i8* ; [#uses=4] + %dp = alloca i8* ; [#uses=2] + %ip = alloca i8* ; [#uses=0] + %centre = alloca i32 ; [#uses=0] + %tmp = alloca i32 ; [#uses=0] + %brightness = alloca i32 ; [#uses=0] + %area = alloca i32 ; [#uses=0] + %y = alloca i32 ; [#uses=0] + %x = alloca i32 ; [#uses=2] + %j = alloca i32 ; [#uses=6] + %i = alloca i32 ; [#uses=1] + %mask_size = alloca i32 ; [#uses=5] + %increment = alloca i32 ; [#uses=1] + %n_max = alloca i32 ; [#uses=4] + %temp = alloca float ; [#uses=1] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + store i32 %three_by_three, i32* %three_by_three_addr + store i8* %in, i8** %in_addr + %dt = fptrunc double %dt1 to float ; [#uses=1] + store float %dt, float* %dt_addr + store i32 %x_size, i32* %x_size_addr + store i32 %y_size, i32* %y_size_addr + store i8* %bp, i8** %bp_addr + %0 = load i8** %in_addr, align 4 ; [#uses=1] + store i8* %0, i8** %out, align 4 + %1 = call arm_apcscc i32 (...)* @foo() nounwind ; [#uses=1] + store i32 %1, i32* %i, align 4 + %2 = load i32* %three_by_three_addr, align 4 ; [#uses=1] + %3 = icmp eq i32 %2, 0 ; [#uses=1] + br i1 %3, label %bb, label %bb2 + +bb: ; preds = %entry + %4 = load float* %dt_addr, align 4 ; [#uses=1] + %5 = fpext float %4 to double ; [#uses=1] + %6 = fmul double %5, 1.500000e+00 ; [#uses=1] + %7 = fptosi double %6 to i32 ; [#uses=1] + %8 = add nsw i32 %7, 1 ; [#uses=1] + store i32 %8, i32* %mask_size, align 4 + br label %bb3 + +bb2: ; preds = %entry + store i32 1, i32* %mask_size, align 4 + br label %bb3 + +bb3: ; preds = %bb2, %bb + %9 = load i32* %mask_size, align 4 ; [#uses=1] + %10 = mul i32 %9, 2 ; [#uses=1] + %11 = add nsw i32 %10, 1 ; [#uses=1] + store i32 %11, i32* %n_max, align 4 + %12 = load i32* %x_size_addr, align 4 ; [#uses=1] + %13 = load i32* %n_max, align 4 ; [#uses=1] + %14 = sub i32 %12, %13 ; [#uses=1] + store i32 %14, i32* %increment, align 4 + %15 = load i32* %n_max, align 4 ; [#uses=1] + %16 = load i32* %n_max, align 4 ; [#uses=1] + %17 = mul i32 %15, %16 ; [#uses=1] + %18 = call arm_apcscc noalias i8* @malloc(i32 %17) nounwind ; [#uses=1] + store i8* %18, i8** %dp, align 4 + %19 = load i8** %dp, align 4 ; [#uses=1] + store i8* %19, i8** %dpt, align 4 + %20 = load float* %dt_addr, align 4 ; [#uses=1] + %21 = load float* %dt_addr, align 4 ; [#uses=1] + %22 = fmul float %20, %21 ; [#uses=1] + %23 = fsub float -0.000000e+00, %22 ; [#uses=1] + store float %23, float* %temp, align 4 + %24 = load i32* %mask_size, align 4 ; [#uses=1] + %25 = sub i32 0, %24 ; [#uses=1] + store i32 %25, i32* %j, align 4 + br label %bb5 + +bb4: ; preds = %bb5 + %26 = load i32* %j, align 4 ; [#uses=1] + %27 = load i32* %j, align 4 ; [#uses=1] + %28 = mul i32 %26, %27 ; [#uses=1] + %29 = sitofp i32 %28 to double ; [#uses=1] + %30 = fmul double %29, 1.234000e+00 ; [#uses=1] + %31 = fptosi double %30 to i32 ; [#uses=1] + store i32 %31, i32* %x, align 4 + %32 = load i32* %x, align 4 ; [#uses=1] + %33 = trunc i32 %32 to i8 ; [#uses=1] + %34 = load i8** %dpt, align 4 ; [#uses=1] + store i8 %33, i8* %34, align 1 + %35 = load i8** %dpt, align 4 ; [#uses=1] + %36 = getelementptr inbounds i8* %35, i64 1 ; [#uses=1] + store i8* %36, i8** %dpt, align 4 + %37 = load i32* %j, align 4 ; [#uses=1] + %38 = add nsw i32 %37, 1 ; [#uses=1] + store i32 %38, i32* %j, align 4 + br label %bb5 + +bb5: ; preds = %bb4, %bb3 + %39 = load i32* %j, align 4 ; [#uses=1] + %40 = load i32* %mask_size, align 4 ; [#uses=1] + %41 = icmp sle i32 %39, %40 ; [#uses=1] + br i1 %41, label %bb4, label %bb6 + +bb6: ; preds = %bb5 + br label %return + +return: ; preds = %bb6 + ret void +} + +declare arm_apcscc i32 @foo(...) + +declare arm_apcscc noalias i8* @malloc(i32) nounwind From clattner at apple.com Tue Dec 1 16:04:43 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 14:04:43 -0800 Subject: [llvm-commits] [llvm] r89245 - in /llvm/trunk/utils/TableGen: OptParserEmitter.cpp OptParserEmitter.h TableGen.cpp In-Reply-To: <200911182129.nAILTp1m015264@zion.cs.uiuc.edu> References: <200911182129.nAILTp1m015264@zion.cs.uiuc.edu> Message-ID: <0919AD5E-A737-4E1E-89C0-0686D32695AF@apple.com> On Nov 18, 2009, at 1:29 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Wed Nov 18 15:29:51 2009 > New Revision: 89245 > > URL: http://llvm.org/viewvc/llvm-project?rev=89245&view=rev > Log: > TableGen: Add initial backend for clang Driver's option parsing. Cool. > +void OptParserEmitter::run(raw_ostream &OS) { > + // Get the option groups and options. > + const std::vector &Groups = > + Records.getAllDerivedDefinitions("OptionGroup"); > + std::vector Opts = > Records.getAllDerivedDefinitions("Option"); > + > + if (GenDefs) { > + OS << "\ > +//=== TableGen'erated File - Option Parsing Definitions ---------*- > C++ -*-===//\n \ Please use TableGenBackend::EmitSourceFileHeader instead of duplicating it. One thing I've learned in my time hacking tblgen is that it is probably best to emit one .inc file for a given purpose, instead of emitting one for the ".h" and one for the ".cpp". If you emit something like: #ifdef GET_HEADER_CODE ... #endif #ifdef GET_FILE_CODE ... #endif then #include it into the right contexts with the right #defines set. -Chris From clattner at apple.com Tue Dec 1 16:15:35 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 14:15:35 -0800 Subject: [llvm-commits] [llvm] r89176 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp In-Reply-To: <200911180103.nAI13usJ018941@zion.cs.uiuc.edu> References: <200911180103.nAI13usJ018941@zion.cs.uiuc.edu> Message-ID: <1A1AE227-CA98-41BB-864B-003A9B9EA0CD@apple.com> On Nov 17, 2009, at 5:03 PM, Bill Wendling wrote: > Author: void > Date: Tue Nov 17 19:03:56 2009 > New Revision: 89176 > > URL: http://llvm.org/viewvc/llvm-project?rev=89176&view=rev > Log: > The llvm-gcc front-end and the pass manager use two separate > TargetData objects. > This is probably not confined to *just* these two things. Hi Bill, This commit message doesn't really make sense to me at all. I would have expected it to be something like "Convert TargetData to use an AbstractTypesUser so that it doesn't have dangling pointers when abstract types get resolved". > +++ llvm/trunk/include/llvm/Target/TargetData.h Tue Nov 17 19:03:56 > 2009 > @@ -30,6 +30,7 @@ > class IntegerType; > class StructType; > class StructLayout; > +class StructLayoutMap; Why did you publish the StructLayoutMap type? If you keep it a void*, you can put it in an anonymous namespace in the .cpp file. > +++ llvm/trunk/lib/Target/TargetData.cpp Tue Nov 17 19:03:56 2009 > @@ -323,37 +323,130 @@ > : Alignments[BestMatchIdx].PrefAlign; > } > > -typedef DenseMapLayoutInfoTy; > +typedef DenseMap LayoutInfoTy; > > +namespace llvm { > + > +class StructLayoutMap : public AbstractTypeUser { > + LayoutInfoTy LayoutInfo; > + > + /// refineAbstractType - The callback method invoked when an > abstract type is > + /// resolved to another type. An object must override this > method to update > + /// its internal state to reference NewType instead of OldType. > + /// > + virtual void refineAbstractType(const DerivedType *OldTy, > + const Type *) { > + const StructType *STy = dyn_cast(OldTy); > + if (!STy) { > + OldTy->removeAbstractTypeUser(this); > + return; This should be an error, so you should assert on "STy != 0". The only types this AbstractTypeUser tracks are structs. > + } > + > + StructLayout *SL = LayoutInfo[STy]; > + if (SL) { > + SL->~StructLayout(); > + free(SL); > + LayoutInfo[STy] = NULL; This should use find() instead of [] for two reasons. 1. STy *must* be in the densemap, so this should be an assert that the iterator != end. 2. You don't want to set the entry for STy to null, you want to delete the entry in the Densemap with erase(iterator). > + /// typeBecameConcrete - The other case which AbstractTypeUsers > must be aware > + /// of is when a type makes the transition from being abstract > (where it has > + /// clients on its AbstractTypeUsers list) to concrete (where it > does not). > + /// This method notifies ATU's when this occurs for a type. > + /// > + virtual void typeBecameConcrete(const DerivedType *AbsTy) { Same comments as refineAbstractType. > + bool insert(const Type *Ty) { > + if (Ty->isAbstract()) > + Ty->addAbstractTypeUser(this); > + return true; > + } Just inline this into its one caller. > +public: > + virtual ~StructLayoutMap() { > + // Remove any layouts. > + for (LayoutInfoTy::iterator > + I = LayoutInfo.begin(), E = LayoutInfo.end(); I != E; ++I) > + if (StructLayout *SL = I->second) { > + SL->~StructLayout(); > + free(SL); > + } This needs to unregister as listeners from the abstract types! > + } > + > + inline LayoutInfoTy::iterator begin() { > + return LayoutInfo.begin(); > + } > + inline LayoutInfoTy::iterator end() { > + return LayoutInfo.end(); > + } > + inline LayoutInfoTy::const_iterator begin() const { > + return LayoutInfo.begin(); > + } > + inline LayoutInfoTy::const_iterator end() const { > + return LayoutInfo.end(); > + } > + > + LayoutInfoTy::iterator find(const StructType *&Val) { > + return LayoutInfo.find(Val); > + } > + LayoutInfoTy::const_iterator find(const StructType *&Val) const { > + return LayoutInfo.find(Val); > + } > + > + bool erase(const StructType *&Val) { > + return LayoutInfo.erase(Val); > + } > + bool erase(LayoutInfoTy::iterator I) { > + return LayoutInfo.erase(I); > + } This stuff is all dead. Please remove it. > + > + StructLayout *&operator[](const Type *Key) { Key should be declared as 'const StructType *'. > + const StructType *STy = dyn_cast(Key); > + assert(STy && "Trying to access the struct layout map with a > non-struct!"); which allows you to eliminate this. > + insert(STy); > + return LayoutInfo[STy]; Don't do a redundant map lookup after 'insert'. -Chris From evan.cheng at apple.com Tue Dec 1 16:25:01 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 01 Dec 2009 22:25:01 -0000 Subject: [llvm-commits] [llvm] r90269 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll Message-ID: <200912012225.nB1MP1Yi032712@zion.cs.uiuc.edu> Author: evancheng Date: Tue Dec 1 16:25:00 2009 New Revision: 90269 URL: http://llvm.org/viewvc/llvm-project?rev=90269&view=rev Log: Fix PR5391: support early clobber physical register def tied with a use (ewwww) - A valno should be set HasRedefByEC if there is an early clobber def in the middle of its live ranges. It should not be set if the def of the valno is defined by an early clobber. - If a physical register def is tied to an use and it's an early clobber, it just means the HasRedefByEC is set since it's still one continuous live range. - Add a couple of missing checks for HasRedefByEC in the coalescer. In general, it should not coalesce a vr with a physical register if the physical register has a early clobber def somewhere. This is overly conservative but that's the price for using such a nasty inline asm "feature". Added: llvm/trunk/test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=90269&r1=90268&r2=90269&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Dec 1 16:25:00 2009 @@ -374,8 +374,6 @@ // Value#0 is now defined by the 2-addr instruction. OldValNo->def = RedefIndex; OldValNo->setCopy(0); - if (MO.isEarlyClobber()) - OldValNo->setHasRedefByEC(true); // Add the new live interval which replaces the range for the input copy. LiveRange LR(DefIndex, RedefIndex, ValNo); @@ -513,8 +511,6 @@ if (mi->isRegTiedToUseOperand(DefIdx)) { // Two-address instruction. end = baseIndex.getDefIndex(); - assert(!mi->getOperand(DefIdx).isEarlyClobber() && - "Two address instruction is an early clobber?"); } else { // Another instruction redefines the register before it is ever read. // Then the register is essentially dead at the instruction that defines Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=90269&r1=90268&r2=90269&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Tue Dec 1 16:25:00 2009 @@ -1938,6 +1938,10 @@ if (Overlaps) { // If we haven't already recorded that this value # is safe, check it. if (!InVector(LHSIt->valno, EliminatedLHSVals)) { + // If it's re-defined by an early clobber somewhere in the live range, + // then conservatively abort coalescing. + if (LHSIt->valno->hasRedefByEC()) + return false; // Copy from the RHS? if (!RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) return false; // Nope, bail out. @@ -1977,6 +1981,10 @@ // if coalescing succeeds. Just skip the liverange. if (++LHSIt == LHSEnd) break; } else { + // If it's re-defined by an early clobber somewhere in the live range, + // then conservatively abort coalescing. + if (LHSIt->valno->hasRedefByEC()) + return false; // Otherwise, if this is a copy from the RHS, mark it as being merged // in. if (RangeIsDefinedByCopyFromReg(LHS, LHSIt, RHS.reg)) { @@ -2316,6 +2324,10 @@ if (LHSValNoAssignments[I->valno->id] != RHSValNoAssignments[J->valno->id]) return false; + // If it's re-defined by an early clobber somewhere in the live range, + // then conservatively abort coalescing. + if (NewVNInfo[LHSValNoAssignments[I->valno->id]]->hasRedefByEC()) + return false; } if (I->end < J->end) { Added: llvm/trunk/test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll?rev=90269&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll (added) +++ llvm/trunk/test/CodeGen/X86/2009-12-01-EarlyClobberBug.ll Tue Dec 1 16:25:00 2009 @@ -0,0 +1,38 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s +; pr5391 + +define void @t() nounwind ssp { +entry: +; CHECK: t: +; CHECK: movl %ecx, %eax +; CHECK: %eax = foo (%eax, %ecx) + %b = alloca i32 ; [#uses=2] + %a = alloca i32 ; [#uses=1] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + %0 = load i32* %b, align 4 ; [#uses=1] + %1 = load i32* %b, align 4 ; [#uses=1] + %asmtmp = call i32 asm "$0 = foo ($1, $2)", "=&{ax},%0,r,~{dirflag},~{fpsr},~{flags}"(i32 %0, i32 %1) nounwind ; [#uses=1] + store i32 %asmtmp, i32* %a + br label %return + +return: ; preds = %entry + ret void +} + +define void @t2() nounwind ssp { +entry: +; CHECK: t2: +; CHECK: movl %eax, %ecx +; CHECK: %ecx = foo (%ecx, %eax) + %b = alloca i32 ; [#uses=2] + %a = alloca i32 ; [#uses=1] + %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] + %0 = load i32* %b, align 4 ; [#uses=1] + %1 = load i32* %b, align 4 ; [#uses=1] + %asmtmp = call i32 asm "$0 = foo ($1, $2)", "=&r,%0,r,~{dirflag},~{fpsr},~{flags}"(i32 %0, i32 %1) nounwind ; [#uses=1] + store i32 %asmtmp, i32* %a + br label %return + +return: ; preds = %entry + ret void +} From echristo at apple.com Tue Dec 1 16:28:42 2009 From: echristo at apple.com (Eric Christopher) Date: Tue, 01 Dec 2009 22:28:42 -0000 Subject: [llvm-commits] [llvm] r90271 - /llvm/trunk/docs/LangRef.html Message-ID: <200912012228.nB1MSgja000395@zion.cs.uiuc.edu> Author: echristo Date: Tue Dec 1 16:28:41 2009 New Revision: 90271 URL: http://llvm.org/viewvc/llvm-project?rev=90271&view=rev Log: Update per Bill's comments. Work in progress. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=90271&r1=90270&r2=90271&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Tue Dec 1 16:28:41 2009 @@ -7263,22 +7263,22 @@
    Overview:

    The llvm.objectsize intrinsic returns the constant number of bytes - from ptr to the end of the object ptr points to if it + from ptr to the end of the object ptr points to, if it can deduce this at compile time. If there are any side-effects in evaluating the argument or it cannot deduce which objects ptr points to at compile - time the intrinsic returns (size_t) -1 for type 0 - or 1 and (size_t) 0 for type 2 or 3.

    + time, the intrinsic returns i32/i64 -1 for type 0 + or 1 and i32/i64 0 for type 2 or 3.

    Arguments:

    The llvm.objectsize intrinsic takes two arguments. The first - argument is a pointer to the object ptr and an integer type. - type is an integer ranging from 0 to 3. The lsb corresponds to - a return value based on whole objects, the second bit whether or not we - return the maximum or minimum remaining bytes computed.

    + argument is a pointer to the object ptr. The second argument + is an integer type which ranges from 0 to 3. The first bit + corresponds to a return value based on whole objects, and the second bit + whether or not we return the maximum or minimum remaining bytes computed.

    Semantics:

    The llvm.objectsize intrinsic is lowered to either a constant - representing the size of the object concerned or (size_t) -1 if + representing the size of the object concerned or i32/i64 -1 if it cannot be determined at compile time.

    From sabre at nondot.org Tue Dec 1 16:51:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Tue, 01 Dec 2009 22:51:42 -0000 Subject: [llvm-commits] [llvm] r90275 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <200912012251.nB1MpgqP001238@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 16:51:41 2009 New Revision: 90275 URL: http://llvm.org/viewvc/llvm-project?rev=90275&view=rev Log: return more useful error messages by using strerror to format errno instead of returning an ambiguous reason. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=90275&r1=90274&r2=90275&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Dec 1 16:51:41 2009 @@ -176,7 +176,7 @@ #endif int FD = ::open(Filename.str().c_str(), O_RDONLY|OpenFlags); if (FD == -1) { - if (ErrStr) *ErrStr = "could not open file"; + if (ErrStr) *ErrStr = strerror(errno); return 0; } @@ -186,7 +186,7 @@ struct stat FileInfo; // TODO: This should use fstat64 when available. if (fstat(FD, &FileInfo) == -1) { - if (ErrStr) *ErrStr = "could not get file length"; + if (ErrStr) *ErrStr = strerror(errno); ::close(FD); return 0; } @@ -230,8 +230,8 @@ // try again } else { // error reading. + if (ErrStr) *ErrStr = strerror(errno); close(FD); - if (ErrStr) *ErrStr = "error reading file data"; return 0; } } From clattner at apple.com Tue Dec 1 17:04:15 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 15:04:15 -0800 Subject: [llvm-commits] [llvm] r90271 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200912012228.nB1MSgja000395@zion.cs.uiuc.edu> References: <200912012228.nB1MSgja000395@zion.cs.uiuc.edu> Message-ID: On Dec 1, 2009, at 2:28 PM, Eric Christopher wrote: > Author: echristo > Date: Tue Dec 1 16:28:41 2009 > New Revision: 90271 > > URL: http://llvm.org/viewvc/llvm-project?rev=90271&view=rev > Log: > Update per Bill's comments. Work in progress. Some more thoughts: "declare i32 @llvm.objectsize.i32( i8* , i32 ) declare i64 @llvm.objectsize.i64( i8* , i32 )" These intrinsics allow any integer return type. You should mention this instead of referring to i32/i64. "If there are any side-effects in evaluating the argument" This concept doesn't exist in LLVM IR. "... for type 0 or 1 and i32/i64 0 for type 2 or 3." Referring to types before you explain what they aren't doesn't make sense. I'd move this down to the 'semantics' section out of overview. Make overview a higher level description talking about how the goal and use of the intrinsic. This section would also be a good place to describe what an 'object' is, which is not a term used in the rest of langref. "The first bit corresponds to a return value based on whole objects, and the second bit whether or not we return the maximum or minimum remaining bytes computed." This doesn't make a lot of sense to me either, please turn this into a table describing what each value is :) -Chris > +++ llvm/trunk/docs/LangRef.html Tue Dec 1 16:28:41 2009 > @@ -7263,22 +7263,22 @@ > >
    Overview:
    >

    The llvm.objectsize intrinsic returns the constant > number of bytes > - from ptr to the end of the object ptr points > to if it > + from ptr to the end of the object ptr points > to, if it > can deduce this at compile time. If there are any side-effects > in evaluating > the argument or it cannot deduce which objects ptr > points to at compile > - time the intrinsic returns (size_t) -1 for type tt> 0 > - or 1 and (size_t) 0 for type 2 or 3.

    > + time, the intrinsic returns i32/i64 -1 for type tt> 0 > + or 1 and i32/i64 0 for type 2 or 3.

    > >
    Arguments:
    >

    The llvm.objectsize intrinsic takes two arguments. The > first > - argument is a pointer to the object ptr and an integer > type. > - type is an integer ranging from 0 to 3. The lsb > corresponds to > - a return value based on whole objects, the second bit whether or > not we > - return the maximum or minimum remaining bytes computed.

    > + argument is a pointer to the object ptr. The second > argument > + is an integer type which ranges from 0 to 3. The first > bit > + corresponds to a return value based on whole objects, and the > second bit > + whether or not we return the maximum or minimum remaining bytes > computed.

    > >
    Semantics:
    >

    The llvm.objectsize intrinsic is lowered to either a > constant > - representing the size of the object concerned or (size_t) > -1 if > + representing the size of the object concerned or i32/i64 -1 tt> if > it cannot be determined at compile time.

    > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From espindola at google.com Tue Dec 1 17:06:42 2009 From: espindola at google.com (Rafael Espindola) Date: Tue, 1 Dec 2009 18:06:42 -0500 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> Message-ID: <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> > Instead, I think the ARM backend needs to handle "byval" arguments. ?That is how both x86 and ppc handle the testcase in pr5406. ?I don't think it is possible to fix the PassInIntegerRegisters code to correctly handle aggregates that are not a multiple of the register size, at least not without much more extensive changes. ?You either end up accessing memory past the end of the argument (as Dale pointed out earlier) or splitting the tail into pieces, which is wrong depending on whether each piece is in a separate register or in memory. Why do you think so? Do you have an example where the new patch fails? The byval argument was introduced to handle cases in the ELF x86_64 abi where it is not possible to map how a struct is passed to an equivalent way of passing primitive types. It also had some additional benefits in the end. Do you have a case in the ARM ABI where we cannot map a struct passing to an equivalent way of passing primitive types? If so, I can try to implement byval for ARM, but it will take me some time to get to it. If not, I would suggest doing the quick fix first. Cheers, -- Rafael ?vila de Esp?ndola From dpatel at apple.com Tue Dec 1 17:07:59 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 23:07:59 -0000 Subject: [llvm-commits] [llvm] r90281 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200912012307.nB1N7xBT001828@zion.cs.uiuc.edu> Author: dpatel Date: Tue Dec 1 17:07:59 2009 New Revision: 90281 URL: http://llvm.org/viewvc/llvm-project?rev=90281&view=rev Log: Reuse existing subprogram DIE. 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=90281&r1=90280&r2=90281&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Dec 1 17:07:59 2009 @@ -1087,7 +1087,11 @@ const DISubprogram &SP, bool IsConstructor, bool IsInlined) { - DIE *SPDie = new DIE(dwarf::DW_TAG_subprogram); + DIE *SPDie = ModuleCU->getDIE(SP.getNode()); + if (SPDie) + return SPDie; + + SPDie = new DIE(dwarf::DW_TAG_subprogram); addString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, SP.getName()); StringRef LinkageName = SP.getLinkageName(); @@ -1669,7 +1673,8 @@ ModuleCU->insertDIE(N, SubprogramDie); // Add to context owner. - ModuleCU->getCUDie()->addChild(SubprogramDie); + if (SP.getContext().getNode() == SP.getCompileUnit().getNode()) + ModuleCU->getCUDie()->addChild(SubprogramDie); // Expose as global. ModuleCU->addGlobal(SP.getName(), SubprogramDie); From dpatel at apple.com Tue Dec 1 17:09:02 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 23:09:02 -0000 Subject: [llvm-commits] [llvm] r90282 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <200912012309.nB1N93I7001870@zion.cs.uiuc.edu> Author: dpatel Date: Tue Dec 1 17:09:02 2009 New Revision: 90282 URL: http://llvm.org/viewvc/llvm-project?rev=90282&view=rev Log: Add utility routine to create subprogram definition entry from subprogram declaration entry. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=90282&r1=90281&r2=90282&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Dec 1 17:09:02 2009 @@ -567,6 +567,10 @@ DIType Type, bool isLocalToUnit, bool isDefinition); + /// CreateSubprogramDefinition - Create new subprogram descriptor for the + /// given declaration. + DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration); + /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable CreateGlobalVariable(DIDescriptor Context, StringRef Name, Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=90282&r1=90281&r2=90282&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Dec 1 17:09:02 2009 @@ -884,6 +884,29 @@ return DISubprogram(MDNode::get(VMContext, &Elts[0], 11)); } +/// CreateSubprogramDefinition - Create new subprogram descriptor for the +/// given declaration. +DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) { + if (SPDeclaration.isDefinition()) + return DISubprogram(SPDeclaration.getNode()); + + MDNode *DeclNode = SPDeclaration.getNode(); + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_subprogram), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + DeclNode->getElement(2), // Context + DeclNode->getElement(3), // Name + DeclNode->getElement(4), // DisplayName + DeclNode->getElement(5), // LinkageName + DeclNode->getElement(6), // CompileUnit + DeclNode->getElement(7), // LineNo + DeclNode->getElement(8), // Type + DeclNode->getElement(9), // isLocalToUnit + ConstantInt::get(Type::getInt1Ty(VMContext), true) + }; + return DISubprogram(MDNode::get(VMContext, &Elts[0], 11)); +} + /// CreateGlobalVariable - Create a new descriptor for the specified global. DIGlobalVariable DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, From dpatel at apple.com Tue Dec 1 17:27:50 2009 From: dpatel at apple.com (Devang Patel) Date: Tue, 01 Dec 2009 23:27:50 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90284 - in /llvm-gcc-4.2/trunk/gcc: llvm-debug.cpp llvm-debug.h Message-ID: <200912012327.nB1NRoeO002616@zion.cs.uiuc.edu> Author: dpatel Date: Tue Dec 1 17:27:50 2009 New Revision: 90284 URL: http://llvm.org/viewvc/llvm-project?rev=90284&view=rev Log: Reuse existing DISubprograms. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp llvm-gcc-4.2/trunk/gcc/llvm-debug.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=90284&r1=90283&r2=90284&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Dec 1 17:27:50 2009 @@ -232,6 +232,22 @@ /// "llvm.dbg.func.start." void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn, BasicBlock *CurBB) { + + DIType FNType = getOrCreateType(TREE_TYPE(FnDecl)); + + std::map::iterator I = SPCache.find(FnDecl); + if (I != SPCache.end()) { + DISubprogram SPDecl(cast(I->second)); + DISubprogram SP = + DebugFactory.CreateSubprogramDefinition(SPDecl); + SPDecl.getNode()->replaceAllUsesWith(SP.getNode()); + + // Push function on region stack. + RegionStack.push_back(WeakVH(SP.getNode())); + RegionMap[FnDecl] = WeakVH(SP.getNode()); + return; + } + // Gather location information. expanded_location Loc = GetNodeLocation(FnDecl, false); StringRef LinkageName = getLinkageName(FnDecl); @@ -246,10 +262,12 @@ lang_hooks.dwarf_name(FnDecl, 0), LinkageName, getOrCreateCompileUnit(Loc.file), lineno, - getOrCreateType(TREE_TYPE(FnDecl)), + FNType, Fn->hasInternalLinkage(), true /*definition*/); + SPCache[FnDecl] = WeakVH(SP.getNode()); + // Push function on region stack. RegionStack.push_back(WeakVH(SP.getNode())); RegionMap[FnDecl] = WeakVH(SP.getNode()); @@ -766,18 +784,23 @@ // In C++, TEMPLATE_DECLs are marked Ignored, and should be. if (DECL_P (Member) && DECL_IGNORED_P (Member)) continue; - // Get the location of the member. - expanded_location MemLoc = GetNodeLocation(Member, false); - - const char *MemberName = lang_hooks.dwarf_name(Member, 0); - StringRef LinkageName = getLinkageName(Member); - DIType SPTy = getOrCreateType(TREE_TYPE(Member)); - DISubprogram SP = - DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName, - LinkageName, - getOrCreateCompileUnit(MemLoc.file), - MemLoc.line, SPTy, false, false); - EltTys.push_back(SP); + std::map::iterator I = SPCache.find(Member); + if (I != SPCache.end()) + EltTys.push_back(DISubprogram(cast(I->second))); + else { + // Get the location of the member. + expanded_location MemLoc = GetNodeLocation(Member, false); + const char *MemberName = lang_hooks.dwarf_name(Member, 0); + StringRef LinkageName = getLinkageName(Member); + DIType SPTy = getOrCreateType(TREE_TYPE(Member)); + DISubprogram SP = + DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName, + LinkageName, + getOrCreateCompileUnit(MemLoc.file), + MemLoc.line, SPTy, false, false); + EltTys.push_back(SP); + SPCache[Member] = WeakVH(SP.getNode()); + } } llvm::DIArray Elements = Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=90284&r1=90283&r2=90284&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Tue Dec 1 17:27:50 2009 @@ -65,6 +65,9 @@ std::map TypeCache; // Cache of previously constructed // Types. + std::map SPCache; + // Cache of previously constructed + // Subprograms. SmallVector RegionStack; // Stack to track declarative scopes. From bob.wilson at apple.com Tue Dec 1 17:27:01 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 1 Dec 2009 15:27:01 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> Message-ID: On Dec 1, 2009, at 3:06 PM, Rafael Espindola wrote: >> Instead, I think the ARM backend needs to handle "byval" arguments. That is how both x86 and ppc handle the testcase in pr5406. I don't think it is possible to fix the PassInIntegerRegisters code to correctly handle aggregates that are not a multiple of the register size, at least not without much more extensive changes. You either end up accessing memory past the end of the argument (as Dale pointed out earlier) or splitting the tail into pieces, which is wrong depending on whether each piece is in a separate register or in memory. > > Why do you think so? Do you have an example where the new patch fails? No, I don't know that it fails. But neither do I know that it is OK, so you'll at least need to get someone else to review the patch. Dale has dealt with this code quite a lot and last time we put this patch in, he objected that it might be unsafe by causing accesses past the end of an aggregate. At the time, I replied by citing a comment in the x86-64 code suggesting that gcc does the same thing, but after looking at it more closely, I think that comment was referring to a slightly different case. > > The byval argument was introduced to handle cases in the ELF x86_64 > abi where it is not possible to map how a struct is passed to an > equivalent way of passing primitive types. It also had some additional > benefits in the end. Well, I don't know the history, but "byval" is essentially the default for passing structures on both ppc and x86-32. Without knowing otherwise, I'm inclined to follow the same approach for ARM. > > Do you have a case in the ARM ABI where we cannot map a struct passing > to an equivalent way of passing primitive types? If so, I can try to > implement byval for ARM, but it will take me some time to get to it. > If not, I would suggest doing the quick fix first. I don't have any testcases that are better than the one for pr5406. I'm not sure if it is safe to access a 24-bit struct as an i32. From wangmp at apple.com Tue Dec 1 23:00:00 2009 From: wangmp at apple.com (Mon P Wang) Date: Wed, 02 Dec 2009 05:00:00 -0000 Subject: [llvm-commits] [llvm] r90290 - in /llvm/trunk: lib/Analysis/ValueTracking.cpp test/Transforms/InstCombine/sext-2.ll Message-ID: <200912020500.nB2500Zk013010@zion.cs.uiuc.edu> Author: wangmp Date: Tue Dec 1 22:59:58 2009 New Revision: 90290 URL: http://llvm.org/viewvc/llvm-project?rev=90290&view=rev Log: Fixed an assertion failure for tracking sext of a vector of integers Added: llvm/trunk/test/Transforms/InstCombine/sext-2.ll Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=90290&r1=90289&r2=90290&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue Dec 1 22:59:58 2009 @@ -659,7 +659,7 @@ switch (Operator::getOpcode(V)) { default: break; case Instruction::SExt: - Tmp = TyBits-cast(U->getOperand(0)->getType())->getBitWidth(); + Tmp = TyBits - U->getOperand(0)->getType()->getScalarSizeInBits(); return ComputeNumSignBits(U->getOperand(0), TD, Depth+1) + Tmp; case Instruction::AShr: Added: llvm/trunk/test/Transforms/InstCombine/sext-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext-2.ll?rev=90290&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext-2.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/sext-2.ll Tue Dec 1 22:59:58 2009 @@ -0,0 +1,14 @@ +; Checks to see that instcombine can handle a sign extension of i1 + +; RUN: opt < %s -instcombine -S | FileCheck %s + +define void @test(<2 x i16> %srcA, <2 x i16> %srcB, <2 x i16>* %dst) nounwind { +entry: +; CHECK-NOT: tmask +; CHECK: ret + %cmp = icmp eq <2 x i16> %srcB, %srcA; + %sext = sext <2 x i1> %cmp to <2 x i16>; + %tmask = ashr <2 x i16> %sext, ; + store <2 x i16> %tmask, <2 x i16>* %dst; + ret void +} From sabre at nondot.org Tue Dec 1 23:32:16 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 05:32:16 -0000 Subject: [llvm-commits] [llvm] r90291 - /llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Message-ID: <200912020532.nB25WGEI013995@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 23:32:16 2009 New Revision: 90291 URL: http://llvm.org/viewvc/llvm-project?rev=90291&view=rev Log: filecheckize Modified: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Modified: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext-misc.ll?rev=90291&r1=90290&r2=90291&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext-misc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Tue Dec 1 23:32:16 2009 @@ -1,4 +1,4 @@ -; RUN: opt < %s -instcombine -S | not grep sext +; RUN: opt < %s -instcombine -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" @@ -6,53 +6,82 @@ declare i32 @llvm.ctlz.i32(i32) declare i32 @llvm.cttz.i32(i32) -define i64 @foo(i32 %x) { +define i64 @test1(i32 %x) { %t = call i32 @llvm.ctpop.i32(i32 %x) %s = sext i32 %t to i64 ret i64 %s + +; CHECK: @test1 +; CHECK: zext i32 %t } -define i64 @boo(i32 %x) { + +define i64 @test2(i32 %x) { %t = call i32 @llvm.ctlz.i32(i32 %x) %s = sext i32 %t to i64 ret i64 %s + +; CHECK: @test2 +; CHECK: zext i32 %t } -define i64 @zoo(i32 %x) { + +define i64 @test3(i32 %x) { %t = call i32 @llvm.cttz.i32(i32 %x) %s = sext i32 %t to i64 ret i64 %s + +; CHECK: @test3 +; CHECK: zext i32 %t } -define i64 @coo(i32 %x) { + +define i64 @test4(i32 %x) { %t = udiv i32 %x, 3 %s = sext i32 %t to i64 ret i64 %s + +; CHECK: @test4 +; CHECK: zext i32 %t } -define i64 @moo(i32 %x) { + +define i64 @test5(i32 %x) { %t = urem i32 %x, 30000 %s = sext i32 %t to i64 ret i64 %s +; CHECK: @test5 +; CHECK: zext i32 %t } -define i64 @yoo(i32 %x) { + +define i64 @test6(i32 %x) { %u = lshr i32 %x, 3 %t = mul i32 %u, 3 %s = sext i32 %t to i64 ret i64 %s +; CHECK: @test6 +; CHECK: zext i32 %t } -define i64 @voo(i32 %x) { + +define i64 @test7(i32 %x) { %t = and i32 %x, 511 %u = sub i32 20000, %t %s = sext i32 %u to i64 ret i64 %s +; CHECK: @test7 +; CHECK: zext i32 %u to i64 } -define i32 @woo(i8 %a, i32 %f, i1 %p, i32* %z) { + +define i32 @test8(i8 %a, i32 %f, i1 %p, i32* %z) { %d = lshr i32 %f, 24 %e = select i1 %p, i32 %d, i32 0 %s = trunc i32 %e to i16 %n = sext i16 %s to i32 ret i32 %n +; CHECK: @test8 +; CHECK: %d = lshr i32 %f, 24 +; CHECK: %n = select i1 %p, i32 %d, i32 0 +; CHECK: ret i32 %n } ; rdar://6013816 -define i16 @test(i16 %t, i1 %cond) nounwind { +define i16 @test9(i16 %t, i1 %cond) nounwind { entry: br i1 %cond, label %T, label %F T: @@ -63,15 +92,25 @@ %V = phi i32 [%t2, %T], [42, %entry] %W = trunc i32 %V to i16 ret i16 %W +; CHECK: @test9 +; CHECK: T: +; CHECK-NEXT: br label %F +; CHECK: F: +; CHECK-NEXT: phi i16 +; CHECK-NEXT: ret i16 } ; PR2638 -define i32 @test2(i32 %i) nounwind { +define i32 @test10(i32 %i) nounwind { entry: - %tmp12 = trunc i32 %i to i8 ; [#uses=1] - %tmp16 = shl i8 %tmp12, 6 ; [#uses=1] - %a = ashr i8 %tmp16, 6 ; [#uses=1] - %b = sext i8 %a to i32 ; [#uses=1] + %tmp12 = trunc i32 %i to i8 + %tmp16 = shl i8 %tmp12, 6 + %a = ashr i8 %tmp16, 6 + %b = sext i8 %a to i32 ret i32 %b +; CHECK: @test10 +; CHECK: shl i32 %i, 30 +; CHECK-NEXT: ashr i32 +; CHECK-NEXT: ret i32 } From sabre at nondot.org Tue Dec 1 23:32:33 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 05:32:33 -0000 Subject: [llvm-commits] [llvm] r90292 - in /llvm/trunk/test/Transforms/InstCombine: sext-misc.ll sext.ll Message-ID: <200912020532.nB25WXuH014015@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 23:32:33 2009 New Revision: 90292 URL: http://llvm.org/viewvc/llvm-project?rev=90292&view=rev Log: rename test Added: llvm/trunk/test/Transforms/InstCombine/sext.ll - copied unchanged from r90291, llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Removed: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll Removed: llvm/trunk/test/Transforms/InstCombine/sext-misc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext-misc.ll?rev=90291&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext-misc.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sext-misc.ll (removed) @@ -1,116 +0,0 @@ -; RUN: opt < %s -instcombine -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" - -declare i32 @llvm.ctpop.i32(i32) -declare i32 @llvm.ctlz.i32(i32) -declare i32 @llvm.cttz.i32(i32) - -define i64 @test1(i32 %x) { - %t = call i32 @llvm.ctpop.i32(i32 %x) - %s = sext i32 %t to i64 - ret i64 %s - -; CHECK: @test1 -; CHECK: zext i32 %t -} - -define i64 @test2(i32 %x) { - %t = call i32 @llvm.ctlz.i32(i32 %x) - %s = sext i32 %t to i64 - ret i64 %s - -; CHECK: @test2 -; CHECK: zext i32 %t -} - -define i64 @test3(i32 %x) { - %t = call i32 @llvm.cttz.i32(i32 %x) - %s = sext i32 %t to i64 - ret i64 %s - -; CHECK: @test3 -; CHECK: zext i32 %t -} - -define i64 @test4(i32 %x) { - %t = udiv i32 %x, 3 - %s = sext i32 %t to i64 - ret i64 %s - -; CHECK: @test4 -; CHECK: zext i32 %t -} - -define i64 @test5(i32 %x) { - %t = urem i32 %x, 30000 - %s = sext i32 %t to i64 - ret i64 %s -; CHECK: @test5 -; CHECK: zext i32 %t -} - -define i64 @test6(i32 %x) { - %u = lshr i32 %x, 3 - %t = mul i32 %u, 3 - %s = sext i32 %t to i64 - ret i64 %s -; CHECK: @test6 -; CHECK: zext i32 %t -} - -define i64 @test7(i32 %x) { - %t = and i32 %x, 511 - %u = sub i32 20000, %t - %s = sext i32 %u to i64 - ret i64 %s -; CHECK: @test7 -; CHECK: zext i32 %u to i64 -} - -define i32 @test8(i8 %a, i32 %f, i1 %p, i32* %z) { - %d = lshr i32 %f, 24 - %e = select i1 %p, i32 %d, i32 0 - %s = trunc i32 %e to i16 - %n = sext i16 %s to i32 - ret i32 %n -; CHECK: @test8 -; CHECK: %d = lshr i32 %f, 24 -; CHECK: %n = select i1 %p, i32 %d, i32 0 -; CHECK: ret i32 %n -} - -; rdar://6013816 -define i16 @test9(i16 %t, i1 %cond) nounwind { -entry: - br i1 %cond, label %T, label %F -T: - %t2 = sext i16 %t to i32 - br label %F - -F: - %V = phi i32 [%t2, %T], [42, %entry] - %W = trunc i32 %V to i16 - ret i16 %W -; CHECK: @test9 -; CHECK: T: -; CHECK-NEXT: br label %F -; CHECK: F: -; CHECK-NEXT: phi i16 -; CHECK-NEXT: ret i16 -} - -; PR2638 -define i32 @test10(i32 %i) nounwind { -entry: - %tmp12 = trunc i32 %i to i8 - %tmp16 = shl i8 %tmp12, 6 - %a = ashr i8 %tmp16, 6 - %b = sext i8 %a to i32 - ret i32 %b -; CHECK: @test10 -; CHECK: shl i32 %i, 30 -; CHECK-NEXT: ashr i32 -; CHECK-NEXT: ret i32 -} - From sabre at nondot.org Tue Dec 1 23:34:35 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 05:34:35 -0000 Subject: [llvm-commits] [llvm] r90293 - in /llvm/trunk/test/Transforms/InstCombine: sext-2.ll sext.ll Message-ID: <200912020534.nB25YZOr014086@zion.cs.uiuc.edu> Author: lattner Date: Tue Dec 1 23:34:35 2009 New Revision: 90293 URL: http://llvm.org/viewvc/llvm-project?rev=90293&view=rev Log: merge sext-2 into sext.ll Removed: llvm/trunk/test/Transforms/InstCombine/sext-2.ll Modified: llvm/trunk/test/Transforms/InstCombine/sext.ll Removed: llvm/trunk/test/Transforms/InstCombine/sext-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext-2.ll?rev=90292&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext-2.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sext-2.ll (removed) @@ -1,14 +0,0 @@ -; Checks to see that instcombine can handle a sign extension of i1 - -; RUN: opt < %s -instcombine -S | FileCheck %s - -define void @test(<2 x i16> %srcA, <2 x i16> %srcB, <2 x i16>* %dst) nounwind { -entry: -; CHECK-NOT: tmask -; CHECK: ret - %cmp = icmp eq <2 x i16> %srcB, %srcA; - %sext = sext <2 x i1> %cmp to <2 x i16>; - %tmask = ashr <2 x i16> %sext, ; - store <2 x i16> %tmask, <2 x i16>* %dst; - ret void -} Modified: llvm/trunk/test/Transforms/InstCombine/sext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sext.ll?rev=90293&r1=90292&r2=90293&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/sext.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/sext.ll Tue Dec 1 23:34:35 2009 @@ -114,3 +114,15 @@ ; CHECK-NEXT: ret i32 } +define void @test11(<2 x i16> %srcA, <2 x i16> %srcB, <2 x i16>* %dst) { + %cmp = icmp eq <2 x i16> %srcB, %srcA + %sext = sext <2 x i1> %cmp to <2 x i16> + %tmask = ashr <2 x i16> %sext, + store <2 x i16> %tmask, <2 x i16>* %dst + ret void +; CHECK: @test11 +; CHECK-NEXT: icmp eq +; CHECK-NEXT: sext <2 x i1> +; CHECK-NEXT: store <2 x i16> +; CHECK-NEXT: ret +} From clattner at apple.com Wed Dec 2 00:00:52 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 22:00:52 -0800 Subject: [llvm-commits] [llvm] r89639 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll In-Reply-To: <200911230317.nAN3HYvG017794@zion.cs.uiuc.edu> References: <200911230317.nAN3HYvG017794@zion.cs.uiuc.edu> Message-ID: <984EC5D0-4D6D-4D8D-83D0-D39D24932914@apple.com> On Nov 22, 2009, at 7:17 PM, Nick Lewycky wrote: > Author: nicholas > Date: Sun Nov 22 21:17:33 2009 > New Revision: 89639 > > URL: http://llvm.org/viewvc/llvm-project?rev=89639&view=rev > Log: > Reapply r88830 with a bugfix: this transform only applies to icmp eq/ne. This > fixes part of PR5438. Thanks for working on this, some thoughts: > > + // icmp ne A, B is equal to xor A, B when A and B only really have one bit. > + // It is also profitable to transform icmp eq into not(xor(A, B)) because that > + // may lead to additional simplifications. > + if (ICI->isEquality() && CI.getType() == ICI->getOperand(0)->getType()) { > + if (const IntegerType *ITy = dyn_cast(CI.getType())) { > + uint32_t BitWidth = ITy->getBitWidth(); > + if (BitWidth > 1) { If this is a zext from bool, the result type can't be i1. The source and dest of a zext can't be the same type, so this 'if' seems unneeded. > + Value *LHS = ICI->getOperand(0); > + Value *RHS = ICI->getOperand(1); > + > + APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); > + APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); > + APInt TypeMask(APInt::getHighBitsSet(BitWidth, BitWidth-1)); Why isn't TypeMask looking at all the bits? > + ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); > + ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); > + > + if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && > + KnownZeroRHS.countLeadingOnes() == BitWidth-1) { This check seems over-constrained. This xforms should apply when it is one of *any* bit set. For example, this: entry: %0 = and i32 %a, 8 ; [#uses=1] %1 = and i32 %b, 8 ; [#uses=1] %2 = icmp eq i32 %0, %1 ; [#uses=1] %3 = zext i1 %2 to i32 ; [#uses=1] ret i32 %3 } should also be transformed. If you intend to keep it written this way, it would be more natural to use MaskedValueIsZero instead of ComputeMaskedBits, however, generalizing this should be easy, so please do :) -Chris From sabre at nondot.org Wed Dec 2 00:05:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 06:05:42 -0000 Subject: [llvm-commits] [llvm] r90297 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Message-ID: <200912020605.nB265gop015125@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 00:05:42 2009 New Revision: 90297 URL: http://llvm.org/viewvc/llvm-project?rev=90297&view=rev Log: tidy up, remove dependence on order of evaluation of function args from EmitMemCpy. Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=90297&r1=90296&r2=90297&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Wed Dec 2 00:05:42 2009 @@ -128,8 +128,7 @@ /// CastToCStr - Return V if it is an i8*, otherwise cast it to i8*. Value *LibCallOptimization::CastToCStr(Value *V, IRBuilder<> &B) { - return - B.CreateBitCast(V, Type::getInt8PtrTy(*Context), "cstr"); + return B.CreateBitCast(V, Type::getInt8PtrTy(*Context), "cstr"); } /// EmitStrLen - Emit a call to the strlen function to the builder, for the @@ -157,27 +156,25 @@ Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, IRBuilder<> &B) { Module *M = Caller->getParent(); - Intrinsic::ID IID = Intrinsic::memcpy; - const Type *Tys[1]; - Tys[0] = Len->getType(); - Value *MemCpy = Intrinsic::getDeclaration(M, IID, Tys, 1); - return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src, B), Len, + const Type *Ty = Len->getType(); + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); + Dst = CastToCStr(Dst, B); + Src = CastToCStr(Src, B); + return B.CreateCall4(MemCpy, Dst, Src, Len, ConstantInt::get(Type::getInt32Ty(*Context), Align)); } -/// EmitMemMOve - Emit a call to the memmove function to the builder. This +/// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. Value *LibCallOptimization::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, IRBuilder<> &B) { Module *M = Caller->getParent(); - Intrinsic::ID IID = Intrinsic::memmove; - const Type *Tys[1]; - Tys[0] = TD->getIntPtrType(*Context); - Value *MemMove = Intrinsic::getDeclaration(M, IID, Tys, 1); - Value *D = CastToCStr(Dst, B); - Value *S = CastToCStr(Src, B); + const Type *Ty = TD->getIntPtrType(*Context); + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); + Dst = CastToCStr(Dst, B); + Src = CastToCStr(Src, B); Value *A = ConstantInt::get(Type::getInt32Ty(*Context), Align); - return B.CreateCall4(MemMove, D, S, Len, A); + return B.CreateCall4(MemMove, Dst, Src, Len, A); } /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is From clattner at apple.com Wed Dec 2 00:24:52 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 22:24:52 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> Message-ID: <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> On Nov 20, 2009, at 5:01 PM, Eric Christopher wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=89523&view=rev > Log: > Add more optimizations for object size checking, enable handling of > object size intrinsic and verify return type is correct. Collect various > code in one place. Hi Eric, > +//===---------------------------------------===// > +// 'object size' > +namespace { > +struct SizeOpt : public LibCallOptimization { This code (if it is kept) should be moved to instcombine, and generalized to work on more than just i32/i64. IT should work on any llvm.objectsize.ixxx intrinsic call. > + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { > + // TODO: We can do more with this, but delaying to here should be no change > + // in behavior. > + ConstantInt *Const = dyn_cast(CI->getOperand(2)); > + > + if (!Const) return 0; This intrinsic *requires* this to be a ConstantInt, right? If so, change this to be cast<> instead of dyn_cast. Unlike random function calls, intrinsics have hard requirements that the optimizer can depend on. > + const Type *Ty = Callee->getFunctionType()->getReturnType(); > + > + if (Const->getZExtValue() < 2) > + return Constant::getAllOnesValue(Ty); > + else > + return ConstantInt::get(Ty, 0); I don't really get this. Why is libcalloptimizer turning these into "I don't know"? Shouldn't codegen (e.g. codegenprepare) do this? This seems really wrong. > +//===---------------------------------------===// > +// 'memcpy_chk' Optimizations > + > +struct MemCpyChkOpt : public LibCallOptimization { > + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { > + // These optimizations require TargetData. > + if (!TD) return 0; > + > + const FunctionType *FT = Callee->getFunctionType(); > + if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || > + !isa(FT->getParamType(0)) || > + !isa(FT->getParamType(1)) || > + !isa(FT->getParamType(3)) || > + FT->getParamType(2) != TD->getIntPtrType(*Context)) > + return 0; > + > + ConstantInt *SizeCI = dyn_cast(CI->getOperand(4)); > + if (!SizeCI) > + return 0; > + if (SizeCI->isAllOnesValue()) { > + EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), 1, B); > + return CI->getOperand(1); > + } This should also handle the case when getOperand(3) and getOperand(4) are both constant ints and op3 <= op4? If we know that op3 > op4, I'm fine with leaving it unoptimized :) Also, please do the check for 'SizeCI' being a constantint before anything else to avoid doing pointless validation. > +//===---------------------------------------===// > +// 'memset_chk' Optimizations > + > +struct MemSetChkOpt : public LibCallOptimization { > + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { > + // These optimizations require TargetData. > + if (!TD) return 0; > + > + const FunctionType *FT = Callee->getFunctionType(); > + if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || > + !isa(FT->getParamType(0)) || > + !isa(FT->getParamType(1)) || > + !isa(FT->getParamType(3)) || > + FT->getParamType(2) != TD->getIntPtrType(*Context)) > + return 0; > + > + ConstantInt *SizeCI = dyn_cast(CI->getOperand(4)); > + if (!SizeCI) > + return 0; > + if (SizeCI->isAllOnesValue()) { > + Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), > + false); > + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B); > + return CI->getOperand(1); > + } Can this code be factored better? Maybe introduce a new intermediate class that all of MemCpyChkOpt/MemSetChkOpt/MemMoveChkOpt inherit from that then inherits from LibCallOptimization? -Chris > + > + return 0; > + } > +}; > + > +//===---------------------------------------===// > +// 'memmove_chk' Optimizations > + > +struct MemMoveChkOpt : public LibCallOptimization { > + virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) { > + // These optimizations require TargetData. > + if (!TD) return 0; > + > + const FunctionType *FT = Callee->getFunctionType(); > + if (FT->getNumParams() != 4 || FT->getReturnType() != FT->getParamType(0) || > + !isa(FT->getParamType(0)) || > + !isa(FT->getParamType(1)) || > + !isa(FT->getParamType(3)) || > + FT->getParamType(2) != TD->getIntPtrType(*Context)) > + return 0; > + > + ConstantInt *SizeCI = dyn_cast(CI->getOperand(4)); > + if (!SizeCI) > + return 0; > + if (SizeCI->isAllOnesValue()) { > + EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), > + 1, B); > + return CI->getOperand(1); > + } > + > + return 0; > + } > +}; > + > +//===----------------------------------------------------------------------===// > // Math Library Optimizations > //===----------------------------------------------------------------------===// > > @@ -1356,7 +1458,7 @@ > if (FormatStr == "%c" && CI->getNumOperands() > 2 && > isa(CI->getOperand(2)->getType())) { > Value *Res = EmitPutChar(CI->getOperand(2), B); > - > + > if (CI->use_empty()) return CI; > return B.CreateIntCast(Res, CI->getType(), true); > } > @@ -1586,7 +1688,10 @@ > // Formatting and IO Optimizations > SPrintFOpt SPrintF; PrintFOpt PrintF; > FWriteOpt FWrite; FPutsOpt FPuts; FPrintFOpt FPrintF; > + > + // Object Size Checking > SizeOpt ObjectSize; > + MemCpyChkOpt MemCpyChk; MemSetChkOpt MemSetChk; MemMoveChkOpt MemMoveChk; > > bool Modified; // This is only used by doInitialization. > public: > @@ -1692,9 +1797,13 @@ > Optimizations["fwrite"] = &FWrite; > Optimizations["fputs"] = &FPuts; > Optimizations["fprintf"] = &FPrintF; > - > - // Miscellaneous > - Optimizations["llvm.objectsize"] = &ObjectSize; > + > + // Object Size Checking > + Optimizations["llvm.objectsize.i32"] = &ObjectSize; > + Optimizations["llvm.objectsize.i64"] = &ObjectSize; > + Optimizations["__memcpy_chk"] = &MemCpyChk; > + Optimizations["__memset_chk"] = &MemSetChk; > + Optimizations["__memmove_chk"] = &MemMoveChk; > } > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Wed Dec 2 00:29:55 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 22:29:55 -0800 Subject: [llvm-commits] [llvm] r88911 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/2009-09-10-SpillComments.ll In-Reply-To: <200911161512.nAGFCNWI021792@zion.cs.uiuc.edu> References: <200911161512.nAGFCNWI021792@zion.cs.uiuc.edu> Message-ID: On Nov 16, 2009, at 7:12 AM, David Greene wrote: > Author: greened > Date: Mon Nov 16 09:12:23 2009 > New Revision: 88911 > > URL: http://llvm.org/viewvc/llvm-project?rev=88911&view=rev > Log: > > Support spill comments. > > Have the asm printer emit a comment if an instruction is a spill or > reload and have the spiller mark copies it introdues so the asm printer > can also annotate those. Hi David, This looks good, a comment about the testcase: > +++ llvm/trunk/test/CodeGen/X86/2009-09-10-SpillComments.ll Mon Nov 16 09:12:23 2009 > @@ -0,0 +1,105 @@ > +; RUN: llc < %s -mtriple=x86_64-unknown-linux | grep "Spill" > +; RUN: llc < %s -mtriple=x86_64-unknown-linux | grep "Folded Spill" > +; RUN: llc < %s -mtriple=x86_64-unknown-linux | grep "Reload" > +; RUN: llc < %s -mtriple=x86_64-unknown-linux | grep "Reload Reuse" Please convert this to FileCheck: among other things, llc should only be run once. Also, please mark walk_fixup_memory_subreg 'nounwind' to avoid unrelated EH spew, -Chris > + > + %struct..0anon = type { i32 } > + %struct.rtvec_def = type { i32, [1 x %struct..0anon] } > + %struct.rtx_def = type { i16, i8, i8, [1 x %struct..0anon] } > + at rtx_format = external global [116 x i8*] ; <[116 x i8*]*> [#uses=1] > + at rtx_length = external global [117 x i32] ; <[117 x i32]*> [#uses=1] > + > +declare %struct.rtx_def* @fixup_memory_subreg(%struct.rtx_def*, %struct.rtx_def*, i32) > + > +define %struct.rtx_def* @walk_fixup_memory_subreg(%struct.rtx_def* %x, %struct.rtx_def* %insn) { > +entry: > + %tmp2 = icmp eq %struct.rtx_def* %x, null ; [#uses=1] > + br i1 %tmp2, label %UnifiedReturnBlock, label %cond_next > + > +cond_next: ; preds = %entry > + %tmp6 = getelementptr %struct.rtx_def* %x, i32 0, i32 0 ; [#uses=1] > + %tmp7 = load i16* %tmp6 ; [#uses=2] > + %tmp78 = zext i16 %tmp7 to i32 ; [#uses=2] > + %tmp10 = icmp eq i16 %tmp7, 54 ; [#uses=1] > + br i1 %tmp10, label %cond_true13, label %cond_next32 > + > +cond_true13: ; preds = %cond_next > + %tmp15 = getelementptr %struct.rtx_def* %x, i32 0, i32 3 ; <[1 x %struct..0anon]*> [#uses=1] > + %tmp1718 = bitcast [1 x %struct..0anon]* %tmp15 to %struct.rtx_def** ; <%struct.rtx_def**> [#uses=1] > + %tmp19 = load %struct.rtx_def** %tmp1718 ; <%struct.rtx_def*> [#uses=1] > + %tmp20 = getelementptr %struct.rtx_def* %tmp19, i32 0, i32 0 ; [#uses=1] > + %tmp21 = load i16* %tmp20 ; [#uses=1] > + %tmp22 = icmp eq i16 %tmp21, 57 ; [#uses=1] > + br i1 %tmp22, label %cond_true25, label %cond_next32 > + > +cond_true25: ; preds = %cond_true13 > + %tmp29 = tail call %struct.rtx_def* @fixup_memory_subreg( %struct.rtx_def* %x, %struct.rtx_def* %insn, i32 1 ) ; <%struct.rtx_def*> [#uses=1] > + ret %struct.rtx_def* %tmp29 > + > +cond_next32: ; preds = %cond_true13, %cond_next > + %tmp34 = getelementptr [116 x i8*]* @rtx_format, i32 0, i32 %tmp78 ; [#uses=1] > + %tmp35 = load i8** %tmp34, align 4 ; [#uses=1] > + %tmp37 = getelementptr [117 x i32]* @rtx_length, i32 0, i32 %tmp78 ; [#uses=1] > + %tmp38 = load i32* %tmp37, align 4 ; [#uses=1] > + %i.011 = add i32 %tmp38, -1 ; [#uses=2] > + %tmp12513 = icmp sgt i32 %i.011, -1 ; [#uses=1] > + br i1 %tmp12513, label %bb, label %UnifiedReturnBlock > + > +bb: ; preds = %bb123, %cond_next32 > + %indvar = phi i32 [ %indvar.next26, %bb123 ], [ 0, %cond_next32 ] ; [#uses=2] > + %i.01.0 = sub i32 %i.011, %indvar ; [#uses=5] > + %tmp42 = getelementptr i8* %tmp35, i32 %i.01.0 ; [#uses=2] > + %tmp43 = load i8* %tmp42 ; [#uses=1] > + switch i8 %tmp43, label %bb123 [ > + i8 101, label %cond_true47 > + i8 69, label %bb105.preheader > + ] > + > +cond_true47: ; preds = %bb > + %tmp52 = getelementptr %struct.rtx_def* %x, i32 0, i32 3, i32 %i.01.0 ; <%struct..0anon*> [#uses=1] > + %tmp5354 = bitcast %struct..0anon* %tmp52 to %struct.rtx_def** ; <%struct.rtx_def**> [#uses=1] > + %tmp55 = load %struct.rtx_def** %tmp5354 ; <%struct.rtx_def*> [#uses=1] > + %tmp58 = tail call %struct.rtx_def* @walk_fixup_memory_subreg( %struct.rtx_def* %tmp55, %struct.rtx_def* %insn ) ; <%struct.rtx_def*> [#uses=1] > + %tmp62 = getelementptr %struct.rtx_def* %x, i32 0, i32 3, i32 %i.01.0, i32 0 ; [#uses=1] > + %tmp58.c = ptrtoint %struct.rtx_def* %tmp58 to i32 ; [#uses=1] > + store i32 %tmp58.c, i32* %tmp62 > + %tmp6816 = load i8* %tmp42 ; [#uses=1] > + %tmp6917 = icmp eq i8 %tmp6816, 69 ; [#uses=1] > + br i1 %tmp6917, label %bb105.preheader, label %bb123 > + > +bb105.preheader: ; preds = %cond_true47, %bb > + %tmp11020 = getelementptr %struct.rtx_def* %x, i32 0, i32 3, i32 %i.01.0 ; <%struct..0anon*> [#uses=1] > + %tmp11111221 = bitcast %struct..0anon* %tmp11020 to %struct.rtvec_def** ; <%struct.rtvec_def**> [#uses=3] > + %tmp11322 = load %struct.rtvec_def** %tmp11111221 ; <%struct.rtvec_def*> [#uses=1] > + %tmp11423 = getelementptr %struct.rtvec_def* %tmp11322, i32 0, i32 0 ; [#uses=1] > + %tmp11524 = load i32* %tmp11423 ; [#uses=1] > + %tmp11625 = icmp eq i32 %tmp11524, 0 ; [#uses=1] > + br i1 %tmp11625, label %bb123, label %bb73 > + > +bb73: ; preds = %bb73, %bb105.preheader > + %j.019 = phi i32 [ %tmp104, %bb73 ], [ 0, %bb105.preheader ] ; [#uses=3] > + %tmp81 = load %struct.rtvec_def** %tmp11111221 ; <%struct.rtvec_def*> [#uses=2] > + %tmp92 = getelementptr %struct.rtvec_def* %tmp81, i32 0, i32 1, i32 %j.019 ; <%struct..0anon*> [#uses=1] > + %tmp9394 = bitcast %struct..0anon* %tmp92 to %struct.rtx_def** ; <%struct.rtx_def**> [#uses=1] > + %tmp95 = load %struct.rtx_def** %tmp9394 ; <%struct.rtx_def*> [#uses=1] > + %tmp98 = tail call %struct.rtx_def* @walk_fixup_memory_subreg( %struct.rtx_def* %tmp95, %struct.rtx_def* %insn ) ; <%struct.rtx_def*> [#uses=1] > + %tmp101 = getelementptr %struct.rtvec_def* %tmp81, i32 0, i32 1, i32 %j.019, i32 0 ; [#uses=1] > + %tmp98.c = ptrtoint %struct.rtx_def* %tmp98 to i32 ; [#uses=1] > + store i32 %tmp98.c, i32* %tmp101 > + %tmp104 = add i32 %j.019, 1 ; [#uses=2] > + %tmp113 = load %struct.rtvec_def** %tmp11111221 ; <%struct.rtvec_def*> [#uses=1] > + %tmp114 = getelementptr %struct.rtvec_def* %tmp113, i32 0, i32 0 ; [#uses=1] > + %tmp115 = load i32* %tmp114 ; [#uses=1] > + %tmp116 = icmp ult i32 %tmp104, %tmp115 ; [#uses=1] > + br i1 %tmp116, label %bb73, label %bb123 > + > +bb123: ; preds = %bb73, %bb105.preheader, %cond_true47, %bb > + %i.0 = add i32 %i.01.0, -1 ; [#uses=1] > + %tmp125 = icmp sgt i32 %i.0, -1 ; [#uses=1] > + %indvar.next26 = add i32 %indvar, 1 ; [#uses=1] > + br i1 %tmp125, label %bb, label %UnifiedReturnBlock > + > +UnifiedReturnBlock: ; preds = %bb123, %cond_next32, %entry > + %UnifiedRetVal = phi %struct.rtx_def* [ null, %entry ], [ %x, %cond_next32 ], [ %x, %bb123 ] ; <%struct.rtx_def*> [#uses=1] > + ret %struct.rtx_def* %UnifiedRetVal > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Wed Dec 2 00:35:55 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 06:35:55 -0000 Subject: [llvm-commits] [llvm] r90298 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <200912020635.nB26ZtBD016047@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 00:35:55 2009 New Revision: 90298 URL: http://llvm.org/viewvc/llvm-project?rev=90298&view=rev Log: formatting cleanups. 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=90298&r1=90297&r2=90298&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Wed Dec 2 00:35:55 2009 @@ -85,9 +85,14 @@ return true; if (IntrinsicInst *II = dyn_cast(I)) { switch (II->getIntrinsicID()) { - default: return false; - case Intrinsic::memset: case Intrinsic::memmove: case Intrinsic::memcpy: - case Intrinsic::init_trampoline: case Intrinsic::lifetime_end: return true; + default: + return false; + case Intrinsic::memset: + case Intrinsic::memmove: + case Intrinsic::memcpy: + case Intrinsic::init_trampoline: + case Intrinsic::lifetime_end: + return true; } } return false; @@ -111,14 +116,13 @@ return SI->getPointerOperand(); if (MemIntrinsic *MI = dyn_cast(I)) return MI->getOperand(1); - IntrinsicInst *II = cast(I); - switch (II->getIntrinsicID()) { - default: - assert(false && "Unexpected intrinsic!"); - case Intrinsic::init_trampoline: - return II->getOperand(1); - case Intrinsic::lifetime_end: - return II->getOperand(2); + + switch (cast(I)->getIntrinsicID()) { + default: assert(false && "Unexpected intrinsic!"); + case Intrinsic::init_trampoline: + return I->getOperand(1); + case Intrinsic::lifetime_end: + return I->getOperand(2); } } @@ -135,15 +139,13 @@ if (MemIntrinsic *MI = dyn_cast(I)) { Len = MI->getLength(); } else { - IntrinsicInst *II = cast(I); - switch (II->getIntrinsicID()) { - default: - assert(false && "Unexpected intrinsic!"); - case Intrinsic::init_trampoline: - return -1u; - case Intrinsic::lifetime_end: - Len = II->getOperand(1); - break; + switch (cast(I)->getIntrinsicID()) { + default: assert(false && "Unexpected intrinsic!"); + case Intrinsic::init_trampoline: + return -1u; + case Intrinsic::lifetime_end: + Len = I->getOperand(1); + break; } } if (ConstantInt *LenCI = dyn_cast(Len)) From clattner at apple.com Wed Dec 2 00:38:19 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 22:38:19 -0800 Subject: [llvm-commits] [llvm] r86840 - in /llvm/trunk: include/llvm/IntrinsicInst.h lib/Transforms/Utils/Local.cpp test/Transforms/InstCombine/invariant.ll In-Reply-To: <200911111534.nABFYEd0025670@zion.cs.uiuc.edu> References: <200911111534.nABFYEd0025670@zion.cs.uiuc.edu> Message-ID: <92E3CFF2-F830-4826-BDCF-5EF745AA4904@apple.com> On Nov 11, 2009, at 7:34 AM, Duncan Sands wrote: > Author: baldrick > Date: Wed Nov 11 09:34:13 2009 > New Revision: 86840 > > URL: http://llvm.org/viewvc/llvm-project?rev=86840&view=rev > Log: > Don't trivially delete unused calls to llvm.invariant.start. This allows > llvm.invariant.start to be used without necessarily being paired with a call > to llvm.invariant.end. If you run the entire optimization pipeline then such > calls are in fact deleted (adce does it), but that's actually a good thing since > we probably do want them to be zapped late in the game. There should really be > an integration test that checks that the llvm.invariant.start call lasts long > enough that all passes that do interesting things with it get to do their stuff > before it is deleted. But since no passes do anything interesting with it yet > this will have to wait for later. Hi Duncan, > +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Nov 11 09:34:13 2009 > @@ -252,6 +252,9 @@ > // We don't want debug info removed by anything this general. > if (isa(I)) return false; > > + // Likewise for memory use markers. > + if (isa(I)) return false; Is this still needed? I thought that it turns out that these intrinsics need to be marked as having side effects after all? -Chris From sabre at nondot.org Wed Dec 2 00:44:58 2009 From: sabre at nondot.org (Chris Lattner) Date: Wed, 02 Dec 2009 06:44:58 -0000 Subject: [llvm-commits] [llvm] r90299 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <200912020644.nB26ixXr016330@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 00:44:58 2009 New Revision: 90299 URL: http://llvm.org/viewvc/llvm-project?rev=90299&view=rev Log: factor some code better. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90299&r1=90298&r2=90299&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Dec 2 00:44:58 2009 @@ -1187,6 +1187,13 @@ return V; } +static bool isLifetimeStartOrEnd(Instruction *Inst) { + if (IntrinsicInst* II = dyn_cast(Inst)) + return II->getIntrinsicID() == Intrinsic::lifetime_start || + II->getIntrinsicID() == Intrinsic::lifetime_end; + return false; +} + /// processNonLocalLoad - Attempt to eliminate a load whose dependencies are /// non-local by performing PHI construction. bool GVN::processNonLocalLoad(LoadInst *LI, @@ -1254,21 +1261,14 @@ Instruction *DepInst = DepInfo.getInst(); // Loading the allocation -> undef. - if (isa(DepInst) || isMalloc(DepInst)) { + if (isa(DepInst) || isMalloc(DepInst) || + // Loading immediately after lifetime begin or end -> undef. + isLifetimeStartOrEnd(DepInst)) { ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, UndefValue::get(LI->getType()))); continue; } - // Loading immediately after lifetime begin or end -> undef. - if (IntrinsicInst* II = dyn_cast(DepInst)) { - if (II->getIntrinsicID() == Intrinsic::lifetime_start || - II->getIntrinsicID() == Intrinsic::lifetime_end) { - ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, - UndefValue::get(LI->getType()))); - } - } - if (StoreInst *S = dyn_cast(DepInst)) { // Reject loads and stores that are to the same address but are of // different types if we have to. From clattner at apple.com Wed Dec 2 00:47:38 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 22:47:38 -0800 Subject: [llvm-commits] [llvm] r85383 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/DeadStoreElimination.cpp lib/Transforms/Scalar/GVN.cpp test/Transforms/DeadStoreElimination/lifetime-simple.ll test/Transforms/GVN/lifetime-simple.ll In-Reply-To: <200910280705.n9S75ZKs005281@zion.cs.uiuc.edu> References: <200910280705.n9S75ZKs005281@zion.cs.uiuc.edu> Message-ID: On Oct 28, 2009, at 12:05 AM, Owen Anderson wrote: > Author: resistor > Date: Wed Oct 28 02:05:35 2009 > New Revision: 85383 > > URL: http://llvm.org/viewvc/llvm-project?rev=85383&view=rev > Log: > Treat lifetime begin/end markers as allocations/frees respectively for the > purposes for GVN/DSE. Hi Owen, some questions: > +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Oct 28 02:05:35 2009 > @@ -200,6 +199,19 @@ > invariantTag = II->getOperand(1); > continue; > } > + > + // If we reach a lifetime begin or end marker, then the query ends here > + // because the value is undefined. > + } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || > + II->getIntrinsicID() == Intrinsic::lifetime_end) { > + uint64_t invariantSize = ~0ULL; > + if (ConstantInt* CI = dyn_cast(II->getOperand(1))) > + invariantSize = CI->getZExtValue(); > + > + AliasAnalysis::AliasResult R = > + AA->alias(II->getOperand(2), invariantSize, MemPtr, MemSize); > + if (R == AliasAnalysis::MustAlias) > + return MemDepResult::getDef(II); > } > } I just pointed out several issues with this code (I thought Nick wrote it) here: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20091130/092042.html Beyond what I wrote there, I Don't see why memdep is caring about handling a load that depends on a lifetime end. This should *never* happen, so why do we even have the code? > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Oct 28 02:05:35 2009 > @@ -1248,6 +1248,15 @@ > UndefValue::get(LI->getType()))); > continue; > } > + > + // Loading immediately after lifetime begin or end -> undef. > + if (IntrinsicInst* II = dyn_cast(DepInst)) { > + if (II->getIntrinsicID() == Intrinsic::lifetime_start || > + II->getIntrinsicID() == Intrinsic::lifetime_end) { > + ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, > + UndefValue::get(LI->getType()))); > + } Likewise, this should not care about lifetime_end. It is also missing a continue, which I fixed on mainline. > + > + // If this load occurs either right after a lifetime begin or a lifetime end, > + // then the loaded value is undefined. Again, why lifetime_end? > + if (IntrinsicInst* II = dyn_cast(DepInst)) { Please fix the *. -Chris From clattner at apple.com Wed Dec 2 01:31:19 2009 From: clattner at apple.com (Chris Lattner) Date: Tue, 1 Dec 2009 23:31:19 -0800 Subject: [llvm-commits] [llvm] r89297 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Utils/SimplifyCFG.cpp In-Reply-To: <200911190202.nAJ22ACR027438@zion.cs.uiuc.edu> References: <200911190202.nAJ22ACR027438@zion.cs.uiuc.edu> Message-ID: <0F9C0ACF-84F4-4872-B911-5FEC96BFF05C@apple.com> On Nov 18, 2009, at 6:02 PM, Jim Grosbach wrote: > Author: grosbach > Date: Wed Nov 18 20:02:10 2009 > New Revision: 89297 > > URL: http://llvm.org/viewvc/llvm-project?rev=89297&view=rev > Log: > Make EliminateDuplicatePHINodes() available as a utility function Hi Jim, Please move this function out to 'lib/Transforms/Utils/Local.cpp'. SimplifyCFG.cpp should just have the simplifycfg entrypoint. -Chris > > Modified: > llvm/trunk/include/llvm/Transforms/Utils/Local.h > llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp > > Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=89297&r1=89296&r2=89297&view=diff > > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Wed Nov 18 20:02:10 2009 > @@ -107,7 +107,14 @@ > /// rewriting all the predecessors to branch to the successor block and return > /// true. If we can't transform, return false. > bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB); > - > + > +/// EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI > +/// nodes in this block. This doesn't try to be clever about PHI nodes > +/// which differ only in the order of the incoming values, but instcombine > +/// orders them so it usually won't matter. > +/// > +bool EliminateDuplicatePHINodes(BasicBlock *BB); > + > /// SimplifyCFG - This function is used to do simplification of a CFG. For > /// example, it adjusts branches to branches to eliminate the extra hop, it > /// eliminates unreachable basic blocks, and does other "peephole" optimization > > Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=89297&r1=89296&r2=89297&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Nov 18 20:02:10 2009 > @@ -1594,7 +1594,7 @@ > /// which differ only in the order of the incoming values, but instcombine > /// orders them so it usually won't matter. > /// > -static bool EliminateDuplicatePHINodes(BasicBlock *BB) { > +bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) { > bool Changed = false; > > // This implementation doesn't currently consider undef operands > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From resistor at mac.com Wed Dec 2 01:35:19 2009 From: resistor at mac.com (Owen Anderson) Date: Wed, 02 Dec 2009 07:35:19 -0000 Subject: [llvm-commits] [llvm] r90304 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/GVN.cpp test/Transforms/DeadStoreElimination/lifetime-simple.ll test/Transforms/GVN/lifetime-simple.ll Message-ID: <200912020735.nB27ZJlf017871@zion.cs.uiuc.edu> Author: resistor Date: Wed Dec 2 01:35:19 2009 New Revision: 90304 URL: http://llvm.org/viewvc/llvm-project?rev=90304&view=rev Log: Cleanup/remove some parts of the lifetime region handling code in memdep and GVN, per Chris' comments. Adjust testcases to match. Removed: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/lifetime-simple.ll Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90304&r1=90303&r2=90304&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Dec 2 01:35:19 2009 @@ -186,15 +186,17 @@ } if (IntrinsicInst *II = dyn_cast(Inst)) { + // Debug intrinsics don't cause dependences. + if (isa(Inst)) continue; + // If we pass an invariant-end marker, then we've just entered an // invariant region and can start ignoring dependencies. if (II->getIntrinsicID() == Intrinsic::invariant_end) { - uint64_t InvariantSize = ~0ULL; - if (ConstantInt *CI = dyn_cast(II->getOperand(2))) - InvariantSize = CI->getZExtValue(); - - AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(3), InvariantSize, MemPtr, MemSize); + // FIXME: This only considers queries directly on the invariant-tagged + // pointer, not on query pointers that are indexed off of them. It'd + // be nice to handle that at some point. + AliasAnalysis::AliasResult R = + AA->alias(II->getOperand(3), ~0ULL, MemPtr, ~0ULL); if (R == AliasAnalysis::MustAlias) { InvariantTag = II->getOperand(1); continue; @@ -202,14 +204,12 @@ // If we reach a lifetime begin or end marker, then the query ends here // because the value is undefined. - } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || - II->getIntrinsicID() == Intrinsic::lifetime_end) { - uint64_t InvariantSize = ~0ULL; - if (ConstantInt *CI = dyn_cast(II->getOperand(1))) - InvariantSize = CI->getZExtValue(); - + } else if (II->getIntrinsicID() == Intrinsic::lifetime_start) { + // FIXME: This only considers queries directly on the invariant-tagged + // pointer, not on query pointers that are indexed off of them. It'd + // be nice to handle that at some point. AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(2), InvariantSize, MemPtr, MemSize); + AA->alias(II->getOperand(2), ~0ULL, MemPtr, ~0ULL); if (R == AliasAnalysis::MustAlias) return MemDepResult::getDef(II); } @@ -219,9 +219,6 @@ // at this point. Nothing a load depends on can live in an invariant region. if (isLoad && InvariantTag) continue; - // Debug intrinsics don't cause dependences. - if (isa(Inst)) continue; - // Values depend on loads if the pointers are must aliased. This means that // a load depends on another must aliased load from the same value. if (LoadInst *LI = dyn_cast(Inst)) { Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90304&r1=90303&r2=90304&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Dec 2 01:35:19 2009 @@ -1187,10 +1187,9 @@ return V; } -static bool isLifetimeStartOrEnd(Instruction *Inst) { +static bool isLifetimeStart(Instruction *Inst) { if (IntrinsicInst* II = dyn_cast(Inst)) - return II->getIntrinsicID() == Intrinsic::lifetime_start || - II->getIntrinsicID() == Intrinsic::lifetime_end; + return II->getIntrinsicID() == Intrinsic::lifetime_start; return false; } @@ -1262,8 +1261,8 @@ // Loading the allocation -> undef. if (isa(DepInst) || isMalloc(DepInst) || - // Loading immediately after lifetime begin or end -> undef. - isLifetimeStartOrEnd(DepInst)) { + // Loading immediately after lifetime begin -> undef. + isLifetimeStart(DepInst)) { ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, UndefValue::get(LI->getType()))); continue; @@ -1635,11 +1634,10 @@ return true; } - // If this load occurs either right after a lifetime begin or a lifetime end, + // If this load occurs either right after a lifetime begin, // then the loaded value is undefined. if (IntrinsicInst* II = dyn_cast(DepInst)) { - if (II->getIntrinsicID() == Intrinsic::lifetime_start || - II->getIntrinsicID() == Intrinsic::lifetime_end) { + if (II->getIntrinsicID() == Intrinsic::lifetime_start) { L->replaceAllUsesWith(UndefValue::get(L->getType())); toErase.push_back(L); NumGVNLoad++; Removed: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll?rev=90303&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll (original) +++ llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll (removed) @@ -1,18 +0,0 @@ -; RUN: opt < %s -dse -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" - -define i8 @test2(i8* %P) nounwind { -; CHECK: @test2 -; CHECK-NOT: store i8 1 -; CHECK: ret i8 0 -entry: - call void @llvm.lifetime.start(i64 32, i8* %P) - call void @llvm.lifetime.end(i64 32, i8* %P) - store i8 1, i8* %P - ret i8 0 -} - -declare {}* @llvm.lifetime.start(i64 %S, i8* nocapture %P) readonly -declare void @llvm.lifetime.end(i64 %S, i8* nocapture %P) \ No newline at end of file Modified: llvm/trunk/test/Transforms/GVN/lifetime-simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/lifetime-simple.ll?rev=90304&r1=90303&r2=90304&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/lifetime-simple.ll (original) +++ llvm/trunk/test/Transforms/GVN/lifetime-simple.ll Wed Dec 2 01:35:19 2009 @@ -4,9 +4,9 @@ target triple = "i386-apple-darwin7" define i8 @test(i8* %P) nounwind { -; CHECK: @test +; CHECK: lifetime.start ; CHECK-NOT: load -; CHECK: ret i8 undef +; CHECK: lifetime.end entry: call void @llvm.lifetime.start(i64 32, i8* %P) %0 = load i8* %P From baldrick at free.fr Wed Dec 2 02:36:28 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 09:36:28 +0100 Subject: [llvm-commits] [llvm] r90045 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/DeadStoreElimination/lifetime.ll In-Reply-To: References: <200911282127.nASLRoum025712@zion.cs.uiuc.edu> Message-ID: <4B16270C.6060208@free.fr> Hi Chris, > mustalias queries don't care about the size of the operands, so > getting it is pointless. Either the pointers themselves mustalias or > not. As such, this won't catch the case where you have a lifetime > marker saying that a 20 byte object is live/dead but where you're > accessing 4 bytes into the 20 byte object. I don't know if you care > about this case, if so, please fix it somehow, otherwise remove the > dead code and add a FIXME describing the issue. I don't know if the following use case is relevant to this, but since it's important to me I mention it here: the dragonegg trampoline code creates a struct alloca for which one field (holding the trampoline pointer)] is constant after being initialized. For technical reasons (i.e. this was the best I could come up with given that I can't modify gcc itself) this field is in the middle of the alloca, and other fields are not constant. I mark this field with an llvm.invariant call. It is important that loads from this field simplify to the original stored value whenever possible, since this can result in eliminating uses of the trampoline (a big win). [Such loads may be in other functions and as such only exposed after inlining]. Currently such loads are not always simplified :( This is an example where the whole object is not invariant, and it is important to be precise about what is being accessed. Ciao, Duncan. From baldrick at free.fr Wed Dec 2 04:19:11 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 10:19:11 -0000 Subject: [llvm-commits] [dragonegg] r90315 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912021019.nB2AJB0v007319@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 04:19:10 2009 New Revision: 90315 URL: http://llvm.org/viewvc/llvm-project?rev=90315&view=rev Log: Aggregate types are never used as unary or binary right-hand-sides for gimple assignment. Simplify code using this. 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=90315&r1=90314&r2=90315&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 04:19:10 2009 @@ -1169,6 +1169,10 @@ /// DestLoc. void TreeToLLVM::EmitAggregate(tree exp, const MemRef &DestLoc) { assert(AGGREGATE_TYPE_P(TREE_TYPE(exp)) && "Expected an aggregate type!"); + if (TREE_CODE(exp) == CONSTRUCTOR) { + EmitCONSTRUCTOR(exp, &DestLoc); + return; + } LValue LV = EmitLV(exp); assert(!LV.isBitfield() && "Bitfields containing aggregates not supported!"); EmitAggregateCopy(DestLoc, MemRef(LV.Ptr, LV.getAlignment(), @@ -6810,11 +6814,11 @@ void TreeToLLVM::RenderGIMPLE_ASSIGN(gimple stmt) { tree lhs = gimple_assign_lhs(stmt); if (AGGREGATE_TYPE_P(TREE_TYPE(lhs))) { + assert(get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS && + "Aggregate type but rhs not simple!"); LValue LV = EmitLV(lhs); MemRef NewLoc(LV.Ptr, LV.getAlignment(), TREE_THIS_VOLATILE(lhs)); - // TODO: This case can presumably only happen with special gimple - // assign right-hand-sides. Try to simplify by exploiting this. - EmitGimpleAssignRHS(stmt, &NewLoc); + EmitAggregate(gimple_assign_rhs1 (stmt), NewLoc); return; } WriteScalarToLHS(lhs, EmitGimpleAssignRHS(stmt, 0)); From baldrick at free.fr Wed Dec 2 06:52:02 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 12:52:02 -0000 Subject: [llvm-commits] [dragonegg] r90316 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912021252.nB2Cq2ep012674@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 06:52:01 2009 New Revision: 90316 URL: http://llvm.org/viewvc/llvm-project?rev=90316&view=rev Log: Remove DestLoc in situations where all callers pass in NULL. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90316&r1=90315&r2=90316&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 06:52:01 2009 @@ -2213,12 +2213,12 @@ /// EmitLoadOfLValue - When an l-value expression is used in a context that /// requires an r-value, this method emits the lvalue computation, then loads /// the result. -Value *TreeToLLVM::EmitLoadOfLValue(tree exp, const MemRef *DestLoc) { +Value *TreeToLLVM::EmitLoadOfLValue(tree exp) { if (canEmitRegisterVariable(exp)) // If this is a register variable, EmitLV can't handle it (there is no // l-value of a register variable). Emit an inline asm node that copies the // value out of the specified register. - return EmitReadOfRegisterVariable(exp, DestLoc); + return EmitReadOfRegisterVariable(exp); LValue LV = EmitLV(exp); bool isVolatile = TREE_THIS_VOLATILE(exp); @@ -2233,17 +2233,11 @@ if (!LV.isBitfield()) { - if (!DestLoc) { - // Scalar value: emit a load. - Value *Ptr = Builder.CreateBitCast(LV.Ptr, Ty->getPointerTo()); - LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); - LI->setAlignment(Alignment); - return LI; - } else { - EmitAggregateCopy(*DestLoc, MemRef(LV.Ptr, Alignment, isVolatile), - TREE_TYPE(exp)); - return 0; - } + // Scalar value: emit a load. + Value *Ptr = Builder.CreateBitCast(LV.Ptr, Ty->getPointerTo()); + LoadInst *LI = Builder.CreateLoad(Ptr, isVolatile); + LI->setAlignment(Alignment); + return LI; } else { // This is a bitfield reference. if (!LV.BitSize) @@ -2414,9 +2408,8 @@ return 0; } -Value *TreeToLLVM::EmitGimpleAssignSingleRHS(tree rhs, const MemRef *DestLoc) { - assert((AGGREGATE_TYPE_P(TREE_TYPE(rhs)) == (DestLoc != 0)) && - "DestLoc for aggregate types only!"); +Value *TreeToLLVM::EmitGimpleAssignSingleRHS(tree rhs) { + assert(!AGGREGATE_TYPE_P(TREE_TYPE(rhs)) && "Expected a scalar type!"); Value *Result = 0; @@ -2436,19 +2429,13 @@ case INDIRECT_REF: case REALPART_EXPR: case VIEW_CONVERT_EXPR: - Result = EmitLoadOfLValue(rhs, DestLoc); - break; - // Declarations (tcc_declaration). case PARM_DECL: case RESULT_DECL: case VAR_DECL: - Result = EmitLoadOfLValue(rhs, DestLoc); - break; - // Constants (tcc_constant). case STRING_CST: - Result = EmitLoadOfLValue(rhs, DestLoc); + Result = EmitLoadOfLValue(rhs); break; // Expressions (tcc_expression). @@ -2456,21 +2443,19 @@ case OBJ_TYPE_REF: Result = EmitOBJ_TYPE_REF(rhs); break; // Exceptional (tcc_exceptional). - case CONSTRUCTOR: Result = EmitCONSTRUCTOR(rhs, DestLoc); break; + case CONSTRUCTOR: Result = EmitCONSTRUCTOR(rhs, 0); break; } - assert(((DestLoc && Result == 0) || DestLoc == 0) && - "Expected a scalar or aggregate but got the wrong thing!"); - // Check that the type of the result matches that of the tree node. - assert((Result == 0 || Result->getType() == ConvertType(TREE_TYPE(rhs))) && - "Value has wrong type!"); + assert(Result && "Expected a scalar, got an aggregate!"); + assert(Result->getType() == ConvertType(TREE_TYPE(rhs)) && + "Value has wrong type!"); return Result; } -Value *TreeToLLVM::EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc) { +Value *TreeToLLVM::EmitGimpleAssignRHS(gimple stmt) { if (get_gimple_rhs_class(gimple_expr_code(stmt)) == GIMPLE_SINGLE_RHS) - return EmitGimpleAssignSingleRHS(gimple_assign_rhs1 (stmt), DestLoc); + return EmitGimpleAssignSingleRHS(gimple_assign_rhs1 (stmt)); tree type = TREE_TYPE(gimple_assign_lhs(stmt)); tree_code code = gimple_assign_rhs_code(stmt); @@ -2496,7 +2481,7 @@ case NEGATE_EXPR: return EmitNEGATE_EXPR(rhs1); case NOP_EXPR: - return EmitNOP_EXPR(type, rhs1, DestLoc); + return EmitNOP_EXPR(type, rhs1); case PAREN_EXPR: return EmitPAREN_EXPR(rhs1); case TRUTH_NOT_EXPR: @@ -3078,30 +3063,13 @@ return 0; } -Value *TreeToLLVM::EmitNOP_EXPR(tree type, tree op, const MemRef *DestLoc) { +Value *TreeToLLVM::EmitNOP_EXPR(tree type, tree op) { const Type *Ty = ConvertType(type); bool OpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op)); bool ExpIsSigned = !TYPE_UNSIGNED(type); - if (DestLoc == 0) { - // Scalar to scalar copy. - assert(!AGGREGATE_TYPE_P(TREE_TYPE(op)) - && "Aggregate to scalar nop_expr!"); - return CastToAnyType(EmitGimpleReg(op), OpIsSigned, Ty, ExpIsSigned); - } else if (AGGREGATE_TYPE_P(TREE_TYPE(op))) { - // Aggregate to aggregate copy. - MemRef NewLoc = *DestLoc; - NewLoc.Ptr = Builder.CreateBitCast(DestLoc->Ptr,Ty->getPointerTo()); - EmitAggregate(op, NewLoc); - return 0; - } - - // Scalar to aggregate copy. - Value *OpVal = EmitGimpleReg(op); - Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, - PointerType::getUnqual(OpVal->getType())); - StoreInst *St = Builder.CreateStore(OpVal, Ptr, DestLoc->Volatile); - St->setAlignment(DestLoc->getAlignment()); - return 0; + // Scalar to scalar copy. + assert(!AGGREGATE_TYPE_P(TREE_TYPE(op)) && "Aggregate to scalar nop_expr!"); + return CastToAnyType(EmitGimpleReg(op), OpIsSigned, Ty, ExpIsSigned); } Value *TreeToLLVM::EmitCONVERT_EXPR(tree type, tree op) { @@ -3699,16 +3667,12 @@ /// Reads from register variables are handled by emitting an inline asm node /// that copies the value out of the specified register. -Value *TreeToLLVM::EmitReadOfRegisterVariable(tree decl, - const MemRef *DestLoc) { +Value *TreeToLLVM::EmitReadOfRegisterVariable(tree decl) { const Type *Ty = ConvertType(TREE_TYPE(decl)); // If there was an error, return something bogus. - if (ValidateRegisterVariable(decl)) { - if (Ty->isSingleValueType()) - return UndefValue::get(Ty); - return 0; // Just don't copy something into DestLoc. - } + if (ValidateRegisterVariable(decl)) + return UndefValue::get(Ty); // Turn this into a 'tmp = call Ty asm "", "={reg}"()'. FunctionType *FTy = FunctionType::get(Ty, std::vector(),false); @@ -6821,7 +6785,7 @@ EmitAggregate(gimple_assign_rhs1 (stmt), NewLoc); return; } - WriteScalarToLHS(lhs, EmitGimpleAssignRHS(stmt, 0)); + WriteScalarToLHS(lhs, EmitGimpleAssignRHS(stmt)); } void TreeToLLVM::RenderGIMPLE_CALL(gimple stmt) { Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90316&r1=90315&r2=90316&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Wed Dec 2 06:52:01 2009 @@ -621,16 +621,15 @@ private: // Expressions. - Value *EmitGimpleAssignSingleRHS(tree_node *rhs, const MemRef *DestLoc); - Value *EmitGimpleAssignRHS(gimple stmt, const MemRef *DestLoc); + Value *EmitGimpleAssignSingleRHS(tree_node *rhs); + Value *EmitGimpleAssignRHS(gimple stmt); Value *EmitGimpleCallRHS(gimple stmt, const MemRef *DestLoc); - Value *EmitLoadOfLValue(tree_node *exp, const MemRef *DestLoc); - Value *EmitOBJ_TYPE_REF(tree_node *exp, const MemRef *DestLoc); + Value *EmitLoadOfLValue(tree_node *exp); Value *EmitADDR_EXPR(tree_node *exp); Value *EmitOBJ_TYPE_REF(tree_node *exp); Value *EmitCallOf(Value *Callee, gimple stmt, const MemRef *DestLoc, const AttrListPtr &PAL); - Value *EmitNOP_EXPR(tree_node *type, tree_node *op, const MemRef *DestLoc); + Value *EmitNOP_EXPR(tree_node *type, tree_node *op); Value *EmitCONVERT_EXPR(tree_node *type, tree_node *op); Value *EmitNEGATE_EXPR(tree_node *op); Value *EmitCONJ_EXPR(tree_node *op); @@ -661,7 +660,7 @@ Value *EmitFILTER_EXPR(tree_node *exp); // Inline Assembly and Register Variables. - Value *EmitReadOfRegisterVariable(tree_node *vardecl, const MemRef *DestLoc); + Value *EmitReadOfRegisterVariable(tree_node *vardecl); void EmitModifyOfRegisterVariable(tree_node *vardecl, Value *RHS); // Helpers for Builtin Function Expansion. From baldrick at free.fr Wed Dec 2 07:12:00 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 13:12:00 -0000 Subject: [llvm-commits] [dragonegg] r90317 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <200912021312.nB2DC0w5013386@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 07:11:59 2009 New Revision: 90317 URL: http://llvm.org/viewvc/llvm-project?rev=90317&view=rev Log: Rename some functions and move them out of line. No functionality change. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=90317&r1=90316&r2=90317&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 07:11:59 2009 @@ -867,7 +867,7 @@ // Find the incoming value for this predecessor. while (VI != VE && VI->first != BB) ++VI; assert(VI != VE && "No value for predecessor!"); - Value *Val = EmitGimpleReg(VI->second); + Value *Val = EmitRegister(VI->second); // Need to bitcast to the right type (useless_type_conversion_p). Place // the bitcast at the end of the predecessor, before the terminator. @@ -1483,7 +1483,7 @@ } } - Value *TypeSize = EmitGimpleReg(TYPE_SIZE_UNIT(type)); + Value *TypeSize = EmitRegister(TYPE_SIZE_UNIT(type)); EmitMemCpy(DestLoc.Ptr, SrcLoc.Ptr, TypeSize, std::min(DestLoc.getAlignment(), SrcLoc.getAlignment())); } @@ -1536,7 +1536,7 @@ } EmitMemSet(DestLoc.Ptr, ConstantInt::get(Type::getInt8Ty(Context), 0), - EmitGimpleReg(TYPE_SIZE_UNIT(type)), DestLoc.getAlignment()); + EmitRegister(TYPE_SIZE_UNIT(type)), DestLoc.getAlignment()); } Value *TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, @@ -1693,7 +1693,7 @@ Ty = ConvertType(type); } else { // Compute the variable's size in bytes. - Size = EmitGimpleReg(DECL_SIZE_UNIT(decl)); + Size = EmitRegister(DECL_SIZE_UNIT(decl)); Ty = Type::getInt8Ty(Context); Size = Builder.CreateIntCast(Size, Type::getInt32Ty(Context), /*isSigned*/false); @@ -1845,7 +1845,7 @@ //FIXME // Add the type infos. //FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { //FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(EmitGimpleReg(TType)); +//FIXME Args.push_back(EmitRegister(TType)); //FIXME } //FIXME } else if (RegionKind > 0) { //FIXME // Catch. @@ -1860,7 +1860,7 @@ //FIXME // Add the type infos. //FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { //FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(EmitGimpleReg(TType)); +//FIXME Args.push_back(EmitRegister(TType)); //FIXME } //FIXME } //FIXME } @@ -1884,7 +1884,7 @@ //FIXME Type::getInt8PtrTy(Context)); //FIXME else //FIXME // This language has a type that catches all others. -//FIXME CatchAll = EmitGimpleReg(catch_all_type); +//FIXME CatchAll = EmitRegister(catch_all_type); //FIXME } //FIXME Args.push_back(CatchAll); //FIXME } @@ -1944,7 +1944,7 @@ //FIXME //FIXME Value *Cond = NULL; //FIXME for (; TypeList; TypeList = TREE_CHAIN (TypeList)) { -//FIXME Value *TType = EmitGimpleReg(lookup_type_for_runtime(TREE_VALUE(TypeList))); +//FIXME Value *TType = EmitRegister(lookup_type_for_runtime(TREE_VALUE(TypeList))); //FIXME TType = Builder.CreateBitCast(TType, //FIXME Type::getInt8PtrTy(Context)); //FIXME @@ -2130,9 +2130,9 @@ return DefineSSAName(reg, Def); } -/// EmitGimpleInvariantAddress - The given address is constant in this function. +/// EmitInvariantAddress - The given address is constant in this function. /// Return the corresponding LLVM value. Only creates code in the entry block. -Value *TreeToLLVM::EmitGimpleInvariantAddress(tree addr) { +Value *TreeToLLVM::EmitInvariantAddress(tree addr) { assert(is_gimple_invariant_address(addr) && "Expected a locally constant address!"); assert(is_gimple_reg_type(TREE_TYPE(addr)) && "Not of register type!"); @@ -2173,8 +2173,9 @@ return Address; } -/// EmitGimpleConstant - Return the LLVM constant for this global constant. -Constant *TreeToLLVM::EmitGimpleConstant(tree reg) { +/// EmitRegisterConstant - Convert the given global constant of register type to +/// an LLVM constant. Creates no code, only constants. +Constant *TreeToLLVM::EmitRegisterConstant(tree reg) { #ifndef NDEBUG if (!is_gimple_constant(reg)) { debug_tree(reg); @@ -2210,6 +2211,26 @@ return C; } +/// EmitMinInvariant - The given value is constant in this function. Return the +/// corresponding LLVM value. Only creates code in the entry block. +Value *TreeToLLVM::EmitMinInvariant(tree reg) { + Value *V = (TREE_CODE(reg) == ADDR_EXPR) ? + EmitInvariantAddress(reg) : EmitRegisterConstant(reg); + assert(V->getType() == ConvertType(TREE_TYPE(reg)) && + "Gimple min invariant has wrong type!"); + return V; +} + +/// EmitRegister - Convert the specified gimple register or local constant of +/// register type to an LLVM value. Only creates code in the entry block. +Value *TreeToLLVM::EmitRegister(tree reg) { + Value *V = (TREE_CODE(reg) == SSA_NAME) ? + EmitSSA_NAME(reg) : EmitMinInvariant(reg); + assert(V->getType() == ConvertType(TREE_TYPE(reg)) && + "Gimple register has wrong type!"); + return V; +} + /// EmitLoadOfLValue - When an l-value expression is used in a context that /// requires an r-value, this method emits the lvalue computation, then loads /// the result. @@ -2322,7 +2343,7 @@ } Value *TreeToLLVM::EmitOBJ_TYPE_REF(tree exp) { - return Builder.CreateBitCast(EmitGimpleReg(OBJ_TYPE_REF_EXPR(exp)), + return Builder.CreateBitCast(EmitRegister(OBJ_TYPE_REF_EXPR(exp)), ConvertType(TREE_TYPE(exp))); } @@ -2340,7 +2361,7 @@ unsigned HOST_WIDE_INT idx; tree value; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (exp), idx, value) { - Value *Elt = EmitGimpleReg(value); + Value *Elt = EmitRegister(value); if (const VectorType *EltTy = dyn_cast(Elt->getType())) { // GCC allows vectors to be built up from vectors. Extract all of the @@ -2397,7 +2418,7 @@ EmitAggregate(tree_value, *DestLoc); } else { // Scalar value. Evaluate to a register, then do the store. - Value *V = EmitGimpleReg(tree_value); + Value *V = EmitRegister(tree_value); Value *Ptr = Builder.CreateBitCast(DestLoc->Ptr, PointerType::getUnqual(V->getType())); StoreInst *St = Builder.CreateStore(V, Ptr, DestLoc->Volatile); @@ -2414,7 +2435,7 @@ Value *Result = 0; switch (TREE_CODE(rhs)) { - default: Result = EmitGimpleReg(rhs); break; + default: Result = EmitRegister(rhs); break; // Exception handling. //FIXME case EXC_PTR_EXPR: Result = EmitEXC_PTR_EXPR(rhs); break; @@ -2586,7 +2607,7 @@ && "Not calling a function pointer?"); tree function_type = TREE_TYPE(TREE_TYPE (call_expr)); - Value *Callee = EmitGimpleReg(call_expr); + Value *Callee = EmitRegister(call_expr); CallingConv::ID CallingConv; AttrListPtr PAL; @@ -2938,7 +2959,7 @@ // Pass the static chain, if any, as the first parameter. if (gimple_call_chain(stmt)) - CallOperands.push_back(EmitGimpleReg(gimple_call_chain(stmt))); + CallOperands.push_back(EmitRegister(gimple_call_chain(stmt))); // Loop over the arguments, expanding them and adding them to the op list. std::vector ScalarArgs; @@ -2950,7 +2971,7 @@ // Push the argument. if (ArgTy->isSingleValueType()) { // A scalar - push the value. - Client.pushValue(EmitGimpleReg(arg)); + Client.pushValue(EmitRegister(arg)); } else if (LLVM_SHOULD_PASS_AGGREGATE_AS_FCA(type, ArgTy)) { if (AGGREGATE_TYPE_P(type)) { // Pass the aggregate as a first class value. @@ -2958,7 +2979,7 @@ Client.pushValue(Builder.CreateLoad(ArgVal.Ptr)); } else { // Already first class (eg: a complex number) - push the value. - Client.pushValue(EmitGimpleReg(arg)); + Client.pushValue(EmitRegister(arg)); } } else { if (AGGREGATE_TYPE_P(type)) { @@ -2970,7 +2991,7 @@ // A first class value (eg: a complex number). Push the address of a // temporary copy. Value *Copy = CreateTemporary(ArgTy); - Builder.CreateStore(EmitGimpleReg(arg), Copy); + Builder.CreateStore(EmitRegister(arg), Copy); Client.pushAddress(Copy); } } @@ -3069,18 +3090,18 @@ bool ExpIsSigned = !TYPE_UNSIGNED(type); // Scalar to scalar copy. assert(!AGGREGATE_TYPE_P(TREE_TYPE(op)) && "Aggregate to scalar nop_expr!"); - return CastToAnyType(EmitGimpleReg(op), OpIsSigned, Ty, ExpIsSigned); + return CastToAnyType(EmitRegister(op), OpIsSigned, Ty, ExpIsSigned); } Value *TreeToLLVM::EmitCONVERT_EXPR(tree type, tree op) { bool OpIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op)); bool ExpIsSigned = !TYPE_UNSIGNED(type); - return CastToAnyType(EmitGimpleReg(op), OpIsSigned, ConvertType(type), + return CastToAnyType(EmitRegister(op), OpIsSigned, ConvertType(type), ExpIsSigned); } Value *TreeToLLVM::EmitNEGATE_EXPR(tree op) { - Value *V = EmitGimpleReg(op); + Value *V = EmitRegister(op); if (TREE_CODE(TREE_TYPE(op)) != COMPLEX_TYPE) { if (V->getType()->isFPOrFPVector()) @@ -3104,7 +3125,7 @@ Value *TreeToLLVM::EmitCONJ_EXPR(tree op) { // ~(a+ib) = a + i*-b Value *R, *I; - SplitComplex(EmitGimpleReg(op), R, I); + SplitComplex(EmitRegister(op), R, I); if (I->getType()->isFloatingPoint()) I = Builder.CreateFNeg(I); else @@ -3113,7 +3134,7 @@ } Value *TreeToLLVM::EmitABS_EXPR(tree op) { - Value *Op = EmitGimpleReg(op); + Value *Op = EmitRegister(op); if (!Op->getType()->isFloatingPoint()) { Value *OpN = Builder.CreateNeg(Op, (Op->getNameStr()+"neg").c_str()); ICmpInst::Predicate pred = TYPE_UNSIGNED(TREE_TYPE(op)) ? @@ -3157,12 +3178,12 @@ } Value *TreeToLLVM::EmitBIT_NOT_EXPR(tree op) { - Value *Op = EmitGimpleReg(op); + Value *Op = EmitRegister(op); return Builder.CreateNot(Op, (Op->getNameStr()+"not").c_str()); } Value *TreeToLLVM::EmitTRUTH_NOT_EXPR(tree type, tree op) { - Value *V = EmitGimpleReg(op); + Value *V = EmitRegister(op); if (V->getType() != Type::getInt1Ty(Context)) V = Builder.CreateICmpNE(V, Constant::getNullValue(V->getType()), "toBool"); @@ -3173,8 +3194,8 @@ /// EmitCompare - Compare LHS with RHS using the appropriate comparison code. /// The result is an i1 boolean. Value *TreeToLLVM::EmitCompare(tree lhs, tree rhs, tree_code code) { - Value *LHS = EmitGimpleReg(lhs); - Value *RHS = Builder.CreateBitCast(EmitGimpleReg(rhs), LHS->getType()); + Value *LHS = EmitRegister(lhs); + Value *RHS = Builder.CreateBitCast(EmitRegister(rhs), LHS->getType()); // Compute the LLVM opcodes corresponding to the GCC comparison. CmpInst::Predicate UIPred = CmpInst::BAD_ICMP_PREDICATE; @@ -3262,8 +3283,8 @@ if (TREE_CODE(type) == COMPLEX_TYPE) return EmitComplexBinOp(type, code, op0, op1); - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); // GCC has no problem with things like "xor uint X, int 17", and X-Y, where // X and Y are pointer types, but the result is an integer. As such, convert @@ -3305,8 +3326,8 @@ } Value *TreeToLLVM::EmitTruthOp(tree type, tree op0, tree op1, unsigned Opc) { - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); // This is a truth operation like the strict &&,||,^^. Convert to bool as // a test against zero @@ -3323,8 +3344,8 @@ Value *TreeToLLVM::EmitShiftOp(tree op0, tree op1, unsigned Opc) { - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); if (RHS->getType() != LHS->getType()) RHS = Builder.CreateIntCast(RHS, LHS->getType(), /*isSigned*/false, (RHS->getNameStr()+".cast").c_str()); @@ -3334,8 +3355,8 @@ Value *TreeToLLVM::EmitRotateOp(tree type, tree op0, tree op1, unsigned Opc1, unsigned Opc2) { - Value *In = EmitGimpleReg(op0); - Value *Amt = EmitGimpleReg(op1); + Value *In = EmitRegister(op0); + Value *Amt = EmitRegister(op1); if (Amt->getType() != In->getType()) Amt = Builder.CreateIntCast(Amt, In->getType(), /*isSigned*/false, @@ -3358,8 +3379,8 @@ Value *TreeToLLVM::EmitMinMaxExpr(tree type, tree op0, tree op1, unsigned UIPred, unsigned SIPred, unsigned FPPred, bool isMax) { - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); const Type *Ty = ConvertType(type); @@ -3400,8 +3421,8 @@ const Type *Ty = ConvertType(type); Constant *Zero = ConstantInt::get(Ty, 0); - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); // The two possible values for Mod. Value *Rem = Builder.CreateSRem(LHS, RHS, "rem"); @@ -3433,8 +3454,8 @@ Constant *One = ConstantInt::get(Ty, 1); Constant *MinusOne = Constant::getAllOnesValue(Ty); - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); if (!TYPE_UNSIGNED(type)) { // In the case of signed arithmetic, we calculate CDiv as follows: @@ -3486,8 +3507,8 @@ Value *TreeToLLVM::EmitFLOOR_DIV_EXPR(tree type, tree op0, tree op1) { // Notation: FLOOR_DIV_EXPR <-> FDiv, TRUNC_DIV_EXPR <-> Div. - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); // FDiv calculates LHS/RHS by rounding down to the nearest integer. In terms // of Div this means if the values of LHS and RHS have the same sign or if LHS @@ -3550,8 +3571,8 @@ Constant *Zero = ConstantInt::get(Ty, 0); Constant *Two = ConstantInt::get(Ty, 2); - Value *LHS = EmitGimpleReg(op0); - Value *RHS = EmitGimpleReg(op1); + Value *LHS = EmitRegister(op0); + Value *RHS = EmitRegister(op1); if (!TYPE_UNSIGNED(type)) { // In the case of signed arithmetic, we calculate RDiv as follows: @@ -3619,8 +3640,8 @@ } Value *TreeToLLVM::EmitPOINTER_PLUS_EXPR(tree type, tree op0, tree op1) { - Value *Ptr = EmitGimpleReg(op0); // The pointer. - Value *Idx = EmitGimpleReg(op1); // The offset in bytes. + Value *Ptr = EmitRegister(op0); // The pointer. + Value *Idx = EmitRegister(op1); // The offset in bytes. // Convert the pointer into an i8* and add the offset to it. Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); @@ -3633,7 +3654,7 @@ Value *TreeToLLVM::EmitPAREN_EXPR(tree op) { // TODO: Understand and correctly deal with this subtle expression. - return EmitGimpleReg(op); + return EmitRegister(op); } @@ -4191,7 +4212,7 @@ EmitAggregate(OpVal, OpLoc); Operands.push_back(Builder.CreateLoad(OpLoc.Ptr)); } else { - Operands.push_back(EmitGimpleReg(OpVal)); + Operands.push_back(EmitRegister(OpVal)); } } @@ -4224,8 +4245,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4249,9 +4270,9 @@ TreeToLLVM::BuildCmpAndSwapAtomicBuiltin(gimple stmt, tree type, bool isBool) { const Type *ResultTy = ConvertType(type); Value* C[3] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)), - EmitGimpleReg(gimple_call_arg(stmt, 2)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)), + EmitRegister(gimple_call_arg(stmt, 2)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4398,8 +4419,8 @@ } Value* Args[] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; // Grab the current return type. @@ -4423,7 +4444,7 @@ case BUILT_IN_CLZ: // These GCC builtins always return int. case BUILT_IN_CLZL: case BUILT_IN_CLZLL: { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctlz); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4435,7 +4456,7 @@ case BUILT_IN_CTZ: // These GCC builtins always return int. case BUILT_IN_CTZL: case BUILT_IN_CTZLL: { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::cttz); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4447,7 +4468,7 @@ case BUILT_IN_PARITYLL: case BUILT_IN_PARITYL: case BUILT_IN_PARITY: { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctpop); Result = Builder.CreateBinOp(Instruction::And, Result, ConstantInt::get(Result->getType(), 1)); @@ -4456,7 +4477,7 @@ case BUILT_IN_POPCOUNT: // These GCC builtins always return int. case BUILT_IN_POPCOUNTL: case BUILT_IN_POPCOUNTLL: { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::ctpop); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4467,7 +4488,7 @@ } case BUILT_IN_BSWAP32: case BUILT_IN_BSWAP64: { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::bswap); tree return_type = gimple_call_return_type(stmt); const Type *DestTy = ConvertType(return_type); @@ -4503,7 +4524,7 @@ case BUILT_IN_LOGL: // If errno math has been disabled, expand these to llvm.log calls. if (!flag_errno_math) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4514,7 +4535,7 @@ case BUILT_IN_LOG2L: // If errno math has been disabled, expand these to llvm.log2 calls. if (!flag_errno_math) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log2); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4525,7 +4546,7 @@ case BUILT_IN_LOG10L: // If errno math has been disabled, expand these to llvm.log10 calls. if (!flag_errno_math) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::log10); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4536,7 +4557,7 @@ case BUILT_IN_EXPL: // If errno math has been disabled, expand these to llvm.exp calls. if (!flag_errno_math) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::exp); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4547,7 +4568,7 @@ case BUILT_IN_EXP2L: // If errno math has been disabled, expand these to llvm.exp2 calls. if (!flag_errno_math) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::exp2); Result = CastToFPType(Result, ConvertType(gimple_call_return_type(stmt))); return true; @@ -4558,7 +4579,7 @@ case BUILT_IN_FFSLL: { // FFS(X) -> (x == 0 ? 0 : CTTZ(x)+1) // The argument and return type of cttz should match the argument type of // the ffs, but should ignore the return type of ffs. - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); EmitBuiltinUnaryOp(Amt, Result, Intrinsic::cttz); Result = Builder.CreateAdd(Result, ConstantInt::get(Result->getType(), 1)); @@ -4599,9 +4620,9 @@ //TODO //TODO // Get arguments. //TODO tree arglist = CALL_EXPR_ARGS(stmt); -//TODO Value *ExprVal = EmitGimpleReg(gimple_call_arg(stmt, 0)); +//TODO Value *ExprVal = EmitRegister(gimple_call_arg(stmt, 0)); //TODO const Type *Ty = ExprVal->getType(); -//TODO Value *StrVal = EmitGimpleReg(gimple_call_arg(stmt, 1)); +//TODO Value *StrVal = EmitRegister(gimple_call_arg(stmt, 1)); //TODO //TODO SmallVector Args; //TODO Args.push_back(ExprVal); @@ -4762,8 +4783,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4802,8 +4823,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4842,8 +4863,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4882,8 +4903,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4922,8 +4943,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -4962,8 +4983,8 @@ tree return_type = gimple_call_return_type(stmt); const Type *ResultTy = ConvertType(return_type); Value* C[2] = { - EmitGimpleReg(gimple_call_arg(stmt, 0)), - EmitGimpleReg(gimple_call_arg(stmt, 1)) + EmitRegister(gimple_call_arg(stmt, 0)), + EmitRegister(gimple_call_arg(stmt, 1)) }; const Type* Ty[2]; Ty[0] = ResultTy; @@ -5015,7 +5036,7 @@ case BUILT_IN_LOCK_RELEASE_8: Ty = Type::getInt64Ty(Context); break; } - Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Ptr = EmitRegister(gimple_call_arg(stmt, 0)); Ptr = Builder.CreateBitCast(Ptr, Ty->getPointerTo()); Builder.CreateStore(Constant::getNullValue(Ty), Ptr, true); Result = 0; @@ -5031,7 +5052,7 @@ tree value = gimple_call_arg(stmt, 1); if (TREE_CODE(value) != INTEGER_CST || - cast(EmitGimpleReg(value))->getValue() != 1) { + cast(EmitRegister(value))->getValue() != 1) { error ("%<__builtin_longjmp%> second argument must be 1"); return false; } @@ -5075,7 +5096,7 @@ } Value *TreeToLLVM::EmitBuiltinSQRT(gimple stmt) { - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); const Type* Ty = Amt->getType(); return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -5087,8 +5108,8 @@ if (!validate_gimple_arglist(stmt, REAL_TYPE, INTEGER_TYPE, VOID_TYPE)) return 0; - Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 0)); - Value *Pow = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Val = EmitRegister(gimple_call_arg(stmt, 0)); + Value *Pow = EmitRegister(gimple_call_arg(stmt, 1)); const Type *Ty = Val->getType(); Pow = Builder.CreateIntCast(Pow, Type::getInt32Ty(Context), /*isSigned*/true); @@ -5104,8 +5125,8 @@ if (!validate_gimple_arglist(stmt, REAL_TYPE, REAL_TYPE, VOID_TYPE)) return 0; - Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 0)); - Value *Pow = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Val = EmitRegister(gimple_call_arg(stmt, 0)); + Value *Pow = EmitRegister(gimple_call_arg(stmt, 1)); const Type *Ty = Val->getType(); SmallVector Args; @@ -5123,7 +5144,7 @@ bool TreeToLLVM::EmitBuiltinExtendPointer(gimple stmt, Value *&Result) { tree arg0 = gimple_call_arg(stmt, 0); - Value *Amt = EmitGimpleReg(arg0); + Value *Amt = EmitRegister(arg0); bool AmtIsSigned = !TYPE_UNSIGNED(TREE_TYPE(arg0)); bool ExpIsSigned = !TYPE_UNSIGNED(gimple_call_return_type(stmt)); Result = CastToAnyType(Amt, AmtIsSigned, @@ -5179,12 +5200,12 @@ unsigned SrcAlign = getPointerAlignment(Src); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = EmitGimpleReg(Dst); - Value *SrcV = EmitGimpleReg(Src); - Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 2)); + Value *DstV = EmitRegister(Dst); + Value *SrcV = EmitRegister(Src); + Value *Len = EmitRegister(gimple_call_arg(stmt, 2)); if (SizeCheck) { tree SizeArg = gimple_call_arg(stmt, 3); - Value *Size = EmitGimpleReg(SizeArg); + Value *Size = EmitRegister(SizeArg); if (!OptimizeIntoPlainBuiltIn(stmt, Len, Size)) return false; } @@ -5209,12 +5230,12 @@ tree Dst = gimple_call_arg(stmt, 0); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = EmitGimpleReg(Dst); - Value *Val = EmitGimpleReg(gimple_call_arg(stmt, 1)); - Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 2)); + Value *DstV = EmitRegister(Dst); + Value *Val = EmitRegister(gimple_call_arg(stmt, 1)); + Value *Len = EmitRegister(gimple_call_arg(stmt, 2)); if (SizeCheck) { tree SizeArg = gimple_call_arg(stmt, 3); - Value *Size = EmitGimpleReg(SizeArg); + Value *Size = EmitRegister(SizeArg); if (!OptimizeIntoPlainBuiltIn(stmt, Len, Size)) return false; } @@ -5229,9 +5250,9 @@ tree Dst = gimple_call_arg(stmt, 0); unsigned DstAlign = getPointerAlignment(Dst); - Value *DstV = EmitGimpleReg(Dst); + Value *DstV = EmitRegister(Dst); Value *Val = Constant::getNullValue(Type::getInt32Ty(Context)); - Value *Len = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Len = EmitRegister(gimple_call_arg(stmt, 1)); EmitMemSet(DstV, Val, Len, DstAlign); return true; } @@ -5240,12 +5261,12 @@ if (!validate_gimple_arglist(stmt, POINTER_TYPE, 0)) return false; - Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Ptr = EmitRegister(gimple_call_arg(stmt, 0)); Value *ReadWrite = 0; Value *Locality = 0; if (gimple_call_num_args(stmt) > 1) { // Args 1/2 are optional - ReadWrite = EmitGimpleReg(gimple_call_arg(stmt, 1)); + ReadWrite = EmitRegister(gimple_call_arg(stmt, 1)); if (!isa(ReadWrite)) { error("second argument to %<__builtin_prefetch%> must be a constant"); ReadWrite = 0; @@ -5260,7 +5281,7 @@ } if (gimple_call_num_args(stmt) > 2) { - Locality = EmitGimpleReg(gimple_call_arg(stmt, 2)); + Locality = EmitRegister(gimple_call_arg(stmt, 2)); if (!isa(Locality)) { error("third argument to %<__builtin_prefetch%> must be a constant"); Locality = 0; @@ -5297,7 +5318,7 @@ return false; ConstantInt *Level = - dyn_cast(EmitGimpleReg(gimple_call_arg(stmt, 0))); + dyn_cast(EmitRegister(gimple_call_arg(stmt, 0))); if (!Level) { if (isFrame) error("invalid argument to %<__builtin_frame_address%>"); @@ -5315,7 +5336,7 @@ } bool TreeToLLVM::EmitBuiltinExtractReturnAddr(gimple stmt, Value *&Result) { - Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Ptr = EmitRegister(gimple_call_arg(stmt, 0)); // FIXME: Actually we should do something like this: // @@ -5330,7 +5351,7 @@ } bool TreeToLLVM::EmitBuiltinFrobReturnAddr(gimple stmt, Value *&Result) { - Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Ptr = EmitRegister(gimple_call_arg(stmt, 0)); // FIXME: Actually we should do something like this: // @@ -5435,8 +5456,8 @@ return false; const Type *IntPtr = TD.getIntPtrType(Context); - Value *Offset = EmitGimpleReg(gimple_call_arg(stmt, 0)); - Value *Handler = EmitGimpleReg(gimple_call_arg(stmt, 1)); + Value *Offset = EmitRegister(gimple_call_arg(stmt, 0)); + Value *Handler = EmitRegister(gimple_call_arg(stmt, 1)); Intrinsic::ID IID = (IntPtr == Type::getInt32Ty(Context) ? Intrinsic::eh_return_i32 : Intrinsic::eh_return_i64); @@ -5470,7 +5491,7 @@ } Value *Addr = - Builder.CreateBitCast(EmitGimpleReg(gimple_call_arg(stmt, 0)), + Builder.CreateBitCast(EmitRegister(gimple_call_arg(stmt, 0)), Type::getInt8PtrTy(Context)); Constant *Size, *Idx; @@ -5535,7 +5556,7 @@ if (!validate_gimple_arglist(stmt, POINTER_TYPE, VOID_TYPE)) return false; - Value *Ptr = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Ptr = EmitRegister(gimple_call_arg(stmt, 0)); Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, @@ -5547,7 +5568,7 @@ bool TreeToLLVM::EmitBuiltinAlloca(gimple stmt, Value *&Result) { if (!validate_gimple_arglist(stmt, INTEGER_TYPE, VOID_TYPE)) return false; - Value *Amt = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Amt = EmitRegister(gimple_call_arg(stmt, 0)); Amt = Builder.CreateIntCast(Amt, Type::getInt32Ty(Context), /*isSigned*/true); Result = Builder.CreateAlloca(Type::getInt8Ty(Context), Amt); return true; @@ -5558,7 +5579,7 @@ // optimal. Result = gimple_call_num_args(stmt) < 2 ? Constant::getNullValue(ConvertType(gimple_call_return_type(stmt))) : - EmitGimpleReg(gimple_call_arg(stmt, 0)); + EmitRegister(gimple_call_arg(stmt, 0)); return true; } @@ -5577,14 +5598,14 @@ } Constant *va_start = Intrinsic::getDeclaration(TheModule, Intrinsic::vastart); - Value *ArgVal = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *ArgVal = EmitRegister(gimple_call_arg(stmt, 0)); ArgVal = Builder.CreateBitCast(ArgVal, Type::getInt8PtrTy(Context)); Builder.CreateCall(va_start, ArgVal); return true; } bool TreeToLLVM::EmitBuiltinVAEnd(gimple stmt) { - Value *Arg = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Arg = EmitRegister(gimple_call_arg(stmt, 0)); Arg = Builder.CreateBitCast(Arg, Type::getInt8PtrTy(Context)); Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::vaend), Arg); @@ -5595,19 +5616,19 @@ tree Arg1T = gimple_call_arg(stmt, 0); tree Arg2T = gimple_call_arg(stmt, 1); - Value *Arg1 = EmitGimpleReg(Arg1T); // Emit the address of the destination. + Value *Arg1 = EmitRegister(Arg1T); // Emit the address of the destination. // The second arg of llvm.va_copy is a pointer to a valist. Value *Arg2; if (!AGGREGATE_TYPE_P(va_list_type_node)) { // Emit it as a value, then store it to a temporary slot. - Value *V2 = EmitGimpleReg(Arg2T); + Value *V2 = EmitRegister(Arg2T); Arg2 = CreateTemporary(V2->getType()); Builder.CreateStore(V2, Arg2); } else { // If the target has aggregate valists, then the second argument // from GCC is the address of the source valist and we don't // need to do anything special. - Arg2 = EmitGimpleReg(Arg2T); + Arg2 = EmitRegister(Arg2T); } static const Type *VPTy = Type::getInt8PtrTy(Context); @@ -5632,7 +5653,7 @@ // allocated for the trampoline - load it out and return it. assert(TD.getPointerSize() <= TRAMPOLINE_SIZE && "Trampoline smaller than a pointer!"); - Value *Tramp = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Tramp = EmitRegister(gimple_call_arg(stmt, 0)); Tramp = Builder.CreateBitCast(Tramp, ResultTy->getPointerTo()); Result = Builder.CreateLoad(Tramp, "adjusted"); @@ -5668,8 +5689,8 @@ TrampTmp->setAlignment(TRAMPOLINE_ALIGNMENT); TrampTmp->setName("TRAMP"); - Value *Func = EmitGimpleReg(gimple_call_arg(stmt, 1)); - Value *Chain = EmitGimpleReg(gimple_call_arg(stmt, 2)); + Value *Func = EmitRegister(gimple_call_arg(stmt, 1)); + Value *Chain = EmitRegister(gimple_call_arg(stmt, 2)); Value *Ops[3] = { Builder.CreateBitCast(TrampTmp, VPTy), @@ -5684,7 +5705,7 @@ // Store the llvm.init.trampoline result to the GCC trampoline storage. assert(TD.getPointerSize() <= TRAMPOLINE_SIZE && "Trampoline smaller than a pointer!"); - Value *Tramp = EmitGimpleReg(gimple_call_arg(stmt, 0)); + Value *Tramp = EmitRegister(gimple_call_arg(stmt, 0)); Tramp = Builder.CreateBitCast(Tramp, Adjusted->getType()->getPointerTo()); StoreInst *Store = Builder.CreateStore(Adjusted, Tramp); @@ -5721,7 +5742,7 @@ } Value *TreeToLLVM::EmitCOMPLEX_EXPR(tree op0, tree op1) { - return CreateComplex(EmitGimpleReg(op0), EmitGimpleReg(op1)); + return CreateComplex(EmitRegister(op0), EmitRegister(op1)); } // EmitComplexBinOp - Note that this operates on binops like ==/!=, which return @@ -5729,9 +5750,9 @@ Value *TreeToLLVM::EmitComplexBinOp(tree type, tree_code code, tree op0, tree op1) { Value *LHSr, *LHSi; - SplitComplex(EmitGimpleReg(op0), LHSr, LHSi); + SplitComplex(EmitRegister(op0), LHSr, LHSi); Value *RHSr, *RHSi; - SplitComplex(EmitGimpleReg(op1), RHSr, RHSi); + SplitComplex(EmitRegister(op1), RHSr, RHSi); Value *DSTr, *DSTi; switch (code) { @@ -5880,12 +5901,12 @@ unsigned ArrayAlign; // First subtract the lower bound, if any, in the type of the index. - Value *IndexVal = EmitGimpleReg(Index); + Value *IndexVal = EmitRegister(Index); tree LowerBound = array_ref_low_bound(exp); if (!integer_zerop(LowerBound)) IndexVal = TYPE_UNSIGNED(TREE_TYPE(Index)) ? - Builder.CreateSub(IndexVal, EmitGimpleReg(LowerBound)) : - Builder.CreateNSWSub(IndexVal, EmitGimpleReg(LowerBound)); + Builder.CreateSub(IndexVal, EmitRegister(LowerBound)) : + Builder.CreateNSWSub(IndexVal, EmitRegister(LowerBound)); LValue ArrayAddrLV = EmitLV(Array); assert(!ArrayAddrLV.isBitfield() && "Arrays cannot be bitfields!"); @@ -5928,7 +5949,7 @@ assert(TREE_OPERAND(exp, 3) && "Size missing for variable sized element!"); // ScaleFactor is the size of the element type in units divided by (exactly) // TYPE_ALIGN_UNIT(ElementType). - Value *ScaleFactor = Builder.CreateIntCast(EmitGimpleReg(TREE_OPERAND(exp, 3)), + Value *ScaleFactor = Builder.CreateIntCast(EmitRegister(TREE_OPERAND(exp, 3)), IntPtrTy, /*isSigned*/false); assert(isPowerOf2_32(TYPE_ALIGN(ElementType)) && "Alignment not a power of two!"); @@ -6061,7 +6082,7 @@ assert(!(BITS_PER_UNIT & 7) && "Unit size not a multiple of 8 bits!"); if (TREE_OPERAND(exp, 2)) { - Offset = EmitGimpleReg(TREE_OPERAND(exp, 2)); + Offset = EmitRegister(TREE_OPERAND(exp, 2)); // At this point the offset is measured in units divided by (exactly) // (DECL_OFFSET_ALIGN / BITS_PER_UNIT). Convert to octets. unsigned factor = DECL_OFFSET_ALIGN(FieldDecl) / 8; @@ -6070,7 +6091,7 @@ ConstantInt::get(Offset->getType(), factor)); } else { assert(DECL_FIELD_OFFSET(FieldDecl) && "Field offset not available!"); - Offset = EmitGimpleReg(DECL_FIELD_OFFSET(FieldDecl)); + Offset = EmitRegister(DECL_FIELD_OFFSET(FieldDecl)); // At this point the offset is measured in units. Convert to octets. unsigned factor = BITS_PER_UNIT / 8; if (factor != 1) @@ -6290,7 +6311,7 @@ LValue TreeToLLVM::EmitLV_INDIRECT_REF(tree exp) { // The lvalue is just the address. - LValue LV = LValue(EmitGimpleReg(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); + LValue LV = LValue(EmitRegister(TREE_OPERAND(exp, 0)), expr_align(exp) / 8); // May need a useless type conversion (useless_type_conversion_p), for example // when INDIRECT_REF is applied to a void*, resulting in a non-void type. LV.Ptr = Builder.CreateBitCast(LV.Ptr, @@ -6579,7 +6600,7 @@ // should be a bit in the label identifying it as in an asm. Op = getLabelDeclBlock(TREE_OPERAND(Val, 0)); } else - Op = EmitGimpleReg(Val); + Op = EmitRegister(Val); } else { LValue LV = EmitLV(Val); assert(!LV.isBitfield() && "Inline asm can't have bitfield operand"); @@ -6839,7 +6860,7 @@ // Indirect branch. basic_block source = gimple_bb(stmt); - IndirectBrInst *Br = Builder.CreateIndirectBr(EmitGimpleReg(dest), + IndirectBrInst *Br = Builder.CreateIndirectBr(EmitRegister(dest), EDGE_COUNT(source->succs)); // Add the list of possible destinations. @@ -6883,7 +6904,7 @@ MemRef DestLoc(DECL_LOCAL(result), 1, false); // FIXME: What alignment? EmitAggregate(retval, DestLoc); } else { - Value *Val = Builder.CreateBitCast(EmitGimpleReg(retval), + Value *Val = Builder.CreateBitCast(EmitRegister(retval), ConvertType(TREE_TYPE(result))); Builder.CreateStore(Val, DECL_LOCAL(result)); } @@ -6895,7 +6916,7 @@ void TreeToLLVM::RenderGIMPLE_SWITCH(gimple stmt) { // Emit the condition. - Value *Index = EmitGimpleReg(gimple_switch_index(stmt)); + Value *Index = EmitRegister(gimple_switch_index(stmt)); bool IndexIsSigned = !TYPE_UNSIGNED(TREE_TYPE(gimple_switch_index(stmt))); // Create the switch instruction. @@ -6910,7 +6931,7 @@ BasicBlock *Dest = getLabelDeclBlock(CASE_LABEL(label)); // Convert the integer to the right type. - Value *Val = EmitGimpleReg(CASE_LOW(label)); + Value *Val = EmitRegister(CASE_LOW(label)); Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(CASE_LOW(label))), Index->getType(), IndexIsSigned); ConstantInt *LowC = cast(Val); @@ -6921,7 +6942,7 @@ } // Otherwise, we have a range, like 'case 1 ... 17'. - Val = EmitGimpleReg(CASE_HIGH(label)); + Val = EmitRegister(CASE_HIGH(label)); // Make sure the case value is the same type as the switch expression Val = CastToAnyType(Val, !TYPE_UNSIGNED(TREE_TYPE(CASE_HIGH(label))), Index->getType(), IndexIsSigned); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=90317&r1=90316&r2=90317&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Wed Dec 2 07:11:59 2009 @@ -526,34 +526,21 @@ /// Only creates code in the entry block. Value *EmitSSA_NAME(tree_node *reg); - /// EmitGimpleInvariantAddress - The given address is constant in this - /// function. Return the corresponding LLVM value. Only creates code in - /// the entry block. - Value *EmitGimpleInvariantAddress(tree_node *addr); - - /// EmitGimpleConstant - Convert the given global constant of register type to - /// an LLVM constant. Creates no code, only constants. - Constant *EmitGimpleConstant(tree_node *reg); - - /// EmitGimpleMinInvariant - The given value is constant in this function. + /// EmitInvariantAddress - The given address is constant in this function. /// Return the corresponding LLVM value. Only creates code in the entry block. - Value *EmitGimpleMinInvariant(tree_node *reg) { - Value *V = (TREE_CODE(reg) == ADDR_EXPR) ? - EmitGimpleInvariantAddress(reg) : EmitGimpleConstant(reg); - assert(V->getType() == ConvertType(TREE_TYPE(reg)) && - "Gimple min invariant has wrong type!"); - return V; - } + Value *EmitInvariantAddress(tree_node *addr); + + /// EmitRegisterConstant - Convert the given global constant of register type + /// to an LLVM constant. Creates no code, only constants. + Constant *EmitRegisterConstant(tree_node *reg); - /// EmitGimpleReg - Convert the specified gimple register or local constant of + /// EmitMinInvariant - The given value is constant in this function. Return + /// the corresponding LLVM value. Only creates code in the entry block. + Value *EmitMinInvariant(tree_node *reg); + + /// EmitRegister - Convert the specified gimple register or local constant of /// register type to an LLVM value. Only creates code in the entry block. - Value *EmitGimpleReg(tree_node *reg) { - Value *V = (TREE_CODE(reg) == SSA_NAME) ? - EmitSSA_NAME(reg) : EmitGimpleMinInvariant(reg); - assert(V->getType() == ConvertType(TREE_TYPE(reg)) && - "Gimple register has wrong type!"); - return V; - } + Value *EmitRegister(tree_node *reg); /// EmitBlock - Add the specified basic block to the end of the function. If /// the previous block falls through into it, add an explicit branch. @@ -611,8 +598,6 @@ /// static bool isNoopCast(Value *V, const Type *Ty); - void HandleMultiplyDefinedGimpleTemporary(tree_node *var); - /// EmitAnnotateIntrinsic - Emits call to annotate attr intrinsic void EmitAnnotateIntrinsic(Value *V, tree_node *decl); From baldrick at free.fr Wed Dec 2 07:42:20 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 14:42:20 +0100 Subject: [llvm-commits] [llvm] r86840 - in /llvm/trunk: include/llvm/IntrinsicInst.h lib/Transforms/Utils/Local.cpp test/Transforms/InstCombine/invariant.ll In-Reply-To: <92E3CFF2-F830-4826-BDCF-5EF745AA4904@apple.com> References: <200911111534.nABFYEd0025670@zion.cs.uiuc.edu> <92E3CFF2-F830-4826-BDCF-5EF745AA4904@apple.com> Message-ID: <4B166EBC.8060808@free.fr> Hi Chris, >> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Nov 11 09:34:13 2009 >> @@ -252,6 +252,9 @@ >> // We don't want debug info removed by anything this general. >> if (isa(I)) return false; >> >> + // Likewise for memory use markers. >> + if (isa(I)) return false; > > Is this still needed? I thought that it turns out that these intrinsics need to be marked as having side effects after all? this is only needed for llvm.invariant.start, which is readonly. That makes some sense because if it wasn't readonly then passes that are not llvm.invariant aware might think it stomps on the values being declared invariant. Another possibility is to have it be marked as writing memory like the others, and teach every possible place that it doesn't do anything bad. Ciao, Duncan. From baldrick at free.fr Wed Dec 2 07:45:36 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 14:45:36 +0100 Subject: [llvm-commits] [llvm] r90199 - /llvm/trunk/include/llvm/IntrinsicsX86.td In-Reply-To: <812D35AA-0BFB-4B0D-97F9-252061AFE654@apple.com> References: <200912010318.nB13IQK0009959@zion.cs.uiuc.edu> <4B14D8DF.1050600@free.fr> <812D35AA-0BFB-4B0D-97F9-252061AFE654@apple.com> Message-ID: <4B166F80.5040709@free.fr> Hi Chris, > I'm not worried about the CBE here, the goal is to eliminate the > intrinsic completely and use a shuffle. fair enough. However it does still see more logical to me to let the custom front-end lowering code inspect builtins first, and only do automatic mapping to llvm intrinsics second. Not a priority for anyone though I suppose :) Ciao, Duncan. From dpatel at apple.com Wed Dec 2 09:25:16 2009 From: dpatel at apple.com (Devang Patel) Date: Wed, 02 Dec 2009 15:25:16 -0000 Subject: [llvm-commits] [llvm] r90318 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DIE.h DwarfDebug.cpp Message-ID: <200912021525.nB2FPGZs017570@zion.cs.uiuc.edu> Author: dpatel Date: Wed Dec 2 09:25:16 2009 New Revision: 90318 URL: http://llvm.org/viewvc/llvm-project?rev=90318&view=rev Log: Clarify that DIEString does not keep a copy of the string. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=90318&r1=90317&r2=90318&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Wed Dec 2 09:25:16 2009 @@ -274,7 +274,7 @@ }; //===--------------------------------------------------------------------===// - /// DIEString - A string value DIE. + /// DIEString - A string value DIE. This DIE keeps string reference only. /// class DIEString : public DIEValue { const StringRef Str; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=90318&r1=90317&r2=90318&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Dec 2 09:25:16 2009 @@ -330,8 +330,8 @@ Die->addValue(Attribute, Form, Value); } -/// addString - Add a string attribute data and value. -/// +/// addString - Add a string attribute data and value. DIEString only +/// keeps string reference. void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form, const StringRef String) { DIEValue *Value = new DIEString(String); From espindola at google.com Wed Dec 2 09:27:14 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 2 Dec 2009 10:27:14 -0500 Subject: [llvm-commits] [patch] Implement no-canonical-prefixes. In-Reply-To: <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> Message-ID: <38a0d8450912020727r1cef56a8r462373f183957922@mail.gmail.com> 2009/12/1 Chandler Carruth : > This needs to be updated after Duncan's refactoring of the driver... > Is it still relevant? Some parts of the driver now explicitly mention > preserving symlinks. An updated patch is attached. It is still relevant. For example, create a symlink Debug2 -> Debug and run: $ ./Debug2/bin/clang -no-canonical-prefixes -c -v test.c 2>&1 | grep clang-cc "./Debug2/bin/clang-cc" -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -munwind-tables -mcpu x86-64 -v -fmessage-length 0 -fgnu-runtime -fdiagnostics-show-option -o /tmp/cc-N0vEJy.s -x c test.c $ ./Debug2/bin/clang -c -v test.c 2>&1 | grep clang-cc "/usr/local/google/home/espindola/llvm/build/Debug/bin/clang-cc" -triple x86_64-unknown-linux-gnu -S -disable-free -main-file-name test.c -mrelocation-model static -mdisable-fp-elim -munwind-tables -mcpu x86-64 -v -fmessage-length 0 -fgnu-runtime -fdiagnostics-show-option -o /tmp/cc-pIwcRJ.s -x c test.c clang-cc version 1.1 based upon llvm 2.7svn hosted on x86_64-unknown-linux-gnu Note that with -no-canonical-prefixes we use ./Debug2/bin-clang-cc and without it we use /usr/local/google/home/espindola/llvm/build/Debug/bin/clang-cc. I am not sure why someone would ever want to use the canonical path, but this behavior is consistent with how gcc finds cc1. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: no-canonical-prefixes.patch Type: text/x-diff Size: 2655 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091202/581de697/attachment.bin From benny.kra at googlemail.com Wed Dec 2 09:33:44 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Wed, 02 Dec 2009 15:33:44 -0000 Subject: [llvm-commits] [llvm] r90319 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200912021533.nB2FXiZc017877@zion.cs.uiuc.edu> Author: d0k Date: Wed Dec 2 09:33:44 2009 New Revision: 90319 URL: http://llvm.org/viewvc/llvm-project?rev=90319&view=rev Log: Silence compiler warnings. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90319&r1=90318&r2=90319&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Dec 2 09:33:44 2009 @@ -196,7 +196,7 @@ // pointer, not on query pointers that are indexed off of them. It'd // be nice to handle that at some point. AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(3), ~0ULL, MemPtr, ~0ULL); + AA->alias(II->getOperand(3), ~0U, MemPtr, ~0U); if (R == AliasAnalysis::MustAlias) { InvariantTag = II->getOperand(1); continue; @@ -209,7 +209,7 @@ // pointer, not on query pointers that are indexed off of them. It'd // be nice to handle that at some point. AliasAnalysis::AliasResult R = - AA->alias(II->getOperand(2), ~0ULL, MemPtr, ~0ULL); + AA->alias(II->getOperand(2), ~0U, MemPtr, ~0U); if (R == AliasAnalysis::MustAlias) return MemDepResult::getDef(II); } From astifter-llvm at gmx.at Wed Dec 2 09:57:15 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Wed, 02 Dec 2009 15:57:15 -0000 Subject: [llvm-commits] [llvm] r90320 - /llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h Message-ID: <200912021557.nB2FvFtk018712@zion.cs.uiuc.edu> Author: astifter Date: Wed Dec 2 09:57:15 2009 New Revision: 90320 URL: http://llvm.org/viewvc/llvm-project?rev=90320&view=rev Log: Cheap, mostly strict, stable sorting. This is necessary for tests so the results are comparable. Modified: llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h Modified: llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h?rev=90320&r1=90319&r2=90320&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h (original) +++ llvm/trunk/lib/Transforms/Instrumentation/MaximumSpanningTree.h Wed Dec 2 09:57:15 2009 @@ -15,6 +15,7 @@ #ifndef LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H #define LLVM_ANALYSIS_MAXIMUMSPANNINGTREE_H +#include "llvm/BasicBlock.h" #include "llvm/ADT/EquivalenceClasses.h" #include #include @@ -33,6 +34,18 @@ typename MaximumSpanningTree::EdgeWeight Y) const { if (X.second > Y.second) return true; if (X.second < Y.second) return false; + if (const BasicBlock *BBX = dyn_cast(X.first.first)) { + if (const BasicBlock *BBY = dyn_cast(Y.first.first)) { + if (BBX->size() > BBY->size()) return true; + if (BBX->size() < BBY->size()) return false; + } + } + if (const BasicBlock *BBX = dyn_cast(X.first.second)) { + if (const BasicBlock *BBY = dyn_cast(Y.first.second)) { + if (BBX->size() > BBY->size()) return true; + if (BBX->size() < BBY->size()) return false; + } + } return false; } }; From baldrick at free.fr Wed Dec 2 10:24:26 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 16:24:26 -0000 Subject: [llvm-commits] [dragonegg] r90321 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912021624.nB2GOQ7P019647@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 10:24:25 2009 New Revision: 90321 URL: http://llvm.org/viewvc/llvm-project?rev=90321&view=rev Log: In C++ code, the target of a call may be an OBJ_TYPE_REF. Ignore these. 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=90321&r1=90320&r2=90321&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 10:24:25 2009 @@ -2224,11 +2224,10 @@ /// EmitRegister - Convert the specified gimple register or local constant of /// register type to an LLVM value. Only creates code in the entry block. Value *TreeToLLVM::EmitRegister(tree reg) { + while (TREE_CODE(reg) == OBJ_TYPE_REF) reg = OBJ_TYPE_REF_EXPR(reg); Value *V = (TREE_CODE(reg) == SSA_NAME) ? EmitSSA_NAME(reg) : EmitMinInvariant(reg); - assert(V->getType() == ConvertType(TREE_TYPE(reg)) && - "Gimple register has wrong type!"); - return V; + return Builder.CreateBitCast(V, ConvertType(TREE_TYPE(reg))); } /// EmitLoadOfLValue - When an l-value expression is used in a context that From grosbach at apple.com Wed Dec 2 11:06:46 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 02 Dec 2009 17:06:46 -0000 Subject: [llvm-commits] [llvm] r90324 - in /llvm/trunk/lib/Transforms/Utils: Local.cpp SimplifyCFG.cpp Message-ID: <200912021706.nB2H6kqD021352@zion.cs.uiuc.edu> Author: grosbach Date: Wed Dec 2 11:06:45 2009 New Revision: 90324 URL: http://llvm.org/viewvc/llvm-project?rev=90324&view=rev Log: Move EliminateDuplicatePHINodes() from SimplifyCFG.cpp to Local.cpp Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=90324&r1=90323&r2=90324&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Dec 2 11:06:45 2009 @@ -603,3 +603,65 @@ return true; } +/// EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI +/// nodes in this block. This doesn't try to be clever about PHI nodes +/// which differ only in the order of the incoming values, but instcombine +/// orders them so it usually won't matter. +/// +bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) { + bool Changed = false; + + // This implementation doesn't currently consider undef operands + // specially. Theroetically, two phis which are identical except for + // one having an undef where the other doesn't could be collapsed. + + // Map from PHI hash values to PHI nodes. If multiple PHIs have + // the same hash value, the element is the first PHI in the + // linked list in CollisionMap. + DenseMap HashMap; + + // Maintain linked lists of PHI nodes with common hash values. + DenseMap CollisionMap; + + // Examine each PHI. + for (BasicBlock::iterator I = BB->begin(); + PHINode *PN = dyn_cast(I++); ) { + // Compute a hash value on the operands. Instcombine will likely have sorted + // them, which helps expose duplicates, but we have to check all the + // operands to be safe in case instcombine hasn't run. + uintptr_t Hash = 0; + for (User::op_iterator I = PN->op_begin(), E = PN->op_end(); I != E; ++I) { + // This hash algorithm is quite weak as hash functions go, but it seems + // to do a good enough job for this particular purpose, and is very quick. + Hash ^= reinterpret_cast(static_cast(*I)); + Hash = (Hash << 7) | (Hash >> (sizeof(uintptr_t) * CHAR_BIT - 7)); + } + // If we've never seen this hash value before, it's a unique PHI. + std::pair::iterator, bool> Pair = + HashMap.insert(std::make_pair(Hash, PN)); + if (Pair.second) continue; + // Otherwise it's either a duplicate or a hash collision. + for (PHINode *OtherPN = Pair.first->second; ; ) { + if (OtherPN->isIdenticalTo(PN)) { + // A duplicate. Replace this PHI with its duplicate. + PN->replaceAllUsesWith(OtherPN); + PN->eraseFromParent(); + Changed = true; + break; + } + // A non-duplicate hash collision. + DenseMap::iterator I = CollisionMap.find(OtherPN); + if (I == CollisionMap.end()) { + // Set this PHI to be the head of the linked list of colliding PHIs. + PHINode *Old = Pair.first->second; + Pair.first->second = PN; + CollisionMap[PN] = Old; + break; + } + // Procede to the next PHI in the list. + OtherPN = I->second; + } + } + + return Changed; +} Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=90324&r1=90323&r2=90324&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Dec 2 11:06:45 2009 @@ -1589,69 +1589,6 @@ return true; } -/// EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI -/// nodes in this block. This doesn't try to be clever about PHI nodes -/// which differ only in the order of the incoming values, but instcombine -/// orders them so it usually won't matter. -/// -bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) { - bool Changed = false; - - // This implementation doesn't currently consider undef operands - // specially. Theroetically, two phis which are identical except for - // one having an undef where the other doesn't could be collapsed. - - // Map from PHI hash values to PHI nodes. If multiple PHIs have - // the same hash value, the element is the first PHI in the - // linked list in CollisionMap. - DenseMap HashMap; - - // Maintain linked lists of PHI nodes with common hash values. - DenseMap CollisionMap; - - // Examine each PHI. - for (BasicBlock::iterator I = BB->begin(); - PHINode *PN = dyn_cast(I++); ) { - // Compute a hash value on the operands. Instcombine will likely have sorted - // them, which helps expose duplicates, but we have to check all the - // operands to be safe in case instcombine hasn't run. - uintptr_t Hash = 0; - for (User::op_iterator I = PN->op_begin(), E = PN->op_end(); I != E; ++I) { - // This hash algorithm is quite weak as hash functions go, but it seems - // to do a good enough job for this particular purpose, and is very quick. - Hash ^= reinterpret_cast(static_cast(*I)); - Hash = (Hash << 7) | (Hash >> (sizeof(uintptr_t) * CHAR_BIT - 7)); - } - // If we've never seen this hash value before, it's a unique PHI. - std::pair::iterator, bool> Pair = - HashMap.insert(std::make_pair(Hash, PN)); - if (Pair.second) continue; - // Otherwise it's either a duplicate or a hash collision. - for (PHINode *OtherPN = Pair.first->second; ; ) { - if (OtherPN->isIdenticalTo(PN)) { - // A duplicate. Replace this PHI with its duplicate. - PN->replaceAllUsesWith(OtherPN); - PN->eraseFromParent(); - Changed = true; - break; - } - // A non-duplicate hash collision. - DenseMap::iterator I = CollisionMap.find(OtherPN); - if (I == CollisionMap.end()) { - // Set this PHI to be the head of the linked list of colliding PHIs. - PHINode *Old = Pair.first->second; - Pair.first->second = PN; - CollisionMap[PN] = Old; - break; - } - // Procede to the next PHI in the list. - OtherPN = I->second; - } - } - - return Changed; -} - /// SimplifyCFG - This function is used to do simplification of a CFG. For /// example, it adjusts branches to branches to eliminate the extra hop, it /// eliminates unreachable basic blocks, and does other "peephole" optimization From grosbach at apple.com Wed Dec 2 11:07:53 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 2 Dec 2009 09:07:53 -0800 Subject: [llvm-commits] [llvm] r89297 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Utils/SimplifyCFG.cpp In-Reply-To: <0F9C0ACF-84F4-4872-B911-5FEC96BFF05C@apple.com> References: <200911190202.nAJ22ACR027438@zion.cs.uiuc.edu> <0F9C0ACF-84F4-4872-B911-5FEC96BFF05C@apple.com> Message-ID: On Dec 1, 2009, at 11:31 PM, Chris Lattner wrote: > > On Nov 18, 2009, at 6:02 PM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Wed Nov 18 20:02:10 2009 >> New Revision: 89297 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89297&view=rev >> Log: >> Make EliminateDuplicatePHINodes() available as a utility function > > Hi Jim, > > Please move this function out to 'lib/Transforms/Utils/Local.cpp'. > SimplifyCFG.cpp should just have the simplifycfg entrypoint. OK. Done in r90324. > -Chris > >> >> Modified: >> llvm/trunk/include/llvm/Transforms/Utils/Local.h >> llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp >> >> Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=89297&r1=89296&r2=89297&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) >> +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Wed Nov 18 >> 20:02:10 2009 >> @@ -107,7 +107,14 @@ >> /// rewriting all the predecessors to branch to the successor block >> and return >> /// true. If we can't transform, return false. >> bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB); >> - >> + >> +/// EliminateDuplicatePHINodes - Check for and eliminate duplicate >> PHI >> +/// nodes in this block. This doesn't try to be clever about PHI >> nodes >> +/// which differ only in the order of the incoming values, but >> instcombine >> +/// orders them so it usually won't matter. >> +/// >> +bool EliminateDuplicatePHINodes(BasicBlock *BB); >> + >> /// SimplifyCFG - This function is used to do simplification of a >> CFG. For >> /// example, it adjusts branches to branches to eliminate the extra >> hop, it >> /// eliminates unreachable basic blocks, and does other "peephole" >> optimization >> >> Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=89297&r1=89296&r2=89297&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Nov 18 >> 20:02:10 2009 >> @@ -1594,7 +1594,7 @@ >> /// which differ only in the order of the incoming values, but >> instcombine >> /// orders them so it usually won't matter. >> /// >> -static bool EliminateDuplicatePHINodes(BasicBlock *BB) { >> +bool llvm::EliminateDuplicatePHINodes(BasicBlock *BB) { >> bool Changed = false; >> >> // This implementation doesn't currently consider undef operands >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From bob.wilson at apple.com Wed Dec 2 11:15:24 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 02 Dec 2009 17:15:24 -0000 Subject: [llvm-commits] [llvm] r90326 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <200912021715.nB2HFOKd021796@zion.cs.uiuc.edu> Author: bwilson Date: Wed Dec 2 11:15:24 2009 New Revision: 90326 URL: http://llvm.org/viewvc/llvm-project?rev=90326&view=rev Log: Don't count PHI instructions toward the limit for tail duplicating a block. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90326&r1=90325&r2=90326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Wed Dec 2 11:15:24 2009 @@ -129,20 +129,22 @@ // Check the instructions in the block to determine whether tail-duplication // is invalid or unlikely to be profitable. - unsigned i = 0; + unsigned InstrCount = 0; bool HasCall = false; for (MachineBasicBlock::iterator I = TailBB->begin(); - I != TailBB->end(); ++I, ++i) { + I != TailBB->end(); ++I) { // Non-duplicable things shouldn't be tail-duplicated. if (I->getDesc().isNotDuplicable()) return false; // Don't duplicate more than the threshold. - if (i == MaxDuplicateCount) return false; + if (InstrCount == MaxDuplicateCount) return false; // Remember if we saw a call. if (I->getDesc().isCall()) HasCall = true; + if (I->getOpcode() != TargetInstrInfo::PHI) + InstrCount += 1; } // Heuristically, don't tail-duplicate calls if it would expand code size, // as it's less likely to be worth the extra cost. - if (i > 1 && HasCall) + if (InstrCount > 1 && HasCall) return false; // Iterate through all the unique predecessors and tail-duplicate this From clattner at apple.com Wed Dec 2 11:44:18 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 2 Dec 2009 09:44:18 -0800 Subject: [llvm-commits] [llvm] r86840 - in /llvm/trunk: include/llvm/IntrinsicInst.h lib/Transforms/Utils/Local.cpp test/Transforms/InstCombine/invariant.ll In-Reply-To: <4B166EBC.8060808@free.fr> References: <200911111534.nABFYEd0025670@zion.cs.uiuc.edu> <92E3CFF2-F830-4826-BDCF-5EF745AA4904@apple.com> <4B166EBC.8060808@free.fr> Message-ID: <3B05F8DF-3101-4B12-A600-23B0EBEB58E7@apple.com> On Dec 2, 2009, at 5:42 AM, Duncan Sands wrote: > Hi Chris, > >>> +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Wed Nov 11 09:34:13 >>> 2009 >>> @@ -252,6 +252,9 @@ >>> // We don't want debug info removed by anything this general. >>> if (isa(I)) return false; >>> >>> + // Likewise for memory use markers. >>> + if (isa(I)) return false; >> Is this still needed? I thought that it turns out that these >> intrinsics need to be marked as having side effects after all? > > this is only needed for llvm.invariant.start, which is readonly. > That makes > some sense because if it wasn't readonly then passes that are not > llvm.invariant > aware might think it stomps on the values being declared invariant. > Another > possibility is to have it be marked as writing memory like the > others, and teach > every possible place that it doesn't do anything bad. I think marking it as potentially writing is the right way to go. There are few places that should care (memdep and the code that infers readonly/readnone) right? -Chris From grosbach at apple.com Wed Dec 2 13:30:33 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 02 Dec 2009 19:30:33 -0000 Subject: [llvm-commits] [llvm] r90336 - in /llvm/trunk: include/llvm/CodeGen/MachineFrameInfo.h include/llvm/CodeGen/Passes.h lib/CodeGen/MaxStackAlignment.cpp lib/Target/ARM/ARM.h lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMTargetMachine.cpp lib/Target/X86/X86.h lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86TargetMachine.cpp Message-ID: <200912021930.nB2JUaaW027194@zion.cs.uiuc.edu> Author: grosbach Date: Wed Dec 2 13:30:24 2009 New Revision: 90336 URL: http://llvm.org/viewvc/llvm-project?rev=90336&view=rev Log: Factor the stack alignment calculations out into a target independent pass. No functionality change. Added: llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/lib/Target/ARM/ARM.h llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/lib/Target/X86/X86.h llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Wed Dec 2 13:30:24 2009 @@ -327,7 +327,20 @@ /// setMaxAlignment - Set the preferred alignment. /// void setMaxAlignment(unsigned Align) { MaxAlignment = Align; } - + + /// calculateMaxStackAlignment() - If there is a local object which requires + /// greater alignment than the current max alignment, adjust accordingly. + void calculateMaxStackAlignment() { + for (int i = getObjectIndexBegin(), + e = getObjectIndexEnd(); i != e; ++i) { + if (isDeadObjectIndex(i)) + continue; + + unsigned Align = getObjectAlignment(i); + MaxAlignment = std::max(MaxAlignment, Align); + } + } + /// hasCalls - Return true if the current function has no function calls. /// This is only valid during or after prolog/epilog code emission. /// Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Wed Dec 2 13:30:24 2009 @@ -191,6 +191,10 @@ /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. FunctionPass *createSjLjEHPass(const TargetLowering *tli); + /// createMaxStackAlignmentCalculatorPass() - Determine the maximum required + /// alignment for a function. + FunctionPass* createMaxStackAlignmentCalculatorPass(); + } // End llvm namespace #endif Added: llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp?rev=90336&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp (added) +++ llvm/trunk/lib/CodeGen/MaxStackAlignment.cpp Wed Dec 2 13:30:24 2009 @@ -0,0 +1,70 @@ +//===-- MaxStackAlignment.cpp - Compute the required stack alignment -- ---===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass looks for vector register usage and aligned local objects to +// calculate the maximum required alignment for a function. This is used by +// targets which support it to determine if dynamic stack realignment is +// necessary. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/Passes.h" + +using namespace llvm; + +namespace { + struct MaximalStackAlignmentCalculator : public MachineFunctionPass { + static char ID; + MaximalStackAlignmentCalculator() : MachineFunctionPass(&ID) {} + + virtual bool runOnMachineFunction(MachineFunction &MF) { + MachineFrameInfo *FFI = MF.getFrameInfo(); + MachineRegisterInfo &RI = MF.getRegInfo(); + + // Calculate max stack alignment of all already allocated stack objects. + FFI->calculateMaxStackAlignment(); + unsigned MaxAlign = FFI->getMaxAlignment(); + + // Be over-conservative: scan over all vreg defs and find whether vector + // registers are used. If yes, there is probability that vector registers + // will be spilled and thus the stack needs to be aligned properly. + // FIXME: It would be better to only do this if a spill actually + // happens rather than conseratively aligning the stack regardless. + for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister; + RegNum < RI.getLastVirtReg(); ++RegNum) + MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment()); + + if (FFI->getMaxAlignment() == MaxAlign) + return false; + + FFI->setMaxAlignment(MaxAlign); + return true; + } + + virtual const char *getPassName() const { + return "Stack Alignment Requirements Auto-Detector"; + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + } + }; + + char MaximalStackAlignmentCalculator::ID = 0; +} + +FunctionPass* +llvm::createMaxStackAlignmentCalculatorPass() { + return new MaximalStackAlignmentCalculator(); +} + Modified: llvm/trunk/lib/Target/ARM/ARM.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.h (original) +++ llvm/trunk/lib/Target/ARM/ARM.h Wed Dec 2 13:30:24 2009 @@ -109,7 +109,6 @@ FunctionPass *createNEONMoveFixPass(); FunctionPass *createThumb2ITBlockPass(); FunctionPass *createThumb2SizeReductionPass(); -FunctionPass *createARMMaxStackAlignmentCalculatorPass(); extern Target TheARMTarget, TheThumbTarget; Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Wed Dec 2 13:30:24 2009 @@ -471,21 +471,6 @@ } } -static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) { - unsigned MaxAlign = 0; - - for (int i = FFI->getObjectIndexBegin(), - e = FFI->getObjectIndexEnd(); i != e; ++i) { - if (FFI->isDeadObjectIndex(i)) - continue; - - unsigned Align = FFI->getObjectAlignment(i); - MaxAlign = std::max(MaxAlign, Align); - } - - return MaxAlign; -} - /// hasFP - Return true if the specified function should have a dedicated frame /// pointer register. This is true if the function has variable sized allocas /// or if frame pointer elimination is disabled. @@ -585,14 +570,12 @@ SmallVector UnspilledCS2GPRs; ARMFunctionInfo *AFI = MF.getInfo(); - MachineFrameInfo *MFI = MF.getFrameInfo(); // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). if (RealignStack) { - unsigned MaxAlign = std::max(MFI->getMaxAlignment(), - calculateMaxStackAlignment(MFI)); - MFI->setMaxAlignment(MaxAlign); + MachineFrameInfo *MFI = MF.getFrameInfo(); + MFI->calculateMaxStackAlignment(); } // Don't spill FP if the frame can be eliminated. This is determined @@ -1479,48 +1462,4 @@ emitSPUpdate(isARM, MBB, MBBI, dl, TII, VARegSaveSize); } -namespace { - struct MaximalStackAlignmentCalculator : public MachineFunctionPass { - static char ID; - MaximalStackAlignmentCalculator() : MachineFunctionPass(&ID) {} - - virtual bool runOnMachineFunction(MachineFunction &MF) { - MachineFrameInfo *FFI = MF.getFrameInfo(); - MachineRegisterInfo &RI = MF.getRegInfo(); - - // Calculate max stack alignment of all already allocated stack objects. - unsigned MaxAlign = calculateMaxStackAlignment(FFI); - - // Be over-conservative: scan over all vreg defs and find, whether vector - // registers are used. If yes - there is probability, that vector register - // will be spilled and thus stack needs to be aligned properly. - for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister; - RegNum < RI.getLastVirtReg(); ++RegNum) - MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment()); - - if (FFI->getMaxAlignment() == MaxAlign) - return false; - - FFI->setMaxAlignment(MaxAlign); - return true; - } - - virtual const char *getPassName() const { - return "ARM Stack Required Alignment Auto-Detector"; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - } - }; - - char MaximalStackAlignmentCalculator::ID = 0; -} - -FunctionPass* -llvm::createARMMaxStackAlignmentCalculatorPass() { - return new MaximalStackAlignmentCalculator(); -} - #include "ARMGenRegisterInfo.inc" Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Wed Dec 2 13:30:24 2009 @@ -95,7 +95,7 @@ // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). - PM.add(createARMMaxStackAlignmentCalculatorPass()); + PM.add(createMaxStackAlignmentCalculatorPass()); // FIXME: temporarily disabling load / store optimization pass for Thumb1. if (OptLevel != CodeGenOpt::None && !Subtarget.isThumb1Only()) Modified: llvm/trunk/lib/Target/X86/X86.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.h?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.h (original) +++ llvm/trunk/lib/Target/X86/X86.h Wed Dec 2 13:30:24 2009 @@ -62,11 +62,6 @@ /// FunctionPass *createEmitX86CodeToMemory(); -/// createX86MaxStackAlignmentCalculatorPass - This function returns a pass -/// which calculates maximal stack alignment required for function -/// -FunctionPass *createX86MaxStackAlignmentCalculatorPass(); - extern Target TheX86_32Target, TheX86_64Target; } // End llvm namespace Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Dec 2 13:30:24 2009 @@ -423,21 +423,6 @@ // Stack Frame Processing methods //===----------------------------------------------------------------------===// -static unsigned calculateMaxStackAlignment(const MachineFrameInfo *FFI) { - unsigned MaxAlign = 0; - - for (int i = FFI->getObjectIndexBegin(), - e = FFI->getObjectIndexEnd(); i != e; ++i) { - if (FFI->isDeadObjectIndex(i)) - continue; - - unsigned Align = FFI->getObjectAlignment(i); - MaxAlign = std::max(MaxAlign, Align); - } - - return MaxAlign; -} - /// hasFP - Return true if the specified function should have a dedicated frame /// pointer register. This is true if the function has variable sized allocas /// or if frame pointer elimination is disabled. @@ -638,10 +623,7 @@ // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). - unsigned MaxAlign = std::max(MFI->getMaxAlignment(), - calculateMaxStackAlignment(MFI)); - - MFI->setMaxAlignment(MaxAlign); + MFI->calculateMaxStackAlignment(); X86MachineFunctionInfo *X86FI = MF.getInfo(); int32_t TailCallReturnAddrDelta = X86FI->getTCReturnAddrDelta(); @@ -1482,45 +1464,3 @@ } #include "X86GenRegisterInfo.inc" - -namespace { - struct MSAC : public MachineFunctionPass { - static char ID; - MSAC() : MachineFunctionPass(&ID) {} - - virtual bool runOnMachineFunction(MachineFunction &MF) { - MachineFrameInfo *FFI = MF.getFrameInfo(); - MachineRegisterInfo &RI = MF.getRegInfo(); - - // Calculate max stack alignment of all already allocated stack objects. - unsigned MaxAlign = calculateMaxStackAlignment(FFI); - - // Be over-conservative: scan over all vreg defs and find, whether vector - // registers are used. If yes - there is probability, that vector register - // will be spilled and thus stack needs to be aligned properly. - for (unsigned RegNum = TargetRegisterInfo::FirstVirtualRegister; - RegNum < RI.getLastVirtReg(); ++RegNum) - MaxAlign = std::max(MaxAlign, RI.getRegClass(RegNum)->getAlignment()); - - if (FFI->getMaxAlignment() == MaxAlign) - return false; - - FFI->setMaxAlignment(MaxAlign); - return true; - } - - virtual const char *getPassName() const { - return "X86 Maximal Stack Alignment Calculator"; - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - } - }; - - char MSAC::ID = 0; -} - -FunctionPass* -llvm::createX86MaxStackAlignmentCalculatorPass() { return new MSAC(); } Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=90336&r1=90335&r2=90336&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Wed Dec 2 13:30:24 2009 @@ -163,7 +163,7 @@ CodeGenOpt::Level OptLevel) { // Calculate and set max stack object alignment early, so we can decide // whether we will need stack realignment (and thus FP). - PM.add(createX86MaxStackAlignmentCalculatorPass()); + PM.add(createMaxStackAlignmentCalculatorPass()); return false; // -print-machineinstr shouldn't print after this. } From grosbach at apple.com Wed Dec 2 13:31:07 2009 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 02 Dec 2009 19:31:07 -0000 Subject: [llvm-commits] [llvm] r90337 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <200912021931.nB2JV72R027223@zion.cs.uiuc.edu> Author: grosbach Date: Wed Dec 2 13:31:07 2009 New Revision: 90337 URL: http://llvm.org/viewvc/llvm-project?rev=90337&view=rev Log: Add MaxStackAlignment.cpp to CMake Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=90337&r1=90336&r2=90337&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Wed Dec 2 13:31:07 2009 @@ -36,6 +36,7 @@ MachineRegisterInfo.cpp MachineSink.cpp MachineVerifier.cpp + MaxStackAlignment.cpp ObjectCodeEmitter.cpp OcamlGC.cpp PHIElimination.cpp From baldrick at free.fr Wed Dec 2 14:38:46 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 20:38:46 -0000 Subject: [llvm-commits] [dragonegg] r90345 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912022038.nB2Kck5t029857@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 14:38:46 2009 New Revision: 90345 URL: http://llvm.org/viewvc/llvm-project?rev=90345&view=rev Log: Due to exception handling not being wired up, an LLVM basic block can have no predecessors even though the GCC basic block does. This can result in phi nodes with no operands, which is not allowed. For the moment, just nuke the phi node in this case. 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=90345&r1=90344&r2=90345&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Dec 2 14:38:46 2009 @@ -812,8 +812,7 @@ // The incoming GCC basic block. basic_block bb = gimple_phi_arg_edge(P.gcc_phi, i)->src; - // If there is no corresponding LLVM basic block then the GCC basic block - // was unreachable - skip this phi argument. + // The corresponding LLVM basic block. DenseMap::iterator BI = BasicBlocks.find(bb); assert(BI != BasicBlocks.end() && "GCC basic block not output?"); @@ -849,6 +848,17 @@ ++PI, ++Index) Predecessors.push_back(std::make_pair(*PI, Index)); + if (Predecessors.empty()) { + // FIXME: If this happens then GCC has a control flow edge where LLVM has + // none - something has gone wrong. For the moment be laid back about it + // because the fact we don't yet wire up exception handling code means it + // happens all the time in Ada and C++. + P.PHI->replaceAllUsesWith(UndefValue::get(P.PHI->getType())); + P.PHI->eraseFromParent(); + IncomingValues.clear(); + continue; + } + // Sort the predecessors by basic block. In GCC, each predecessor occurs // exactly once. However in LLVM a predecessor can occur several times, // and then every copy of the predecessor must be associated with exactly From baldrick at free.fr Wed Dec 2 14:41:10 2009 From: baldrick at free.fr (Duncan Sands) Date: Wed, 02 Dec 2009 20:41:10 -0000 Subject: [llvm-commits] [dragonegg] r90346 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <200912022041.nB2KfBE5029966@zion.cs.uiuc.edu> Author: baldrick Date: Wed Dec 2 14:41:10 2009 New Revision: 90346 URL: http://llvm.org/viewvc/llvm-project?rev=90346&view=rev Log: In spite of what the gcc docs say, you can get a CONST_DECL here when compiling C++. If this happens, simply grab the value out of the CONST_DECL. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=90346&r1=90345&r2=90346&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Wed Dec 2 14:41:10 2009 @@ -531,6 +531,8 @@ if (TYPE_SIZE(type)) { for (tree Link = TYPE_VALUES(type); Link; Link = TREE_CHAIN(Link)) { tree EnumValue = TREE_VALUE(Link); + if (TREE_CODE(EnumValue) == CONST_DECL) + EnumValue = DECL_INITIAL(EnumValue); int64_t Value = getINTEGER_CSTVal(EnumValue); const char *EnumName = IDENTIFIER_POINTER(TREE_PURPOSE(Link)); Elements.push_back(DebugFactory.CreateEnumerator(EnumName, Value)); From espindola at google.com Wed Dec 2 15:45:42 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 2 Dec 2009 16:45:42 -0500 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> Message-ID: <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> > I don't have any testcases that are better than the one for pr5406. ?I'm not sure if it is safe to access a 24-bit struct as an i32. If it is not, that is (almost) a testcase :-) Consider ----------------- struct foo { char[3] a; }; void f(struct foo x); void g(int a, int b, int c, int d, struct foo x); ---------------------- We should expand this to void @f(i32) and void @g(i32, i32, i32, i32, i16, i8) That is, using i32 or i16 + i8 will depend on the value being on the stack on in a register. Given that we would have to change PassInIntegerRegisters to know what fraction of the type is being passed in registers (or implement byval for arm). Cheers, -- Rafael ?vila de Esp?ndola From isanbard at gmail.com Wed Dec 2 16:01:08 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 2 Dec 2009 14:01:08 -0800 Subject: [llvm-commits] [llvm] r89295 - /llvm/trunk/test/CodeGen/X86/unaligned-load.ll In-Reply-To: <3DE0E765-32EF-4669-8CD9-FF3E75CF3191@apple.com> References: <200911190133.nAJ1XvIY026278@zion.cs.uiuc.edu> <3DE0E765-32EF-4669-8CD9-FF3E75CF3191@apple.com> Message-ID: On Dec 1, 2009, at 1:52 PM, Chris Lattner wrote: > On Nov 18, 2009, at 5:33 PM, Bill Wendling wrote: > >> Author: void >> Date: Wed Nov 18 19:33:57 2009 >> New Revision: 89295 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89295&view=rev >> Log: >> Test from Dhrystone to make sure that we're not emitting an aligned >> load for a >> string that's aligned at 8-bytes instead of 16-bytes. > > Why do you need the 'not grep'? Isn't the check for movups enough? > Perhaps. I'd rather be safe than sorry. But if people feel it's not necessary, then I can remove the check. -bw > -Chris > >> >> Added: >> llvm/trunk/test/CodeGen/X86/unaligned-load.ll >> >> Added: llvm/trunk/test/CodeGen/X86/unaligned-load.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unaligned-load.ll?rev=89295&view=auto >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/X86/unaligned-load.ll (added) >> +++ llvm/trunk/test/CodeGen/X86/unaligned-load.ll Wed Nov 18 >> 19:33:57 2009 >> @@ -0,0 +1,28 @@ >> +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation- >> model=dynamic-no-pic | not grep {movaps\t_.str3} >> +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation- >> model=dynamic-no-pic | FileCheck %s >> + >> + at .str1 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, SOME >> STRING\00", align 8 >> + at .str3 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, 2'ND >> STRING\00", align 8 >> + >> +define void @func() nounwind ssp { >> +entry: >> + %String2Loc = alloca [31 x i8], align 1 >> + br label %bb >> + >> +bb: >> + %String2Loc9 = getelementptr inbounds [31 x i8]* %String2Loc, i64 >> 0, i64 0 >> + call void @llvm.memcpy.i64(i8* %String2Loc9, i8* getelementptr >> inbounds ([31 x i8]* @.str3, i64 0, i64 0), i64 31, i32 1) >> +; CHECK: movups _.str3 >> + br label %bb >> + >> +return: >> + ret void >> +} >> + >> +declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, >> i32) nounwind >> + >> +; CHECK: .align 3 >> +; CHECK-NEXT: _.str1: >> +; CHECK-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" >> +; CHECK-NEXT: .align 3 >> +; CHECK-NEXT: _.str3: >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Wed Dec 2 16:02:30 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 02 Dec 2009 22:02:30 -0000 Subject: [llvm-commits] [llvm] r90352 - /llvm/trunk/test/CodeGen/X86/unaligned-load.ll Message-ID: <200912022202.nB2M2VbU000588@zion.cs.uiuc.edu> Author: void Date: Wed Dec 2 16:02:20 2009 New Revision: 90352 URL: http://llvm.org/viewvc/llvm-project?rev=90352&view=rev Log: Remove unnecessary check. Modified: llvm/trunk/test/CodeGen/X86/unaligned-load.ll Modified: llvm/trunk/test/CodeGen/X86/unaligned-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unaligned-load.ll?rev=90352&r1=90351&r2=90352&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/unaligned-load.ll (original) +++ llvm/trunk/test/CodeGen/X86/unaligned-load.ll Wed Dec 2 16:02:20 2009 @@ -1,4 +1,3 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=dynamic-no-pic | not grep {movaps\t_.str3} ; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=dynamic-no-pic | FileCheck %s @.str1 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, SOME STRING\00", align 8 From evan.cheng at apple.com Wed Dec 2 16:02:53 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 02 Dec 2009 22:02:53 -0000 Subject: [llvm-commits] [llvm] r90353 - in /llvm/trunk: include/llvm/CodeGen/MachineSSAUpdater.h lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912022202.nB2M2roO000610@zion.cs.uiuc.edu> Author: evancheng Date: Wed Dec 2 16:02:52 2009 New Revision: 90353 URL: http://llvm.org/viewvc/llvm-project?rev=90353&view=rev Log: Skeleton for MachineInstr level SSA updater. Added: llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Added: llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h?rev=90353&view=auto ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h (added) +++ llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h Wed Dec 2 16:02:52 2009 @@ -0,0 +1,99 @@ +//===-- MachineSSAUpdater.h - Unstructured SSA Update Tool ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the MachineSSAUpdater class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_MACHINESSAUPDATER_H +#define LLVM_CODEGEN_MACHINESSAUPDATER_H + +namespace llvm { + class MachineBasicBlock; + class MachineInstr; + template class SmallVectorImpl; + +/// SSAUpdater - This class updates SSA form for a set of values defined in +/// multiple blocks. This is used when code duplication or another unstructured +/// transformation wants to rewrite a set of uses of one value with uses of a +/// set of values. +class MachineSSAUpdater { + /// AvailableVals - This keeps track of which value to use on a per-block + /// basis. When we insert PHI nodes, we keep track of them here. + //typedef DenseMap AvailableValsTy; + void *AV; + + /// IncomingPredInfo - We use this as scratch space when doing our recursive + /// walk. This should only be used in GetValueInBlockInternal, normally it + /// should be empty. + //std::vector > IncomingPredInfo; + void *IPI; + + /// InsertedPHIs - If this is non-null, the MachineSSAUpdater adds all PHI + /// nodes that it creates to the vector. + SmallVectorImpl *InsertedPHIs; +public: + /// MachineSSAUpdater constructor. If InsertedPHIs is specified, it will be + /// filled in with all PHI Nodes created by rewriting. + explicit MachineSSAUpdater(SmallVectorImpl *InsertedPHIs = 0); + ~MachineSSAUpdater(); + + /// Initialize - Reset this object to get ready for a new set of SSA + /// updates. + void Initialize(); + + /// AddAvailableValue - Indicate that a rewritten value is available at the + /// end of the specified block with the specified value. + void AddAvailableValue(MachineBasicBlock *BB, unsigned V); + + /// HasValueForBlock - Return true if the MachineSSAUpdater already has a + /// value for the specified block. + bool HasValueForBlock(MachineBasicBlock *BB) const; + + /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is + /// live at the end of the specified block. + unsigned GetValueAtEndOfBlock(MachineBasicBlock *BB); + + /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that + /// is live in the middle of the specified block. + /// + /// GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one + /// important case: if there is a definition of the rewritten value after the + /// 'use' in BB. Consider code like this: + /// + /// X1 = ... + /// SomeBB: + /// use(X) + /// X2 = ... + /// br Cond, SomeBB, OutBB + /// + /// In this case, there are two values (X1 and X2) added to the AvailableVals + /// set by the client of the rewriter, and those values are both live out of + /// their respective blocks. However, the use of X happens in the *middle* of + /// a block. Because of this, we need to insert a new PHI node in SomeBB to + /// merge the appropriate values, and this value isn't live out of the block. + /// + unsigned GetValueInMiddleOfBlock(MachineBasicBlock *BB); + + /// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, + /// which use their value in the corresponding predecessor. Note that this + /// will not work if the use is supposed to be rewritten to a value defined in + /// the same block as the use, but above it. Any 'AddAvailableValue's added + /// for the use's block will be considered to be below it. + void RewriteUse(unsigned &U); + +private: + unsigned GetValueAtEndOfBlockInternal(MachineBasicBlock *BB); + void operator=(const MachineSSAUpdater&); // DO NOT IMPLEMENT + MachineSSAUpdater(const MachineSSAUpdater&); // DO NOT IMPLEMENT +}; + +} // End llvm namespace + +#endif Added: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90353&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (added) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Wed Dec 2 16:02:52 2009 @@ -0,0 +1,108 @@ +//===- MachineSSAUpdater.cpp - Unstructured SSA Update Tool ---------------===// +// +// 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 MachineSSAUpdater class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/MachineSSAUpdater.h" +#include "llvm/CodeGen/MachineInstr.h" +#include "llvm/ADT/DenseMap.h" +using namespace llvm; + +typedef DenseMap AvailableValsTy; +typedef std::vector > + IncomingPredInfoTy; + +static AvailableValsTy &getAvailableVals(void *AV) { + return *static_cast(AV); +} + +static IncomingPredInfoTy &getIncomingPredInfo(void *IPI) { + return *static_cast(IPI); +} + + +MachineSSAUpdater::MachineSSAUpdater(SmallVectorImpl *NewPHI) + : AV(0), IPI(0), InsertedPHIs(NewPHI) {} + +MachineSSAUpdater::~MachineSSAUpdater() { + delete &getAvailableVals(AV); + delete &getIncomingPredInfo(IPI); +} + +/// Initialize - Reset this object to get ready for a new set of SSA +/// updates. ProtoValue is the value used to name PHI nodes. +void MachineSSAUpdater::Initialize() { + if (AV == 0) + AV = new AvailableValsTy(); + else + getAvailableVals(AV).clear(); + + if (IPI == 0) + IPI = new IncomingPredInfoTy(); + else + getIncomingPredInfo(IPI).clear(); +} + +/// HasValueForBlock - Return true if the MachineSSAUpdater already has a value for +/// the specified block. +bool MachineSSAUpdater::HasValueForBlock(MachineBasicBlock *BB) const { + return getAvailableVals(AV).count(BB); +} + +/// AddAvailableValue - Indicate that a rewritten value is available in the +/// specified block with the specified value. +void MachineSSAUpdater::AddAvailableValue(MachineBasicBlock *BB, unsigned V) { + getAvailableVals(AV)[BB] = V; +} + +/// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is +/// live at the end of the specified block. +unsigned MachineSSAUpdater::GetValueAtEndOfBlock(MachineBasicBlock *BB) { + return GetValueAtEndOfBlockInternal(BB); +} + +/// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that +/// is live in the middle of the specified block. +/// +/// GetValueInMiddleOfBlock is the same as GetValueAtEndOfBlock except in one +/// important case: if there is a definition of the rewritten value after the +/// 'use' in BB. Consider code like this: +/// +/// X1 = ... +/// SomeBB: +/// use(X) +/// X2 = ... +/// br Cond, SomeBB, OutBB +/// +/// In this case, there are two values (X1 and X2) added to the AvailableVals +/// set by the client of the rewriter, and those values are both live out of +/// their respective blocks. However, the use of X happens in the *middle* of +/// a block. Because of this, we need to insert a new PHI node in SomeBB to +/// merge the appropriate values, and this value isn't live out of the block. +/// +unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { + return 0; +} + +/// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, +/// which use their value in the corresponding predecessor. +void MachineSSAUpdater::RewriteUse(unsigned &U) { +} + + +/// GetValueAtEndOfBlockInternal - Check to see if AvailableVals has an entry +/// for the specified BB and if so, return it. If not, construct SSA form by +/// walking predecessors inserting PHI nodes as needed until we get to a block +/// where the value is available. +/// +unsigned MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){ + return 0; +} From dgregor at apple.com Wed Dec 2 16:19:33 2009 From: dgregor at apple.com (Douglas Gregor) Date: Wed, 02 Dec 2009 22:19:33 -0000 Subject: [llvm-commits] [llvm] r90354 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <200912022219.nB2MJXR3001215@zion.cs.uiuc.edu> Author: dgregor Date: Wed Dec 2 16:19:31 2009 New Revision: 90354 URL: http://llvm.org/viewvc/llvm-project?rev=90354&view=rev Log: Fix CMake makefiles Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=90354&r1=90353&r2=90354&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Wed Dec 2 16:19:31 2009 @@ -35,6 +35,7 @@ MachinePassRegistry.cpp MachineRegisterInfo.cpp MachineSink.cpp + MachineSSAUpdater.cpp MachineVerifier.cpp MaxStackAlignment.cpp ObjectCodeEmitter.cpp From bob.wilson at apple.com Wed Dec 2 16:26:35 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 2 Dec 2009 14:26:35 -0800 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> Message-ID: <7A18F56D-9717-4765-91D8-CADC3276E959@apple.com> On Dec 2, 2009, at 1:45 PM, Rafael Espindola wrote: >> I don't have any testcases that are better than the one for pr5406. I'm not sure if it is safe to access a 24-bit struct as an i32. > > If it is not, that is (almost) a testcase :-) > > Consider > > ----------------- > struct foo { > char[3] a; > }; > > void f(struct foo x); > void g(int a, int b, int c, int d, struct foo x); > ---------------------- > > > We should expand this to > > void @f(i32) > and > void @g(i32, i32, i32, i32, i16, i8) > > That is, using i32 or i16 + i8 will depend on the value being on the > stack on in a register. Given that we would have to change > PassInIntegerRegisters to know what fraction of the type is being > passed in registers (or implement byval for arm). Right. I checked with ddunbar yesterday about how clang handles this, and it is currently passing the struct as an i32. Whether that is safe may depend on how that i32 is created. E.G., if clang constructs that i32 value by loading individual bytes from the struct, that should clearly be OK. Depending on the ABI, it may be endian-dependent whether the struct is packed into the high or low bits of the i32. I don't see any code to handle that, but it's quite possible I'm just missing it. I'm hoping Dale will weigh in on this soon, but I'm tentatively planning to add the byval support as soon as I get a chance (which may be a while). From espindola at google.com Wed Dec 2 16:39:40 2009 From: espindola at google.com (Rafael Espindola) Date: Wed, 2 Dec 2009 17:39:40 -0500 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <7A18F56D-9717-4765-91D8-CADC3276E959@apple.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> <7A18F56D-9717-4765-91D8-CADC3276E959@apple.com> Message-ID: <38a0d8450912021439y640f9183q220319ca5dbf087e@mail.gmail.com> > I'm hoping Dale will weigh in on this soon, but I'm tentatively planning to add the byval support as soon as I get a chance (which may be a while). I have a small preference for expanding it early, but if most prefer the byval solution I can give it a try. Not the highest priority item for me right now, but might be able to help. Cheers, -- Rafael ?vila de Esp?ndola From clattner at apple.com Wed Dec 2 18:06:54 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 2 Dec 2009 16:06:54 -0800 Subject: [llvm-commits] [llvm] r90353 - in /llvm/trunk: include/llvm/CodeGen/MachineSSAUpdater.h lib/CodeGen/MachineSSAUpdater.cpp In-Reply-To: <200912022202.nB2M2roO000610@zion.cs.uiuc.edu> References: <200912022202.nB2M2roO000610@zion.cs.uiuc.edu> Message-ID: On Dec 2, 2009, at 2:02 PM, Evan Cheng wrote: > + /// RewriteUse - Rewrite a use of the symbolic value. This > handles PHI nodes, > + /// which use their value in the corresponding predecessor. Note > that this > + /// will not work if the use is supposed to be rewritten to a > value defined in > + /// the same block as the use, but above it. Any > 'AddAvailableValue's added > + /// for the use's block will be considered to be below it. > + void RewriteUse(unsigned &U); > + This should probably take a MachineOperand, because it will need to getReg() / setReg() it. -Chris From isanbard at gmail.com Wed Dec 2 18:14:12 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 2 Dec 2009 16:14:12 -0800 Subject: [llvm-commits] [llvm] r89176 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp In-Reply-To: <1A1AE227-CA98-41BB-864B-003A9B9EA0CD@apple.com> References: <200911180103.nAI13usJ018941@zion.cs.uiuc.edu> <1A1AE227-CA98-41BB-864B-003A9B9EA0CD@apple.com> Message-ID: <392E62EA-54C9-4B80-91C3-85A67CBA3A68@gmail.com> On Dec 1, 2009, at 2:15 PM, Chris Lattner wrote: > On Nov 17, 2009, at 5:03 PM, Bill Wendling wrote: > >> Author: void >> Date: Tue Nov 17 19:03:56 2009 >> New Revision: 89176 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89176&view=rev >> Log: >> The llvm-gcc front-end and the pass manager use two separate >> TargetData objects. >> This is probably not confined to *just* these two things. > > Hi Bill, > > This commit message doesn't really make sense to me at all. I would > have expected it to be something like "Convert TargetData to use an > AbstractTypesUser so that it doesn't have dangling pointers when > abstract types get resolved". > Ah. Sorry about that. >> +++ llvm/trunk/include/llvm/Target/TargetData.h Tue Nov 17 19:03:56 >> 2009 >> @@ -30,6 +30,7 @@ >> class IntegerType; >> class StructType; >> class StructLayout; >> +class StructLayoutMap; > > Why did you publish the StructLayoutMap type? If you keep it a void*, > you can put it in an anonymous namespace in the .cpp file. > Because I don't like casting to and from void*. :-) But sure. >> +++ llvm/trunk/lib/Target/TargetData.cpp Tue Nov 17 19:03:56 2009 >> @@ -323,37 +323,130 @@ >> : Alignments[BestMatchIdx].PrefAlign; >> } >> >> -typedef DenseMapLayoutInfoTy; >> +typedef DenseMap LayoutInfoTy; >> >> +namespace llvm { >> + >> +class StructLayoutMap : public AbstractTypeUser { >> + LayoutInfoTy LayoutInfo; >> + >> + /// refineAbstractType - The callback method invoked when an >> abstract type is >> + /// resolved to another type. An object must override this >> method to update >> + /// its internal state to reference NewType instead of OldType. >> + /// >> + virtual void refineAbstractType(const DerivedType *OldTy, >> + const Type *) { >> + const StructType *STy = dyn_cast(OldTy); >> + if (!STy) { >> + OldTy->removeAbstractTypeUser(this); >> + return; > > This should be an error, so you should assert on "STy != 0". The only > types this AbstractTypeUser tracks are structs. > Okay. >> + } >> + >> + StructLayout *SL = LayoutInfo[STy]; >> + if (SL) { >> + SL->~StructLayout(); >> + free(SL); >> + LayoutInfo[STy] = NULL; > > This should use find() instead of [] for two reasons. > > 1. STy *must* be in the densemap, so this should be an assert that the > iterator != end. > 2. You don't want to set the entry for STy to null, you want to delete > the entry in the Densemap with erase(iterator). > >> + /// typeBecameConcrete - The other case which AbstractTypeUsers >> must be aware >> + /// of is when a type makes the transition from being abstract >> (where it has >> + /// clients on its AbstractTypeUsers list) to concrete (where it >> does not). >> + /// This method notifies ATU's when this occurs for a type. >> + /// >> + virtual void typeBecameConcrete(const DerivedType *AbsTy) { > > Same comments as refineAbstractType. > >> + bool insert(const Type *Ty) { >> + if (Ty->isAbstract()) >> + Ty->addAbstractTypeUser(this); >> + return true; >> + } > > Just inline this into its one caller. > > >> +public: >> + virtual ~StructLayoutMap() { >> + // Remove any layouts. >> + for (LayoutInfoTy::iterator >> + I = LayoutInfo.begin(), E = LayoutInfo.end(); I != E; + >> +I) >> + if (StructLayout *SL = I->second) { >> + SL->~StructLayout(); >> + free(SL); >> + } > > This needs to unregister as listeners from the abstract types! > >> + } >> + >> + inline LayoutInfoTy::iterator begin() { >> + return LayoutInfo.begin(); >> + } >> + inline LayoutInfoTy::iterator end() { >> + return LayoutInfo.end(); >> + } >> + inline LayoutInfoTy::const_iterator begin() const { >> + return LayoutInfo.begin(); >> + } >> + inline LayoutInfoTy::const_iterator end() const { >> + return LayoutInfo.end(); >> + } >> + >> + LayoutInfoTy::iterator find(const StructType *&Val) { >> + return LayoutInfo.find(Val); >> + } >> + LayoutInfoTy::const_iterator find(const StructType *&Val) const { >> + return LayoutInfo.find(Val); >> + } >> + >> + bool erase(const StructType *&Val) { >> + return LayoutInfo.erase(Val); >> + } >> + bool erase(LayoutInfoTy::iterator I) { >> + return LayoutInfo.erase(I); >> + } > > This stuff is all dead. Please remove it. > Well, not all of them. :-) >> + >> + StructLayout *&operator[](const Type *Key) { > > Key should be declared as 'const StructType *'. > Okay. >> + const StructType *STy = dyn_cast(Key); >> + assert(STy && "Trying to access the struct layout map with a >> non-struct!"); > which allows you to eliminate this. > >> + insert(STy); >> + return LayoutInfo[STy]; > > Don't do a redundant map lookup after 'insert'. > I reworked a lot of this so that it's arguably more correct now...I hope at least. -bw From isanbard at gmail.com Wed Dec 2 18:17:12 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Dec 2009 00:17:12 -0000 Subject: [llvm-commits] [llvm] r90362 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <200912030017.nB30HCrf005224@zion.cs.uiuc.edu> Author: void Date: Wed Dec 2 18:17:12 2009 New Revision: 90362 URL: http://llvm.org/viewvc/llvm-project?rev=90362&view=rev Log: This initial code is meant to convert TargetData to use an AbstractTypesUser so that it doesn't have dangling pointers when abstract types are resolved. This modifies it somewhat to address comments: making the "StructLayoutMap" an anonymous structure, calling "removeAbstractTypeUser" when appropriate, and adding asserts where helpful. Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=90362&r1=90361&r2=90362&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Wed Dec 2 18:17:12 2009 @@ -30,7 +30,6 @@ class IntegerType; class StructType; class StructLayout; -class StructLayoutMap; class GlobalVariable; class LLVMContext; @@ -86,7 +85,7 @@ static const TargetAlignElem InvalidAlignmentElem; // The StructType -> StructLayout map. - mutable StructLayoutMap *LayoutMap; + mutable void *LayoutMap; //! Set/initialize target alignments void setAlignment(AlignTypeEnum align_type, unsigned char abi_align, Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90362&r1=90361&r2=90362&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Dec 2 18:17:12 2009 @@ -325,7 +325,7 @@ typedef DenseMap LayoutInfoTy; -namespace llvm { +namespace { class StructLayoutMap : public AbstractTypeUser { LayoutInfoTy LayoutInfo; @@ -337,18 +337,12 @@ virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { const StructType *STy = dyn_cast(OldTy); - if (!STy) { - OldTy->removeAbstractTypeUser(this); - return; - } - - StructLayout *SL = LayoutInfo[STy]; - if (SL) { - SL->~StructLayout(); - free(SL); - LayoutInfo[STy] = NULL; - } + assert(STy && "This can only track struct types."); + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); OldTy->removeAbstractTypeUser(this); } @@ -359,69 +353,46 @@ /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { const StructType *STy = dyn_cast(AbsTy); - if (!STy) { - AbsTy->removeAbstractTypeUser(this); - return; - } - - StructLayout *SL = LayoutInfo[STy]; - if (SL) { - SL->~StructLayout(); - free(SL); - LayoutInfo[STy] = NULL; - } + assert(STy && "This can only track struct types."); + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); AbsTy->removeAbstractTypeUser(this); } - bool insert(const Type *Ty) { - if (Ty->isAbstract()) - Ty->addAbstractTypeUser(this); - return true; - } - public: virtual ~StructLayoutMap() { // Remove any layouts. for (LayoutInfoTy::iterator - I = LayoutInfo.begin(), E = LayoutInfo.end(); I != E; ++I) - if (StructLayout *SL = I->second) { - SL->~StructLayout(); - free(SL); + I = LayoutInfo.begin(), E = LayoutInfo.end(); I != E; ++I) { + const Type *Key = I->first; + StructLayout *Value = I->second; + + if (Key && Key->isAbstract()) + Key->removeAbstractTypeUser(this); + + if (Value) { + Value->~StructLayout(); + free(Value); } + } } - inline LayoutInfoTy::iterator begin() { - return LayoutInfo.begin(); - } - inline LayoutInfoTy::iterator end() { - return LayoutInfo.end(); - } - inline LayoutInfoTy::const_iterator begin() const { - return LayoutInfo.begin(); - } - inline LayoutInfoTy::const_iterator end() const { + LayoutInfoTy::iterator end() { return LayoutInfo.end(); } LayoutInfoTy::iterator find(const StructType *&Val) { return LayoutInfo.find(Val); } - LayoutInfoTy::const_iterator find(const StructType *&Val) const { - return LayoutInfo.find(Val); - } - bool erase(const StructType *&Val) { - return LayoutInfo.erase(Val); - } bool erase(LayoutInfoTy::iterator I) { return LayoutInfo.erase(I); } - StructLayout *&operator[](const Type *Key) { - const StructType *STy = dyn_cast(Key); - assert(STy && "Trying to access the struct layout map with a non-struct!"); - insert(STy); + StructLayout *&operator[](const StructType *STy) { return LayoutInfo[STy]; } @@ -432,14 +403,15 @@ } // end namespace llvm TargetData::~TargetData() { - delete LayoutMap; + delete static_cast(LayoutMap); } const StructLayout *TargetData::getStructLayout(const StructType *Ty) const { if (!LayoutMap) LayoutMap = new StructLayoutMap(); - StructLayout *&SL = (*LayoutMap)[Ty]; + StructLayoutMap *STM = static_cast(LayoutMap); + StructLayout *&SL = (*STM)[Ty]; if (SL) return SL; // Otherwise, create the struct layout. Because it is variable length, we @@ -453,6 +425,10 @@ SL = L; new (L) StructLayout(Ty, *this); + + if (Ty->isAbstract()) + Ty->addAbstractTypeUser(STM); + return L; } @@ -463,14 +439,17 @@ void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { if (!LayoutMap) return; // No cache. - DenseMap::iterator I = LayoutMap->find(Ty); - if (I == LayoutMap->end()) return; + StructLayoutMap *STM = static_cast(LayoutMap); + LayoutInfoTy::iterator I = STM->find(Ty); + if (I == STM->end()) return; I->second->~StructLayout(); free(I->second); - LayoutMap->erase(I); -} + STM->erase(I); + if (Ty->isAbstract()) + Ty->removeAbstractTypeUser(STM); +} std::string TargetData::getStringRepresentation() const { std::string Result; From clattner at apple.com Wed Dec 2 18:32:38 2009 From: clattner at apple.com (Chris Lattner) Date: Wed, 2 Dec 2009 16:32:38 -0800 Subject: [llvm-commits] [llvm] r89176 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp In-Reply-To: <392E62EA-54C9-4B80-91C3-85A67CBA3A68@gmail.com> References: <200911180103.nAI13usJ018941@zion.cs.uiuc.edu> <1A1AE227-CA98-41BB-864B-003A9B9EA0CD@apple.com> <392E62EA-54C9-4B80-91C3-85A67CBA3A68@gmail.com> Message-ID: <35C85951-2433-45E6-B0A0-43F0C04BA008@apple.com> On Dec 2, 2009, at 4:14 PM, Bill Wendling wrote: >>> + insert(STy); >>> + return LayoutInfo[STy]; >> >> Don't do a redundant map lookup after 'insert'. >> > I reworked a lot of this so that it's arguably more correct now...I > hope at least. Thanks Bill, definite improvement. Next round: TD.cpp:402: } // end namespace llvm -> end anonymous namespace. typedef DenseMap LayoutInfoTy; Please pull this into the StructLayoutMap class. void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { if (!LayoutMap) return; // No cache. StructLayoutMap *STM = static_cast(LayoutMap); LayoutInfoTy::iterator I = STM->find(Ty); if (I == STM->end()) return; I->second->~StructLayout(); free(I->second); STM->erase(I); if (Ty->isAbstract()) Ty->removeAbstractTypeUser(STM); } Most of this code should be in StructLayoutMap. The body should be something like: { if (!LayoutMap) return; // No cache. StructLayoutMap *STM = static_cast(LayoutMap); STM->InvalidateEntry(Ty); } and all the goop should be sucked into InvalidateEntry. This will allow removing a bunch of public methods from StructLayoutMap. virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { This should just call the new 'InvalidateEntry' method instead of duplicating the logic. Likewise with typeBecameConcrete. const StructType *STy = dyn_cast(AbsTy); assert(STy && "This can only track struct types."); Just use 'cast' instead of dyn_cast + assert. It is more efficient in a release-assert build. virtual ~StructLayoutMap() { // Remove any layouts. for (LayoutInfoTy::iterator I = LayoutInfo.begin(), E = LayoutInfo.end(); I != E; ++I) { const Type *Key = I->first; StructLayout *Value = I->second; if (Key && Key->isAbstract()) Key->removeAbstractTypeUser(this); How can Key be null? Code aggressively with strong invariants, not defensively. if (Value) { How can Value be null? Much of the logic in TargetData::getStructLayout should be sucked into StructLayoutMap. -Chris From sabre at nondot.org Wed Dec 2 18:50:43 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 00:50:43 -0000 Subject: [llvm-commits] [llvm] r90365 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ lib/Analysis/ lib/CodeGen/ lib/CodeGen/SelectionDAG/ lib/Target/ lib/Target/ARM/ lib/Target/CBackend/ lib/Target/MSP430/ lib/Target/SystemZ/ lib/Target/X86/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ Message-ID: <200912030050.nB30ojF0006758@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 18:50:42 2009 New Revision: 90365 URL: http://llvm.org/viewvc/llvm-project?rev=90365&view=rev Log: improve portability to avoid conflicting with std::next in c++'0x. Patch by Howard Hinnant! Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h llvm/trunk/include/llvm/CodeGen/LinkAllCodegenComponents.h llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h llvm/trunk/include/llvm/LinkAllVMCore.h llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp llvm/trunk/lib/CodeGen/LowerSubregs.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp llvm/trunk/lib/CodeGen/PHIElimination.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp llvm/trunk/lib/CodeGen/RegisterScavenging.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/StackSlotColoring.cpp llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp llvm/trunk/lib/Target/CBackend/CBackend.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp llvm/trunk/lib/VMCore/BasicBlock.cpp Modified: llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h (original) +++ llvm/trunk/include/llvm/CodeGen/DAGISelHeader.h Wed Dec 2 18:50:42 2009 @@ -93,7 +93,7 @@ // a reference to the root node, preventing it from being deleted, // and tracking any changes of the root. HandleSDNode Dummy(CurDAG->getRoot()); - ISelPosition = next(SelectionDAG::allnodes_iterator(CurDAG->getRoot().getNode())); + ISelPosition = llvm::next(SelectionDAG::allnodes_iterator(CurDAG->getRoot().getNode())); // The AllNodes list is now topological-sorted. Visit the // nodes by starting at the end of the list (the root of the Modified: llvm/trunk/include/llvm/CodeGen/LinkAllCodegenComponents.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LinkAllCodegenComponents.h?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LinkAllCodegenComponents.h (original) +++ llvm/trunk/include/llvm/CodeGen/LinkAllCodegenComponents.h Wed Dec 2 18:50:42 2009 @@ -19,6 +19,7 @@ #include "llvm/CodeGen/SchedulerRegistry.h" #include "llvm/CodeGen/GCs.h" #include "llvm/Target/TargetMachine.h" +#include namespace { struct ForceCodegenLinking { Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Wed Dec 2 18:50:42 2009 @@ -1095,7 +1095,7 @@ /// hasOneUse - Return true if there is exactly one use of this node. /// bool hasOneUse() const { - return !use_empty() && next(use_begin()) == use_end(); + return !use_empty() && llvm::next(use_begin()) == use_end(); } /// use_size - Return the number of uses of this node. This method takes Modified: llvm/trunk/include/llvm/LinkAllVMCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LinkAllVMCore.h?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/include/llvm/LinkAllVMCore.h (original) +++ llvm/trunk/include/llvm/LinkAllVMCore.h Wed Dec 2 18:50:42 2009 @@ -35,6 +35,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SlowOperationInformer.h" +#include namespace { struct ForceVMCoreLinking { Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Wed Dec 2 18:50:42 2009 @@ -628,7 +628,7 @@ BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); BasicBlock::iterator SaveInsertPt = Builder.GetInsertPoint(); BasicBlock::iterator NewInsertPt = - next(BasicBlock::iterator(cast(V))); + llvm::next(BasicBlock::iterator(cast(V))); while (isa(NewInsertPt)) ++NewInsertPt; V = expandCodeFor(SE.getTruncateExpr(SE.getUnknown(V), Ty), 0, NewInsertPt); @@ -844,7 +844,7 @@ if (L && S->hasComputableLoopEvolution(L)) InsertPt = L->getHeader()->getFirstNonPHI(); while (isInsertedInstruction(InsertPt)) - InsertPt = next(BasicBlock::iterator(InsertPt)); + InsertPt = llvm::next(BasicBlock::iterator(InsertPt)); break; } Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Wed Dec 2 18:50:42 2009 @@ -427,7 +427,7 @@ static void FixTail(MachineBasicBlock *CurMBB, MachineBasicBlock *SuccBB, const TargetInstrInfo *TII) { MachineFunction *MF = CurMBB->getParent(); - MachineFunction::iterator I = next(MachineFunction::iterator(CurMBB)); + MachineFunction::iterator I = llvm::next(MachineFunction::iterator(CurMBB)); MachineBasicBlock *TBB = 0, *FBB = 0; SmallVector Cond; if (I != MF->end() && @@ -805,7 +805,7 @@ // a compile-time infinite loop repeatedly doing and undoing the same // transformations.) - for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); I != E; ++I) { if (I->pred_size() >= 2 && I->pred_size() < TailMergeThreshold) { SmallPtrSet UniquePreds; @@ -833,7 +833,7 @@ continue; // This is the QBB case described above if (!FBB) - FBB = next(MachineFunction::iterator(PBB)); + FBB = llvm::next(MachineFunction::iterator(PBB)); } // Failing case: the only way IBB can be reached from PBB is via // exception handling. Happens for landing pads. Would be nice @@ -1239,7 +1239,7 @@ // B elsewhere // next: if (CurFallsThru) { - MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); + MachineBasicBlock *NextBB = llvm::next(MachineFunction::iterator(MBB)); CurCond.clear(); TII->InsertBranch(*MBB, NextBB, 0, CurCond); } Modified: llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp (original) +++ llvm/trunk/lib/CodeGen/CodePlacementOpt.cpp Wed Dec 2 18:50:42 2009 @@ -182,7 +182,7 @@ // Move it and all the blocks that can reach it via fallthrough edges // exclusively, to keep existing fallthrough edges intact. MachineFunction::iterator Begin = Pred; - MachineFunction::iterator End = next(Begin); + MachineFunction::iterator End = llvm::next(Begin); while (Begin != MF.begin()) { MachineFunction::iterator Prior = prior(Begin); if (Prior == MF.begin()) @@ -255,7 +255,8 @@ // to the top of the loop to avoid loosing that fallthrough. Otherwise append // them to the bottom, even if it previously had a fallthrough, on the theory // that it's worth an extra branch to keep the loop contiguous. - MachineFunction::iterator InsertPt = next(MachineFunction::iterator(BotMBB)); + MachineFunction::iterator InsertPt = + llvm::next(MachineFunction::iterator(BotMBB)); bool InsertAtTop = false; if (TopMBB != MF.begin() && !HasFallthrough(prior(MachineFunction::iterator(TopMBB))) && @@ -268,7 +269,7 @@ // with the loop header. SmallPtrSet ContiguousBlocks; for (MachineFunction::iterator I = TopMBB, - E = next(MachineFunction::iterator(BotMBB)); I != E; ++I) + E = llvm::next(MachineFunction::iterator(BotMBB)); I != E; ++I) ContiguousBlocks.insert(I); // Find non-contigous blocks and fix them. @@ -301,7 +302,7 @@ // Process this block and all loop blocks contiguous with it, to keep // them in their relative order. MachineFunction::iterator Begin = BB; - MachineFunction::iterator End = next(MachineFunction::iterator(BB)); + MachineFunction::iterator End = llvm::next(MachineFunction::iterator(BB)); for (; End != MF.end(); ++End) { if (!L->contains(End)) break; if (!HasAnalyzableTerminator(End)) break; Modified: llvm/trunk/lib/CodeGen/LowerSubregs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerSubregs.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LowerSubregs.cpp (original) +++ llvm/trunk/lib/CodeGen/LowerSubregs.cpp Wed Dec 2 18:50:42 2009 @@ -312,7 +312,7 @@ mbbi != mbbe; ++mbbi) { for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); mi != me;) { - MachineBasicBlock::iterator nmi = next(mi); + MachineBasicBlock::iterator nmi = llvm::next(mi); MachineInstr *MI = mi; if (MI->getOpcode() == TargetInstrInfo::EXTRACT_SUBREG) { MadeChange |= LowerExtract(MI); Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Dec 2 18:50:42 2009 @@ -290,7 +290,7 @@ } else { // The block has a fallthrough conditional branch. MachineBasicBlock *MBBA = *succ_begin(); - MachineBasicBlock *MBBB = *next(succ_begin()); + MachineBasicBlock *MBBB = *llvm::next(succ_begin()); if (MBBA == TBB) std::swap(MBBB, MBBA); if (isLayoutSuccessor(TBB)) { if (TII->ReverseBranchCondition(Cond)) { @@ -359,7 +359,7 @@ bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const { MachineFunction::const_iterator I(this); - return next(I) == MachineFunction::const_iterator(MBB); + return llvm::next(I) == MachineFunction::const_iterator(MBB); } bool MachineBasicBlock::canFallThrough() { @@ -461,7 +461,8 @@ bool MadeChange = false; bool AddedFallThrough = false; - MachineFunction::iterator FallThru = next(MachineFunction::iterator(this)); + MachineFunction::iterator FallThru = + llvm::next(MachineFunction::iterator(this)); // If this block ends with a conditional branch that falls through to its // successor, set DestB as the successor. Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Wed Dec 2 18:50:42 2009 @@ -328,7 +328,7 @@ if (I->second) OS << " in reg%" << I->second; - if (next(I) != E) + if (llvm::next(I) != E) OS << ", "; } OS << '\n'; @@ -342,7 +342,7 @@ else OS << "%physreg" << *I; - if (next(I) != E) + if (llvm::next(I) != E) OS << " "; } OS << '\n'; Modified: llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineLoopInfo.cpp Wed Dec 2 18:50:42 2009 @@ -62,11 +62,11 @@ MachineBasicBlock *BotMBB = getHeader(); MachineFunction::iterator End = BotMBB->getParent()->end(); if (BotMBB != prior(End)) { - MachineBasicBlock *NextMBB = next(MachineFunction::iterator(BotMBB)); + MachineBasicBlock *NextMBB = llvm::next(MachineFunction::iterator(BotMBB)); while (contains(NextMBB)) { BotMBB = NextMBB; - if (BotMBB == next(MachineFunction::iterator(BotMBB))) break; - NextMBB = next(MachineFunction::iterator(BotMBB)); + if (BotMBB == llvm::next(MachineFunction::iterator(BotMBB))) break; + NextMBB = llvm::next(MachineFunction::iterator(BotMBB)); } } return BotMBB; Modified: llvm/trunk/lib/CodeGen/PHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PHIElimination.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/PHIElimination.cpp Wed Dec 2 18:50:42 2009 @@ -301,8 +301,8 @@ // Check that no other terminators use values. #ifndef NDEBUG - for (MachineBasicBlock::iterator TI = next(Term); TI != opBlock.end(); - ++TI) { + for (MachineBasicBlock::iterator TI = llvm::next(Term); + TI != opBlock.end(); ++TI) { assert(!TI->readsRegister(SrcReg) && "Terminator instructions cannot use virtual registers unless" "they are the first terminator in a block!"); @@ -377,7 +377,7 @@ ++NumSplits; MachineBasicBlock *NMBB = MF->CreateMachineBasicBlock(); - MF->insert(next(MachineFunction::iterator(A)), NMBB); + MF->insert(llvm::next(MachineFunction::iterator(A)), NMBB); DEBUG(errs() << "PHIElimination splitting critical edge:" " BB#" << A->getNumber() << " -- BB#" << NMBB->getNumber() Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Wed Dec 2 18:50:42 2009 @@ -876,7 +876,7 @@ if (!ValNo->isDefAccurate() || DefMI->getParent() == BarrierMBB) KillPt = findSpillPoint(BarrierMBB, Barrier, NULL, RefsInMBB); else - KillPt = next(MachineBasicBlock::iterator(DefMI)); + KillPt = llvm::next(MachineBasicBlock::iterator(DefMI)); if (KillPt == DefMI->getParent()->end()) return false; @@ -1118,7 +1118,7 @@ return false; // No gap to insert spill. } } else { - SpillPt = next(MachineBasicBlock::iterator(DefMI)); + SpillPt = llvm::next(MachineBasicBlock::iterator(DefMI)); if (SpillPt == DefMBB->end()) { DEBUG(errs() << "FAILED (could not find a suitable spill point).\n"); return false; // No gap to insert spill. Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Wed Dec 2 18:50:42 2009 @@ -674,7 +674,7 @@ if (PrevI == BB->end()) I = BB->begin(); // The replaced instr was the first in the block. else - I = next(PrevI); + I = llvm::next(PrevI); continue; } Modified: llvm/trunk/lib/CodeGen/RegisterScavenging.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterScavenging.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterScavenging.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterScavenging.cpp Wed Dec 2 18:50:42 2009 @@ -125,7 +125,7 @@ Tracking = true; } else { assert(MBBI != MBB->end() && "Already at the end of the basic block!"); - MBBI = next(MBBI); + MBBI = llvm::next(MBBI); } MachineInstr *MI = MBBI; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Dec 2 18:50:42 2009 @@ -541,7 +541,7 @@ void FastISel::FastEmitBranch(MachineBasicBlock *MSucc) { MachineFunction::iterator NextMBB = - next(MachineFunction::iterator(MBB)); + llvm::next(MachineFunction::iterator(MBB)); if (MBB->isLayoutSuccessor(MSucc)) { // The unconditional fall-through case, which needs no instructions. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Wed Dec 2 18:50:42 2009 @@ -232,7 +232,7 @@ // node is only legalized after all of its operands are legalized. DAG.AssignTopologicalOrder(); for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(), - E = prior(DAG.allnodes_end()); I != next(E); ++I) + E = prior(DAG.allnodes_end()); I != llvm::next(E); ++I) LegalizeOp(SDValue(I, 0)); // Finally, it's possible the root changed. Get the new root. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp Wed Dec 2 18:50:42 2009 @@ -79,7 +79,7 @@ // node is only legalized after all of its operands are legalized. DAG.AssignTopologicalOrder(); for (SelectionDAG::allnodes_iterator I = DAG.allnodes_begin(), - E = prior(DAG.allnodes_end()); I != next(E); ++I) + E = prior(DAG.allnodes_end()); I != llvm::next(E); ++I) LegalizeOp(SDValue(I, 0)); // Finally, it's possible the root changed. Get the new root. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Wed Dec 2 18:50:42 2009 @@ -789,7 +789,7 @@ SDB->setCurDebugLoc(FastIS->getCurDebugLoc()); bool HadTailCall = false; - SelectBasicBlock(LLVMBB, BI, next(BI), HadTailCall); + SelectBasicBlock(LLVMBB, BI, llvm::next(BI), HadTailCall); // If the call was emitted as a tail call, we're done with the block. if (HadTailCall) { Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed Dec 2 18:50:42 2009 @@ -130,7 +130,8 @@ // See PR3149: // 172 %ECX = MOV32rr %reg1039 // 180 INLINEASM , 10, %EAX, 14, %ECX, 9, %EAX, + // sbbl $3,$0>, 10, %EAX, 14, %ECX, 9, + // %EAX, // 36, , 1, %reg0, 0, 9, %ECX, 36, , 1, %reg0, 0 // 188 %EAX = MOV32rr %EAX // 196 %ECX = MOV32rr %ECX @@ -281,12 +282,12 @@ } } -/// RemoveCopyByCommutingDef - We found a non-trivially-coalescable copy with IntA -/// being the source and IntB being the dest, thus this defines a value number -/// in IntB. If the source value number (in IntA) is defined by a commutable -/// instruction and its other operand is coalesced to the copy dest register, -/// see if we can transform the copy into a noop by commuting the definition. For -/// example, +/// RemoveCopyByCommutingDef - We found a non-trivially-coalescable copy with +/// IntA being the source and IntB being the dest, thus this defines a value +/// number in IntB. If the source value number (in IntA) is defined by a +/// commutable instruction and its other operand is coalesced to the copy dest +/// register, see if we can transform the copy into a noop by commuting the +/// definition. For example, /// /// A3 = op A2 B0 /// ... @@ -508,7 +509,8 @@ if (BHasSubRegs) { for (const unsigned *SR = tri_->getSubRegisters(IntB.reg); *SR; ++SR) { LiveInterval &SRLI = li_->getInterval(*SR); - SRLI.MergeInClobberRange(*li_, AI->start, End, li_->getVNInfoAllocator()); + SRLI.MergeInClobberRange(*li_, AI->start, End, + li_->getVNInfoAllocator()); } } } @@ -708,7 +710,8 @@ checkForDeadDef = true; } - MachineBasicBlock::iterator MII = next(MachineBasicBlock::iterator(CopyMI)); + MachineBasicBlock::iterator MII = + llvm::next(MachineBasicBlock::iterator(CopyMI)); tii_->reMaterialize(*MBB, MII, DstReg, DstSubIdx, DefMI, tri_); MachineInstr *NewMI = prior(MII); @@ -1611,9 +1614,9 @@ } } } else { - // If the virtual register live interval is long but it has low use desity, - // do not join them, instead mark the physical register as its allocation - // preference. + // If the virtual register live interval is long but it has low use + // density, do not join them, instead mark the physical register as its + // allocation preference. LiveInterval &JoinVInt = SrcIsPhys ? DstInt : SrcInt; unsigned JoinVReg = SrcIsPhys ? DstReg : SrcReg; unsigned JoinPReg = SrcIsPhys ? SrcReg : DstReg; @@ -2739,7 +2742,8 @@ joinIntervals(); DEBUG({ errs() << "********** INTERVALS POST JOINING **********\n"; - for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); I != E; ++I){ + for (LiveIntervals::iterator I = li_->begin(), E = li_->end(); + I != E; ++I){ I->second->print(errs(), tri_); errs() << "\n"; } @@ -2780,7 +2784,7 @@ DoDelete = true; } if (!DoDelete) - mii = next(mii); + mii = llvm::next(mii); else { li_->RemoveMachineInstrFromMaps(MI); mii = mbbi->erase(mii); Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Wed Dec 2 18:50:42 2009 @@ -140,9 +140,9 @@ // Insert store if necessary. if (hasDef) { - tii->storeRegToStackSlot(*mi->getParent(), next(miItr), newVReg, true, + tii->storeRegToStackSlot(*mi->getParent(), llvm::next(miItr), newVReg, true, ss, trc); - MachineInstr *storeInstr(next(miItr)); + MachineInstr *storeInstr(llvm::next(miItr)); SlotIndex storeIndex = lis->InsertMachineInstrInMaps(storeInstr).getDefIndex(); SlotIndex beginIndex = storeIndex.getPrevIndex(); Modified: llvm/trunk/lib/CodeGen/StackSlotColoring.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StackSlotColoring.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/StackSlotColoring.cpp (original) +++ llvm/trunk/lib/CodeGen/StackSlotColoring.cpp Wed Dec 2 18:50:42 2009 @@ -668,7 +668,7 @@ if (DCELimit != -1 && (int)NumDead >= DCELimit) break; - MachineBasicBlock::iterator NextMI = next(I); + MachineBasicBlock::iterator NextMI = llvm::next(I); if (NextMI == MBB->end()) continue; int FirstSS, SecondSS; Modified: llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetInstrInfoImpl.cpp Wed Dec 2 18:50:42 2009 @@ -329,7 +329,7 @@ return false; // For the def, it should be the only def of that register. - if (MO.isDef() && (next(MRI.def_begin(Reg)) != MRI.def_end() || + if (MO.isDef() && (llvm::next(MRI.def_begin(Reg)) != MRI.def_end() || MRI.isLiveIn(Reg))) return false; Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Wed Dec 2 18:50:42 2009 @@ -211,7 +211,7 @@ ++KillPos; unsigned NumVisited = 0; - for (MachineBasicBlock::iterator I = next(OldPos); I != KillPos; ++I) { + for (MachineBasicBlock::iterator I = llvm::next(OldPos); I != KillPos; ++I) { MachineInstr *OtherMI = I; if (NumVisited > 30) // FIXME: Arbitrary limit to reduce compile time cost. return false; @@ -412,7 +412,7 @@ MachineRegisterInfo::def_iterator Begin = MRI->def_begin(Reg); // If there are multiple defs, we can't do a simple analysis, so just // go with what the kill flag says. - if (next(Begin) != MRI->def_end()) + if (llvm::next(Begin) != MRI->def_end()) return true; DefMI = &*Begin; bool IsSrcPhys, IsDstPhys; @@ -643,7 +643,7 @@ if (!Sunk) { DistanceMap.insert(std::make_pair(NewMI, Dist)); mi = NewMI; - nmi = next(mi); + nmi = llvm::next(mi); } return true; } @@ -923,7 +923,7 @@ Processed.clear(); for (MachineBasicBlock::iterator mi = mbbi->begin(), me = mbbi->end(); mi != me; ) { - MachineBasicBlock::iterator nmi = next(mi); + MachineBasicBlock::iterator nmi = llvm::next(mi); const TargetInstrDesc &TID = mi->getDesc(); bool FirstTied = true; Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Wed Dec 2 18:50:42 2009 @@ -754,7 +754,7 @@ } // Skip over the same register. - std::multimap::iterator NI = next(I); + std::multimap::iterator NI = llvm::next(I); while (NI != E && NI->first == Reg) { ++I; ++NI; @@ -1133,7 +1133,7 @@ std::vector &KillOps, VirtRegMap &VRM) { - MachineBasicBlock::iterator NextMII = next(MII); + MachineBasicBlock::iterator NextMII = llvm::next(MII); if (NextMII == MBB.end()) return false; @@ -1186,7 +1186,7 @@ // Unfold next instructions that fold the same SS. do { MachineInstr &NextMI = *NextMII; - NextMII = next(NextMII); + NextMII = llvm::next(NextMII); NewMIs.clear(); if (!TII->unfoldMemoryOperand(MF, &NextMI, VirtReg, false, false, NewMIs)) llvm_unreachable("Unable unfold the load / store folding instruction!"); @@ -1463,8 +1463,8 @@ std::vector &KillOps, VirtRegMap &VRM) { - MachineBasicBlock::iterator oldNextMII = next(MII); - TII->storeRegToStackSlot(MBB, next(MII), PhysReg, true, StackSlot, RC); + MachineBasicBlock::iterator oldNextMII = llvm::next(MII); + TII->storeRegToStackSlot(MBB, llvm::next(MII), PhysReg, true, StackSlot, RC); MachineInstr *StoreMI = prior(oldNextMII); VRM.addSpillSlotUse(StackSlot, StoreMI); DEBUG(errs() << "Store:\t" << *StoreMI); @@ -1626,14 +1626,14 @@ DistanceMap.clear(); for (MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); MII != E; ) { - MachineBasicBlock::iterator NextMII = next(MII); + MachineBasicBlock::iterator NextMII = llvm::next(MII); VirtRegMap::MI2VirtMapTy::const_iterator I, End; bool Erased = false; bool BackTracked = false; if (OptimizeByUnfold(MBB, MII, MaybeDeadStores, Spills, RegKills, KillOps, VRM)) - NextMII = next(MII); + NextMII = llvm::next(MII); MachineInstr &MI = *MII; @@ -1657,7 +1657,7 @@ // Back-schedule reloads and remats. MachineBasicBlock::iterator InsertLoc = - ComputeReloadLoc(next(MII), MBB.begin(), PhysReg, TRI, false, + ComputeReloadLoc(llvm::next(MII), MBB.begin(), PhysReg, TRI, false, SS, TII, MF); TII->loadRegFromStackSlot(MBB, InsertLoc, PhysReg, SS, RC); @@ -1667,7 +1667,7 @@ ++NumPSpills; DistanceMap.insert(std::make_pair(LoadMI, Dist++)); } - NextMII = next(MII); + NextMII = llvm::next(MII); } // Insert restores here if asked to. @@ -1785,14 +1785,14 @@ const TargetRegisterClass *RC = RegInfo->getRegClass(VirtReg); unsigned Phys = VRM.getPhys(VirtReg); int StackSlot = VRM.getStackSlot(VirtReg); - MachineBasicBlock::iterator oldNextMII = next(MII); - TII->storeRegToStackSlot(MBB, next(MII), Phys, isKill, StackSlot, RC); + MachineBasicBlock::iterator oldNextMII = llvm::next(MII); + TII->storeRegToStackSlot(MBB, llvm::next(MII), Phys, isKill, StackSlot, RC); MachineInstr *StoreMI = prior(oldNextMII); VRM.addSpillSlotUse(StackSlot, StoreMI); DEBUG(errs() << "Store:\t" << *StoreMI); VRM.virtFolded(VirtReg, StoreMI, VirtRegMap::isMod); } - NextMII = next(MII); + NextMII = llvm::next(MII); } /// ReusedOperands - Keep track of operand reuse in case we need to undo @@ -2265,7 +2265,7 @@ if (CommuteToFoldReload(MBB, MII, VirtReg, SrcReg, StackSlot, Spills, RegKills, KillOps, TRI, VRM)) { - NextMII = next(MII); + NextMII = llvm::next(MII); BackTracked = true; goto ProcessNextInst; } @@ -2381,7 +2381,7 @@ MachineInstr *&LastStore = MaybeDeadStores[StackSlot]; SpillRegToStackSlot(MBB, MII, -1, PhysReg, StackSlot, RC, true, LastStore, Spills, ReMatDefs, RegKills, KillOps, VRM); - NextMII = next(MII); + NextMII = llvm::next(MII); // Check to see if this is a noop copy. If so, eliminate the // instruction before considering the dest reg to be changed. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Wed Dec 2 18:50:42 2009 @@ -418,10 +418,10 @@ static bool BBHasFallthrough(MachineBasicBlock *MBB) { // Get the next machine basic block in the function. MachineFunction::iterator MBBI = MBB; - if (next(MBBI) == MBB->getParent()->end()) // Can't fall off end of function. + if (llvm::next(MBBI) == MBB->getParent()->end()) // Can't fall off end of function. return false; - MachineBasicBlock *NextBB = next(MBBI); + MachineBasicBlock *NextBB = llvm::next(MBBI); for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(), E = MBB->succ_end(); I != E; ++I) if (*I == NextBB) @@ -760,7 +760,7 @@ CompareMBBNumbers); MachineBasicBlock* WaterBB = *IP; if (WaterBB == OrigBB) - WaterList.insert(next(IP), NewBB); + WaterList.insert(llvm::next(IP), NewBB); else WaterList.insert(IP, OrigBB); NewWaterList.insert(OrigBB); @@ -887,7 +887,7 @@ void ARMConstantIslands::AdjustBBOffsetsAfter(MachineBasicBlock *BB, int delta) { - MachineFunction::iterator MBBI = BB; MBBI = next(MBBI); + MachineFunction::iterator MBBI = BB; MBBI = llvm::next(MBBI); for(unsigned i = BB->getNumber()+1, e = BB->getParent()->getNumBlockIDs(); i < e; ++i) { BBOffsets[i] += delta; @@ -929,7 +929,7 @@ if (delta==0) return; } - MBBI = next(MBBI); + MBBI = llvm::next(MBBI); } } @@ -1096,7 +1096,7 @@ DEBUG(errs() << "Split at end of block\n"); if (&UserMBB->back() == UserMI) assert(BBHasFallthrough(UserMBB) && "Expected a fallthrough BB!"); - NewMBB = next(MachineFunction::iterator(UserMBB)); + NewMBB = llvm::next(MachineFunction::iterator(UserMBB)); // Add an unconditional branch from UserMBB to fallthrough block. // Record it for branch lengthening; this new branch will not get out of // range, but if the preceding conditional branch is out of range, the @@ -1144,7 +1144,7 @@ for (unsigned Offset = UserOffset+TII->GetInstSizeInBytes(UserMI); Offset < BaseInsertOffset; Offset += TII->GetInstSizeInBytes(MI), - MI = next(MI)) { + MI = llvm::next(MI)) { if (CPUIndex < CPUsers.size() && CPUsers[CPUIndex].MI == MI) { CPUser &U = CPUsers[CPUIndex]; if (!OffsetIsInRange(Offset, EndInsertOffset, @@ -1204,7 +1204,7 @@ NewWaterList.insert(NewIsland); } // The new CPE goes before the following block (NewMBB). - NewMBB = next(MachineFunction::iterator(WaterBB)); + NewMBB = llvm::next(MachineFunction::iterator(WaterBB)); } else { // No water found. @@ -1406,7 +1406,7 @@ NumCBrFixed++; if (BMI != MI) { - if (next(MachineBasicBlock::iterator(MI)) == prior(MBB->end()) && + if (llvm::next(MachineBasicBlock::iterator(MI)) == prior(MBB->end()) && BMI->getOpcode() == Br.UncondBr) { // Last MI in the BB is an unconditional branch. Can we simply invert the // condition and swap destinations: @@ -1433,12 +1433,12 @@ // branch to the destination. int delta = TII->GetInstSizeInBytes(&MBB->back()); BBSizes[MBB->getNumber()] -= delta; - MachineBasicBlock* SplitBB = next(MachineFunction::iterator(MBB)); + MachineBasicBlock* SplitBB = llvm::next(MachineFunction::iterator(MBB)); AdjustBBOffsetsAfter(SplitBB, -delta); MBB->back().eraseFromParent(); // BBOffsets[SplitBB] is wrong temporarily, fixed below } - MachineBasicBlock *NextBB = next(MachineFunction::iterator(MBB)); + MachineBasicBlock *NextBB = llvm::next(MachineFunction::iterator(MBB)); DEBUG(errs() << " Insert B to BB#" << DestBB->getNumber() << " also invert condition and change dest. to BB#" Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Wed Dec 2 18:50:42 2009 @@ -48,7 +48,7 @@ MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end(); while (MBBI != E) { MachineInstr &MI = *MBBI; - MachineBasicBlock::iterator NMBBI = next(MBBI); + MachineBasicBlock::iterator NMBBI = llvm::next(MBBI); unsigned Opcode = MI.getOpcode(); switch (Opcode) { Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Wed Dec 2 18:50:42 2009 @@ -449,7 +449,7 @@ } if (MBBI != MBB.end()) { - MachineBasicBlock::iterator NextMBBI = next(MBBI); + MachineBasicBlock::iterator NextMBBI = llvm::next(MBBI); if ((Mode == ARM_AM::ia || Mode == ARM_AM::ib) && isMatchingIncrement(NextMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM4ModeImm(Mode, true)); @@ -494,7 +494,7 @@ } if (MBBI != MBB.end()) { - MachineBasicBlock::iterator NextMBBI = next(MBBI); + MachineBasicBlock::iterator NextMBBI = llvm::next(MBBI); if (Mode == ARM_AM::ia && isMatchingIncrement(NextMBBI, Base, Bytes, 0, Pred, PredReg)) { MI->getOperand(1).setImm(ARM_AM::getAM5Opc(ARM_AM::ia, true, Offset)); @@ -604,7 +604,7 @@ } if (!DoMerge && MBBI != MBB.end()) { - MachineBasicBlock::iterator NextMBBI = next(MBBI); + MachineBasicBlock::iterator NextMBBI = llvm::next(MBBI); if (!isAM5 && isMatchingDecrement(NextMBBI, Base, Bytes, Limit, Pred, PredReg)) { DoMerge = true; Modified: llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp (original) +++ llvm/trunk/lib/Target/ARM/NEONMoveFix.cpp Wed Dec 2 18:50:42 2009 @@ -51,7 +51,7 @@ MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); MachineBasicBlock::iterator NextMII; for (; MII != E; MII = NextMII) { - NextMII = next(MII); + NextMII = llvm::next(MII); MachineInstr *MI = &*MII; if (MI->getOpcode() == ARM::VMOVD && Modified: llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/NEONPreAllocPass.cpp Wed Dec 2 18:50:42 2009 @@ -338,7 +338,7 @@ if (!isNEONMultiRegOp(MI->getOpcode(), FirstOpnd, NumRegs, Offset, Stride)) continue; - MachineBasicBlock::iterator NextI = next(MBBI); + MachineBasicBlock::iterator NextI = llvm::next(MBBI); for (unsigned R = 0; R < NumRegs; ++R) { MachineOperand &MO = MI->getOperand(FirstOpnd + R); assert(MO.isReg() && MO.getSubReg() == 0 && "unexpected operand"); Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Wed Dec 2 18:50:42 2009 @@ -528,7 +528,7 @@ MI.getOperand(i+1).ChangeToImmediate(Mask); } Offset = (Offset - Mask * Scale); - MachineBasicBlock::iterator NII = next(II); + MachineBasicBlock::iterator NII = llvm::next(II); emitThumbRegPlusImmediate(MBB, NII, DestReg, DestReg, Offset, TII, *this, dl); } else { Modified: llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Wed Dec 2 18:50:42 2009 @@ -649,7 +649,7 @@ MachineBasicBlock::iterator MII = MBB.begin(), E = MBB.end(); MachineBasicBlock::iterator NextMII; for (; MII != E; MII = NextMII) { - NextMII = next(MII); + NextMII = llvm::next(MII); MachineInstr *MI = &*MII; LiveCPSR = UpdateCPSRUse(*MI, LiveCPSR); Modified: llvm/trunk/lib/Target/CBackend/CBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/CBackend.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/CBackend/CBackend.cpp (original) +++ llvm/trunk/lib/Target/CBackend/CBackend.cpp Wed Dec 2 18:50:42 2009 @@ -2573,7 +2573,7 @@ BasicBlock *Succ = cast(SI.getOperand(i+1)); printPHICopiesForSuccessor (SI.getParent(), Succ, 2); printBranchToBlock(SI.getParent(), Succ, 2); - if (Function::iterator(Succ) == next(Function::iterator(SI.getParent()))) + if (Function::iterator(Succ) == llvm::next(Function::iterator(SI.getParent()))) Out << " break;\n"; } Out << " }\n"; @@ -2593,7 +2593,7 @@ /// FIXME: This should be reenabled, but loop reordering safe!! return true; - if (next(Function::iterator(From)) != Function::iterator(To)) + if (llvm::next(Function::iterator(From)) != Function::iterator(To)) return true; // Not the direct successor, we need a goto. //isa(From->getTerminator()) Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Wed Dec 2 18:50:42 2009 @@ -270,8 +270,8 @@ } // If the block has any instructions after a JMP, delete them. - while (next(I) != MBB.end()) - next(I)->eraseFromParent(); + while (llvm::next(I) != MBB.end()) + llvm::next(I)->eraseFromParent(); Cond.clear(); FBB = 0; Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp Wed Dec 2 18:50:42 2009 @@ -193,10 +193,10 @@ // We need to materialize the offset via add instruction. unsigned DstReg = MI.getOperand(0).getReg(); if (Offset < 0) - BuildMI(MBB, next(II), dl, TII.get(MSP430::SUB16ri), DstReg) + BuildMI(MBB, llvm::next(II), dl, TII.get(MSP430::SUB16ri), DstReg) .addReg(DstReg).addImm(-Offset); else - BuildMI(MBB, next(II), dl, TII.get(MSP430::ADD16ri), DstReg) + BuildMI(MBB, llvm::next(II), dl, TII.get(MSP430::ADD16ri), DstReg) .addReg(DstReg).addImm(Offset); return 0; @@ -251,7 +251,7 @@ .addReg(MSP430::SPW); // Mark the FramePtr as live-in in every block except the entry. - for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); I != E; ++I) I->addLiveIn(MSP430::FPW); Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp Wed Dec 2 18:50:42 2009 @@ -454,8 +454,8 @@ } // If the block has any instructions after a JMP, delete them. - while (next(I) != MBB.end()) - next(I)->eraseFromParent(); + while (llvm::next(I) != MBB.end()) + llvm::next(I)->eraseFromParent(); Cond.clear(); FBB = 0; Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp Wed Dec 2 18:50:42 2009 @@ -247,7 +247,7 @@ .addReg(SystemZ::R15D); // Mark the FramePtr as live-in in every block except the entry. - for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); I != E; ++I) I->addLiveIn(SystemZ::R11D); Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Dec 2 18:50:42 2009 @@ -29,6 +29,7 @@ #include "llvm/ADT/DenseMap.h" #include #include +#include using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Wed Dec 2 18:50:42 2009 @@ -16,6 +16,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/ADT/StringSet.h" +#include "X86MachinefunctionInfo.h" namespace llvm { class X86MachineFunctionInfo; Modified: llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FloatingPoint.cpp Wed Dec 2 18:50:42 2009 @@ -289,7 +289,7 @@ while (Start != BB.begin() && prior(Start) != PrevI) --Start; errs() << "Inserted instructions:\n\t"; Start->print(errs(), &MF.getTarget()); - while (++Start != next(I)) {} + while (++Start != llvm::next(I)) {} } dumpStack(); ); Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Dec 2 18:50:42 2009 @@ -1587,8 +1587,8 @@ } // If the block has any instructions after a JMP, delete them. - while (next(I) != MBB.end()) - next(I)->eraseFromParent(); + while (llvm::next(I) != MBB.end()) + llvm::next(I)->eraseFromParent(); Cond.clear(); FBB = 0; // Delete the JMP if it's equivalent to a fall-through. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Dec 2 18:50:42 2009 @@ -723,7 +723,7 @@ if (MBBI == MBB.end()) return; - MachineBasicBlock::iterator NI = next(MBBI); + MachineBasicBlock::iterator NI = llvm::next(MBBI); if (NI == MBB.end()) return; unsigned Opc = NI->getOpcode(); @@ -757,7 +757,7 @@ return 0; MachineBasicBlock::iterator PI = doMergeWithPrevious ? prior(MBBI) : MBBI; - MachineBasicBlock::iterator NI = doMergeWithPrevious ? 0 : next(MBBI); + MachineBasicBlock::iterator NI = doMergeWithPrevious ? 0 : llvm::next(MBBI); unsigned Opc = PI->getOpcode(); int Offset = 0; @@ -983,7 +983,7 @@ } // Mark the FramePtr as live-in in every block except the entry. - for (MachineFunction::iterator I = next(MF.begin()), E = MF.end(); + for (MachineFunction::iterator I = llvm::next(MF.begin()), E = MF.end(); I != E; ++I) I->addLiveIn(FramePtr); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyHalfPowrLibCalls.cpp Wed Dec 2 18:50:42 2009 @@ -88,7 +88,7 @@ if (!isa(Body->getTerminator())) break; - Instruction *NextInst = next(BasicBlock::iterator(Call)); + Instruction *NextInst = llvm::next(BasicBlock::iterator(Call)); // Inline the call, taking care of what code ends up where. NewBlock = SplitBlock(NextInst->getParent(), NextInst, this); Modified: llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LowerSwitch.cpp Wed Dec 2 18:50:42 2009 @@ -244,7 +244,7 @@ // Merge case into clusters if (Cases.size()>=2) - for (CaseItr I=Cases.begin(), J=next(Cases.begin()); J!=Cases.end(); ) { + for (CaseItr I=Cases.begin(), J=llvm::next(Cases.begin()); J!=Cases.end(); ) { int64_t nextValue = cast(J->Low)->getSExtValue(); int64_t currentValue = cast(I->High)->getSExtValue(); BasicBlock* nextBB = J->BB; Modified: llvm/trunk/lib/VMCore/BasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/BasicBlock.cpp?rev=90365&r1=90364&r2=90365&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/BasicBlock.cpp (original) +++ llvm/trunk/lib/VMCore/BasicBlock.cpp Wed Dec 2 18:50:42 2009 @@ -262,7 +262,7 @@ assert(I != InstList.end() && "Trying to get me to create degenerate basic block!"); - BasicBlock *InsertBefore = next(Function::iterator(this)) + BasicBlock *InsertBefore = llvm::next(Function::iterator(this)) .getNodePtrUnchecked(); BasicBlock *New = BasicBlock::Create(getContext(), BBName, getParent(), InsertBefore); From sabre at nondot.org Wed Dec 2 18:55:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 00:55:05 -0000 Subject: [llvm-commits] [llvm] r90366 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <200912030055.nB30t5vp006910@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 18:55:04 2009 New Revision: 90366 URL: http://llvm.org/viewvc/llvm-project?rev=90366&view=rev Log: remove some dead std::ostream using code. Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=90366&r1=90365&r2=90366&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Wed Dec 2 18:55:04 2009 @@ -59,8 +59,6 @@ unsigned char pref_align, uint32_t bit_width); /// Equality predicate bool operator==(const TargetAlignElem &rhs) const; - /// output stream operator - std::ostream &dump(std::ostream &os) const; }; class TargetData : public ImmutablePass { Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90366&r1=90365&r2=90366&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Dec 2 18:55:04 2009 @@ -29,7 +29,6 @@ #include "llvm/ADT/DenseMap.h" #include #include -#include using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. @@ -118,14 +117,6 @@ && TypeBitWidth == rhs.TypeBitWidth); } -std::ostream & -TargetAlignElem::dump(std::ostream &os) const { - return os << AlignType - << TypeBitWidth - << ":" << (int) (ABIAlign * 8) - << ":" << (int) (PrefAlign * 8); -} - const TargetAlignElem TargetData::InvalidAlignmentElem = TargetAlignElem::get((AlignTypeEnum) -1, 0, 0, 0); From sabre at nondot.org Wed Dec 2 19:05:45 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 01:05:45 -0000 Subject: [llvm-commits] [llvm] r90369 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/InstCombine/crash.ll Message-ID: <200912030105.nB315j02007436@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 19:05:45 2009 New Revision: 90369 URL: http://llvm.org/viewvc/llvm-project?rev=90369&view=rev Log: fix PR5673 by being more careful about pointers to functions. Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/test/Transforms/InstCombine/crash.ll Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=90369&r1=90368&r2=90369&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Wed Dec 2 19:05:45 2009 @@ -569,9 +569,16 @@ SmallVector NewIdxs; do { if (const SequentialType *ATy = dyn_cast(Ty)) { - // The only pointer indexing we'll do is on the first index of the GEP. - if (isa(ATy) && !NewIdxs.empty()) - break; + if (isa(ATy)) { + // The only pointer indexing we'll do is on the first index of the GEP. + if (!NewIdxs.empty()) + break; + + // Only handle pointers to sized types, not pointers to functions. + if (!ATy->getElementType()->isSized()) + return 0; + } + // Determine which element of the array the offset points into. APInt ElemSize(BitWidth, TD->getTypeAllocSize(ATy->getElementType())); if (ElemSize == 0) Modified: llvm/trunk/test/Transforms/InstCombine/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/crash.ll?rev=90369&r1=90368&r2=90369&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/crash.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/crash.ll Wed Dec 2 19:05:45 2009 @@ -137,3 +137,14 @@ exit: ret void } + + +; PR5673 + + at test6g = external global i32* + +define arm_aapcs_vfpcc i32 @test6(i32 %argc, i8** %argv) nounwind { +entry: + store i32* getelementptr (i32* bitcast (i32 (i32, i8**)* @test6 to i32*), i32 -2048), i32** @test6g, align 4 + unreachable +} From sabre at nondot.org Wed Dec 2 19:10:05 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 01:10:05 -0000 Subject: [llvm-commits] [llvm] r90370 - /llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Message-ID: <200912030110.nB31A5lp007635@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 19:10:05 2009 New Revision: 90370 URL: http://llvm.org/viewvc/llvm-project?rev=90370&view=rev Log: yay for case insensitive file systems (?) Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Modified: llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h?rev=90370&r1=90369&r2=90370&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86COFFMachineModuleInfo.h Wed Dec 2 19:10:05 2009 @@ -16,7 +16,7 @@ #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/ADT/StringSet.h" -#include "X86MachinefunctionInfo.h" +#include "X86MachineFunctionInfo.h" namespace llvm { class X86MachineFunctionInfo; From isanbard at gmail.com Wed Dec 2 19:15:46 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Dec 2009 01:15:46 -0000 Subject: [llvm-commits] [llvm] r90371 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912030115.nB31Fkj0007834@zion.cs.uiuc.edu> Author: void Date: Wed Dec 2 19:15:46 2009 New Revision: 90371 URL: http://llvm.org/viewvc/llvm-project?rev=90371&view=rev Log: Further improvements: refactoring code that does the same thing into one function, converting "dyn_cast" to "cast", asserting the correct things, and other general cleanups. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90371&r1=90370&r2=90371&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Dec 2 19:15:46 2009 @@ -315,11 +315,12 @@ : Alignments[BestMatchIdx].PrefAlign; } -typedef DenseMap LayoutInfoTy; - namespace { class StructLayoutMap : public AbstractTypeUser { +public: + typedef DenseMap LayoutInfoTy; +private: LayoutInfoTy LayoutInfo; /// refineAbstractType - The callback method invoked when an abstract type is @@ -328,14 +329,9 @@ /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { - const StructType *STy = dyn_cast(OldTy); - assert(STy && "This can only track struct types."); - - LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); - Iter->second->~StructLayout(); - free(Iter->second); - LayoutInfo.erase(Iter); - OldTy->removeAbstractTypeUser(this); + assert(LayoutInfo.find(cast(OldTy)) != LayoutInfo.end() && + "Abstract value not in local map!"); + InvalidateEntry(cast(OldTy)); } /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware @@ -344,14 +340,9 @@ /// This method notifies ATU's when this occurs for a type. /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { - const StructType *STy = dyn_cast(AbsTy); - assert(STy && "This can only track struct types."); - - LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); - Iter->second->~StructLayout(); - free(Iter->second); - LayoutInfo.erase(Iter); - AbsTy->removeAbstractTypeUser(this); + assert(LayoutInfo.find(cast(AbsTy)) != LayoutInfo.end() && + "Abstract value not in local map!"); + InvalidateEntry(cast(AbsTy)); } public: @@ -365,23 +356,21 @@ if (Key && Key->isAbstract()) Key->removeAbstractTypeUser(this); - if (Value) { - Value->~StructLayout(); - free(Value); - } + Value->~StructLayout(); + free(Value); } } - LayoutInfoTy::iterator end() { - return LayoutInfo.end(); - } - - LayoutInfoTy::iterator find(const StructType *&Val) { - return LayoutInfo.find(Val); - } + void InvalidateEntry(const StructType *Ty) { + LayoutInfoTy::iterator I = LayoutInfo.find(Ty); + if (I == LayoutInfo.end()) return; + + I->second->~StructLayout(); + free(I->second); + LayoutInfo.erase(I); - bool erase(LayoutInfoTy::iterator I) { - return LayoutInfo.erase(I); + if (Ty->isAbstract()) + Ty->removeAbstractTypeUser(this); } StructLayout *&operator[](const StructType *STy) { @@ -392,7 +381,7 @@ virtual void dump() const {} }; -} // end namespace llvm +} // end anonymous namespace TargetData::~TargetData() { delete static_cast(LayoutMap); @@ -430,17 +419,9 @@ /// avoid a dangling pointer in this cache. void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { if (!LayoutMap) return; // No cache. - - StructLayoutMap *STM = static_cast(LayoutMap); - LayoutInfoTy::iterator I = STM->find(Ty); - if (I == STM->end()) return; - - I->second->~StructLayout(); - free(I->second); - STM->erase(I); - if (Ty->isAbstract()) - Ty->removeAbstractTypeUser(STM); + StructLayoutMap *STM = static_cast(LayoutMap); + STM->InvalidateEntry(Ty); } std::string TargetData::getStringRepresentation() const { From isanbard at gmail.com Wed Dec 2 19:18:05 2009 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 2 Dec 2009 17:18:05 -0800 Subject: [llvm-commits] [llvm] r89176 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp In-Reply-To: <35C85951-2433-45E6-B0A0-43F0C04BA008@apple.com> References: <200911180103.nAI13usJ018941@zion.cs.uiuc.edu> <1A1AE227-CA98-41BB-864B-003A9B9EA0CD@apple.com> <392E62EA-54C9-4B80-91C3-85A67CBA3A68@gmail.com> <35C85951-2433-45E6-B0A0-43F0C04BA008@apple.com> Message-ID: <8840333C-F0DF-4A28-B038-8EAD6D351534@gmail.com> On Dec 2, 2009, at 4:32 PM, Chris Lattner wrote: > On Dec 2, 2009, at 4:14 PM, Bill Wendling wrote: >>>> + insert(STy); >>>> + return LayoutInfo[STy]; >>> >>> Don't do a redundant map lookup after 'insert'. >>> >> I reworked a lot of this so that it's arguably more correct now...I >> hope at least. > > Thanks Bill, definite improvement. Next round: > Don?d! -bw From dpatel at apple.com Wed Dec 2 19:25:38 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Dec 2009 01:25:38 -0000 Subject: [llvm-commits] [llvm] r90375 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <200912030125.nB31Pcx1008180@zion.cs.uiuc.edu> Author: dpatel Date: Wed Dec 2 19:25:38 2009 New Revision: 90375 URL: http://llvm.org/viewvc/llvm-project?rev=90375&view=rev Log: Emit method definition DIE at module level (even for methods with inlined functino body at soure level) so that the debugger can invoke it. This fixes many test failures in gdb test suite. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=90375&r1=90374&r2=90375&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Dec 2 19:25:38 2009 @@ -891,8 +891,8 @@ continue; DIE *ElemDie = NULL; if (Element.getTag() == dwarf::DW_TAG_subprogram) - ElemDie = createSubprogramDIE(DW_Unit, - DISubprogram(Element.getNode())); + ElemDie = createMemberSubprogramDIE(DW_Unit, + DISubprogram(Element.getNode())); else ElemDie = createMemberDIE(DW_Unit, DIDerivedType(Element.getNode())); @@ -1082,16 +1082,12 @@ return MemberDie; } -/// createSubprogramDIE - Create new DIE using SP. -DIE *DwarfDebug::createSubprogramDIE(CompileUnit *DW_Unit, - const DISubprogram &SP, - bool IsConstructor, - bool IsInlined) { - DIE *SPDie = ModuleCU->getDIE(SP.getNode()); - if (SPDie) - return SPDie; - - SPDie = new DIE(dwarf::DW_TAG_subprogram); +/// createRawSubprogramDIE - Create new partially incomplete DIE. This is +/// a helper routine used by createMemberSubprogramDIE and +/// createSubprogramDIE. +DIE *DwarfDebug::createRawSubprogramDIE(CompileUnit *DW_Unit, + const DISubprogram &SP) { + DIE *SPDie = new DIE(dwarf::DW_TAG_subprogram); addString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, SP.getName()); StringRef LinkageName = SP.getLinkageName(); @@ -1107,9 +1103,6 @@ } addSourceLine(SPDie, &SP); - DICompositeType SPTy = SP.getType(); - DIArray Args = SPTy.getTypeArray(); - // Add prototyped tag, if C or ObjC. unsigned Lang = SP.getCompileUnit().getLanguage(); if (Lang == dwarf::DW_LANG_C99 || Lang == dwarf::DW_LANG_C89 || @@ -1117,19 +1110,70 @@ addUInt(SPDie, dwarf::DW_AT_prototyped, dwarf::DW_FORM_flag, 1); // Add Return Type. + DICompositeType SPTy = SP.getType(); + DIArray Args = SPTy.getTypeArray(); unsigned SPTag = SPTy.getTag(); - if (!IsConstructor) { - if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type) - addType(DW_Unit, SPDie, SPTy); - else - addType(DW_Unit, SPDie, DIType(Args.getElement(0).getNode())); - } + if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type) + addType(DW_Unit, SPDie, SPTy); + else + addType(DW_Unit, SPDie, DIType(Args.getElement(0).getNode())); + + return SPDie; +} + +/// createMemberSubprogramDIE - Create new member DIE using SP. This routine +/// always returns a die with DW_AT_declaration attribute. +DIE *DwarfDebug::createMemberSubprogramDIE(CompileUnit *DW_Unit, + const DISubprogram &SP) { + DIE *SPDie = ModuleCU->getDIE(SP.getNode()); + if (!SPDie) + SPDie = createSubprogramDIE(DW_Unit, SP); + + // If SPDie has DW_AT_declaration then reuse it. + if (!SP.isDefinition()) + return SPDie; + + // Otherwise create new DIE for the declaration. First push definition + // DIE at the top level. + if (TopLevelDIEs.insert(SPDie)) + TopLevelDIEsVector.push_back(SPDie); + + SPDie = createRawSubprogramDIE(DW_Unit, SP); + + // Add arguments. + DICompositeType SPTy = SP.getType(); + DIArray Args = SPTy.getTypeArray(); + unsigned SPTag = SPTy.getTag(); + if (SPTag == dwarf::DW_TAG_subroutine_type) + for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { + DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter); + addType(DW_Unit, Arg, DIType(Args.getElement(i).getNode())); + addUInt(Arg, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); // ?? + SPDie->addChild(Arg); + } + + addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + return SPDie; +} + +/// createSubprogramDIE - Create new DIE using SP. +DIE *DwarfDebug::createSubprogramDIE(CompileUnit *DW_Unit, + const DISubprogram &SP) { + DIE *SPDie = ModuleCU->getDIE(SP.getNode()); + if (SPDie) + return SPDie; + + SPDie = createRawSubprogramDIE(DW_Unit, SP); if (!SP.isDefinition()) { addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); // Add arguments. Do not add arguments for subprogram definition. They will - // be handled through RecordVariable. + // be handled while processing variables. + DICompositeType SPTy = SP.getType(); + DIArray Args = SPTy.getTypeArray(); + unsigned SPTag = SPTy.getTag(); + if (SPTag == dwarf::DW_TAG_subroutine_type) for (unsigned i = 1, N = Args.getNumElements(); i < N; ++i) { DIE *Arg = new DIE(dwarf::DW_TAG_formal_parameter); @@ -1641,7 +1685,8 @@ ModuleCU->insertDIE(N, VariableDie); // Add to context owner. - ModuleCU->getCUDie()->addChild(VariableDie); + if (TopLevelDIEs.insert(VariableDie)) + TopLevelDIEsVector.push_back(VariableDie); // Expose as global. FIXME - need to check external flag. ModuleCU->addGlobal(DI_GV.getName(), VariableDie); @@ -1674,7 +1719,8 @@ // Add to context owner. if (SP.getContext().getNode() == SP.getCompileUnit().getNode()) - ModuleCU->getCUDie()->addChild(SubprogramDie); + if (TopLevelDIEs.insert(SubprogramDie)) + TopLevelDIEsVector.push_back(SubprogramDie); // Expose as global. ModuleCU->addGlobal(SP.getName(), SubprogramDie); @@ -1775,6 +1821,11 @@ addUInt(ISP, dwarf::DW_AT_inline, 0, dwarf::DW_INL_inlined); } + // Insert top level DIEs. + for (SmallVector::iterator TI = TopLevelDIEsVector.begin(), + TE = TopLevelDIEsVector.end(); TI != TE; ++TI) + ModuleCU->getCUDie()->addChild(*TI); + // Standard sections final addresses. Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getTextSection()); EmitLabel("text_end", 0); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=90375&r1=90374&r2=90375&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Dec 2 19:25:38 2009 @@ -157,6 +157,10 @@ /// AbstractSubprogramDIEs - Collection of abstruct subprogram DIEs. SmallPtrSet AbstractSubprogramDIEs; + /// TopLevelDIEs - Collection of top level DIEs. + SmallPtrSet TopLevelDIEs; + SmallVector TopLevelDIEsVector; + /// ScopedGVs - Tracks global variables that are not at file scope. /// For example void f() { static int b = 42; } SmallVector ScopedGVs; @@ -342,10 +346,17 @@ DIE *createMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT); /// createSubprogramDIE - Create new DIE using SP. - DIE *createSubprogramDIE(CompileUnit *DW_Unit, - const DISubprogram &SP, - bool IsConstructor = false, - bool IsInlined = false); + DIE *createSubprogramDIE(CompileUnit *DW_Unit, const DISubprogram &SP); + + /// createMemberSubprogramDIE - Create new member DIE using SP. This + /// routine always returns a die with DW_AT_declaration attribute. + + DIE *createMemberSubprogramDIE(CompileUnit *DW_Unit, const DISubprogram &SP); + + /// createRawSubprogramDIE - Create new partially incomplete DIE. This is + /// a helper routine used by createMemberSubprogramDIE and + /// createSubprogramDIE. + DIE *createRawSubprogramDIE(CompileUnit *DW_Unit, const DISubprogram &SP); /// findCompileUnit - Get the compile unit for the given descriptor. /// From sabre at nondot.org Wed Dec 2 19:46:18 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 01:46:18 -0000 Subject: [llvm-commits] [llvm] r90380 - /llvm/trunk/test/Transforms/GVN/crash-2.ll Message-ID: <200912030146.nB31kIx5008916@zion.cs.uiuc.edu> Author: lattner Date: Wed Dec 2 19:46:18 2009 New Revision: 90380 URL: http://llvm.org/viewvc/llvm-project?rev=90380&view=rev Log: add a failing testcase. Added: llvm/trunk/test/Transforms/GVN/crash-2.ll Added: llvm/trunk/test/Transforms/GVN/crash-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/crash-2.ll?rev=90380&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/crash-2.ll (added) +++ llvm/trunk/test/Transforms/GVN/crash-2.ll Wed Dec 2 19:46:18 2009 @@ -0,0 +1,44 @@ +; RUN: opt -gvn -S %s +; XFAIL: * +; rdar://7438974 + +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-darwin9.0" + + at g = external global i64, align 8 + +define i32* @foo() { +do.end17.i: + %tmp18.i = load i7** undef + %tmp1 = bitcast i7* %tmp18.i to i8* + br i1 undef, label %do.body36.i, label %if.then21.i + +if.then21.i: + %tmp2 = bitcast i7* %tmp18.i to i8* + ret i32* undef + +do.body36.i: + %ivar38.i = load i64* @g + %tmp3 = bitcast i7* %tmp18.i to i8* + %add.ptr39.sum.i = add i64 %ivar38.i, 8 + %tmp40.i = getelementptr inbounds i8* %tmp3, i64 %add.ptr39.sum.i + %tmp4 = bitcast i8* %tmp40.i to i64* + %tmp41.i = load i64* %tmp4 + br i1 undef, label %if.then48.i, label %do.body57.i + +if.then48.i: + %call54.i = call i32 @foo2() + br label %do.body57.i + +do.body57.i: + %tmp58.i = load i7** undef + %ivar59.i = load i64* @g + %tmp5 = bitcast i7* %tmp58.i to i8* + %add.ptr65.sum.i = add i64 %ivar59.i, 8 + %tmp66.i = getelementptr inbounds i8* %tmp5, i64 %add.ptr65.sum.i + %tmp6 = bitcast i8* %tmp66.i to i64* + %tmp67.i = load i64* %tmp6 + ret i32* undef +} + +declare i32 @foo2() From stoklund at 2pi.dk Wed Dec 2 19:49:56 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Dec 2009 01:49:56 -0000 Subject: [llvm-commits] [llvm] r90381 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Message-ID: <200912030149.nB31nuZP009015@zion.cs.uiuc.edu> Author: stoklund Date: Wed Dec 2 19:49:56 2009 New Revision: 90381 URL: http://llvm.org/viewvc/llvm-project?rev=90381&view=rev Log: Don't hang on to pointers or references after vector::push_back. The MO reference to a MachineOperand can be invalidated by MachineInstr::addOperand. Don't even use it for debugging. Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Modified: llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp?rev=90381&r1=90380&r2=90381&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Wed Dec 2 19:49:56 2009 @@ -510,12 +510,9 @@ } if (MO.isKill() != kill) { - bool removed = ToggleKillFlag(MI, MO); - if (removed) { - DEBUG(errs() << "Fixed in "); - } else { - DEBUG(errs() << "Fixed " << MO << " in "); - } + DEBUG(errs() << "Fixing " << MO << " in "); + // Warning: ToggleKillFlag may invalidate MO. + ToggleKillFlag(MI, MO); DEBUG(MI->dump()); } From isanbard at gmail.com Wed Dec 2 19:54:07 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Dec 2009 01:54:07 -0000 Subject: [llvm-commits] [llvm] r90383 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912030154.nB31s7KU009188@zion.cs.uiuc.edu> Author: void Date: Wed Dec 2 19:54:07 2009 New Revision: 90383 URL: http://llvm.org/viewvc/llvm-project?rev=90383&view=rev Log: Revert r90371. It was causing build failures. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90383&r1=90382&r2=90383&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Dec 2 19:54:07 2009 @@ -315,12 +315,11 @@ : Alignments[BestMatchIdx].PrefAlign; } +typedef DenseMap LayoutInfoTy; + namespace { class StructLayoutMap : public AbstractTypeUser { -public: - typedef DenseMap LayoutInfoTy; -private: LayoutInfoTy LayoutInfo; /// refineAbstractType - The callback method invoked when an abstract type is @@ -329,9 +328,14 @@ /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { - assert(LayoutInfo.find(cast(OldTy)) != LayoutInfo.end() && - "Abstract value not in local map!"); - InvalidateEntry(cast(OldTy)); + const StructType *STy = dyn_cast(OldTy); + assert(STy && "This can only track struct types."); + + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); + OldTy->removeAbstractTypeUser(this); } /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware @@ -340,9 +344,14 @@ /// This method notifies ATU's when this occurs for a type. /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { - assert(LayoutInfo.find(cast(AbsTy)) != LayoutInfo.end() && - "Abstract value not in local map!"); - InvalidateEntry(cast(AbsTy)); + const StructType *STy = dyn_cast(AbsTy); + assert(STy && "This can only track struct types."); + + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); + AbsTy->removeAbstractTypeUser(this); } public: @@ -356,21 +365,23 @@ if (Key && Key->isAbstract()) Key->removeAbstractTypeUser(this); - Value->~StructLayout(); - free(Value); + if (Value) { + Value->~StructLayout(); + free(Value); + } } } - void InvalidateEntry(const StructType *Ty) { - LayoutInfoTy::iterator I = LayoutInfo.find(Ty); - if (I == LayoutInfo.end()) return; - - I->second->~StructLayout(); - free(I->second); - LayoutInfo.erase(I); + LayoutInfoTy::iterator end() { + return LayoutInfo.end(); + } - if (Ty->isAbstract()) - Ty->removeAbstractTypeUser(this); + LayoutInfoTy::iterator find(const StructType *&Val) { + return LayoutInfo.find(Val); + } + + bool erase(LayoutInfoTy::iterator I) { + return LayoutInfo.erase(I); } StructLayout *&operator[](const StructType *STy) { @@ -381,7 +392,7 @@ virtual void dump() const {} }; -} // end anonymous namespace +} // end namespace llvm TargetData::~TargetData() { delete static_cast(LayoutMap); @@ -419,9 +430,17 @@ /// avoid a dangling pointer in this cache. void TargetData::InvalidateStructLayoutInfo(const StructType *Ty) const { if (!LayoutMap) return; // No cache. - + StructLayoutMap *STM = static_cast(LayoutMap); - STM->InvalidateEntry(Ty); + LayoutInfoTy::iterator I = STM->find(Ty); + if (I == STM->end()) return; + + I->second->~StructLayout(); + free(I->second); + STM->erase(I); + + if (Ty->isAbstract()) + Ty->removeAbstractTypeUser(STM); } std::string TargetData::getStringRepresentation() const { From evan.cheng at apple.com Wed Dec 2 20:31:43 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 03 Dec 2009 02:31:43 -0000 Subject: [llvm-commits] [llvm] r90395 - in /llvm/trunk: include/llvm/CodeGen/MachineInstr.h include/llvm/CodeGen/MachineSSAUpdater.h lib/CodeGen/MachineInstr.cpp lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912030231.nB32VhuU010496@zion.cs.uiuc.edu> Author: evancheng Date: Wed Dec 2 20:31:43 2009 New Revision: 90395 URL: http://llvm.org/viewvc/llvm-project?rev=90395&view=rev Log: Fill out codegen SSA updater. It's not yet tested. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstr.h?rev=90395&r1=90394&r2=90395&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstr.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstr.h Wed Dec 2 20:31:43 2009 @@ -320,6 +320,11 @@ /// loads the instruction does are invariant (if it does multiple loads). bool isInvariantLoad(AliasAnalysis *AA) const; + /// isConstantValuePHI - If the specified instruction is a PHI that always + /// merges together the same virtual register, return the register, otherwise + /// return 0. + unsigned isConstantValuePHI() const; + // // Debugging support // Modified: llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h?rev=90395&r1=90394&r2=90395&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineSSAUpdater.h Wed Dec 2 20:31:43 2009 @@ -16,13 +16,18 @@ namespace llvm { class MachineBasicBlock; + class MachineFunction; class MachineInstr; + class MachineOperand; + class MachineRegisterInfo; + class TargetInstrInfo; + class TargetRegisterClass; template class SmallVectorImpl; -/// SSAUpdater - This class updates SSA form for a set of values defined in -/// multiple blocks. This is used when code duplication or another unstructured -/// transformation wants to rewrite a set of uses of one value with uses of a -/// set of values. +/// MachineSSAUpdater - This class updates SSA form for a set of virtual +/// registers defined in multiple blocks. This is used when code duplication +/// or another unstructured transformation wants to rewrite a set of uses of one +/// vreg with uses of a set of vregs. class MachineSSAUpdater { /// AvailableVals - This keeps track of which value to use on a per-block /// basis. When we insert PHI nodes, we keep track of them here. @@ -35,18 +40,28 @@ //std::vector > IncomingPredInfo; void *IPI; + /// VR - Current virtual register whose uses are being updated. + unsigned VR; + + /// VRC - Register class of the current virtual register. + const TargetRegisterClass *VRC; + /// InsertedPHIs - If this is non-null, the MachineSSAUpdater adds all PHI /// nodes that it creates to the vector. SmallVectorImpl *InsertedPHIs; + + const TargetInstrInfo *TII; + MachineRegisterInfo *MRI; public: /// MachineSSAUpdater constructor. If InsertedPHIs is specified, it will be /// filled in with all PHI Nodes created by rewriting. - explicit MachineSSAUpdater(SmallVectorImpl *InsertedPHIs = 0); + explicit MachineSSAUpdater(MachineFunction &MF, + SmallVectorImpl *InsertedPHIs = 0); ~MachineSSAUpdater(); /// Initialize - Reset this object to get ready for a new set of SSA /// updates. - void Initialize(); + void Initialize(unsigned V); /// AddAvailableValue - Indicate that a rewritten value is available at the /// end of the specified block with the specified value. @@ -86,7 +101,7 @@ /// will not work if the use is supposed to be rewritten to a value defined in /// the same block as the use, but above it. Any 'AddAvailableValue's added /// for the use's block will be considered to be below it. - void RewriteUse(unsigned &U); + void RewriteUse(MachineOperand &U); private: unsigned GetValueAtEndOfBlockInternal(MachineBasicBlock *BB); Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90395&r1=90394&r2=90395&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Wed Dec 2 20:31:43 2009 @@ -1058,6 +1058,20 @@ return true; } +/// isConstantValuePHI - If the specified instruction is a PHI that always +/// merges together the same virtual register, return the register, otherwise +/// return 0. +unsigned MachineInstr::isConstantValuePHI() const { + if (getOpcode() != TargetInstrInfo::PHI) + return 0; + + unsigned Reg = getOperand(1).getReg(); + for (unsigned i = 3, e = getNumOperands(); i < e; i += 2) + if (getOperand(i).getReg() != Reg) + return 0; + return Reg; +} + void MachineInstr::dump() const { errs() << " " << *this; } Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90395&r1=90394&r2=90395&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Wed Dec 2 20:31:43 2009 @@ -7,16 +7,25 @@ // //===----------------------------------------------------------------------===// // -// This file implements the MachineSSAUpdater class. +// This file implements the MachineSSAUpdater class. It's based on SSAUpdater +// class in lib/Transforms/Utils. // //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineSSAUpdater.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetRegisterInfo.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; -typedef DenseMap AvailableValsTy; +typedef DenseMap AvailableValsTy; typedef std::vector > IncomingPredInfoTy; @@ -29,8 +38,12 @@ } -MachineSSAUpdater::MachineSSAUpdater(SmallVectorImpl *NewPHI) - : AV(0), IPI(0), InsertedPHIs(NewPHI) {} +MachineSSAUpdater::MachineSSAUpdater(MachineFunction &MF, + SmallVectorImpl *NewPHI) + : AV(0), IPI(0), InsertedPHIs(NewPHI) { + TII = MF.getTarget().getInstrInfo(); + MRI = &MF.getRegInfo(); +} MachineSSAUpdater::~MachineSSAUpdater() { delete &getAvailableVals(AV); @@ -39,7 +52,7 @@ /// Initialize - Reset this object to get ready for a new set of SSA /// updates. ProtoValue is the value used to name PHI nodes. -void MachineSSAUpdater::Initialize() { +void MachineSSAUpdater::Initialize(unsigned V) { if (AV == 0) AV = new AvailableValsTy(); else @@ -49,6 +62,9 @@ IPI = new IncomingPredInfoTy(); else getIncomingPredInfo(IPI).clear(); + + VR = V; + VRC = MRI->getRegClass(VR); } /// HasValueForBlock - Return true if the MachineSSAUpdater already has a value for @@ -69,6 +85,18 @@ return GetValueAtEndOfBlockInternal(BB); } +/// InsertNewPHI - Insert an empty PHI instruction which define a value of the +/// given register class at the start of the specified basic block. It returns +/// the virtual register defined by the PHI instruction. +static +MachineInstr *InsertNewPHI(MachineBasicBlock *BB, const TargetRegisterClass *RC, + MachineRegisterInfo *MRI, const TargetInstrInfo *TII) { + unsigned NewVR = MRI->createVirtualRegister(RC); + return BuildMI(*BB, BB->front(), BB->front().getDebugLoc(), + TII->get(TargetInstrInfo::PHI), NewVR); +} + + /// GetValueInMiddleOfBlock - Construct SSA form, materializing a value that /// is live in the middle of the specified block. /// @@ -89,14 +117,86 @@ /// merge the appropriate values, and this value isn't live out of the block. /// unsigned MachineSSAUpdater::GetValueInMiddleOfBlock(MachineBasicBlock *BB) { + // If there is no definition of the renamed variable in this block, just use + // GetValueAtEndOfBlock to do our work. + if (!getAvailableVals(AV).count(BB)) + return GetValueAtEndOfBlock(BB); + + if (BB->pred_empty()) + llvm_unreachable("Unreachable block!"); + + // Otherwise, we have the hard case. Get the live-in values for each + // predecessor. + SmallVector, 8> PredValues; + unsigned SingularValue = 0; + + bool isFirstPred = true; + for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(), + E = BB->pred_end(); PI != E; ++PI) { + MachineBasicBlock *PredBB = *PI; + unsigned PredVal = GetValueAtEndOfBlockInternal(PredBB); + PredValues.push_back(std::make_pair(PredBB, PredVal)); + + // Compute SingularValue. + if (isFirstPred) { + SingularValue = PredVal; + isFirstPred = false; + } else if (PredVal != SingularValue) + SingularValue = 0; + } + + // Otherwise, if all the merged values are the same, just use it. + if (SingularValue != 0) + return SingularValue; + + // Otherwise, we do need a PHI: insert one now. + MachineInstr *InsertedPHI = InsertNewPHI(BB, VRC, MRI, TII); + + // Fill in all the predecessors of the PHI. + MachineInstrBuilder MIB(InsertedPHI); + for (unsigned i = 0, e = PredValues.size(); i != e; ++i) + MIB.addReg(PredValues[i].second).addMBB(PredValues[i].first); + + // See if the PHI node can be merged to a single value. This can happen in + // loop cases when we get a PHI of itself and one other value. + if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { + InsertedPHI->eraseFromParent(); + return ConstVal; + } + + // If the client wants to know about all new instructions, tell it. + if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); + + DEBUG(errs() << " Inserted PHI: " << *InsertedPHI << "\n"); + return InsertedPHI->getOperand(0).getReg(); +} + +static +MachineBasicBlock *findCorrespondingPred(const MachineInstr *MI, + MachineOperand *U) { + for (unsigned i = 1, e = MI->getNumOperands(); i != e; i += 2) { + if (&MI->getOperand(i) == U) + return MI->getOperand(i+1).getMBB(); + } + + llvm_unreachable("MachineOperand::getParent() failure?"); return 0; } /// RewriteUse - Rewrite a use of the symbolic value. This handles PHI nodes, /// which use their value in the corresponding predecessor. -void MachineSSAUpdater::RewriteUse(unsigned &U) { -} +void MachineSSAUpdater::RewriteUse(MachineOperand &U) { + MachineInstr *UseMI = U.getParent(); + unsigned NewVR = 0; + if (UseMI->getOpcode() == TargetInstrInfo::PHI) { + MachineBasicBlock *SourceBB = findCorrespondingPred(UseMI, &U); + NewVR = GetValueAtEndOfBlock(SourceBB); + } else { + NewVR = GetValueInMiddleOfBlock(UseMI->getParent()); + } + U.setReg(NewVR); +} /// GetValueAtEndOfBlockInternal - Check to see if AvailableVals has an entry /// for the specified BB and if so, return it. If not, construct SSA form by @@ -104,5 +204,126 @@ /// where the value is available. /// unsigned MachineSSAUpdater::GetValueAtEndOfBlockInternal(MachineBasicBlock *BB){ - return 0; + AvailableValsTy &AvailableVals = getAvailableVals(AV); + + // Query AvailableVals by doing an insertion of null. + std::pair InsertRes = + AvailableVals.insert(std::make_pair(BB, 0)); + + // Handle the case when the insertion fails because we have already seen BB. + if (!InsertRes.second) { + // If the insertion failed, there are two cases. The first case is that the + // value is already available for the specified block. If we get this, just + // return the value. + if (InsertRes.first->second != 0) + return InsertRes.first->second; + + // Otherwise, if the value we find is null, then this is the value is not + // known but it is being computed elsewhere in our recursion. This means + // that we have a cycle. Handle this by inserting a PHI node and returning + // it. When we get back to the first instance of the recursion we will fill + // in the PHI node. + MachineInstr *NewPHI = InsertNewPHI(BB, VRC, MRI, TII); + unsigned NewVR = NewPHI->getOperand(0).getReg(); + InsertRes.first->second = NewVR; + return NewVR; + } + + if (BB->pred_empty()) + llvm_unreachable("Unreachable block!"); + + // Okay, the value isn't in the map and we just inserted a null in the entry + // to indicate that we're processing the block. Since we have no idea what + // value is in this block, we have to recurse through our predecessors. + // + // While we're walking our predecessors, we keep track of them in a vector, + // then insert a PHI node in the end if we actually need one. We could use a + // smallvector here, but that would take a lot of stack space for every level + // of the recursion, just use IncomingPredInfo as an explicit stack. + IncomingPredInfoTy &IncomingPredInfo = getIncomingPredInfo(IPI); + unsigned FirstPredInfoEntry = IncomingPredInfo.size(); + + // As we're walking the predecessors, keep track of whether they are all + // producing the same value. If so, this value will capture it, if not, it + // will get reset to null. We distinguish the no-predecessor case explicitly + // below. + unsigned SingularValue = 0; + bool isFirstPred = true; + for (MachineBasicBlock::pred_iterator PI = BB->pred_begin(), + E = BB->pred_end(); PI != E; ++PI) { + MachineBasicBlock *PredBB = *PI; + unsigned PredVal = GetValueAtEndOfBlockInternal(PredBB); + IncomingPredInfo.push_back(std::make_pair(PredBB, PredVal)); + + // Compute SingularValue. + if (isFirstPred) { + SingularValue = PredVal; + isFirstPred = false; + } else if (PredVal != SingularValue) + SingularValue = 0; + } + + /// Look up BB's entry in AvailableVals. 'InsertRes' may be invalidated. If + /// this block is involved in a loop, a no-entry PHI node will have been + /// inserted as InsertedVal. Otherwise, we'll still have the null we inserted + /// above. + unsigned InsertedVal = AvailableVals[BB]; + + // If all the predecessor values are the same then we don't need to insert a + // PHI. This is the simple and common case. + if (SingularValue) { + // If a PHI node got inserted, replace it with the singlar value and delete + // it. + if (InsertedVal) { + MachineInstr *OldVal = MRI->getVRegDef(InsertedVal); + // Be careful about dead loops. These RAUW's also update InsertedVal. + assert(InsertedVal != SingularValue && "Dead loop?"); + MRI->replaceRegWith(InsertedVal, SingularValue); + OldVal->eraseFromParent(); + } else { + InsertedVal = SingularValue; + } + + // Drop the entries we added in IncomingPredInfo to restore the stack. + IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, + IncomingPredInfo.end()); + return InsertedVal; + } + + + // Otherwise, we do need a PHI: insert one now if we don't already have one. + MachineInstr *InsertedPHI; + if (InsertedVal == 0) { + InsertedPHI = InsertNewPHI(BB, VRC, MRI, TII); + InsertedVal = InsertedPHI->getOperand(0).getReg(); + } else { + InsertedPHI = MRI->getVRegDef(InsertedVal); + } + + // Fill in all the predecessors of the PHI. + MachineInstrBuilder MIB(InsertedPHI); + for (IncomingPredInfoTy::iterator I = + IncomingPredInfo.begin()+FirstPredInfoEntry, + E = IncomingPredInfo.end(); I != E; ++I) + MIB.addReg(I->second).addMBB(I->first); + + // Drop the entries we added in IncomingPredInfo to restore the stack. + IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, + IncomingPredInfo.end()); + + // See if the PHI node can be merged to a single value. This can happen in + // loop cases when we get a PHI of itself and one other value. + if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { + MRI->replaceRegWith(InsertedVal, ConstVal); + InsertedPHI->eraseFromParent(); + InsertedVal = ConstVal; + } else { + DEBUG(errs() << " Inserted PHI: " << *InsertedPHI << "\n"); + + // If the client wants to know about all new instructions, tell it. + if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); + } + + return InsertedVal; + } From resistor at mac.com Wed Dec 2 21:43:30 2009 From: resistor at mac.com (Owen Anderson) Date: Thu, 03 Dec 2009 03:43:30 -0000 Subject: [llvm-commits] [llvm] r90408 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/crash-2.ll Message-ID: <200912030343.nB33hUco012896@zion.cs.uiuc.edu> Author: resistor Date: Wed Dec 2 21:43:29 2009 New Revision: 90408 URL: http://llvm.org/viewvc/llvm-project?rev=90408&view=rev Log: Fix this crasher, and add a FIXME for a missed optimization. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/crash-2.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90408&r1=90407&r2=90408&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Dec 2 21:43:29 2009 @@ -1449,6 +1449,16 @@ LoadPtr = MD->GetAvailablePHITranslatedValue(LI->getOperand(0), LoadBB, UnavailablePred, TD, *DT); } + + // Assign value numbers to these new instructions. + for (SmallVector::iterator NI = NewInsts.begin(), + NE = NewInsts.end(); NI != NE; ++NI) { + // FIXME: We really _ought_ to insert these value numbers into their + // parent's availability map. However, in doing so, we risk getting into + // ordering issues. If a block hasn't been processed yet, we would be + // marking a value as AVAIL-IN, which isn't what we intend. + VN.lookup_or_add(*NI); + } // If we couldn't find or insert a computation of this phi translated value, // we fail PRE. Modified: llvm/trunk/test/Transforms/GVN/crash-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/crash-2.ll?rev=90408&r1=90407&r2=90408&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/crash-2.ll (original) +++ llvm/trunk/test/Transforms/GVN/crash-2.ll Wed Dec 2 21:43:29 2009 @@ -1,5 +1,4 @@ ; RUN: opt -gvn -S %s -; XFAIL: * ; rdar://7438974 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" From stoklund at 2pi.dk Wed Dec 2 23:15:35 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Dec 2009 05:15:35 -0000 Subject: [llvm-commits] [llvm] r90415 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Message-ID: <200912030515.nB35FZmd015646@zion.cs.uiuc.edu> Author: stoklund Date: Wed Dec 2 23:15:35 2009 New Revision: 90415 URL: http://llvm.org/viewvc/llvm-project?rev=90415&view=rev Log: Don't call getValueType() on a null SDValue Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=90415&r1=90414&r2=90415&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Wed Dec 2 23:15:35 2009 @@ -546,7 +546,8 @@ To[0].getNode()->dump(&DAG); errs() << " and " << NumTo-1 << " other values\n"; for (unsigned i = 0, e = NumTo; i != e; ++i) - assert(N->getValueType(i) == To[i].getValueType() && + assert((!To[i].getNode() || + N->getValueType(i) == To[i].getValueType()) && "Cannot combine value to value of different type!")); WorkListRemover DeadNodes(*this); DAG.ReplaceAllUsesWith(N, To, &DeadNodes); From bob.wilson at apple.com Thu Dec 3 00:40:55 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 03 Dec 2009 06:40:55 -0000 Subject: [llvm-commits] [llvm] r90417 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2009-12-02-vtrn-undef.ll Message-ID: <200912030640.nB36etKX018295@zion.cs.uiuc.edu> Author: bwilson Date: Thu Dec 3 00:40:55 2009 New Revision: 90417 URL: http://llvm.org/viewvc/llvm-project?rev=90417&view=rev Log: Recognize canonical forms of vector shuffles where the same vector is used for both source operands. In the canonical form, the 2nd operand is changed to an undef and the shuffle mask is adjusted to only reference elements from the 1st operand. Radar 7434842. Added: llvm/trunk/test/CodeGen/ARM/2009-12-02-vtrn-undef.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=90417&r1=90416&r2=90417&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Thu Dec 3 00:40:55 2009 @@ -2528,6 +2528,25 @@ return true; } +/// isVTRN_v_undef_Mask - Special case of isVTRNMask for canonical form of +/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef". +/// Mask is e.g., <0, 0, 2, 2> instead of <0, 4, 2, 6>. +static bool isVTRN_v_undef_Mask(const SmallVectorImpl &M, EVT VT, + unsigned &WhichResult) { + unsigned EltSz = VT.getVectorElementType().getSizeInBits(); + if (EltSz == 64) + return false; + + unsigned NumElts = VT.getVectorNumElements(); + WhichResult = (M[0] == 0 ? 0 : 1); + for (unsigned i = 0; i < NumElts; i += 2) { + if ((unsigned) M[i] != i + WhichResult || + (unsigned) M[i+1] != i + WhichResult) + return false; + } + return true; +} + static bool isVUZPMask(const SmallVectorImpl &M, EVT VT, unsigned &WhichResult) { unsigned EltSz = VT.getVectorElementType().getSizeInBits(); @@ -2548,6 +2567,33 @@ return true; } +/// isVUZP_v_undef_Mask - Special case of isVUZPMask for canonical form of +/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef". +/// Mask is e.g., <0, 2, 0, 2> instead of <0, 2, 4, 6>, +static bool isVUZP_v_undef_Mask(const SmallVectorImpl &M, EVT VT, + unsigned &WhichResult) { + unsigned EltSz = VT.getVectorElementType().getSizeInBits(); + if (EltSz == 64) + return false; + + unsigned Half = VT.getVectorNumElements() / 2; + WhichResult = (M[0] == 0 ? 0 : 1); + for (unsigned j = 0; j != 2; ++j) { + unsigned Idx = WhichResult; + for (unsigned i = 0; i != Half; ++i) { + if ((unsigned) M[i + j * Half] != Idx) + return false; + Idx += 2; + } + } + + // VUZP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32. + if (VT.is64BitVector() && EltSz == 32) + return false; + + return true; +} + static bool isVZIPMask(const SmallVectorImpl &M, EVT VT, unsigned &WhichResult) { unsigned EltSz = VT.getVectorElementType().getSizeInBits(); @@ -2571,6 +2617,33 @@ return true; } +/// isVZIP_v_undef_Mask - Special case of isVZIPMask for canonical form of +/// "vector_shuffle v, v", i.e., "vector_shuffle v, undef". +/// Mask is e.g., <0, 0, 1, 1> instead of <0, 4, 1, 5>. +static bool isVZIP_v_undef_Mask(const SmallVectorImpl &M, EVT VT, + unsigned &WhichResult) { + unsigned EltSz = VT.getVectorElementType().getSizeInBits(); + if (EltSz == 64) + return false; + + unsigned NumElts = VT.getVectorNumElements(); + WhichResult = (M[0] == 0 ? 0 : 1); + unsigned Idx = WhichResult * NumElts / 2; + for (unsigned i = 0; i != NumElts; i += 2) { + if ((unsigned) M[i] != Idx || + (unsigned) M[i+1] != Idx) + return false; + Idx += 1; + } + + // VZIP.32 for 64-bit vectors is a pseudo-instruction alias for VTRN.32. + if (VT.is64BitVector() && EltSz == 32) + return false; + + return true; +} + + static SDValue BuildSplat(SDValue Val, EVT VT, SelectionDAG &DAG, DebugLoc dl) { // Canonicalize all-zeros and all-ones vectors. ConstantSDNode *ConstVal = cast(Val.getNode()); @@ -2683,7 +2756,10 @@ isVEXTMask(M, VT, ReverseVEXT, Imm) || isVTRNMask(M, VT, WhichResult) || isVUZPMask(M, VT, WhichResult) || - isVZIPMask(M, VT, WhichResult)); + isVZIPMask(M, VT, WhichResult) || + isVTRN_v_undef_Mask(M, VT, WhichResult) || + isVUZP_v_undef_Mask(M, VT, WhichResult) || + isVZIP_v_undef_Mask(M, VT, WhichResult)); } /// GeneratePerfectShuffle - Given an entry in the perfect-shuffle table, emit @@ -2815,6 +2891,16 @@ return DAG.getNode(ARMISD::VZIP, dl, DAG.getVTList(VT, VT), V1, V2).getValue(WhichResult); + if (isVTRN_v_undef_Mask(ShuffleMask, VT, WhichResult)) + return DAG.getNode(ARMISD::VTRN, dl, DAG.getVTList(VT, VT), + V1, V1).getValue(WhichResult); + if (isVUZP_v_undef_Mask(ShuffleMask, VT, WhichResult)) + return DAG.getNode(ARMISD::VUZP, dl, DAG.getVTList(VT, VT), + V1, V1).getValue(WhichResult); + if (isVZIP_v_undef_Mask(ShuffleMask, VT, WhichResult)) + return DAG.getNode(ARMISD::VZIP, dl, DAG.getVTList(VT, VT), + V1, V1).getValue(WhichResult); + // If the shuffle is not directly supported and it has 4 elements, use // the PerfectShuffle-generated table to synthesize it from other shuffles. if (VT.getVectorNumElements() == 4 && Added: llvm/trunk/test/CodeGen/ARM/2009-12-02-vtrn-undef.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-12-02-vtrn-undef.ll?rev=90417&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-12-02-vtrn-undef.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2009-12-02-vtrn-undef.ll Thu Dec 3 00:40:55 2009 @@ -0,0 +1,19 @@ +; RUN: llc -mcpu=cortex-a8 < %s | FileCheck %s + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:64:64-v128:128:128-a0:0:32-n32" +target triple = "armv7-apple-darwin10" + +%struct.int16x8_t = type { <8 x i16> } +%struct.int16x8x2_t = type { [2 x %struct.int16x8_t] } + +define arm_apcscc void @t(%struct.int16x8x2_t* noalias nocapture sret %agg.result, <8 x i16> %tmp.0, %struct.int16x8x2_t* nocapture %dst) nounwind { +entry: +;CHECK: vtrn.16 + %0 = shufflevector <8 x i16> %tmp.0, <8 x i16> undef, <8 x i32> + %1 = shufflevector <8 x i16> %tmp.0, <8 x i16> undef, <8 x i32> + %agg.result1218.0 = getelementptr %struct.int16x8x2_t* %agg.result, i32 0, i32 0, i32 0, i32 0 ; <<8 x i16>*> + store <8 x i16> %0, <8 x i16>* %agg.result1218.0, align 16 + %agg.result12.1.0 = getelementptr %struct.int16x8x2_t* %agg.result, i32 0, i32 0, i32 1, i32 0 ; <<8 x i16>*> + store <8 x i16> %1, <8 x i16>* %agg.result12.1.0, align 16 + ret void +} From sabre at nondot.org Thu Dec 3 00:58:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 06:58:32 -0000 Subject: [llvm-commits] [llvm] r90419 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <200912030658.nB36wWhj018959@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 00:58:32 2009 New Revision: 90419 URL: http://llvm.org/viewvc/llvm-project?rev=90419&view=rev Log: fix a build problem with VC++, PR5664, patch by Alp Toker! Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=90419&r1=90418&r2=90419&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Thu Dec 3 00:58:32 2009 @@ -418,11 +418,13 @@ return true; } -/// FIXME: Works around a gcc miscompilation with -fstrict-aliasing +/// FIXME: Works around a gcc miscompilation with -fstrict-aliasing. +DISABLE_INLINE static unsigned getNumJTEntries(const std::vector &JT, - unsigned JTI) DISABLE_INLINE; + unsigned JTI); static unsigned getNumJTEntries(const std::vector &JT, unsigned JTI) { + assert(JTI < JT.size()); return JT[JTI].MBBs.size(); } From natebegeman at mac.com Thu Dec 3 01:11:30 2009 From: natebegeman at mac.com (Nate Begeman) Date: Thu, 03 Dec 2009 07:11:30 -0000 Subject: [llvm-commits] [llvm] r90423 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/vec_compare-2.ll Message-ID: <200912030711.nB37BU0A019459@zion.cs.uiuc.edu> Author: sampo Date: Thu Dec 3 01:11:29 2009 New Revision: 90423 URL: http://llvm.org/viewvc/llvm-project?rev=90423&view=rev Log: Don't pull vector sext through both hands of a logical operation, since doing so prevents the fusion of vector sext and setcc into vsetcc. Add a testcase for the above transformation. Fix a bogus use of APInt noticed while tracking this down. Added: llvm/trunk/test/CodeGen/X86/vec_compare-2.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=90423&r1=90422&r2=90423&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Dec 3 01:11:29 2009 @@ -1688,10 +1688,14 @@ // fold (OP (sext x), (sext y)) -> (sext (OP x, y)) // fold (OP (aext x), (aext y)) -> (aext (OP x, y)) // fold (OP (trunc x), (trunc y)) -> (trunc (OP x, y)) (if trunc isn't free) + // + // do not sink logical op inside of a vector extend, since it may combine + // into a vsetcc. if ((N0.getOpcode() == ISD::ZERO_EXTEND || N0.getOpcode() == ISD::ANY_EXTEND|| N0.getOpcode() == ISD::SIGN_EXTEND || (N0.getOpcode() == ISD::TRUNCATE && !TLI.isTruncateFree(N0.getOperand(0).getValueType(), VT))) && + !VT.isVector() && N0.getOperand(0).getValueType() == N1.getOperand(0).getValueType() && (!LegalOperations || TLI.isOperationLegal(N->getOpcode(), N0.getOperand(0).getValueType()))) { @@ -1944,8 +1948,10 @@ } // fold (or x, undef) -> -1 - if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF) - return DAG.getConstant(APInt::getAllOnesValue(VT.getSizeInBits()), VT); + if (N0.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF) { + EVT EltVT = VT.isVector() ? VT.getVectorElementType() : VT; + return DAG.getConstant(APInt::getAllOnesValue(EltVT.getSizeInBits()), VT); + } // fold (or c1, c2) -> c1|c2 if (N0C && N1C) return DAG.FoldConstantArithmetic(ISD::OR, VT, N0C, N1C); Added: llvm/trunk/test/CodeGen/X86/vec_compare-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare-2.ll?rev=90423&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare-2.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_compare-2.ll Thu Dec 3 01:11:29 2009 @@ -0,0 +1,29 @@ +; RUN: llc < %s -march=x86 -mcpu=penryn -disable-mmx | FileCheck %s + +declare <4 x float> @llvm.x86.sse41.blendvps(<4 x float>, <4 x float>, <4 x float>) nounwind readnone + +declare <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32>, <4 x i32>) nounwind readnone + +declare <4 x i32> @llvm.x86.sse41.pmaxsd(<4 x i32>, <4 x i32>) nounwind readnone + +define void @blackDespeckle_wrapper(i8** %args_list, i64* %gtid, i64 %xend) { +entry: +; CHECK-NOT: set +; CHECK: pcmpgt +; CHECK: blendvps + %shr.i = ashr <4 x i32> zeroinitializer, ; <<4 x i32>> [#uses=1] + %cmp318.i = sext <4 x i1> zeroinitializer to <4 x i32> ; <<4 x i32>> [#uses=1] + %sub322.i = sub <4 x i32> %shr.i, zeroinitializer ; <<4 x i32>> [#uses=1] + %cmp323.x = icmp slt <4 x i32> zeroinitializer, %sub322.i ; <<4 x i1>> [#uses=1] + %cmp323.i = sext <4 x i1> %cmp323.x to <4 x i32> ; <<4 x i32>> [#uses=1] + %or.i = or <4 x i32> %cmp318.i, %cmp323.i ; <<4 x i32>> [#uses=1] + %tmp10.i83.i = bitcast <4 x i32> %or.i to <4 x float> ; <<4 x float>> [#uses=1] + %0 = call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> undef, <4 x float> undef, <4 x float> %tmp10.i83.i) nounwind ; <<4 x float>> [#uses=1] + %conv.i.i15.i = bitcast <4 x float> %0 to <4 x i32> ; <<4 x i32>> [#uses=1] + %swz.i.i28.i = shufflevector <4 x i32> %conv.i.i15.i, <4 x i32> undef, <2 x i32> ; <<2 x i32>> [#uses=1] + %tmp6.i29.i = bitcast <2 x i32> %swz.i.i28.i to <4 x i16> ; <<4 x i16>> [#uses=1] + %swz.i30.i = shufflevector <4 x i16> %tmp6.i29.i, <4 x i16> undef, <2 x i32> ; <<2 x i16>> [#uses=1] + store <2 x i16> %swz.i30.i, <2 x i16>* undef + unreachable + ret void +} From sabre at nondot.org Thu Dec 3 01:41:54 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 07:41:54 -0000 Subject: [llvm-commits] [llvm] r90428 - /llvm/trunk/lib/Target/README.txt Message-ID: <200912030741.nB37fsLv020622@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 01:41:54 2009 New Revision: 90428 URL: http://llvm.org/viewvc/llvm-project?rev=90428&view=rev Log: add a note Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=90428&r1=90427&r2=90428&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Thu Dec 3 01:41:54 2009 @@ -1704,3 +1704,35 @@ would delete the or instruction for us. //===---------------------------------------------------------------------===// + +FunctionAttrs is not marking this function as readnone (just readonly): +$ clang t.c -emit-llvm -S -o - -O0 | opt -mem2reg -S -functionattrs + +int t(int a, int b, int c) { + int *p; + if (a) + p = &a; + else + p = &c; + return *p; +} + +This is because we codegen this to: + +define i32 @t(i32 %a, i32 %b, i32 %c) nounwind readonly ssp { +entry: + %a.addr = alloca i32 ; [#uses=3] + %c.addr = alloca i32 ; [#uses=2] +... + +if.end: + %p.0 = phi i32* [ %a.addr, %if.then ], [ %c.addr, %if.else ] + %tmp2 = load i32* %p.0 ; [#uses=1] + ret i32 %tmp2 +} + +And functionattrs doesn't realize that the p.0 load points to function local +memory. + +//===---------------------------------------------------------------------===// + From sabre at nondot.org Thu Dec 3 01:43:46 2009 From: sabre at nondot.org (Chris Lattner) Date: Thu, 03 Dec 2009 07:43:46 -0000 Subject: [llvm-commits] [llvm] r90429 - /llvm/trunk/lib/Target/README.txt Message-ID: <200912030743.nB37hkXR020707@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 01:43:46 2009 New Revision: 90429 URL: http://llvm.org/viewvc/llvm-project?rev=90429&view=rev Log: expand note. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=90429&r1=90428&r2=90429&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Thu Dec 3 01:43:46 2009 @@ -1734,5 +1734,20 @@ And functionattrs doesn't realize that the p.0 load points to function local memory. +Also, functionattrs doesn't know about memcpy/memset. This function should be +marked readnone, since it only twiddles local memory, but functionattrs doesn't +handle memset/memcpy/memmove aggressively: + +struct X { int *p; int *q; }; +int foo() { + int i = 0, j = 1; + struct X x, y; + int **p; + y.p = &i; + x.q = &j; + p = __builtin_memcpy (&x, &y, sizeof (int *)); + return **p; +} + //===---------------------------------------------------------------------===// From evan.cheng at apple.com Thu Dec 3 02:43:53 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 03 Dec 2009 08:43:53 -0000 Subject: [llvm-commits] [llvm] r90432 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <200912030843.nB38hsRR025570@zion.cs.uiuc.edu> Author: evancheng Date: Thu Dec 3 02:43:53 2009 New Revision: 90432 URL: http://llvm.org/viewvc/llvm-project?rev=90432&view=rev Log: Teach tail duplication to update SSA form. Work in progress. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90432&r1=90431&r2=90432&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Thu Dec 3 02:43:53 2009 @@ -17,6 +17,8 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/MachineSSAUpdater.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -36,11 +38,21 @@ cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2), cl::Hidden); +typedef std::vector AvailableValsTy; + namespace { /// TailDuplicatePass - Perform tail duplication. class TailDuplicatePass : public MachineFunctionPass { const TargetInstrInfo *TII; MachineModuleInfo *MMI; + MachineRegisterInfo *MRI; + + // SSAUpdateVRs - A list of virtual registers for which to update SSA form. + SmallVector SSAUpdateVRs; + + // SSAUpdateVals - For each virtual register in SSAUpdateVals keep a list of + // source virtual registers. + DenseMap SSAUpdateVals; public: static char ID; @@ -50,6 +62,7 @@ virtual const char *getPassName() const { return "Tail Duplication"; } private: + void AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg); bool TailDuplicateBlocks(MachineFunction &MF); bool TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF); void RemoveDeadBlock(MachineBasicBlock *MBB); @@ -64,6 +77,7 @@ bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) { TII = MF.getTarget().getInstrInfo(); + MRI = &MF.getRegInfo(); MMI = getAnalysisIfAvailable(); bool MadeChange = false; @@ -83,6 +97,9 @@ bool TailDuplicatePass::TailDuplicateBlocks(MachineFunction &MF) { bool MadeChange = false; + SSAUpdateVRs.clear(); + SSAUpdateVals.clear(); + for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; @@ -100,13 +117,83 @@ ++NumDeadBlocks; } } + + if (!SSAUpdateVRs.empty()) { + // Update SSA form. + MachineSSAUpdater SSAUpdate(MF); + + for (unsigned i = 0, e = SSAUpdateVRs.size(); i != e; ++i) { + unsigned VReg = SSAUpdateVRs[i]; + SSAUpdate.Initialize(VReg); + + // If the original definition is still around, add it as an available + // value. + MachineInstr *DefMI = MRI->getVRegDef(VReg); + MachineBasicBlock *DefBB = 0; + if (DefMI) { + DefBB = DefMI->getParent(); + SSAUpdate.AddAvailableValue(DefBB, VReg); + } + + // Add the new vregs as available values. + DenseMap::iterator LI = + SSAUpdateVals.find(VReg); + for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { + unsigned NewReg = LI->second[j]; + MachineInstr *DefMI = MRI->getVRegDef(NewReg); + SSAUpdate.AddAvailableValue(DefMI->getParent(), NewReg); + } + + // Rewrite uses that are outside of the original def's block. + for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(VReg), + UE = MRI->use_end(); UI != UE; ++UI) { + MachineInstr *UseMI = &*UI; + if (UseMI->getParent() != DefBB) + SSAUpdate.RewriteUse(UI.getOperand()); + } + } + } + return MadeChange; } +static bool isDefLiveOut(unsigned Reg, MachineBasicBlock *BB, + const MachineRegisterInfo *MRI) { + for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(Reg), + UE = MRI->use_end(); UI != UE; ++UI) { + MachineInstr *UseMI = &*UI; + if (UseMI->getParent() != BB) + return true; + } + return false; +} + +static unsigned getPHISrcRegOpIdx(MachineInstr *MI, MachineBasicBlock *SrcBB) { + for (unsigned i = 1, e = MI->getNumOperands(); i != e; i += 2) + if (MI->getOperand(i+1).getMBB() == SrcBB) + return i; + return 0; +} + +/// AddSSAUpdateEntry - Add a definition and source virtual registers pair for +/// SSA update. +void TailDuplicatePass::AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg) { + DenseMap::iterator LI = + SSAUpdateVals.find(OrigReg); + if (LI != SSAUpdateVals.end()) + LI->second.push_back(NewReg); + else { + AvailableValsTy Vals; + Vals.push_back(NewReg); + SSAUpdateVals.insert(std::make_pair(OrigReg, Vals)); + SSAUpdateVRs.push_back(OrigReg); + } +} + /// TailDuplicate - If it is profitable, duplicate TailBB's contents in each /// of its predecessors. bool TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, - MachineFunction &MF) { + MachineFunction &MF) { // Don't try to tail-duplicate single-block loops. if (TailBB->isSuccessor(TailBB)) return false; @@ -179,10 +266,54 @@ // Remove PredBB's unconditional branch. TII->RemoveBranch(*PredBB); + // Clone the contents of TailBB into PredBB. - for (MachineBasicBlock::iterator I = TailBB->begin(), E = TailBB->end(); - I != E; ++I) { + DenseMap LocalVRMap; + MachineBasicBlock::iterator I = TailBB->begin(); + MachineBasicBlock::iterator NI; + for (MachineBasicBlock::iterator E = TailBB->end(); I != E; I = NI) { + NI = next(I); + if (I->getOpcode() == TargetInstrInfo::PHI) { + // Replace the uses of the def of the PHI with the register coming + // from PredBB. + unsigned DefReg = I->getOperand(0).getReg(); + unsigned SrcOpIdx = getPHISrcRegOpIdx(I, PredBB); + unsigned SrcReg = I->getOperand(SrcOpIdx).getReg(); + LocalVRMap.insert(std::make_pair(DefReg, SrcReg)); + if (isDefLiveOut(DefReg, TailBB, MRI)) + AddSSAUpdateEntry(DefReg, SrcReg); + + // Remove PredBB from the PHI node. + I->RemoveOperand(SrcOpIdx+1); + I->RemoveOperand(SrcOpIdx); + if (I->getNumOperands() == 1) + I->eraseFromParent(); + continue; + } + + // Replace def of virtual registers with new registers, and update uses + // with PHI source register or the new registers. MachineInstr *NewMI = MF.CloneMachineInstr(I); + for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = NewMI->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) + continue; + if (MO.isDef()) { + const TargetRegisterClass *RC = MRI->getRegClass(Reg); + unsigned NewReg = MRI->createVirtualRegister(RC); + MO.setReg(NewReg); + LocalVRMap.insert(std::make_pair(Reg, NewReg)); + if (isDefLiveOut(Reg, TailBB, MRI)) + AddSSAUpdateEntry(Reg, NewReg); + } else { + DenseMap::iterator VI = LocalVRMap.find(Reg); + if (VI != LocalVRMap.end()) + MO.setReg(VI->second); + } + } PredBB->insert(PredBB->end(), NewMI); } NumInstrDups += TailBB->size() - 1; // subtract one for removed branch From baldrick at free.fr Thu Dec 3 02:44:42 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Dec 2009 09:44:42 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> Message-ID: <4B177A7A.9010906@free.fr> Rafael Espindola wrote: >> I don't have any testcases that are better than the one for pr5406. I'm not sure if it is safe to access a 24-bit struct as an i32. Well, you could always access it as an i24 :) Ciao, Duncan. From astifter-llvm at gmx.at Thu Dec 3 02:56:41 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Thu, 03 Dec 2009 09:56:41 +0100 Subject: [llvm-commits] Fwd: [llvm] r80947 - /llvm/trunk/test/Analysis/Profiling/profiling-tool-chain.ll In-Reply-To: <6a8523d60909110842y1ae8ae66sedbb8249d12acc2@mail.gmail.com> References: <200909032109.n83L9sbE030014@zion.cs.uiuc.edu> <6a8523d60909031424m6e3de00amfef5815e5fcac666@mail.gmail.com> <4AA03ADE.3000004@gmx.at> <4AAA106B.2080508@gmx.at> <6a8523d60909110842y1ae8ae66sedbb8249d12acc2@mail.gmail.com> Message-ID: <4B177D49.1040401@gmx.at> Sorry to ask, but would you mind trying this test again with the latest revisions? Unfortunatelly I can't reproduce this bug myself... I haven't made any specific changes, but maybe it has resolved itself? Thanks, Andi On 09/11/2009 05:42 PM, Daniel Dunbar wrote: > On Fri, Sep 11, 2009 at 1:55 AM, Andreas Neustifter > wrote: >> Hi Daniel, >> >> Andreas Neustifter wrote: >>> >>> Daniel Dunbar wrote: >>>> I attached a tarball of the Output/ directory from the self-hosted >>>> tests. If I compare to my local copy its clear what the problem is, >>>> the OptEdgeProfCounts are wrong in the self hosted module. No clues as >>>> to why yet. Do you have any idea what might be going on? >>> >>> No, not really. The initializer for OptEdgeProfCounters is wrong. >> >> Is there any progress on this? > > No, sorry. > >> What are the exact steps to produce this selfhosted build? I would like >> to check on that this weekend... > > Well, if it reproduces easily then all you should need to do is: > 1. build LLVM. > 2. build llvm-gcc > 3. build a new copy of LLVM configured to use your fresh llvm-gcc, > and using that as the C/C++ compiler. > 4. run make check (with those test portions enabled). > > - Daniel > From baldrick at free.fr Thu Dec 3 03:00:26 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Dec 2009 10:00:26 +0100 Subject: [llvm-commits] [llvm] r90417 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2009-12-02-vtrn-undef.ll In-Reply-To: <200912030640.nB36etKX018295@zion.cs.uiuc.edu> References: <200912030640.nB36etKX018295@zion.cs.uiuc.edu> Message-ID: <4B177E2A.2040908@free.fr> Hi Bob, > Recognize canonical forms of vector shuffles where the same vector is used for > both source operands. In the canonical form, the 2nd operand is changed to an > undef and the shuffle mask is adjusted to only reference elements from the 1st > operand. Radar 7434842. this sounds like a general optimization, i.e. not ARM specific. How about doing this in the DAG combiner instead? Ciao, Duncan. From astifter-llvm at gmx.at Thu Dec 3 03:30:12 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Thu, 03 Dec 2009 09:30:12 -0000 Subject: [llvm-commits] [llvm] r90445 - in /llvm/trunk: include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileInfo.cpp Message-ID: <200912030930.nB39UCep006456@zion.cs.uiuc.edu> Author: astifter Date: Thu Dec 3 03:30:12 2009 New Revision: 90445 URL: http://llvm.org/viewvc/llvm-project?rev=90445&view=rev Log: Converted ProfileInfo to template, added more API for ProfileInfo-preserving. Modified: llvm/trunk/include/llvm/Analysis/ProfileInfo.h llvm/trunk/lib/Analysis/ProfileInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/ProfileInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ProfileInfo.h?rev=90445&r1=90444&r2=90445&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ProfileInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/ProfileInfo.h Thu Dec 3 03:30:12 2009 @@ -21,116 +21,228 @@ #ifndef LLVM_ANALYSIS_PROFILEINFO_H #define LLVM_ANALYSIS_PROFILEINFO_H -#include "llvm/BasicBlock.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/Format.h" +#include "llvm/Support/raw_ostream.h" #include #include #include +#include namespace llvm { - class Function; class Pass; class raw_ostream; + class BasicBlock; + class Function; + class MachineBasicBlock; + class MachineFunction; + + // Helper for dumping edges to errs(). + raw_ostream& operator<<(raw_ostream &O, std::pair E); + raw_ostream& operator<<(raw_ostream &O, std::pair E); + + raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB); + raw_ostream& operator<<(raw_ostream &O, const MachineBasicBlock *MBB); + + raw_ostream& operator<<(raw_ostream &O, const Function *F); + raw_ostream& operator<<(raw_ostream &O, const MachineFunction *MF); + /// ProfileInfo Class - This class holds and maintains profiling /// information for some unit of code. - class ProfileInfo { + template + class ProfileInfoT { public: // Types for handling profiling information. - typedef std::pair Edge; + typedef std::pair Edge; typedef std::pair EdgeWeight; typedef std::map EdgeWeights; - typedef std::map BlockCounts; + typedef std::map BlockCounts; + typedef std::map Path; protected: // EdgeInformation - Count the number of times a transition between two // blocks is executed. As a special case, we also hold an edge from the // null BasicBlock to the entry block to indicate how many times the // function was entered. - std::map EdgeInformation; + std::map EdgeInformation; // BlockInformation - Count the number of times a block is executed. - std::map BlockInformation; + std::map BlockInformation; // FunctionInformation - Count the number of times a function is executed. - std::map FunctionInformation; + std::map FunctionInformation; + + ProfileInfoT *MachineProfile; public: static char ID; // Class identification, replacement for typeinfo - virtual ~ProfileInfo(); // We want to be subclassed + ProfileInfoT(); + ~ProfileInfoT(); // We want to be subclassed // MissingValue - The value that is returned for execution counts in case // no value is available. static const double MissingValue; // getFunction() - Returns the Function for an Edge, checking for validity. - static const Function* getFunction(Edge e) { + static const FType* getFunction(Edge e) { if (e.first) { return e.first->getParent(); } else if (e.second) { return e.second->getParent(); } assert(0 && "Invalid ProfileInfo::Edge"); - return (const Function*)0; + return (const FType*)0; } // getEdge() - Creates an Edge from two BasicBlocks. - static Edge getEdge(const BasicBlock *Src, const BasicBlock *Dest) { + static Edge getEdge(const BType *Src, const BType *Dest) { return std::make_pair(Src, Dest); } //===------------------------------------------------------------------===// /// Profile Information Queries /// - double getExecutionCount(const Function *F); + double getExecutionCount(const FType *F); + + double getExecutionCount(const BType *BB); + + void setExecutionCount(const BType *BB, double w); - double getExecutionCount(const BasicBlock *BB); + void addExecutionCount(const BType *BB, double w); double getEdgeWeight(Edge e) const { - std::map::const_iterator J = + typename std::map::const_iterator J = EdgeInformation.find(getFunction(e)); if (J == EdgeInformation.end()) return MissingValue; - EdgeWeights::const_iterator I = J->second.find(e); + typename EdgeWeights::const_iterator I = J->second.find(e); if (I == J->second.end()) return MissingValue; return I->second; } - EdgeWeights &getEdgeWeights (const Function *F) { + void setEdgeWeight(Edge e, double w) { + DEBUG_WITH_TYPE("profile-info", + errs() << "Creating Edge " << e + << " (weight: " << format("%.20g",w) << ")\n"); + EdgeInformation[getFunction(e)][e] = w; + } + + void addEdgeWeight(Edge e, double w); + + EdgeWeights &getEdgeWeights (const FType *F) { return EdgeInformation[F]; } //===------------------------------------------------------------------===// /// Analysis Update Methods /// - void removeBlock(const BasicBlock *BB) { - std::map::iterator J = - BlockInformation.find(BB->getParent()); - if (J == BlockInformation.end()) return; + void removeBlock(const BType *BB); - J->second.erase(BB); - } + void removeEdge(Edge e); - void removeEdge(Edge e) { - std::map::iterator J = - EdgeInformation.find(getFunction(e)); - if (J == EdgeInformation.end()) return; + void replaceEdge(const Edge &, const Edge &); - J->second.erase(e); + enum GetPathMode { + GetPathToExit = 1, + GetPathToValue = 2, + GetPathToDest = 4, + GetPathWithNewEdges = 8 + }; + + const BType *GetPath(const BType *Src, const BType *Dest, + Path &P, unsigned Mode); + + void divertFlow(const Edge &, const Edge &); + + void splitEdge(const BType *FirstBB, const BType *SecondBB, + const BType *NewBB, bool MergeIdenticalEdges = false); + + void splitBlock(const BType *Old, const BType* New); + + void splitBlock(const BType *BB, const BType* NewBB, + BType *const *Preds, unsigned NumPreds); + + void replaceAllUses(const BType *RmBB, const BType *DestBB); + + void transfer(const FType *Old, const FType *New); + + void repair(const FType *F); + + void dump(FType *F = 0, bool real = true) { + errs() << "**** This is ProfileInfo " << this << " speaking:\n"; + if (!real) { + typename std::set Functions; + + errs() << "Functions: \n"; + if (F) { + errs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n"; + Functions.insert(F); + } else { + for (typename std::map::iterator fi = FunctionInformation.begin(), + fe = FunctionInformation.end(); fi != fe; ++fi) { + errs() << fi->first << "@" << format("%p",fi->first) << ": " << format("%.20g",fi->second) << "\n"; + Functions.insert(fi->first); + } + } + + for (typename std::set::iterator FI = Functions.begin(), FE = Functions.end(); + FI != FE; ++FI) { + const FType *F = *FI; + typename std::map::iterator bwi = BlockInformation.find(F); + errs() << "BasicBlocks for Function " << F << ":\n"; + for (typename BlockCounts::const_iterator bi = bwi->second.begin(), be = bwi->second.end(); bi != be; ++bi) { + errs() << bi->first << "@" << format("%p", bi->first) << ": " << format("%.20g",bi->second) << "\n"; + } + } + + for (typename std::set::iterator FI = Functions.begin(), FE = Functions.end(); + FI != FE; ++FI) { + typename std::map::iterator ei = EdgeInformation.find(*FI); + errs() << "Edges for Function " << ei->first << ":\n"; + for (typename EdgeWeights::iterator ewi = ei->second.begin(), ewe = ei->second.end(); + ewi != ewe; ++ewi) { + errs() << ewi->first << ": " << format("%.20g",ewi->second) << "\n"; + } + } + } else { + assert(F && "No function given, this is not supported!"); + errs() << "Functions: \n"; + errs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n"; + + errs() << "BasicBlocks for Function " << F << ":\n"; + for (typename FType::const_iterator BI = F->begin(), BE = F->end(); + BI != BE; ++BI) { + const BType *BB = &(*BI); + errs() << BB << "@" << format("%p", BB) << ": " << format("%.20g",getExecutionCount(BB)) << "\n"; + } + } + errs() << "**** ProfileInfo " << this << ", over and out.\n"; } - void splitEdge(const BasicBlock *FirstBB, const BasicBlock *SecondBB, - const BasicBlock *NewBB, bool MergeIdenticalEdges = false); + bool CalculateMissingEdge(const BType *BB, Edge &removed, bool assumeEmptyExit = false); + + bool EstimateMissingEdges(const BType *BB); - void replaceAllUses(const BasicBlock *RmBB, const BasicBlock *DestBB); + ProfileInfoT *MI() { + if (MachineProfile == 0) + MachineProfile = new ProfileInfoT(); + return MachineProfile; + } + + bool hasMI() const { + return (MachineProfile != 0); + } }; + typedef ProfileInfoT ProfileInfo; + typedef ProfileInfoT MachineProfileInfo; + /// createProfileLoaderPass - This function returns a Pass that loads the /// profiling information for the module from the specified filename, making /// it available to the optimizers. Pass *createProfileLoaderPass(const std::string &Filename); - raw_ostream& operator<<(raw_ostream &O, ProfileInfo::Edge E); - } // End llvm namespace #endif Modified: llvm/trunk/lib/Analysis/ProfileInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfo.cpp?rev=90445&r1=90444&r2=90445&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileInfo.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileInfo.cpp Thu Dec 3 03:30:12 2009 @@ -11,25 +11,51 @@ // "no profile" implementation. // //===----------------------------------------------------------------------===// - +#define DEBUG_TYPE "profile-info" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/ProfileInfo.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/Pass.h" #include "llvm/Support/CFG.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Format.h" +#include "llvm/ADT/SmallSet.h" #include +#include +#include using namespace llvm; // Register the ProfileInfo interface, providing a nice name to refer to. static RegisterAnalysisGroup Z("Profile Information"); + +namespace llvm { + +template <> +ProfileInfoT::ProfileInfoT() {} +template <> +ProfileInfoT::~ProfileInfoT() {} + +template <> +ProfileInfoT::ProfileInfoT() { + MachineProfile = 0; +} +template <> +ProfileInfoT::~ProfileInfoT() { + if (MachineProfile) delete MachineProfile; +} + +template<> char ProfileInfo::ID = 0; -ProfileInfo::~ProfileInfo() {} +template<> +char MachineProfileInfo::ID = 0; +template<> const double ProfileInfo::MissingValue = -1; +template<> +const double MachineProfileInfo::MissingValue = -1; + +template<> double ProfileInfo::getExecutionCount(const BasicBlock *BB) { std::map::iterator J = BlockInformation.find(BB->getParent()); @@ -39,35 +65,72 @@ return I->second; } + double Count = MissingValue; + pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); // Are there zero predecessors of this block? if (PI == PE) { - // If this is the entry block, look for the Null -> Entry edge. - if (BB == &BB->getParent()->getEntryBlock()) - return getEdgeWeight(getEdge(0, BB)); - else - return 0; // Otherwise, this is a dead block. + Edge e = getEdge(0,BB); + Count = getEdgeWeight(e); + } else { + // Otherwise, if there are predecessors, the execution count of this block is + // the sum of the edge frequencies from the incoming edges. + std::set ProcessedPreds; + Count = 0; + for (; PI != PE; ++PI) + if (ProcessedPreds.insert(*PI).second) { + double w = getEdgeWeight(getEdge(*PI, BB)); + if (w == MissingValue) { + Count = MissingValue; + break; + } + Count += w; + } } - // Otherwise, if there are predecessors, the execution count of this block is - // the sum of the edge frequencies from the incoming edges. - std::set ProcessedPreds; - double Count = 0; - for (; PI != PE; ++PI) - if (ProcessedPreds.insert(*PI).second) { - double w = getEdgeWeight(getEdge(*PI, BB)); - if (w == MissingValue) { - Count = MissingValue; - break; - } - Count += w; + // If the predecessors did not suffice to get block weight, try successors. + if (Count == MissingValue) { + + succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB); + + // Are there zero successors of this block? + if (SI == SE) { + Edge e = getEdge(BB,0); + Count = getEdgeWeight(e); + } else { + std::set ProcessedSuccs; + Count = 0; + for (; SI != SE; ++SI) + if (ProcessedSuccs.insert(*SI).second) { + double w = getEdgeWeight(getEdge(BB, *SI)); + if (w == MissingValue) { + Count = MissingValue; + break; + } + Count += w; + } } + } if (Count != MissingValue) BlockInformation[BB->getParent()][BB] = Count; return Count; } +template<> +double MachineProfileInfo::getExecutionCount(const MachineBasicBlock *MBB) { + std::map::iterator J = + BlockInformation.find(MBB->getParent()); + if (J != BlockInformation.end()) { + BlockCounts::iterator I = J->second.find(MBB); + if (I != J->second.end()) + return I->second; + } + + return MissingValue; +} + +template<> double ProfileInfo::getExecutionCount(const Function *F) { std::map::iterator J = FunctionInformation.find(F); @@ -83,35 +146,204 @@ return Count; } +template<> +double MachineProfileInfo::getExecutionCount(const MachineFunction *MF) { + std::map::iterator J = + FunctionInformation.find(MF); + if (J != FunctionInformation.end()) + return J->second; + + double Count = getExecutionCount(&MF->front()); + if (Count != MissingValue) FunctionInformation[MF] = Count; + return Count; +} + +template<> +void ProfileInfo::setExecutionCount(const BasicBlock *BB, double w) { + DEBUG(errs() << "Creating Block " << BB->getName() + << " (weight: " << format("%.20g",w) << ")\n"); + BlockInformation[BB->getParent()][BB] = w; +} + +template<> +void MachineProfileInfo::setExecutionCount(const MachineBasicBlock *MBB, double w) { + DEBUG(errs() << "Creating Block " << MBB->getBasicBlock()->getName() + << " (weight: " << format("%.20g",w) << ")\n"); + BlockInformation[MBB->getParent()][MBB] = w; +} + +template<> +void ProfileInfo::addEdgeWeight(Edge e, double w) { + double oldw = getEdgeWeight(e); + assert (oldw != MissingValue && "Adding weight to Edge with no previous weight"); + DEBUG(errs() << "Adding to Edge " << e + << " (new weight: " << format("%.20g",oldw + w) << ")\n"); + EdgeInformation[getFunction(e)][e] = oldw + w; +} + +template<> +void ProfileInfo::addExecutionCount(const BasicBlock *BB, double w) { + double oldw = getExecutionCount(BB); + assert (oldw != MissingValue && "Adding weight to Block with no previous weight"); + DEBUG(errs() << "Adding to Block " << BB->getName() + << " (new weight: " << format("%.20g",oldw + w) << ")\n"); + BlockInformation[BB->getParent()][BB] = oldw + w; +} + +template<> +void ProfileInfo::removeBlock(const BasicBlock *BB) { + std::map::iterator J = + BlockInformation.find(BB->getParent()); + if (J == BlockInformation.end()) return; + + DEBUG(errs() << "Deleting " << BB->getName() << "\n"); + J->second.erase(BB); +} + +template<> +void ProfileInfo::removeEdge(Edge e) { + std::map::iterator J = + EdgeInformation.find(getFunction(e)); + if (J == EdgeInformation.end()) return; + + DEBUG(errs() << "Deleting" << e << "\n"); + J->second.erase(e); +} + +template<> +void ProfileInfo::replaceEdge(const Edge &oldedge, const Edge &newedge) { + double w; + if ((w = getEdgeWeight(newedge)) == MissingValue) { + w = getEdgeWeight(oldedge); + DEBUG(errs() << "Replacing " << oldedge << " with " << newedge << "\n"); + } else { + w += getEdgeWeight(oldedge); + DEBUG(errs() << "Adding " << oldedge << " to " << newedge << "\n"); + } + setEdgeWeight(newedge,w); + removeEdge(oldedge); +} + +template<> +const BasicBlock *ProfileInfo::GetPath(const BasicBlock *Src, const BasicBlock *Dest, + Path &P, unsigned Mode) { + const BasicBlock *BB = 0; + bool hasFoundPath = false; + + std::queue BFS; + BFS.push(Src); + + while(BFS.size() && !hasFoundPath) { + BB = BFS.front(); + BFS.pop(); + + succ_const_iterator Succ = succ_begin(BB), End = succ_end(BB); + if (Succ == End) { + P[0] = BB; + if (Mode & GetPathToExit) { + hasFoundPath = true; + BB = 0; + } + } + for(;Succ != End; ++Succ) { + if (P.find(*Succ) != P.end()) continue; + Edge e = getEdge(BB,*Succ); + if ((Mode & GetPathWithNewEdges) && (getEdgeWeight(e) != MissingValue)) continue; + P[*Succ] = BB; + BFS.push(*Succ); + if ((Mode & GetPathToDest) && *Succ == Dest) { + hasFoundPath = true; + BB = *Succ; + break; + } + if ((Mode & GetPathToValue) && (getExecutionCount(*Succ) != MissingValue)) { + hasFoundPath = true; + BB = *Succ; + break; + } + } + } + + return BB; +} + +template<> +void ProfileInfo::divertFlow(const Edge &oldedge, const Edge &newedge) { + DEBUG(errs() << "Diverting " << oldedge << " via " << newedge ); + + // First check if the old edge was taken, if not, just delete it... + if (getEdgeWeight(oldedge) == 0) { + removeEdge(oldedge); + return; + } + + Path P; + P[newedge.first] = 0; + P[newedge.second] = newedge.first; + const BasicBlock *BB = GetPath(newedge.second,oldedge.second,P,GetPathToExit | GetPathToDest); + + double w = getEdgeWeight (oldedge); + DEBUG(errs() << ", Weight: " << format("%.20g",w) << "\n"); + do { + const BasicBlock *Parent = P.find(BB)->second; + Edge e = getEdge(Parent,BB); + double oldw = getEdgeWeight(e); + double oldc = getExecutionCount(e.first); + setEdgeWeight(e, w+oldw); + if (Parent != oldedge.first) { + setExecutionCount(e.first, w+oldc); + } + BB = Parent; + } while (BB != newedge.first); + removeEdge(oldedge); +} + /// Replaces all occurences of RmBB in the ProfilingInfo with DestBB. /// This checks all edges of the function the blocks reside in and replaces the /// occurences of RmBB with DestBB. +template<> void ProfileInfo::replaceAllUses(const BasicBlock *RmBB, const BasicBlock *DestBB) { - DEBUG(errs() << "Replacing " << RmBB->getNameStr() - << " with " << DestBB->getNameStr() << "\n"); + DEBUG(errs() << "Replacing " << RmBB->getName() + << " with " << DestBB->getName() << "\n"); const Function *F = DestBB->getParent(); std::map::iterator J = EdgeInformation.find(F); if (J == EdgeInformation.end()) return; - for (EdgeWeights::iterator I = J->second.begin(), E = J->second.end(); - I != E; ++I) { - Edge e = I->first; - Edge newedge; bool foundedge = false; + Edge e, newedge; + bool erasededge = false; + EdgeWeights::iterator I = J->second.begin(), E = J->second.end(); + while(I != E) { + e = (I++)->first; + bool foundedge = false; bool eraseedge = false; if (e.first == RmBB) { - newedge = getEdge(DestBB, e.second); - foundedge = true; + if (e.second == DestBB) { + eraseedge = true; + } else { + newedge = getEdge(DestBB, e.second); + foundedge = true; + } } if (e.second == RmBB) { - newedge = getEdge(e.first, DestBB); - foundedge = true; + if (e.first == DestBB) { + eraseedge = true; + } else { + newedge = getEdge(e.first, DestBB); + foundedge = true; + } } if (foundedge) { - double w = getEdgeWeight(e); - EdgeInformation[F][newedge] = w; - DEBUG(errs() << "Replacing " << e << " with " << newedge << "\n"); - J->second.erase(e); + replaceEdge(e, newedge); + } + if (eraseedge) { + if (erasededge) { + Edge newedge = getEdge(DestBB, DestBB); + replaceEdge(e, newedge); + } else { + removeEdge(e); + erasededge = true; + } } } } @@ -119,6 +351,7 @@ /// Splits an edge in the ProfileInfo and redirects flow over NewBB. /// Since its possible that there is more than one edge in the CFG from FristBB /// to SecondBB its necessary to redirect the flow proporionally. +template<> void ProfileInfo::splitEdge(const BasicBlock *FirstBB, const BasicBlock *SecondBB, const BasicBlock *NewBB, @@ -153,7 +386,7 @@ // We know now how many edges there are from FirstBB to SecondBB, reroute a // proportional part of the edge weight over NewBB. - double neww = w / succ_count; + double neww = floor(w / succ_count); ECs[n1] += neww; ECs[n2] += neww; BlockInformation[F][NewBB] += neww; @@ -164,14 +397,666 @@ } } -raw_ostream& llvm::operator<<(raw_ostream &O, ProfileInfo::Edge E) { +template<> +void ProfileInfo::splitBlock(const BasicBlock *Old, const BasicBlock* New) { + const Function *F = Old->getParent(); + std::map::iterator J = + EdgeInformation.find(F); + if (J == EdgeInformation.end()) return; + + DEBUG(errs() << "Splitting " << Old->getName() << " to " << New->getName() << "\n"); + + std::set Edges; + for (EdgeWeights::iterator ewi = J->second.begin(), ewe = J->second.end(); + ewi != ewe; ++ewi) { + Edge old = ewi->first; + if (old.first == Old) { + Edges.insert(old); + } + } + for (std::set::iterator EI = Edges.begin(), EE = Edges.end(); + EI != EE; ++EI) { + Edge newedge = getEdge(New, EI->second); + replaceEdge(*EI, newedge); + } + + double w = getExecutionCount(Old); + setEdgeWeight(getEdge(Old, New), w); + setExecutionCount(New, w); +} + +template<> +void ProfileInfo::splitBlock(const BasicBlock *BB, const BasicBlock* NewBB, + BasicBlock *const *Preds, unsigned NumPreds) { + const Function *F = BB->getParent(); + std::map::iterator J = + EdgeInformation.find(F); + if (J == EdgeInformation.end()) return; + + DEBUG(errs() << "Splitting " << NumPreds << " Edges from " << BB->getName() + << " to " << NewBB->getName() << "\n"); + + // Collect weight that was redirected over NewBB. + double newweight = 0; + + std::set ProcessedPreds; + // For all requestes Predecessors. + for (unsigned pred = 0; pred < NumPreds; ++pred) { + const BasicBlock * Pred = Preds[pred]; + if (ProcessedPreds.insert(Pred).second) { + // Create edges and read old weight. + Edge oldedge = getEdge(Pred, BB); + Edge newedge = getEdge(Pred, NewBB); + + // Remember how much weight was redirected. + newweight += getEdgeWeight(oldedge); + + replaceEdge(oldedge,newedge); + } + } + + Edge newedge = getEdge(NewBB,BB); + setEdgeWeight(newedge, newweight); + setExecutionCount(NewBB, newweight); +} + +template<> +void ProfileInfo::transfer(const Function *Old, const Function *New) { + DEBUG(errs() << "Replacing Function " << Old->getName() << " with " + << New->getName() << "\n"); + std::map::iterator J = + EdgeInformation.find(Old); + if(J != EdgeInformation.end()) { + EdgeInformation[New] = J->second; + } + EdgeInformation.erase(Old); + BlockInformation.erase(Old); + FunctionInformation.erase(Old); +} + +static double readEdgeOrRemember(ProfileInfo::Edge edge, double w, ProfileInfo::Edge &tocalc, + unsigned &uncalc) { + if (w == ProfileInfo::MissingValue) { + tocalc = edge; + uncalc++; + return 0; + } else { + return w; + } +} + +template<> +bool ProfileInfo::CalculateMissingEdge(const BasicBlock *BB, Edge &removed, bool assumeEmptySelf) { + Edge edgetocalc; + unsigned uncalculated = 0; + + // collect weights of all incoming and outgoing edges, rememer edges that + // have no value + double incount = 0; + SmallSet pred_visited; + pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); + if (bbi==bbe) { + Edge e = getEdge(0,BB); + incount += readEdgeOrRemember(e, getEdgeWeight(e) ,edgetocalc,uncalculated); + } + for (;bbi != bbe; ++bbi) { + if (pred_visited.insert(*bbi)) { + Edge e = getEdge(*bbi,BB); + incount += readEdgeOrRemember(e, getEdgeWeight(e) ,edgetocalc,uncalculated); + } + } + + double outcount = 0; + SmallSet succ_visited; + succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); + if (sbbi==sbbe) { + Edge e = getEdge(BB,0); + if (getEdgeWeight(e) == MissingValue) { + double w = getExecutionCount(BB); + if (w != MissingValue) { + setEdgeWeight(e,w); + removed = e; + } + } + outcount += readEdgeOrRemember(e, getEdgeWeight(e), edgetocalc, uncalculated); + } + for (;sbbi != sbbe; ++sbbi) { + if (succ_visited.insert(*sbbi)) { + Edge e = getEdge(BB,*sbbi); + outcount += readEdgeOrRemember(e, getEdgeWeight(e), edgetocalc, uncalculated); + } + } + + // if exactly one edge weight was missing, calculate it and remove it from + // spanning tree + if (uncalculated == 0 ) { + return true; + } else + if (uncalculated == 1) { + if (incount < outcount) { + EdgeInformation[BB->getParent()][edgetocalc] = outcount-incount; + } else { + EdgeInformation[BB->getParent()][edgetocalc] = incount-outcount; + } + DEBUG(errs() << "--Calc Edge Counter for " << edgetocalc << ": " + << format("%.20g", getEdgeWeight(edgetocalc)) << "\n"); + removed = edgetocalc; + return true; + } else + if (uncalculated == 2 && assumeEmptySelf && edgetocalc.first == edgetocalc.second && incount == outcount) { + setEdgeWeight(edgetocalc, incount * 10); + removed = edgetocalc; + return true; + } else { + return false; + } +} + +static void readEdge(ProfileInfo *PI, ProfileInfo::Edge e, double &calcw, std::set &misscount) { + double w = PI->getEdgeWeight(e); + if (w != ProfileInfo::MissingValue) { + calcw += w; + } else { + misscount.insert(e); + } +} + +template<> +bool ProfileInfo::EstimateMissingEdges(const BasicBlock *BB) { + bool hasNoSuccessors = false; + + double inWeight = 0; + std::set inMissing; + std::set ProcessedPreds; + pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); + if (bbi == bbe) { + readEdge(this,getEdge(0,BB),inWeight,inMissing); + } + for( ; bbi != bbe; ++bbi ) { + if (ProcessedPreds.insert(*bbi).second) { + readEdge(this,getEdge(*bbi,BB),inWeight,inMissing); + } + } + + double outWeight = 0; + std::set outMissing; + std::set ProcessedSuccs; + succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); + if (sbbi == sbbe) { + readEdge(this,getEdge(BB,0),outWeight,outMissing); + hasNoSuccessors = true; + } + for ( ; sbbi != sbbe; ++sbbi ) { + if (ProcessedSuccs.insert(*sbbi).second) { + readEdge(this,getEdge(BB,*sbbi),outWeight,outMissing); + } + } + + double share; + std::set::iterator ei,ee; + if (inMissing.size() == 0 && outMissing.size() > 0) { + ei = outMissing.begin(); + ee = outMissing.end(); + share = inWeight/outMissing.size(); + setExecutionCount(BB,inWeight); + } else + if (inMissing.size() > 0 && outMissing.size() == 0 && outWeight == 0) { + ei = inMissing.begin(); + ee = inMissing.end(); + share = 0; + setExecutionCount(BB,0); + } else + if (inMissing.size() == 0 && outMissing.size() == 0) { + setExecutionCount(BB,outWeight); + return true; + } else { + return false; + } + for ( ; ei != ee; ++ei ) { + setEdgeWeight(*ei,share); + } + return true; +} + +template<> +void ProfileInfo::repair(const Function *F) { +// if (getExecutionCount(&(F->getEntryBlock())) == 0) { +// for (Function::const_iterator FI = F->begin(), FE = F->end(); +// FI != FE; ++FI) { +// const BasicBlock* BB = &(*FI); +// { +// pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); +// if (NBB == End) { +// setEdgeWeight(getEdge(0,BB),0); +// } +// for(;NBB != End; ++NBB) { +// setEdgeWeight(getEdge(*NBB,BB),0); +// } +// } +// { +// succ_const_iterator NBB = succ_begin(BB), End = succ_end(BB); +// if (NBB == End) { +// setEdgeWeight(getEdge(0,BB),0); +// } +// for(;NBB != End; ++NBB) { +// setEdgeWeight(getEdge(*NBB,BB),0); +// } +// } +// } +// return; +// } + // The set of BasicBlocks that are still unvisited. + std::set Unvisited; + + // The set of return edges (Edges with no successors). + std::set ReturnEdges; + double ReturnWeight = 0; + + // First iterate over the whole function and collect: + // 1) The blocks in this function in the Unvisited set. + // 2) The return edges in the ReturnEdges set. + // 3) The flow that is leaving the function already via return edges. + + // Data structure for searching the function. + std::queue BFS; + const BasicBlock *BB = &(F->getEntryBlock()); + BFS.push(BB); + Unvisited.insert(BB); + + while (BFS.size()) { + BB = BFS.front(); BFS.pop(); + succ_const_iterator NBB = succ_begin(BB), End = succ_end(BB); + if (NBB == End) { + Edge e = getEdge(BB,0); + double w = getEdgeWeight(e); + if (w == MissingValue) { + // If the return edge has no value, try to read value from block. + double bw = getExecutionCount(BB); + if (bw != MissingValue) { + setEdgeWeight(e,bw); + ReturnWeight += bw; + } else { + // If both return edge and block provide no value, collect edge. + ReturnEdges.insert(e); + } + } else { + // If the return edge has a proper value, collect it. + ReturnWeight += w; + } + } + for (;NBB != End; ++NBB) { + if (Unvisited.insert(*NBB).second) { + BFS.push(*NBB); + } + } + } + + while (Unvisited.size() > 0) { + unsigned oldUnvisitedCount = Unvisited.size(); + bool FoundPath = false; + + // If there is only one edge left, calculate it. + if (ReturnEdges.size() == 1) { + ReturnWeight = getExecutionCount(&(F->getEntryBlock())) - ReturnWeight; + + Edge e = *ReturnEdges.begin(); + setEdgeWeight(e,ReturnWeight); + setExecutionCount(e.first,ReturnWeight); + + Unvisited.erase(e.first); + ReturnEdges.erase(e); + continue; + } + + // Calculate all blocks where only one edge is missing, this may also + // resolve furhter return edges. + std::set::iterator FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE) { + const BasicBlock *BB = *FI; ++FI; + Edge e; + if(CalculateMissingEdge(BB,e,true)) { + if (BlockInformation[F].find(BB) == BlockInformation[F].end()) { + setExecutionCount(BB,getExecutionCount(BB)); + } + Unvisited.erase(BB); + if (e.first != 0 && e.second == 0) { + ReturnEdges.erase(e); + ReturnWeight += getEdgeWeight(e); + } + } + } + if (oldUnvisitedCount > Unvisited.size()) continue; + + // Estimate edge weights by dividing the flow proportionally. + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE) { + const BasicBlock *BB = *FI; ++FI; + const BasicBlock *Dest = 0; + bool AllEdgesHaveSameReturn = true; + // Check each Successor, these must all end up in the same or an empty + // return block otherwise its dangerous to do an estimation on them. + for (succ_const_iterator Succ = succ_begin(BB), End = succ_end(BB); + Succ != End; ++Succ) { + Path P; + GetPath(*Succ, 0, P, GetPathToExit); + if (Dest && Dest != P[0]) { + AllEdgesHaveSameReturn = false; + } + Dest = P[0]; + } + if (AllEdgesHaveSameReturn) { + if(EstimateMissingEdges(BB)) { + Unvisited.erase(BB); + break; + } + } + } + if (oldUnvisitedCount > Unvisited.size()) continue; + + // Check if there is a path to an block that has a known value and redirect + // flow accordingly. + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE && !FoundPath) { + // Fetch path. + const BasicBlock *BB = *FI; ++FI; + Path P; + const BasicBlock *Dest = GetPath(BB, 0, P, GetPathToValue); + + // Calculate incoming flow. + double iw = 0; unsigned inmissing = 0; unsigned incount = 0; unsigned invalid = 0; + std::set Processed; + for (pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); + NBB != End; ++NBB) { + if (Processed.insert(*NBB).second) { + Edge e = getEdge(*NBB, BB); + double ew = getEdgeWeight(e); + if (ew != MissingValue) { + iw += ew; + invalid++; + } else { + // If the path contains the successor, this means its a backedge, + // do not count as missing. + if (P.find(*NBB) == P.end()) + inmissing++; + } + incount++; + } + } + if (inmissing == incount) continue; + if (invalid == 0) continue; + + // Subtract (already) outgoing flow. + Processed.clear(); + for (succ_const_iterator NBB = succ_begin(BB), End = succ_end(BB); + NBB != End; ++NBB) { + if (Processed.insert(*NBB).second) { + Edge e = getEdge(BB, *NBB); + double ew = getEdgeWeight(e); + if (ew != MissingValue) { + iw -= ew; + } + } + } + if (iw < 0) continue; + + // Check the recieving end of the path if it can handle the flow. + double ow = getExecutionCount(Dest); + Processed.clear(); + for (succ_const_iterator NBB = succ_begin(BB), End = succ_end(BB); + NBB != End; ++NBB) { + if (Processed.insert(*NBB).second) { + Edge e = getEdge(BB, *NBB); + double ew = getEdgeWeight(e); + if (ew != MissingValue) { + ow -= ew; + } + } + } + if (ow < 0) continue; + + // Determine how much flow shall be used. + double ew = getEdgeWeight(getEdge(P[Dest],Dest)); + if (ew != MissingValue) { + ew = ew Processed; + for (pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); + NBB != End; ++NBB) { + if (Processed.insert(*NBB).second) { + Edge e = getEdge(*NBB, BB); + double ew = getEdgeWeight(e); + if (ew != MissingValue) { + iw += ew; + } + } + } + setEdgeWeight(e,iw * 10); + FoundPath = true; + } + } + } + if (FoundPath) continue; + + // Determine backedges, set them to zero. + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE && !FoundPath) { + const BasicBlock *BB = *FI; ++FI; + const BasicBlock *Dest; + Path P; + bool BackEdgeFound = false; + for (pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); + NBB != End; ++NBB) { + Dest = GetPath(BB, *NBB, P, GetPathToDest | GetPathWithNewEdges); + if (Dest == *NBB) { + BackEdgeFound = true; + break; + } + } + if (BackEdgeFound) { + Edge e = getEdge(Dest,BB); + double w = getEdgeWeight(e); + if (w == MissingValue) { + setEdgeWeight(e,0); + FoundPath = true; + } + do { + Edge e = getEdge(P[Dest], Dest); + double w = getEdgeWeight(e); + if (w == MissingValue) { + setEdgeWeight(e,0); + FoundPath = true; + } + Dest = P[Dest]; + } while (Dest != BB); + } + } + if (FoundPath) continue; + + // Channel flow to return block. + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE && !FoundPath) { + const BasicBlock *BB = *FI; ++FI; + + Path P; + const BasicBlock *Dest = GetPath(BB, 0, P, GetPathToExit | GetPathWithNewEdges); + Dest = P[0]; + if (!Dest) continue; + + if (getEdgeWeight(getEdge(Dest,0)) == MissingValue) { + // Calculate incoming flow. + double iw = 0; + std::set Processed; + for (pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); + NBB != End; ++NBB) { + if (Processed.insert(*NBB).second) { + Edge e = getEdge(*NBB, BB); + double ew = getEdgeWeight(e); + if (ew != MissingValue) { + iw += ew; + } + } + } + do { + Edge e = getEdge(P[Dest], Dest); + double w = getEdgeWeight(e); + if (w == MissingValue) { + setEdgeWeight(e,iw); + FoundPath = true; + } else { + assert(0 && "Edge should not have value already!"); + } + Dest = P[Dest]; + } while (Dest != BB); + } + } + if (FoundPath) continue; + + // Speculatively set edges to zero. + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE && !FoundPath) { + const BasicBlock *BB = *FI; ++FI; + + for (pred_const_iterator NBB = pred_begin(BB), End = pred_end(BB); + NBB != End; ++NBB) { + Edge e = getEdge(*NBB,BB); + double w = getEdgeWeight(e); + if (w == MissingValue) { + setEdgeWeight(e,0); + FoundPath = true; + break; + } + } + } + if (FoundPath) continue; + + errs() << "{"; + FI = Unvisited.begin(), FE = Unvisited.end(); + while(FI != FE) { + const BasicBlock *BB = *FI; ++FI; + errs() << BB->getName(); + if (FI != FE) + errs() << ","; + } + errs() << "}"; + + errs() << "ASSERT: could not repair function"; + assert(0 && "could not repair function"); + } + + EdgeWeights J = EdgeInformation[F]; + for (EdgeWeights::iterator EI = J.begin(), EE = J.end(); EI != EE; ++EI) { + Edge e = EI->first; + + bool SuccFound = false; + if (e.first != 0) { + succ_const_iterator NBB = succ_begin(e.first), End = succ_end(e.first); + if (NBB == End) { + if (0 == e.second) { + SuccFound = true; + } + } + for (;NBB != End; ++NBB) { + if (*NBB == e.second) { + SuccFound = true; + break; + } + } + if (!SuccFound) { + removeEdge(e); + } + } + } +} + +raw_ostream& operator<<(raw_ostream &O, const Function *F) { + return O << F->getName(); +} + +raw_ostream& operator<<(raw_ostream &O, const MachineFunction *MF) { + return O << MF->getFunction()->getName() << "(MF)"; +} + +raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB) { + return O << BB->getName(); +} + +raw_ostream& operator<<(raw_ostream &O, const MachineBasicBlock *MBB) { + return O << MBB->getBasicBlock()->getName() << "(MB)"; +} + +raw_ostream& operator<<(raw_ostream &O, std::pair E) { + O << "("; + + if (E.first) + O << E.first; + else + O << "0"; + + O << ","; + + if (E.second) + O << E.second; + else + O << "0"; + + return O << ")"; +} + +raw_ostream& operator<<(raw_ostream &O, std::pair E) { O << "("; - O << (E.first ? E.first->getNameStr() : "0"); + + if (E.first) + O << E.first; + else + O << "0"; + O << ","; - O << (E.second ? E.second->getNameStr() : "0"); + + if (E.second) + O << E.second; + else + O << "0"; + return O << ")"; } +} // namespace llvm + //===----------------------------------------------------------------------===// // NoProfile ProfileInfo implementation // From astifter-llvm at gmx.at Thu Dec 3 05:00:38 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Thu, 03 Dec 2009 11:00:38 -0000 Subject: [llvm-commits] [llvm] r90446 - in /llvm/trunk: include/llvm/Analysis/Passes.h lib/Analysis/ProfileInfoLoaderPass.cpp Message-ID: <200912031100.nB3B0cvw009587@zion.cs.uiuc.edu> Author: astifter Date: Thu Dec 3 05:00:37 2009 New Revision: 90446 URL: http://llvm.org/viewvc/llvm-project?rev=90446&view=rev Log: Use ProfileInfo-API in ProfileInfo Loader and do more assertions. Modified: llvm/trunk/include/llvm/Analysis/Passes.h llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp Modified: llvm/trunk/include/llvm/Analysis/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/Passes.h?rev=90446&r1=90445&r2=90446&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/Passes.h (original) +++ llvm/trunk/include/llvm/Analysis/Passes.h Thu Dec 3 05:00:37 2009 @@ -92,6 +92,7 @@ // file. // ModulePass *createProfileLoaderPass(); + extern const PassInfo *ProfileLoaderPassID; //===--------------------------------------------------------------------===// // Modified: llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp?rev=90446&r1=90445&r2=90446&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileInfoLoaderPass.cpp Thu Dec 3 05:00:37 2009 @@ -74,6 +74,8 @@ static RegisterAnalysisGroup Y(X); +const PassInfo *llvm::ProfileLoaderPassID = &X; + ModulePass *llvm::createProfileLoaderPass() { return new LoaderPass(); } /// createProfileLoaderPass - This function returns a Pass that loads the @@ -112,46 +114,9 @@ recurseBasicBlock(*bbi); } - Edge edgetocalc; - unsigned uncalculated = 0; - - // collect weights of all incoming and outgoing edges, rememer edges that - // have no value - double incount = 0; - SmallSet pred_visited; - pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); - if (bbi==bbe) { - readEdgeOrRemember(getEdge(0, BB),edgetocalc,uncalculated,incount); - } - for (;bbi != bbe; ++bbi) { - if (pred_visited.insert(*bbi)) { - readEdgeOrRemember(getEdge(*bbi, BB),edgetocalc,uncalculated,incount); - } - } - - double outcount = 0; - SmallSet succ_visited; - succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); - if (sbbi==sbbe) { - readEdgeOrRemember(getEdge(BB, 0),edgetocalc,uncalculated,outcount); - } - for (;sbbi != sbbe; ++sbbi) { - if (succ_visited.insert(*sbbi)) { - readEdgeOrRemember(getEdge(BB, *sbbi),edgetocalc,uncalculated,outcount); - } - } - - // if exactly one edge weight was missing, calculate it and remove it from - // spanning tree - if (uncalculated == 1) { - if (incount < outcount) { - EdgeInformation[BB->getParent()][edgetocalc] = outcount-incount; - } else { - EdgeInformation[BB->getParent()][edgetocalc] = incount-outcount; - } - DEBUG(errs() << "--Calc Edge Counter for " << edgetocalc << ": " - << format("%g", getEdgeWeight(edgetocalc)) << "\n"); - SpanningTree.erase(edgetocalc); + Edge tocalc; + if (CalculateMissingEdge(BB, tocalc)) { + SpanningTree.erase(tocalc); } } @@ -219,9 +184,9 @@ } } while (SpanningTree.size() > 0) { -#if 0 + unsigned size = SpanningTree.size(); -#endif + BBisUnvisited.clear(); for (std::set::iterator ei = SpanningTree.begin(), ee = SpanningTree.end(); ei != ee; ++ei) { @@ -231,17 +196,16 @@ while (BBisUnvisited.size() > 0) { recurseBasicBlock(*BBisUnvisited.begin()); } -#if 0 + if (SpanningTree.size() == size) { DEBUG(errs()<<"{"); for (std::set::iterator ei = SpanningTree.begin(), ee = SpanningTree.end(); ei != ee; ++ei) { - DEBUG(errs()<<"("<<(ei->first?ei->first->getName():"0")<<"," - <<(ei->second?ei->second->getName():"0")<<"),"); + DEBUG(errs()<< *ei <<","); } assert(0 && "No edge calculated!"); } -#endif + } } if (ReadCount != Counters.size()) { From daniel at zuster.org Thu Dec 3 05:12:42 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 03 Dec 2009 11:12:42 -0000 Subject: [llvm-commits] [llvm] r90447 - in /llvm/trunk: include/llvm/ADT/DeltaAlgorithm.h lib/Support/CMakeLists.txt lib/Support/DeltaAlgorithm.cpp unittests/ADT/DeltaAlgorithmTest.cpp Message-ID: <200912031112.nB3BCglp009918@zion.cs.uiuc.edu> Author: ddunbar Date: Thu Dec 3 05:12:42 2009 New Revision: 90447 URL: http://llvm.org/viewvc/llvm-project?rev=90447&view=rev Log: Add an implementation of the delta debugging algorithm. - This is a pretty slow / memory intensive implementation, and I will likely change it to an iterative model, but it works. Added: llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h llvm/trunk/lib/Support/DeltaAlgorithm.cpp llvm/trunk/unittests/ADT/DeltaAlgorithmTest.cpp Modified: llvm/trunk/lib/Support/CMakeLists.txt Added: llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h?rev=90447&view=auto ============================================================================== --- llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h (added) +++ llvm/trunk/include/llvm/ADT/DeltaAlgorithm.h Thu Dec 3 05:12:42 2009 @@ -0,0 +1,89 @@ +//===--- DeltaAlgorithm.h - A Set Minimization Algorithm -------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_DELTAALGORITHM_H +#define LLVM_ADT_DELTAALGORITHM_H + +#include +#include + +namespace llvm { + +/// DeltaAlgorithm - Implements the delta debugging algorithm (A. Zeller '99) +/// for minimizing arbitrary sets using a predicate function. +/// +/// The result of the algorithm is a subset of the input change set which is +/// guaranteed to satisfy the predicate, assuming that the input set did. For +/// well formed predicates, the result set is guaranteed to be such that +/// removing any single element would falsify the predicate. +/// +/// For best results the predicate function *should* (but need not) satisfy +/// certain properties, in particular: +/// (1) The predicate should return false on an empty set and true on the full +/// set. +/// (2) If the predicate returns true for a set of changes, it should return +/// true for all supersets of that set. +/// +/// It is not an error to provide a predicate that does not satisfy these +/// requirements, and the algorithm will generally produce reasonable +/// results. However, it may run substantially more tests than with a good +/// predicate. +class DeltaAlgorithm { +public: + typedef unsigned change_ty; + // FIXME: Use a decent data structure. + typedef std::set changeset_ty; + typedef std::vector changesetlist_ty; + +private: + /// Cache of failed test results. Successful test results are never cached + /// since we always reduce following a success. + std::set FailedTestsCache; + + /// GetTestResult - Get the test result for the \arg Changes from the + /// cache, executing the test if necessary. + /// + /// \param Changes - The change set to test. + /// \return - The test result. + bool GetTestResult(const changeset_ty &Changes); + + /// Split - Partition a set of changes \arg Sinto one or two subsets. + void Split(const changeset_ty &S, changesetlist_ty &Res); + + /// Delta - Minimize a set of \arg Changes which has been partioned into + /// smaller sets, by attempting to remove individual subsets. + changeset_ty Delta(const changeset_ty &Changes, + const changesetlist_ty &Sets); + + /// Search - Search for a subset (or subsets) in \arg Sets which can be + /// removed from \arg Changes while still satisfying the predicate. + /// + /// \param Res - On success, a subset of Changes which satisfies the + /// predicate. + /// \return - True on success. + bool Search(const changeset_ty &Changes, const changesetlist_ty &Sets, + changeset_ty &Res); + +protected: + /// UpdatedSearchState - Callback used when the search state changes. + virtual void UpdatedSearchState(const changeset_ty &Changes, + const changesetlist_ty &Sets) {} + + /// ExecuteOneTest - Execute a single test predicate on the change set \arg S. + virtual bool ExecuteOneTest(const changeset_ty &S) = 0; + +public: + /// Run - Minimize the set \arg Changes by executing \see ExecuteOneTest() on + /// subsets of changes and returning the smallest set which still satisfies + /// the test predicate. + changeset_ty Run(const changeset_ty &Changes); +}; + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/Support/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=90447&r1=90446&r2=90447&view=diff ============================================================================== --- llvm/trunk/lib/Support/CMakeLists.txt (original) +++ llvm/trunk/lib/Support/CMakeLists.txt Thu Dec 3 05:12:42 2009 @@ -6,6 +6,7 @@ CommandLine.cpp ConstantRange.cpp Debug.cpp + DeltaAlgorithm.cpp Dwarf.cpp ErrorHandling.cpp FileUtilities.cpp Added: llvm/trunk/lib/Support/DeltaAlgorithm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DeltaAlgorithm.cpp?rev=90447&view=auto ============================================================================== --- llvm/trunk/lib/Support/DeltaAlgorithm.cpp (added) +++ llvm/trunk/lib/Support/DeltaAlgorithm.cpp Thu Dec 3 05:12:42 2009 @@ -0,0 +1,110 @@ +//===--- DeltaAlgorithm.h - A Set Minimization Algorithm -------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/DeltaAlgorithm.h" +#include +using namespace llvm; + +bool DeltaAlgorithm::GetTestResult(const changeset_ty &Changes) { + if (FailedTestsCache.count(Changes)) + return false; + + bool Result = ExecuteOneTest(Changes); + if (!Result) + FailedTestsCache.insert(Changes); + + return Result; +} + +void DeltaAlgorithm::Split(const changeset_ty &S, changesetlist_ty &Res) { + // FIXME: Allow clients to provide heuristics for improved splitting. + + // FIXME: This is really slow. + changeset_ty LHS, RHS; + unsigned idx = 0; + for (changeset_ty::const_iterator it = S.begin(), + ie = S.end(); it != ie; ++it, ++idx) + ((idx & 1) ? LHS : RHS).insert(*it); + if (!LHS.empty()) + Res.push_back(LHS); + if (!RHS.empty()) + Res.push_back(RHS); +} + +DeltaAlgorithm::changeset_ty +DeltaAlgorithm::Delta(const changeset_ty &Changes, + const changesetlist_ty &Sets) { + // Invariant: union(Res) == Changes + UpdatedSearchState(Changes, Sets); + + // If there is nothing left we can remove, we are done. + if (Sets.size() <= 1) + return Changes; + + // Look for a passing subset. + changeset_ty Res; + if (Search(Changes, Sets, Res)) + return Res; + + // Otherwise, partition the sets if possible; if not we are done. + changesetlist_ty SplitSets; + for (changesetlist_ty::const_iterator it = Sets.begin(), + ie = Sets.end(); it != ie; ++it) + Split(*it, SplitSets); + if (SplitSets.size() == Sets.size()) + return Changes; + + return Delta(Changes, SplitSets); +} + +bool DeltaAlgorithm::Search(const changeset_ty &Changes, + const changesetlist_ty &Sets, + changeset_ty &Res) { + // FIXME: Parallelize. + for (changesetlist_ty::const_iterator it = Sets.begin(), + ie = Sets.end(); it != ie; ++it) { + // If the test passes on this subset alone, recurse. + if (GetTestResult(*it)) { + changesetlist_ty Sets; + Split(*it, Sets); + Res = Delta(*it, Sets); + return true; + } + + // Otherwise, if we have more than two sets, see if test passes on the + // complement. + if (Sets.size() > 2) { + // FIXME: This is really slow. + changeset_ty Complement; + std::set_difference( + Changes.begin(), Changes.end(), it->begin(), it->end(), + std::insert_iterator(Complement, Complement.begin())); + if (GetTestResult(Complement)) { + changesetlist_ty ComplementSets; + ComplementSets.insert(ComplementSets.end(), Sets.begin(), it); + ComplementSets.insert(ComplementSets.end(), it + 1, Sets.end()); + Res = Delta(Complement, ComplementSets); + return true; + } + } + } + + return false; +} + +DeltaAlgorithm::changeset_ty DeltaAlgorithm::Run(const changeset_ty &Changes) { + // Check empty set first to quickly find poor test functions. + if (GetTestResult(changeset_ty())) + return changeset_ty(); + + // Otherwise run the real delta algorithm. + changesetlist_ty Sets; + Split(Changes, Sets); + + return Delta(Changes, Sets); +} Added: llvm/trunk/unittests/ADT/DeltaAlgorithmTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/DeltaAlgorithmTest.cpp?rev=90447&view=auto ============================================================================== --- llvm/trunk/unittests/ADT/DeltaAlgorithmTest.cpp (added) +++ llvm/trunk/unittests/ADT/DeltaAlgorithmTest.cpp Thu Dec 3 05:12:42 2009 @@ -0,0 +1,96 @@ +//===- llvm/unittest/ADT/DeltaAlgorithmTest.cpp ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" +#include "llvm/ADT/DeltaAlgorithm.h" +#include +#include +using namespace llvm; + +std::ostream &operator<<(std::ostream &OS, + const std::set &S) { + OS << "{"; + for (std::set::const_iterator it = S.begin(), + ie = S.end(); it != ie; ++it) { + if (it != S.begin()) + OS << ","; + OS << *it; + } + OS << "}"; + return OS; +} + +namespace { + +class FixedDeltaAlgorithm : public DeltaAlgorithm { + changeset_ty FailingSet; + unsigned NumTests; + +protected: + virtual bool ExecuteOneTest(const changeset_ty &Changes) { + ++NumTests; + return std::includes(Changes.begin(), Changes.end(), + FailingSet.begin(), FailingSet.end()); + } + +public: + FixedDeltaAlgorithm(const changeset_ty &_FailingSet) + : FailingSet(_FailingSet), + NumTests(0) {} + + unsigned getNumTests() const { return NumTests; } +}; + +std::set fixed_set(unsigned N, ...) { + std::set S; + va_list ap; + va_start(ap, N); + for (unsigned i = 0; i != N; ++i) + S.insert(va_arg(ap, unsigned)); + va_end(ap); + return S; +} + +std::set range(unsigned Start, unsigned End) { + std::set S; + while (Start != End) + S.insert(Start++); + return S; +} + +std::set range(unsigned N) { + return range(0, N); +} + +TEST(DeltaAlgorithmTest, Basic) { + // P = {3,5,7} \in S + // [0, 20) should minimize to {3,5,7} in a reasonable number of tests. + std::set Fails = fixed_set(3, 3, 5, 7); + FixedDeltaAlgorithm FDA(Fails); + EXPECT_EQ(fixed_set(3, 3, 5, 7), FDA.Run(range(20))); + EXPECT_GE(33U, FDA.getNumTests()); + + // P = {3,5,7} \in S + // [10, 20) should minimize to [10,20) + EXPECT_EQ(range(10,20), FDA.Run(range(10,20))); + + // P = [0,4) \in S + // [0, 4) should minimize to [0,4) in 11 tests. + // + // 11 = |{ {}, + // {0}, {1}, {2}, {3}, + // {1, 2, 3}, {0, 2, 3}, {0, 1, 3}, {0, 1, 2}, + // {0, 1}, {2, 3} }| + FDA = FixedDeltaAlgorithm(range(10)); + EXPECT_EQ(range(4), FDA.Run(range(4))); + EXPECT_EQ(11U, FDA.getNumTests()); +} + +} + From baldrick at free.fr Thu Dec 3 06:37:09 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Dec 2009 13:37:09 +0100 Subject: [llvm-commits] [llvm] r90447 - in /llvm/trunk: include/llvm/ADT/DeltaAlgorithm.h lib/Support/CMakeLists.txt lib/Support/DeltaAlgorithm.cpp unittests/ADT/DeltaAlgorithmTest.cpp In-Reply-To: <200912031112.nB3BCglp009918@zion.cs.uiuc.edu> References: <200912031112.nB3BCglp009918@zion.cs.uiuc.edu> Message-ID: <4B17B0F5.6000705@free.fr> Hi Daniel, > ============================================================================== > --- llvm/trunk/lib/Support/DeltaAlgorithm.cpp (added) > +++ llvm/trunk/lib/Support/DeltaAlgorithm.cpp Thu Dec 3 05:12:42 2009 > @@ -0,0 +1,110 @@ > +//===--- DeltaAlgorithm.h - A Set Minimization Algorithm -------*- C++ -*--===// shouldn't this be DeltaAlgorithm.cpp? Ciao, Duncan. From astifter-llvm at gmx.at Thu Dec 3 06:41:14 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Thu, 03 Dec 2009 12:41:14 -0000 Subject: [llvm-commits] [llvm] r90449 - /llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Message-ID: <200912031241.nB3CfEsD012550@zion.cs.uiuc.edu> Author: astifter Date: Thu Dec 3 06:41:14 2009 New Revision: 90449 URL: http://llvm.org/viewvc/llvm-project?rev=90449&view=rev Log: Do not create negative edge weights in ProfileEstimator. Use integer values for weights to prevent rounding errors. Make ProfileEstimator more robust in general CFGs. Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=90449&r1=90448&r2=90449&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Thu Dec 3 06:41:14 2009 @@ -35,6 +35,7 @@ LoopInfo *LI; std::set BBToVisit; std::map LoopExitWeights; + std::map MinimalWeight; public: static char ID; // Class identification, replacement for typeinfo explicit ProfileEstimatorPass(const double execcount = 0) @@ -91,7 +92,7 @@ void inline ProfileEstimatorPass::printEdgeWeight(Edge E) { DEBUG(errs() << "-- Weight of Edge " << E << ":" - << format("%g", getEdgeWeight(E)) << "\n"); + << format("%20.20g", getEdgeWeight(E)) << "\n"); } // recurseBasicBlock() - This calculates the ProfileInfo estimation for a @@ -174,6 +175,12 @@ double w = getEdgeWeight(*ei); if (w == MissingValue) { Edges.push_back(*ei); + // Check if there is a necessary minimal weight, if yes, subtract it + // from weight. + if (MinimalWeight.find(*ei) != MinimalWeight.end()) { + incoming -= MinimalWeight[*ei]; + DEBUG(errs() << "Reserving " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n"); + } } else { incoming -= w; } @@ -191,11 +198,43 @@ printEdgeWeight(edge); } } - // Distribute remaining weight onto the exit edges. + + // Distribute remaining weight to the exting edges. To prevent fractions + // from building up and provoking precision problems the weight which is to + // be distributed is split and the rounded, the last edge gets a somewhat + // bigger value, but we are close enough for an estimation. + double fraction = floor(incoming/Edges.size()); for (SmallVector::iterator ei = Edges.begin(), ee = Edges.end(); ei != ee; ++ei) { - EdgeInformation[BB->getParent()][*ei] += incoming/Edges.size(); + double w = 0; + if (ei != (ee-1)) { + w = fraction; + incoming -= fraction; + } else { + w = incoming; + } + EdgeInformation[BB->getParent()][*ei] += w; + // Read necessary minimal weight. + if (MinimalWeight.find(*ei) != MinimalWeight.end()) { + EdgeInformation[BB->getParent()][*ei] += MinimalWeight[*ei]; + DEBUG(errs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n"); + } printEdgeWeight(*ei); + + // Add minimal weight to paths to all exit edges, this is used to ensure + // that enough flow is reaching this edges. + Path p; + const BasicBlock *Dest = GetPath(BB, (*ei).first, p, GetPathToDest); + while (Dest != BB) { + const BasicBlock *Parent = p.find(Dest)->second; + Edge e = getEdge(Parent, Dest); + if (MinimalWeight.find(e) == MinimalWeight.end()) { + MinimalWeight[e] = 0; + } + MinimalWeight[e] += w; + DEBUG(errs() << "Minimal Weight for " << e << ": " << format("%.20g",MinimalWeight[e]) << "\n"); + Dest = Parent; + } } // Increase flow into the loop. BBWeight *= (ExecCount+1); @@ -203,7 +242,7 @@ BlockInformation[BB->getParent()][BB] = BBWeight; // Up until now we considered only the loop exiting edges, now we have a - // definite block weight and must ditribute this onto the outgoing edges. + // definite block weight and must distribute this onto the outgoing edges. // Since there may be already flow attached to some of the edges, read this // flow first and remember the edges that have still now flow attached. Edges.clear(); @@ -225,15 +264,32 @@ BBWeight -= getEdgeWeight(edge); } else { Edges.push_back(edge); + // If minimal weight is necessary, reserve weight by subtracting weight + // from block weight, this is readded later on. + if (MinimalWeight.find(edge) != MinimalWeight.end()) { + BBWeight -= MinimalWeight[edge]; + DEBUG(errs() << "Reserving " << format("%.20g",MinimalWeight[edge]) << " at " << edge << "\n"); + } } } } + double fraction = floor(BBWeight/Edges.size()); // Finally we know what flow is still not leaving the block, distribute this // flow onto the empty edges. for (SmallVector::iterator ei = Edges.begin(), ee = Edges.end(); ei != ee; ++ei) { - EdgeInformation[BB->getParent()][*ei] += BBWeight/Edges.size(); + if (ei != (ee-1)) { + EdgeInformation[BB->getParent()][*ei] += fraction; + BBWeight -= fraction; + } else { + EdgeInformation[BB->getParent()][*ei] += BBWeight; + } + // Readd minial necessary weight. + if (MinimalWeight.find(*ei) != MinimalWeight.end()) { + EdgeInformation[BB->getParent()][*ei] += MinimalWeight[*ei]; + DEBUG(errs() << "Additionally " << format("%.20g",MinimalWeight[*ei]) << " at " << (*ei) << "\n"); + } printEdgeWeight(*ei); } @@ -260,20 +316,24 @@ for (Function::iterator bi = F.begin(), be = F.end(); bi != be; ++bi) BBToVisit.insert(bi); + // Clear Minimal Edges. + MinimalWeight.clear(); + DEBUG(errs() << "Working on function " << F.getNameStr() << "\n"); // Since the entry block is the first one and has no predecessors, the edge // (0,entry) is inserted with the starting weight of 1. BasicBlock *entry = &F.getEntryBlock(); - BlockInformation[&F][entry] = 1; + BlockInformation[&F][entry] = pow(2,32); Edge edge = getEdge(0,entry); - EdgeInformation[&F][edge] = 1; + EdgeInformation[&F][edge] = BlockInformation[&F][entry]; printEdgeWeight(edge); // Since recurseBasicBlock() maybe returns with a block which was not fully - // estimated, use recurseBasicBlock() until everything is calculated. + // estimated, use recurseBasicBlock() until everything is calculated. + bool cleanup = false; recurseBasicBlock(entry); - while (BBToVisit.size() > 0) { + while (BBToVisit.size() > 0 && !cleanup) { // Remember number of open blocks, this is later used to check if progress // was made. unsigned size = BBToVisit.size(); @@ -287,21 +347,65 @@ if (BBToVisit.size() < size) break; } - // If there was not a single block resovled, make some assumptions. + // If there was not a single block resolved, make some assumptions. if (BBToVisit.size() == size) { - BasicBlock *BB = *(BBToVisit.begin()); - // Since this BB was not calculated because of missing incoming edges, - // set these edges to zero. - for (pred_iterator bbi = pred_begin(BB), bbe = pred_end(BB); - bbi != bbe; ++bbi) { - Edge e = getEdge(*bbi,BB); - double w = getEdgeWeight(e); - if (w == MissingValue) { - EdgeInformation[&F][e] = 0; - DEBUG(errs() << "Assuming edge weight: "); - printEdgeWeight(e); + bool found = false; + for (std::set::iterator BBI = BBToVisit.begin(), BBE = BBToVisit.end(); + (BBI != BBE) && (!found); ++BBI) { + BasicBlock *BB = *BBI; + // Try each predecessor if it can be assumend. + for (pred_iterator bbi = pred_begin(BB), bbe = pred_end(BB); + (bbi != bbe) && (!found); ++bbi) { + Edge e = getEdge(*bbi,BB); + double w = getEdgeWeight(e); + // Check that edge from predecessor is still free. + if (w == MissingValue) { + // Check if there is a circle from this block to predecessor. + Path P; + const BasicBlock *Dest = GetPath(BB, *bbi, P, GetPathToDest); + if (Dest != *bbi) { + // If there is no circle, just set edge weight to 0 + EdgeInformation[&F][e] = 0; + DEBUG(errs() << "Assuming edge weight: "); + printEdgeWeight(e); + found = true; + } + } } } + if (!found) { + cleanup = true; + DEBUG(errs() << "No assumption possible in Fuction "< Author: astifter Date: Thu Dec 3 06:55:57 2009 New Revision: 90451 URL: http://llvm.org/viewvc/llvm-project?rev=90451&view=rev Log: Convert ProfileVerifier to template so it can be used for different types of ProfileInfo. Modified: llvm/trunk/lib/Analysis/ProfileVerifierPass.cpp Modified: llvm/trunk/lib/Analysis/ProfileVerifierPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileVerifierPass.cpp?rev=90451&r1=90450&r2=90451&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileVerifierPass.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileVerifierPass.cpp Thu Dec 3 06:55:57 2009 @@ -21,6 +21,7 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Format.h" #include "llvm/Support/Debug.h" #include using namespace llvm; @@ -29,44 +30,45 @@ ProfileVerifierDisableAssertions("profile-verifier-noassert", cl::desc("Disable assertions")); -namespace { - class ProfileVerifierPass : public FunctionPass { +namespace llvm { + template + class ProfileVerifierPassT : public FunctionPass { struct DetailedBlockInfo { - const BasicBlock *BB; - double BBWeight; - double inWeight; - int inCount; - double outWeight; - int outCount; + const BType *BB; + double BBWeight; + double inWeight; + int inCount; + double outWeight; + int outCount; }; - ProfileInfo *PI; - std::set BBisVisited; - std::set FisVisited; + ProfileInfoT *PI; + std::set BBisVisited; + std::set FisVisited; bool DisableAssertions; // When debugging is enabled, the verifier prints a whole slew of debug // information, otherwise its just the assert. These are all the helper // functions. bool PrintedDebugTree; - std::set BBisPrinted; + std::set BBisPrinted; void debugEntry(DetailedBlockInfo*); - void printDebugInfo(const BasicBlock *BB); + void printDebugInfo(const BType *BB); public: static char ID; // Class identification, replacement for typeinfo - explicit ProfileVerifierPass () : FunctionPass(&ID) { + explicit ProfileVerifierPassT () : FunctionPass(&ID) { DisableAssertions = ProfileVerifierDisableAssertions; } - explicit ProfileVerifierPass (bool da) : FunctionPass(&ID), - DisableAssertions(da) { + explicit ProfileVerifierPassT (bool da) : FunctionPass(&ID), + DisableAssertions(da) { } void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); - AU.addRequired(); + AU.addRequired >(); } const char *getPassName() const { @@ -74,271 +76,302 @@ } /// run - Verify the profile information. - bool runOnFunction(Function &F); - void recurseBasicBlock(const BasicBlock*); + bool runOnFunction(FType &F); + void recurseBasicBlock(const BType*); - bool exitReachable(const Function*); - double ReadOrAssert(ProfileInfo::Edge); + bool exitReachable(const FType*); + double ReadOrAssert(typename ProfileInfoT::Edge); void CheckValue(bool, const char*, DetailedBlockInfo*); }; -} // End of anonymous namespace -char ProfileVerifierPass::ID = 0; -static RegisterPass -X("profile-verifier", "Verify profiling information", false, true); + typedef ProfileVerifierPassT ProfileVerifierPass; -namespace llvm { - FunctionPass *createProfileVerifierPass() { - return new ProfileVerifierPass(ProfileVerifierDisableAssertions); - } -} + template + void ProfileVerifierPassT::printDebugInfo(const BType *BB) { -void ProfileVerifierPass::printDebugInfo(const BasicBlock *BB) { + if (BBisPrinted.find(BB) != BBisPrinted.end()) return; - if (BBisPrinted.find(BB) != BBisPrinted.end()) return; - - double BBWeight = PI->getExecutionCount(BB); - if (BBWeight == ProfileInfo::MissingValue) { BBWeight = 0; } - double inWeight = 0; - int inCount = 0; - std::set ProcessedPreds; - for ( pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); - bbi != bbe; ++bbi ) { - if (ProcessedPreds.insert(*bbi).second) { - ProfileInfo::Edge E = PI->getEdge(*bbi,BB); - double EdgeWeight = PI->getEdgeWeight(E); - if (EdgeWeight == ProfileInfo::MissingValue) { EdgeWeight = 0; } - errs() << "calculated in-edge " << E << ": " << EdgeWeight << "\n"; - inWeight += EdgeWeight; - inCount++; + double BBWeight = PI->getExecutionCount(BB); + if (BBWeight == ProfileInfoT::MissingValue) { BBWeight = 0; } + double inWeight = 0; + int inCount = 0; + std::set ProcessedPreds; + for ( pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); + bbi != bbe; ++bbi ) { + if (ProcessedPreds.insert(*bbi).second) { + typename ProfileInfoT::Edge E = PI->getEdge(*bbi,BB); + double EdgeWeight = PI->getEdgeWeight(E); + if (EdgeWeight == ProfileInfoT::MissingValue) { EdgeWeight = 0; } + errs() << "calculated in-edge " << E << ": " + << format("%20.20g",EdgeWeight) << "\n"; + inWeight += EdgeWeight; + inCount++; + } } - } - double outWeight = 0; - int outCount = 0; - std::set ProcessedSuccs; - for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); - bbi != bbe; ++bbi ) { - if (ProcessedSuccs.insert(*bbi).second) { - ProfileInfo::Edge E = PI->getEdge(BB,*bbi); - double EdgeWeight = PI->getEdgeWeight(E); - if (EdgeWeight == ProfileInfo::MissingValue) { EdgeWeight = 0; } - errs() << "calculated out-edge " << E << ": " << EdgeWeight << "\n"; - outWeight += EdgeWeight; - outCount++; + double outWeight = 0; + int outCount = 0; + std::set ProcessedSuccs; + for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); + bbi != bbe; ++bbi ) { + if (ProcessedSuccs.insert(*bbi).second) { + typename ProfileInfoT::Edge E = PI->getEdge(BB,*bbi); + double EdgeWeight = PI->getEdgeWeight(E); + if (EdgeWeight == ProfileInfoT::MissingValue) { EdgeWeight = 0; } + errs() << "calculated out-edge " << E << ": " + << format("%20.20g",EdgeWeight) << "\n"; + outWeight += EdgeWeight; + outCount++; + } + } + errs() << "Block " << BB->getNameStr() << " in " + << BB->getParent()->getNameStr() << ":" + << "BBWeight=" << format("%20.20g",BBWeight) << "," + << "inWeight=" << format("%20.20g",inWeight) << "," + << "inCount=" << inCount << "," + << "outWeight=" << format("%20.20g",outWeight) << "," + << "outCount" << outCount << "\n"; + + // mark as visited and recurse into subnodes + BBisPrinted.insert(BB); + for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); + bbi != bbe; ++bbi ) { + printDebugInfo(*bbi); } } - errs()<<"Block "<getNameStr()<<" in "<getParent()->getNameStr() - <<",BBWeight="<BB->getNameStr() << " in " - << DI->BB->getParent()->getNameStr() << ":"; - errs() << "BBWeight=" << DI->BBWeight << ","; - errs() << "inWeight=" << DI->inWeight << ","; - errs() << "inCount=" << DI->inCount << ","; - errs() << "outWeight=" << DI->outWeight << ","; - errs() << "outCount=" << DI->outCount << "\n"; - if (!PrintedDebugTree) { - PrintedDebugTree = true; - printDebugInfo(&(DI->BB->getParent()->getEntryBlock())); - } -} -// This compares A and B but considering maybe small differences. -static bool Equals(double A, double B) { - double maxRelativeError = 0.0000001; - if (A == B) - return true; - double relativeError; - if (fabs(B) > fabs(A)) - relativeError = fabs((A - B) / B); - else - relativeError = fabs((A - B) / A); - if (relativeError <= maxRelativeError) return true; - return false; -} - -// This checks if the function "exit" is reachable from an given function -// via calls, this is necessary to check if a profile is valid despite the -// counts not fitting exactly. -bool ProfileVerifierPass::exitReachable(const Function *F) { - if (!F) return false; - - if (FisVisited.count(F)) return false; - - Function *Exit = F->getParent()->getFunction("exit"); - if (Exit == F) { - return true; + template + void ProfileVerifierPassT::debugEntry (DetailedBlockInfo *DI) { + errs() << "TROUBLE: Block " << DI->BB->getNameStr() << " in " + << DI->BB->getParent()->getNameStr() << ":" + << "BBWeight=" << format("%20.20g",DI->BBWeight) << "," + << "inWeight=" << format("%20.20g",DI->inWeight) << "," + << "inCount=" << DI->inCount << "," + << "outWeight=" << format("%20.20g",DI->outWeight) << "," + << "outCount=" << DI->outCount << "\n"; + if (!PrintedDebugTree) { + PrintedDebugTree = true; + printDebugInfo(&(DI->BB->getParent()->getEntryBlock())); + } } - FisVisited.insert(F); - bool exits = false; - for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { - if (const CallInst *CI = dyn_cast(&*I)) { - exits |= exitReachable(CI->getCalledFunction()); - if (exits) break; + // This compares A and B for equality. + static bool Equals(double A, double B) { + return A == B; + } + + // This checks if the function "exit" is reachable from an given function + // via calls, this is necessary to check if a profile is valid despite the + // counts not fitting exactly. + template + bool ProfileVerifierPassT::exitReachable(const FType *F) { + if (!F) return false; + + if (FisVisited.count(F)) return false; + + FType *Exit = F->getParent()->getFunction("exit"); + if (Exit == F) { + return true; + } + + FisVisited.insert(F); + bool exits = false; + for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { + if (const CallInst *CI = dyn_cast(&*I)) { + FType *F = CI->getCalledFunction(); + if (F) { + exits |= exitReachable(F); + } else { + // This is a call to a pointer, all bets are off... + exits = true; + } + if (exits) break; + } } + return exits; } - return exits; -} -#define ASSERTMESSAGE(M) \ - errs() << (M) << "\n"; \ - if (!DisableAssertions) assert(0 && (M)); - -double ProfileVerifierPass::ReadOrAssert(ProfileInfo::Edge E) { - double EdgeWeight = PI->getEdgeWeight(E); - if (EdgeWeight == ProfileInfo::MissingValue) { - errs() << "Edge " << E << " in Function " - << ProfileInfo::getFunction(E)->getNameStr() << ": "; - ASSERTMESSAGE("ASSERT:Edge has missing value"); - return 0; - } else { - return EdgeWeight; + #define ASSERTMESSAGE(M) \ + { errs() << "ASSERT:" << (M) << "\n"; \ + if (!DisableAssertions) assert(0 && (M)); } + + template + double ProfileVerifierPassT::ReadOrAssert(typename ProfileInfoT::Edge E) { + double EdgeWeight = PI->getEdgeWeight(E); + if (EdgeWeight == ProfileInfoT::MissingValue) { + errs() << "Edge " << E << " in Function " + << ProfileInfoT::getFunction(E)->getNameStr() << ": "; + ASSERTMESSAGE("Edge has missing value"); + return 0; + } else { + if (EdgeWeight < 0) { + errs() << "Edge " << E << " in Function " + << ProfileInfoT::getFunction(E)->getNameStr() << ": "; + ASSERTMESSAGE("Edge has negative value"); + } + return EdgeWeight; + } } -} -void ProfileVerifierPass::CheckValue(bool Error, const char *Message, - DetailedBlockInfo *DI) { - if (Error) { - DEBUG(debugEntry(DI)); - errs() << "Block " << DI->BB->getNameStr() << " in Function " - << DI->BB->getParent()->getNameStr() << ": "; - ASSERTMESSAGE(Message); - } - return; -} - -// This calculates the Information for a block and then recurses into the -// successors. -void ProfileVerifierPass::recurseBasicBlock(const BasicBlock *BB) { - - // Break the recursion by remembering all visited blocks. - if (BBisVisited.find(BB) != BBisVisited.end()) return; - - // Use a data structure to store all the information, this can then be handed - // to debug printers. - DetailedBlockInfo DI; - DI.BB = BB; - DI.outCount = DI.inCount = 0; - DI.inWeight = DI.outWeight = 0.0; - - // Read predecessors. - std::set ProcessedPreds; - pred_const_iterator bpi = pred_begin(BB), bpe = pred_end(BB); - // If there are none, check for (0,BB) edge. - if (bpi == bpe) { - DI.inWeight += ReadOrAssert(PI->getEdge(0,BB)); - DI.inCount++; - } - for (;bpi != bpe; ++bpi) { - if (ProcessedPreds.insert(*bpi).second) { - DI.inWeight += ReadOrAssert(PI->getEdge(*bpi,BB)); + template + void ProfileVerifierPassT::CheckValue(bool Error, + const char *Message, + DetailedBlockInfo *DI) { + if (Error) { + DEBUG(debugEntry(DI)); + errs() << "Block " << DI->BB->getNameStr() << " in Function " + << DI->BB->getParent()->getNameStr() << ": "; + ASSERTMESSAGE(Message); + } + return; + } + + // This calculates the Information for a block and then recurses into the + // successors. + template + void ProfileVerifierPassT::recurseBasicBlock(const BType *BB) { + + // Break the recursion by remembering all visited blocks. + if (BBisVisited.find(BB) != BBisVisited.end()) return; + + // Use a data structure to store all the information, this can then be handed + // to debug printers. + DetailedBlockInfo DI; + DI.BB = BB; + DI.outCount = DI.inCount = 0; + DI.inWeight = DI.outWeight = 0; + + // Read predecessors. + std::set ProcessedPreds; + pred_const_iterator bpi = pred_begin(BB), bpe = pred_end(BB); + // If there are none, check for (0,BB) edge. + if (bpi == bpe) { + DI.inWeight += ReadOrAssert(PI->getEdge(0,BB)); DI.inCount++; } - } + for (;bpi != bpe; ++bpi) { + if (ProcessedPreds.insert(*bpi).second) { + DI.inWeight += ReadOrAssert(PI->getEdge(*bpi,BB)); + DI.inCount++; + } + } - // Read successors. - std::set ProcessedSuccs; - succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); - // If there is an (0,BB) edge, consider it too. (This is done not only when - // there are no successors, but every time; not every function contains - // return blocks with no successors (think loop latch as return block)). - double w = PI->getEdgeWeight(PI->getEdge(BB,0)); - if (w != ProfileInfo::MissingValue) { - DI.outWeight += w; - DI.outCount++; - } - for (;bbi != bbe; ++bbi) { - if (ProcessedSuccs.insert(*bbi).second) { - DI.outWeight += ReadOrAssert(PI->getEdge(BB,*bbi)); + // Read successors. + std::set ProcessedSuccs; + succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); + // If there is an (0,BB) edge, consider it too. (This is done not only when + // there are no successors, but every time; not every function contains + // return blocks with no successors (think loop latch as return block)). + double w = PI->getEdgeWeight(PI->getEdge(BB,0)); + if (w != ProfileInfoT::MissingValue) { + DI.outWeight += w; DI.outCount++; } - } + for (;bbi != bbe; ++bbi) { + if (ProcessedSuccs.insert(*bbi).second) { + DI.outWeight += ReadOrAssert(PI->getEdge(BB,*bbi)); + DI.outCount++; + } + } - // Read block weight. - DI.BBWeight = PI->getExecutionCount(BB); - CheckValue(DI.BBWeight == ProfileInfo::MissingValue, - "ASSERT:BasicBlock has missing value", &DI); - - // Check if this block is a setjmp target. - bool isSetJmpTarget = false; - if (DI.outWeight > DI.inWeight) { - for (BasicBlock::const_iterator i = BB->begin(), ie = BB->end(); - i != ie; ++i) { - if (const CallInst *CI = dyn_cast(&*i)) { - Function *F = CI->getCalledFunction(); - if (F && (F->getNameStr() == "_setjmp")) { - isSetJmpTarget = true; break; + // Read block weight. + DI.BBWeight = PI->getExecutionCount(BB); + CheckValue(DI.BBWeight == ProfileInfoT::MissingValue, + "BasicBlock has missing value", &DI); + CheckValue(DI.BBWeight < 0, + "BasicBlock has negative value", &DI); + + // Check if this block is a setjmp target. + bool isSetJmpTarget = false; + if (DI.outWeight > DI.inWeight) { + for (typename BType::const_iterator i = BB->begin(), ie = BB->end(); + i != ie; ++i) { + if (const CallInst *CI = dyn_cast(&*i)) { + FType *F = CI->getCalledFunction(); + if (F && (F->getNameStr() == "_setjmp")) { + isSetJmpTarget = true; break; + } } } } - } - // Check if this block is eventually reaching exit. - bool isExitReachable = false; - if (DI.inWeight > DI.outWeight) { - for (BasicBlock::const_iterator i = BB->begin(), ie = BB->end(); - i != ie; ++i) { - if (const CallInst *CI = dyn_cast(&*i)) { - FisVisited.clear(); - isExitReachable |= exitReachable(CI->getCalledFunction()); - if (isExitReachable) break; + // Check if this block is eventually reaching exit. + bool isExitReachable = false; + if (DI.inWeight > DI.outWeight) { + for (typename BType::const_iterator i = BB->begin(), ie = BB->end(); + i != ie; ++i) { + if (const CallInst *CI = dyn_cast(&*i)) { + FType *F = CI->getCalledFunction(); + if (F) { + FisVisited.clear(); + isExitReachable |= exitReachable(F); + } else { + // This is a call to a pointer, all bets are off... + isExitReachable = true; + } + if (isExitReachable) break; + } } } - } - if (DI.inCount > 0 && DI.outCount == 0) { - // If this is a block with no successors. - if (!isSetJmpTarget) { - CheckValue(!Equals(DI.inWeight,DI.BBWeight), - "ASSERT:inWeight and BBWeight do not match", &DI); - } - } else if (DI.inCount == 0 && DI.outCount > 0) { - // If this is a block with no predecessors. - if (!isExitReachable) - CheckValue(!Equals(DI.BBWeight,DI.outWeight), - "ASSERT:BBWeight and outWeight do not match", &DI); - } else { - // If this block has successors and predecessors. - if (DI.inWeight > DI.outWeight && !isExitReachable) - CheckValue(!Equals(DI.inWeight,DI.outWeight), - "ASSERT:inWeight and outWeight do not match", &DI); - if (DI.inWeight < DI.outWeight && !isSetJmpTarget) - CheckValue(!Equals(DI.inWeight,DI.outWeight), - "ASSERT:inWeight and outWeight do not match", &DI); + if (DI.inCount > 0 && DI.outCount == 0) { + // If this is a block with no successors. + if (!isSetJmpTarget) { + CheckValue(!Equals(DI.inWeight,DI.BBWeight), + "inWeight and BBWeight do not match", &DI); + } + } else if (DI.inCount == 0 && DI.outCount > 0) { + // If this is a block with no predecessors. + if (!isExitReachable) + CheckValue(!Equals(DI.BBWeight,DI.outWeight), + "BBWeight and outWeight do not match", &DI); + } else { + // If this block has successors and predecessors. + if (DI.inWeight > DI.outWeight && !isExitReachable) + CheckValue(!Equals(DI.inWeight,DI.outWeight), + "inWeight and outWeight do not match", &DI); + if (DI.inWeight < DI.outWeight && !isSetJmpTarget) + CheckValue(!Equals(DI.inWeight,DI.outWeight), + "inWeight and outWeight do not match", &DI); + } + + + // Mark this block as visited, rescurse into successors. + BBisVisited.insert(BB); + for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); + bbi != bbe; ++bbi ) { + recurseBasicBlock(*bbi); + } } + template + bool ProfileVerifierPassT::runOnFunction(FType &F) { + PI = getAnalysisIfAvailable >(); + if (!PI) + ASSERTMESSAGE("No ProfileInfo available"); + + // Prepare global variables. + PrintedDebugTree = false; + BBisVisited.clear(); - // Mark this block as visited, rescurse into successors. - BBisVisited.insert(BB); - for ( succ_const_iterator bbi = succ_begin(BB), bbe = succ_end(BB); - bbi != bbe; ++bbi ) { - recurseBasicBlock(*bbi); + // Fetch entry block and recurse into it. + const BType *entry = &F.getEntryBlock(); + recurseBasicBlock(entry); + + if (PI->getExecutionCount(&F) != PI->getExecutionCount(entry)) + ASSERTMESSAGE("Function count and entry block count do not match"); + + return false; } + + template + char ProfileVerifierPassT::ID = 0; } -bool ProfileVerifierPass::runOnFunction(Function &F) { - PI = &getAnalysis(); +static RegisterPass +X("profile-verifier", "Verify profiling information", false, true); - // Prepare global variables. - PrintedDebugTree = false; - BBisVisited.clear(); - - // Fetch entry block and recurse into it. - const BasicBlock *entry = &F.getEntryBlock(); - recurseBasicBlock(entry); - - if (!DisableAssertions) - assert((PI->getExecutionCount(&F)==PI->getExecutionCount(entry)) && - "Function count and entry block count do not match"); - return false; +namespace llvm { + FunctionPass *createProfileVerifierPass() { + return new ProfileVerifierPass(ProfileVerifierDisableAssertions); + } } + From baldrick at free.fr Thu Dec 3 07:15:28 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Dec 2009 13:15:28 -0000 Subject: [llvm-commits] [dragonegg] r90453 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912031315.nB3DFT2i013884@zion.cs.uiuc.edu> Author: baldrick Date: Thu Dec 3 07:15:28 2009 New Revision: 90453 URL: http://llvm.org/viewvc/llvm-project?rev=90453&view=rev Log: Use a more direct method of obtaining the entry block. 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=90453&r1=90452&r2=90453&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Thu Dec 3 07:15:28 2009 @@ -2148,7 +2148,7 @@ assert(is_gimple_reg_type(TREE_TYPE(addr)) && "Not of register type!"); // Any generated code goes in the entry block. - BasicBlock *EntryBlock = SSAInsertionPoint->getParent(); + BasicBlock *EntryBlock = Fn->begin(); // Note the current builder position. BasicBlock *SavedInsertBB = Builder.GetInsertBlock(); From benny.kra at googlemail.com Thu Dec 3 07:23:04 2009 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 03 Dec 2009 13:23:04 -0000 Subject: [llvm-commits] [llvm] r90454 - /llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Message-ID: <200912031323.nB3DN4Vv014147@zion.cs.uiuc.edu> Author: d0k Date: Thu Dec 3 07:23:03 2009 New Revision: 90454 URL: http://llvm.org/viewvc/llvm-project?rev=90454&view=rev Log: Fix MSVC build. Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=90454&r1=90453&r2=90454&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original) +++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Thu Dec 3 07:23:03 2009 @@ -324,7 +324,7 @@ // Since the entry block is the first one and has no predecessors, the edge // (0,entry) is inserted with the starting weight of 1. BasicBlock *entry = &F.getEntryBlock(); - BlockInformation[&F][entry] = pow(2,32); + BlockInformation[&F][entry] = pow(2.0, 32.0); Edge edge = getEdge(0,entry); EdgeInformation[&F][edge] = BlockInformation[&F][entry]; printEdgeWeight(edge); From astifter-llvm at gmx.at Thu Dec 3 07:34:57 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Thu, 03 Dec 2009 14:34:57 +0100 Subject: [llvm-commits] [llvm] r90454 - /llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp In-Reply-To: <200912031323.nB3DN4Vv014147@zion.cs.uiuc.edu> References: <200912031323.nB3DN4Vv014147@zion.cs.uiuc.edu> Message-ID: <4B17BE81.6040201@gmx.at> Sorry, overlooked that on the buildbots. Thanks, Andi On 12/03/2009 02:23 PM, Benjamin Kramer wrote: > Author: d0k > Date: Thu Dec 3 07:23:03 2009 > New Revision: 90454 > > URL: http://llvm.org/viewvc/llvm-project?rev=90454&view=rev > Log: > Fix MSVC build. > > Modified: > llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp > > Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=90454&r1=90453&r2=90454&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original) > +++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Thu Dec 3 07:23:03 2009 > @@ -324,7 +324,7 @@ > // Since the entry block is the first one and has no predecessors, the edge > // (0,entry) is inserted with the starting weight of 1. > BasicBlock *entry =&F.getEntryBlock(); > - BlockInformation[&F][entry] = pow(2,32); > + BlockInformation[&F][entry] = pow(2.0, 32.0); > Edge edge = getEdge(0,entry); > EdgeInformation[&F][edge] = BlockInformation[&F][entry]; > printEdgeWeight(edge); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From espindola at google.com Thu Dec 3 08:16:35 2009 From: espindola at google.com (Rafael Espindola) Date: Thu, 3 Dec 2009 09:16:35 -0500 Subject: [llvm-commits] [llvm-gcc-4.2] r86892 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h In-Reply-To: <4B177A7A.9010906@free.fr> References: <200911112305.nABN5jd1010544@zion.cs.uiuc.edu> <860AC9D2-EA76-476F-9B1D-DA0E7BB0A651@apple.com> <35038F04-ED7A-4D60-ABD5-0CADD56536D2@apple.com> <38a0d8450911252018p3930f82cg43ebe9f6ded326c0@mail.gmail.com> <38a0d8450912011506n2577f4dfoaea9de802b37954f@mail.gmail.com> <38a0d8450912021345n646360ddtf847aaa57cc34356@mail.gmail.com> <4B177A7A.9010906@free.fr> Message-ID: <38a0d8450912030616k23e13e6dq900dc1dc22af59a6@mail.gmail.com> > Well, you could always access it as an i24 :) That is an interesting point. Do you know if the arm backend would do the right thing in both cases? void @f(i24) Should be expanded and passed in a register. void @g(i32, i32, i32, i32, i24) Should not be expanded and put in memory. Using i32 for the first case has the advantage that the expansion is explicit in the IL, but using i24 in both might be easier to implement :-) > Ciao, > > Duncan. > Cheers, -- Rafael ?vila de Esp?ndola From bob.wilson at apple.com Thu Dec 3 11:35:57 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 3 Dec 2009 09:35:57 -0800 Subject: [llvm-commits] [llvm] r90417 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2009-12-02-vtrn-undef.ll In-Reply-To: <4B177E2A.2040908@free.fr> References: <200912030640.nB36etKX018295@zion.cs.uiuc.edu> <4B177E2A.2040908@free.fr> Message-ID: <47E9C204-8F76-49E5-B98F-7BF51FF0DAEA@apple.com> On Dec 3, 2009, at 1:00 AM, Duncan Sands wrote: > Hi Bob, > >> Recognize canonical forms of vector shuffles where the same vector is used for >> both source operands. In the canonical form, the 2nd operand is changed to an >> undef and the shuffle mask is adjusted to only reference elements from the 1st >> operand. Radar 7434842. > > this sounds like a general optimization, i.e. not ARM specific. How about doing > this in the DAG combiner instead? Maybe I don't understand your suggestion, but I don't see how that would work. Besides the obvious problem that we may have code that is relying on these shuffles being in this canonical form, transforming them out of canonical form is very target-specific. For example, if you have: shuffle v, undef, <0, 0, 2, 2> you could transform it to any of the following: shuffle v, v, <0, 4, 2, 6> shuffle v, v, <4, 0, 6, 2> shuffle v, v, <4, 4, 2, 2> etc. To make this useful, you have to know what shuffle masks the target can support. For some shuffles, e.g., NEON's vrev instructions, the target may only support operations with one source operand, so you wouldn't want to change those at all. From clattner at apple.com Thu Dec 3 11:44:39 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 3 Dec 2009 09:44:39 -0800 Subject: [llvm-commits] [llvm] r90454 - /llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp In-Reply-To: <4B17BE81.6040201@gmx.at> References: <200912031323.nB3DN4Vv014147@zion.cs.uiuc.edu> <4B17BE81.6040201@gmx.at> Message-ID: <454B53DF-91D8-4F4B-8A54-37F70D18B89C@apple.com> On Dec 3, 2009, at 5:34 AM, Andreas Neustifter wrote: > Sorry, overlooked that on the buildbots. Hi Andreas, Instead of using pow(2, x) why not just use "1 << x", or better yet, just use the constant in this case? -Chris > > Thanks, Andi > > On 12/03/2009 02:23 PM, Benjamin Kramer wrote: >> Author: d0k >> Date: Thu Dec 3 07:23:03 2009 >> New Revision: 90454 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90454&view=rev >> Log: >> Fix MSVC build. >> >> Modified: >> llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp >> >> Modified: llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp?rev=90454&r1=90453&r2=90454&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp (original) >> +++ llvm/trunk/lib/Analysis/ProfileEstimatorPass.cpp Thu Dec 3 >> 07:23:03 2009 >> @@ -324,7 +324,7 @@ >> // Since the entry block is the first one and has no >> predecessors, the edge >> // (0,entry) is inserted with the starting weight of 1. >> BasicBlock *entry =&F.getEntryBlock(); >> - BlockInformation[&F][entry] = pow(2,32); >> + BlockInformation[&F][entry] = pow(2.0, 32.0); >> Edge edge = getEdge(0,entry); >> EdgeInformation[&F][edge] = BlockInformation[&F][entry]; >> printEdgeWeight(edge); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From clattner at apple.com Thu Dec 3 11:47:11 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 3 Dec 2009 09:47:11 -0800 Subject: [llvm-commits] [llvm] r90445 - in /llvm/trunk: include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileInfo.cpp In-Reply-To: <200912030930.nB39UCep006456@zion.cs.uiuc.edu> References: <200912030930.nB39UCep006456@zion.cs.uiuc.edu> Message-ID: <7F5F0839-581F-45B2-8931-9183DD8D1C1A@apple.com> On Dec 3, 2009, at 1:30 AM, Andreas Neustifter wrote: > Author: astifter > Date: Thu Dec 3 03:30:12 2009 > New Revision: 90445 > > URL: http://llvm.org/viewvc/llvm-project?rev=90445&view=rev > Log: > Converted ProfileInfo to template, added more API for ProfileInfo- > preserving. Does this have to be a template? Why not use a base class that keeps a map and then have derived classes for LLVM BB and MBB's? This would significantly reduce code size. -Chris > > Modified: > llvm/trunk/include/llvm/Analysis/ProfileInfo.h > llvm/trunk/lib/Analysis/ProfileInfo.cpp > > Modified: llvm/trunk/include/llvm/Analysis/ProfileInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ProfileInfo.h?rev=90445&r1=90444&r2=90445&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Analysis/ProfileInfo.h (original) > +++ llvm/trunk/include/llvm/Analysis/ProfileInfo.h Thu Dec 3 > 03:30:12 2009 > @@ -21,116 +21,228 @@ > #ifndef LLVM_ANALYSIS_PROFILEINFO_H > #define LLVM_ANALYSIS_PROFILEINFO_H > > -#include "llvm/BasicBlock.h" > +#include "llvm/Support/Debug.h" > +#include "llvm/Support/Format.h" > +#include "llvm/Support/raw_ostream.h" > #include > #include > #include > +#include > > namespace llvm { > - class Function; > class Pass; > class raw_ostream; > > + class BasicBlock; > + class Function; > + class MachineBasicBlock; > + class MachineFunction; > + > + // Helper for dumping edges to errs(). > + raw_ostream& operator<<(raw_ostream &O, std::pair BasicBlock *, const BasicBlock *> E); > + raw_ostream& operator<<(raw_ostream &O, std::pair MachineBasicBlock *, const MachineBasicBlock *> E); > + > + raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB); > + raw_ostream& operator<<(raw_ostream &O, const MachineBasicBlock > *MBB); > + > + raw_ostream& operator<<(raw_ostream &O, const Function *F); > + raw_ostream& operator<<(raw_ostream &O, const MachineFunction *MF); > + > /// ProfileInfo Class - This class holds and maintains profiling > /// information for some unit of code. > - class ProfileInfo { > + template > + class ProfileInfoT { > public: > // Types for handling profiling information. > - typedef std::pair Edge; > + typedef std::pair Edge; > typedef std::pair EdgeWeight; > typedef std::map EdgeWeights; > - typedef std::map BlockCounts; > + typedef std::map BlockCounts; > + typedef std::map Path; > > protected: > // EdgeInformation - Count the number of times a transition > between two > // blocks is executed. As a special case, we also hold an edge > from the > // null BasicBlock to the entry block to indicate how many times > the > // function was entered. > - std::map EdgeInformation; > + std::map EdgeInformation; > > // BlockInformation - Count the number of times a block is > executed. > - std::map BlockInformation; > + std::map BlockInformation; > > // FunctionInformation - Count the number of times a function is > executed. > - std::map FunctionInformation; > + std::map FunctionInformation; > + > + ProfileInfoT *MachineProfile; > public: > static char ID; // Class identification, replacement for typeinfo > - virtual ~ProfileInfo(); // We want to be subclassed > + ProfileInfoT(); > + ~ProfileInfoT(); // We want to be subclassed > > // MissingValue - The value that is returned for execution > counts in case > // no value is available. > static const double MissingValue; > > // getFunction() - Returns the Function for an Edge, checking > for validity. > - static const Function* getFunction(Edge e) { > + static const FType* getFunction(Edge e) { > if (e.first) { > return e.first->getParent(); > } else if (e.second) { > return e.second->getParent(); > } > assert(0 && "Invalid ProfileInfo::Edge"); > - return (const Function*)0; > + return (const FType*)0; > } > > // getEdge() - Creates an Edge from two BasicBlocks. > - static Edge getEdge(const BasicBlock *Src, const BasicBlock > *Dest) { > + static Edge getEdge(const BType *Src, const BType *Dest) { > return std::make_pair(Src, Dest); > } > > // > ===------------------------------------------------------------------ > ===// > /// Profile Information Queries > /// > - double getExecutionCount(const Function *F); > + double getExecutionCount(const FType *F); > + > + double getExecutionCount(const BType *BB); > + > + void setExecutionCount(const BType *BB, double w); > > - double getExecutionCount(const BasicBlock *BB); > + void addExecutionCount(const BType *BB, double w); > > double getEdgeWeight(Edge e) const { > - std::map::const_iterator J = > + typename std::map::const_iterator > J = > EdgeInformation.find(getFunction(e)); > if (J == EdgeInformation.end()) return MissingValue; > > - EdgeWeights::const_iterator I = J->second.find(e); > + typename EdgeWeights::const_iterator I = J->second.find(e); > if (I == J->second.end()) return MissingValue; > > return I->second; > } > > - EdgeWeights &getEdgeWeights (const Function *F) { > + void setEdgeWeight(Edge e, double w) { > + DEBUG_WITH_TYPE("profile-info", > + errs() << "Creating Edge " << e > + << " (weight: " << format("%.20g",w) << ")\n"); > + EdgeInformation[getFunction(e)][e] = w; > + } > + > + void addEdgeWeight(Edge e, double w); > + > + EdgeWeights &getEdgeWeights (const FType *F) { > return EdgeInformation[F]; > } > > // > ===------------------------------------------------------------------ > ===// > /// Analysis Update Methods > /// > - void removeBlock(const BasicBlock *BB) { > - std::map::iterator J = > - BlockInformation.find(BB->getParent()); > - if (J == BlockInformation.end()) return; > + void removeBlock(const BType *BB); > > - J->second.erase(BB); > - } > + void removeEdge(Edge e); > > - void removeEdge(Edge e) { > - std::map::iterator J = > - EdgeInformation.find(getFunction(e)); > - if (J == EdgeInformation.end()) return; > + void replaceEdge(const Edge &, const Edge &); > > - J->second.erase(e); > + enum GetPathMode { > + GetPathToExit = 1, > + GetPathToValue = 2, > + GetPathToDest = 4, > + GetPathWithNewEdges = 8 > + }; > + > + const BType *GetPath(const BType *Src, const BType *Dest, > + Path &P, unsigned Mode); > + > + void divertFlow(const Edge &, const Edge &); > + > + void splitEdge(const BType *FirstBB, const BType *SecondBB, > + const BType *NewBB, bool MergeIdenticalEdges = > false); > + > + void splitBlock(const BType *Old, const BType* New); > + > + void splitBlock(const BType *BB, const BType* NewBB, > + BType *const *Preds, unsigned NumPreds); > + > + void replaceAllUses(const BType *RmBB, const BType *DestBB); > + > + void transfer(const FType *Old, const FType *New); > + > + void repair(const FType *F); > + > + void dump(FType *F = 0, bool real = true) { > + errs() << "**** This is ProfileInfo " << this << " speaking: > \n"; > + if (!real) { > + typename std::set Functions; > + > + errs() << "Functions: \n"; > + if (F) { > + errs() << F << "@" << format("%p", F) << ": " << > format("%.20g",getExecutionCount(F)) << "\n"; > + Functions.insert(F); > + } else { > + for (typename std::map::iterator fi > = FunctionInformation.begin(), > + fe = FunctionInformation.end(); fi != fe; ++fi) { > + errs() << fi->first << "@" << format("%p",fi->first) << > ": " << format("%.20g",fi->second) << "\n"; > + Functions.insert(fi->first); > + } > + } > + > + for (typename std::set::iterator FI = > Functions.begin(), FE = Functions.end(); > + FI != FE; ++FI) { > + const FType *F = *FI; > + typename std::map::iterator > bwi = BlockInformation.find(F); > + errs() << "BasicBlocks for Function " << F << ":\n"; > + for (typename BlockCounts::const_iterator bi = bwi- > >second.begin(), be = bwi->second.end(); bi != be; ++bi) { > + errs() << bi->first << "@" << format("%p", bi->first) > << ": " << format("%.20g",bi->second) << "\n"; > + } > + } > + > + for (typename std::set::iterator FI = > Functions.begin(), FE = Functions.end(); > + FI != FE; ++FI) { > + typename std::map::iterator ei > = EdgeInformation.find(*FI); > + errs() << "Edges for Function " << ei->first << ":\n"; > + for (typename EdgeWeights::iterator ewi = ei- > >second.begin(), ewe = ei->second.end(); > + ewi != ewe; ++ewi) { > + errs() << ewi->first << ": " << format("%.20g",ewi- > >second) << "\n"; > + } > + } > + } else { > + assert(F && "No function given, this is not supported!"); > + errs() << "Functions: \n"; > + errs() << F << "@" << format("%p", F) << ": " << format("%. > 20g",getExecutionCount(F)) << "\n"; > + > + errs() << "BasicBlocks for Function " << F << ":\n"; > + for (typename FType::const_iterator BI = F->begin(), BE = F- > >end(); > + BI != BE; ++BI) { > + const BType *BB = &(*BI); > + errs() << BB << "@" << format("%p", BB) << ": " << > format("%.20g",getExecutionCount(BB)) << "\n"; > + } > + } > + errs() << "**** ProfileInfo " << this << ", over and out.\n"; > } > > - void splitEdge(const BasicBlock *FirstBB, const BasicBlock > *SecondBB, > - const BasicBlock *NewBB, bool > MergeIdenticalEdges = false); > + bool CalculateMissingEdge(const BType *BB, Edge &removed, bool > assumeEmptyExit = false); > + > + bool EstimateMissingEdges(const BType *BB); > > - void replaceAllUses(const BasicBlock *RmBB, const BasicBlock > *DestBB); > + ProfileInfoT *MI() { > + if (MachineProfile == 0) > + MachineProfile = new ProfileInfoT MachineBasicBlock>(); > + return MachineProfile; > + } > + > + bool hasMI() const { > + return (MachineProfile != 0); > + } > }; > > + typedef ProfileInfoT ProfileInfo; > + typedef ProfileInfoT > MachineProfileInfo; > + > /// createProfileLoaderPass - This function returns a Pass that > loads the > /// profiling information for the module from the specified > filename, making > /// it available to the optimizers. > Pass *createProfileLoaderPass(const std::string &Filename); > > - raw_ostream& operator<<(raw_ostream &O, ProfileInfo::Edge E); > - > } // End llvm namespace > > #endif > > Modified: llvm/trunk/lib/Analysis/ProfileInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ProfileInfo.cpp?rev=90445&r1=90444&r2=90445&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Analysis/ProfileInfo.cpp (original) > +++ llvm/trunk/lib/Analysis/ProfileInfo.cpp Thu Dec 3 03:30:12 2009 > @@ -11,25 +11,51 @@ > // "no profile" implementation. > // > // > = > = > = > ----------------------------------------------------------------------= > ==// > - > +#define DEBUG_TYPE "profile-info" > #include "llvm/Analysis/Passes.h" > #include "llvm/Analysis/ProfileInfo.h" > +#include "llvm/CodeGen/MachineBasicBlock.h" > +#include "llvm/CodeGen/MachineFunction.h" > #include "llvm/Pass.h" > #include "llvm/Support/CFG.h" > -#include "llvm/Support/Debug.h" > -#include "llvm/Support/raw_ostream.h" > -#include "llvm/Support/Format.h" > +#include "llvm/ADT/SmallSet.h" > #include > +#include > +#include > using namespace llvm; > > // Register the ProfileInfo interface, providing a nice name to > refer to. > static RegisterAnalysisGroup Z("Profile Information"); > + > +namespace llvm { > + > +template <> > +ProfileInfoT::ProfileInfoT() {} > +template <> > +ProfileInfoT::~ProfileInfoT() {} > + > +template <> > +ProfileInfoT::ProfileInfoT() { > + MachineProfile = 0; > +} > +template <> > +ProfileInfoT::~ProfileInfoT() { > + if (MachineProfile) delete MachineProfile; > +} > + > +template<> > char ProfileInfo::ID = 0; > > -ProfileInfo::~ProfileInfo() {} > +template<> > +char MachineProfileInfo::ID = 0; > > +template<> > const double ProfileInfo::MissingValue = -1; > > +template<> > +const double MachineProfileInfo::MissingValue = -1; > + > +template<> > double ProfileInfo::getExecutionCount(const BasicBlock *BB) { > std::map::iterator J = > BlockInformation.find(BB->getParent()); > @@ -39,35 +65,72 @@ > return I->second; > } > > + double Count = MissingValue; > + > pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); > > // Are there zero predecessors of this block? > if (PI == PE) { > - // If this is the entry block, look for the Null -> Entry edge. > - if (BB == &BB->getParent()->getEntryBlock()) > - return getEdgeWeight(getEdge(0, BB)); > - else > - return 0; // Otherwise, this is a dead block. > + Edge e = getEdge(0,BB); > + Count = getEdgeWeight(e); > + } else { > + // Otherwise, if there are predecessors, the execution count of > this block is > + // the sum of the edge frequencies from the incoming edges. > + std::set ProcessedPreds; > + Count = 0; > + for (; PI != PE; ++PI) > + if (ProcessedPreds.insert(*PI).second) { > + double w = getEdgeWeight(getEdge(*PI, BB)); > + if (w == MissingValue) { > + Count = MissingValue; > + break; > + } > + Count += w; > + } > } > > - // Otherwise, if there are predecessors, the execution count of > this block is > - // the sum of the edge frequencies from the incoming edges. > - std::set ProcessedPreds; > - double Count = 0; > - for (; PI != PE; ++PI) > - if (ProcessedPreds.insert(*PI).second) { > - double w = getEdgeWeight(getEdge(*PI, BB)); > - if (w == MissingValue) { > - Count = MissingValue; > - break; > - } > - Count += w; > + // If the predecessors did not suffice to get block weight, try > successors. > + if (Count == MissingValue) { > + > + succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB); > + > + // Are there zero successors of this block? > + if (SI == SE) { > + Edge e = getEdge(BB,0); > + Count = getEdgeWeight(e); > + } else { > + std::set ProcessedSuccs; > + Count = 0; > + for (; SI != SE; ++SI) > + if (ProcessedSuccs.insert(*SI).second) { > + double w = getEdgeWeight(getEdge(BB, *SI)); > + if (w == MissingValue) { > + Count = MissingValue; > + break; > + } > + Count += w; > + } > } > + } > > if (Count != MissingValue) BlockInformation[BB->getParent()][BB] = > Count; > return Count; > } > > +template<> > +double MachineProfileInfo::getExecutionCount(const > MachineBasicBlock *MBB) { > + std::map::iterator J = > + BlockInformation.find(MBB->getParent()); > + if (J != BlockInformation.end()) { > + BlockCounts::iterator I = J->second.find(MBB); > + if (I != J->second.end()) > + return I->second; > + } > + > + return MissingValue; > +} > + > +template<> > double ProfileInfo::getExecutionCount(const Function *F) { > std::map::iterator J = > FunctionInformation.find(F); > @@ -83,35 +146,204 @@ > return Count; > } > > +template<> > +double MachineProfileInfo::getExecutionCount(const MachineFunction > *MF) { > + std::map::iterator J = > + FunctionInformation.find(MF); > + if (J != FunctionInformation.end()) > + return J->second; > + > + double Count = getExecutionCount(&MF->front()); > + if (Count != MissingValue) FunctionInformation[MF] = Count; > + return Count; > +} > + > +template<> > +void ProfileInfo::setExecutionCount(const BasicBlock *BB, double w) { > + DEBUG(errs() << "Creating Block " << BB->getName() > + << " (weight: " << format("%.20g",w) << ")\n"); > + BlockInformation[BB->getParent()][BB] = w; > +} > + > +template<> > +void MachineProfileInfo::setExecutionCount(const MachineBasicBlock > *MBB, double w) { > + DEBUG(errs() << "Creating Block " << MBB->getBasicBlock()- > >getName() > + << " (weight: " << format("%.20g",w) << ")\n"); > + BlockInformation[MBB->getParent()][MBB] = w; > +} > + > +template<> > +void ProfileInfo::addEdgeWeight(Edge e, double w) { > + double oldw = getEdgeWeight(e); > + assert (oldw != MissingValue && "Adding weight to Edge with no > previous weight"); > + DEBUG(errs() << "Adding to Edge " << e > + << " (new weight: " << format("%.20g",oldw + w) << ") > \n"); > + EdgeInformation[getFunction(e)][e] = oldw + w; > +} > + > +template<> > +void ProfileInfo::addExecutionCount(const BasicBlock *BB, double w) { > + double oldw = getExecutionCount(BB); > + assert (oldw != MissingValue && "Adding weight to Block with no > previous weight"); > + DEBUG(errs() << "Adding to Block " << BB->getName() > + << " (new weight: " << format("%.20g",oldw + w) << ") > \n"); > + BlockInformation[BB->getParent()][BB] = oldw + w; > +} > + > +template<> > +void ProfileInfo::removeBlock(const BasicBlock *BB) { > + std::map::iterator J = > + BlockInformation.find(BB->getParent()); > + if (J == BlockInformation.end()) return; > + > + DEBUG(errs() << "Deleting " << BB->getName() << "\n"); > + J->second.erase(BB); > +} > + > +template<> > +void ProfileInfo::removeEdge(Edge e) { > + std::map::iterator J = > + EdgeInformation.find(getFunction(e)); > + if (J == EdgeInformation.end()) return; > + > + DEBUG(errs() << "Deleting" << e << "\n"); > + J->second.erase(e); > +} > + > +template<> > +void ProfileInfo::replaceEdge(const Edge &oldedge, const Edge > &newedge) { > + double w; > + if ((w = getEdgeWeight(newedge)) == MissingValue) { > + w = getEdgeWeight(oldedge); > + DEBUG(errs() << "Replacing " << oldedge << " with " << newedge > << "\n"); > + } else { > + w += getEdgeWeight(oldedge); > + DEBUG(errs() << "Adding " << oldedge << " to " << newedge << > "\n"); > + } > + setEdgeWeight(newedge,w); > + removeEdge(oldedge); > +} > + > +template<> > +const BasicBlock *ProfileInfo::GetPath(const BasicBlock *Src, const > BasicBlock *Dest, > + Path &P, unsigned Mode) { > + const BasicBlock *BB = 0; > + bool hasFoundPath = false; > + > + std::queue BFS; > + BFS.push(Src); > + > + while(BFS.size() && !hasFoundPath) { > + BB = BFS.front(); > + BFS.pop(); > + > + succ_const_iterator Succ = succ_begin(BB), End = succ_end(BB); > + if (Succ == End) { > + P[0] = BB; > + if (Mode & GetPathToExit) { > + hasFoundPath = true; > + BB = 0; > + } > + } > + for(;Succ != End; ++Succ) { > + if (P.find(*Succ) != P.end()) continue; > + Edge e = getEdge(BB,*Succ); > + if ((Mode & GetPathWithNewEdges) && (getEdgeWeight(e) != > MissingValue)) continue; > + P[*Succ] = BB; > + BFS.push(*Succ); > + if ((Mode & GetPathToDest) && *Succ == Dest) { > + hasFoundPath = true; > + BB = *Succ; > + break; > + } > + if ((Mode & GetPathToValue) && (getExecutionCount(*Succ) != > MissingValue)) { > + hasFoundPath = true; > + BB = *Succ; > + break; > + } > + } > + } > + > + return BB; > +} > + > +template<> > +void ProfileInfo::divertFlow(const Edge &oldedge, const Edge > &newedge) { > + DEBUG(errs() << "Diverting " << oldedge << " via " << newedge ); > + > + // First check if the old edge was taken, if not, just delete it... > + if (getEdgeWeight(oldedge) == 0) { > + removeEdge(oldedge); > + return; > + } > + > + Path P; > + P[newedge.first] = 0; > + P[newedge.second] = newedge.first; > + const BasicBlock *BB = > GetPath(newedge.second,oldedge.second,P,GetPathToExit | > GetPathToDest); > + > + double w = getEdgeWeight (oldedge); > + DEBUG(errs() << ", Weight: " << format("%.20g",w) << "\n"); > + do { > + const BasicBlock *Parent = P.find(BB)->second; > + Edge e = getEdge(Parent,BB); > + double oldw = getEdgeWeight(e); > + double oldc = getExecutionCount(e.first); > + setEdgeWeight(e, w+oldw); > + if (Parent != oldedge.first) { > + setExecutionCount(e.first, w+oldc); > + } > + BB = Parent; > + } while (BB != newedge.first); > + removeEdge(oldedge); > +} > + > /// Replaces all occurences of RmBB in the ProfilingInfo with DestBB. > /// This checks all edges of the function the blocks reside in and > replaces the > /// occurences of RmBB with DestBB. > +template<> > void ProfileInfo::replaceAllUses(const BasicBlock *RmBB, > const BasicBlock *DestBB) { > - DEBUG(errs() << "Replacing " << RmBB->getNameStr() > - << " with " << DestBB->getNameStr() << "\n"); > + DEBUG(errs() << "Replacing " << RmBB->getName() > + << " with " << DestBB->getName() << "\n"); > const Function *F = DestBB->getParent(); > std::map::iterator J = > EdgeInformation.find(F); > if (J == EdgeInformation.end()) return; > > - for (EdgeWeights::iterator I = J->second.begin(), E = J- > >second.end(); > - I != E; ++I) { > - Edge e = I->first; > - Edge newedge; bool foundedge = false; > + Edge e, newedge; > + bool erasededge = false; > + EdgeWeights::iterator I = J->second.begin(), E = J->second.end(); > + while(I != E) { > + e = (I++)->first; > + bool foundedge = false; bool eraseedge = false; > if (e.first == RmBB) { > - newedge = getEdge(DestBB, e.second); > - foundedge = true; > + if (e.second == DestBB) { > + eraseedge = true; > + } else { > + newedge = getEdge(DestBB, e.second); > + foundedge = true; > + } > } > if (e.second == RmBB) { > - newedge = getEdge(e.first, DestBB); > - foundedge = true; > + if (e.first == DestBB) { > + eraseedge = true; > + } else { > + newedge = getEdge(e.first, DestBB); > + foundedge = true; > + } > } > if (foundedge) { > - double w = getEdgeWeight(e); > - EdgeInformation[F][newedge] = w; > - DEBUG(errs() << "Replacing " << e << " with " << newedge << > "\n"); > - J->second.erase(e); > + replaceEdge(e, newedge); > + } > + if (eraseedge) { > + if (erasededge) { > + Edge newedge = getEdge(DestBB, DestBB); > + replaceEdge(e, newedge); > + } else { > + removeEdge(e); > + erasededge = true; > + } > } > } > } > @@ -119,6 +351,7 @@ > /// Splits an edge in the ProfileInfo and redirects flow over NewBB. > /// Since its possible that there is more than one edge in the CFG > from FristBB > /// to SecondBB its necessary to redirect the flow proporionally. > +template<> > void ProfileInfo::splitEdge(const BasicBlock *FirstBB, > const BasicBlock *SecondBB, > const BasicBlock *NewBB, > @@ -153,7 +386,7 @@ > > // We know now how many edges there are from FirstBB to SecondBB, > reroute a > // proportional part of the edge weight over NewBB. > - double neww = w / succ_count; > + double neww = floor(w / succ_count); > ECs[n1] += neww; > ECs[n2] += neww; > BlockInformation[F][NewBB] += neww; > @@ -164,14 +397,666 @@ > } > } > > -raw_ostream& llvm::operator<<(raw_ostream &O, ProfileInfo::Edge E) { > +template<> > +void ProfileInfo::splitBlock(const BasicBlock *Old, const > BasicBlock* New) { > + const Function *F = Old->getParent(); > + std::map::iterator J = > + EdgeInformation.find(F); > + if (J == EdgeInformation.end()) return; > + > + DEBUG(errs() << "Splitting " << Old->getName() << " to " << New- > >getName() << "\n"); > + > + std::set Edges; > + for (EdgeWeights::iterator ewi = J->second.begin(), ewe = J- > >second.end(); > + ewi != ewe; ++ewi) { > + Edge old = ewi->first; > + if (old.first == Old) { > + Edges.insert(old); > + } > + } > + for (std::set::iterator EI = Edges.begin(), EE = Edges.end(); > + EI != EE; ++EI) { > + Edge newedge = getEdge(New, EI->second); > + replaceEdge(*EI, newedge); > + } > + > + double w = getExecutionCount(Old); > + setEdgeWeight(getEdge(Old, New), w); > + setExecutionCount(New, w); > +} > + > +template<> > +void ProfileInfo::splitBlock(const BasicBlock *BB, const > BasicBlock* NewBB, > + BasicBlock *const *Preds, unsigned > NumPreds) { > + const Function *F = BB->getParent(); > + std::map::iterator J = > + EdgeInformation.find(F); > + if (J == EdgeInformation.end()) return; > + > + DEBUG(errs() << "Splitting " << NumPreds << " Edges from " << BB- > >getName() > + << " to " << NewBB->getName() << "\n"); > + > + // Collect weight that was redirected over NewBB. > + double newweight = 0; > + > + std::set ProcessedPreds; > + // For all requestes Predecessors. > + for (unsigned pred = 0; pred < NumPreds; ++pred) { > + const BasicBlock * Pred = Preds[pred]; > + if (ProcessedPreds.insert(Pred).second) { > + // Create edges and read old weight. > + Edge oldedge = getEdge(Pred, BB); > + Edge newedge = getEdge(Pred, NewBB); > + > + // Remember how much weight was redirected. > + newweight += getEdgeWeight(oldedge); > + > + replaceEdge(oldedge,newedge); > + } > + } > + > + Edge newedge = getEdge(NewBB,BB); > + setEdgeWeight(newedge, newweight); > + setExecutionCount(NewBB, newweight); > +} > + > +template<> > +void ProfileInfo::transfer(const Function *Old, const Function > *New) { > + DEBUG(errs() << "Replacing Function " << Old->getName() << " with " > + << New->getName() << "\n"); > + std::map::iterator J = > + EdgeInformation.find(Old); > + if(J != EdgeInformation.end()) { > + EdgeInformation[New] = J->second; > + } > + EdgeInformation.erase(Old); > + BlockInformation.erase(Old); > + FunctionInformation.erase(Old); > +} > + > +static double readEdgeOrRemember(ProfileInfo::Edge edge, double w, > ProfileInfo::Edge &tocalc, > + unsigned &uncalc) { > + if (w == ProfileInfo::MissingValue) { > + tocalc = edge; > + uncalc++; > + return 0; > + } else { > + return w; > + } > +} > + > +template<> > +bool ProfileInfo::CalculateMissingEdge(const BasicBlock *BB, Edge > &removed, bool assumeEmptySelf) { > + Edge edgetocalc; > + unsigned uncalculated = 0; > + > + // collect weights of all incoming and outgoing edges, rememer > edges that > + // have no value > + double incount = 0; > + SmallSet pred_visited; > + pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); > + if (bbi==bbe) { > + Edge e = getEdge(0,BB); > + incount += readEdgeOrRemember(e, > getEdgeWeight(e) ,edgetocalc,uncalculated); > + } > + for (;bbi != bbe; ++bbi) { > + if (pred_visited.insert(*bbi)) { > + Edge e = getEdge(*bbi,BB); > + incount += readEdgeOrRemember(e, > getEdgeWeight(e) ,edgetocalc,uncalculated); > + } > + } > + > + double outcount = 0; > + SmallSet succ_visited; > + succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); > + if (sbbi==sbbe) { > + Edge e = getEdge(BB,0); > + if (getEdgeWeight(e) == MissingValue) { > + double w = getExecutionCount(BB); > + if (w != MissingValue) { > + setEdgeWeight(e,w); > + removed = e; > + } > + } > + outcount += readEdgeOrRemember(e, getEdgeWeight(e), edgetocalc, > uncalculated); > + } > + for (;sbbi != sbbe; ++sbbi) { > + if (succ_visited.insert(*sbbi)) { > + Edge e = getEdge(BB,*sbbi); > + outcount += readEdgeOrRemember(e, getEdgeWeight(e), > edgetocalc, uncalculated); > + } > + } > + > + // if exactly one edge weight was missing, calculate it and > remove it from > + // spanning tree > + if (uncalculated == 0 ) { > + return true; > + } else > + if (uncalculated == 1) { > + if (incount < outcount) { > + EdgeInformation[BB->getParent()][edgetocalc] = outcount- > incount; > + } else { > + EdgeInformation[BB->getParent()][edgetocalc] = incount- > outcount; > + } > + DEBUG(errs() << "--Calc Edge Counter for " << edgetocalc << ": " > + << format("%.20g", getEdgeWeight(edgetocalc)) << > "\n"); > + removed = edgetocalc; > + return true; > + } else > + if (uncalculated == 2 && assumeEmptySelf && edgetocalc.first == > edgetocalc.second && incount == outcount) { > + setEdgeWeight(edgetocalc, incount * 10); > + removed = edgetocalc; > + return true; > + } else { > + return false; > + } > +} > + > +static void readEdge(ProfileInfo *PI, ProfileInfo::Edge e, double > &calcw, std::set &misscount) { > + double w = PI->getEdgeWeight(e); > + if (w != ProfileInfo::MissingValue) { > + calcw += w; > + } else { > + misscount.insert(e); > + } > +} > + > +template<> > +bool ProfileInfo::EstimateMissingEdges(const BasicBlock *BB) { > + bool hasNoSuccessors = false; > + > + double inWeight = 0; > + std::set inMissing; > + std::set ProcessedPreds; > + pred_const_iterator bbi = pred_begin(BB), bbe = pred_end(BB); > + if (bbi == bbe) { > + readEdge(this,getEdge(0,BB),inWeight,inMissing); > + } > + for( ; bbi != bbe; ++bbi ) { > + if (ProcessedPreds.insert(*bbi).second) { > + readEdge(this,getEdge(*bbi,BB),inWeight,inMissing); > + } > + } > + > + double outWeight = 0; > + std::set outMissing; > + std::set ProcessedSuccs; > + succ_const_iterator sbbi = succ_begin(BB), sbbe = succ_end(BB); > + if (sbbi == sbbe) { > + readEdge(this,getEdge(BB,0),outWeight,outMissing); > + hasNoSuccessors = true; > + } > + for ( ; sbbi != sbbe; ++sbbi ) { > + if (ProcessedSuccs.insert(*sbbi).second) { > + readEdge(this,getEdge(BB,*sbbi),outWeight,outMissing); > + } > + } > + > + double share; > + std::set::iterator ei,ee; > + if (inMissing.size() == 0 && outMissing.size() > 0) { > + ei = outMissing.begin(); > + ee = outMissing.end(); > + share = inWeight/outMissing.size(); > + setExecutionCount(BB,inWeight); > + } else > + if (inMissing.size() > 0 && outMissing.size() == 0 && outWeight > == 0) { > + ei = inMissing.begin(); > + ee = inMissing.end(); > + share = 0; > + setExecutionCount(BB,0); > + } else > + if (inMissing.size() == 0 && outMissing.size() == 0) { > + setExecutionCount(BB,outWeight); > + return true; > + } else { > + return false; > + } > + for ( ; ei != ee; ++ei ) { > + setEdgeWeight(*ei,share); > + } > + return true; > +} > + > +template<> > +void ProfileInfo::repair(const Function *F) { > +// if (getExecutionCount(&(F->getEntryBlock())) == 0) { > +// for (Function::const_iterator FI = F->begin(), FE = F->end(); > +// FI != FE; ++FI) { > +// const BasicBlock* BB = &(*FI); > +// { > +// pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > +// if (NBB == End) { > +// setEdgeWeight(getEdge(0,BB),0); > +// } > +// for(;NBB != End; ++NBB) { > +// setEdgeWeight(getEdge(*NBB,BB),0); > +// } > +// } > +// { > +// succ_const_iterator NBB = succ_begin(BB), End = > succ_end(BB); > +// if (NBB == End) { > +// setEdgeWeight(getEdge(0,BB),0); > +// } > +// for(;NBB != End; ++NBB) { > +// setEdgeWeight(getEdge(*NBB,BB),0); > +// } > +// } > +// } > +// return; > +// } > + // The set of BasicBlocks that are still unvisited. > + std::set Unvisited; > + > + // The set of return edges (Edges with no successors). > + std::set ReturnEdges; > + double ReturnWeight = 0; > + > + // First iterate over the whole function and collect: > + // 1) The blocks in this function in the Unvisited set. > + // 2) The return edges in the ReturnEdges set. > + // 3) The flow that is leaving the function already via return > edges. > + > + // Data structure for searching the function. > + std::queue BFS; > + const BasicBlock *BB = &(F->getEntryBlock()); > + BFS.push(BB); > + Unvisited.insert(BB); > + > + while (BFS.size()) { > + BB = BFS.front(); BFS.pop(); > + succ_const_iterator NBB = succ_begin(BB), End = succ_end(BB); > + if (NBB == End) { > + Edge e = getEdge(BB,0); > + double w = getEdgeWeight(e); > + if (w == MissingValue) { > + // If the return edge has no value, try to read value from > block. > + double bw = getExecutionCount(BB); > + if (bw != MissingValue) { > + setEdgeWeight(e,bw); > + ReturnWeight += bw; > + } else { > + // If both return edge and block provide no value, > collect edge. > + ReturnEdges.insert(e); > + } > + } else { > + // If the return edge has a proper value, collect it. > + ReturnWeight += w; > + } > + } > + for (;NBB != End; ++NBB) { > + if (Unvisited.insert(*NBB).second) { > + BFS.push(*NBB); > + } > + } > + } > + > + while (Unvisited.size() > 0) { > + unsigned oldUnvisitedCount = Unvisited.size(); > + bool FoundPath = false; > + > + // If there is only one edge left, calculate it. > + if (ReturnEdges.size() == 1) { > + ReturnWeight = getExecutionCount(&(F->getEntryBlock())) - > ReturnWeight; > + > + Edge e = *ReturnEdges.begin(); > + setEdgeWeight(e,ReturnWeight); > + setExecutionCount(e.first,ReturnWeight); > + > + Unvisited.erase(e.first); > + ReturnEdges.erase(e); > + continue; > + } > + > + // Calculate all blocks where only one edge is missing, this > may also > + // resolve furhter return edges. > + std::set::iterator FI = Unvisited.begin(), > FE = Unvisited.end(); > + while(FI != FE) { > + const BasicBlock *BB = *FI; ++FI; > + Edge e; > + if(CalculateMissingEdge(BB,e,true)) { > + if (BlockInformation[F].find(BB) == > BlockInformation[F].end()) { > + setExecutionCount(BB,getExecutionCount(BB)); > + } > + Unvisited.erase(BB); > + if (e.first != 0 && e.second == 0) { > + ReturnEdges.erase(e); > + ReturnWeight += getEdgeWeight(e); > + } > + } > + } > + if (oldUnvisitedCount > Unvisited.size()) continue; > + > + // Estimate edge weights by dividing the flow proportionally. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE) { > + const BasicBlock *BB = *FI; ++FI; > + const BasicBlock *Dest = 0; > + bool AllEdgesHaveSameReturn = true; > + // Check each Successor, these must all end up in the same or > an empty > + // return block otherwise its dangerous to do an estimation > on them. > + for (succ_const_iterator Succ = succ_begin(BB), End = > succ_end(BB); > + Succ != End; ++Succ) { > + Path P; > + GetPath(*Succ, 0, P, GetPathToExit); > + if (Dest && Dest != P[0]) { > + AllEdgesHaveSameReturn = false; > + } > + Dest = P[0]; > + } > + if (AllEdgesHaveSameReturn) { > + if(EstimateMissingEdges(BB)) { > + Unvisited.erase(BB); > + break; > + } > + } > + } > + if (oldUnvisitedCount > Unvisited.size()) continue; > + > + // Check if there is a path to an block that has a known value > and redirect > + // flow accordingly. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE && !FoundPath) { > + // Fetch path. > + const BasicBlock *BB = *FI; ++FI; > + Path P; > + const BasicBlock *Dest = GetPath(BB, 0, P, GetPathToValue); > + > + // Calculate incoming flow. > + double iw = 0; unsigned inmissing = 0; unsigned incount = 0; > unsigned invalid = 0; > + std::set Processed; > + for (pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > + NBB != End; ++NBB) { > + if (Processed.insert(*NBB).second) { > + Edge e = getEdge(*NBB, BB); > + double ew = getEdgeWeight(e); > + if (ew != MissingValue) { > + iw += ew; > + invalid++; > + } else { > + // If the path contains the successor, this means its a > backedge, > + // do not count as missing. > + if (P.find(*NBB) == P.end()) > + inmissing++; > + } > + incount++; > + } > + } > + if (inmissing == incount) continue; > + if (invalid == 0) continue; > + > + // Subtract (already) outgoing flow. > + Processed.clear(); > + for (succ_const_iterator NBB = succ_begin(BB), End = > succ_end(BB); > + NBB != End; ++NBB) { > + if (Processed.insert(*NBB).second) { > + Edge e = getEdge(BB, *NBB); > + double ew = getEdgeWeight(e); > + if (ew != MissingValue) { > + iw -= ew; > + } > + } > + } > + if (iw < 0) continue; > + > + // Check the recieving end of the path if it can handle the > flow. > + double ow = getExecutionCount(Dest); > + Processed.clear(); > + for (succ_const_iterator NBB = succ_begin(BB), End = > succ_end(BB); > + NBB != End; ++NBB) { > + if (Processed.insert(*NBB).second) { > + Edge e = getEdge(BB, *NBB); > + double ew = getEdgeWeight(e); > + if (ew != MissingValue) { > + ow -= ew; > + } > + } > + } > + if (ow < 0) continue; > + > + // Determine how much flow shall be used. > + double ew = getEdgeWeight(getEdge(P[Dest],Dest)); > + if (ew != MissingValue) { > + ew = ew + ew = ew + } else { > + if (inmissing == 0) > + ew = iw; > + } > + > + // Create flow. > + if (ew != MissingValue) { > + do { > + Edge e = getEdge(P[Dest],Dest); > + if (getEdgeWeight(e) == MissingValue) { > + setEdgeWeight(e,ew); > + FoundPath = true; > + } > + Dest = P[Dest]; > + } while (Dest != BB); > + } > + } > + if (FoundPath) continue; > + > + // Calculate a block with self loop. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE && !FoundPath) { > + const BasicBlock *BB = *FI; ++FI; > + bool SelfEdgeFound = false; > + for (succ_const_iterator NBB = succ_begin(BB), End = > succ_end(BB); > + NBB != End; ++NBB) { > + if (*NBB == BB) { > + SelfEdgeFound = true; > + break; > + } > + } > + if (SelfEdgeFound) { > + Edge e = getEdge(BB,BB); > + if (getEdgeWeight(e) == MissingValue) { > + double iw = 0; > + std::set Processed; > + for (pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > + NBB != End; ++NBB) { > + if (Processed.insert(*NBB).second) { > + Edge e = getEdge(*NBB, BB); > + double ew = getEdgeWeight(e); > + if (ew != MissingValue) { > + iw += ew; > + } > + } > + } > + setEdgeWeight(e,iw * 10); > + FoundPath = true; > + } > + } > + } > + if (FoundPath) continue; > + > + // Determine backedges, set them to zero. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE && !FoundPath) { > + const BasicBlock *BB = *FI; ++FI; > + const BasicBlock *Dest; > + Path P; > + bool BackEdgeFound = false; > + for (pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > + NBB != End; ++NBB) { > + Dest = GetPath(BB, *NBB, P, GetPathToDest | > GetPathWithNewEdges); > + if (Dest == *NBB) { > + BackEdgeFound = true; > + break; > + } > + } > + if (BackEdgeFound) { > + Edge e = getEdge(Dest,BB); > + double w = getEdgeWeight(e); > + if (w == MissingValue) { > + setEdgeWeight(e,0); > + FoundPath = true; > + } > + do { > + Edge e = getEdge(P[Dest], Dest); > + double w = getEdgeWeight(e); > + if (w == MissingValue) { > + setEdgeWeight(e,0); > + FoundPath = true; > + } > + Dest = P[Dest]; > + } while (Dest != BB); > + } > + } > + if (FoundPath) continue; > + > + // Channel flow to return block. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE && !FoundPath) { > + const BasicBlock *BB = *FI; ++FI; > + > + Path P; > + const BasicBlock *Dest = GetPath(BB, 0, P, GetPathToExit | > GetPathWithNewEdges); > + Dest = P[0]; > + if (!Dest) continue; > + > + if (getEdgeWeight(getEdge(Dest,0)) == MissingValue) { > + // Calculate incoming flow. > + double iw = 0; > + std::set Processed; > + for (pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > + NBB != End; ++NBB) { > + if (Processed.insert(*NBB).second) { > + Edge e = getEdge(*NBB, BB); > + double ew = getEdgeWeight(e); > + if (ew != MissingValue) { > + iw += ew; > + } > + } > + } > + do { > + Edge e = getEdge(P[Dest], Dest); > + double w = getEdgeWeight(e); > + if (w == MissingValue) { > + setEdgeWeight(e,iw); > + FoundPath = true; > + } else { > + assert(0 && "Edge should not have value already!"); > + } > + Dest = P[Dest]; > + } while (Dest != BB); > + } > + } > + if (FoundPath) continue; > + > + // Speculatively set edges to zero. > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE && !FoundPath) { > + const BasicBlock *BB = *FI; ++FI; > + > + for (pred_const_iterator NBB = pred_begin(BB), End = > pred_end(BB); > + NBB != End; ++NBB) { > + Edge e = getEdge(*NBB,BB); > + double w = getEdgeWeight(e); > + if (w == MissingValue) { > + setEdgeWeight(e,0); > + FoundPath = true; > + break; > + } > + } > + } > + if (FoundPath) continue; > + > + errs() << "{"; > + FI = Unvisited.begin(), FE = Unvisited.end(); > + while(FI != FE) { > + const BasicBlock *BB = *FI; ++FI; > + errs() << BB->getName(); > + if (FI != FE) > + errs() << ","; > + } > + errs() << "}"; > + > + errs() << "ASSERT: could not repair function"; > + assert(0 && "could not repair function"); > + } > + > + EdgeWeights J = EdgeInformation[F]; > + for (EdgeWeights::iterator EI = J.begin(), EE = J.end(); EI != > EE; ++EI) { > + Edge e = EI->first; > + > + bool SuccFound = false; > + if (e.first != 0) { > + succ_const_iterator NBB = succ_begin(e.first), End = > succ_end(e.first); > + if (NBB == End) { > + if (0 == e.second) { > + SuccFound = true; > + } > + } > + for (;NBB != End; ++NBB) { > + if (*NBB == e.second) { > + SuccFound = true; > + break; > + } > + } > + if (!SuccFound) { > + removeEdge(e); > + } > + } > + } > +} > + > +raw_ostream& operator<<(raw_ostream &O, const Function *F) { > + return O << F->getName(); > +} > + > +raw_ostream& operator<<(raw_ostream &O, const MachineFunction *MF) { > + return O << MF->getFunction()->getName() << "(MF)"; > +} > + > +raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB) { > + return O << BB->getName(); > +} > + > +raw_ostream& operator<<(raw_ostream &O, const MachineBasicBlock > *MBB) { > + return O << MBB->getBasicBlock()->getName() << "(MB)"; > +} > + > +raw_ostream& operator<<(raw_ostream &O, std::pair *, const BasicBlock *> E) { > + O << "("; > + > + if (E.first) > + O << E.first; > + else > + O << "0"; > + > + O << ","; > + > + if (E.second) > + O << E.second; > + else > + O << "0"; > + > + return O << ")"; > +} > + > +raw_ostream& operator<<(raw_ostream &O, std::pair MachineBasicBlock *, const MachineBasicBlock *> E) { > O << "("; > - O << (E.first ? E.first->getNameStr() : "0"); > + > + if (E.first) > + O << E.first; > + else > + O << "0"; > + > O << ","; > - O << (E.second ? E.second->getNameStr() : "0"); > + > + if (E.second) > + O << E.second; > + else > + O << "0"; > + > return O << ")"; > } > > +} // namespace llvm > + > // > = > = > = > ----------------------------------------------------------------------= > ==// > // NoProfile ProfileInfo implementation > // > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Thu Dec 3 13:03:18 2009 From: gohman at apple.com (Dan Gohman) Date: Thu, 03 Dec 2009 19:03:18 -0000 Subject: [llvm-commits] [llvm] r90473 - /llvm/trunk/lib/Support/CommandLine.cpp Message-ID: <200912031903.nB3J3IIn026112@zion.cs.uiuc.edu> Author: djg Date: Thu Dec 3 13:03:18 2009 New Revision: 90473 URL: http://llvm.org/viewvc/llvm-project?rev=90473&view=rev Log: Print a newline after the Args: line so that unrelated errs() output doesn't end up on the same line. Modified: llvm/trunk/lib/Support/CommandLine.cpp Modified: llvm/trunk/lib/Support/CommandLine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=90473&r1=90472&r2=90473&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Thu Dec 3 13:03:18 2009 @@ -778,9 +778,10 @@ free(*i); } - DEBUG(errs() << "\nArgs: "; + DEBUG(errs() << "Args: "; for (int i = 0; i < argc; ++i) errs() << argv[i] << ' '; + errs() << '\n'; ); // If we had an error processing our arguments, don't let the program execute From dpatel at apple.com Thu Dec 3 13:11:07 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Dec 2009 19:11:07 -0000 Subject: [llvm-commits] [llvm] r90474 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h Message-ID: <200912031911.nB3JB7Yc026381@zion.cs.uiuc.edu> Author: dpatel Date: Thu Dec 3 13:11:07 2009 New Revision: 90474 URL: http://llvm.org/viewvc/llvm-project?rev=90474&view=rev Log: Add support to emit debug info for virtual functions and virtual base classes. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=90474&r1=90473&r2=90474&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Thu Dec 3 13:11:07 2009 @@ -197,7 +197,8 @@ FlagProtected = 1 << 1, FlagFwdDecl = 1 << 2, FlagAppleBlock = 1 << 3, - FlagBlockByrefStruct = 1 << 4 + FlagBlockByrefStruct = 1 << 4, + FlagVirtual = 1 << 5 }; protected: @@ -242,6 +243,9 @@ bool isBlockByrefStruct() const { return (getFlags() & FlagBlockByrefStruct) != 0; } + bool isVirtual() const { + return (getFlags() & FlagVirtual) != 0; + } /// dump - print type. void dump() const; @@ -366,6 +370,24 @@ /// compile unit, like 'static' in C. unsigned isLocalToUnit() const { return getUnsignedField(9); } unsigned isDefinition() const { return getUnsignedField(10); } + + unsigned getVirtuality() const { + if (DbgNode->getNumElements() < 14) + return 0; + return getUnsignedField(11); + } + + unsigned getVirtualIndex() const { + if (DbgNode->getNumElements() < 14) + return 0; + return getUnsignedField(12); + } + + DICompositeType getContainingType() const { + assert (DbgNode->getNumElements() >= 14 && "Invalid type!"); + return getFieldAs(13); + } + StringRef getFilename() const { return getCompileUnit().getFilename();} StringRef getDirectory() const { return getCompileUnit().getDirectory();} @@ -565,7 +587,10 @@ StringRef LinkageName, DICompileUnit CompileUnit, unsigned LineNo, DIType Type, bool isLocalToUnit, - bool isDefinition); + bool isDefinition, + unsigned VK = 0, + unsigned VIndex = 0, + DIType = DIType()); /// CreateSubprogramDefinition - Create new subprogram descriptor for the /// given declaration. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=90474&r1=90473&r2=90474&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Thu Dec 3 13:11:07 2009 @@ -866,7 +866,9 @@ DICompileUnit CompileUnit, unsigned LineNo, DIType Type, bool isLocalToUnit, - bool isDefinition) { + bool isDefinition, + unsigned VK, unsigned VIndex, + DIType ContainingType) { Value *Elts[] = { GetTagConstant(dwarf::DW_TAG_subprogram), @@ -879,9 +881,12 @@ ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), Type.getNode(), ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), - ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition) + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK), + ConstantInt::get(Type::getInt32Ty(VMContext), VIndex), + ContainingType.getNode() }; - return DISubprogram(MDNode::get(VMContext, &Elts[0], 11)); + return DISubprogram(MDNode::get(VMContext, &Elts[0], 14)); } /// CreateSubprogramDefinition - Create new subprogram descriptor for the @@ -902,9 +907,12 @@ DeclNode->getElement(7), // LineNo DeclNode->getElement(8), // Type DeclNode->getElement(9), // isLocalToUnit - ConstantInt::get(Type::getInt1Ty(VMContext), true) + ConstantInt::get(Type::getInt1Ty(VMContext), true), + DeclNode->getElement(11), // Virtuality + DeclNode->getElement(12), // VIndex + DeclNode->getElement(13) // Containting Type }; - return DISubprogram(MDNode::get(VMContext, &Elts[0], 11)); + return DISubprogram(MDNode::get(VMContext, &Elts[0], 14)); } /// CreateGlobalVariable - Create a new descriptor for the specified global. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=90474&r1=90473&r2=90474&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Dec 3 13:11:07 2009 @@ -779,6 +779,7 @@ DW_Unit->addDie(Buffer); Entry->setEntry(Buffer); Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry); + ModuleCU->insertDIE(Ty.getNode(), Buffer); } /// constructTypeDIE - Construct basic type die from DIBasicType. @@ -1073,12 +1074,17 @@ addBlock(MemberDie, dwarf::DW_AT_data_member_location, 0, MemLocationDie); if (DT.isProtected()) - addUInt(MemberDie, dwarf::DW_AT_accessibility, 0, + addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_flag, dwarf::DW_ACCESS_protected); else if (DT.isPrivate()) - addUInt(MemberDie, dwarf::DW_AT_accessibility, 0, + addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_flag, dwarf::DW_ACCESS_private); - + else if (DT.getTag() == dwarf::DW_TAG_inheritance) + addUInt(MemberDie, dwarf::DW_AT_accessibility, dwarf::DW_FORM_flag, + dwarf::DW_ACCESS_public); + if (DT.isVirtual()) + addUInt(MemberDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_flag, + dwarf::DW_VIRTUALITY_virtual); return MemberDie; } @@ -1113,11 +1119,22 @@ DICompositeType SPTy = SP.getType(); DIArray Args = SPTy.getTypeArray(); unsigned SPTag = SPTy.getTag(); + if (Args.isNull() || SPTag != dwarf::DW_TAG_subroutine_type) addType(DW_Unit, SPDie, SPTy); else addType(DW_Unit, SPDie, DIType(Args.getElement(0).getNode())); + unsigned VK = SP.getVirtuality(); + if (VK) { + addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_flag, VK); + DIEBlock *Block = new DIEBlock(); + addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_constu); + addUInt(Block, 0, dwarf::DW_FORM_data1, SP.getVirtualIndex()); + addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block); + ContainingTypeMap.insert(std::make_pair(SPDie, WeakVH(SP.getContainingType().getNode()))); + } + return SPDie; } @@ -1826,6 +1843,17 @@ TE = TopLevelDIEsVector.end(); TI != TE; ++TI) ModuleCU->getCUDie()->addChild(*TI); + for (DenseMap::iterator CI = ContainingTypeMap.begin(), + CE = ContainingTypeMap.end(); CI != CE; ++CI) { + DIE *SPDie = CI->first; + MDNode *N = dyn_cast_or_null(CI->second); + if (!N) continue; + DIE *NDie = ModuleCU->getDIE(N); + if (!NDie) continue; + addDIEEntry(SPDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); + addDIEEntry(NDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); + } + // Standard sections final addresses. Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getTextSection()); EmitLabel("text_end", 0); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=90474&r1=90473&r2=90474&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Dec 3 13:11:07 2009 @@ -154,6 +154,8 @@ /// (at the end of the module) as DW_AT_inline. SmallPtrSet InlinedSubprogramDIEs; + DenseMap ContainingTypeMap; + /// AbstractSubprogramDIEs - Collection of abstruct subprogram DIEs. SmallPtrSet AbstractSubprogramDIEs; From dpatel at apple.com Thu Dec 3 13:14:05 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Dec 2009 19:14:05 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90475 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <200912031914.nB3JE5w6026477@zion.cs.uiuc.edu> Author: dpatel Date: Thu Dec 3 13:14:04 2009 New Revision: 90475 URL: http://llvm.org/viewvc/llvm-project?rev=90475&view=rev Log: Emit debug info for virtual functions and virtual base classes. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=90475&r1=90474&r2=90475&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Dec 3 13:14:04 2009 @@ -255,7 +255,14 @@ unsigned lineno = CurLineNo; if (isCopyOrDestroyHelper(FnDecl)) lineno = 0; - + + unsigned Virtuality = 0; + unsigned VIndex = 0; + DIType ContainingType; + if (DECL_VINDEX (FnDecl)) { + Virtuality = dwarf::DW_VIRTUALITY_virtual; + ContainingType = getOrCreateType(DECL_CONTEXT (FnDecl)); + } DISubprogram SP = DebugFactory.CreateSubprogram(findRegion(FnDecl), lang_hooks.dwarf_name(FnDecl, 0), @@ -264,7 +271,9 @@ getOrCreateCompileUnit(Loc.file), lineno, FNType, Fn->hasInternalLinkage(), - true /*definition*/); + true /*definition*/, + Virtuality, VIndex, ContainingType); + SPCache[FnDecl] = WeakVH(SP.getNode()); @@ -714,18 +723,30 @@ llvm::SmallVector EltTys; if (tree binfo = TYPE_BINFO(type)) { + VEC(tree,gc) *accesses = BINFO_BASE_ACCESSES (binfo); + for (unsigned i = 0, e = BINFO_N_BASE_BINFOS(binfo); i != e; ++i) { tree BInfo = BINFO_BASE_BINFO(binfo, i); tree BInfoType = BINFO_TYPE (BInfo); DIType BaseClass = getOrCreateType(BInfoType); - + unsigned Flags = 0; + if (BINFO_VIRTUAL_P (BInfo)) + Flags = llvm::DIType::FlagVirtual; + if (accesses) { + tree access = VEC_index (tree, accesses, i); + if (access == access_protected_node) + Flags |= llvm::DIType::FlagProtected; + else if (access == access_private_node) + Flags |= llvm::DIType::FlagPrivate; + } + // FIXME : name, size, align etc... DIType DTy = DebugFactory.CreateDerivedType(DW_TAG_inheritance, findRegion(type), StringRef(), llvm::DICompileUnit(), 0,0,0, - getINTEGER_CSTVal(BINFO_OFFSET(BInfo)), - 0, BaseClass); + getINTEGER_CSTVal(BINFO_OFFSET(BInfo))*8, + Flags, BaseClass); EltTys.push_back(DTy); } } @@ -793,11 +814,19 @@ const char *MemberName = lang_hooks.dwarf_name(Member, 0); StringRef LinkageName = getLinkageName(Member); DIType SPTy = getOrCreateType(TREE_TYPE(Member)); + unsigned Virtuality = 0; + unsigned VIndex = 0; + DIType ContainingType; + if (DECL_VINDEX (Member)) { + Virtuality = dwarf::DW_VIRTUALITY_virtual; + ContainingType = getOrCreateType(DECL_CONTEXT(Member)); + } DISubprogram SP = DebugFactory.CreateSubprogram(findRegion(Member), MemberName, MemberName, LinkageName, getOrCreateCompileUnit(MemLoc.file), - MemLoc.line, SPTy, false, false); + MemLoc.line, SPTy, false, false, + Virtuality, VIndex, ContainingType); EltTys.push_back(SP); SPCache[Member] = WeakVH(SP.getNode()); } From stoklund at 2pi.dk Thu Dec 3 14:49:11 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 03 Dec 2009 20:49:11 -0000 Subject: [llvm-commits] [llvm] r90481 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <200912032049.nB3KnBou030187@zion.cs.uiuc.edu> Author: stoklund Date: Thu Dec 3 14:49:10 2009 New Revision: 90481 URL: http://llvm.org/viewvc/llvm-project?rev=90481&view=rev Log: Clean up some loop logic. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=90481&r1=90480&r2=90481&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Dec 3 14:49:10 2009 @@ -159,12 +159,10 @@ end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); index != end; index = index.getNextIndex()) { - // skip deleted instructions - while (index != end && !getInstructionFromIndex(index)) - index = index.getNextIndex(); - if (index == end) break; - MachineInstr *MI = getInstructionFromIndex(index); + if (!MI) + continue; // skip deleted instructions + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg)) if (SrcReg == li.reg || DstReg == li.reg) @@ -201,15 +199,9 @@ end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); index != end; index = index.getNextIndex()) { - // Skip deleted instructions. - MachineInstr *MI = 0; - while (index != end) { - MI = getInstructionFromIndex(index); - if (MI) - break; - index = index.getNextIndex(); - } - if (index == end) break; + MachineInstr *MI = getInstructionFromIndex(index); + if (!MI) + continue; // skip deleted instructions if (JoinedCopies.count(MI)) continue; From baldrick at free.fr Thu Dec 3 15:37:32 2009 From: baldrick at free.fr (Duncan Sands) Date: Thu, 03 Dec 2009 21:37:32 -0000 Subject: [llvm-commits] [llvm] r90482 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Message-ID: <200912032137.nB3LbWYs031658@zion.cs.uiuc.edu> Author: baldrick Date: Thu Dec 3 15:37:32 2009 New Revision: 90482 URL: http://llvm.org/viewvc/llvm-project?rev=90482&view=rev Log: Fix ExpandShiftWithUnknownAmountBit, which was completely bogus. Pointed out by Javier Martinez (who also provided a patch). Since this logic is not used on (for example) x86, I guess nobody noticed. Tested by generating SHL, SRL, SRA on various choices of i64 for all possible shift amounts, and comparing with gcc. Since I did this on x86-32, I had to force the use of ExpandShiftWithUnknownAmountBit. What I'm saying here is that I don't have a testcase I can add to the repository. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=90482&r1=90481&r2=90482&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Thu Dec 3 15:37:32 2009 @@ -1167,55 +1167,56 @@ GetExpandedInteger(N->getOperand(0), InL, InH); SDValue NVBitsNode = DAG.getConstant(NVTBits, ShTy); - SDValue Amt2 = DAG.getNode(ISD::SUB, dl, ShTy, NVBitsNode, Amt); - SDValue Cmp = DAG.getSetCC(dl, TLI.getSetCCResultType(ShTy), - Amt, NVBitsNode, ISD::SETULT); + SDValue AmtExcess = DAG.getNode(ISD::SUB, dl, ShTy, Amt, NVBitsNode); + SDValue AmtLack = DAG.getNode(ISD::SUB, dl, ShTy, NVBitsNode, Amt); + SDValue isShort = DAG.getSetCC(dl, TLI.getSetCCResultType(ShTy), + Amt, NVBitsNode, ISD::SETULT); - SDValue Lo1, Hi1, Lo2, Hi2; + SDValue LoS, HiS, LoL, HiL; switch (N->getOpcode()) { default: llvm_unreachable("Unknown shift"); case ISD::SHL: - // ShAmt < NVTBits - Lo1 = DAG.getConstant(0, NVT); // Low part is zero. - Hi1 = DAG.getNode(ISD::SHL, dl, NVT, InL, Amt); // High part from Lo part. - - // ShAmt >= NVTBits - Lo2 = DAG.getNode(ISD::SHL, dl, NVT, InL, Amt); - Hi2 = DAG.getNode(ISD::OR, dl, NVT, + // Short: ShAmt < NVTBits + LoS = DAG.getNode(ISD::SHL, dl, NVT, InL, Amt); + HiS = DAG.getNode(ISD::OR, dl, NVT, DAG.getNode(ISD::SHL, dl, NVT, InH, Amt), - DAG.getNode(ISD::SRL, dl, NVT, InL, Amt2)); + DAG.getNode(ISD::SRL, dl, NVT, InL, AmtLack)); - Lo = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Lo1, Lo2); - Hi = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Hi1, Hi2); + // Long: ShAmt >= NVTBits + LoL = DAG.getConstant(0, NVT); // Lo part is zero. + HiL = DAG.getNode(ISD::SHL, dl, NVT, InL, AmtExcess); // Hi from Lo part. + + Lo = DAG.getNode(ISD::SELECT, dl, NVT, isShort, LoS, LoL); + Hi = DAG.getNode(ISD::SELECT, dl, NVT, isShort, HiS, HiL); return true; case ISD::SRL: - // ShAmt < NVTBits - Hi1 = DAG.getConstant(0, NVT); // Hi part is zero. - Lo1 = DAG.getNode(ISD::SRL, dl, NVT, InH, Amt); // Lo part from Hi part. - - // ShAmt >= NVTBits - Hi2 = DAG.getNode(ISD::SRL, dl, NVT, InH, Amt); - Lo2 = DAG.getNode(ISD::OR, dl, NVT, - DAG.getNode(ISD::SRL, dl, NVT, InL, Amt), - DAG.getNode(ISD::SHL, dl, NVT, InH, Amt2)); + // Short: ShAmt < NVTBits + HiS = DAG.getNode(ISD::SRL, dl, NVT, InH, Amt); + LoS = DAG.getNode(ISD::OR, dl, NVT, + DAG.getNode(ISD::SRL, dl, NVT, InL, Amt), + DAG.getNode(ISD::SHL, dl, NVT, InH, AmtLack)); - Lo = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Lo1, Lo2); - Hi = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Hi1, Hi2); + // Long: ShAmt >= NVTBits + HiL = DAG.getConstant(0, NVT); // Hi part is zero. + LoL = DAG.getNode(ISD::SRL, dl, NVT, InH, AmtExcess); // Lo from Hi part. + + Lo = DAG.getNode(ISD::SELECT, dl, NVT, isShort, LoS, LoL); + Hi = DAG.getNode(ISD::SELECT, dl, NVT, isShort, HiS, HiL); return true; case ISD::SRA: - // ShAmt < NVTBits - Hi1 = DAG.getNode(ISD::SRA, dl, NVT, InH, // Sign extend high part. - DAG.getConstant(NVTBits-1, ShTy)); - Lo1 = DAG.getNode(ISD::SRA, dl, NVT, InH, Amt); // Lo part from Hi part. - - // ShAmt >= NVTBits - Hi2 = DAG.getNode(ISD::SRA, dl, NVT, InH, Amt); - Lo2 = DAG.getNode(ISD::OR, dl, NVT, + // Short: ShAmt < NVTBits + HiS = DAG.getNode(ISD::SRA, dl, NVT, InH, Amt); + LoS = DAG.getNode(ISD::OR, dl, NVT, DAG.getNode(ISD::SRL, dl, NVT, InL, Amt), - DAG.getNode(ISD::SHL, dl, NVT, InH, Amt2)); + DAG.getNode(ISD::SHL, dl, NVT, InH, AmtLack)); + + // Long: ShAmt >= NVTBits + HiL = DAG.getNode(ISD::SRA, dl, NVT, InH, // Sign of Hi part. + DAG.getConstant(NVTBits-1, ShTy)); + LoL = DAG.getNode(ISD::SRA, dl, NVT, InH, AmtExcess); // Lo from Hi part. - Lo = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Lo1, Lo2); - Hi = DAG.getNode(ISD::SELECT, dl, NVT, Cmp, Hi1, Hi2); + Lo = DAG.getNode(ISD::SELECT, dl, NVT, isShort, LoS, LoL); + Hi = DAG.getNode(ISD::SELECT, dl, NVT, isShort, HiS, HiL); return true; } From bob.wilson at apple.com Thu Dec 3 15:47:08 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 03 Dec 2009 21:47:08 -0000 Subject: [llvm-commits] [llvm] r90487 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <200912032147.nB3Ll8Be031992@zion.cs.uiuc.edu> Author: bwilson Date: Thu Dec 3 15:47:07 2009 New Revision: 90487 URL: http://llvm.org/viewvc/llvm-project?rev=90487&view=rev Log: Fix a comment typo. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=90487&r1=90486&r2=90487&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Dec 3 15:47:07 2009 @@ -563,7 +563,7 @@ return false; } -/// OptimizeMemoryInst - Load and Store Instructions have often have +/// OptimizeMemoryInst - Load and Store Instructions often have /// addressing modes that can do significant amounts of computation. As such, /// instruction selection will try to get the load or store to do as much /// computation as possible for the program. The problem is that isel can only From evan.cheng at apple.com Thu Dec 3 15:50:58 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 03 Dec 2009 21:50:58 -0000 Subject: [llvm-commits] [llvm] r90488 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> Author: evancheng Date: Thu Dec 3 15:50:58 2009 New Revision: 90488 URL: http://llvm.org/viewvc/llvm-project?rev=90488&view=rev Log: Watch out for PHI instruction with no source operands. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90488&r1=90487&r2=90488&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Thu Dec 3 15:50:58 2009 @@ -1064,6 +1064,8 @@ unsigned MachineInstr::isConstantValuePHI() const { if (getOpcode() != TargetInstrInfo::PHI) return 0; + if (getNumOperands() <= 1) + return 0; unsigned Reg = getOperand(1).getReg(); for (unsigned i = 3, e = getNumOperands(); i < e; i += 2) From evan.cheng at apple.com Thu Dec 3 15:51:55 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 03 Dec 2009 21:51:55 -0000 Subject: [llvm-commits] [llvm] r90489 - /llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912032151.nB3Lptqs032173@zion.cs.uiuc.edu> Author: evancheng Date: Thu Dec 3 15:51:55 2009 New Revision: 90489 URL: http://llvm.org/viewvc/llvm-project?rev=90489&view=rev Log: Handle undef values properly. Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90489&r1=90488&r2=90489&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Thu Dec 3 15:51:55 2009 @@ -85,15 +85,16 @@ return GetValueAtEndOfBlockInternal(BB); } -/// InsertNewPHI - Insert an empty PHI instruction which define a value of the -/// given register class at the start of the specified basic block. It returns -/// the virtual register defined by the PHI instruction. +/// InsertNewDef - Insert an empty PHI or IMPLICIT_DEF instruction which define +/// a value of the given register class at the start of the specified basic +/// block. It returns the virtual register defined by the instruction. static -MachineInstr *InsertNewPHI(MachineBasicBlock *BB, const TargetRegisterClass *RC, - MachineRegisterInfo *MRI, const TargetInstrInfo *TII) { +MachineInstr *InsertNewDef(unsigned Opcode, + MachineBasicBlock *BB, MachineBasicBlock::iterator I, + const TargetRegisterClass *RC, + MachineRegisterInfo *MRI, const TargetInstrInfo *TII) { unsigned NewVR = MRI->createVirtualRegister(RC); - return BuildMI(*BB, BB->front(), BB->front().getDebugLoc(), - TII->get(TargetInstrInfo::PHI), NewVR); + return BuildMI(*BB, I, I->getDebugLoc(), TII->get(Opcode), NewVR); } @@ -122,8 +123,9 @@ if (!getAvailableVals(AV).count(BB)) return GetValueAtEndOfBlock(BB); - if (BB->pred_empty()) - llvm_unreachable("Unreachable block!"); + // If there are no predecessors, just return undef. + if (BB->pred_empty()) + return ~0U; // Sentinel value representing undef. // Otherwise, we have the hard case. Get the live-in values for each // predecessor. @@ -150,7 +152,8 @@ return SingularValue; // Otherwise, we do need a PHI: insert one now. - MachineInstr *InsertedPHI = InsertNewPHI(BB, VRC, MRI, TII); + MachineInstr *InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, + BB->front(), VRC, MRI, TII); // Fill in all the predecessors of the PHI. MachineInstrBuilder MIB(InsertedPHI); @@ -195,6 +198,13 @@ NewVR = GetValueInMiddleOfBlock(UseMI->getParent()); } + if (NewVR == ~0U) { + // Insert an implicit_def to represent an undef value. + MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, + UseMI->getParent(), UseMI, VRC,MRI,TII); + NewVR = NewDef->getOperand(0).getReg(); + } + U.setReg(NewVR); } @@ -223,14 +233,18 @@ // that we have a cycle. Handle this by inserting a PHI node and returning // it. When we get back to the first instance of the recursion we will fill // in the PHI node. - MachineInstr *NewPHI = InsertNewPHI(BB, VRC, MRI, TII); + MachineInstr *NewPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(), + VRC, MRI,TII); unsigned NewVR = NewPHI->getOperand(0).getReg(); InsertRes.first->second = NewVR; return NewVR; } + // If there are no predecessors, then we must have found an unreachable block + // just return 'undef'. Since there are no predecessors, InsertRes must not + // be invalidated. if (BB->pred_empty()) - llvm_unreachable("Unreachable block!"); + return InsertRes.first->second = ~0U; // Sentinel value representing undef. // Okay, the value isn't in the map and we just inserted a null in the entry // to indicate that we're processing the block. Since we have no idea what @@ -294,18 +308,24 @@ // Otherwise, we do need a PHI: insert one now if we don't already have one. MachineInstr *InsertedPHI; if (InsertedVal == 0) { - InsertedPHI = InsertNewPHI(BB, VRC, MRI, TII); + InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(), + VRC, MRI, TII); InsertedVal = InsertedPHI->getOperand(0).getReg(); } else { InsertedPHI = MRI->getVRegDef(InsertedVal); } // Fill in all the predecessors of the PHI. + bool IsUndef = true; MachineInstrBuilder MIB(InsertedPHI); for (IncomingPredInfoTy::iterator I = IncomingPredInfo.begin()+FirstPredInfoEntry, - E = IncomingPredInfo.end(); I != E; ++I) + E = IncomingPredInfo.end(); I != E; ++I) { + if (I->second == ~0U) + continue; + IsUndef = false; MIB.addReg(I->second).addMBB(I->first); + } // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, @@ -313,7 +333,10 @@ // See if the PHI node can be merged to a single value. This can happen in // loop cases when we get a PHI of itself and one other value. - if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { + if (IsUndef) { + InsertedPHI->eraseFromParent(); + InsertedVal = ~0U; + } else if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { MRI->replaceRegWith(InsertedVal, ConstVal); InsertedPHI->eraseFromParent(); InsertedVal = ConstVal; From grosbach at apple.com Thu Dec 3 15:55:02 2009 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 03 Dec 2009 21:55:02 -0000 Subject: [llvm-commits] [llvm] r90490 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <200912032155.nB3Lt2vk032293@zion.cs.uiuc.edu> Author: grosbach Date: Thu Dec 3 15:55:01 2009 New Revision: 90490 URL: http://llvm.org/viewvc/llvm-project?rev=90490&view=rev Log: remove out of date FIXME. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=90490&r1=90489&r2=90490&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Thu Dec 3 15:55:01 2009 @@ -759,7 +759,6 @@ assert((RC == ARM::QPRRegisterClass || RC == ARM::QPR_VFP2RegisterClass || RC == ARM::QPR_8RegisterClass) && "Unknown regclass!"); - // FIXME: Neon instructions should support predicates if (Align >= 16 && (getRegisterInfo().needsStackRealignment(MF))) { AddDefaultPred(BuildMI(MBB, I, DL, get(ARM::VLD1q64), DestReg) From clattner at apple.com Thu Dec 3 16:01:43 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 3 Dec 2009 14:01:43 -0800 Subject: [llvm-commits] [llvm] r90488 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp In-Reply-To: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> References: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> Message-ID: On Dec 3, 2009, at 1:50 PM, Evan Cheng wrote: > Author: evancheng > Date: Thu Dec 3 15:50:58 2009 > New Revision: 90488 > > URL: http://llvm.org/viewvc/llvm-project?rev=90488&view=rev > Log: > Watch out for PHI instruction with no source operands. These aren't valid at the LLVM IR level, are they allowed at MI level? What pass is creating them? -Chris > > Modified: > llvm/trunk/lib/CodeGen/MachineInstr.cpp > > Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90488&r1=90487&r2=90488&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Thu Dec 3 15:50:58 2009 > @@ -1064,6 +1064,8 @@ > unsigned MachineInstr::isConstantValuePHI() const { > if (getOpcode() != TargetInstrInfo::PHI) > return 0; > + if (getNumOperands() <= 1) > + return 0; > > unsigned Reg = getOperand(1).getReg(); > for (unsigned i = 3, e = getNumOperands(); i < e; i += 2) > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Thu Dec 3 16:55:45 2009 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 03 Dec 2009 22:55:45 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90495 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Message-ID: <200912032255.nB3MtjgW001940@zion.cs.uiuc.edu> Author: void Date: Thu Dec 3 16:55:45 2009 New Revision: 90495 URL: http://llvm.org/viewvc/llvm-project?rev=90495&view=rev Log: Temporarily ignore the '-g' flag on PPC. We're not generating debug info for it at this time. Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h?rev=90495&r1=90494&r2=90495&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Thu Dec 3 16:55:45 2009 @@ -117,7 +117,8 @@ "/* LLVM LOCAL ignore -g in LTO mode */"\ "/* On Darwin, debug info is stored in separate .dSYM files. */"\ "/* This requires special support in LTO mode. */" \ - %{O4|flto: % References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> <38a0d8450912020727r1cef56a8r462373f183957922@mail.gmail.com> Message-ID: <38a0d8450912031456t54efd76dyae13199fd96cc3b2@mail.gmail.com> Updated it again. Note that this is an option to clang, not clang-cc. It was not affected by the refactoring. I also uploaded the patch to http://codereview.appspot.com/165047 Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: no-canonical-prefixes.patch Type: text/x-diff Size: 2655 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091203/0237caf1/attachment.bin From evan.cheng at apple.com Thu Dec 3 17:02:13 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 3 Dec 2009 15:02:13 -0800 Subject: [llvm-commits] [llvm] r90488 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp In-Reply-To: References: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> Message-ID: On Dec 3, 2009, at 2:01 PM, Chris Lattner wrote: > > On Dec 3, 2009, at 1:50 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Thu Dec 3 15:50:58 2009 >> New Revision: 90488 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90488&view=rev >> Log: >> Watch out for PHI instruction with no source operands. > > These aren't valid at the LLVM IR level, are they allowed at MI level? What pass is creating them? They are not valid in MI level but could exist before the instruction is completely filled out. I don't want this function to trip over them. Evan > > -Chris > >> >> Modified: >> llvm/trunk/lib/CodeGen/MachineInstr.cpp >> >> Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90488&r1=90487&r2=90488&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) >> +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Thu Dec 3 15:50:58 2009 >> @@ -1064,6 +1064,8 @@ >> unsigned MachineInstr::isConstantValuePHI() const { >> if (getOpcode() != TargetInstrInfo::PHI) >> return 0; >> + if (getNumOperands() <= 1) >> + return 0; >> >> unsigned Reg = getOperand(1).getReg(); >> for (unsigned i = 3, e = getNumOperands(); i < e; i += 2) >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From vhernandez at apple.com Thu Dec 3 17:40:58 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Thu, 03 Dec 2009 23:40:58 -0000 Subject: [llvm-commits] [llvm] r90497 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h Message-ID: <200912032340.nB3Nex5D003399@zion.cs.uiuc.edu> Author: hernande Date: Thu Dec 3 17:40:58 2009 New Revision: 90497 URL: http://llvm.org/viewvc/llvm-project?rev=90497&view=rev Log: Add ParseInlineMetadata() which can parses metadata that refers to an instruction. Extend ParseParameterList() to use this new function so that calls to llvm.dbg.declare can pass inline metadata Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=90497&r1=90496&r2=90497&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Dec 3 17:40:58 2009 @@ -581,6 +581,37 @@ return false; } +/// ParseInlineMetadata: +/// !{type %instr} +/// !{...} MDNode +/// !"foo" MDString +bool LLParser::ParseInlineMetadata(Value *&V, PerFunctionState &PFS) { + assert(Lex.getKind() == lltok::Metadata && "Only for Metadata"); + V = 0; + + Lex.Lex(); + if (Lex.getKind() == lltok::lbrace) { + Lex.Lex(); + if (ParseTypeAndValue(V, PFS) || + ParseToken(lltok::rbrace, "expected end of metadata node")) + return true; + + Value *Vals[] = { V }; + V = MDNode::get(Context, Vals, 1); + return false; + } + + // Standalone metadata reference + // !{ ..., !42, ... } + if (!ParseMDNode((MetadataBase *&)V)) + return false; + + // MDString: + // '!' STRINGCONSTANT + if (ParseMDString((MetadataBase *&)V)) return true; + return false; +} + /// ParseAlias: /// ::= GlobalVar '=' OptionalVisibility 'alias' OptionalLinkage Aliasee /// Aliasee @@ -1377,15 +1408,23 @@ // Parse the argument. LocTy ArgLoc; PATypeHolder ArgTy(Type::getVoidTy(Context)); - unsigned ArgAttrs1, ArgAttrs2; + unsigned ArgAttrs1 = Attribute::None; + unsigned ArgAttrs2 = Attribute::None; Value *V; - if (ParseType(ArgTy, ArgLoc) || - ParseOptionalAttrs(ArgAttrs1, 0) || - ParseValue(ArgTy, V, PFS) || - // FIXME: Should not allow attributes after the argument, remove this in - // LLVM 3.0. - ParseOptionalAttrs(ArgAttrs2, 3)) + if (ParseType(ArgTy, ArgLoc)) return true; + + if (Lex.getKind() == lltok::Metadata) { + if (ParseInlineMetadata(V, PFS)) + return true; + } else { + if (ParseOptionalAttrs(ArgAttrs1, 0) || + ParseValue(ArgTy, V, PFS) || + // FIXME: Should not allow attributes after the argument, remove this + // in LLVM 3.0. + ParseOptionalAttrs(ArgAttrs2, 3)) + return true; + } ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2)); } Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=90497&r1=90496&r2=90497&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Thu Dec 3 17:40:58 2009 @@ -279,7 +279,9 @@ LocTy Loc; return ParseTypeAndBasicBlock(BB, Loc, PFS); } - + + bool ParseInlineMetadata(Value *&V, PerFunctionState &PFS); + struct ParamInfo { LocTy Loc; Value *V; From dpatel at apple.com Thu Dec 3 17:46:58 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 03 Dec 2009 23:46:58 -0000 Subject: [llvm-commits] [llvm] r90498 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200912032346.nB3Nkwlo003586@zion.cs.uiuc.edu> Author: dpatel Date: Thu Dec 3 17:46:57 2009 New Revision: 90498 URL: http://llvm.org/viewvc/llvm-project?rev=90498&view=rev Log: Insert composite type DIE into the map before processing type fields. This allows fields to find their context DIE from the map. 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=90498&r1=90497&r2=90498&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Dec 3 17:46:57 2009 @@ -758,6 +758,7 @@ // Construct type. DIE *Buffer = new DIE(dwarf::DW_TAG_base_type); + ModuleCU->insertDIE(Ty.getNode(), Buffer); if (Ty.isBasicType()) constructTypeDIE(DW_Unit, *Buffer, DIBasicType(Ty.getNode())); else if (Ty.isCompositeType()) @@ -779,7 +780,6 @@ DW_Unit->addDie(Buffer); Entry->setEntry(Buffer); Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry); - ModuleCU->insertDIE(Ty.getNode(), Buffer); } /// constructTypeDIE - Construct basic type die from DIBasicType. From evan.cheng at apple.com Thu Dec 3 18:09:06 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 04 Dec 2009 00:09:06 -0000 Subject: [llvm-commits] [llvm] r90501 - /llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912040009.nB40965V004352@zion.cs.uiuc.edu> Author: evancheng Date: Thu Dec 3 18:09:05 2009 New Revision: 90501 URL: http://llvm.org/viewvc/llvm-project?rev=90501&view=rev Log: - If the reaching definition is an undef and the use is a PHI, add the implicit_def to the end of the source block. - When reaching value is replaced with another, update the cache as well. Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90501&r1=90500&r2=90501&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Thu Dec 3 18:09:05 2009 @@ -194,17 +194,22 @@ if (UseMI->getOpcode() == TargetInstrInfo::PHI) { MachineBasicBlock *SourceBB = findCorrespondingPred(UseMI, &U); NewVR = GetValueAtEndOfBlock(SourceBB); - } else { - NewVR = GetValueInMiddleOfBlock(UseMI->getParent()); - } - - if (NewVR == ~0U) { // Insert an implicit_def to represent an undef value. MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, - UseMI->getParent(), UseMI, VRC,MRI,TII); + SourceBB,SourceBB->getFirstTerminator(), + VRC, MRI, TII); NewVR = NewDef->getOperand(0).getReg(); + } else { + NewVR = GetValueInMiddleOfBlock(UseMI->getParent()); + if (NewVR == ~0U) { + // Insert an implicit_def to represent an undef value. + MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, + UseMI->getParent(), UseMI, + VRC, MRI, TII); + NewVR = NewDef->getOperand(0).getReg(); + } } - + U.setReg(NewVR); } @@ -281,7 +286,7 @@ /// this block is involved in a loop, a no-entry PHI node will have been /// inserted as InsertedVal. Otherwise, we'll still have the null we inserted /// above. - unsigned InsertedVal = AvailableVals[BB]; + unsigned &InsertedVal = AvailableVals[BB]; // If all the predecessor values are the same then we don't need to insert a // PHI. This is the simple and common case. @@ -294,10 +299,10 @@ assert(InsertedVal != SingularValue && "Dead loop?"); MRI->replaceRegWith(InsertedVal, SingularValue); OldVal->eraseFromParent(); - } else { - InsertedVal = SingularValue; } + InsertedVal = SingularValue; + // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, IncomingPredInfo.end()); @@ -348,5 +353,4 @@ } return InsertedVal; - } From stoklund at 2pi.dk Thu Dec 3 18:16:04 2009 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 04 Dec 2009 00:16:04 -0000 Subject: [llvm-commits] [llvm] r90502 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/RegAllocLinearScan.cpp test/CodeGen/X86/2009-01-12-CoalescerBug.ll test/CodeGen/X86/twoaddr-coalesce.ll Message-ID: <200912040016.nB40G4dJ004565@zion.cs.uiuc.edu> Author: stoklund Date: Thu Dec 3 18:16:04 2009 New Revision: 90502 URL: http://llvm.org/viewvc/llvm-project?rev=90502&view=rev Log: Also attempt trivial coalescing for live intervals that end in a copy. The coalescer is supposed to clean these up, but when setting up parameters for a function call, there may be copies to physregs. If the defining instruction has been LICM'ed far away, the coalescer won't touch it. The register allocation hint does not always work - when the register allocator is backtracking, it clears the hints. This patch takes care of a few more cases that r90163 missed. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=90502&r1=90501&r2=90502&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Thu Dec 3 18:16:04 2009 @@ -117,6 +117,12 @@ bool conflictsWithPhysRegDef(const LiveInterval &li, VirtRegMap &vrm, unsigned reg); + /// conflictsWithPhysRegUse - Returns true if the specified register is used + /// or defined during the duration of the specified interval. Copies to and + /// from li.reg are allowed. + bool conflictsWithPhysRegUse(const LiveInterval &li, VirtRegMap &vrm, + unsigned reg); + /// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except /// it can check use as well. bool conflictsWithPhysRegRef(LiveInterval &li, unsigned Reg, Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=90502&r1=90501&r2=90502&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Dec 3 18:16:04 2009 @@ -157,19 +157,15 @@ I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { for (SlotIndex index = I->start.getBaseIndex(), end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); - index != end; - index = index.getNextIndex()) { + index != end; + index = index.getNextIndex()) { MachineInstr *MI = getInstructionFromIndex(index); if (!MI) continue; // skip deleted instructions - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; - if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg)) - if (SrcReg == li.reg || DstReg == li.reg) - continue; for (unsigned i = 0; i != MI->getNumOperands(); ++i) { MachineOperand& mop = MI->getOperand(i); - if (!mop.isReg()) + if (!mop.isReg() || mop.isUse()) continue; unsigned PhysReg = mop.getReg(); if (PhysReg == 0 || PhysReg == li.reg) @@ -188,6 +184,50 @@ return false; } +/// conflictsWithPhysRegUse - Returns true if the specified register is used or +/// defined during the duration of the specified interval. Copies to and from +/// li.reg are allowed. +bool LiveIntervals::conflictsWithPhysRegUse(const LiveInterval &li, + VirtRegMap &vrm, unsigned reg) { + for (LiveInterval::Ranges::const_iterator + I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { + for (SlotIndex index = I->start.getBaseIndex(), + end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); + index != end; + index = index.getNextIndex()) { + MachineInstr *MI = getInstructionFromIndex(index); + if (!MI) + continue; // skip deleted instructions + + // Terminators are considered conflicts since reg may be used at the + // destination. + if (MI->getDesc().isTerminator()) + return true; + + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand& mop = MI->getOperand(i); + if (!mop.isReg() || mop.isUndef()) + continue; + unsigned PhysReg = mop.getReg(); + if (PhysReg == 0 || PhysReg == li.reg) + continue; + if (TargetRegisterInfo::isVirtualRegister(PhysReg)) { + if (!vrm.hasPhys(PhysReg)) + continue; + PhysReg = vrm.getPhys(PhysReg); + } + if (PhysReg && tri_->regsOverlap(PhysReg, reg)) { + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (!tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) || + (SrcReg != li.reg && DstReg != li.reg)) + return true; + } + } + } + } + return false; +} + /// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except /// it can check use as well. bool LiveIntervals::conflictsWithPhysRegRef(LiveInterval &li, Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=90502&r1=90501&r2=90502&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Thu Dec 3 18:16:04 2009 @@ -390,66 +390,70 @@ RelatedRegClasses.unionSets(I->second, OneClassForEachPhysReg[*AS]); } -/// attemptTrivialCoalescing - If a simple interval is defined by a copy, -/// try allocate the definition the same register as the source register -/// if the register is not defined during live time of the interval. This -/// eliminate a copy. This is used to coalesce copies which were not -/// coalesced away before allocation either due to dest and src being in -/// different register classes or because the coalescer was overly -/// conservative. +/// attemptTrivialCoalescing - If a simple interval is defined by a copy, try +/// allocate the definition the same register as the source register if the +/// register is not defined during live time of the interval. If the interval is +/// killed by a copy, try to use the destination register. This eliminates a +/// copy. This is used to coalesce copies which were not coalesced away before +/// allocation either due to dest and src being in different register classes or +/// because the coalescer was overly conservative. unsigned RALinScan::attemptTrivialCoalescing(LiveInterval &cur, unsigned Reg) { unsigned Preference = vrm_->getRegAllocPref(cur.reg); if ((Preference && Preference == Reg) || !cur.containsOneValue()) return Reg; VNInfo *vni = cur.begin()->valno; - if ((vni->def == SlotIndex()) || - vni->isUnused() || !vni->isDefAccurate()) + if (vni->isUnused()) return Reg; - MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg, PhysReg; - if (!CopyMI || - !tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) - return Reg; - PhysReg = SrcReg; - if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { - if (!vrm_->isAssignedReg(SrcReg)) + unsigned CandReg; + bool forward; // extending physreg forward + { + MachineInstr *CopyMI; + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (vni->def != SlotIndex() && vni->isDefAccurate() && + (CopyMI = li_->getInstructionFromIndex(vni->def)) && + tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) + // Defined by a copy, try to extend SrcReg forward + CandReg = SrcReg, forward = true; + else if (cur.ranges.size()==1 && + (CopyMI = + li_->getInstructionFromIndex(cur.begin()->end.getBaseIndex())) && + tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg) && + cur.reg == SrcReg) + // Only used by a copy, try to extend DstReg backwards + CandReg = DstReg, forward = false; + else + return Reg; + } + + if (TargetRegisterInfo::isVirtualRegister(CandReg)) { + if (!vrm_->isAssignedReg(CandReg)) return Reg; - PhysReg = vrm_->getPhys(SrcReg); + CandReg = vrm_->getPhys(CandReg); } - if (Reg == PhysReg) + if (Reg == CandReg) return Reg; const TargetRegisterClass *RC = mri_->getRegClass(cur.reg); - if (!RC->contains(PhysReg)) + if (!RC->contains(CandReg)) return Reg; - // Try to coalesce. - if (!li_->conflictsWithPhysRegDef(cur, *vrm_, PhysReg)) { - DEBUG(errs() << "Coalescing: " << cur << " -> " << tri_->getName(PhysReg) - << '\n'); - vrm_->clearVirt(cur.reg); - vrm_->assignVirt2Phys(cur.reg, PhysReg); - - // Remove unnecessary kills since a copy does not clobber the register. - if (li_->hasInterval(SrcReg)) { - LiveInterval &SrcLI = li_->getInterval(SrcReg); - for (MachineRegisterInfo::use_iterator I = mri_->use_begin(cur.reg), - E = mri_->use_end(); I != E; ++I) { - MachineOperand &O = I.getOperand(); - if (!O.isKill()) - continue; - MachineInstr *MI = &*I; - if (SrcLI.liveAt(li_->getInstructionIndex(MI).getDefIndex())) - O.setIsKill(false); - } - } - - ++NumCoalesce; - return PhysReg; + if (forward) { + if (li_->conflictsWithPhysRegDef(cur, *vrm_, CandReg)) + return Reg; + } else { + if (li_->conflictsWithPhysRegUse(cur, *vrm_, CandReg)) + return Reg; } - return Reg; + // Try to coalesce. + DEBUG(errs() << "Coalescing: " << cur << " -> " << tri_->getName(CandReg) + << '\n'); + vrm_->clearVirt(cur.reg); + vrm_->assignVirt2Phys(cur.reg, CandReg); + + ++NumCoalesce; + return CandReg; } bool RALinScan::runOnMachineFunction(MachineFunction &fn) { Modified: llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll?rev=90502&r1=90501&r2=90502&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll Thu Dec 3 18:16:04 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | grep movq | count 2 +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | grep movq | count 1 ; PR3311 %struct.CUMULATIVE_ARGS = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } Modified: llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll?rev=90502&r1=90501&r2=90502&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll (original) +++ llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll Thu Dec 3 18:16:04 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 | grep mov | count 5 +; RUN: llc < %s -march=x86 | grep mov | count 4 ; rdar://6523745 @"\01LC" = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] From clattner at apple.com Thu Dec 3 18:56:13 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 3 Dec 2009 16:56:13 -0800 Subject: [llvm-commits] [llvm] r90488 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp In-Reply-To: References: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> Message-ID: On Dec 3, 2009, at 3:02 PM, Evan Cheng wrote: > > On Dec 3, 2009, at 2:01 PM, Chris Lattner wrote: > >> >> On Dec 3, 2009, at 1:50 PM, Evan Cheng wrote: >> >>> Author: evancheng >>> Date: Thu Dec 3 15:50:58 2009 >>> New Revision: 90488 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=90488&view=rev >>> Log: >>> Watch out for PHI instruction with no source operands. >> >> These aren't valid at the LLVM IR level, are they allowed at MI >> level? What pass is creating them? > > They are not valid in MI level but could exist before the > instruction is completely filled out. I don't want this function to > trip over them. The corresponding function at the IR level should abort on this, is MI level different? -Chris From clattner at apple.com Thu Dec 3 18:56:13 2009 From: clattner at apple.com (Chris Lattner) Date: Thu, 3 Dec 2009 16:56:13 -0800 Subject: [llvm-commits] [llvm] r90488 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp In-Reply-To: References: <200912032150.nB3LoxEH032123@zion.cs.uiuc.edu> Message-ID: On Dec 3, 2009, at 3:02 PM, Evan Cheng wrote: > > On Dec 3, 2009, at 2:01 PM, Chris Lattner wrote: > >> >> On Dec 3, 2009, at 1:50 PM, Evan Cheng wrote: >> >>> Author: evancheng >>> Date: Thu Dec 3 15:50:58 2009 >>> New Revision: 90488 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=90488&view=rev >>> Log: >>> Watch out for PHI instruction with no source operands. >> >> These aren't valid at the LLVM IR level, are they allowed at MI >> level? What pass is creating them? > > They are not valid in MI level but could exist before the > instruction is completely filled out. I don't want this function to > trip over them. The corresponding function at the IR level should abort on this, is MI level different? -Chris From sabre at nondot.org Thu Dec 3 19:03:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 04 Dec 2009 01:03:32 -0000 Subject: [llvm-commits] [llvm] r90507 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <200912040103.nB413WZI006369@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 19:03:32 2009 New Revision: 90507 URL: http://llvm.org/viewvc/llvm-project?rev=90507&view=rev Log: add an assert to make it really clear what this is doing. Return singularval as a compile time perf optimization to avoid a load. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=90507&r1=90506&r2=90507&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Dec 3 19:03:32 2009 @@ -295,10 +295,14 @@ InsertedVal = SingularValue; } + // Either path through the 'if' should have set insertedVal -> SingularVal. + assert((InsertedVal == SingularValue || isa(InsertedVal)) && + "RAUW didn't change InsertedVal to be SingularVal"); + // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, IncomingPredInfo.end()); - return InsertedVal; + return SingularValue; } // Otherwise, we do need a PHI: insert one now if we don't already have one. From mrs at apple.com Thu Dec 3 19:26:26 2009 From: mrs at apple.com (Mike Stump) Date: Fri, 04 Dec 2009 01:26:26 -0000 Subject: [llvm-commits] [llvm] r90508 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200912040126.nB41QQaq007158@zion.cs.uiuc.edu> Author: mrs Date: Thu Dec 3 19:26:26 2009 New Revision: 90508 URL: http://llvm.org/viewvc/llvm-project?rev=90508&view=rev Log: Add some helpers for Invoke to mirror CreateCall helpers. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=90508&r1=90507&r2=90508&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Dec 3 19:26:26 2009 @@ -269,6 +269,19 @@ return Insert(IndirectBrInst::Create(Addr, NumDests)); } + InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, + BasicBlock *UnwindDest, const Twine &Name = "") { + Value *Args[] = { 0 }; + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, + Args), Name); + } + InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, + BasicBlock *UnwindDest, Value *Arg1, + const Twine &Name = "") { + Value *Args[] = { Arg1 }; + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, + Args+1), Name); + } /// CreateInvoke - Create an invoke instruction. template InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, From bob.wilson at apple.com Thu Dec 3 19:33:04 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 04 Dec 2009 01:33:04 -0000 Subject: [llvm-commits] [llvm] r90511 - /llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Message-ID: <200912040133.nB41X4si007455@zion.cs.uiuc.edu> Author: bwilson Date: Thu Dec 3 19:33:04 2009 New Revision: 90511 URL: http://llvm.org/viewvc/llvm-project?rev=90511&view=rev Log: Fix a comment typo. Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=90511&r1=90510&r2=90511&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Thu Dec 3 19:33:04 2009 @@ -357,7 +357,7 @@ // without the other. SplitAddRecs(Ops, Ty, SE); - // Decend down the pointer's type and attempt to convert the other + // Descend down the pointer's type and attempt to convert the other // operands into GEP indices, at each level. The first index in a GEP // indexes into the array implied by the pointer operand; the rest of // the indices index into the element or field type selected by the From vhernandez at apple.com Thu Dec 3 19:35:02 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 04 Dec 2009 01:35:02 -0000 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> Author: hernande Date: Thu Dec 3 19:35:02 2009 New Revision: 90512 URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev Log: Teach AsmWriter to write inline (not via a global metadata slot) metadata that contains an instruction Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009 @@ -695,8 +695,13 @@ !I->hasName()) CreateFunctionSlot(I); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { + // Create a metadata slot only if N contains no instructions. + for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) + if (isa(N->getElement(n))) + continue; CreateMetadataSlot(N); + } // Process metadata attached with this instruction. MDs.clear(); @@ -1227,6 +1232,25 @@ } if (const MDNode *N = dyn_cast(V)) { + if (Machine->getMetadataSlot(N) == -1) { + // Print metadata inline, not via slot reference number. + Out << "!{"; + for (unsigned mi = 0, me = N->getNumElements(); mi != me; ++mi) { + const Value *Val = N->getElement(mi); + if (!Val) + Out << "null"; + else { + TypePrinter->print(N->getElement(0)->getType(), Out); + Out << ' '; + WriteAsOperandInternal(Out, N->getElement(0), TypePrinter, Machine); + } + if (mi + 1 != me) + Out << ", "; + } + Out << '}'; + return; + } + Out << '!' << Machine->getMetadataSlot(N); return; } From dpatel at apple.com Thu Dec 3 19:37:53 2009 From: dpatel at apple.com (Devang Patel) Date: Thu, 3 Dec 2009 17:37:53 -0800 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp In-Reply-To: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> References: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> Message-ID: <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> Hi Victor, On Dec 3, 2009, at 5:35 PM, Victor Hernandez wrote: > Author: hernande > Date: Thu Dec 3 19:35:02 2009 > New Revision: 90512 > > URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev > Log: > Teach AsmWriter to write inline (not via a global metadata slot) > metadata that contains an instruction > > Modified: > llvm/trunk/lib/VMCore/AsmWriter.cpp > > Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) > +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009 > @@ -695,8 +695,13 @@ > !I->hasName()) > CreateFunctionSlot(I); > for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) > - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) > + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { > + // Create a metadata slot only if N contains no > instructions. > + for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) > + if (isa(N->getElement(n))) > + continue; > CreateMetadataSlot(N); > + } > > // Process metadata attached with this instruction. > MDs.clear(); There are other places where CreateMetadataSlot() is used. Please move this check in side CreateMetadataSlot(). - Devang From mrs at apple.com Thu Dec 3 19:53:15 2009 From: mrs at apple.com (Mike Stump) Date: Fri, 04 Dec 2009 01:53:15 -0000 Subject: [llvm-commits] [llvm] r90514 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200912040153.nB41rFth008133@zion.cs.uiuc.edu> Author: mrs Date: Thu Dec 3 19:53:15 2009 New Revision: 90514 URL: http://llvm.org/viewvc/llvm-project?rev=90514&view=rev Log: Create yet another helper for Invoke. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=90514&r1=90513&r2=90514&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Dec 3 19:53:15 2009 @@ -282,6 +282,14 @@ return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, Args+1), Name); } + InvokeInst *CreateInvoke3(Value *Callee, BasicBlock *NormalDest, + BasicBlock *UnwindDest, Value *Arg1, + Value *Arg2, Value *Arg3, + const Twine &Name = "") { + Value *Args[] = { Arg1, Arg2, Arg3 }; + return Insert(InvokeInst::Create(Callee, NormalDest, UnwindDest, Args, + Args+3), Name); + } /// CreateInvoke - Create an invoke instruction. template InvokeInst *CreateInvoke(Value *Callee, BasicBlock *NormalDest, From sabre at nondot.org Thu Dec 3 20:10:17 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 04 Dec 2009 02:10:17 -0000 Subject: [llvm-commits] [llvm] r90518 - in /llvm/trunk: include/llvm/Analysis/PHITransAddr.h lib/Analysis/PHITransAddr.cpp Message-ID: <200912040210.nB42AHSC008812@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 20:10:16 2009 New Revision: 90518 URL: http://llvm.org/viewvc/llvm-project?rev=90518&view=rev Log: add the start of a class used to handle phi translation in memdep and gvn (this is just a skeleton so far). This will ultimately be used to fix a nasty miscompilation with GVN. Added: llvm/trunk/include/llvm/Analysis/PHITransAddr.h llvm/trunk/lib/Analysis/PHITransAddr.cpp Added: llvm/trunk/include/llvm/Analysis/PHITransAddr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/PHITransAddr.h?rev=90518&view=auto ============================================================================== --- llvm/trunk/include/llvm/Analysis/PHITransAddr.h (added) +++ llvm/trunk/include/llvm/Analysis/PHITransAddr.h Thu Dec 3 20:10:16 2009 @@ -0,0 +1,91 @@ +//===- PHITransAddr.h - PHI Translation for Addresses -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the PHITransAddr class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ANALYSIS_PHITRANSADDR_H +#define LLVM_ANALYSIS_PHITRANSADDR_H + +#include "llvm/Instruction.h" +#include "llvm/ADT/SmallVector.h" + +namespace llvm { + class DominatorTree; + class TargetData; + +/// PHITransAddr - An address value which tracks and handles phi translation. +/// As we walk "up" the CFG through predecessors, we need to ensure that the +/// address we're tracking is kept up to date. For example, if we're analyzing +/// an address of "&A[i]" and walk through the definition of 'i' which is a PHI +/// node, we *must* phi translate i to get "&A[j]" or else we will analyze an +/// incorrect pointer in the predecessor block. +/// +/// This is designed to be a relatively small object that lives on the stack and +/// is copyable. +/// +class PHITransAddr { + /// Addr - The actual address we're analyzing. + Value *Addr; + + /// InstInputs - The inputs for our symbolic address. + SmallVector InstInputs; +public: + PHITransAddr(Value *addr) : Addr(addr) { + // If the address is an instruction, the whole thing is considered an input. + if (Instruction *I = dyn_cast(Addr)) + InstInputs.push_back(I); + } + + /// NeedsPHITranslationFromBlock - Return true if moving from the specified + /// BasicBlock to its predecessors requires PHI translation. + bool NeedsPHITranslationFromBlock(BasicBlock *BB) const { + // We do need translation if one of our input instructions is defined in + // this block. + for (unsigned i = 0, e = InstInputs.size(); i != e; ++i) + if (InstInputs[i]->getParent() == BB) + return true; + return false; + } + + /// IsPHITranslatable - If this needs PHI translation, return true if we have + /// some hope of doing it. This should be used as a filter to avoid calling + /// GetPHITranslatedValue in hopeless situations. + bool IsPHITranslatable() const; + + /// GetPHITranslatedValue - Given a computation that satisfied the + /// isPHITranslatable predicate, see if we can translate the computation into + /// the specified predecessor block. If so, return that value, otherwise + /// return null. + Value *GetPHITranslatedValue(Value *InVal, BasicBlock *CurBB, + BasicBlock *Pred, const TargetData *TD) const; + + /// GetAvailablePHITranslatePointer - Return the value computed by + /// PHITranslatePointer if it dominates PredBB, otherwise return null. + Value *GetAvailablePHITranslatedValue(Value *V, + BasicBlock *CurBB, BasicBlock *PredBB, + const TargetData *TD, + const DominatorTree &DT) const; + + /// InsertPHITranslatedPointer - Insert a computation of the PHI translated + /// version of 'V' for the edge PredBB->CurBB into the end of the PredBB + /// block. All newly created instructions are added to the NewInsts list. + /// This returns null on failure. + /// + Value *InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB, + BasicBlock *PredBB, const TargetData *TD, + const DominatorTree &DT, + SmallVectorImpl &NewInsts) const; + +}; + +} // end namespace llvm + +#endif Added: llvm/trunk/lib/Analysis/PHITransAddr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/PHITransAddr.cpp?rev=90518&view=auto ============================================================================== --- llvm/trunk/lib/Analysis/PHITransAddr.cpp (added) +++ llvm/trunk/lib/Analysis/PHITransAddr.cpp Thu Dec 3 20:10:16 2009 @@ -0,0 +1,71 @@ +//===- PHITransAddr.cpp - PHI Translation for Addresses -------------------===// +// +// 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 PHITransAddr class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Analysis/PHITransAddr.h" +#include "llvm/Analysis/Dominators.h" +using namespace llvm; + +/// IsPHITranslatable - If this needs PHI translation, return true if we have +/// some hope of doing it. This should be used as a filter to avoid calling +/// GetPHITranslatedValue in hopeless situations. +bool PHITransAddr::IsPHITranslatable() const { + return true; // not a good filter. +} + +/// GetPHITranslatedValue - Given a computation that satisfied the +/// isPHITranslatable predicate, see if we can translate the computation into +/// the specified predecessor block. If so, return that value, otherwise +/// return null. +Value *PHITransAddr::GetPHITranslatedValue(Value *InVal, BasicBlock *CurBB, + BasicBlock *Pred, + const TargetData *TD) const { + // Not a great implementation. + return 0; +} + +/// GetAvailablePHITranslatePointer - Return the value computed by +/// PHITranslatePointer if it dominates PredBB, otherwise return null. +Value *PHITransAddr:: +GetAvailablePHITranslatedValue(Value *V, + BasicBlock *CurBB, BasicBlock *PredBB, + const TargetData *TD, + const DominatorTree &DT) const { + // See if PHI translation succeeds. + V = GetPHITranslatedValue(V, CurBB, PredBB, TD); + if (V == 0) return 0; + + // Make sure the value is live in the predecessor. + if (Instruction *Inst = dyn_cast_or_null(V)) + if (!DT.dominates(Inst->getParent(), PredBB)) + return 0; + return V; +} + +/// InsertPHITranslatedPointer - Insert a computation of the PHI translated +/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB +/// block. All newly created instructions are added to the NewInsts list. +/// This returns null on failure. +/// +Value *PHITransAddr:: +InsertPHITranslatedPointer(Value *InVal, BasicBlock *CurBB, + BasicBlock *PredBB, const TargetData *TD, + const DominatorTree &DT, + SmallVectorImpl &NewInsts) const { + // See if we have a version of this value already available and dominating + // PredBB. If so, there is no need to insert a new copy. + if (Value *Res = GetAvailablePHITranslatedValue(InVal, CurBB, PredBB, TD, DT)) + return Res; + + // Not a great implementation. + return 0; +} From sabre at nondot.org Thu Dec 3 20:12:12 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 04 Dec 2009 02:12:12 -0000 Subject: [llvm-commits] [llvm] r90520 - /llvm/trunk/test/Transforms/GVN/rle.ll Message-ID: <200912040212.nB42CCP3008921@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 20:12:12 2009 New Revision: 90520 URL: http://llvm.org/viewvc/llvm-project?rev=90520&view=rev Log: Small and carefully crafted testcase showing a miscompilation by GVN that I'm working on. This is manifesting as a miscompile of 255.vortex on some targets. No check lines yet because it fails. Modified: llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=90520&r1=90519&r2=90520&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Thu Dec 3 20:12:12 2009 @@ -280,3 +280,36 @@ } +declare i1 @cond() readonly +declare i1 @cond2() readonly + +define i32 @phi_trans2() { +entry: + %P = alloca i32, i32 400 + br label %F1 + +F1: + %A = phi i32 [1, %entry], [2, %F] + %cond2 = call i1 @cond() + br i1 %cond2, label %T1, label %TY + +T1: + %P2 = getelementptr i32* %P, i32 %A + %x = load i32* %P2 + %cond = call i1 @cond2() + br i1 %cond, label %TX, label %F + +F: + %P3 = getelementptr i32* %P, i32 2 + store i32 17, i32* %P3 + + store i32 42, i32* %P2 ; Provides "P[A]". + br label %F1 + +TX: + ret i32 %x ;; SHOULD NOT BE COMPILED TO 'ret i32 42'. +TY: + ret i32 0 +} + + From chandlerc at google.com Thu Dec 3 21:25:06 2009 From: chandlerc at google.com (Chandler Carruth) Date: Thu, 3 Dec 2009 19:25:06 -0800 Subject: [llvm-commits] [patch] Implement no-canonical-prefixes. In-Reply-To: <38a0d8450912031456t54efd76dyae13199fd96cc3b2@mail.gmail.com> References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> <38a0d8450912020727r1cef56a8r462373f183957922@mail.gmail.com> <38a0d8450912031456t54efd76dyae13199fd96cc3b2@mail.gmail.com> Message-ID: <74c447500912031925g359835darb90757eeaf21c206@mail.gmail.com> On Thu, Dec 3, 2009 at 2:56 PM, Rafael Espindola wrote: > Updated it again. > > Note that this is an option to clang, not clang-cc. It was not > affected by the refactoring. > > I also uploaded the patch to > http://codereview.appspot.com/165047 I published comments there. > > Cheers, > -- > Rafael ?vila de Esp?ndola > From sabre at nondot.org Thu Dec 3 22:15:37 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 04 Dec 2009 04:15:37 -0000 Subject: [llvm-commits] [llvm] r90539 - /llvm/trunk/lib/Analysis/CMakeLists.txt Message-ID: <200912040415.nB44FbRR013034@zion.cs.uiuc.edu> Author: lattner Date: Thu Dec 3 22:15:36 2009 New Revision: 90539 URL: http://llvm.org/viewvc/llvm-project?rev=90539&view=rev Log: add to cmake Modified: llvm/trunk/lib/Analysis/CMakeLists.txt Modified: llvm/trunk/lib/Analysis/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/CMakeLists.txt?rev=90539&r1=90538&r2=90539&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/CMakeLists.txt (original) +++ llvm/trunk/lib/Analysis/CMakeLists.txt Thu Dec 3 22:15:36 2009 @@ -27,6 +27,7 @@ LoopPass.cpp MemoryBuiltins.cpp MemoryDependenceAnalysis.cpp + PHITransAddr.cpp PointerTracking.cpp PostDominators.cpp ProfileEstimatorPass.cpp From sabre at nondot.org Fri Dec 4 00:29:30 2009 From: sabre at nondot.org (Chris Lattner) Date: Fri, 04 Dec 2009 06:29:30 -0000 Subject: [llvm-commits] [llvm] r90545 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/ConstProp/loads.ll Message-ID: <200912040629.nB46TUDk017638@zion.cs.uiuc.edu> Author: lattner Date: Fri Dec 4 00:29:29 2009 New Revision: 90545 URL: http://llvm.org/viewvc/llvm-project?rev=90545&view=rev Log: Fix PR5551 by not ignoring the top level constantexpr when folding a load from constant. Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/test/Transforms/ConstProp/loads.ll Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=90545&r1=90544&r2=90545&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Fri Dec 4 00:29:29 2009 @@ -432,7 +432,7 @@ // Instead of loading constant c string, use corresponding integer value // directly if string length is small enough. std::string Str; - if (TD && GetConstantStringInfo(CE->getOperand(0), Str) && !Str.empty()) { + if (TD && GetConstantStringInfo(CE, Str) && !Str.empty()) { unsigned StrLen = Str.length(); const Type *Ty = cast(CE->getType())->getElementType(); unsigned NumBits = Ty->getPrimitiveSizeInBits(); Modified: llvm/trunk/test/Transforms/ConstProp/loads.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/loads.ll?rev=90545&r1=90544&r2=90545&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/loads.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/loads.ll Fri Dec 4 00:29:29 2009 @@ -101,3 +101,12 @@ } +; PR5551 + at test12g = private constant [6 x i8] c"a\00b\00\00\00" + +define i16 @test12() { + %a = load i16* getelementptr inbounds ([3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1) + ret i16 %a +; CHECK: @test12 +; CHECK: ret i16 98 +} From foldr at codedgers.com Fri Dec 4 00:38:28 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 04 Dec 2009 06:38:28 -0000 Subject: [llvm-commits] [llvm] r90547 - /llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Message-ID: <200912040638.nB46cSDM018154@zion.cs.uiuc.edu> Author: foldr Date: Fri Dec 4 00:38:28 2009 New Revision: 90547 URL: http://llvm.org/viewvc/llvm-project?rev=90547&view=rev Log: Support -march/-mtune/-mcpu. Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90547&r1=90546&r2=90547&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Fri Dec 4 00:38:28 2009 @@ -44,6 +44,12 @@ (help "Relocation model: dynamic-no-pic"), (hidden)), (parameter_option "linker", (help "Choose linker (possible values: gcc, g++)")), + (parameter_option "mtune", + (help "Target a specific CPU type"), (hidden)), + (parameter_option "march", + (help "A synonym for -mtune"), (hidden)), + (parameter_option "mcpu", + (help "A deprecated synonym for -mtune"), (hidden)), (parameter_option "MF", (help "Specify a file to write dependencies to"), (hidden)), (parameter_option "MT", @@ -119,6 +125,9 @@ (not_empty "I"), (forward "I"), (not_empty "F"), (forward "F"), (not_empty "D"), (forward "D"), + (not_empty "march"), (forward "march"), + (not_empty "mtune"), (forward "mtune"), + (not_empty "mcpu"), (forward "mcpu"), (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), (switch_on "O3"), (forward "O3"), @@ -179,6 +188,9 @@ (switch_on "fPIC"), (append_cmd "-relocation-model=pic"), (switch_on "mdynamic-no-pic"), (append_cmd "-relocation-model=dynamic-no-pic"), + (not_empty "march"), (forward "mcpu"), + (not_empty "mtune"), (forward "mcpu"), + (not_empty "mcpu"), (forward "mcpu"), (not_empty "Wllc,"), (unpack_values "Wllc,"))) ]>; From foldr at codedgers.com Fri Dec 4 00:38:45 2009 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 04 Dec 2009 06:38:45 -0000 Subject: [llvm-commits] [llvm] r90548 - /llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Message-ID: <200912040638.nB46cj31018175@zion.cs.uiuc.edu> Author: foldr Date: Fri Dec 4 00:38:45 2009 New Revision: 90548 URL: http://llvm.org/viewvc/llvm-project?rev=90548&view=rev Log: Forward -m32/-m64 to the linker. Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=90548&r1=90547&r2=90548&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Fri Dec 4 00:38:45 2009 @@ -38,6 +38,10 @@ (help "Compile and assemble, but do not link")), (switch_option "pthread", (help "Enable threads")), + (switch_option "m32", + (help "Generate code for a 32-bit environment"), (hidden)), + (switch_option "m64", + (help "Generate code for a 64-bit environment"), (hidden)), (switch_option "fPIC", (help "Relocation model: PIC"), (hidden)), (switch_option "mdynamic-no-pic", @@ -128,6 +132,8 @@ (not_empty "march"), (forward "march"), (not_empty "mtune"), (forward "mtune"), (not_empty "mcpu"), (forward "mcpu"), + (switch_on "m32"), (forward "m32"), + (switch_on "m64"), (forward "m64"), (switch_on "O1"), (forward "O1"), (switch_on "O2"), (forward "O2"), (switch_on "O3"), (forward "O3"), @@ -207,6 +213,8 @@ (not_empty "F"), (forward "F"), (not_empty "framework"), (forward "framework"), (not_empty "weak_framework"), (forward "weak_framework"), + (switch_on "m32"), (forward "m32"), + (switch_on "m64"), (forward "m64"), (not_empty "l"), (forward "l"), (not_empty "Wl,"), (forward "Wl,"))) ]>; From astifter-llvm at gmx.at Fri Dec 4 00:58:25 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Fri, 04 Dec 2009 06:58:25 -0000 Subject: [llvm-commits] [llvm] r90553 - /llvm/trunk/lib/VMCore/PassManager.cpp Message-ID: <200912040658.nB46wPe8018848@zion.cs.uiuc.edu> Author: astifter Date: Fri Dec 4 00:58:24 2009 New Revision: 90553 URL: http://llvm.org/viewvc/llvm-project?rev=90553&view=rev Log: Added debug output for inherited passes that are invalidated. Modified: llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=90553&r1=90552&r2=90553&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Fri Dec 4 00:58:24 2009 @@ -738,9 +738,15 @@ std::map::iterator Info = I++; if (!dynamic_cast(Info->second) && std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == - PreservedSet.end()) + PreservedSet.end()) { // Remove this analysis + if (PassDebugging >= Details) { + Pass *S = Info->second; + errs() << " -- '" << P->getPassName() << "' is not preserving '"; + errs() << S->getPassName() << "'\n"; + } InheritedAnalysis[Index]->erase(Info); + } } } } From astifter-llvm at gmx.at Fri Dec 4 01:33:28 2009 From: astifter-llvm at gmx.at (Andreas Neustifter) Date: Fri, 04 Dec 2009 08:33:28 +0100 Subject: [llvm-commits] [llvm] r90445 - in /llvm/trunk: include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileInfo.cpp In-Reply-To: <7F5F0839-581F-45B2-8931-9183DD8D1C1A@apple.com> References: <200912030930.nB39UCep006456@zion.cs.uiuc.edu> <7F5F0839-581F-45B2-8931-9183DD8D1C1A@apple.com> Message-ID: <4B18BB48.5080106@gmx.at> On 12/03/2009 06:47 PM, Chris Lattner wrote: > > On Dec 3, 2009, at 1:30 AM, Andreas Neustifter wrote: > >> Author: astifter >> Date: Thu Dec 3 03:30:12 2009 >> New Revision: 90445 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90445&view=rev >> Log: >> Converted ProfileInfo to template, added more API for >> ProfileInfo-preserving. > > Does this have to be a template? Why not use a base class that keeps a > map and then have derived classes for LLVM BB and MBB's? > This would significantly reduce code size. I'm still not very proficient with the C++-Type system so maybe this is a stupid question but: When I would use this approach, how would I use the shared code between the two derived classes? Naturally the code would be in the base class, but when I want to use this code I would have to have functions in the derived classes that hand the typecasted pointers to the base class? I must admit that I still have to move shared code from ProfileInfo.cpp to ProfileInfo.h, but there will be a large shared code base between this two classes. Agreed, the shared code in the base class is duplicated, is this what I shall strive to prevent? Andi From mikael.lepisto at tut.fi Fri Dec 4 01:55:23 2009 From: mikael.lepisto at tut.fi (=?ISO-8859-1?Q?Mikael_Lepist=F6?=) Date: Fri, 4 Dec 2009 09:55:23 +0200 Subject: [llvm-commits] [PATCH] fix compiling llvm-gcc against installed llvm, tested with rev 89457 In-Reply-To: <825CF204-986A-492F-8AE9-4B5B0473CF3E@tut.fi> References: <825CF204-986A-492F-8AE9-4B5B0473CF3E@tut.fi> Message-ID: Hi, I sent this patch two weeks ago and I didn't see any comments about it. Short summary about changes: Patch allows compiling llvm-gcc against any installation, as long as llvm-config --includedir and llvm-config --libdir points to correct places. llvm-config returns always correct values for those switches it does not matter if we ran it from object or installation directory. e.g. when llvm-config is ran in objdir, it points to obj and src dir locations if it's ran from installation path, it returns paths of installed includes and libraries. - Mikael On 21.11.2009, at 0:04, Mikael Lepist? wrote: > Hi, > > Here is patch again (I sent this also few weeks ago) for allowing > compilation of llvm-gcc against llvm installation directory. For > some reason it never got applied during llvm-2.6 release hurries. > > Before patch compiling llvm-gcc against llvm worked only if llvm > includes and libs were installed in same prefix. However e.g. in > debian deb packages have includes and libs installed in different > prefix. > > Patch allows compiling llvm-gcc against any installation, as long as > llvm-config --includedir and llvm-config --libdir points to correct > places. > > I tried that after patch building llvm-gcc still works: > against llvm install directory > against llvm objdir when objdir == srcdir > against llvm objdir when objdir != srcdir > > I also tested building llvm-gcc without enable-llvm. > > Mikael Lepist? > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Fri Dec 4 02:12:06 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 4 Dec 2009 00:12:06 -0800 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp In-Reply-To: <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> References: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> Message-ID: <6a8523d60912040012v355ff54drdb80b9a84199027f@mail.gmail.com> Hi Victor, This is causing a crash in Clang (on its test suite), can you take a look? The crash is here: if (isa(N->getElement(n))) and N->getElement(n) is null. Perhaps this just needs a null check, but I'm not sure if that is supposed to happen. - Daniel On Thu, Dec 3, 2009 at 5:37 PM, Devang Patel wrote: > Hi Victor, > On Dec 3, 2009, at 5:35 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Thu Dec ?3 19:35:02 2009 >> New Revision: 90512 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev >> Log: >> Teach AsmWriter to write inline (not via a global metadata slot) >> metadata that contains an instruction >> >> Modified: >> ? ?llvm/trunk/lib/VMCore/AsmWriter.cpp >> >> Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff >> >> = >> = >> = >> = >> = >> = >> = >> = >> ====================================================================== >> --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) >> +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec ?3 19:35:02 2009 >> @@ -695,8 +695,13 @@ >> ? ? ? ? ? !I->hasName()) >> ? ? ? ? CreateFunctionSlot(I); >> ? ? ? for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) >> - ? ? ? ?if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) >> + ? ? ? ?if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { >> + ? ? ? ? ?// Create a metadata slot only if N contains no >> instructions. >> + ? ? ? ? ?for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) >> + ? ? ? ? ? ?if (isa(N->getElement(n))) >> + ? ? ? ? ? ? ?continue; >> ? ? ? ? ? CreateMetadataSlot(N); >> + ? ? ? ?} >> >> ? ? ? // Process metadata attached with this instruction. >> ? ? ? MDs.clear(); > > There are other places where CreateMetadataSlot() is used. Please move > this check in side CreateMetadataSlot(). > - > Devang > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From daniel at zuster.org Fri Dec 4 02:17:08 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 04 Dec 2009 08:17:08 -0000 Subject: [llvm-commits] [llvm] r90557 - /llvm/trunk/lib/Support/DeltaAlgorithm.cpp Message-ID: <200912040817.nB48H8Cr022079@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Dec 4 02:17:07 2009 New Revision: 90557 URL: http://llvm.org/viewvc/llvm-project?rev=90557&view=rev Log: Fix typo and add missing include. Modified: llvm/trunk/lib/Support/DeltaAlgorithm.cpp Modified: llvm/trunk/lib/Support/DeltaAlgorithm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/DeltaAlgorithm.cpp?rev=90557&r1=90556&r2=90557&view=diff ============================================================================== --- llvm/trunk/lib/Support/DeltaAlgorithm.cpp (original) +++ llvm/trunk/lib/Support/DeltaAlgorithm.cpp Fri Dec 4 02:17:07 2009 @@ -1,4 +1,4 @@ -//===--- DeltaAlgorithm.h - A Set Minimization Algorithm -------*- C++ -*--===// +//===--- DeltaAlgorithm.cpp - A Set Minimization Algorithm -----*- C++ -*--===// // // The LLVM Compiler Infrastructure // @@ -8,6 +8,7 @@ #include "llvm/ADT/DeltaAlgorithm.h" #include +#include using namespace llvm; bool DeltaAlgorithm::GetTestResult(const changeset_ty &Changes) { From baldrick at free.fr Fri Dec 4 02:42:17 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 04 Dec 2009 08:42:17 -0000 Subject: [llvm-commits] [llvm] r90564 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Message-ID: <200912040842.nB48gH9w027620@zion.cs.uiuc.edu> Author: baldrick Date: Fri Dec 4 02:42:17 2009 New Revision: 90564 URL: http://llvm.org/viewvc/llvm-project?rev=90564&view=rev Log: Add note about a subtle bug in this code. Does not effect the main architectures that LLVM targets, because they don't use this code. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=90564&r1=90563&r2=90564&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Fri Dec 4 02:42:17 2009 @@ -1180,6 +1180,8 @@ LoS = DAG.getNode(ISD::SHL, dl, NVT, InL, Amt); HiS = DAG.getNode(ISD::OR, dl, NVT, DAG.getNode(ISD::SHL, dl, NVT, InH, Amt), + // FIXME: If Amt is zero, the following shift generates an undefined result + // on some architectures. DAG.getNode(ISD::SRL, dl, NVT, InL, AmtLack)); // Long: ShAmt >= NVTBits @@ -1194,6 +1196,8 @@ HiS = DAG.getNode(ISD::SRL, dl, NVT, InH, Amt); LoS = DAG.getNode(ISD::OR, dl, NVT, DAG.getNode(ISD::SRL, dl, NVT, InL, Amt), + // FIXME: If Amt is zero, the following shift generates an undefined result + // on some architectures. DAG.getNode(ISD::SHL, dl, NVT, InH, AmtLack)); // Long: ShAmt >= NVTBits @@ -1208,6 +1212,8 @@ HiS = DAG.getNode(ISD::SRA, dl, NVT, InH, Amt); LoS = DAG.getNode(ISD::OR, dl, NVT, DAG.getNode(ISD::SRL, dl, NVT, InL, Amt), + // FIXME: If Amt is zero, the following shift generates an undefined result + // on some architectures. DAG.getNode(ISD::SHL, dl, NVT, InH, AmtLack)); // Long: ShAmt >= NVTBits From echristo at apple.com Fri Dec 4 03:03:36 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 4 Dec 2009 01:03:36 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> Message-ID: > > >> +//===---------------------------------------===// >> +// 'object size' >> +namespace { >> +struct SizeOpt : public LibCallOptimization { > > This code (if it is kept) should be moved to instcombine, and generalized to work on more than just i32/i64. IT should work on any llvm.objectsize.ixxx intrinsic call. Well, there are only two we generate at the moment, but it could be adapted to any since we're just returning a length. I'm not sure about instcombine itself, but this is likely not the place to put it for sure :) > >> + const Type *Ty = Callee->getFunctionType()->getReturnType(); >> + >> + if (Const->getZExtValue() < 2) >> + return Constant::getAllOnesValue(Ty); >> + else >> + return ConstantInt::get(Ty, 0); > > I don't really get this. Why is libcalloptimizer turning these into "I don't know"? Shouldn't codegen (e.g. codegenprepare) do this? This seems really wrong. It's doing this now so that these other optimizations below can replace the checking calls with normal calls. It also matches what llvm-gcc did before. That said, we are producing less checks than we should - I went for keeping existing behavior over trying to get it all right at once. > > This should also handle the case when getOperand(3) and getOperand(4) are both constant ints and op3 <= op4? If we know that op3 > op4, I'm fine with leaving it unoptimized :) > Good question. I wasn't sure if this pass was iterative? I.e. if I change it to memcpy can the rest of the pass infrastructure deal with it? Of course, I could just look and figure it out - I just hadn't gotten that far :) > > Can this code be factored better? Maybe introduce a new intermediate class that all of MemCpyChkOpt/MemSetChkOpt/MemMoveChkOpt inherit from that then inherits from LibCallOptimization? Most assuredly. It was bugging me too :) -eric From evan.cheng at apple.com Fri Dec 4 03:23:38 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 04 Dec 2009 09:23:38 -0000 Subject: [llvm-commits] [llvm] r90566 - /llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912040923.nB49NcOb006275@zion.cs.uiuc.edu> Author: evancheng Date: Fri Dec 4 03:23:37 2009 New Revision: 90566 URL: http://llvm.org/viewvc/llvm-project?rev=90566&view=rev Log: Don't try to be cute with undef optimization here. Let ProcessImplicitDefs handle it. Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90566&r1=90565&r2=90566&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Fri Dec 4 03:23:37 2009 @@ -94,7 +94,7 @@ const TargetRegisterClass *RC, MachineRegisterInfo *MRI, const TargetInstrInfo *TII) { unsigned NewVR = MRI->createVirtualRegister(RC); - return BuildMI(*BB, I, I->getDebugLoc(), TII->get(Opcode), NewVR); + return BuildMI(*BB, I, DebugLoc::getUnknownLoc(), TII->get(Opcode), NewVR); } @@ -124,8 +124,13 @@ return GetValueAtEndOfBlock(BB); // If there are no predecessors, just return undef. - if (BB->pred_empty()) - return ~0U; // Sentinel value representing undef. + if (BB->pred_empty()) { + // Insert an implicit_def to represent an undef value. + MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, + BB, BB->getFirstTerminator(), + VRC, MRI, TII); + return NewDef->getOperand(0).getReg(); + } // Otherwise, we have the hard case. Get the live-in values for each // predecessor. @@ -194,20 +199,8 @@ if (UseMI->getOpcode() == TargetInstrInfo::PHI) { MachineBasicBlock *SourceBB = findCorrespondingPred(UseMI, &U); NewVR = GetValueAtEndOfBlock(SourceBB); - // Insert an implicit_def to represent an undef value. - MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, - SourceBB,SourceBB->getFirstTerminator(), - VRC, MRI, TII); - NewVR = NewDef->getOperand(0).getReg(); } else { NewVR = GetValueInMiddleOfBlock(UseMI->getParent()); - if (NewVR == ~0U) { - // Insert an implicit_def to represent an undef value. - MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, - UseMI->getParent(), UseMI, - VRC, MRI, TII); - NewVR = NewDef->getOperand(0).getReg(); - } } U.setReg(NewVR); @@ -248,8 +241,13 @@ // If there are no predecessors, then we must have found an unreachable block // just return 'undef'. Since there are no predecessors, InsertRes must not // be invalidated. - if (BB->pred_empty()) - return InsertRes.first->second = ~0U; // Sentinel value representing undef. + if (BB->pred_empty()) { + // Insert an implicit_def to represent an undef value. + MachineInstr *NewDef = InsertNewDef(TargetInstrInfo::IMPLICIT_DEF, + BB, BB->getFirstTerminator(), + VRC, MRI, TII); + return InsertRes.first->second = NewDef->getOperand(0).getReg(); + } // Okay, the value isn't in the map and we just inserted a null in the entry // to indicate that we're processing the block. Since we have no idea what @@ -321,16 +319,11 @@ } // Fill in all the predecessors of the PHI. - bool IsUndef = true; MachineInstrBuilder MIB(InsertedPHI); for (IncomingPredInfoTy::iterator I = IncomingPredInfo.begin()+FirstPredInfoEntry, - E = IncomingPredInfo.end(); I != E; ++I) { - if (I->second == ~0U) - continue; - IsUndef = false; + E = IncomingPredInfo.end(); I != E; ++I) MIB.addReg(I->second).addMBB(I->first); - } // Drop the entries we added in IncomingPredInfo to restore the stack. IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry, @@ -338,10 +331,7 @@ // See if the PHI node can be merged to a single value. This can happen in // loop cases when we get a PHI of itself and one other value. - if (IsUndef) { - InsertedPHI->eraseFromParent(); - InsertedVal = ~0U; - } else if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { + if (unsigned ConstVal = InsertedPHI->isConstantValuePHI()) { MRI->replaceRegWith(InsertedVal, ConstVal); InsertedPHI->eraseFromParent(); InsertedVal = ConstVal; From evan.cheng at apple.com Fri Dec 4 03:42:46 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 04 Dec 2009 09:42:46 -0000 Subject: [llvm-commits] [llvm] r90567 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/TailDuplication.cpp Message-ID: <200912040942.nB49gkHc006852@zion.cs.uiuc.edu> Author: evancheng Date: Fri Dec 4 03:42:45 2009 New Revision: 90567 URL: http://llvm.org/viewvc/llvm-project?rev=90567&view=rev Log: Add a pre-regalloc tail duplication pass. Modified: llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=90567&r1=90566&r2=90567&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Dec 4 03:42:45 2009 @@ -131,7 +131,7 @@ /// TailDuplicate Pass - Duplicate blocks with unconditional branches /// into tails of their predecessors. - FunctionPass *createTailDuplicatePass(); + FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false); /// IfConverter Pass - This pass performs machine code if conversion. FunctionPass *createIfConverterPass(); Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=90567&r1=90566&r2=90567&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Dec 4 03:42:45 2009 @@ -74,6 +74,9 @@ static cl::opt EnableSplitGEPGVN("split-gep-gvn", cl::Hidden, cl::desc("Split GEPs and run no-load GVN")); +static cl::opt PreAllocTailDup("pre-regalloc-taildup", cl::Hidden, + cl::desc("Pre-register allocation tail duplication")); + LLVMTargetMachine::LLVMTargetMachine(const Target &T, const std::string &TargetTriple) : TargetMachine(T) { @@ -302,6 +305,13 @@ /* allowDoubleDefs= */ true); } + // Pre-ra tail duplication. + if (OptLevel != CodeGenOpt::None && + !DisableTailDuplicate && PreAllocTailDup) { + PM.add(createTailDuplicatePass(true)); + printAndVerify(PM, "After Pre-RegAlloc TailDuplicate"); + } + // Run pre-ra passes. if (addPreRegAlloc(PM, OptLevel)) printAndVerify(PM, "After PreRegAlloc passes", @@ -348,7 +358,7 @@ // Tail duplication. if (OptLevel != CodeGenOpt::None && !DisableTailDuplicate) { - PM.add(createTailDuplicatePass()); + PM.add(createTailDuplicatePass(false)); printAndVerify(PM, "After TailDuplicate"); } Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90567&r1=90566&r2=90567&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Dec 4 03:42:45 2009 @@ -43,6 +43,7 @@ namespace { /// TailDuplicatePass - Perform tail duplication. class TailDuplicatePass : public MachineFunctionPass { + bool PreRegAlloc; const TargetInstrInfo *TII; MachineModuleInfo *MMI; MachineRegisterInfo *MRI; @@ -56,13 +57,24 @@ public: static char ID; - explicit TailDuplicatePass() : MachineFunctionPass(&ID) {} + explicit TailDuplicatePass(bool PreRA) : + MachineFunctionPass(&ID), PreRegAlloc(PreRA) {} virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "Tail Duplication"; } private: void AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg); + void ProcessPHI(MachineInstr *MI, MachineBasicBlock *TailBB, + MachineBasicBlock *PredBB, + DenseMap &LocalVRMap); + void DuplicateInstruction(MachineInstr *MI, + MachineBasicBlock *TailBB, + MachineBasicBlock *PredBB, + MachineFunction &MF, + DenseMap &LocalVRMap); + void UpdateSuccessorsPHIs(MachineBasicBlock *FromBB,MachineBasicBlock *ToBB, + SmallSetVector &Succs); bool TailDuplicateBlocks(MachineFunction &MF); bool TailDuplicate(MachineBasicBlock *TailBB, MachineFunction &MF); void RemoveDeadBlock(MachineBasicBlock *MBB); @@ -71,8 +83,8 @@ char TailDuplicatePass::ID = 0; } -FunctionPass *llvm::createTailDuplicatePass() { - return new TailDuplicatePass(); +FunctionPass *llvm::createTailDuplicatePass(bool PreRegAlloc) { + return new TailDuplicatePass(PreRegAlloc); } bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) { @@ -97,9 +109,6 @@ bool TailDuplicatePass::TailDuplicateBlocks(MachineFunction &MF) { bool MadeChange = false; - SSAUpdateVRs.clear(); - SSAUpdateVals.clear(); - for (MachineFunction::iterator I = ++MF.begin(), E = MF.end(); I != E; ) { MachineBasicBlock *MBB = I++; @@ -109,8 +118,9 @@ MadeChange |= TailDuplicate(MBB, MF); - // If it is dead, remove it. - if (MBB->pred_empty()) { + // If it is dead, remove it. Don't do this if this pass is run before + // register allocation to avoid having to update PHI nodes. + if (!PreRegAlloc && MBB->pred_empty()) { NumInstrDups -= MBB->size(); RemoveDeadBlock(MBB); MadeChange = true; @@ -118,42 +128,6 @@ } } - if (!SSAUpdateVRs.empty()) { - // Update SSA form. - MachineSSAUpdater SSAUpdate(MF); - - for (unsigned i = 0, e = SSAUpdateVRs.size(); i != e; ++i) { - unsigned VReg = SSAUpdateVRs[i]; - SSAUpdate.Initialize(VReg); - - // If the original definition is still around, add it as an available - // value. - MachineInstr *DefMI = MRI->getVRegDef(VReg); - MachineBasicBlock *DefBB = 0; - if (DefMI) { - DefBB = DefMI->getParent(); - SSAUpdate.AddAvailableValue(DefBB, VReg); - } - - // Add the new vregs as available values. - DenseMap::iterator LI = - SSAUpdateVals.find(VReg); - for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { - unsigned NewReg = LI->second[j]; - MachineInstr *DefMI = MRI->getVRegDef(NewReg); - SSAUpdate.AddAvailableValue(DefMI->getParent(), NewReg); - } - - // Rewrite uses that are outside of the original def's block. - for (MachineRegisterInfo::use_iterator UI = MRI->use_begin(VReg), - UE = MRI->use_end(); UI != UE; ++UI) { - MachineInstr *UseMI = &*UI; - if (UseMI->getParent() != DefBB) - SSAUpdate.RewriteUse(UI.getOperand()); - } - } - } - return MadeChange; } @@ -190,6 +164,98 @@ } } +/// ProcessPHI - Process but do not duplicate a PHI node in TailBB. Remember the +/// source register that's contributed by PredBB and update SSA update map. +void TailDuplicatePass::ProcessPHI(MachineInstr *MI, + MachineBasicBlock *TailBB, + MachineBasicBlock *PredBB, + DenseMap &LocalVRMap) { + unsigned DefReg = MI->getOperand(0).getReg(); + unsigned SrcOpIdx = getPHISrcRegOpIdx(MI, PredBB); + assert(SrcOpIdx && "Unable to find matching PHI source?"); + unsigned SrcReg = MI->getOperand(SrcOpIdx).getReg(); + LocalVRMap.insert(std::make_pair(DefReg, SrcReg)); + if (isDefLiveOut(DefReg, TailBB, MRI)) + AddSSAUpdateEntry(DefReg, SrcReg); + + // Remove PredBB from the PHI node. + MI->RemoveOperand(SrcOpIdx+1); + MI->RemoveOperand(SrcOpIdx); + if (MI->getNumOperands() == 1) + MI->eraseFromParent(); +} + +/// DuplicateInstruction - Duplicate a TailBB instruction to PredBB and update +/// the source operands due to earlier PHI translation. +void TailDuplicatePass::DuplicateInstruction(MachineInstr *MI, + MachineBasicBlock *TailBB, + MachineBasicBlock *PredBB, + MachineFunction &MF, + DenseMap &LocalVRMap) { + MachineInstr *NewMI = MF.CloneMachineInstr(MI); + for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = NewMI->getOperand(i); + if (!MO.isReg()) + continue; + unsigned Reg = MO.getReg(); + if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) + continue; + if (MO.isDef()) { + const TargetRegisterClass *RC = MRI->getRegClass(Reg); + unsigned NewReg = MRI->createVirtualRegister(RC); + MO.setReg(NewReg); + LocalVRMap.insert(std::make_pair(Reg, NewReg)); + if (isDefLiveOut(Reg, TailBB, MRI)) + AddSSAUpdateEntry(Reg, NewReg); + } else { + DenseMap::iterator VI = LocalVRMap.find(Reg); + if (VI != LocalVRMap.end()) + MO.setReg(VI->second); + } + } + PredBB->insert(PredBB->end(), NewMI); +} + +/// UpdateSuccessorsPHIs - After FromBB is tail duplicated into its predecessor +/// blocks, the successors have gained new predecessors. Update the PHI +/// instructions in them accordingly. +void TailDuplicatePass::UpdateSuccessorsPHIs(MachineBasicBlock *FromBB, + MachineBasicBlock *ToBB, + SmallSetVector &Succs) { + for (SmallSetVector::iterator SI = Succs.begin(), + SE = Succs.end(); SI != SE; ++SI) { + MachineBasicBlock *SuccBB = *SI; + for (MachineBasicBlock::iterator II = SuccBB->begin(), EE = SuccBB->end(); + II != EE; ++II) { + if (II->getOpcode() != TargetInstrInfo::PHI) + break; + for (unsigned i = 1, e = II->getNumOperands(); i != e; i += 2) { + MachineOperand &MO1 = II->getOperand(i+1); + if (MO1.getMBB() != FromBB) + continue; + MachineOperand &MO0 = II->getOperand(i); + unsigned Reg = MO0.getReg(); + if (ToBB) { + // Folded into the previous BB. + II->RemoveOperand(i+1); + II->RemoveOperand(i); + } + DenseMap::iterator LI = + SSAUpdateVals.find(Reg); + if (LI == SSAUpdateVals.end()) + break; + for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { + unsigned NewReg = LI->second[j]; + MachineInstr *DefMI = MRI->getVRegDef(NewReg); + II->addOperand(MachineOperand::CreateReg(NewReg, false)); + II->addOperand(MachineOperand::CreateMBB(DefMI->getParent())); + } + break; + } + } + } +} + /// TailDuplicate - If it is profitable, duplicate TailBB's contents in each /// of its predecessors. bool TailDuplicatePass::TailDuplicate(MachineBasicBlock *TailBB, @@ -222,6 +288,10 @@ I != TailBB->end(); ++I) { // Non-duplicable things shouldn't be tail-duplicated. if (I->getDesc().isNotDuplicable()) return false; + // Do not duplicate 'return' instructions if this is a pre-regalloc run. + // A return may expand into a lot more instructions (e.g. reload of callee + // saved registers) after PEI. + if (PreRegAlloc && I->getDesc().isReturn()) return false; // Don't duplicate more than the threshold. if (InstrCount == MaxDuplicateCount) return false; // Remember if we saw a call. @@ -238,8 +308,8 @@ // block into them, if possible. Copying the list ahead of time also // avoids trouble with the predecessor list reallocating. bool Changed = false; - SmallSetVector Preds(TailBB->pred_begin(), - TailBB->pred_end()); + SmallSetVector Preds(TailBB->pred_begin(), + TailBB->pred_end()); for (SmallSetVector::iterator PI = Preds.begin(), PE = Preds.end(); PI != PE; ++PI) { MachineBasicBlock *PredBB = *PI; @@ -270,51 +340,18 @@ // Clone the contents of TailBB into PredBB. DenseMap LocalVRMap; MachineBasicBlock::iterator I = TailBB->begin(); - MachineBasicBlock::iterator NI; - for (MachineBasicBlock::iterator E = TailBB->end(); I != E; I = NI) { - NI = next(I); - if (I->getOpcode() == TargetInstrInfo::PHI) { + while (I != TailBB->end()) { + MachineInstr *MI = &*I; + ++I; + if (MI->getOpcode() == TargetInstrInfo::PHI) { // Replace the uses of the def of the PHI with the register coming // from PredBB. - unsigned DefReg = I->getOperand(0).getReg(); - unsigned SrcOpIdx = getPHISrcRegOpIdx(I, PredBB); - unsigned SrcReg = I->getOperand(SrcOpIdx).getReg(); - LocalVRMap.insert(std::make_pair(DefReg, SrcReg)); - if (isDefLiveOut(DefReg, TailBB, MRI)) - AddSSAUpdateEntry(DefReg, SrcReg); - - // Remove PredBB from the PHI node. - I->RemoveOperand(SrcOpIdx+1); - I->RemoveOperand(SrcOpIdx); - if (I->getNumOperands() == 1) - I->eraseFromParent(); - continue; - } - - // Replace def of virtual registers with new registers, and update uses - // with PHI source register or the new registers. - MachineInstr *NewMI = MF.CloneMachineInstr(I); - for (unsigned i = 0, e = NewMI->getNumOperands(); i != e; ++i) { - MachineOperand &MO = NewMI->getOperand(i); - if (!MO.isReg()) - continue; - unsigned Reg = MO.getReg(); - if (!Reg || TargetRegisterInfo::isPhysicalRegister(Reg)) - continue; - if (MO.isDef()) { - const TargetRegisterClass *RC = MRI->getRegClass(Reg); - unsigned NewReg = MRI->createVirtualRegister(RC); - MO.setReg(NewReg); - LocalVRMap.insert(std::make_pair(Reg, NewReg)); - if (isDefLiveOut(Reg, TailBB, MRI)) - AddSSAUpdateEntry(Reg, NewReg); - } else { - DenseMap::iterator VI = LocalVRMap.find(Reg); - if (VI != LocalVRMap.end()) - MO.setReg(VI->second); - } + ProcessPHI(MI, TailBB, PredBB, LocalVRMap); + } else { + // Replace def of virtual registers with new registers, and update + // uses with PHI source register or the new registers. + DuplicateInstruction(MI, TailBB, PredBB, MF, LocalVRMap); } - PredBB->insert(PredBB->end(), NewMI); } NumInstrDups += TailBB->size() - 1; // subtract one for removed branch @@ -323,35 +360,115 @@ assert(PredBB->succ_empty() && "TailDuplicate called on block with multiple successors!"); for (MachineBasicBlock::succ_iterator I = TailBB->succ_begin(), - E = TailBB->succ_end(); I != E; ++I) - PredBB->addSuccessor(*I); + E = TailBB->succ_end(); I != E; ++I) + PredBB->addSuccessor(*I); Changed = true; ++NumTailDups; } + // Save the successors list. + SmallSetVector Succs(TailBB->succ_begin(), + TailBB->succ_end()); + // If TailBB was duplicated into all its predecessors except for the prior // block, which falls through unconditionally, move the contents of this // block into the prior block. - MachineBasicBlock &PrevBB = *prior(MachineFunction::iterator(TailBB)); + MachineBasicBlock *PrevBB = prior(MachineFunction::iterator(TailBB)); MachineBasicBlock *PriorTBB = 0, *PriorFBB = 0; SmallVector PriorCond; bool PriorUnAnalyzable = - TII->AnalyzeBranch(PrevBB, PriorTBB, PriorFBB, PriorCond, true); + TII->AnalyzeBranch(*PrevBB, PriorTBB, PriorFBB, PriorCond, true); // This has to check PrevBB->succ_size() because EH edges are ignored by // AnalyzeBranch. + // If TailBB starts with PHIs, then don't bother. Let the post regalloc + // run clean it up. + MachineBasicBlock *NewTailBB = 0; if (!PriorUnAnalyzable && PriorCond.empty() && !PriorTBB && - TailBB->pred_size() == 1 && PrevBB.succ_size() == 1 && + TailBB->pred_size() == 1 && PrevBB->succ_size() == 1 && !TailBB->hasAddressTaken()) { - DEBUG(errs() << "\nMerging into block: " << PrevBB + DEBUG(errs() << "\nMerging into block: " << *PrevBB << "From MBB: " << *TailBB); - PrevBB.splice(PrevBB.end(), TailBB, TailBB->begin(), TailBB->end()); - PrevBB.removeSuccessor(PrevBB.succ_begin());; - assert(PrevBB.succ_empty()); - PrevBB.transferSuccessors(TailBB); + if (PreRegAlloc) { + DenseMap LocalVRMap; + MachineBasicBlock::iterator I = TailBB->begin(); + // Process PHI instructions first. + while (I != TailBB->end() && I->getOpcode() == TargetInstrInfo::PHI) { + // Replace the uses of the def of the PHI with the register coming + // from PredBB. + MachineInstr *MI = &*I++; + ProcessPHI(MI, TailBB, PrevBB, LocalVRMap); + if (MI->getParent()) + MI->eraseFromParent(); + } + + // Now copy the non-PHI instructions. + while (I != TailBB->end()) { + // Replace def of virtual registers with new registers, and update + // uses with PHI source register or the new registers. + MachineInstr *MI = &*I++; + DuplicateInstruction(MI, TailBB, PrevBB, MF, LocalVRMap); + MI->eraseFromParent(); + } + } else { + // No PHIs to worry about, just splice the instructions over. + PrevBB->splice(PrevBB->end(), TailBB, TailBB->begin(), TailBB->end()); + } + PrevBB->removeSuccessor(PrevBB->succ_begin()); + assert(PrevBB->succ_empty()); + PrevBB->transferSuccessors(TailBB); + NewTailBB = PrevBB; Changed = true; } + if (!PreRegAlloc) + return Changed; + + // TailBB's immediate successors are now successors of those predecessors + // which duplicated TailBB. Add the predecessors as sources to the PHI + // instructions. + UpdateSuccessorsPHIs(TailBB, NewTailBB, Succs); + + if (!SSAUpdateVRs.empty()) { + // Update SSA form. + MachineSSAUpdater SSAUpdate(MF); + for (unsigned i = 0, e = SSAUpdateVRs.size(); i != e; ++i) { + unsigned VReg = SSAUpdateVRs[i]; + SSAUpdate.Initialize(VReg); + + // If the original definition is still around, add it as an available + // value. + MachineInstr *DefMI = MRI->getVRegDef(VReg); + MachineBasicBlock *DefBB = 0; + if (DefMI) { + DefBB = DefMI->getParent(); + SSAUpdate.AddAvailableValue(DefBB, VReg); + } + + // Add the new vregs as available values. + DenseMap::iterator LI = + SSAUpdateVals.find(VReg); + for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { + unsigned NewReg = LI->second[j]; + MachineInstr *DefMI = MRI->getVRegDef(NewReg); + SSAUpdate.AddAvailableValue(DefMI->getParent(), NewReg); + } + + // Rewrite uses that are outside of the original def's block. + MachineRegisterInfo::use_iterator UI = MRI->use_begin(VReg); + while (UI != MRI->use_end()) { + MachineOperand &UseMO = UI.getOperand(); + MachineInstr *UseMI = &*UI; + ++UI; + if (UseMI->getParent() != DefBB) + SSAUpdate.RewriteUse(UseMO); + } + } + + SSAUpdateVRs.clear(); + SSAUpdateVals.clear(); + } + return Changed; } From anton at korobeynikov.info Fri Dec 4 07:09:52 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 4 Dec 2009 16:09:52 +0300 Subject: [llvm-commits] [PATCH] fix compiling llvm-gcc against installed llvm, tested with rev 89457 In-Reply-To: References: <825CF204-986A-492F-8AE9-4B5B0473CF3E@tut.fi> Message-ID: Hello, Mikael > Patch allows compiling llvm-gcc against any installation, as long as > llvm-config --includedir and llvm-config --libdir points to correct > places. We've discussed this patch with Daniel Dunbar some time ago. It looks ok for me, the only thing which needs to be checked is that everything is ok with apple-style builds (when LLVM itself is built "universal", etc.). So, someone from Apple should confirm that this is ok as well. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From espindola at google.com Fri Dec 4 10:10:12 2009 From: espindola at google.com (Rafael Espindola) Date: Fri, 4 Dec 2009 11:10:12 -0500 Subject: [llvm-commits] [patch] Implement no-canonical-prefixes. In-Reply-To: <74c447500912031925g359835darb90757eeaf21c206@mail.gmail.com> References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> <38a0d8450912020727r1cef56a8r462373f183957922@mail.gmail.com> <38a0d8450912031456t54efd76dyae13199fd96cc3b2@mail.gmail.com> <74c447500912031925g359835darb90757eeaf21c206@mail.gmail.com> Message-ID: <38a0d8450912040810s4d21f836vae99272d35713a7a@mail.gmail.com> > I published comments there. Updated. Is running upload.py the correct way to do it? :-) Cheers, -- Rafael ?vila de Esp?ndola From dpatel at apple.com Fri Dec 4 11:39:50 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 4 Dec 2009 09:39:50 -0800 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp In-Reply-To: <6a8523d60912040012v355ff54drdb80b9a84199027f@mail.gmail.com> References: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> <6a8523d60912040012v355ff54drdb80b9a84199027f@mail.gmail.com> Message-ID: On Dec 4, 2009, at 12:12 AM, Daniel Dunbar wrote: > Hi Victor, > > This is causing a crash in Clang (on its test suite), can you take a > look? The crash is here: > if (isa(N->getElement(n))) > and N->getElement(n) is null. Perhaps this just needs a null check, > but I'm not sure if that is supposed to happen. Yes, Null can happen and it is valid. In fact, most of the MDNodes describing location has null as the last element. - Devang > > - Daniel > > On Thu, Dec 3, 2009 at 5:37 PM, Devang Patel wrote: >> Hi Victor, >> On Dec 3, 2009, at 5:35 PM, Victor Hernandez wrote: >> >>> Author: hernande >>> Date: Thu Dec 3 19:35:02 2009 >>> New Revision: 90512 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev >>> Log: >>> Teach AsmWriter to write inline (not via a global metadata slot) >>> metadata that contains an instruction >>> >>> Modified: >>> llvm/trunk/lib/VMCore/AsmWriter.cpp >>> >>> Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff >>> >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> = >>> ==================================================================== >>> --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) >>> +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009 >>> @@ -695,8 +695,13 @@ >>> !I->hasName()) >>> CreateFunctionSlot(I); >>> for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) >>> - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) >>> + if (MDNode *N = dyn_cast_or_null(I->getOperand >>> (i))) { >>> + // Create a metadata slot only if N contains no >>> instructions. >>> + for (unsigned n = 0, e = N->getNumElements(); n != e; + >>> +n) >>> + if (isa(N->getElement(n))) >>> + continue; >>> CreateMetadataSlot(N); >>> + } >>> >>> // Process metadata attached with this instruction. >>> MDs.clear(); >> >> There are other places where CreateMetadataSlot() is used. Please >> move >> this check in side CreateMetadataSlot(). >> - >> Devang >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From vhernandez at apple.com Fri Dec 4 12:29:24 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 04 Dec 2009 18:29:24 -0000 Subject: [llvm-commits] [llvm] r90572 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <200912041829.nB4ITONe026130@zion.cs.uiuc.edu> Author: hernande Date: Fri Dec 4 12:29:23 2009 New Revision: 90572 URL: http://llvm.org/viewvc/llvm-project?rev=90572&view=rev Log: Fix crasher when N->getElement(n) is NULL Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90572&r1=90571&r2=90572&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Fri Dec 4 12:29:23 2009 @@ -698,7 +698,7 @@ if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { // Create a metadata slot only if N contains no instructions. for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) - if (isa(N->getElement(n))) + if (N->getElement(n) && isa(N->getElement(n))) continue; CreateMetadataSlot(N); } From vhernandez at apple.com Fri Dec 4 13:00:47 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 4 Dec 2009 11:00:47 -0800 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp In-Reply-To: References: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> <6a8523d60912040012v355ff54drdb80b9a84199027f@mail.gmail.com> Message-ID: <8248B57C-5BA2-4C4A-8443-255D0AFEDDA6@apple.com> I fixed this in r90572. Victor On Dec 4, 2009, at 9:39 AM, Devang Patel wrote: > > On Dec 4, 2009, at 12:12 AM, Daniel Dunbar wrote: > >> Hi Victor, >> >> This is causing a crash in Clang (on its test suite), can you take a >> look? The crash is here: >> if (isa(N->getElement(n))) >> and N->getElement(n) is null. Perhaps this just needs a null check, >> but I'm not sure if that is supposed to happen. > > Yes, Null can happen and it is valid. In fact, most of the MDNodes describing location has null as the last element. > - > Devang > >> >> - Daniel >> >> On Thu, Dec 3, 2009 at 5:37 PM, Devang Patel wrote: >>> Hi Victor, >>> On Dec 3, 2009, at 5:35 PM, Victor Hernandez wrote: >>> >>>> Author: hernande >>>> Date: Thu Dec 3 19:35:02 2009 >>>> New Revision: 90512 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev >>>> Log: >>>> Teach AsmWriter to write inline (not via a global metadata slot) >>>> metadata that contains an instruction >>>> >>>> Modified: >>>> llvm/trunk/lib/VMCore/AsmWriter.cpp >>>> >>>> Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff >>>> >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> = >>>> ====================================================================== >>>> --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) >>>> +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009 >>>> @@ -695,8 +695,13 @@ >>>> !I->hasName()) >>>> CreateFunctionSlot(I); >>>> for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) >>>> - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) >>>> + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { >>>> + // Create a metadata slot only if N contains no >>>> instructions. >>>> + for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) >>>> + if (isa(N->getElement(n))) >>>> + continue; >>>> CreateMetadataSlot(N); >>>> + } >>>> >>>> // Process metadata attached with this instruction. >>>> MDs.clear(); >>> >>> There are other places where CreateMetadataSlot() is used. Please move >>> this check in side CreateMetadataSlot(). >>> - >>> Devang >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091204/531f893d/attachment.html From evan.cheng at apple.com Fri Dec 4 13:09:10 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 04 Dec 2009 19:09:10 -0000 Subject: [llvm-commits] [llvm] r90575 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp Message-ID: <200912041909.nB4J9ABe027704@zion.cs.uiuc.edu> Author: evancheng Date: Fri Dec 4 13:09:10 2009 New Revision: 90575 URL: http://llvm.org/viewvc/llvm-project?rev=90575&view=rev Log: Handle recursive PHI's. Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=90575&r1=90574&r2=90575&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original) +++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Dec 4 13:09:10 2009 @@ -38,7 +38,7 @@ cl::desc("Maximum instructions to consider tail duplicating"), cl::init(2), cl::Hidden); -typedef std::vector AvailableValsTy; +typedef std::vector > AvailableValsTy; namespace { /// TailDuplicatePass - Perform tail duplication. @@ -64,7 +64,8 @@ virtual const char *getPassName() const { return "Tail Duplication"; } private: - void AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg); + void AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg, + MachineBasicBlock *BB); void ProcessPHI(MachineInstr *MI, MachineBasicBlock *TailBB, MachineBasicBlock *PredBB, DenseMap &LocalVRMap); @@ -151,14 +152,14 @@ /// AddSSAUpdateEntry - Add a definition and source virtual registers pair for /// SSA update. -void TailDuplicatePass::AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg) { - DenseMap::iterator LI = - SSAUpdateVals.find(OrigReg); +void TailDuplicatePass::AddSSAUpdateEntry(unsigned OrigReg, unsigned NewReg, + MachineBasicBlock *BB) { + DenseMap::iterator LI= SSAUpdateVals.find(OrigReg); if (LI != SSAUpdateVals.end()) - LI->second.push_back(NewReg); + LI->second.push_back(std::make_pair(BB, NewReg)); else { AvailableValsTy Vals; - Vals.push_back(NewReg); + Vals.push_back(std::make_pair(BB, NewReg)); SSAUpdateVals.insert(std::make_pair(OrigReg, Vals)); SSAUpdateVRs.push_back(OrigReg); } @@ -176,7 +177,7 @@ unsigned SrcReg = MI->getOperand(SrcOpIdx).getReg(); LocalVRMap.insert(std::make_pair(DefReg, SrcReg)); if (isDefLiveOut(DefReg, TailBB, MRI)) - AddSSAUpdateEntry(DefReg, SrcReg); + AddSSAUpdateEntry(DefReg, SrcReg, PredBB); // Remove PredBB from the PHI node. MI->RemoveOperand(SrcOpIdx+1); @@ -206,7 +207,7 @@ MO.setReg(NewReg); LocalVRMap.insert(std::make_pair(Reg, NewReg)); if (isDefLiveOut(Reg, TailBB, MRI)) - AddSSAUpdateEntry(Reg, NewReg); + AddSSAUpdateEntry(Reg, NewReg, PredBB); } else { DenseMap::iterator VI = LocalVRMap.find(Reg); if (VI != LocalVRMap.end()) @@ -240,15 +241,14 @@ II->RemoveOperand(i+1); II->RemoveOperand(i); } - DenseMap::iterator LI = - SSAUpdateVals.find(Reg); + DenseMap::iterator LI=SSAUpdateVals.find(Reg); if (LI == SSAUpdateVals.end()) break; for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { - unsigned NewReg = LI->second[j]; - MachineInstr *DefMI = MRI->getVRegDef(NewReg); - II->addOperand(MachineOperand::CreateReg(NewReg, false)); - II->addOperand(MachineOperand::CreateMBB(DefMI->getParent())); + MachineBasicBlock *SrcBB = LI->second[j].first; + unsigned SrcReg = LI->second[j].second; + II->addOperand(MachineOperand::CreateReg(SrcReg, false)); + II->addOperand(MachineOperand::CreateMBB(SrcBB)); } break; } @@ -449,9 +449,9 @@ DenseMap::iterator LI = SSAUpdateVals.find(VReg); for (unsigned j = 0, ee = LI->second.size(); j != ee; ++j) { - unsigned NewReg = LI->second[j]; - MachineInstr *DefMI = MRI->getVRegDef(NewReg); - SSAUpdate.AddAvailableValue(DefMI->getParent(), NewReg); + MachineBasicBlock *SrcBB = LI->second[j].first; + unsigned SrcReg = LI->second[j].second; + SSAUpdate.AddAvailableValue(SrcBB, SrcReg); } // Rewrite uses that are outside of the original def's block. From chandlerc at google.com Fri Dec 4 13:21:09 2009 From: chandlerc at google.com (Chandler Carruth) Date: Fri, 4 Dec 2009 11:21:09 -0800 Subject: [llvm-commits] [patch] Implement no-canonical-prefixes. In-Reply-To: <38a0d8450912040810s4d21f836vae99272d35713a7a@mail.gmail.com> References: <38a0d8450911290834l4c32bba0m40da8daf624cf088@mail.gmail.com> <74c447500912010933u1c0c8e45i343095f0afba8ef1@mail.gmail.com> <38a0d8450912020727r1cef56a8r462373f183957922@mail.gmail.com> <38a0d8450912031456t54efd76dyae13199fd96cc3b2@mail.gmail.com> <74c447500912031925g359835darb90757eeaf21c206@mail.gmail.com> <38a0d8450912040810s4d21f836vae99272d35713a7a@mail.gmail.com> Message-ID: <74c447500912041121m1f7db35dn945b97993257be14@mail.gmail.com> On Fri, Dec 4, 2009 at 8:10 AM, Rafael Espindola wrote: >> I published comments there. > > Updated. Is running upload.py the correct way to do it? ?:-) LGTM > > Cheers, > -- > Rafael ?vila de Esp?ndola > From isanbard at gmail.com Fri Dec 4 13:40:57 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 04 Dec 2009 19:40:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90579 - /llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Message-ID: <200912041940.nB4JevP6028847@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 13:40:56 2009 New Revision: 90579 URL: http://llvm.org/viewvc/llvm-project?rev=90579&view=rev Log: Revert r90495. It may be causing build failures on PPC. Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h?rev=90579&r1=90578&r2=90579&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Fri Dec 4 13:40:56 2009 @@ -117,8 +117,7 @@ "/* LLVM LOCAL ignore -g in LTO mode */"\ "/* On Darwin, debug info is stored in separate .dSYM files. */"\ "/* This requires special support in LTO mode. */" \ - "/* LLVM LOCAL - FIXME: Ignore -g on PPC until we get debug info fixed. */" \ - % Author: hernande Date: Fri Dec 4 14:07:10 2009 New Revision: 90581 URL: http://llvm.org/viewvc/llvm-project?rev=90581&view=rev Log: Avoid creating a metadata slot for all metadata that contains an instruction Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90581&r1=90580&r2=90581&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Fri Dec 4 14:07:10 2009 @@ -695,13 +695,8 @@ !I->hasName()) CreateFunctionSlot(I); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { - // Create a metadata slot only if N contains no instructions. - for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) - if (N->getElement(n) && isa(N->getElement(n))) - continue; + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) CreateMetadataSlot(N); - } // Process metadata attached with this instruction. MDs.clear(); @@ -818,6 +813,11 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) { assert(N && "Can't insert a null Value into SlotTracker!"); + // Don't insert if N contains an instruction. + for (unsigned i = 0, e = N->getNumElements(); i != e; ++i) + if (N->getElement(i) && isa(N->getElement(i))) + return; + ValueMap::iterator I = mdnMap.find(N); if (I != mdnMap.end()) return; From vhernandez at apple.com Fri Dec 4 14:28:27 2009 From: vhernandez at apple.com (Victor Hernandez) Date: Fri, 4 Dec 2009 12:28:27 -0800 Subject: [llvm-commits] [llvm] r90512 - /llvm/trunk/lib/VMCore/AsmWriter.cpp In-Reply-To: <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> References: <200912040135.nB41Z27L007524@zion.cs.uiuc.edu> <5BBED35B-7D2B-47ED-A27A-C48F84E8FBBA@apple.com> Message-ID: <9867B3A7-C062-418F-8C74-3E8968F3001B@apple.com> I fixed this in r 90581. Victor On Dec 3, 2009, at 5:37 PM, Devang Patel wrote: > Hi Victor, > On Dec 3, 2009, at 5:35 PM, Victor Hernandez wrote: > >> Author: hernande >> Date: Thu Dec 3 19:35:02 2009 >> New Revision: 90512 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90512&view=rev >> Log: >> Teach AsmWriter to write inline (not via a global metadata slot) metadata that contains an instruction >> >> Modified: >> llvm/trunk/lib/VMCore/AsmWriter.cpp >> >> Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90512&r1=90511&r2=90512&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) >> +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Dec 3 19:35:02 2009 >> @@ -695,8 +695,13 @@ >> !I->hasName()) >> CreateFunctionSlot(I); >> for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) >> - if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) >> + if (MDNode *N = dyn_cast_or_null(I->getOperand(i))) { >> + // Create a metadata slot only if N contains no instructions. >> + for (unsigned n = 0, e = N->getNumElements(); n != e; ++n) >> + if (isa(N->getElement(n))) >> + continue; >> CreateMetadataSlot(N); >> + } >> >> // Process metadata attached with this instruction. >> MDs.clear(); > > There are other places where CreateMetadataSlot() is used. Please move this check in side CreateMetadataSlot(). > - > Devang From isanbard at gmail.com Fri Dec 4 15:03:02 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 04 Dec 2009 21:03:02 -0000 Subject: [llvm-commits] [llvm] r90588 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912042103.nB4L32Yt031594@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 15:03:02 2009 New Revision: 90588 URL: http://llvm.org/viewvc/llvm-project?rev=90588&view=rev Log: Some code cleanup. No functionality change. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90588&r1=90587&r2=90588&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Fri Dec 4 15:03:02 2009 @@ -315,11 +315,12 @@ : Alignments[BestMatchIdx].PrefAlign; } -typedef DenseMap LayoutInfoTy; - namespace { class StructLayoutMap : public AbstractTypeUser { +public: + typedef DenseMap LayoutInfoTy; +private: LayoutInfoTy LayoutInfo; /// refineAbstractType - The callback method invoked when an abstract type is @@ -328,9 +329,7 @@ /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { - const StructType *STy = dyn_cast(OldTy); - assert(STy && "This can only track struct types."); - + const StructType *STy = cast(OldTy); LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); Iter->second->~StructLayout(); free(Iter->second); @@ -344,9 +343,7 @@ /// This method notifies ATU's when this occurs for a type. /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { - const StructType *STy = dyn_cast(AbsTy); - assert(STy && "This can only track struct types."); - + const StructType *STy = cast(AbsTy); LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); Iter->second->~StructLayout(); free(Iter->second); @@ -362,13 +359,11 @@ const Type *Key = I->first; StructLayout *Value = I->second; - if (Key && Key->isAbstract()) + if (Key->isAbstract()) Key->removeAbstractTypeUser(this); - if (Value) { - Value->~StructLayout(); - free(Value); - } + Value->~StructLayout(); + free(Value); } } @@ -392,7 +387,7 @@ virtual void dump() const {} }; -} // end namespace llvm +} // end anonymous namespace TargetData::~TargetData() { delete static_cast(LayoutMap); @@ -432,7 +427,7 @@ if (!LayoutMap) return; // No cache. StructLayoutMap *STM = static_cast(LayoutMap); - LayoutInfoTy::iterator I = STM->find(Ty); + StructLayoutMap::LayoutInfoTy::iterator I = STM->find(Ty); if (I == STM->end()) return; I->second->~StructLayout(); From dpatel at apple.com Fri Dec 4 15:07:12 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 04 Dec 2009 21:07:12 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90590 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-convert.cpp llvm-internal.h llvm-types.cpp tree.h Message-ID: <200912042107.nB4L7CZR031791@zion.cs.uiuc.edu> Author: dpatel Date: Fri Dec 4 15:07:12 2009 New Revision: 90590 URL: http://llvm.org/viewvc/llvm-project?rev=90590&view=rev Log: Do not use std::map on the side to store mapping between FIELD_DECL and llvm field index. The map will not be restored when PCH is read. Store llvm field index directly inside FIELD_DECL. Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h llvm-gcc-4.2/trunk/gcc/llvm-types.cpp llvm-gcc-4.2/trunk/gcc/tree.h Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=90590&r1=90589&r2=90590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Dec 4 15:07:12 2009 @@ -510,7 +510,7 @@ if (TREE_CODE(Field) == FIELD_DECL) { const tree Ftype = getDeclaredType(Field); const Type *FTy = ConvertType(Ftype); - unsigned FNo = GetFieldIndex(Field); + unsigned FNo = GET_LLVM_FIELD_INDEX(Field); assert(FNo != ~0U && "Case not handled yet!"); // Currently, a bvyal type inside a non-byval struct is a zero-length 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=90590&r1=90589&r2=90590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Dec 4 15:07:12 2009 @@ -6576,7 +6576,7 @@ tree field_offset = component_ref_field_offset (exp); // If this is a normal field at a fixed offset from the start, handle it. if (TREE_CODE(field_offset) == INTEGER_CST) { - unsigned int MemberIndex = GetFieldIndex(FieldDecl); + unsigned int MemberIndex = GET_LLVM_FIELD_INDEX(FieldDecl); // If the LLVM struct has zero field, don't try to index into it, just use // the current pointer. @@ -8082,7 +8082,7 @@ tree field_offset = component_ref_field_offset (exp); // If this is a normal field at a fixed offset from the start, handle it. if (TREE_CODE(field_offset) == INTEGER_CST) { - unsigned int MemberIndex = GetFieldIndex(FieldDecl); + unsigned int MemberIndex = GET_LLVM_FIELD_INDEX(FieldDecl); Constant *Ops[] = { StructAddrLV, Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=90590&r1=90589&r2=90590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Fri Dec 4 15:07:12 2009 @@ -126,18 +126,11 @@ /// std::vector PointersToReresolve; - /// FieldIndexMap - Holds the mapping from a FIELD_DECL to the index of the - /// corresponding LLVM field. - std::map FieldIndexMap; public: TypeConverter() : ConvertingStruct(false) {} const Type *ConvertType(tree_node *type); - /// GetFieldIndex - Returns the index of the LLVM field corresponding to - /// this FIELD_DECL. - unsigned int GetFieldIndex(tree_node *field_decl); - /// GCCTypeOverlapsWithLLVMTypePadding - Return true if the specified GCC type /// has any data that overlaps with structure padding in the specified LLVM /// type. @@ -165,7 +158,6 @@ private: const Type *ConvertRECORD(tree_node *type, tree_node *orig_type); const Type *ConvertUNION(tree_node *type, tree_node *orig_type); - void SetFieldIndex(tree_node *field_decl, unsigned int Index); bool DecodeStructFields(tree_node *Field, StructTypeConversionInfo &Info); void DecodeStructBitField(tree_node *Field, StructTypeConversionInfo &Info); void SelectUnionMember(tree_node *type, StructTypeConversionInfo &Info); @@ -179,12 +171,6 @@ return TheTypeConverter->ConvertType(type); } -/// GetFieldIndex - Given FIELD_DECL obtain its index. -/// -inline unsigned int GetFieldIndex(tree_node *field_decl) { - return TheTypeConverter->GetFieldIndex(field_decl); -} - /// getINTEGER_CSTVal - Return the specified INTEGER_CST value as a uint64_t. /// uint64_t getINTEGER_CSTVal(tree_node *exp); Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=90590&r1=90589&r2=90590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Dec 4 15:07:12 2009 @@ -651,23 +651,6 @@ } } -/// GetFieldIndex - Returns the index of the LLVM field corresponding to -/// this FIELD_DECL, or ~0U if the type the field belongs to has not yet -/// been converted. -unsigned int TypeConverter::GetFieldIndex(tree field_decl) { - assert(TREE_CODE(field_decl) == FIELD_DECL && "Not a FIELD_DECL!"); - std::map::iterator I = FieldIndexMap.find(field_decl); - assert(I != FieldIndexMap.end() && "Type not laid out for LLVM?"); - return I->second; -} - -/// SetFieldIndex - Set the index of the LLVM field corresponding to -/// this FIELD_DECL. -void TypeConverter::SetFieldIndex(tree_node *field_decl, unsigned int Index) { - assert(TREE_CODE(field_decl) == FIELD_DECL && "Not a FIELD_DECL!"); - FieldIndexMap[field_decl] = Index; -} - bool TypeConverter::GCCTypeOverlapsWithLLVMTypePadding(tree type, const Type *Ty) { @@ -2242,7 +2225,7 @@ TREE_CODE(DECL_FIELD_OFFSET(Field)) == INTEGER_CST) { if (HasOnlyZeroOffsets) { // Set the field idx to zero for all members of a union. - SetFieldIndex(Field, 0); + SET_LLVM_FIELD_INDEX(Field, 0); } else { uint64_t FieldOffsetInBits = getFieldOffsetInBits(Field); tree FieldType = getDeclaredType(Field); @@ -2274,7 +2257,7 @@ unsigned FieldNo = Info->getLLVMFieldFor(FieldOffsetInBits, CurFieldNo, isZeroSizeField); - SetFieldIndex(Field, FieldNo); + SET_LLVM_FIELD_INDEX(Field, FieldNo); assert((isBitfield(Field) || FieldNo == ~0U || FieldOffsetInBits == 8*Info->ElementOffsetInBytes[FieldNo]) && Modified: llvm-gcc-4.2/trunk/gcc/tree.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/tree.h?rev=90590&r1=90589&r2=90590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/tree.h (original) +++ llvm-gcc-4.2/trunk/gcc/tree.h Fri Dec 4 15:07:12 2009 @@ -2782,6 +2782,9 @@ tree bit_offset; tree fcontext; + /* LLVM LOCAL begin */ + unsigned llvm_field_index; /* Field index in llvm struct. */ + /* LLVM LOCAL end */ }; /* A numeric unique identifier for a LABEL_DECL. The UID allocation is @@ -2864,6 +2867,9 @@ #define SET_DECL_LLVM_INDEX(NODE, INDEX) \ (DECL_WRTL_CHECK(NODE)->decl_with_rtl.llvm = INDEX) #define GET_DECL_LLVM_INDEX(NODE) (DECL_WRTL_CHECK(NODE)->decl_with_rtl.llvm) +#define GET_LLVM_FIELD_INDEX(NODE) (FIELD_DECL_CHECK(NODE)->field_decl.llvm_field_index) +#define SET_LLVM_FIELD_INDEX(NODE, INDEX) \ + (FIELD_DECL_CHECK(NODE)->field_decl.llvm_field_index = INDEX) /* Returns nonzero if the DECL_LLVM for NODE has already been set. */ extern bool llvm_set_decl_p(tree); From baldrick at free.fr Fri Dec 4 15:36:50 2009 From: baldrick at free.fr (Duncan Sands) Date: Fri, 04 Dec 2009 21:36:50 -0000 Subject: [llvm-commits] [dragonegg] r90598 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <200912042136.nB4LaowA000763@zion.cs.uiuc.edu> Author: baldrick Date: Fri Dec 4 15:36:50 2009 New Revision: 90598 URL: http://llvm.org/viewvc/llvm-project?rev=90598&view=rev Log: Emit wrong code rather than crashing. 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=90598&r1=90597&r2=90598&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Dec 4 15:36:50 2009 @@ -6880,7 +6880,7 @@ } void TreeToLLVM::RenderGIMPLE_RESX(gimple stmt) { -abort(); + Builder.CreateUnwind(); // FIXME //FIXME int RegionNo = gimple_resx_region(stmt); //FIXME std::vector Handlers; //FIXME From daniel at zuster.org Fri Dec 4 15:41:24 2009 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 04 Dec 2009 21:41:24 -0000 Subject: [llvm-commits] [llvm] r90599 - /llvm/trunk/utils/TableGen/OptParserEmitter.cpp Message-ID: <200912042141.nB4LfOYu000932@zion.cs.uiuc.edu> Author: ddunbar Date: Fri Dec 4 15:41:24 2009 New Revision: 90599 URL: http://llvm.org/viewvc/llvm-project?rev=90599&view=rev Log: OptParser: Emit HelpText field for option groups. Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=90599&r1=90598&r2=90599&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Fri Dec 4 15:41:24 2009 @@ -127,7 +127,18 @@ OS << "INVALID"; // The other option arguments (unused for groups). - OS << ", INVALID, 0, 0, 0, 0)\n"; + OS << ", INVALID, 0, 0"; + + // The option help text. + if (!dynamic_cast(R.getValueInit("HelpText"))) { + OS << ",\n"; + OS << " "; + write_cstring(OS, R.getValueAsString("HelpText")); + } else + OS << ", 0"; + + // The option meta-variable name (unused). + OS << ", 0)\n"; } OS << "\n"; From bob.wilson at apple.com Fri Dec 4 15:51:36 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 04 Dec 2009 21:51:36 -0000 Subject: [llvm-commits] [llvm] r90601 - /llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Message-ID: <200912042151.nB4LpaEJ001394@zion.cs.uiuc.edu> Author: bwilson Date: Fri Dec 4 15:51:35 2009 New Revision: 90601 URL: http://llvm.org/viewvc/llvm-project?rev=90601&view=rev Log: Fix 80-column violations. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=90601&r1=90600&r2=90601&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Dec 4 15:51:35 2009 @@ -503,7 +503,6 @@ } } - isSafeElementUse(GEP, AreAllZeroIndices, AI, Info); if (Info.isUnsafe) return; break; @@ -614,7 +613,7 @@ // integer. Specifically, consider A[0][i]. We cannot know that the user // isn't doing invalid things like allowing i to index an out-of-range // subscript that accesses A[1]. Because of this, we have to reject SROA - // of any accesses into structs where any of the components are variables. + // of any accesses into structs where any of the components are variables. if (IdxVal->getZExtValue() >= AT->getNumElements()) return MarkUnsafe(Info); } else if (const VectorType *VT = dyn_cast(*I)) { @@ -1481,7 +1480,8 @@ if (StoreInst *SI = dyn_cast(User)) { assert(SI->getOperand(0) != Ptr && "Consistency error!"); // FIXME: Remove once builder has Twine API. - Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str()); + Value *Old = Builder.CreateLoad(NewAI, + (NewAI->getName()+".in").str().c_str()); Value *New = ConvertScalar_InsertValue(SI->getOperand(0), Old, Offset, Builder); Builder.CreateStore(New, NewAI); @@ -1506,7 +1506,8 @@ APVal |= APVal << 8; // FIXME: Remove once builder has Twine API. - Value *Old = Builder.CreateLoad(NewAI, (NewAI->getName()+".in").str().c_str()); + Value *Old = Builder.CreateLoad(NewAI, + (NewAI->getName()+".in").str().c_str()); Value *New = ConvertScalar_InsertValue( ConstantInt::get(User->getContext(), APVal), Old, Offset, Builder); From bob.wilson at apple.com Fri Dec 4 15:57:37 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 04 Dec 2009 21:57:37 -0000 Subject: [llvm-commits] [llvm] r90603 - /llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Message-ID: <200912042157.nB4LvboF001654@zion.cs.uiuc.edu> Author: bwilson Date: Fri Dec 4 15:57:37 2009 New Revision: 90603 URL: http://llvm.org/viewvc/llvm-project?rev=90603&view=rev Log: Fix up some comments. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=90603&r1=90602&r2=90603&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Dec 4 15:57:37 2009 @@ -450,11 +450,9 @@ NumReplaced++; } - /// isSafeElementUse - Check to see if this use is an allowed use for a /// getelementptr instruction of an array aggregate allocation. isFirstElt /// indicates whether Ptr is known to the start of the aggregate. -/// void SROA::isSafeElementUse(Value *Ptr, bool isFirstElt, AllocaInst *AI, AllocaInfo &Info) { for (Value::use_iterator I = Ptr->use_begin(), E = Ptr->use_end(); @@ -544,7 +542,6 @@ /// isSafeUseOfAllocation - Check to see if this user is an allowed use for an /// aggregate allocation. -/// void SROA::isSafeUseOfAllocation(Instruction *User, AllocaInst *AI, AllocaInfo &Info) { if (BitCastInst *C = dyn_cast(User)) @@ -627,7 +624,7 @@ return isSafeElementUse(GEPI, IsAllZeroIndices, AI, Info); } -/// isSafeMemIntrinsicOnAllocation - Return true if the specified memory +/// isSafeMemIntrinsicOnAllocation - Check if the specified memory /// intrinsic can be promoted by SROA. At this point, we know that the operand /// of the memintrinsic is a pointer to the beginning of the allocation. void SROA::isSafeMemIntrinsicOnAllocation(MemIntrinsic *MI, AllocaInst *AI, @@ -655,8 +652,8 @@ } } -/// isSafeUseOfBitCastedAllocation - Return true if all users of this bitcast -/// are +/// isSafeUseOfBitCastedAllocation - Check if all users of this bitcast +/// from an alloca are safe for SROA of that alloca. void SROA::isSafeUseOfBitCastedAllocation(BitCastInst *BC, AllocaInst *AI, AllocaInfo &Info) { for (Value::use_iterator UI = BC->use_begin(), E = BC->use_end(); @@ -927,7 +924,7 @@ MI->eraseFromParent(); } -/// RewriteStoreUserOfWholeAlloca - We found an store of an integer that +/// RewriteStoreUserOfWholeAlloca - We found a store of an integer that /// overwrites the entire allocation. Extract out the pieces of the stored /// integer and store them individually. void SROA::RewriteStoreUserOfWholeAlloca(StoreInst *SI, AllocaInst *AI, @@ -1051,7 +1048,7 @@ SI->eraseFromParent(); } -/// RewriteLoadUserOfWholeAlloca - We found an load of the entire allocation to +/// RewriteLoadUserOfWholeAlloca - We found a load of the entire allocation to /// an integer. Load the individual pieces to form the aggregate value. void SROA::RewriteLoadUserOfWholeAlloca(LoadInst *LI, AllocaInst *AI, SmallVector &NewElts) { @@ -1185,7 +1182,6 @@ /// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of /// an aggregate can be broken down into elements. Return 0 if not, 3 if safe, /// or 1 if safe after canonicalization has been performed. -/// int SROA::isSafeAllocaToScalarRepl(AllocaInst *AI) { // Loop over the use list of the alloca. We can only transform it if all of // the users are safe to transform. @@ -1354,7 +1350,6 @@ /// /// If we see at least one access to the value that is as a vector type, set the /// SawVec flag. -/// bool SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial, const Type *&VecTy, bool &SawVec, uint64_t Offset, unsigned AllocaSize) { @@ -1437,7 +1432,6 @@ return true; } - /// ConvertUsesToScalar - Convert all of the users of Ptr to use the new alloca /// directly. This happens when we are converting an "integer union" to a /// single integer scalar, or when we are converting a "vector union" to a @@ -1680,7 +1674,6 @@ return FromVal; } - /// ConvertScalar_InsertValue - Insert the value "SV" into the existing integer /// or vector value "Old" at the offset specified by Offset. /// From greened at obbligato.org Fri Dec 4 16:38:46 2009 From: greened at obbligato.org (David Greene) Date: Fri, 04 Dec 2009 22:38:46 -0000 Subject: [llvm-commits] [llvm] r90608 - in /llvm/trunk/lib/Target/X86: X86InstrInfo.cpp X86InstrInfo.h Message-ID: <200912042238.nB4Mckif003182@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 16:38:46 2009 New Revision: 90608 URL: http://llvm.org/viewvc/llvm-project?rev=90608&view=rev Log: Have hasLoad/StoreFrom/ToStackSlot return the relevant MachineMemOperand. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=90608&r1=90607&r2=90608&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Dec 4 16:38:46 2009 @@ -34,6 +34,7 @@ #include "llvm/MC/MCAsmInfo.h" #include +#include using namespace llvm; @@ -783,12 +784,14 @@ if ((Reg = isLoadFromStackSlot(MI, FrameIndex))) return Reg; // Check for post-frame index elimination operations - return hasLoadFromStackSlot(MI, FrameIndex); + const MachineMemOperand *Dummy; + return hasLoadFromStackSlot(MI, Dummy, FrameIndex); } return 0; } bool X86InstrInfo::hasLoadFromStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, int &FrameIndex) const { for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), oe = MI->memoperands_end(); @@ -798,6 +801,7 @@ if (const FixedStackPseudoSourceValue *Value = dyn_cast((*o)->getValue())) { FrameIndex = Value->getFrameIndex(); + MMO = *o; return true; } } @@ -819,12 +823,14 @@ if ((Reg = isStoreToStackSlot(MI, FrameIndex))) return Reg; // Check for post-frame index elimination operations - return hasStoreToStackSlot(MI, FrameIndex); + const MachineMemOperand *Dummy; + return hasStoreToStackSlot(MI, Dummy, FrameIndex); } return 0; } bool X86InstrInfo::hasStoreToStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, int &FrameIndex) const { for (MachineInstr::mmo_iterator o = MI->memoperands_begin(), oe = MI->memoperands_end(); @@ -834,6 +840,7 @@ if (const FixedStackPseudoSourceValue *Value = dyn_cast((*o)->getValue())) { FrameIndex = Value->getFrameIndex(); + MMO = *o; return true; } } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=90608&r1=90607&r2=90608&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Fri Dec 4 16:38:46 2009 @@ -457,11 +457,14 @@ /// hasLoadFromStackSlot - If the specified machine instruction has /// a load from a stack slot, return true along with the FrameIndex - /// of the loaded stack slot. If not, return false. Unlike + /// of the loaded stack slot and the machine mem operand containing + /// the reference. If not, return false. Unlike /// isLoadFromStackSlot, this returns true for any instructions that /// loads from the stack. This is a hint only and may not catch all /// cases. - bool hasLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const; + bool hasLoadFromStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, + int &FrameIndex) const; unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; /// isStoreToStackSlotPostFE - Check for post-frame ptr elimination @@ -472,11 +475,13 @@ /// hasStoreToStackSlot - If the specified machine instruction has a /// store to a stack slot, return true along with the FrameIndex of - /// the loaded stack slot. If not, return false. Unlike - /// isStoreToStackSlot, this returns true for any instructions that - /// loads from the stack. This is a hint only and may not catch all - /// cases. - bool hasStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const; + /// the loaded stack slot and the machine mem operand containing the + /// reference. If not, return false. Unlike isStoreToStackSlot, + /// this returns true for any instructions that loads from the + /// stack. This is a hint only and may not catch all cases. + bool hasStoreToStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, + int &FrameIndex) const; bool isReallyTriviallyReMaterializable(const MachineInstr *MI, AliasAnalysis *AA) const; From greened at obbligato.org Fri Dec 4 16:46:04 2009 From: greened at obbligato.org (David Greene) Date: Fri, 04 Dec 2009 22:46:04 -0000 Subject: [llvm-commits] [llvm] r90611 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200912042246.nB4Mk5ru003529@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 16:46:04 2009 New Revision: 90611 URL: http://llvm.org/viewvc/llvm-project?rev=90611&view=rev Log: Use new interfaces to print spill size. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=90611&r1=90610&r2=90611&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Dec 4 16:46:04 2009 @@ -1857,35 +1857,38 @@ // We assume a single instruction only has a spill or reload, not // both. + const MachineMemOperand *MMO; if (TM.getInstrInfo()->isLoadFromStackSlotPostFE(&MI, FI)) { if (FrameInfo->isSpillSlotObjectIndex(FI)) { + MMO = *MI.memoperands_begin(); if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Reload"; + O << MAI->getCommentString() << MMO->getSize() << "-byte Reload"; Newline = true; } } - else if (TM.getInstrInfo()->hasLoadFromStackSlot(&MI, FI)) { + else if (TM.getInstrInfo()->hasLoadFromStackSlot(&MI, MMO, FI)) { if (FrameInfo->isSpillSlotObjectIndex(FI)) { if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Folded Reload"; + O << MAI->getCommentString() << MMO->getSize() << "-byte Folded Reload"; Newline = true; } } else if (TM.getInstrInfo()->isStoreToStackSlotPostFE(&MI, FI)) { if (FrameInfo->isSpillSlotObjectIndex(FI)) { + MMO = *MI.memoperands_begin(); if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Spill"; + O << MAI->getCommentString() << MMO->getSize() << "-byte Spill"; Newline = true; } } - else if (TM.getInstrInfo()->hasStoreToStackSlot(&MI, FI)) { + else if (TM.getInstrInfo()->hasStoreToStackSlot(&MI, MMO, FI)) { if (FrameInfo->isSpillSlotObjectIndex(FI)) { if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " Folded Spill"; + O << MAI->getCommentString() << MMO->getSize() << "-byte Folded Spill"; Newline = true; } } From isanbard at gmail.com Fri Dec 4 16:46:09 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 04 Dec 2009 22:46:09 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90612 - in /llvm-gcc-4.2/trunk/gcc: cgraph.c cgraph.h cgraphunit.c cp/semantics.c ipa.c llvm-convert.cpp Message-ID: <200912042246.nB4Mk9tB003547@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 16:46:09 2009 New Revision: 90612 URL: http://llvm.org/viewvc/llvm-project?rev=90612&view=rev Log: Revert r72619. It was causing problems with explicit vs. implicit instantiation. See this discussion thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-December/027646.html Along with this PR: http://llvm.org/bugs/show_bug.cgi?id=4262 Modified: llvm-gcc-4.2/trunk/gcc/cgraph.c llvm-gcc-4.2/trunk/gcc/cgraph.h llvm-gcc-4.2/trunk/gcc/cgraphunit.c llvm-gcc-4.2/trunk/gcc/cp/semantics.c llvm-gcc-4.2/trunk/gcc/ipa.c llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/cgraph.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.c?rev=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cgraph.c (original) +++ llvm-gcc-4.2/trunk/gcc/cgraph.c Fri Dec 4 16:46:09 2009 @@ -601,7 +601,7 @@ if (!n->next_clone && !n->global.inlined_to && (cgraph_global_info_ready /* LLVM LOCAL extern inline */ - && (TREE_ASM_WRITTEN (n->decl) || OMIT_FUNCTION_BODY (n->decl)))) + && (TREE_ASM_WRITTEN (n->decl) || IS_EXTERN_INLINE (n->decl)))) kill_body = true; } @@ -1185,7 +1185,7 @@ else if (!(*targetm.binds_local_p) (node->decl) /* LLVM LOCAL extern inline */ - && !DECL_COMDAT (node->decl) && !OMIT_FUNCTION_BODY (node->decl)) + && !DECL_COMDAT (node->decl) && !IS_EXTERN_INLINE (node->decl)) avail = AVAIL_OVERWRITABLE; else avail = AVAIL_AVAILABLE; Modified: llvm-gcc-4.2/trunk/gcc/cgraph.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraph.h?rev=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cgraph.h (original) +++ llvm-gcc-4.2/trunk/gcc/cgraph.h Fri Dec 4 16:46:09 2009 @@ -335,12 +335,14 @@ bool cgraph_default_inline_p (struct cgraph_node *, const char **); /* LLVM LOCAL begin 6501843 */ -/* Make sure bodies of "extern inline" functions are output to LLVM IR. +/* We're no longer running gcc's inliner at all, so the bodies of + used extern always-inline functions must be passed down to the LLVM BE. cgraph used to remove these. (gcc "extern inline" == c99 "inline") */ #ifdef ENABLE_LLVM -#define OMIT_FUNCTION_BODY(f) (false) +#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f) && \ + !lookup_attribute("always_inline", DECL_ATTRIBUTES(f))) #else -#define OMIT_FUNCTION_BODY(f) (DECL_EXTERNAL(f)) +#define IS_EXTERN_INLINE(f) (DECL_EXTERNAL(f)) #endif /* LLVM LOCAL end */ #endif /* GCC_CGRAPH_H */ Modified: llvm-gcc-4.2/trunk/gcc/cgraphunit.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cgraphunit.c?rev=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cgraphunit.c (original) +++ llvm-gcc-4.2/trunk/gcc/cgraphunit.c Fri Dec 4 16:46:09 2009 @@ -385,7 +385,7 @@ if (!n->global.inlined_to && !n->alias /* LLVM LOCAL extern inline */ - && !OMIT_FUNCTION_BODY (n->decl)) + && !IS_EXTERN_INLINE (n->decl)) { cgraph_expand_function (n); output = true; @@ -849,7 +849,7 @@ if (node->analyzed && DECL_SAVED_TREE (node->decl) && !TREE_ASM_WRITTEN (node->decl) /* LLVM LOCAL extern inline */ - && (!OMIT_FUNCTION_BODY (node->decl) || node->global.inlined_to)) + && (!IS_EXTERN_INLINE (node->decl) || node->global.inlined_to)) { if (this_cfun->cfg) { @@ -942,10 +942,7 @@ if (!TREE_ASM_WRITTEN (decl) && !node->alias - /* LLVM LOCAL begin extern inline */ - && (!DECL_EXTERNAL (decl) || - (TREE_CODE (decl) == FUNCTION_DECL && !OMIT_FUNCTION_BODY(decl))) - /* LLVM LOCAL end extern inline */ + && !DECL_EXTERNAL (decl) && (TREE_CODE (decl) != VAR_DECL || !DECL_HAS_VALUE_EXPR_P (decl))) { assemble_variable (decl, 0, 1, 0); @@ -1298,7 +1295,7 @@ || (e && node->reachable)) && !TREE_ASM_WRITTEN (decl) /* LLVM LOCAL extern inline */ - && !OMIT_FUNCTION_BODY (decl)) + && !IS_EXTERN_INLINE (decl)) node->output = 1; else { @@ -1306,7 +1303,7 @@ #ifdef ENABLE_CHECKING if (!node->global.inlined_to && DECL_SAVED_TREE (decl) /* LLVM LOCAL extern inline */ - && !OMIT_FUNCTION_BODY (decl)) + && !IS_EXTERN_INLINE (decl)) { dump_cgraph_node (stderr, node); internal_error ("failed to reclaim unneeded function"); @@ -1314,7 +1311,7 @@ #endif /* LLVM LOCAL extern inline */ gcc_assert (node->global.inlined_to || !DECL_SAVED_TREE (decl) - || OMIT_FUNCTION_BODY (decl)); + || IS_EXTERN_INLINE (decl)); } } Modified: llvm-gcc-4.2/trunk/gcc/cp/semantics.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/cp/semantics.c?rev=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/cp/semantics.c (original) +++ llvm-gcc-4.2/trunk/gcc/cp/semantics.c Fri Dec 4 16:46:09 2009 @@ -3223,18 +3223,14 @@ `-fexternal-templates'; we instantiate the function, even though we're not planning on emitting it, in case we get a chance to inline it. */ - /* LLVM LOCAL extern inline */ - if (OMIT_FUNCTION_BODY (fn)) + if (DECL_EXTERNAL (fn)) return; /* ??? When is this needed? */ saved_function = current_function_decl; /* Emit any thunks that should be emitted at the same time as FN. */ - /* LLVM LOCAL begin extern inline */ - if (!DECL_EXTERNAL (fn)) - emit_associated_thunks (fn); - /* LLVM LOCAL end extern inline */ + emit_associated_thunks (fn); /* This function is only called from cgraph, or recursively from emit_associated_thunks. In neither case should we be currently Modified: llvm-gcc-4.2/trunk/gcc/ipa.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ipa.c?rev=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ipa.c (original) +++ llvm-gcc-4.2/trunk/gcc/ipa.c Fri Dec 4 16:46:09 2009 @@ -113,7 +113,7 @@ for (node = cgraph_nodes; node; node = node->next) if (node->needed && !node->global.inlined_to /* LLVM LOCAL extern inline */ - && ((!OMIT_FUNCTION_BODY (node->decl)) + && ((!IS_EXTERN_INLINE (node->decl)) || !node->analyzed || before_inlining_p)) { @@ -137,7 +137,7 @@ && node->analyzed && (!e->inline_failed || !e->callee->analyzed /* LLVM LOCAL extern inline */ - || !OMIT_FUNCTION_BODY(e->callee->decl) + || !IS_EXTERN_INLINE(e->callee->decl) || before_inlining_p)) { e->callee->aux = first; @@ -169,7 +169,7 @@ if (file) fprintf (file, " %s", cgraph_node_name (node)); /* LLVM LOCAL extern inline */ - if (!node->analyzed || !OMIT_FUNCTION_BODY(node->decl) + if (!node->analyzed || !IS_EXTERN_INLINE(node->decl) || before_inlining_p) cgraph_remove_node (node); else 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=90612&r1=90611&r2=90612&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Dec 4 16:46:09 2009 @@ -490,14 +490,21 @@ // The function should not already have a body. assert(Fn->empty() && "Function expanded multiple times!"); - + // Compute the linkage that the function should get. + // Functions declared "always inline" should not have a body + // emitted; hack this by pretending they're static. That will either + // make them go away or emit a static definition that won't collide with + // anything. if (DECL_LLVM_PRIVATE(FnDecl)) { Fn->setLinkage(Function::PrivateLinkage); } else if (DECL_LLVM_LINKER_PRIVATE(FnDecl)) { Fn->setLinkage(Function::LinkerPrivateLinkage); } else if (!TREE_PUBLIC(FnDecl) /*|| lang_hooks.llvm_is_in_anon(subr)*/) { Fn->setLinkage(Function::InternalLinkage); + } else if (DECL_EXTERNAL(FnDecl) && + lookup_attribute ("always_inline", DECL_ATTRIBUTES (FnDecl))) { + Fn->setLinkage(Function::InternalLinkage); } else if (DECL_COMDAT(FnDecl)) { Fn->setLinkage(Function::getLinkOnceLinkage(flag_odr)); } else if (DECL_WEAK(FnDecl)) { @@ -505,8 +512,6 @@ Fn->setLinkage(Function::WeakAnyLinkage); } else if (DECL_ONE_ONLY(FnDecl)) { Fn->setLinkage(Function::getWeakLinkage(flag_odr)); - } else if (DECL_EXTERNAL(FnDecl)) { - Fn->setLinkage(Function::AvailableExternallyLinkage); } #ifdef TARGET_ADJUST_LLVM_LINKAGE From bob.wilson at apple.com Fri Dec 4 16:46:47 2009 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 04 Dec 2009 22:46:47 -0000 Subject: [llvm-commits] [llvm] r90613 - /llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h Message-ID: <200912042246.nB4MklWc003575@zion.cs.uiuc.edu> Author: bwilson Date: Fri Dec 4 16:46:47 2009 New Revision: 90613 URL: http://llvm.org/viewvc/llvm-project?rev=90613&view=rev Log: Fix indentation. Modified: llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h Modified: llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h?rev=90613&r1=90612&r2=90613&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h (original) +++ llvm/trunk/include/llvm/Support/GetElementPtrTypeIterator.h Fri Dec 4 16:46:47 2009 @@ -84,7 +84,7 @@ inline gep_type_iterator gep_type_begin(const User *GEP) { return gep_type_iterator::begin(GEP->getOperand(0)->getType(), - GEP->op_begin()+1); + GEP->op_begin()+1); } inline gep_type_iterator gep_type_end(const User *GEP) { return gep_type_iterator::end(GEP->op_end()); From dag at cray.com Fri Dec 4 16:46:48 2009 From: dag at cray.com (David Greene) Date: Fri, 4 Dec 2009 16:46:48 -0600 Subject: [llvm-commits] [llvm] r90608 - in /llvm/trunk/lib/Target/X86: X86InstrInfo.cpp X86InstrInfo.h In-Reply-To: <200912042238.nB4Mckif003182@zion.cs.uiuc.edu> References: <200912042238.nB4Mckif003182@zion.cs.uiuc.edu> Message-ID: <200912041646.48789.dag@cray.com> On Friday 04 December 2009 16:38, David Greene wrote: > Author: greened > Date: Fri Dec 4 16:38:46 2009 > New Revision: 90608 > > URL: http://llvm.org/viewvc/llvm-project?rev=90608&view=rev > Log: > > Have hasLoad/StoreFrom/ToStackSlot return the relevant MachineMemOperand. Ack! Sorry, this will cause a build failure. I just checked in the fix. Many apologies. -Dave From greened at obbligato.org Fri Dec 4 17:00:50 2009 From: greened at obbligato.org (David Greene) Date: Fri, 04 Dec 2009 23:00:50 -0000 Subject: [llvm-commits] [llvm] r90615 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h Message-ID: <200912042300.nB4N0oOd004150@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 17:00:50 2009 New Revision: 90615 URL: http://llvm.org/viewvc/llvm-project?rev=90615&view=rev Log: Update the TargetInstrInfo interfaces so hasLoad/StoreFrom/ToStackSlot can return a MachineMemOperand. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90615&r1=90614&r2=90615&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Dec 4 17:00:50 2009 @@ -16,6 +16,7 @@ #include "llvm/Target/TargetInstrDesc.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineMemOperand.h" namespace llvm { @@ -182,11 +183,13 @@ /// hasLoadFromStackSlot - If the specified machine instruction has /// a load from a stack slot, return true along with the FrameIndex - /// of the loaded stack slot. If not, return false. Unlike + /// of the loaded stack slot and the machine mem operand containing + /// the reference. If not, return false. Unlike /// isLoadFromStackSlot, this returns true for any instructions that /// loads from the stack. This is just a hint, as some cases may be /// missed. virtual bool hasLoadFromStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, int &FrameIndex) const { return 0; } @@ -205,17 +208,18 @@ /// stack locations as well. This uses a heuristic so it isn't /// reliable for correctness. virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI, - int &FrameIndex) const { + int &FrameIndex) const { return 0; } /// hasStoreToStackSlot - If the specified machine instruction has a /// store to a stack slot, return true along with the FrameIndex of - /// the loaded stack slot. If not, return false. Unlike - /// isStoreToStackSlot, this returns true for any instructions that - /// loads from the stack. This is just a hint, as some cases may be - /// missed. + /// the loaded stack slot and the machine mem operand containing the + /// reference. If not, return false. Unlike isStoreToStackSlot, + /// this returns true for any instructions that loads from the + /// stack. This is just a hint, as some cases may be missed. virtual bool hasStoreToStackSlot(const MachineInstr *MI, + const MachineMemOperand *&MMO, int &FrameIndex) const { return 0; } @@ -543,6 +547,13 @@ /// length. virtual unsigned getInlineAsmLength(const char *Str, const MCAsmInfo &MAI) const; + + /// TailDuplicationLimit - Returns the limit on the number of instructions + /// in basic block MBB beyond which it will not be tail-duplicated. + virtual unsigned TailDuplicationLimit(const MachineBasicBlock &MBB, + unsigned DefaultLimit) const { + return DefaultLimit; + } }; /// TargetInstrInfoImpl - This is the default implementation of From greened at obbligato.org Fri Dec 4 17:08:02 2009 From: greened at obbligato.org (David Greene) Date: Fri, 04 Dec 2009 23:08:02 -0000 Subject: [llvm-commits] [llvm] r90616 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h Message-ID: <200912042308.nB4N820J004377@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 17:08:02 2009 New Revision: 90616 URL: http://llvm.org/viewvc/llvm-project?rev=90616&view=rev Log: Fix a bad merge. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90616&r1=90615&r2=90616&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Dec 4 17:08:02 2009 @@ -547,13 +547,6 @@ /// length. virtual unsigned getInlineAsmLength(const char *Str, const MCAsmInfo &MAI) const; - - /// TailDuplicationLimit - Returns the limit on the number of instructions - /// in basic block MBB beyond which it will not be tail-duplicated. - virtual unsigned TailDuplicationLimit(const MachineBasicBlock &MBB, - unsigned DefaultLimit) const { - return DefaultLimit; - } }; /// TargetInstrInfoImpl - This is the default implementation of From dpatel at apple.com Fri Dec 4 17:10:24 2009 From: dpatel at apple.com (Devang Patel) Date: Fri, 04 Dec 2009 23:10:24 -0000 Subject: [llvm-commits] [llvm] r90617 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200912042310.nB4NAO5i004500@zion.cs.uiuc.edu> Author: dpatel Date: Fri Dec 4 17:10:24 2009 New Revision: 90617 URL: http://llvm.org/viewvc/llvm-project?rev=90617&view=rev Log: In TAG_subrange_type, uppder bound is zero indexed. 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=90617&r1=90616&r2=90617&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Dec 4 17:10:24 2009 @@ -945,8 +945,7 @@ addDIEEntry(DW_Subrange, dwarf::DW_AT_type, dwarf::DW_FORM_ref4, IndexTy); if (L) addSInt(DW_Subrange, dwarf::DW_AT_lower_bound, 0, L); - if (H) - addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H); + addSInt(DW_Subrange, dwarf::DW_AT_upper_bound, 0, H); Buffer.addChild(DW_Subrange); } From isanbard at gmail.com Fri Dec 4 17:16:58 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 04 Dec 2009 23:16:58 -0000 Subject: [llvm-commits] [llvm] r90619 - in /llvm/trunk/test/FrontendC: 2007-04-11-InlineStorageClassC89.c 2007-04-11-InlineStorageClassC99.c Message-ID: <200912042316.nB4NGwuV004716@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 17:16:56 2009 New Revision: 90619 URL: http://llvm.org/viewvc/llvm-project?rev=90619&view=rev Log: Temporarily revert r72620 because r72619 was reverted. Modified: llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC89.c llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC99.c Modified: llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC89.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC89.c?rev=90619&r1=90618&r2=90619&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC89.c (original) +++ llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC89.c Fri Dec 4 17:16:56 2009 @@ -11,8 +11,9 @@ // RUN: grep -v linkonce | count 1 // RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep define | \ // RUN: grep xstatnoWeak | grep internal | count 1 -// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep define | \ -// RUN: grep xextnoWeak | grep available_externally | count 1 +// RUN: %llvmgcc %s -S -emit-llvm -O0 -o - | grep declare | \ +// RUN: grep xextnoWeak | grep -v internal | grep -v weak | \ +// RUN: grep -v linkonce | count 1 inline int xglobWeak(int) __attribute__((weak)); inline int xglobWeak (int i) { return i*2; Modified: llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC99.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC99.c?rev=90619&r1=90618&r2=90619&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC99.c (original) +++ llvm/trunk/test/FrontendC/2007-04-11-InlineStorageClassC99.c Fri Dec 4 17:16:56 2009 @@ -1,13 +1,14 @@ -// RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ -// RUN: grep xglobWeak | grep weak | count 1 +// RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep declare | \ +// RUN: grep xglobWeak | grep extern_weak | count 1 // RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ // RUN: grep xextWeak | grep weak | count 1 // RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ // RUN: grep xWeaknoinline | grep weak | count 1 // RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ // RUN: grep xWeakextnoinline | grep weak | count 1 -// RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ -// RUN: grep xglobnoWeak | grep available_externally | count 1 +// RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep declare | \ +// RUN: grep xglobnoWeak | grep -v internal | grep -v weak | \ +// RUN: grep -v linkonce | count 1 // RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ // RUN: grep xstatnoWeak | grep internal | count 1 // RUN: %llvmgcc -std=c99 %s -S -emit-llvm -O0 -o - | grep define | \ From gohman at apple.com Fri Dec 4 17:19:55 2009 From: gohman at apple.com (Dan Gohman) Date: Fri, 04 Dec 2009 23:19:55 -0000 Subject: [llvm-commits] [llvm] r90621 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <200912042319.nB4NJtLD004829@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 17:19:55 2009 New Revision: 90621 URL: http://llvm.org/viewvc/llvm-project?rev=90621&view=rev Log: Print a space between the comment character and the text. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=90621&r1=90620&r2=90621&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Dec 4 17:19:55 2009 @@ -1863,7 +1863,7 @@ MMO = *MI.memoperands_begin(); if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << MMO->getSize() << "-byte Reload"; + O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Reload"; Newline = true; } } @@ -1871,7 +1871,8 @@ if (FrameInfo->isSpillSlotObjectIndex(FI)) { if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << MMO->getSize() << "-byte Folded Reload"; + O << MAI->getCommentString() << ' ' + << MMO->getSize() << "-byte Folded Reload"; Newline = true; } } @@ -1880,7 +1881,7 @@ MMO = *MI.memoperands_begin(); if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << MMO->getSize() << "-byte Spill"; + O << MAI->getCommentString() << ' ' << MMO->getSize() << "-byte Spill"; Newline = true; } } @@ -1888,7 +1889,8 @@ if (FrameInfo->isSpillSlotObjectIndex(FI)) { if (Newline) O << '\n'; O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << MMO->getSize() << "-byte Folded Spill"; + O << MAI->getCommentString() << ' ' + << MMO->getSize() << "-byte Folded Spill"; Newline = true; } } From clattner at apple.com Fri Dec 4 17:23:05 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 15:23:05 -0800 Subject: [llvm-commits] [llvm] r90608 - in /llvm/trunk/lib/Target/X86: X86InstrInfo.cpp X86InstrInfo.h In-Reply-To: <200912042238.nB4Mckif003182@zion.cs.uiuc.edu> References: <200912042238.nB4Mckif003182@zion.cs.uiuc.edu> Message-ID: <46673FB1-60C0-4807-A399-E5C4448EF2B4@apple.com> On Dec 4, 2009, at 2:38 PM, David Greene wrote: > URL: http://llvm.org/viewvc/llvm-project?rev=90608&view=rev > Log: > > Have hasLoad/StoreFrom/ToStackSlot return the relevant > MachineMemOperand. Hi David, This change is ok, but why the new #include of ? -Chris > > Modified: > llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > llvm/trunk/lib/Target/X86/X86InstrInfo.h > > Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=90608&r1=90607&r2=90608&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Dec 4 16:38:46 > 2009 > @@ -34,6 +34,7 @@ > #include "llvm/MC/MCAsmInfo.h" > > #include > +#include > From clattner at apple.com Fri Dec 4 17:23:56 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 15:23:56 -0800 Subject: [llvm-commits] [llvm] r90615 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h In-Reply-To: <200912042300.nB4N0oOd004150@zion.cs.uiuc.edu> References: <200912042300.nB4N0oOd004150@zion.cs.uiuc.edu> Message-ID: On Dec 4, 2009, at 3:00 PM, David Greene wrote: > Author: greened > Date: Fri Dec 4 17:00:50 2009 > New Revision: 90615 > > URL: http://llvm.org/viewvc/llvm-project?rev=90615&view=rev > Log: > > Update the TargetInstrInfo interfaces so hasLoad/StoreFrom/ToStackSlot > can return a MachineMemOperand. Again, please remove the unneeded #include and just forward declare MachineMemOperand as needed. -Chris > > Modified: > llvm/trunk/include/llvm/Target/TargetInstrInfo.h > > Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90615&r1=90614&r2=90615&view=diff > > = > = > = > = > = > = > = > = > ====================================================================== > --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) > +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Dec 4 > 17:00:50 2009 > @@ -16,6 +16,7 @@ > > #include "llvm/Target/TargetInstrDesc.h" > #include "llvm/CodeGen/MachineFunction.h" > +#include "llvm/CodeGen/MachineMemOperand.h" > > namespace llvm { > > @@ -182,11 +183,13 @@ > > /// hasLoadFromStackSlot - If the specified machine instruction has > /// a load from a stack slot, return true along with the FrameIndex > - /// of the loaded stack slot. If not, return false. Unlike > + /// of the loaded stack slot and the machine mem operand containing > + /// the reference. If not, return false. Unlike > /// isLoadFromStackSlot, this returns true for any instructions that > /// loads from the stack. This is just a hint, as some cases may be > /// missed. > virtual bool hasLoadFromStackSlot(const MachineInstr *MI, > + const MachineMemOperand *&MMO, > int &FrameIndex) const { > return 0; > } > @@ -205,17 +208,18 @@ > /// stack locations as well. This uses a heuristic so it isn't > /// reliable for correctness. > virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI, > - int &FrameIndex) const { > + int &FrameIndex) const { > return 0; > } > > /// hasStoreToStackSlot - If the specified machine instruction has a > /// store to a stack slot, return true along with the FrameIndex of > - /// the loaded stack slot. If not, return false. Unlike > - /// isStoreToStackSlot, this returns true for any instructions that > - /// loads from the stack. This is just a hint, as some cases may > be > - /// missed. > + /// the loaded stack slot and the machine mem operand containing > the > + /// reference. If not, return false. Unlike isStoreToStackSlot, > + /// this returns true for any instructions that loads from the > + /// stack. This is just a hint, as some cases may be missed. > virtual bool hasStoreToStackSlot(const MachineInstr *MI, > + const MachineMemOperand *&MMO, > int &FrameIndex) const { > return 0; > } > @@ -543,6 +547,13 @@ > /// length. > virtual unsigned getInlineAsmLength(const char *Str, > const MCAsmInfo &MAI) const; > + > + /// TailDuplicationLimit - Returns the limit on the number of > instructions > + /// in basic block MBB beyond which it will not be tail-duplicated. > + virtual unsigned TailDuplicationLimit(const MachineBasicBlock &MBB, > + unsigned DefaultLimit) > const { > + return DefaultLimit; > + } > }; > > /// TargetInstrInfoImpl - This is the default implementation of > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Fri Dec 4 17:29:58 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 04 Dec 2009 23:29:58 -0000 Subject: [llvm-commits] [llvm] r90623 - /llvm/trunk/test/FrontendC++/weak-external.cpp Message-ID: <200912042329.nB4NTwSt005348@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 17:29:57 2009 New Revision: 90623 URL: http://llvm.org/viewvc/llvm-project?rev=90623&view=rev Log: Add testcase for PR4262. Added: llvm/trunk/test/FrontendC++/weak-external.cpp Added: llvm/trunk/test/FrontendC++/weak-external.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/weak-external.cpp?rev=90623&view=auto ============================================================================== --- llvm/trunk/test/FrontendC++/weak-external.cpp (added) +++ llvm/trunk/test/FrontendC++/weak-external.cpp Fri Dec 4 17:29:57 2009 @@ -0,0 +1,17 @@ +// RUN: %llvmgxx %s -S -emit-llvm -O2 -o - | not grep {_ZNSs12_S_constructIPKcEEPcT_S3_RKSaIcESt20forward_iterator_tag} +// PR4262 + +// The "basic_string" extern template instantiation declaration is supposed to +// suppress the implicit instantiation of non-inline member functions. Make sure +// that we suppress the implicit instantiation of non-inline member functions +// defined out-of-line. That we aren't instantiating the basic_string +// constructor when we shouldn't be. Such an instantiation forces the implicit +// instantiation of _S_construct. Since _S_construct is a member +// template, it's instantiation is *not* suppressed (despite being in +// basic_string), so we would emit it as a weak definition. + +#include + +void dummysymbol() { + throw(std::runtime_error("string")); +} From greened at obbligato.org Fri Dec 4 17:55:07 2009 From: greened at obbligato.org (David Greene) Date: Fri, 04 Dec 2009 23:55:07 -0000 Subject: [llvm-commits] [llvm] r90625 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <200912042355.nB4Nt7Lg006220@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 17:55:07 2009 New Revision: 90625 URL: http://llvm.org/viewvc/llvm-project?rev=90625&view=rev Log: Remove an unneeded include. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=90625&r1=90624&r2=90625&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Dec 4 17:55:07 2009 @@ -34,7 +34,6 @@ #include "llvm/MC/MCAsmInfo.h" #include -#include using namespace llvm; From gohman at apple.com Fri Dec 4 18:02:37 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:02:37 -0000 Subject: [llvm-commits] [llvm] r90626 - in /llvm/trunk/test: FrontendC++/ FrontendC/ FrontendObjC/ Message-ID: <200912050002.nB502cAx006487@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:02:37 2009 New Revision: 90626 URL: http://llvm.org/viewvc/llvm-project?rev=90626&view=rev Log: Remove now-redundant llvm-as invocations. Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp llvm/trunk/test/FrontendC/2005-06-15-ExpandGotoInternalProblem.c llvm/trunk/test/FrontendC/2005-09-24-AsmUserPrefix.c llvm/trunk/test/FrontendC/2006-01-13-StackSave.c llvm/trunk/test/FrontendC/2006-01-23-FileScopeAsm.c llvm/trunk/test/FrontendC/2006-03-03-MissingInitializer.c llvm/trunk/test/FrontendC/2007-01-24-InlineAsmCModifier.c llvm/trunk/test/FrontendC/2007-04-11-InlineAsmStruct.c llvm/trunk/test/FrontendC/2007-04-11-InlineAsmUnion.c llvm/trunk/test/FrontendC/2007-08-01-LoadStoreAlign.c llvm/trunk/test/FrontendC/2007-12-VarArrayDebug.c llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c llvm/trunk/test/FrontendC/BasicInstrs.c llvm/trunk/test/FrontendC/extern-weak.c llvm/trunk/test/FrontendC/unaligned-memcpy.c llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m Modified: llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-06-StackTrace.cpp?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-06-StackTrace.cpp Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // This is a regression test on debug info to make sure that we can get a // meaningful stack trace from a C++ program. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic // RUN: %compile_c %t.s -o %t.o // RUN: %link %t.o -o %t.exe Modified: llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-NoCompileUnit.cpp?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-NoCompileUnit.cpp Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // This is a regression test on debug info to make sure we don't hit a compile // unit size issue with gdb. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -o NoCompileUnit.s // RUN: %compile_c NoCompileUnit.s -o NoCompileUnit.o // RUN: %link NoCompileUnit.o -o NoCompileUnit.exe Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2006-11-30-Pubnames.cpp?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // This is a regression test on debug info to make sure that we can access // qualified global names. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -o %t.s -O0 // RUN: %compile_c %t.s -o %t.o // RUN: %link %t.o -o %t.exe Modified: llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-07-15-LineNumbers.cpp?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp (original) +++ llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // This is a regression test on debug info to make sure that we can // print line numbers in asm. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep {SrcLine 25} #include Modified: llvm/trunk/test/FrontendC/2005-06-15-ExpandGotoInternalProblem.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2005-06-15-ExpandGotoInternalProblem.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2005-06-15-ExpandGotoInternalProblem.c (original) +++ llvm/trunk/test/FrontendC/2005-06-15-ExpandGotoInternalProblem.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc -std=c99 %s -S -o - | llvm-as | \ +// RUN: %llvmgcc -std=c99 %s -S -o - | \ // RUN: opt -std-compile-opts -disable-output // PR580 Modified: llvm/trunk/test/FrontendC/2005-09-24-AsmUserPrefix.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2005-09-24-AsmUserPrefix.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2005-09-24-AsmUserPrefix.c (original) +++ llvm/trunk/test/FrontendC/2005-09-24-AsmUserPrefix.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -o - | llvm-as | opt -std-compile-opts | llc | \ +// RUN: %llvmgcc %s -S -o - | opt -std-compile-opts | llc | \ // RUN: not grep _foo2 void foo() __asm__("foo2"); Modified: llvm/trunk/test/FrontendC/2006-01-13-StackSave.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2006-01-13-StackSave.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2006-01-13-StackSave.c (original) +++ llvm/trunk/test/FrontendC/2006-01-13-StackSave.c Fri Dec 4 18:02:37 2009 @@ -1,5 +1,5 @@ // PR691 -// RUN: %llvmgcc %s -S -o - | llvm-as | opt -std-compile-opts | \ +// RUN: %llvmgcc %s -S -o - | opt -std-compile-opts | \ // RUN: llvm-dis | grep llvm.stacksave void test(int N) { Modified: llvm/trunk/test/FrontendC/2006-01-23-FileScopeAsm.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2006-01-23-FileScopeAsm.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2006-01-23-FileScopeAsm.c (original) +++ llvm/trunk/test/FrontendC/2006-01-23-FileScopeAsm.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -o - | llvm-as | opt -std-compile-opts | \ +// RUN: %llvmgcc %s -S -o - | opt -std-compile-opts | \ // RUN: llvm-dis | grep {foo\[12345\]} | count 5 __asm__ ("foo1"); Modified: llvm/trunk/test/FrontendC/2006-03-03-MissingInitializer.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2006-03-03-MissingInitializer.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2006-03-03-MissingInitializer.c (original) +++ llvm/trunk/test/FrontendC/2006-03-03-MissingInitializer.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -o - | llvm-as | opt -std-compile-opts | \ +// RUN: %llvmgcc %s -S -o - | opt -std-compile-opts | \ // RUN: llvm-dis | grep {@nate.*internal global i32 0} struct X { int *XX; int Y;}; Modified: llvm/trunk/test/FrontendC/2007-01-24-InlineAsmCModifier.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-01-24-InlineAsmCModifier.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-01-24-InlineAsmCModifier.c (original) +++ llvm/trunk/test/FrontendC/2007-01-24-InlineAsmCModifier.c Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // Verify that the %c modifier works and strips off any prefixes from // immediates. -// RUN: %llvmgcc -S %s -o - | llvm-as | llc | grep {pickANumber: 789514} +// RUN: %llvmgcc -S %s -o - | llc | grep {pickANumber: 789514} void foo() { __asm__ volatile("/* " "pickANumber" ": %c0 */"::"i"(0xC0C0A)); Modified: llvm/trunk/test/FrontendC/2007-04-11-InlineAsmStruct.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-04-11-InlineAsmStruct.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-04-11-InlineAsmStruct.c (original) +++ llvm/trunk/test/FrontendC/2007-04-11-InlineAsmStruct.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llc +// RUN: %llvmgcc %s -S -emit-llvm -o - | llc struct V { short X, Y; }; int bar() { Modified: llvm/trunk/test/FrontendC/2007-04-11-InlineAsmUnion.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-04-11-InlineAsmUnion.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-04-11-InlineAsmUnion.c (original) +++ llvm/trunk/test/FrontendC/2007-04-11-InlineAsmUnion.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llc +// RUN: %llvmgcc %s -S -emit-llvm -o - | llc union U { int x; float p; }; void foo() { Modified: llvm/trunk/test/FrontendC/2007-08-01-LoadStoreAlign.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-08-01-LoadStoreAlign.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-08-01-LoadStoreAlign.c (original) +++ llvm/trunk/test/FrontendC/2007-08-01-LoadStoreAlign.c Fri Dec 4 18:02:37 2009 @@ -1,5 +1,5 @@ // RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep {align 1} | count 2 -// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | llvm-as | llc +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | llc struct p { char a; Modified: llvm/trunk/test/FrontendC/2007-12-VarArrayDebug.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2007-12-VarArrayDebug.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2007-12-VarArrayDebug.c (original) +++ llvm/trunk/test/FrontendC/2007-12-VarArrayDebug.c Fri Dec 4 18:02:37 2009 @@ -1,5 +1,5 @@ -// RUN: %llvmgcc -S -g -O %s -o - | llvm-as | llc -// RUN: %llvmgcc -S -g %s -o - | llvm-as | llc +// RUN: %llvmgcc -S -g -O %s -o - | llc +// RUN: %llvmgcc -S -g %s -o - | llc extern void foo (void); Modified: llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Fri Dec 4 18:02:37 2009 @@ -1,5 +1,5 @@ // Check bitfields. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -o 2009-02-17-BitField-dbg.s // RUN: %compile_c 2009-02-17-BitField-dbg.s -o 2009-02-17-BitField-dbg.o // RUN: echo {ptype mystruct} > %t2 Modified: llvm/trunk/test/FrontendC/BasicInstrs.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/BasicInstrs.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/BasicInstrs.c (original) +++ llvm/trunk/test/FrontendC/BasicInstrs.c Fri Dec 4 18:02:37 2009 @@ -1,7 +1,7 @@ // This file can be used to see what a native C compiler is generating for a // variety of interesting operations. // -// RUN: %llvmgcc -S %s -o - | llvm-as | llc +// RUN: %llvmgcc -S %s -o - | llc unsigned int udiv(unsigned int X, unsigned int Y) { return X/Y; Modified: llvm/trunk/test/FrontendC/extern-weak.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/extern-weak.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/extern-weak.c (original) +++ llvm/trunk/test/FrontendC/extern-weak.c Fri Dec 4 18:02:37 2009 @@ -1,5 +1,5 @@ // RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep extern_weak -// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | llvm-as | llc +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | llc #if !defined(__linux__) && !defined(__FreeBSD__) && \ !defined(__OpenBSD__) && !defined(__CYGWIN__) && !defined(__DragonFly__) Modified: llvm/trunk/test/FrontendC/unaligned-memcpy.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/unaligned-memcpy.c?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/unaligned-memcpy.c (original) +++ llvm/trunk/test/FrontendC/unaligned-memcpy.c Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -emit-llvm -o - | llvm-as | llc +// RUN: %llvmgcc %s -S -emit-llvm -o - | llc void bork() { char Qux[33] = {0}; Modified: llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m (original) +++ llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Fri Dec 4 18:02:37 2009 @@ -1,6 +1,6 @@ // This is a regression test on debug info to make sure that we can set a // breakpoint on a objective message. -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | llc -o %t.s -O0 +// RUN: %llvmgcc -S -O0 -g %s -o - | llc -o %t.s -O0 // RUN: %compile_c %t.s -o %t.o // RUN: %link %t.o -o %t.exe -framework Foundation // RUN: echo {break randomFunc\n} > %t.in Modified: llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m?rev=90626&r1=90625&r2=90626&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m (original) +++ llvm/trunk/test/FrontendObjC/2009-11-30-Objc-ID.m Fri Dec 4 18:02:37 2009 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc -S -O0 -g %s -o - | llvm-as | \ +// RUN: %llvmgcc -S -O0 -g %s -o - | \ // RUN: llc --disable-fp-elim -o %t.s -O0 // RUN: grep id %t.s | grep DW_AT_name @interface A From greened at obbligato.org Fri Dec 4 18:03:24 2009 From: greened at obbligato.org (David Greene) Date: Sat, 05 Dec 2009 00:03:24 -0000 Subject: [llvm-commits] [llvm] r90627 - /llvm/trunk/include/llvm/Target/TargetInstrInfo.h Message-ID: <200912050003.nB503OkP006517@zion.cs.uiuc.edu> Author: greened Date: Fri Dec 4 18:03:24 2009 New Revision: 90627 URL: http://llvm.org/viewvc/llvm-project?rev=90627&view=rev Log: Remove an unneeded include. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90627&r1=90626&r2=90627&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Dec 4 18:03:24 2009 @@ -16,7 +16,6 @@ #include "llvm/Target/TargetInstrDesc.h" #include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineMemOperand.h" namespace llvm { @@ -27,6 +26,7 @@ class CalleeSavedInfo; class SDNode; class SelectionDAG; +class MachineMemOperand; template class SmallVectorImpl; From gohman at apple.com Fri Dec 4 18:05:43 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:05:43 -0000 Subject: [llvm-commits] [llvm] r90628 - in /llvm/trunk/utils/TableGen: CodeEmitterGen.cpp CodeEmitterGen.h Message-ID: <200912050005.nB505icT006593@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:05:43 2009 New Revision: 90628 URL: http://llvm.org/viewvc/llvm-project?rev=90628&view=rev Log: Minor code simplification. Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.h Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=90628&r1=90627&r2=90628&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Fri Dec 4 18:05:43 2009 @@ -61,14 +61,11 @@ // If the VarBitInit at position 'bit' matches the specified variable then // return the variable bit position. Otherwise return -1. -int CodeEmitterGen::getVariableBit(const std::string &VarName, +int CodeEmitterGen::getVariableBit(const Init *VarVal, BitsInit *BI, int bit) { if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { TypedInit *TI = VBI->getVariable(); - - if (VarInit *VI = dynamic_cast(TI)) { - if (VI->getName() == VarName) return VBI->getBitNum(); - } + if (TI == VarVal) return VBI->getBitNum(); } return -1; @@ -162,11 +159,11 @@ if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) { // Is the operand continuous? If so, we can just mask and OR it in // instead of doing it bit-by-bit, saving a lot in runtime cost. - const std::string &VarName = Vals[i].getName(); + const Init *VarVal = Vals[i].getValue(); bool gotOp = false; for (int bit = BI->getNumBits()-1; bit >= 0; ) { - int varBit = getVariableBit(VarName, BI, bit); + int varBit = getVariableBit(VarVal, BI, bit); if (varBit == -1) { --bit; @@ -176,7 +173,7 @@ int N = 1; for (--bit; bit >= 0;) { - varBit = getVariableBit(VarName, BI, bit); + varBit = getVariableBit(VarVal, BI, bit); if (varBit == -1 || varBit != (beginVarBit - N)) break; ++N; --bit; @@ -188,7 +185,7 @@ while (CGI.isFlatOperandNotEmitted(op)) ++op; - Case += " // op: " + VarName + "\n" + Case += " // op: " + Vals[i].getName() + "\n" + " op = getMachineOpValue(MI, MI.getOperand(" + utostr(op++) + "));\n"; gotOp = true; Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.h?rev=90628&r1=90627&r2=90628&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.h (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.h Fri Dec 4 18:05:43 2009 @@ -23,6 +23,7 @@ class RecordVal; class BitsInit; +class Init; class CodeEmitterGen : public TableGenBackend { RecordKeeper &Records; @@ -35,7 +36,7 @@ void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace); void emitGetValueBit(raw_ostream &o, const std::string &Namespace); void reverseBits(std::vector &Insts); - int getVariableBit(const std::string &VarName, BitsInit *BI, int bit); + int getVariableBit(const Init *VarVal, BitsInit *BI, int bit); }; } // End llvm namespace From gohman at apple.com Fri Dec 4 18:20:51 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:20:51 -0000 Subject: [llvm-commits] [llvm] r90630 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <200912050020.nB50KqXv007018@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:20:51 2009 New Revision: 90630 URL: http://llvm.org/viewvc/llvm-project?rev=90630&view=rev Log: Don't print the debug directory; it's often long and uninteresting. Omit the column number if it is not known. Handle the case of a missing filename better. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=90630&r1=90629&r2=90630&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Fri Dec 4 18:20:51 2009 @@ -1166,9 +1166,14 @@ DebugLocTuple DLT = MF->getDebugLocTuple(debugLoc); DIScope Scope(DLT.Scope); OS << " dbg:"; + // Omit the directory, since it's usually long and uninteresting. if (!Scope.isNull()) - OS << Scope.getDirectory() << ':' << Scope.getFilename() << ':'; - OS << DLT.Line << ":" << DLT.Col; + OS << Scope.getFilename(); + else + OS << ""; + OS << ':' << DLT.Line; + if (DLT.Col != 0) + OS << ':' << DLT.Col; } OS << "\n"; From gohman at apple.com Fri Dec 4 18:23:29 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:23:29 -0000 Subject: [llvm-commits] [llvm] r90631 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/FrontendC++/2009-07-15-LineNumbers.cpp Message-ID: <200912050023.nB50NTbH007102@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:23:29 2009 New Revision: 90631 URL: http://llvm.org/viewvc/llvm-project?rev=90631&view=rev Log: Fix this code to use DIScope instead of DICompileUnit, as in r90181. Don't print "SrcLine"; just print the filename and line number, which is obvious enough and more informative. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=90631&r1=90630&r2=90631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Dec 4 18:23:29 2009 @@ -1837,15 +1837,16 @@ // Print source line info. O.PadToColumn(MAI->getCommentColumn()); - O << MAI->getCommentString() << " SrcLine "; - if (DLT.Scope) { - DICompileUnit CU(DLT.Scope); - if (!CU.isNull()) - O << CU.getFilename() << " "; - } - O << DLT.Line; + O << MAI->getCommentString() << ' '; + DIScope Scope(DLT.Scope); + // Omit the directory, because it's likely to be long and uninteresting. + if (!Scope.isNull()) + O << Scope.getFilename(); + else + O << ""; + O << ':' << DLT.Line; if (DLT.Col != 0) - O << ":" << DLT.Col; + O << ':' << DLT.Col; Newline = true; } Modified: llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC%2B%2B/2009-07-15-LineNumbers.cpp?rev=90631&r1=90630&r2=90631&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp (original) +++ llvm/trunk/test/FrontendC++/2009-07-15-LineNumbers.cpp Fri Dec 4 18:23:29 2009 @@ -1,7 +1,7 @@ // This is a regression test on debug info to make sure that we can // print line numbers in asm. // RUN: %llvmgcc -S -O0 -g %s -o - | \ -// RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep {SrcLine 25} +// RUN: llc --disable-fp-elim -O0 -relocation-model=pic | grep { 2009-07-15-LineNumbers.cpp:25$} #include From gohman at apple.com Fri Dec 4 18:27:08 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:27:08 -0000 Subject: [llvm-commits] [llvm] r90632 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200912050027.nB50R8BI007208@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:27:08 2009 New Revision: 90632 URL: http://llvm.org/viewvc/llvm-project?rev=90632&view=rev Log: The debug information for an LLVM Instruction applies to that Instruction and that Instruction only. Implement this by setting the "current debug position" back to Unknown after processing each instruction. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90632&r1=90631&r2=90632&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Dec 4 18:27:08 2009 @@ -362,6 +362,39 @@ return true; } +/// SetDebugLoc - Update MF's and SDB's DebugLocs if debug information is +/// attached with this instruction. +static void SetDebugLoc(unsigned MDDbgKind, + MetadataContext &TheMetadata, + Instruction *I, + SelectionDAGBuilder *SDB, + FastISel *FastIS, + MachineFunction *MF) { + if (!isa(I)) + if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { + DILocation DILoc(Dbg); + DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); + + SDB->setCurDebugLoc(Loc); + + if (FastIS) + FastIS->setCurDebugLoc(Loc); + + // If the function doesn't have a default debug location yet, set + // it. This is kind of a hack. + if (MF->getDefaultDebugLoc().isUnknown()) + MF->setDefaultDebugLoc(Loc); + } +} + +/// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown. +static void ResetDebugLoc(SelectionDAGBuilder *SDB, + FastISel *FastIS) { + SDB->setCurDebugLoc(DebugLoc::getUnknownLoc()); + if (FastIS) + SDB->setCurDebugLoc(DebugLoc::getUnknownLoc()); +} + void SelectionDAGISel::SelectBasicBlock(BasicBlock *LLVMBB, BasicBlock::iterator Begin, BasicBlock::iterator End, @@ -373,20 +406,16 @@ // Lower all of the non-terminator instructions. If a call is emitted // as a tail call, cease emitting nodes for this block. for (BasicBlock::iterator I = Begin; I != End && !SDB->HasTailCall; ++I) { - if (MDDbgKind) { - // Update DebugLoc if debug information is attached with this - // instruction. - if (!isa(I)) - if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, I)) { - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); - SDB->setCurDebugLoc(Loc); - if (MF->getDefaultDebugLoc().isUnknown()) - MF->setDefaultDebugLoc(Loc); - } - } - if (!isa(I)) + if (MDDbgKind) + SetDebugLoc(MDDbgKind, TheMetadata, I, SDB, 0, MF); + + if (!isa(I)) { SDB->visit(*I); + + // Set the current debug location back to "unknown" so that it doesn't + // spuriously apply to subsequent instructions. + ResetDebugLoc(SDB, 0); + } } if (!SDB->HasTailCall) { @@ -401,7 +430,9 @@ HandlePHINodesInSuccessorBlocks(LLVMBB); // Lower the terminator after the copies are emitted. + SetDebugLoc(MDDbgKind, TheMetadata, LLVMBB->getTerminator(), SDB, 0, MF); SDB->visit(*LLVMBB->getTerminator()); + ResetDebugLoc(SDB, 0); } } @@ -738,24 +769,14 @@ FastIS->startNewBlock(BB); // Do FastISel on as many instructions as possible. for (; BI != End; ++BI) { - if (MDDbgKind) { - // Update DebugLoc if debug information is attached with this - // instruction. - if (!isa(BI)) - if (MDNode *Dbg = TheMetadata.getMD(MDDbgKind, BI)) { - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, - MF.getDebugLocInfo()); - FastIS->setCurDebugLoc(Loc); - if (MF.getDefaultDebugLoc().isUnknown()) - MF.setDefaultDebugLoc(Loc); - } - } + if (MDDbgKind) + SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF); // Just before the terminator instruction, insert instructions to // feed PHI nodes in successor blocks. if (isa(BI)) if (!HandlePHINodesInSuccessorBlocksFast(LLVMBB, FastIS)) { + ResetDebugLoc(SDB, FastIS); if (EnableFastISelVerbose || EnableFastISelAbort) { errs() << "FastISel miss: "; BI->dump(); @@ -766,12 +787,20 @@ } // First try normal tablegen-generated "fast" selection. - if (FastIS->SelectInstruction(BI)) + if (FastIS->SelectInstruction(BI)) { + ResetDebugLoc(SDB, FastIS); continue; + } // Next, try calling the target to attempt to handle the instruction. - if (FastIS->TargetSelectInstruction(BI)) + if (FastIS->TargetSelectInstruction(BI)) { + ResetDebugLoc(SDB, FastIS); continue; + } + + // Clear out the debug location so that it doesn't carry over to + // unrelated instructions. + ResetDebugLoc(SDB, FastIS); // Then handle certain instructions as single-LLVM-Instruction blocks. if (isa(BI)) { @@ -786,8 +815,6 @@ R = FuncInfo->CreateRegForValue(BI); } - SDB->setCurDebugLoc(FastIS->getCurDebugLoc()); - bool HadTailCall = false; SelectBasicBlock(LLVMBB, BI, llvm::next(BI), HadTailCall); @@ -823,9 +850,6 @@ // not handled by FastISel. If FastISel is not run, this is the entire // block. if (BI != End) { - // If FastISel is run and it has known DebugLoc then use it. - if (FastIS && !FastIS->getCurDebugLoc().isUnknown()) - SDB->setCurDebugLoc(FastIS->getCurDebugLoc()); bool HadTailCall; SelectBasicBlock(LLVMBB, BI, End, HadTailCall); } From gohman at apple.com Fri Dec 4 18:32:59 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:32:59 -0000 Subject: [llvm-commits] [llvm] r90633 - /llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Message-ID: <200912050032.nB50WxCV007387@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:32:59 2009 New Revision: 90633 URL: http://llvm.org/viewvc/llvm-project?rev=90633&view=rev Log: Simplify this code: don't call AnalyzeBranch before doing simpler checks. Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=90633&r1=90632&r2=90633&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Fri Dec 4 18:32:59 2009 @@ -363,11 +363,6 @@ } bool MachineBasicBlock::canFallThrough() { - MachineBasicBlock *TBB = 0, *FBB = 0; - SmallVector Cond; - const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo(); - bool BranchUnAnalyzable = TII->AnalyzeBranch(*this, TBB, FBB, Cond, true); - MachineFunction::iterator Fallthrough = this; ++Fallthrough; // If FallthroughBlock is off the end of the function, it can't fall through. @@ -378,16 +373,21 @@ if (!isSuccessor(Fallthrough)) return false; - // If we couldn't analyze the branch, examine the last instruction. - // If the block doesn't end in a known control barrier, assume fallthrough - // is possible. The isPredicable check is needed because this code can be - // called during IfConversion, where an instruction which is normally a - // Barrier is predicated and thus no longer an actual control barrier. This - // is over-conservative though, because if an instruction isn't actually - // predicated we could still treat it like a barrier. - if (BranchUnAnalyzable) + // Analyze the branches, if any, at the end of the block. + MachineBasicBlock *TBB = 0, *FBB = 0; + SmallVector Cond; + const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo(); + if (TII->AnalyzeBranch(*this, TBB, FBB, Cond, true)) { + // If we couldn't analyze the branch, examine the last instruction. + // If the block doesn't end in a known control barrier, assume fallthrough + // is possible. The isPredicable check is needed because this code can be + // called during IfConversion, where an instruction which is normally a + // Barrier is predicated and thus no longer an actual control barrier. This + // is over-conservative though, because if an instruction isn't actually + // predicated we could still treat it like a barrier. return empty() || !back().getDesc().isBarrier() || back().getDesc().isPredicable(); + } // If there is no branch, control always falls through. if (TBB == 0) return true; From gohman at apple.com Fri Dec 4 18:44:40 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 00:44:40 -0000 Subject: [llvm-commits] [llvm] r90634 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/CellSPU/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PowerPC/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ Message-ID: <200912050044.nB50ifkP007792@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 18:44:40 2009 New Revision: 90634 URL: http://llvm.org/viewvc/llvm-project?rev=90634&view=rev Log: Remove the target hook TargetInstrInfo::BlockHasNoFallThrough in favor of MachineBasicBlock::canFallThrough(), which is target-independent and more thorough. Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/CodeGen/MachineVerifier.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.h llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.h llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.h llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.h llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.h llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp llvm/trunk/lib/Target/XCore/XCoreInstrInfo.h Modified: llvm/trunk/include/llvm/Target/TargetInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -465,14 +465,6 @@ return 0; } - /// BlockHasNoFallThrough - Return true if the specified block does not - /// fall-through into its successor block. This is primarily used when a - /// branch is unanalyzable. It is useful for things like unconditional - /// indirect branches (jump tables). - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - return false; - } - /// ReverseBranchCondition - Reverses the branch condition of the specified /// condition list, returning false on success and true if it cannot be /// reversed. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Fri Dec 4 18:44:40 2009 @@ -1140,7 +1140,7 @@ // falls through into MBB and we can't understand the prior block's branch // condition. if (MBB->empty()) { - bool PredHasNoFallThrough = TII->BlockHasNoFallThrough(PrevBB); + bool PredHasNoFallThrough = !PrevBB.canFallThrough(); if (PredHasNoFallThrough || !PriorUnAnalyzable || !PrevBB.isSuccessor(MBB)) { // If the prior block falls through into us, turn it into an Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Fri Dec 4 18:44:40 2009 @@ -376,15 +376,6 @@ report("MBB doesn't fall through but is empty!", MBB); } } - if (TII->BlockHasNoFallThrough(*MBB)) { - if (MBB->empty()) { - report("TargetInstrInfo says the block has no fall through, but the " - "block is empty!", MBB); - } else if (!MBB->back().getDesc().isBarrier()) { - report("TargetInstrInfo says the block has no fall through, but the " - "block does not end in a barrier!", MBB); - } - } } else { // Block is last in function. if (MBB->empty()) { Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -190,9 +190,6 @@ // if there is not such an opcode. virtual unsigned getUnindexedOpcode(unsigned Opc) const =0; - // Return true if the block does not fall through. - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const =0; - virtual MachineInstr *convertToThreeAddress(MachineFunction::iterator &MFI, MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -60,25 +60,6 @@ return 0; } -bool ARMInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case ARM::BX_RET: // Return. - case ARM::LDM_RET: - case ARM::B: - case ARM::BRIND: - case ARM::BR_JTr: // Jumptable branch. - case ARM::BR_JTm: // Jumptable branch through mem. - case ARM::BR_JTadd: // Jumptable branch add to pc. - return true; - default: - break; - } - - return false; -} - void ARMInstrInfo:: reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig, Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -32,9 +32,6 @@ // if there is not such an opcode. unsigned getUnindexedOpcode(unsigned Opc) const; - // Return true if the block does not fall through. - bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig, Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -32,25 +32,6 @@ return 0; } -bool -Thumb1InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case ARM::tBX_RET: - case ARM::tBX_RET_vararg: - case ARM::tPOP_RET: - case ARM::tB: - case ARM::tBRIND: - case ARM::tBR_JTr: - return true; - default: - break; - } - - return false; -} - bool Thumb1InstrInfo::copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg, Modified: llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1InstrInfo.h Fri Dec 4 18:44:40 2009 @@ -31,9 +31,6 @@ // if there is not such an opcode. unsigned getUnindexedOpcode(unsigned Opc) const; - // Return true if the block does not fall through. - bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As /// such, whenever a client has an instance of instruction info, it should /// always be able to get register info as well (through this method). Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -36,30 +36,6 @@ } bool -Thumb2InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case ARM::t2LDM_RET: - case ARM::t2B: // Uncond branch. - case ARM::t2BR_JT: // Jumptable branch. - case ARM::t2TBB: // Table branch byte. - case ARM::t2TBH: // Table branch halfword. - case ARM::tBR_JTr: // Jumptable branch (16-bit version). - case ARM::tBX_RET: - case ARM::tBX_RET_vararg: - case ARM::tPOP_RET: - case ARM::tB: - case ARM::tBRIND: - return true; - default: - break; - } - - return false; -} - -bool Thumb2InstrInfo::copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg, Modified: llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb2InstrInfo.h Fri Dec 4 18:44:40 2009 @@ -31,9 +31,6 @@ // if there is not such an opcode. unsigned getUnindexedOpcode(unsigned Opc) const; - // Return true if the block does not fall through. - bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - bool copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, unsigned DestReg, unsigned SrcReg, Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -392,18 +392,6 @@ .addReg(Alpha::R31); } -bool AlphaInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case Alpha::RETDAG: // Return. - case Alpha::RETDAGp: - case Alpha::BR: // Uncond branch. - case Alpha::JMP: // Indirect branch. - return true; - default: return false; - } -} bool AlphaInstrInfo:: ReverseBranchCondition(SmallVectorImpl &Cond) const { assert(Cond.size() == 2 && "Invalid Alpha branch opcode!"); Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.h (original) +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -78,7 +78,6 @@ unsigned RemoveBranch(MachineBasicBlock &MBB) const; void insertNoop(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const; - bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; bool ReverseBranchCondition(SmallVectorImpl &Cond) const; /// getGlobalBaseReg - Return a virtual register initialized with the Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -580,10 +580,6 @@ } } -bool -SPUInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - return (!MBB.empty() && isUncondBranch(&MBB.back())); -} //! Reverses a branch's condition, returning false on success. bool SPUInstrInfo::ReverseBranchCondition(SmallVectorImpl &Cond) Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -79,9 +79,6 @@ bool canFoldMemoryOperand(const MachineInstr *MI, const SmallVectorImpl &Ops) const; - //! Return true if the specified block does not fall through - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - //! Reverses a branch's condition, returning false on success. virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -219,17 +219,6 @@ return false; } -bool MSP430InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB)const{ - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case MSP430::RET: // Return. - case MSP430::JMP: // Uncond branch. - return true; - default: return false; - } -} - bool MSP430InstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const { const TargetInstrDesc &TID = MI->getDesc(); if (!TID.isTerminator()) return false; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.h Fri Dec 4 18:44:40 2009 @@ -61,7 +61,6 @@ // Branch folding goodness bool ReverseBranchCondition(SmallVectorImpl &Cond) const; - bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; bool isUnpredicatedTerminator(const MachineInstr *MI) const; bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -590,22 +590,6 @@ return 2; } -/// BlockHasNoFallThrough - Analyze if MachineBasicBlock does not -/// fall-through into its successor block. -bool MipsInstrInfo:: -BlockHasNoFallThrough(const MachineBasicBlock &MBB) const -{ - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case Mips::RET: // Return. - case Mips::JR: // Indirect branch. - case Mips::J: // Uncond branch. - return true; - default: return false; - } -} - /// ReverseBranchCondition - Return the inverse opcode of the /// specified Branch instruction. bool MipsInstrInfo:: Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.h (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -232,7 +232,6 @@ return 0; } - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -740,18 +740,6 @@ } -bool PPCInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case PPC::BLR: // Return. - case PPC::B: // Uncond branch. - case PPC::BCTR: // Indirect branch. - return true; - default: return false; - } -} - bool PPCInstrInfo:: ReverseBranchCondition(SmallVectorImpl &Cond) const { assert(Cond.size() == 2 && "Invalid PPC branch opcode!"); Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -143,7 +143,6 @@ virtual bool canFoldMemoryOperand(const MachineInstr *MI, const SmallVectorImpl &Ops) const; - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -402,18 +402,6 @@ return false; } -bool SystemZInstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB)const{ - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case SystemZ::RET: // Return. - case SystemZ::JMP: // Uncond branch. - case SystemZ::JMPr: // Indirect branch. - return true; - default: return false; - } -} - bool SystemZInstrInfo::isUnpredicatedTerminator(const MachineInstr *MI) const { const TargetInstrDesc &TID = MI->getDesc(); if (!TID.isTerminator()) return false; Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.h (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -89,7 +89,6 @@ const std::vector &CSI) const; bool ReverseBranchCondition(SmallVectorImpl &Cond) const; - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const; virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -2719,27 +2719,6 @@ return I->second.first; } -bool X86InstrInfo::BlockHasNoFallThrough(const MachineBasicBlock &MBB) const { - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case X86::TCRETURNri: - case X86::TCRETURNdi: - case X86::RET: // Return. - case X86::RETI: - case X86::TAILJMPd: - case X86::TAILJMPr: - case X86::TAILJMPm: - case X86::JMP: // Uncond branch. - case X86::JMP32r: // Indirect branch. - case X86::JMP64r: // Indirect branch (64-bit). - case X86::JMP32m: // Indirect branch through mem. - case X86::JMP64m: // Indirect branch through mem (64-bit). - return true; - default: return false; - } -} - bool X86InstrInfo:: ReverseBranchCondition(SmallVectorImpl &Cond) const { assert(Cond.size() == 1 && "Invalid X86 branch condition!"); Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Fri Dec 4 18:44:40 2009 @@ -600,7 +600,6 @@ bool UnfoldLoad, bool UnfoldStore, unsigned *LoadRegIndex = 0) const; - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; virtual bool ReverseBranchCondition(SmallVectorImpl &Cond) const; Modified: llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp Fri Dec 4 18:44:40 2009 @@ -453,26 +453,6 @@ return true; } -/// BlockHasNoFallThrough - Analyse if MachineBasicBlock does not -/// fall-through into its successor block. -bool XCoreInstrInfo:: -BlockHasNoFallThrough(const MachineBasicBlock &MBB) const -{ - if (MBB.empty()) return false; - - switch (MBB.back().getOpcode()) { - case XCore::RETSP_u6: // Return. - case XCore::RETSP_lu6: - case XCore::BAU_1r: // Indirect branch. - case XCore::BRFU_u6: // Uncond branch. - case XCore::BRFU_lu6: - case XCore::BRBU_u6: - case XCore::BRBU_lu6: - return true; - default: return false; - } -} - /// ReverseBranchCondition - Return the inverse opcode of the /// specified Branch instruction. bool XCoreInstrInfo:: Modified: llvm/trunk/lib/Target/XCore/XCoreInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreInstrInfo.h?rev=90634&r1=90633&r2=90634&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreInstrInfo.h (original) +++ llvm/trunk/lib/Target/XCore/XCoreInstrInfo.h Fri Dec 4 18:44:40 2009 @@ -87,8 +87,6 @@ MachineBasicBlock::iterator MI, const std::vector &CSI) const; - virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const; - virtual bool ReverseBranchCondition( SmallVectorImpl &Cond) const; }; From gohman at apple.com Fri Dec 4 19:27:58 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 01:27:58 -0000 Subject: [llvm-commits] [llvm] r90636 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200912050127.nB51Rx7x009223@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 19:27:58 2009 New Revision: 90636 URL: http://llvm.org/viewvc/llvm-project?rev=90636&view=rev Log: Make TargetSelectInstruction protected and called from FastISel.cpp instead of SelectionDAGISel.cpp. Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=90636&r1=90635&r2=90636&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Fri Dec 4 19:27:58 2009 @@ -98,14 +98,6 @@ /// bool SelectOperator(User *I, unsigned Opcode); - /// TargetSelectInstruction - This method is called by target-independent - /// code when the normal FastISel process fails to select an instruction. - /// This gives targets a chance to emit code for anything that doesn't - /// fit into FastISel's framework. It returns true if it was successful. - /// - virtual bool - TargetSelectInstruction(Instruction *I) = 0; - /// getRegForValue - Create a virtual register and arrange for it to /// be assigned the value for the given LLVM value. unsigned getRegForValue(Value *V); @@ -134,6 +126,14 @@ #endif ); + /// TargetSelectInstruction - This method is called by target-independent + /// code when the normal FastISel process fails to select an instruction. + /// This gives targets a chance to emit code for anything that doesn't + /// fit into FastISel's framework. It returns true if it was successful. + /// + virtual bool + TargetSelectInstruction(Instruction *I) = 0; + /// FastEmit_r - This method is called by target-independent code /// to request that an instruction with the given type and opcode /// be emitted. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=90636&r1=90635&r2=90636&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Dec 4 19:27:58 2009 @@ -532,7 +532,15 @@ bool FastISel::SelectInstruction(Instruction *I) { - return SelectOperator(I, I->getOpcode()); + // First, try doing target-independent selection. + if (SelectOperator(I, I->getOpcode())) + return true; + + // Next, try calling the target to attempt to handle the instruction. + if (TargetSelectInstruction(I)) + return true; + + return false; } /// FastEmitBranch - Emit an unconditional branch to the given block, Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90636&r1=90635&r2=90636&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Dec 4 19:27:58 2009 @@ -792,12 +792,6 @@ continue; } - // Next, try calling the target to attempt to handle the instruction. - if (FastIS->TargetSelectInstruction(BI)) { - ResetDebugLoc(SDB, FastIS); - continue; - } - // Clear out the debug location so that it doesn't carry over to // unrelated instructions. ResetDebugLoc(SDB, FastIS); From gohman at apple.com Fri Dec 4 19:29:05 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 01:29:05 -0000 Subject: [llvm-commits] [llvm] r90637 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200912050129.nB51T5Oa009266@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 19:29:04 2009 New Revision: 90637 URL: http://llvm.org/viewvc/llvm-project?rev=90637&view=rev Log: Don't blindly set the debug location for PHI node copies. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90637&r1=90636&r2=90637&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Dec 4 19:29:04 2009 @@ -769,9 +769,6 @@ FastIS->startNewBlock(BB); // Do FastISel on as many instructions as possible. for (; BI != End; ++BI) { - if (MDDbgKind) - SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF); - // Just before the terminator instruction, insert instructions to // feed PHI nodes in successor blocks. if (isa(BI)) @@ -786,6 +783,9 @@ break; } + if (MDDbgKind) + SetDebugLoc(MDDbgKind, TheMetadata, BI, SDB, FastIS, &MF); + // First try normal tablegen-generated "fast" selection. if (FastIS->SelectInstruction(BI)) { ResetDebugLoc(SDB, FastIS); From gohman at apple.com Fri Dec 4 19:42:35 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 01:42:35 -0000 Subject: [llvm-commits] [llvm] r90638 - in /llvm/trunk/lib/CodeGen/AsmPrinter: AsmPrinter.cpp DwarfDebug.cpp Message-ID: <200912050142.nB51gZ0r009915@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 19:42:34 2009 New Revision: 90638 URL: http://llvm.org/viewvc/llvm-project?rev=90638&view=rev Log: Print newlines after printing labels for debug info, so that the output isn't cluttered with things like "Llabel47:Llabel48: movq (%rsi), %xmm3" Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=90638&r1=90637&r2=90638&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Dec 4 19:42:34 2009 @@ -1374,6 +1374,7 @@ unsigned L = DW->RecordSourceLine(CurDLT.Line, CurDLT.Col, CurDLT.Scope); printLabel(L); + O << '\n'; DW->BeginScope(MI, L); PrevDLT = CurDLT; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=90638&r1=90637&r2=90638&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Dec 4 19:42:34 2009 @@ -1981,6 +1981,7 @@ unsigned Label = MMI->NextLabelID(); Asm->printLabel(Label); + O << '\n'; SmallVector &SD = I->second; for (SmallVector::iterator SDI = SD.begin(), SDE = SD.end(); From isanbard at gmail.com Fri Dec 4 19:43:34 2009 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 05 Dec 2009 01:43:34 -0000 Subject: [llvm-commits] [llvm] r90639 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912050143.nB51hYfl009950@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 19:43:33 2009 New Revision: 90639 URL: http://llvm.org/viewvc/llvm-project?rev=90639&view=rev Log: Refactor some code. No functionality change. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90639&r1=90638&r2=90639&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Fri Dec 4 19:43:33 2009 @@ -367,6 +367,18 @@ } } + void InvalidateEntry(const StructType *Ty) { + LayoutInfoTy::iterator I = this->find(Ty); + if (I == this->end()) return; + + I->second->~StructLayout(); + free(I->second); + this->erase(I); + + if (Ty->isAbstract()) + Ty->removeAbstractTypeUser(this); + } + LayoutInfoTy::iterator end() { return LayoutInfo.end(); } @@ -427,15 +439,7 @@ if (!LayoutMap) return; // No cache. StructLayoutMap *STM = static_cast(LayoutMap); - StructLayoutMap::LayoutInfoTy::iterator I = STM->find(Ty); - if (I == STM->end()) return; - - I->second->~StructLayout(); - free(I->second); - STM->erase(I); - - if (Ty->isAbstract()) - Ty->removeAbstractTypeUser(STM); + STM->InvalidateEntry(Ty); } std::string TargetData::getStringRepresentation() const { From isanbard at gmail.com Fri Dec 4 19:46:01 2009 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 05 Dec 2009 01:46:01 -0000 Subject: [llvm-commits] [llvm] r90640 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912050146.nB51k1rn010050@zion.cs.uiuc.edu> Author: void Date: Fri Dec 4 19:46:01 2009 New Revision: 90640 URL: http://llvm.org/viewvc/llvm-project?rev=90640&view=rev Log: Inline methods which are called only once. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90640&r1=90639&r2=90640&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Fri Dec 4 19:46:01 2009 @@ -368,29 +368,17 @@ } void InvalidateEntry(const StructType *Ty) { - LayoutInfoTy::iterator I = this->find(Ty); - if (I == this->end()) return; + LayoutInfoTy::iterator I = LayoutInfo.find(Ty); + if (I == LayoutInfo.end()) return; I->second->~StructLayout(); free(I->second); - this->erase(I); + LayoutInfo.erase(I); if (Ty->isAbstract()) Ty->removeAbstractTypeUser(this); } - LayoutInfoTy::iterator end() { - return LayoutInfo.end(); - } - - LayoutInfoTy::iterator find(const StructType *&Val) { - return LayoutInfo.find(Val); - } - - bool erase(LayoutInfoTy::iterator I) { - return LayoutInfo.erase(I); - } - StructLayout *&operator[](const StructType *STy) { return LayoutInfo[STy]; } From gohman at apple.com Fri Dec 4 20:00:34 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 02:00:34 -0000 Subject: [llvm-commits] [llvm] r90641 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <200912050200.nB520Y2P011583@zion.cs.uiuc.edu> Author: djg Date: Fri Dec 4 20:00:34 2009 New Revision: 90641 URL: http://llvm.org/viewvc/llvm-project?rev=90641&view=rev Log: Don't print a space before the : between the file name and line number. And separate the directory and file name with a '/'. 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=90641&r1=90640&r2=90641&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Dec 4 20:00:34 2009 @@ -2616,9 +2616,9 @@ std::pair SourceID = getSourceDirectoryAndFileIds(LineInfo.getSourceID()); O << '\t' << MAI->getCommentString() << ' ' - << getSourceDirectoryName(SourceID.first) << ' ' + << getSourceDirectoryName(SourceID.first) << '/' << getSourceFileName(SourceID.second) - <<" :" << utostr_32(LineInfo.getLine()) << '\n'; + << ':' << utostr_32(LineInfo.getLine()) << '\n'; } // Define the line address. From echristo at apple.com Fri Dec 4 20:46:03 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 05 Dec 2009 02:46:03 -0000 Subject: [llvm-commits] [llvm] r90644 - /llvm/trunk/docs/LangRef.html Message-ID: <200912050246.nB52k3s9013020@zion.cs.uiuc.edu> Author: echristo Date: Fri Dec 4 20:46:03 2009 New Revision: 90644 URL: http://llvm.org/viewvc/llvm-project?rev=90644&view=rev Log: More updates to objectsize intrinsic docs. Modified: llvm/trunk/docs/LangRef.html Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=90644&r1=90643&r2=90644&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Fri Dec 4 20:46:03 2009 @@ -5,7 +5,7 @@ LLVM Assembly Language Reference Manual - @@ -54,7 +54,7 @@
  • Type System
    1. Type Classifications
    2. -
    3. Primitive Types +
    4. Primitive Types
      1. Integer Type
      2. Floating Point Types
      3. @@ -576,7 +576,7 @@ Symbols with "common" linkage are merged in the same way as weak symbols, and they may not be deleted if unreferenced. common symbols may not have an explicit section, - must have a zero initializer, and may not be marked 'constant'. Functions and aliases may not have common linkage. @@ -843,7 +843,7 @@

        LLVM function declarations consist of the "declare" keyword, an optional linkage type, an optional - visibility style, an optional + visibility style, an optional calling convention, a return type, an optional parameter attribute for the return type, a function name, a possibly empty list of arguments, an optional alignment, and an @@ -1192,7 +1192,7 @@ location.

        p:size:abi:pref
        -
        This specifies the size of a pointer and its abi and +
        This specifies the size of a pointer and its abi and preferred alignments. All sizes are in bits. Specifying the pref alignment is optional. If omitted, the preceding : should be omitted too.
        @@ -1202,11 +1202,11 @@ size. The value of size must be in the range [1,2^23).
        vsize:abi:pref
        -
        This specifies the alignment for a vector type of a given bit +
        This specifies the alignment for a vector type of a given bit size.
        fsize:abi:pref
        -
        This specifies the alignment for a floating point type of a given bit +
        This specifies the alignment for a floating point type of a given bit size. The value of size must be either 32 (float) or 64 (double).
        @@ -1222,7 +1222,7 @@
        This specifies a set of native integer widths for the target CPU in bits. For example, it might contain "n32" for 32-bit PowerPC, "n32:64" for PowerPC 64, or "n8:16:32:64" for X86-64. Elements of - this set are considered to support most general arithmetic + this set are considered to support most general arithmetic operations efficiently.
        @@ -1616,16 +1616,16 @@
  • - - @@ -2054,9 +2054,9 @@ For example, if "%X" has a zero bit, then the output of the 'and' operation will always be a zero, no matter what the corresponding bit from the undef is. As such, it is unsafe to optimize or assume that the result of the and is undef. -However, it is safe to assume that all bits of the undef could be 0, and -optimize the and to 0. Likewise, it is safe to assume that all the bits of -the undef operand to the or could be set, allowing the or to be folded to +However, it is safe to assume that all bits of the undef could be 0, and +optimize the and to 0. Likewise, it is safe to assume that all the bits of +the undef operand to the or could be set, allowing the or to be folded to -1.

    @@ -2086,7 +2086,7 @@
       %A = xor undef, undef
    -  
    +
       %B = undef
       %C = xor %B, %B
     
    @@ -2137,7 +2137,7 @@
     it: since the undefined operation "can't happen", the optimizer can assume that
     it occurs in dead code.
     

    - +
     a:  store undef -> %X
    @@ -2149,7 +2149,7 @@
     

    These examples reiterate the fdiv example: a store "of" an undefined value -can be assumed to not have any effect: we can assume that the value is +can be assumed to not have any effect: we can assume that the value is overwritten with bits that happen to match what was already there. However, a store "to" an undefined location could clobber arbitrary memory, therefore, it has undefined behavior.

    @@ -2166,7 +2166,7 @@

    The 'blockaddress' constant computes the address of the specified basic block in the specified function, and always has an i8* type. Taking the address of the entry block is illegal.

    - +

    This value only has defined behavior when used as an operand to the 'indirectbr' instruction or for comparisons against null. Pointer equality tests between labels addresses is undefined @@ -2175,7 +2175,7 @@ pointer sized value as long as the bits are not inspected. This allows ptrtoint and arithmetic to be performed on these values so long as the original value is reconstituted before the indirectbr.

    - +

    Finally, some targets may provide defined semantics when using the value as the operand to an inline assembly, but that is target specific. @@ -2703,7 +2703,7 @@ rest of the arguments indicate the full set of possible destinations that the address may point to. Blocks are allowed to occur multiple times in the destination list, though this isn't particularly useful.

    - +

    This destination list is required so that dataflow analysis has an accurate understanding of the CFG.

    @@ -3060,7 +3060,7 @@

    The two arguments to the 'mul' instruction must be integer or vector of integer values. Both arguments must have identical types.

    - +
    Semantics:

    The value produced is the integer product of the two operands.

    @@ -3132,7 +3132,7 @@

    The 'udiv' instruction returns the quotient of its two operands.

    Arguments:
    -

    The two arguments to the 'udiv' instruction must be +

    The two arguments to the 'udiv' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3167,7 +3167,7 @@

    The 'sdiv' instruction returns the quotient of its two operands.

    Arguments:
    -

    The two arguments to the 'sdiv' instruction must be +

    The two arguments to the 'sdiv' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3238,7 +3238,7 @@ division of its two arguments.

    Arguments:
    -

    The two arguments to the 'urem' instruction must be +

    The two arguments to the 'urem' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3278,7 +3278,7 @@ elements must be integers.

    Arguments:
    -

    The two arguments to the 'srem' instruction must be +

    The two arguments to the 'srem' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3373,7 +3373,7 @@

    Both arguments to the 'shl' instruction must be the same integer or vector of integer type. 'op2' is treated as an unsigned value.

    - +
    Semantics:

    The value produced is op1 * 2op2 mod 2n, where n is the width of the result. If op2 @@ -3409,7 +3409,7 @@ operand shifted to the right a specified number of bits with zero fill.

    Arguments:
    -

    Both arguments to the 'lshr' instruction must be the same +

    Both arguments to the 'lshr' instruction must be the same integer or vector of integer type. 'op2' is treated as an unsigned value.

    @@ -3449,7 +3449,7 @@ extension.

    Arguments:
    -

    Both arguments to the 'ashr' instruction must be the same +

    Both arguments to the 'ashr' instruction must be the same integer or vector of integer type. 'op2' is treated as an unsigned value.

    @@ -3489,7 +3489,7 @@ operands.

    Arguments:
    -

    The two arguments to the 'and' instruction must be +

    The two arguments to the 'and' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3548,7 +3548,7 @@ two operands.

    Arguments:
    -

    The two arguments to the 'or' instruction must be +

    The two arguments to the 'or' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3611,7 +3611,7 @@ complement" operation, which is the "~" operator in C.

    Arguments:
    -

    The two arguments to the 'xor' instruction must be +

    The two arguments to the 'xor' instruction must be integer or vector of integer values. Both arguments must have identical types.

    @@ -3659,7 +3659,7 @@
    -
    + @@ -3782,20 +3782,20 @@
    Example:
    -  <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2, 
    +  <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
                               <4 x i32> <i32 0, i32 4, i32 1, i32 5>  ; yields <4 x i32>
    -  <result> = shufflevector <4 x i32> %v1, <4 x i32> undef, 
    +  <result> = shufflevector <4 x i32> %v1, <4 x i32> undef,
                               <4 x i32> <i32 0, i32 1, i32 2, i32 3>  ; yields <4 x i32> - Identity shuffle.
    -  <result> = shufflevector <8 x i32> %v1, <8 x i32> undef, 
    +  <result> = shufflevector <8 x i32> %v1, <8 x i32> undef,
                               <4 x i32> <i32 0, i32 1, i32 2, i32 3>  ; yields <4 x i32>
    -  <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2, 
    +  <result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
                               <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7 >  ; yields <8 x i32>
     
    -
    + @@ -3880,7 +3880,7 @@ -
    + @@ -4243,15 +4243,15 @@
    Overview:
    -

    The 'zext' instruction zero extends its operand to type +

    The 'zext' instruction zero extends its operand to type ty2.

    Arguments:
    -

    The 'zext' instruction takes a value to cast, which must be of +

    The 'zext' instruction takes a value to cast, which must be of integer type, and a type to cast it to, which must also be of integer type. The bit size of the - value must be smaller than the bit size of the destination type, + value must be smaller than the bit size of the destination type, ty2.

    Semantics:
    @@ -4283,10 +4283,10 @@

    The 'sext' sign extends value to the type ty2.

    Arguments:
    -

    The 'sext' instruction takes a value to cast, which must be of +

    The 'sext' instruction takes a value to cast, which must be of integer type, and a type to cast it to, which must also be of integer type. The bit size of the - value must be smaller than the bit size of the destination type, + value must be smaller than the bit size of the destination type, ty2.

    Semantics:
    @@ -4324,12 +4324,12 @@

    The 'fptrunc' instruction takes a floating point value to cast and a floating point type to cast it to. The size of value must be larger than the size of - ty2. This implies that fptrunc cannot be used to make a + ty2. This implies that fptrunc cannot be used to make a no-op cast.

    Semantics:

    The 'fptrunc' instruction truncates a value from a larger - floating point type to a smaller + floating point type to a smaller floating point type. If the value cannot fit within the destination type, ty2, then the results are undefined.

    @@ -4358,7 +4358,7 @@ floating point value.

    Arguments:
    -

    The 'fpext' instruction takes a +

    The 'fpext' instruction takes a floating point value to cast, and a floating point type to cast it to. The source type must be smaller than the destination type.

    @@ -4401,7 +4401,7 @@ vector integer type with the same number of elements as ty

    Semantics:
    -

    The 'fptoui' instruction converts its +

    The 'fptoui' instruction converts its floating point operand into the nearest (rounding towards zero) unsigned integer value. If the value cannot fit in ty2, the results are undefined.

    @@ -4427,7 +4427,7 @@
    Overview:
    -

    The 'fptosi' instruction converts +

    The 'fptosi' instruction converts floating point value to type ty2.

    @@ -4439,7 +4439,7 @@ vector integer type with the same number of elements as ty

    Semantics:
    -

    The 'fptosi' instruction converts its +

    The 'fptosi' instruction converts its floating point operand into the nearest (rounding towards zero) signed integer value. If the value cannot fit in ty2, the results are undefined.

    @@ -4636,7 +4636,7 @@
       %X = bitcast i8 255 to i8              ; yields i8 :-1
       %Y = bitcast i32* %x to sint*          ; yields sint*:%x
    -  %Z = bitcast <2 x int> %V to i64;      ; yields i64: %V   
    +  %Z = bitcast <2 x int> %V to i64;      ; yields i64: %V
     
    @@ -4696,11 +4696,11 @@ result, as follows:

      -
    1. eq: yields true if the operands are equal, +
    2. eq: yields true if the operands are equal, false otherwise. No sign interpretation is necessary or performed.
    3. -
    4. ne: yields true if the operands are unequal, +
    5. ne: yields true if the operands are unequal, false otherwise. No sign interpretation is necessary or performed.
    6. @@ -4817,42 +4817,42 @@
      1. false: always yields false, regardless of operands.
      2. -
      3. oeq: yields true if both operands are not a QNAN and +
      4. oeq: yields true if both operands are not a QNAN and op1 is equal to op2.
      5. ogt: yields true if both operands are not a QNAN and op1 is greather than op2.
      6. -
      7. oge: yields true if both operands are not a QNAN and +
      8. oge: yields true if both operands are not a QNAN and op1 is greater than or equal to op2.
      9. -
      10. olt: yields true if both operands are not a QNAN and +
      11. olt: yields true if both operands are not a QNAN and op1 is less than op2.
      12. -
      13. ole: yields true if both operands are not a QNAN and +
      14. ole: yields true if both operands are not a QNAN and op1 is less than or equal to op2.
      15. -
      16. one: yields true if both operands are not a QNAN and +
      17. one: yields true if both operands are not a QNAN and op1 is not equal to op2.
      18. ord: yields true if both operands are not a QNAN.
      19. -
      20. ueq: yields true if either operand is a QNAN or +
      21. ueq: yields true if either operand is a QNAN or op1 is equal to op2.
      22. -
      23. ugt: yields true if either operand is a QNAN or +
      24. ugt: yields true if either operand is a QNAN or op1 is greater than op2.
      25. -
      26. uge: yields true if either operand is a QNAN or +
      27. uge: yields true if either operand is a QNAN or op1 is greater than or equal to op2.
      28. -
      29. ult: yields true if either operand is a QNAN or +
      30. ult: yields true if either operand is a QNAN or op1 is less than op2.
      31. -
      32. ule: yields true if either operand is a QNAN or +
      33. ule: yields true if either operand is a QNAN or op1 is less than or equal to op2.
      34. -
      35. une: yields true if either operand is a QNAN or +
      36. une: yields true if either operand is a QNAN or op1 is not equal to op2.
      37. uno: yields true if either operand is a QNAN.
      38. @@ -5144,7 +5144,7 @@ suffix is required. Because the argument's type is matched against the return type, it does not require its own name suffix.

        -

        To learn how to add an intrinsic function, please see the +

        To learn how to add an intrinsic function, please see the Extending LLVM Guide.

    @@ -6579,11 +6579,11 @@
    • ll: All loads before the barrier must complete before any load after the barrier begins.
    • -
    • ls: All loads before the barrier must complete before any +
    • ls: All loads before the barrier must complete before any store after the barrier begins.
    • -
    • ss: All stores before the barrier must complete before any +
    • ss: All stores before the barrier must complete before any store after the barrier begins.
    • -
    • sl: All stores before the barrier must complete before any +
    • sl: All stores before the barrier must complete before any load after the barrier begins.
    @@ -6796,7 +6796,7 @@
    Overview:
    -

    This intrinsic subtracts delta to the value stored in memory at +

    This intrinsic subtracts delta to the value stored in memory at ptr. It yields the original value at ptr.

    Arguments:
    @@ -6952,7 +6952,7 @@
    Overview:
    -

    These intrinsics takes the signed or unsigned minimum or maximum of +

    These intrinsics takes the signed or unsigned minimum or maximum of delta and the value stored in memory at ptr. It yields the original value at ptr.

    @@ -7262,24 +7262,44 @@
    Overview:
    -

    The llvm.objectsize intrinsic returns the constant number of bytes - from ptr to the end of the object ptr points to, if it - can deduce this at compile time. If there are any side-effects in evaluating - the argument or it cannot deduce which objects ptr points to at compile - time, the intrinsic returns i32/i64 -1 for type 0 - or 1 and i32/i64 0 for type 2 or 3.

    +

    The llvm.objectsize intrinsic is designed to provide information + to the optimizers to either discover at compile time either a) when an + operation like memcpy will either overflow a buffer that corresponds to + an object, or b) to determine that a runtime check for overflow isn't + necessary. An object in this context means an allocation of a + specific type.

    Arguments:

    The llvm.objectsize intrinsic takes two arguments. The first argument is a pointer to the object ptr. The second argument - is an integer type which ranges from 0 to 3. The first bit - corresponds to a return value based on whole objects, and the second bit - whether or not we return the maximum or minimum remaining bytes computed.

    + is an integer type which ranges from 0 to 3. The first bit in + the type corresponds to a return value based on whole objects, + and the second bit whether or not we return the maximum or minimum + remaining bytes computed.

    +
    MediaWhoDescription
    - [No Slides]
    - [No Video] -
    Chris Lattner
    LLVM Foundation
    - Welcome -
    [Slides]
    @@ -282,7 +270,7 @@ src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"> Valid HTML 4.01! -
    Last modified: $Date: 2009/12/01 05:29:08 $ +
    Last modified: $Date: 2009/12/01 05:29:47 $ From sabre at nondot.org Mon Nov 30 23:30:11 2009 From: sabre at nondot.org (Chris Lattner) Date: Mon, 30 Nov 2009 23:30:11 -0600 Subject: [llvm-commits] CVS: llvm-www/devmtg/2009-10/RegisterAllocationFutureWorks.pdf OpenCLWithLLVM.pdf ScalarEvolutionAndLoopOptimization.pdf StateOfClang.pdf index.html Message-ID: <200912010530.nB15UBvb014260@zion.cs.uiuc.edu> Changes in directory llvm-www/devmtg/2009-10: RegisterAllocationFutureWorks.pdf added (r1.1) OpenCLWithLLVM.pdf added (r1.1) ScalarEvolutionAndLoopOptimization.pdf added (r1.1) StateOfClang.pdf added (r1.1) index.html updated: 1.29 -> 1.30 --- Log message: Add slides for 4 talks. --- Diffs of the changes: (+5 -5) OpenCLWithLLVM.pdf | 0 RegisterAllocationFutureWorks.pdf | 0 ScalarEvolutionAndLoopOptimization.pdf | 0 StateOfClang.pdf | 0 index.html | 10 +++++----- 5 files changed, 5 insertions(+), 5 deletions(-) Index: llvm-www/devmtg/2009-10/RegisterAllocationFutureWorks.pdf Index: llvm-www/devmtg/2009-10/OpenCLWithLLVM.pdf Index: llvm-www/devmtg/2009-10/ScalarEvolutionAndLoopOptimization.pdf Index: llvm-www/devmtg/2009-10/StateOfClang.pdf Index: llvm-www/devmtg/2009-10/index.html diff -u llvm-www/devmtg/2009-10/index.html:1.29 llvm-www/devmtg/2009-10/index.html:1.30 --- llvm-www/devmtg/2009-10/index.html:1.29 Fri Oct 30 11:27:40 2009 +++ llvm-www/devmtg/2009-10/index.html Mon Nov 30 23:29:08 2009 @@ -67,7 +67,7 @@
    - [No Slides]
    + [Slides]
    [No Video]
    Doug Gregor, Chris Lattner, Ted Kremenek
    - [No Slides]
    + [Slides]
    [No Video]
    Dan Gohman
    - [No Slides]
    + [Slides]
    [No Videos]
    Lang Hames
    - [No Slides]
    + [Slides]
    [No Videos]
    Nate Begeman
    float (i16 signext, i32 *) * Pointer to a function that takes - an i16 that should be sign extended and a - pointer to i32, returning + Pointer to a function that takes + an i16 that should be sign extended and a + pointer to i32, returning float.
    i32 (i8*, ...)A vararg function that takes at least one - pointer to i8 (char in C), - which returns an integer. This is the signature for printf in + A vararg function that takes at least one + pointer to i8 (char in C), + which returns an integer. This is the signature for printf in LLVM.
    + + + + + + + + + + + + + + + + +
    00whole object, maximum number of bytes
    01partial object, maximum number of bytes
    10whole object, minimum number of bytes
    11partial object, minimum number of bytes
    Semantics:

    The llvm.objectsize intrinsic is lowered to either a constant - representing the size of the object concerned or i32/i64 -1 if - it cannot be determined at compile time.

    + representing the size of the object concerned or i32/i64 -1 or 0 + (depending on the type argument if the size cannot be determined + at compile time.

    From nicholas at mxc.ca Fri Dec 4 23:00:00 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 05 Dec 2009 05:00:00 -0000 Subject: [llvm-commits] [llvm] r90646 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll Message-ID: <200912050500.nB5501o8017339@zion.cs.uiuc.edu> Author: nicholas Date: Fri Dec 4 23:00:00 2009 New Revision: 90646 URL: http://llvm.org/viewvc/llvm-project?rev=90646&view=rev Log: Generalize this optimization to work on equality comparisons between any two integers that are constant except for a single bit (the same n-th bit in each). Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=90646&r1=90645&r2=90646&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Fri Dec 4 23:00:00 2009 @@ -8585,25 +8585,36 @@ if (ICI->isEquality() && CI.getType() == ICI->getOperand(0)->getType()) { if (const IntegerType *ITy = dyn_cast(CI.getType())) { uint32_t BitWidth = ITy->getBitWidth(); - if (BitWidth > 1) { - Value *LHS = ICI->getOperand(0); - Value *RHS = ICI->getOperand(1); - - APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); - APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); - APInt TypeMask(APInt::getHighBitsSet(BitWidth, BitWidth-1)); - ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); - ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); + Value *LHS = ICI->getOperand(0); + Value *RHS = ICI->getOperand(1); - if (KnownZeroLHS.countLeadingOnes() == BitWidth-1 && - KnownZeroRHS.countLeadingOnes() == BitWidth-1) { + APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); + APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); + APInt TypeMask(APInt::getAllOnesValue(BitWidth)); + ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); + ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); + + if (KnownZeroLHS == KnownZeroRHS && KnownOneLHS == KnownOneRHS) { + APInt KnownBits = KnownZeroLHS | KnownOneLHS; + APInt UnknownBit = ~KnownBits; + if (UnknownBit.countPopulation() == 1) { if (!DoXform) return ICI; - Value *Xor = Builder->CreateXor(LHS, RHS); + Value *Result = Builder->CreateXor(LHS, RHS); + + // Mask off any bits that are set and won't be shifted away. + if (KnownOneLHS.uge(UnknownBit)) + Result = Builder->CreateAnd(Result, + ConstantInt::get(ITy, UnknownBit)); + + // Shift the bit we're testing down to the lsb. + Result = Builder->CreateLShr( + Result, ConstantInt::get(ITy, UnknownBit.countTrailingZeros())); + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Xor = Builder->CreateXor(Xor, ConstantInt::get(ITy, 1)); - Xor->takeName(ICI); - return ReplaceInstUsesWith(CI, Xor); + Result = Builder->CreateXor(Result, ConstantInt::get(ITy, 1)); + Result->takeName(ICI); + return ReplaceInstUsesWith(CI, Result); } } } Modified: llvm/trunk/test/Transforms/InstCombine/compare-signs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/compare-signs.ll?rev=90646&r1=90645&r2=90646&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/compare-signs.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/compare-signs.ll Fri Dec 4 23:00:00 2009 @@ -2,7 +2,7 @@ ; PR5438 ; TODO: This should also optimize down. -;define i32 @bar(i32 %a, i32 %b) nounwind readnone { +;define i32 @test1(i32 %a, i32 %b) nounwind readnone { ;entry: ; %0 = icmp sgt i32 %a, -1 ; [#uses=1] ; %1 = icmp slt i32 %b, 0 ; [#uses=1] @@ -11,8 +11,18 @@ ; ret i32 %3 ;} -define i32 @qaz(i32 %a, i32 %b) nounwind readnone { -; CHECK: @qaz +; TODO: This optimizes partially but not all the way. +;define i32 @test2(i32 %a, i32 %b) nounwind readnone { +;entry: +; %0 = and i32 %a, 8 ; [#uses=1] +; %1 = and i32 %b, 8 ; [#uses=1] +; %2 = icmp eq i32 %0, %1 ; [#uses=1] +; %3 = zext i1 %2 to i32 ; [#uses=1] +; ret i32 %3 +;} + +define i32 @test3(i32 %a, i32 %b) nounwind readnone { +; CHECK: @test3 entry: ; CHECK: xor i32 %a, %b ; CHECK; lshr i32 %0, 31 @@ -26,3 +36,23 @@ ; CHECK-NOT: zext ; CHECK: ret i32 %2 } + +; Variation on @test3: checking the 2nd bit in a situation where the 5th bit +; is one, not zero. +define i32 @test3i(i32 %a, i32 %b) nounwind readnone { +; CHECK: @test3i +entry: +; CHECK: xor i32 %a, %b +; CHECK; lshr i32 %0, 31 +; CHECK: xor i32 %1, 1 + %0 = lshr i32 %a, 29 ; [#uses=1] + %1 = lshr i32 %b, 29 ; [#uses=1] + %2 = or i32 %0, 35 + %3 = or i32 %1, 35 + %4 = icmp eq i32 %2, %3 ; [#uses=1] + %5 = zext i1 %4 to i32 ; [#uses=1] + ret i32 %5 +; CHECK-NOT: icmp +; CHECK-NOT: zext +; CHECK: ret i32 %2 +} From nicholas at mxc.ca Fri Dec 4 23:01:55 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 04 Dec 2009 21:01:55 -0800 Subject: [llvm-commits] [llvm] r89639 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/compare-signs.ll In-Reply-To: <984EC5D0-4D6D-4D8D-83D0-D39D24932914@apple.com> References: <200911230317.nAN3HYvG017794@zion.cs.uiuc.edu> <984EC5D0-4D6D-4D8D-83D0-D39D24932914@apple.com> Message-ID: <4B19E943.30308@mxc.ca> Chris Lattner wrote: > > On Nov 22, 2009, at 7:17 PM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Sun Nov 22 21:17:33 2009 >> New Revision: 89639 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=89639&view=rev >> Log: >> Reapply r88830 with a bugfix: this transform only applies to icmp eq/ne. This >> fixes part of PR5438. > > Thanks for working on this, some thoughts: > >> >> + // icmp ne A, B is equal to xor A, B when A and B only really have one bit. >> + // It is also profitable to transform icmp eq into not(xor(A, B)) because that >> + // may lead to additional simplifications. >> + if (ICI->isEquality()&& CI.getType() == ICI->getOperand(0)->getType()) { >> + if (const IntegerType *ITy = dyn_cast(CI.getType())) { >> + uint32_t BitWidth = ITy->getBitWidth(); >> + if (BitWidth> 1) { > > If this is a zext from bool, the result type can't be i1. The source and dest of a zext can't be the same type, so this 'if' seems unneeded. Good point. Removed! >> + Value *LHS = ICI->getOperand(0); >> + Value *RHS = ICI->getOperand(1); >> + >> + APInt KnownZeroLHS(BitWidth, 0), KnownOneLHS(BitWidth, 0); >> + APInt KnownZeroRHS(BitWidth, 0), KnownOneRHS(BitWidth, 0); >> + APInt TypeMask(APInt::getHighBitsSet(BitWidth, BitWidth-1)); > > Why isn't TypeMask looking at all the bits? Does now! >> + ComputeMaskedBits(LHS, TypeMask, KnownZeroLHS, KnownOneLHS); >> + ComputeMaskedBits(RHS, TypeMask, KnownZeroRHS, KnownOneRHS); >> + >> + if (KnownZeroLHS.countLeadingOnes() == BitWidth-1&& >> + KnownZeroRHS.countLeadingOnes() == BitWidth-1) { > > This check seems over-constrained. This xforms should apply when it is one of *any* bit set. For example, this: True. Note though that worst case we turn zext+icmp into xor+lshr+and+xor. > entry: > %0 = and i32 %a, 8 ; [#uses=1] > %1 = and i32 %b, 8 ; [#uses=1] > %2 = icmp eq i32 %0, %1 ; [#uses=1] > %3 = zext i1 %2 to i32 ; [#uses=1] > ret i32 %3 > } > > should also be transformed. No. Instcombine does Other Things to this IR before it ever makes it to transformZExtICmp. I've added another testcase which does match the transformation you asked for. Nick From clattner at apple.com Fri Dec 4 23:13:15 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:13:15 -0800 Subject: [llvm-commits] [llvm] r90445 - in /llvm/trunk: include/llvm/Analysis/ProfileInfo.h lib/Analysis/ProfileInfo.cpp In-Reply-To: <4B18BB48.5080106@gmx.at> References: <200912030930.nB39UCep006456@zion.cs.uiuc.edu> <7F5F0839-581F-45B2-8931-9183DD8D1C1A@apple.com> <4B18BB48.5080106@gmx.at> Message-ID: <76A6969F-5ED4-4640-9920-AD8F87B3FA11@apple.com> On Dec 3, 2009, at 11:33 PM, Andreas Neustifter wrote: > > On 12/03/2009 06:47 PM, Chris Lattner wrote: >> >> On Dec 3, 2009, at 1:30 AM, Andreas Neustifter wrote: >> >>> Author: astifter >>> Date: Thu Dec 3 03:30:12 2009 >>> New Revision: 90445 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=90445&view=rev >>> Log: >>> Converted ProfileInfo to template, added more API for >>> ProfileInfo-preserving. >> >> Does this have to be a template? Why not use a base class that keeps a >> map and then have derived classes for LLVM BB and MBB's? >> This would significantly reduce code size. > > I'm still not very proficient with the C++-Type system so maybe this is a stupid question but: > > When I would use this approach, how would I use the shared code between the two derived classes? > Naturally the code would be in the base class, but when I want to use this code I would have to have functions in the derived classes that hand the typecasted pointers to the base class? Yep. > I must admit that I still have to move shared code from ProfileInfo.cpp to ProfileInfo.h, but there will be a large shared code base between this two classes. > > Agreed, the shared code in the base class is duplicated, is this what I shall strive to prevent? Right, exactly. Thanks Andreas, -Chris From clattner at apple.com Fri Dec 4 23:23:29 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:23:29 -0800 Subject: [llvm-commits] [llvm] r90644 - /llvm/trunk/docs/LangRef.html In-Reply-To: <200912050246.nB52k3s9013020@zion.cs.uiuc.edu> References: <200912050246.nB52k3s9013020@zion.cs.uiuc.edu> Message-ID: On Dec 4, 2009, at 6:46 PM, Eric Christopher wrote: > Author: echristo > Date: Fri Dec 4 20:46:03 2009 > New Revision: 90644 > > URL: http://llvm.org/viewvc/llvm-project?rev=90644&view=rev > Log: > More updates to objectsize intrinsic docs. *grumble* trailing whitespace :) Some more requests: 1) As we discussed on IRC, llvm doesn't have a useful notion of a partial object, please change the 'type' argument to an i1. Also, in the Arguments section point out that the type needs to be a literal 0 or 1, variables are not allowed. Please update the implementation to match of course. 2) "An object in this context means an allocation of a specific type". The type doesn't really have anything to do with it, please explain the possible things an 'object' could be. 3) "The first argument is a pointer to the object ptr." it may be a pointer "into" an object as well. Please don't contract 'ptr'. Thanks Eric, -Chris From clattner at apple.com Fri Dec 4 23:29:34 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:29:34 -0800 Subject: [llvm-commits] [llvm] r90640 - /llvm/trunk/lib/Target/TargetData.cpp In-Reply-To: <200912050146.nB51k1rn010050@zion.cs.uiuc.edu> References: <200912050146.nB51k1rn010050@zion.cs.uiuc.edu> Message-ID: On Dec 4, 2009, at 5:46 PM, Bill Wendling wrote: > Author: void > Date: Fri Dec 4 19:46:01 2009 > New Revision: 90640 > > URL: http://llvm.org/viewvc/llvm-project?rev=90640&view=rev > Log: > Inline methods which are called only once. Thanks Bill, a couple more things: class StructLayoutMap : public AbstractTypeUser { public: typedef DenseMap LayoutInfoTy; no longer needs to be public. virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { virtual void typeBecameConcrete(const DerivedType *AbsTy) { ... both of these can now just call InvalidateEntry. const StructLayout *TargetData::getStructLayout(const StructType *Ty) const { Please move the meat of this into StructLayoutMap, allowing the elimination of the operator[]. Otherwise, looks very tidy now, thanks! -Chris From clattner at apple.com Fri Dec 4 23:56:18 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:56:18 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> Message-ID: On Dec 4, 2009, at 1:03 AM, Eric Christopher wrote: >> >> >>> +//===---------------------------------------===// >>> +// 'object size' >>> +namespace { >>> +struct SizeOpt : public LibCallOptimization { >> >> This code (if it is kept) should be moved to instcombine, and generalized to work on more than just i32/i64. IT should work on any llvm.objectsize.ixxx intrinsic call. > > Well, there are only two we generate at the moment, Sure, that is true of the current frontend that generates this, but the optimizer should be generic. > but it could be adapted to any since we're just returning a length. I'm not sure about instcombine itself, but this is likely not the place to put it for sure :) This code should go in instcombine in the InstCombiner::visitCallInst method. >> >>> + const Type *Ty = Callee->getFunctionType()->getReturnType(); >>> + >>> + if (Const->getZExtValue() < 2) >>> + return Constant::getAllOnesValue(Ty); >>> + else >>> + return ConstantInt::get(Ty, 0); >> >> I don't really get this. Why is libcalloptimizer turning these into "I don't know"? Shouldn't codegen (e.g. codegenprepare) do this? This seems really wrong. > > It's doing this now so that these other optimizations below can replace the checking calls with normal calls. It also matches what llvm-gcc did before. That said, we are producing less checks than we should - I went for keeping existing behavior over trying to get it all right at once. This should happen in codegenprepare? libcallsimplify effectively runs at an arbitrary time in the optimizer sequence. We want the optimizer to be able to prove away these calls (which is why having instcombine do the proving is useful) whenever it can, and then lower them to 'unknown' (and simplify the users) right before codegen. >> This should also handle the case when getOperand(3) and getOperand(4) are both constant ints and op3 <= op4? If we know that op3 > op4, I'm fine with leaving it unoptimized :) >> > > Good question. I wasn't sure if this pass was iterative? I.e. if I change it to memcpy can the rest of the pass infrastructure deal with it? Of course, I could just look and figure it out - I just hadn't gotten that far :) Yes, it is iterative. >> Can this code be factored better? Maybe introduce a new intermediate class that all of MemCpyChkOpt/MemSetChkOpt/MemMoveChkOpt inherit from that then inherits from LibCallOptimization? > > Most assuredly. It was bugging me too :) Ok, please do, thanks! -Chris From clattner at apple.com Fri Dec 4 23:58:12 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:58:12 -0800 Subject: [llvm-commits] [llvm] r90045 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/DeadStoreElimination/lifetime.ll In-Reply-To: <4B16270C.6060208@free.fr> References: <200911282127.nASLRoum025712@zion.cs.uiuc.edu> <4B16270C.6060208@free.fr> Message-ID: <4B673E2F-969B-45FD-BA37-4F4DBD10F180@apple.com> On Dec 2, 2009, at 12:36 AM, Duncan Sands wrote: > Hi Chris, > >> mustalias queries don't care about the size of the operands, so getting it is pointless. Either the pointers themselves mustalias or not. As such, this won't catch the case where you have a lifetime marker saying that a 20 byte object is live/dead but where you're accessing 4 bytes into the 20 byte object. I don't know if you care about this case, if so, please fix it somehow, otherwise remove the dead code and add a FIXME describing the issue. > > I don't know if the following use case is relevant to this, but since it's > important to me I mention it here: the dragonegg trampoline code creates a > struct alloca for which one field (holding the trampoline pointer)] is constant > after being initialized. For technical reasons (i.e. this was the best I could > come up with given that I can't modify gcc itself) this field is in the middle > of the alloca, and other fields are not constant. I mark this field with an llvm.invariant call. It is important that loads from this field simplify to the > original stored value whenever possible, since this can result in eliminating > uses of the trampoline (a big win). [Such loads may be in other functions and > as such only exposed after inlining]. Currently such loads are not always > simplified :( This is an example where the whole object is not invariant, and > it is important to be precise about what is being accessed. I think the current code should be capable of getting this. The start of the invariant field and the start of the invariant call should mustalias. Do you have a simple testcase that shows this? -Chris From clattner at apple.com Fri Dec 4 23:59:03 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 21:59:03 -0800 Subject: [llvm-commits] [llvm] r90304 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/GVN.cpp test/Transforms/DeadStoreElimination/lifetime-simple.ll test/Transforms/GVN/lifetime-simple.ll In-Reply-To: <200912020735.nB27ZJlf017871@zion.cs.uiuc.edu> References: <200912020735.nB27ZJlf017871@zion.cs.uiuc.edu> Message-ID: On Dec 1, 2009, at 11:35 PM, Owen Anderson wrote: > Author: resistor > Date: Wed Dec 2 01:35:19 2009 > New Revision: 90304 > > URL: http://llvm.org/viewvc/llvm-project?rev=90304&view=rev > Log: > Cleanup/remove some parts of the lifetime region handling code in memdep and GVN, > per Chris' comments. Adjust testcases to match. Nice, thanks Owen, -Chris > > Removed: > llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll > Modified: > llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp > llvm/trunk/lib/Transforms/Scalar/GVN.cpp > llvm/trunk/test/Transforms/GVN/lifetime-simple.ll > > Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90304&r1=90303&r2=90304&view=diff > > ============================================================================== > --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) > +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Wed Dec 2 01:35:19 2009 > @@ -186,15 +186,17 @@ > } > > if (IntrinsicInst *II = dyn_cast(Inst)) { > + // Debug intrinsics don't cause dependences. > + if (isa(Inst)) continue; > + > // If we pass an invariant-end marker, then we've just entered an > // invariant region and can start ignoring dependencies. > if (II->getIntrinsicID() == Intrinsic::invariant_end) { > - uint64_t InvariantSize = ~0ULL; > - if (ConstantInt *CI = dyn_cast(II->getOperand(2))) > - InvariantSize = CI->getZExtValue(); > - > - AliasAnalysis::AliasResult R = > - AA->alias(II->getOperand(3), InvariantSize, MemPtr, MemSize); > + // FIXME: This only considers queries directly on the invariant-tagged > + // pointer, not on query pointers that are indexed off of them. It'd > + // be nice to handle that at some point. > + AliasAnalysis::AliasResult R = > + AA->alias(II->getOperand(3), ~0ULL, MemPtr, ~0ULL); > if (R == AliasAnalysis::MustAlias) { > InvariantTag = II->getOperand(1); > continue; > @@ -202,14 +204,12 @@ > > // If we reach a lifetime begin or end marker, then the query ends here > // because the value is undefined. > - } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || > - II->getIntrinsicID() == Intrinsic::lifetime_end) { > - uint64_t InvariantSize = ~0ULL; > - if (ConstantInt *CI = dyn_cast(II->getOperand(1))) > - InvariantSize = CI->getZExtValue(); > - > + } else if (II->getIntrinsicID() == Intrinsic::lifetime_start) { > + // FIXME: This only considers queries directly on the invariant-tagged > + // pointer, not on query pointers that are indexed off of them. It'd > + // be nice to handle that at some point. > AliasAnalysis::AliasResult R = > - AA->alias(II->getOperand(2), InvariantSize, MemPtr, MemSize); > + AA->alias(II->getOperand(2), ~0ULL, MemPtr, ~0ULL); > if (R == AliasAnalysis::MustAlias) > return MemDepResult::getDef(II); > } > @@ -219,9 +219,6 @@ > // at this point. Nothing a load depends on can live in an invariant region. > if (isLoad && InvariantTag) continue; > > - // Debug intrinsics don't cause dependences. > - if (isa(Inst)) continue; > - > // Values depend on loads if the pointers are must aliased. This means that > // a load depends on another must aliased load from the same value. > if (LoadInst *LI = dyn_cast(Inst)) { > > Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90304&r1=90303&r2=90304&view=diff > > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Dec 2 01:35:19 2009 > @@ -1187,10 +1187,9 @@ > return V; > } > > -static bool isLifetimeStartOrEnd(Instruction *Inst) { > +static bool isLifetimeStart(Instruction *Inst) { > if (IntrinsicInst* II = dyn_cast(Inst)) > - return II->getIntrinsicID() == Intrinsic::lifetime_start || > - II->getIntrinsicID() == Intrinsic::lifetime_end; > + return II->getIntrinsicID() == Intrinsic::lifetime_start; > return false; > } > > @@ -1262,8 +1261,8 @@ > > // Loading the allocation -> undef. > if (isa(DepInst) || isMalloc(DepInst) || > - // Loading immediately after lifetime begin or end -> undef. > - isLifetimeStartOrEnd(DepInst)) { > + // Loading immediately after lifetime begin -> undef. > + isLifetimeStart(DepInst)) { > ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, > UndefValue::get(LI->getType()))); > continue; > @@ -1635,11 +1634,10 @@ > return true; > } > > - // If this load occurs either right after a lifetime begin or a lifetime end, > + // If this load occurs either right after a lifetime begin, > // then the loaded value is undefined. > if (IntrinsicInst* II = dyn_cast(DepInst)) { > - if (II->getIntrinsicID() == Intrinsic::lifetime_start || > - II->getIntrinsicID() == Intrinsic::lifetime_end) { > + if (II->getIntrinsicID() == Intrinsic::lifetime_start) { > L->replaceAllUsesWith(UndefValue::get(L->getType())); > toErase.push_back(L); > NumGVNLoad++; > > Removed: llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll?rev=90303&view=auto > > ============================================================================== > --- llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll (original) > +++ llvm/trunk/test/Transforms/DeadStoreElimination/lifetime-simple.ll (removed) > @@ -1,18 +0,0 @@ > -; RUN: opt < %s -dse -S | FileCheck %s > - > -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" > -target triple = "i386-apple-darwin7" > - > -define i8 @test2(i8* %P) nounwind { > -; CHECK: @test2 > -; CHECK-NOT: store i8 1 > -; CHECK: ret i8 0 > -entry: > - call void @llvm.lifetime.start(i64 32, i8* %P) > - call void @llvm.lifetime.end(i64 32, i8* %P) > - store i8 1, i8* %P > - ret i8 0 > -} > - > -declare {}* @llvm.lifetime.start(i64 %S, i8* nocapture %P) readonly > -declare void @llvm.lifetime.end(i64 %S, i8* nocapture %P) > \ No newline at end of file > > Modified: llvm/trunk/test/Transforms/GVN/lifetime-simple.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/lifetime-simple.ll?rev=90304&r1=90303&r2=90304&view=diff > > ============================================================================== > --- llvm/trunk/test/Transforms/GVN/lifetime-simple.ll (original) > +++ llvm/trunk/test/Transforms/GVN/lifetime-simple.ll Wed Dec 2 01:35:19 2009 > @@ -4,9 +4,9 @@ > target triple = "i386-apple-darwin7" > > define i8 @test(i8* %P) nounwind { > -; CHECK: @test > +; CHECK: lifetime.start > ; CHECK-NOT: load > -; CHECK: ret i8 undef > +; CHECK: lifetime.end > entry: > call void @llvm.lifetime.start(i64 32, i8* %P) > %0 = load i8* %P > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From echristo at apple.com Sat Dec 5 00:01:11 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 4 Dec 2009 22:01:11 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> Message-ID: <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> >>> >>>> + const Type *Ty = Callee->getFunctionType()->getReturnType(); >>>> + >>>> + if (Const->getZExtValue() < 2) >>>> + return Constant::getAllOnesValue(Ty); >>>> + else >>>> + return ConstantInt::get(Ty, 0); >>> >>> I don't really get this. Why is libcalloptimizer turning these into "I don't know"? Shouldn't codegen (e.g. codegenprepare) do this? This seems really wrong. >> >> It's doing this now so that these other optimizations below can replace the checking calls with normal calls. It also matches what llvm-gcc did before. That said, we are producing less checks than we should - I went for keeping existing behavior over trying to get it all right at once. > > This should happen in codegenprepare? libcallsimplify effectively runs at an arbitrary time in the optimizer sequence. We want the optimizer to be able to prove away these calls (which is why having instcombine do the proving is useful) whenever it can, and then lower them to 'unknown' (and simplify the users) right before codegen. The lower to "unknown" is merely a placeholder that keeps current behavior. We do lower to unknown at codegen time already if we didn't before. It should be all lowered before we get to codegen in one way or another. Otherwise I'm not quite sure what you're asking :) -eric From clattner at apple.com Sat Dec 5 00:03:54 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 22:03:54 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> Message-ID: On Dec 4, 2009, at 10:01 PM, Eric Christopher wrote: >>>> >>>>> + const Type *Ty = Callee->getFunctionType()->getReturnType(); >>>>> + >>>>> + if (Const->getZExtValue() < 2) >>>>> + return Constant::getAllOnesValue(Ty); >>>>> + else >>>>> + return ConstantInt::get(Ty, 0); >>>> >>>> I don't really get this. Why is libcalloptimizer turning these into "I don't know"? Shouldn't codegen (e.g. codegenprepare) do this? This seems really wrong. >>> >>> It's doing this now so that these other optimizations below can replace the checking calls with normal calls. It also matches what llvm-gcc did before. That said, we are producing less checks than we should - I went for keeping existing behavior over trying to get it all right at once. >> >> This should happen in codegenprepare? libcallsimplify effectively runs at an arbitrary time in the optimizer sequence. We want the optimizer to be able to prove away these calls (which is why having instcombine do the proving is useful) whenever it can, and then lower them to 'unknown' (and simplify the users) right before codegen. > > The lower to "unknown" is merely a placeholder that keeps current behavior. What do you mean? > We do lower to unknown at codegen time already if we didn't before. It should be all lowered before we get to codegen in one way or another. Is there code that lowers memcpy_chk(.. unknown) -> memcpy that happens at codegen time? If not, lowering the object size intrinsic only will pessimize real cases, no? -Chris From echristo at apple.com Sat Dec 5 00:06:47 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 4 Dec 2009 22:06:47 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> Message-ID: <65294397-3114-4622-AA51-E1EC10BB4A4A@apple.com> >> >> The lower to "unknown" is merely a placeholder that keeps current behavior. > > What do you mean? > We're lowering to unknown in simplifylibcall because I haven't had time to write the rest of the pass yet :) >> We do lower to unknown at codegen time already if we didn't before. It should be all lowered before we get to codegen in one way or another. > > Is there code that lowers memcpy_chk(.. unknown) -> memcpy that happens at codegen time? If not, lowering the object size intrinsic only will pessimize real cases, no? It would, but we should only get there unoptimized. I see what you mean though and I can get something to do the conversion in the unoptimized case if you'd like, but I probably wouldn't worry about it otherwise. -eric From echristo at apple.com Sat Dec 5 00:16:35 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 05 Dec 2009 06:16:35 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90648 - in /llvm-gcc-4.2/trunk/gcc/config/i386: mmintrin.h tmmintrin.h Message-ID: <200912050616.nB56GZn6019752@zion.cs.uiuc.edu> Author: echristo Date: Sat Dec 5 00:16:35 2009 New Revision: 90648 URL: http://llvm.org/viewvc/llvm-project?rev=90648&view=rev Log: These should be v1di, not long long. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/mmintrin.h llvm-gcc-4.2/trunk/gcc/config/i386/tmmintrin.h Modified: llvm-gcc-4.2/trunk/gcc/config/i386/mmintrin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/mmintrin.h?rev=90648&r1=90647&r2=90648&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/mmintrin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/mmintrin.h Sat Dec 5 00:16:35 2009 @@ -44,6 +44,8 @@ typedef int __v2si __attribute__ ((__vector_size__ (8))); typedef short __v4hi __attribute__ ((__vector_size__ (8))); typedef char __v8qi __attribute__ ((__vector_size__ (8))); +/* LLVM LOCAL */ +typedef long long __v1di __attribute__ ((__vector_size__ (8))); /* APPLE LOCAL begin nodebug inline 4152603 */ #define __always_inline__ __always_inline__, __nodebug__ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/tmmintrin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/tmmintrin.h?rev=90648&r1=90647&r2=90648&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/tmmintrin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/tmmintrin.h Sat Dec 5 00:16:35 2009 @@ -243,9 +243,10 @@ #define _mm_alignr_epi8(__X, __Y, __N) \ ((__m128i)__builtin_ia32_palignr128 ((__v2di)(__X), (__v2di)(__Y), (__N) * 8)) /* APPLE LOCAL end 5814283 */ - +/* LLVM LOCAL begin */ #define _mm_alignr_pi8(__X, __Y, __N) \ - ((__m64)__builtin_ia32_palignr ((long long) (__X), (long long) (__Y), (__N) * 8)) + ((__m64)__builtin_ia32_palignr ((__v1di) (__X), (__v1di) (__Y), (__N) * 8)) +/* LLVM LOCAL end */ /* APPLE LOCAL begin radar 5618945 */ __STATIC_INLINE __m128i __attribute__((__always_inline__)) From echristo at apple.com Sat Dec 5 00:18:30 2009 From: echristo at apple.com (Eric Christopher) Date: Sat, 05 Dec 2009 06:18:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r90649 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <200912050618.nB56IUFR019824@zion.cs.uiuc.edu> Author: echristo Date: Sat Dec 5 00:18:30 2009 New Revision: 90649 URL: http://llvm.org/viewvc/llvm-project?rev=90649&view=rev Log: Truncate to i8 in case we got a larger argument (likely). Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=90649&r1=90648&r2=90649&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Sat Dec 5 00:18:30 2009 @@ -613,7 +613,8 @@ Intrinsic::getDeclaration(TheModule, FnCode == IX86_BUILTIN_PALIGNR ? Intrinsic::x86_ssse3_palign_r : Intrinsic::x86_ssse3_palign_r_128); - Value *CallOps[3] = { Ops[0], Ops[1], Ops[2] }; + Value *Op2 = Builder.CreateTrunc(Ops[2], Type::getInt8Ty(Context)); + Value *CallOps[3] = { Ops[0], Ops[1], Op2 }; Result = Builder.CreateCall(palignr, CallOps, CallOps+3); return true; } else { From clattner at apple.com Sat Dec 5 00:24:07 2009 From: clattner at apple.com (Chris Lattner) Date: Fri, 4 Dec 2009 22:24:07 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: <65294397-3114-4622-AA51-E1EC10BB4A4A@apple.com> References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> <65294397-3114-4622-AA51-E1EC10BB4A4A@apple.com> Message-ID: On Dec 4, 2009, at 10:06 PM, Eric Christopher wrote: >>> >>> The lower to "unknown" is merely a placeholder that keeps current behavior. >> >> What do you mean? >> > > We're lowering to unknown in simplifylibcall because I haven't had time to write the rest of the pass yet :) > >>> We do lower to unknown at codegen time already if we didn't before. It should be all lowered before we get to codegen in one way or another. >> >> Is there code that lowers memcpy_chk(.. unknown) -> memcpy that happens at codegen time? If not, lowering the object size intrinsic only will pessimize real cases, no? > > It would, but we should only get there unoptimized. I see what you mean though and I can get something to do the conversion in the unoptimized case if you'd like, but I probably wouldn't worry about it otherwise. Many memfoo calls will have an unknown length. We want to make sure to get a call to memfoo (instead of memfoo_chk) for both performance and code size reasons. -Chris From echristo at apple.com Sat Dec 5 00:31:36 2009 From: echristo at apple.com (Eric Christopher) Date: Fri, 4 Dec 2009 22:31:36 -0800 Subject: [llvm-commits] [llvm] r89523 - /llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp In-Reply-To: References: <200911210101.nAL11UDE029891@zion.cs.uiuc.edu> <4BB9E6FB-BA42-4659-A796-012D69CE83C4@apple.com> <08D67963-7454-43EC-A7D6-8074D350E20A@apple.com> <65294397-3114-4622-AA51-E1EC10BB4A4A@apple.com> Message-ID: <8BDD65A4-ABB0-4E7D-9D7B-B1678698A8F3@apple.com> On Dec 4, 2009, at 10:24 PM, Chris Lattner wrote: > > On Dec 4, 2009, at 10:06 PM, Eric Christopher wrote: > >>>> >>>> The lower to "unknown" is merely a placeholder that keeps current behavior. >>> >>> What do you mean? >>> >> >> We're lowering to unknown in simplifylibcall because I haven't had time to write the rest of the pass yet :) >> >>>> We do lower to unknown at codegen time already if we didn't before. It should be all lowered before we get to codegen in one way or another. >>> >>> Is there code that lowers memcpy_chk(.. unknown) -> memcpy that happens at codegen time? If not, lowering the object size intrinsic only will pessimize real cases, no? >> >> It would, but we should only get there unoptimized. I see what you mean though and I can get something to do the conversion in the unoptimized case if you'd like, but I probably wouldn't worry about it otherwise. > > Many memfoo calls will have an unknown length. We want to make sure to get a call to memfoo (instead of memfoo_chk) for both performance and code size reasons. After IRC discussion, I understand :) I'll move some things around and make sure that things happen in good time. -eric From nicholas at mxc.ca Sat Dec 5 00:34:25 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 04 Dec 2009 22:34:25 -0800 Subject: [llvm-commits] [llvm] r90045 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/DeadStoreElimination/lifetime.ll In-Reply-To: References: <200911282127.nASLRoum025712@zion.cs.uiuc.edu> Message-ID: <4B19FEF1.5050605@mxc.ca> Chris Lattner wrote: > > On Nov 28, 2009, at 1:27 PM, Nick Lewycky wrote: > >> Author: nicholas >> Date: Sat Nov 28 15:27:49 2009 >> New Revision: 90045 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90045&view=rev >> Log: >> Teach memdep to look for memory use intrinsics during dependency >> queries. Fixes >> PR5574. > > Hi Nick, > > I'm just now catching up on all of the lifetime/invariant stuff you've > added to memdep, here are some comments: > > memdep:188: > > if (IntrinsicInst *II = dyn_cast(Inst)) { > // If we pass an invariant-end marker, then we've just entered an > // invariant region and can start ignoring dependencies. > if (II->getIntrinsicID() == Intrinsic::invariant_end) { > uint64_t InvariantSize = ~0ULL; > if (ConstantInt *CI = dyn_cast(II->getOperand(2))) > InvariantSize = CI->getZExtValue(); > > Operand 2 is guaranteed to be a ConstantInt, this should use cast<>, > however... > > AliasAnalysis::AliasResult R = > AA->alias(II->getOperand(3), InvariantSize, MemPtr, MemSize); > if (R == AliasAnalysis::MustAlias) { > InvariantTag = II->getOperand(1); > continue; > } > > mustalias queries don't care about the size of the operands, so getting > it is pointless. Either the pointers themselves mustalias or not. As > such, this won't catch the case where you have a lifetime marker saying > that a 20 byte object is live/dead but where you're accessing 4 bytes > into the 20 byte object. I don't know if you care about this case, if > so, please fix it somehow, otherwise remove the dead code and add a > FIXME describing the issue. > > > In the case when you do have a mustalias, why do you continue the scan > at all? Can't you just look at the instruction that defines the > Invariant tag and jump up to it? That would allow eliminating > InvariantTag entirely. I really don't like how InvariantTag is scattered > throughout getPointerDependencyFrom. > > > } else if (II->getIntrinsicID() == Intrinsic::lifetime_start || > II->getIntrinsicID() == Intrinsic::lifetime_end) { > > This has the same problem as above, cast<> and mustalias. > > if (R == AliasAnalysis::MustAlias) > return MemDepResult::getDef(II); > > Returning a def of the lifetime start/end is perfectly reasonable here, > but please please document this case (the semantics of this case) in the > comment above the MemDepResult::Def enum in MemDep.h. Thanks. I don't really have an intuitive understanding of what Def really means in MemDep. > // Debug intrinsics don't cause dependences. > if (isa(Inst)) continue; > > This can be hoisted into the 'if dyn_cast' block. > > > memdep:378: > switch (IntrinsicID) { > case Intrinsic::lifetime_start: > case Intrinsic::lifetime_end: > > Please indent the case to the level of the switch, and add a break at > the end of the default case. > > What does this code *do* anyway? Does someone actually call > getDependency() on a lifetime/invariant intrinsic? Sure. In test/Analysis/BasicAA/modref.ll, DSE runs through every instruction in @test3 and calls getDependency(Inst) on each one. DSE bails (on the instruction) if it doesn't get a Def back. > bool isLoad = !QueryInst->mayWriteToMemory(); > if (IntrinsicInst *II = dyn_cast(QueryInst)) { > isLoad |= II->getIntrinsicID() == Intrinsic::lifetime_end; > } > > This dance is gross. I hate it too. Shall I factor it into a function? It feels like that's not an improvement, we're just moving badness around. Nick From nicholas at mxc.ca Sat Dec 5 00:37:24 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 05 Dec 2009 06:37:24 -0000 Subject: [llvm-commits] [llvm] r90650 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <200912050637.nB56bOej020554@zion.cs.uiuc.edu> Author: nicholas Date: Sat Dec 5 00:37:24 2009 New Revision: 90650 URL: http://llvm.org/viewvc/llvm-project?rev=90650&view=rev Log: Fix indentation in switch statement. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=90650&r1=90649&r2=90650&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Sat Dec 5 00:37:24 2009 @@ -373,21 +373,22 @@ IntrinsicID = II->getIntrinsicID(); switch (IntrinsicID) { - case Intrinsic::lifetime_start: - case Intrinsic::lifetime_end: - case Intrinsic::invariant_start: - MemPtr = QueryInst->getOperand(2); - MemSize = cast(QueryInst->getOperand(1))->getZExtValue(); - break; - case Intrinsic::invariant_end: - MemPtr = QueryInst->getOperand(3); - MemSize = cast(QueryInst->getOperand(2))->getZExtValue(); - break; - default: - CallSite QueryCS = CallSite::get(QueryInst); - bool isReadOnly = AA->onlyReadsMemory(QueryCS); - LocalCache = getCallSiteDependencyFrom(QueryCS, isReadOnly, ScanPos, - QueryParent); + case Intrinsic::lifetime_start: + case Intrinsic::lifetime_end: + case Intrinsic::invariant_start: + MemPtr = QueryInst->getOperand(2); + MemSize = cast(QueryInst->getOperand(1))->getZExtValue(); + break; + case Intrinsic::invariant_end: + MemPtr = QueryInst->getOperand(3); + MemSize = cast(QueryInst->getOperand(2))->getZExtValue(); + break; + default: + CallSite QueryCS = CallSite::get(QueryInst); + bool isReadOnly = AA->onlyReadsMemory(QueryCS); + LocalCache = getCallSiteDependencyFrom(QueryCS, isReadOnly, ScanPos, + QueryParent); + break; } } else { // Non-memory instruction. From nicholas at mxc.ca Sat Dec 5 00:37:53 2009 From: nicholas at mxc.ca (Nick Lewycky) Date: Sat, 05 Dec 2009 06:37:53 -0000 Subject: [llvm-commits] [llvm] r90651 - /llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Message-ID: <200912050637.nB56brE5020577@zion.cs.uiuc.edu> Author: nicholas Date: Sat Dec 5 00:37:52 2009 New Revision: 90651 URL: http://llvm.org/viewvc/llvm-project?rev=90651&view=rev Log: Document that memory use intrinsics may also return Def results. Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=90651&r1=90650&r2=90651&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Sat Dec 5 00:37:52 2009 @@ -60,9 +60,9 @@ /// this case, the load is loading an undef value or a store is the /// first store to (that part of) the allocation. /// 3. Dependence queries on calls return Def only when they are - /// readonly calls with identical callees and no intervening - /// clobbers. No validation is done that the operands to the calls - /// are the same. + /// readonly calls or memory use intrinsics with identical callees + /// and no intervening clobbers. No validation is done that the + /// operands to the calls are the same. Def, /// NonLocal - This marker indicates that the query has no dependency in From isanbard at gmail.com Sat Dec 5 01:22:25 2009 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 4 Dec 2009 23:22:25 -0800 Subject: [llvm-commits] [llvm] r90640 - /llvm/trunk/lib/Target/TargetData.cpp In-Reply-To: References: <200912050146.nB51k1rn010050@zion.cs.uiuc.edu> Message-ID: <2EEF1CDC-E009-4C05-9C4A-EA09ABF55A01@gmail.com> On Dec 4, 2009, at 9:29 PM, Chris Lattner wrote: > > On Dec 4, 2009, at 5:46 PM, Bill Wendling wrote: > >> Author: void >> Date: Fri Dec 4 19:46:01 2009 >> New Revision: 90640 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=90640&view=rev >> Log: >> Inline methods which are called only once. > > Thanks Bill, a couple more things: > > class StructLayoutMap : public AbstractTypeUser { > public: > typedef DenseMap LayoutInfoTy; > > no longer needs to be public. > > > > > virtual void refineAbstractType(const DerivedType *OldTy, > const Type *) { > virtual void typeBecameConcrete(const DerivedType *AbsTy) { > ... > > both of these can now just call InvalidateEntry. > > > > const StructLayout *TargetData::getStructLayout(const StructType *Ty) const { > > Please move the meat of this into StructLayoutMap, allowing the elimination of the operator[]. > > > Otherwise, looks very tidy now, thanks! > Thanks. :) I'm doing it in waves because it broke last time. I'll get to the above soon. -bw From isanbard at gmail.com Sat Dec 5 01:30:24 2009 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 05 Dec 2009 07:30:24 -0000 Subject: [llvm-commits] [llvm] r90653 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/RegAllocLinearScan.cpp test/CodeGen/X86/2009-01-12-CoalescerBug.ll test/CodeGen/X86/twoaddr-coalesce.ll Message-ID: <200912050730.nB57UOfo022291@zion.cs.uiuc.edu> Author: void Date: Sat Dec 5 01:30:23 2009 New Revision: 90653 URL: http://llvm.org/viewvc/llvm-project?rev=90653&view=rev Log: Temporarily revert r90502. It was causing the llvm-gcc bootstrap on PPC to fail. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=90653&r1=90652&r2=90653&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Sat Dec 5 01:30:23 2009 @@ -117,12 +117,6 @@ bool conflictsWithPhysRegDef(const LiveInterval &li, VirtRegMap &vrm, unsigned reg); - /// conflictsWithPhysRegUse - Returns true if the specified register is used - /// or defined during the duration of the specified interval. Copies to and - /// from li.reg are allowed. - bool conflictsWithPhysRegUse(const LiveInterval &li, VirtRegMap &vrm, - unsigned reg); - /// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except /// it can check use as well. bool conflictsWithPhysRegRef(LiveInterval &li, unsigned Reg, Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=90653&r1=90652&r2=90653&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Sat Dec 5 01:30:23 2009 @@ -157,15 +157,19 @@ I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { for (SlotIndex index = I->start.getBaseIndex(), end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); - index != end; - index = index.getNextIndex()) { + index != end; + index = index.getNextIndex()) { MachineInstr *MI = getInstructionFromIndex(index); if (!MI) continue; // skip deleted instructions + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; + if (tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg)) + if (SrcReg == li.reg || DstReg == li.reg) + continue; for (unsigned i = 0; i != MI->getNumOperands(); ++i) { MachineOperand& mop = MI->getOperand(i); - if (!mop.isReg() || mop.isUse()) + if (!mop.isReg()) continue; unsigned PhysReg = mop.getReg(); if (PhysReg == 0 || PhysReg == li.reg) @@ -184,50 +188,6 @@ return false; } -/// conflictsWithPhysRegUse - Returns true if the specified register is used or -/// defined during the duration of the specified interval. Copies to and from -/// li.reg are allowed. -bool LiveIntervals::conflictsWithPhysRegUse(const LiveInterval &li, - VirtRegMap &vrm, unsigned reg) { - for (LiveInterval::Ranges::const_iterator - I = li.ranges.begin(), E = li.ranges.end(); I != E; ++I) { - for (SlotIndex index = I->start.getBaseIndex(), - end = I->end.getPrevSlot().getBaseIndex().getNextIndex(); - index != end; - index = index.getNextIndex()) { - MachineInstr *MI = getInstructionFromIndex(index); - if (!MI) - continue; // skip deleted instructions - - // Terminators are considered conflicts since reg may be used at the - // destination. - if (MI->getDesc().isTerminator()) - return true; - - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& mop = MI->getOperand(i); - if (!mop.isReg() || mop.isUndef()) - continue; - unsigned PhysReg = mop.getReg(); - if (PhysReg == 0 || PhysReg == li.reg) - continue; - if (TargetRegisterInfo::isVirtualRegister(PhysReg)) { - if (!vrm.hasPhys(PhysReg)) - continue; - PhysReg = vrm.getPhys(PhysReg); - } - if (PhysReg && tri_->regsOverlap(PhysReg, reg)) { - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; - if (!tii_->isMoveInstr(*MI, SrcReg, DstReg, SrcSubReg, DstSubReg) || - (SrcReg != li.reg && DstReg != li.reg)) - return true; - } - } - } - } - return false; -} - /// conflictsWithPhysRegRef - Similar to conflictsWithPhysRegRef except /// it can check use as well. bool LiveIntervals::conflictsWithPhysRegRef(LiveInterval &li, Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=90653&r1=90652&r2=90653&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Sat Dec 5 01:30:23 2009 @@ -390,70 +390,66 @@ RelatedRegClasses.unionSets(I->second, OneClassForEachPhysReg[*AS]); } -/// attemptTrivialCoalescing - If a simple interval is defined by a copy, try -/// allocate the definition the same register as the source register if the -/// register is not defined during live time of the interval. If the interval is -/// killed by a copy, try to use the destination register. This eliminates a -/// copy. This is used to coalesce copies which were not coalesced away before -/// allocation either due to dest and src being in different register classes or -/// because the coalescer was overly conservative. +/// attemptTrivialCoalescing - If a simple interval is defined by a copy, +/// try allocate the definition the same register as the source register +/// if the register is not defined during live time of the interval. This +/// eliminate a copy. This is used to coalesce copies which were not +/// coalesced away before allocation either due to dest and src being in +/// different register classes or because the coalescer was overly +/// conservative. unsigned RALinScan::attemptTrivialCoalescing(LiveInterval &cur, unsigned Reg) { unsigned Preference = vrm_->getRegAllocPref(cur.reg); if ((Preference && Preference == Reg) || !cur.containsOneValue()) return Reg; VNInfo *vni = cur.begin()->valno; - if (vni->isUnused()) + if ((vni->def == SlotIndex()) || + vni->isUnused() || !vni->isDefAccurate()) return Reg; - unsigned CandReg; - bool forward; // extending physreg forward - { - MachineInstr *CopyMI; - unsigned SrcReg, DstReg, SrcSubReg, DstSubReg; - if (vni->def != SlotIndex() && vni->isDefAccurate() && - (CopyMI = li_->getInstructionFromIndex(vni->def)) && - tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) - // Defined by a copy, try to extend SrcReg forward - CandReg = SrcReg, forward = true; - else if (cur.ranges.size()==1 && - (CopyMI = - li_->getInstructionFromIndex(cur.begin()->end.getBaseIndex())) && - tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg) && - cur.reg == SrcReg) - // Only used by a copy, try to extend DstReg backwards - CandReg = DstReg, forward = false; - else - return Reg; - } - - if (TargetRegisterInfo::isVirtualRegister(CandReg)) { - if (!vrm_->isAssignedReg(CandReg)) + MachineInstr *CopyMI = li_->getInstructionFromIndex(vni->def); + unsigned SrcReg, DstReg, SrcSubReg, DstSubReg, PhysReg; + if (!CopyMI || + !tii_->isMoveInstr(*CopyMI, SrcReg, DstReg, SrcSubReg, DstSubReg)) + return Reg; + PhysReg = SrcReg; + if (TargetRegisterInfo::isVirtualRegister(SrcReg)) { + if (!vrm_->isAssignedReg(SrcReg)) return Reg; - CandReg = vrm_->getPhys(CandReg); + PhysReg = vrm_->getPhys(SrcReg); } - if (Reg == CandReg) + if (Reg == PhysReg) return Reg; const TargetRegisterClass *RC = mri_->getRegClass(cur.reg); - if (!RC->contains(CandReg)) + if (!RC->contains(PhysReg)) return Reg; - if (forward) { - if (li_->conflictsWithPhysRegDef(cur, *vrm_, CandReg)) - return Reg; - } else { - if (li_->conflictsWithPhysRegUse(cur, *vrm_, CandReg)) - return Reg; - } - // Try to coalesce. - DEBUG(errs() << "Coalescing: " << cur << " -> " << tri_->getName(CandReg) - << '\n'); - vrm_->clearVirt(cur.reg); - vrm_->assignVirt2Phys(cur.reg, CandReg); + if (!li_->conflictsWithPhysRegDef(cur, *vrm_, PhysReg)) { + DEBUG(errs() << "Coalescing: " << cur << " -> " << tri_->getName(PhysReg) + << '\n'); + vrm_->clearVirt(cur.reg); + vrm_->assignVirt2Phys(cur.reg, PhysReg); + + // Remove unnecessary kills since a copy does not clobber the register. + if (li_->hasInterval(SrcReg)) { + LiveInterval &SrcLI = li_->getInterval(SrcReg); + for (MachineRegisterInfo::use_iterator I = mri_->use_begin(cur.reg), + E = mri_->use_end(); I != E; ++I) { + MachineOperand &O = I.getOperand(); + if (!O.isKill()) + continue; + MachineInstr *MI = &*I; + if (SrcLI.liveAt(li_->getInstructionIndex(MI).getDefIndex())) + O.setIsKill(false); + } + } + + ++NumCoalesce; + return PhysReg; + } - ++NumCoalesce; - return CandReg; + return Reg; } bool RALinScan::runOnMachineFunction(MachineFunction &fn) { Modified: llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll?rev=90653&r1=90652&r2=90653&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-01-12-CoalescerBug.ll Sat Dec 5 01:30:23 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | grep movq | count 1 +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | grep movq | count 2 ; PR3311 %struct.CUMULATIVE_ARGS = type { i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } Modified: llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll?rev=90653&r1=90652&r2=90653&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll (original) +++ llvm/trunk/test/CodeGen/X86/twoaddr-coalesce.ll Sat Dec 5 01:30:23 2009 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 | grep mov | count 4 +; RUN: llc < %s -march=x86 | grep mov | count 5 ; rdar://6523745 @"\01LC" = internal constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=1] From isanbard at gmail.com Sat Dec 5 01:46:49 2009 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 05 Dec 2009 07:46:49 -0000 Subject: [llvm-commits] [llvm] r90655 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912050746.nB57knX5022889@zion.cs.uiuc.edu> Author: void Date: Sat Dec 5 01:46:49 2009 New Revision: 90655 URL: http://llvm.org/viewvc/llvm-project?rev=90655&view=rev Log: Final cleanups: - Privatize a typedef. - Call the InvalidateEntry when refining a type. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90655&r1=90654&r2=90655&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Sat Dec 5 01:46:49 2009 @@ -318,9 +318,7 @@ namespace { class StructLayoutMap : public AbstractTypeUser { -public: typedef DenseMap LayoutInfoTy; -private: LayoutInfoTy LayoutInfo; /// refineAbstractType - The callback method invoked when an abstract type is @@ -329,12 +327,7 @@ /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { - const StructType *STy = cast(OldTy); - LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); - Iter->second->~StructLayout(); - free(Iter->second); - LayoutInfo.erase(Iter); - OldTy->removeAbstractTypeUser(this); + InvalidateEntry(cast(OldTy)); } /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware @@ -343,12 +336,7 @@ /// This method notifies ATU's when this occurs for a type. /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { - const StructType *STy = cast(AbsTy); - LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); - Iter->second->~StructLayout(); - free(Iter->second); - LayoutInfo.erase(Iter); - AbsTy->removeAbstractTypeUser(this); + InvalidateEntry(cast(AbsTy)); } public: From isanbard at gmail.com Sat Dec 5 01:59:04 2009 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 05 Dec 2009 07:59:04 -0000 Subject: [llvm-commits] [llvm] r90656 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <200912050759.nB57x42v023280@zion.cs.uiuc.edu> Author: void Date: Sat Dec 5 01:59:04 2009 New Revision: 90656 URL: http://llvm.org/viewvc/llvm-project?rev=90656&view=rev Log: Calling InvalidateEntry during the refinement was breaking the bootstrap. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=90656&r1=90655&r2=90656&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Sat Dec 5 01:59:04 2009 @@ -327,7 +327,12 @@ /// virtual void refineAbstractType(const DerivedType *OldTy, const Type *) { - InvalidateEntry(cast(OldTy)); + const StructType *STy = cast(OldTy); + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); + OldTy->removeAbstractTypeUser(this); } /// typeBecameConcrete - The other case which AbstractTypeUsers must be aware @@ -336,7 +341,12 @@ /// This method notifies ATU's when this occurs for a type. /// virtual void typeBecameConcrete(const DerivedType *AbsTy) { - InvalidateEntry(cast(AbsTy)); + const StructType *STy = cast(AbsTy); + LayoutInfoTy::iterator Iter = LayoutInfo.find(STy); + Iter->second->~StructLayout(); + free(Iter->second); + LayoutInfo.erase(Iter); + AbsTy->removeAbstractTypeUser(this); } public: From gohman at apple.com Sat Dec 5 11:51:34 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 17:51:34 -0000 Subject: [llvm-commits] [llvm] r90668 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200912051751.nB5HpYcf024654@zion.cs.uiuc.edu> Author: djg Date: Sat Dec 5 11:51:33 2009 New Revision: 90668 URL: http://llvm.org/viewvc/llvm-project?rev=90668&view=rev Log: Remove the unused DisableLegalizeTypes option and related code. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=90668&r1=90667&r2=90668&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Sat Dec 5 11:51:33 2009 @@ -220,7 +220,7 @@ /// /// Note that this is an involved process that may invalidate pointers into /// the graph. - void Legalize(bool TypesNeedLegalizing, CodeGenOpt::Level OptLevel); + void Legalize(CodeGenOpt::Level OptLevel); /// LegalizeVectors - This transforms the SelectionDAG into a SelectionDAG /// that only uses vector math operations supported by the target. This is Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=90668&r1=90667&r2=90668&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Dec 5 11:51:33 2009 @@ -3059,8 +3059,7 @@ // SelectionDAG::Legalize - This is the entry point for the file. // -void SelectionDAG::Legalize(bool TypesNeedLegalizing, - CodeGenOpt::Level OptLevel) { +void SelectionDAG::Legalize(CodeGenOpt::Level OptLevel) { /// run - This is the main entry point to this class. /// SelectionDAGLegalize(*this, OptLevel).LegalizeDAG(); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90668&r1=90667&r2=90668&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sat Dec 5 11:51:33 2009 @@ -60,8 +60,6 @@ using namespace llvm; static cl::opt -DisableLegalizeTypes("disable-legalize-types", cl::Hidden); -static cl::opt EnableFastISelVerbose("fast-isel-verbose", cl::Hidden, cl::desc("Enable verbose messages in the \"fast\" " "instruction selector")); @@ -529,75 +527,73 @@ // Second step, hack on the DAG until it only uses operations and types that // the target supports. - if (!DisableLegalizeTypes) { - if (ViewLegalizeTypesDAGs) CurDAG->viewGraph("legalize-types input for " + - BlockName); + if (ViewLegalizeTypesDAGs) CurDAG->viewGraph("legalize-types input for " + + BlockName); + + bool Changed; + if (TimePassesIsEnabled) { + NamedRegionTimer T("Type Legalization", GroupName); + Changed = CurDAG->LegalizeTypes(); + } else { + Changed = CurDAG->LegalizeTypes(); + } + + DEBUG(errs() << "Type-legalized selection DAG:\n"); + DEBUG(CurDAG->dump()); - bool Changed; + if (Changed) { + if (ViewDAGCombineLT) + CurDAG->viewGraph("dag-combine-lt input for " + BlockName); + + // Run the DAG combiner in post-type-legalize mode. if (TimePassesIsEnabled) { - NamedRegionTimer T("Type Legalization", GroupName); - Changed = CurDAG->LegalizeTypes(); + NamedRegionTimer T("DAG Combining after legalize types", GroupName); + CurDAG->Combine(NoIllegalTypes, *AA, OptLevel); } else { - Changed = CurDAG->LegalizeTypes(); + CurDAG->Combine(NoIllegalTypes, *AA, OptLevel); } - DEBUG(errs() << "Type-legalized selection DAG:\n"); + DEBUG(errs() << "Optimized type-legalized selection DAG:\n"); DEBUG(CurDAG->dump()); + } - if (Changed) { - if (ViewDAGCombineLT) - CurDAG->viewGraph("dag-combine-lt input for " + BlockName); - - // Run the DAG combiner in post-type-legalize mode. - if (TimePassesIsEnabled) { - NamedRegionTimer T("DAG Combining after legalize types", GroupName); - CurDAG->Combine(NoIllegalTypes, *AA, OptLevel); - } else { - CurDAG->Combine(NoIllegalTypes, *AA, OptLevel); - } - - DEBUG(errs() << "Optimized type-legalized selection DAG:\n"); - DEBUG(CurDAG->dump()); - } + if (TimePassesIsEnabled) { + NamedRegionTimer T("Vector Legalization", GroupName); + Changed = CurDAG->LegalizeVectors(); + } else { + Changed = CurDAG->LegalizeVectors(); + } + if (Changed) { if (TimePassesIsEnabled) { - NamedRegionTimer T("Vector Legalization", GroupName); - Changed = CurDAG->LegalizeVectors(); + NamedRegionTimer T("Type Legalization 2", GroupName); + Changed = CurDAG->LegalizeTypes(); } else { - Changed = CurDAG->LegalizeVectors(); + Changed = CurDAG->LegalizeTypes(); } - if (Changed) { - if (TimePassesIsEnabled) { - NamedRegionTimer T("Type Legalization 2", GroupName); - Changed = CurDAG->LegalizeTypes(); - } else { - Changed = CurDAG->LegalizeTypes(); - } - - if (ViewDAGCombineLT) - CurDAG->viewGraph("dag-combine-lv input for " + BlockName); + if (ViewDAGCombineLT) + CurDAG->viewGraph("dag-combine-lv input for " + BlockName); - // Run the DAG combiner in post-type-legalize mode. - if (TimePassesIsEnabled) { - NamedRegionTimer T("DAG Combining after legalize vectors", GroupName); - CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); - } else { - CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); - } - - DEBUG(errs() << "Optimized vector-legalized selection DAG:\n"); - DEBUG(CurDAG->dump()); + // Run the DAG combiner in post-type-legalize mode. + if (TimePassesIsEnabled) { + NamedRegionTimer T("DAG Combining after legalize vectors", GroupName); + CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); + } else { + CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); } + + DEBUG(errs() << "Optimized vector-legalized selection DAG:\n"); + DEBUG(CurDAG->dump()); } if (ViewLegalizeDAGs) CurDAG->viewGraph("legalize input for " + BlockName); if (TimePassesIsEnabled) { NamedRegionTimer T("DAG Legalization", GroupName); - CurDAG->Legalize(DisableLegalizeTypes, OptLevel); + CurDAG->Legalize(OptLevel); } else { - CurDAG->Legalize(DisableLegalizeTypes, OptLevel); + CurDAG->Legalize(OptLevel); } DEBUG(errs() << "Legalized selection DAG:\n"); From gohman at apple.com Sat Dec 5 11:56:26 2009 From: gohman at apple.com (Dan Gohman) Date: Sat, 05 Dec 2009 17:56:26 -0000 Subject: [llvm-commits] [llvm] r90669 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGISel.h lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <200912051756.nB5HuQof024816@zion.cs.uiuc.edu> Author: djg Date: Sat Dec 5 11:56:26 2009 New Revision: 90669 URL: http://llvm.org/viewvc/llvm-project?rev=90669&view=rev Log: Remove old DBG_LABEL code. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=90669&r1=90668&r2=90669&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Sat Dec 5 11:56:26 2009 @@ -113,7 +113,6 @@ // Calls to these functions are generated by tblgen. SDNode *Select_INLINEASM(SDValue N); SDNode *Select_UNDEF(const SDValue &N); - SDNode *Select_DBG_LABEL(const SDValue &N); SDNode *Select_EH_LABEL(const SDValue &N); void CannotYetSelect(SDValue N); void CannotYetSelectIntrinsic(SDValue N); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=90669&r1=90668&r2=90669&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Sat Dec 5 11:56:26 2009 @@ -1327,14 +1327,6 @@ N.getValueType()); } -SDNode *SelectionDAGISel::Select_DBG_LABEL(const SDValue &N) { - SDValue Chain = N.getOperand(0); - unsigned C = cast(N)->getLabelID(); - SDValue Tmp = CurDAG->getTargetConstant(C, MVT::i32); - return CurDAG->SelectNodeTo(N.getNode(), TargetInstrInfo::DBG_LABEL, - MVT::Other, Tmp, Chain); -} - SDNode *SelectionDAGISel::Select_EH_LABEL(const SDValue &N) { SDValue Chain = N.getOperand(0); unsigned C = cast(N)->getLabelID(); From mm.beck at gmx.net Sat Dec 5 12:54:55 2009 From: mm.beck at gmx.net (Michael Beck) Date: Sat, 05 Dec 2009 19:54:55 +0100 Subject: [llvm-commits] Fix for atomic intrinsics detection when using MSVC Message-ID: <20091205185455.293990@gmx.net> Hi all, the following patch fixes the detection of atomic intrinsics when compiling with MSVC and is consistent with the Atomic.cpp implementation. best regards, -- Michael Beck GRATIS f?r alle GMX-Mitglieder: Die maxdome Movie-FLAT! Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01 -------------- next part -------------- A non-text attachment was scrubbed... Name: CheckAtomic.cmake.diff Type: application/octet-stream Size: 833 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091205/6e6b669e/attachment.obj From jyasskin at gmail.com Sat Dec 5 16:57:23 2009 From: jyasskin at gmail.com (jyasskin at gmail.com) Date: Sat, 05 Dec 2009 22:57:23 +0000 Subject: [llvm-commits] [PATCH] New external2availableexternally pass (issue166075) Message-ID: <00163691fbf3bc89a9047a032500@google.com> Reviewers: , Message: Please take a look: http://codereview.appspot.com/download/issue166075_1.diff Description: When we have a runtime library, it's useful to expose that library to the optimizers, but it's bad to ask LLVM to actually codegen the library's code a second time. This pass name is uncomfortably long. I'd be happy to accept any suggestions for the name. Please review this at http://codereview.appspot.com/166075 Affected files: M docs/Passes.html M include/llvm/LinkAllPasses.h M include/llvm/Transforms/IPO.h A lib/Transforms/IPO/External2Available.cpp A test/Transforms/External2Available/2009-12-05-AllExternals.ll A test/Transforms/External2Available/dg.exp From ofv at wanadoo.es Sat Dec 5 17:19:33 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sat, 05 Dec 2009 23:19:33 -0000 Subject: [llvm-commits] [llvm] r90683 - /llvm/trunk/cmake/modules/CheckAtomic.cmake Message-ID: <200912052319.nB5NJYxw005162@zion.cs.uiuc.edu> Author: ofv Date: Sat Dec 5 17:19:33 2009 New Revision: 90683 URL: http://llvm.org/viewvc/llvm-project?rev=90683&view=rev Log: Fix for atomic intrinsics detection when using MSVC. Patch by Michael Beck! Modified: llvm/trunk/cmake/modules/CheckAtomic.cmake Modified: llvm/trunk/cmake/modules/CheckAtomic.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CheckAtomic.cmake?rev=90683&r1=90682&r2=90683&view=diff ============================================================================== --- llvm/trunk/cmake/modules/CheckAtomic.cmake (original) +++ llvm/trunk/cmake/modules/CheckAtomic.cmake Sat Dec 5 17:19:33 2009 @@ -1,14 +1,26 @@ # atomic builtins are required for threading support. INCLUDE(CheckCXXSourceCompiles) + +#ifdef _MSC_VER +#include +#endif CHECK_CXX_SOURCE_COMPILES(" int main() { +#ifdef _MSC_VER + volatile LONG val = 1; + MemoryBarrier(); + InterlockedCompareExchange(&val, 0, 1); + InterlockedIncrement(&val); + InterlockedDecrement(&val); +#else volatile unsigned long val = 1; __sync_synchronize(); __sync_val_compare_and_swap(&val, 1, 0); __sync_add_and_fetch(&val, 1); __sync_sub_and_fetch(&val, 1); +#endif return 0; } " LLVM_MULTITHREADED) From ofv at wanadoo.es Sat Dec 5 17:21:02 2009 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Sun, 06 Dec 2009 00:21:02 +0100 Subject: [llvm-commits] Fix for atomic intrinsics detection when using MSVC References: <20091205185455.293990@gmx.net> Message-ID: <87zl5xxb1d.fsf@telefonica.net> "Michael Beck" writes: > the following patch fixes the detection of atomic intrinsics when > compiling with MSVC and is consistent with the Atomic.cpp > implementation. Applied on r90683 with some whitespace corrections. Thanks! -- ?scar From ofv at wanadoo.es Sat Dec 5 18:06:33 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sun, 06 Dec 2009 00:06:33 -0000 Subject: [llvm-commits] [llvm] r90685 - /llvm/trunk/cmake/modules/CheckAtomic.cmake Message-ID: <200912060006.nB606Y2E006878@zion.cs.uiuc.edu> Author: ofv Date: Sat Dec 5 18:06:33 2009 New Revision: 90685 URL: http://llvm.org/viewvc/llvm-project?rev=90685&view=rev Log: CheckAtomic.cmake: Put all C++ code inside CHECK_CXX_SOURCE_COMPILES. Modified: llvm/trunk/cmake/modules/CheckAtomic.cmake Modified: llvm/trunk/cmake/modules/CheckAtomic.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CheckAtomic.cmake?rev=90685&r1=90684&r2=90685&view=diff ============================================================================== --- llvm/trunk/cmake/modules/CheckAtomic.cmake (original) +++ llvm/trunk/cmake/modules/CheckAtomic.cmake Sat Dec 5 18:06:33 2009 @@ -2,11 +2,10 @@ INCLUDE(CheckCXXSourceCompiles) +CHECK_CXX_SOURCE_COMPILES(" #ifdef _MSC_VER #include #endif - -CHECK_CXX_SOURCE_COMPILES(" int main() { #ifdef _MSC_VER volatile LONG val = 1; From mm.beck at gmx.net Sat Dec 5 18:46:05 2009 From: mm.beck at gmx.net (Michael Beck) Date: Sun, 06 Dec 2009 01:46:05 +0100 Subject: [llvm-commits] [patch] Fix Windows Atomic implementation Message-ID: <20091206004605.19300@gmx.net> Hi all, The following patch fixes the Atomic implementation if compiled by MSVC compiler. sys::cas_flag should be long on this platform, InterlockedAdd() is defined only for the Itanium architecture (according to MSDN). If this and my previous patch to cmake/modules/CheckAtomic.cmake are applied, cmake builds with MSVC will contain multithreading support. best regards, -- Michael Beck Preisknaller: GMX DSL Flatrate f?r nur 16,99 Euro/mtl.! http://portal.gmx.net/de/go/dsl02 -------------- next part -------------- A non-text attachment was scrubbed... Name: atomic.diff Type: application/octet-stream Size: 959 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091206/2125f42c/attachment.obj From mm.beck at gmx.net Sat Dec 5 19:22:55 2009 From: mm.beck at gmx.net (Michael Beck) Date: Sun, 06 Dec 2009 02:22:55 +0100 Subject: [llvm-commits] [patch] Change the alignment in the X86.Windows subtarget Message-ID: <20091206012255.145970@gmx.net> Hi all, the following patch changes the data-alignment of the 32bit Windows subtarget to values used by the MSVC compiler. I assume this is the right subtarget for MSVC builds, as isCygwin and isMingw exists and at least cmake build have it ... best regards, -- Michael Beck Jetzt kostenlos herunterladen: Internet Explorer 8 und Mozilla Firefox 3.5 - sicherer, schneller und einfacher! http://portal.gmx.net/de/go/chbrowser -------------- next part -------------- A non-text attachment was scrubbed... Name: X86Subtarget.h.diff Type: application/octet-stream Size: 593 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20091206/e9f6c263/attachment.obj From sabre at nondot.org Sat Dec 5 19:47:24 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 01:47:24 -0000 Subject: [llvm-commits] [llvm] r90691 - in /llvm/trunk/test/Transforms/GVN: rle-dominated.ll rle.ll Message-ID: <200912060147.nB61lOvM010262@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 19:47:24 2009 New Revision: 90691 URL: http://llvm.org/viewvc/llvm-project?rev=90691&view=rev Log: merge two tests. Removed: llvm/trunk/test/Transforms/GVN/rle-dominated.ll Modified: llvm/trunk/test/Transforms/GVN/rle.ll Removed: llvm/trunk/test/Transforms/GVN/rle-dominated.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle-dominated.ll?rev=90690&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle-dominated.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle-dominated.ll (removed) @@ -1,20 +0,0 @@ -; RUN: opt < %s -gvn -S | grep load | count 2 - -define i32 @main(i32** %p) { -block1: - %z = load i32** %p - br i1 true, label %block2, label %block3 - -block2: - %a = load i32** %p - br label %block4 - -block3: - %b = load i32** %p - br label %block4 - -block4: - %c = load i32** %p - %d = load i32* %c - ret i32 %d -} Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=90691&r1=90690&r2=90691&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Sat Dec 5 19:47:24 2009 @@ -279,6 +279,31 @@ ; CHECK: ret i8 %A } +define i32 @chained_load(i32** %p) { +block1: + %z = load i32** %p + br i1 true, label %block2, label %block3 + +block2: + %a = load i32** %p + br label %block4 + +block3: + %b = load i32** %p + br label %block4 + +block4: + %c = load i32** %p + %d = load i32* %c + ret i32 %d + +; CHECK: @chained_load +; CHECK: %z = load i32** %p +; CHECK-NOT: load +; CHECK: %d = load i32* %z +; CHECK-NEXT: ret i32 %d +} + declare i1 @cond() readonly declare i1 @cond2() readonly From sabre at nondot.org Sat Dec 5 19:56:22 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 01:56:22 -0000 Subject: [llvm-commits] [llvm] r90694 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <200912060156.nB61uM0R010560@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 19:56:22 2009 New Revision: 90694 URL: http://llvm.org/viewvc/llvm-project?rev=90694&view=rev Log: Add helper methods for forming shift operations with a constant shift amount. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=90694&r1=90693&r2=90694&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Sat Dec 5 19:56:22 2009 @@ -407,18 +407,39 @@ return Folder.CreateShl(LC, RC); return Insert(BinaryOperator::CreateShl(LHS, RHS), Name); } + Value *CreateShl(Value *LHS, uint64_t RHS, const Twine &Name = "") { + Constant *RHSC = ConstantInt::get(LHS->getType(), RHS); + if (Constant *LC = dyn_cast(LHS)) + return Folder.CreateShl(LC, RHSC); + return Insert(BinaryOperator::CreateShl(LHS, RHSC), Name); + } + Value *CreateLShr(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Folder.CreateLShr(LC, RC); return Insert(BinaryOperator::CreateLShr(LHS, RHS), Name); } + Value *CreateLShr(Value *LHS, uint64_t RHS, const Twine &Name = "") { + Constant *RHSC = ConstantInt::get(LHS->getType(), RHS); + if (Constant *LC = dyn_cast(LHS)) + return Folder.CreateLShr(LC, RHSC); + return Insert(BinaryOperator::CreateLShr(LHS, RHSC), Name); + } + Value *CreateAShr(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *LC = dyn_cast(LHS)) if (Constant *RC = dyn_cast(RHS)) return Folder.CreateAShr(LC, RC); return Insert(BinaryOperator::CreateAShr(LHS, RHS), Name); } + Value *CreateAShr(Value *LHS, uint64_t RHS, const Twine &Name = "") { + Constant *RHSC = ConstantInt::get(LHS->getType(), RHS); + if (Constant *LC = dyn_cast(LHS)) + return Folder.CreateSShr(LC, RHSC); + return Insert(BinaryOperator::CreateAShr(LHS, RHSC), Name); + } + Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *RC = dyn_cast(RHS)) { if (isa(RC) && cast(RC)->isAllOnesValue()) From sabre at nondot.org Sat Dec 5 19:57:03 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 01:57:03 -0000 Subject: [llvm-commits] [llvm] r90695 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll Message-ID: <200912060157.nB61v3wo010593@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 19:57:02 2009 New Revision: 90695 URL: http://llvm.org/viewvc/llvm-project?rev=90695&view=rev Log: Handle forwarding local memsets to loads. For example, we optimize this: short x(short *A) { memset(A, 1, sizeof(*A)*100); return A[42]; } to 'return 257' instead of doing the load. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90695&r1=90694&r2=90695&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Dec 5 19:57:02 2009 @@ -40,6 +40,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Support/IRBuilder.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" @@ -987,25 +988,24 @@ } -/// AnalyzeLoadFromClobberingStore - This function is called when we have a -/// memdep query of a load that ends up being a clobbering store. This means -/// that the store *may* provide bits used by the load but we can't be sure -/// because the pointers don't mustalias. Check this case to see if there is -/// anything more we can do before we give up. This returns -1 if we have to -/// give up, or a byte number in the stored value of the piece that feeds the -/// load. -static int AnalyzeLoadFromClobberingStore(LoadInst *L, StoreInst *DepSI, +/// AnalyzeLoadFromClobberingWrite - This function is called when we have a +/// memdep query of a load that ends up being a clobbering memory write (store, +/// memset, memcpy, memmove). This means that the write *may* provide bits used +/// by the load but we can't be sure because the pointers don't mustalias. +/// +/// Check this case to see if there is anything more we can do before we give +/// up. This returns -1 if we have to give up, or a byte number in the stored +/// value of the piece that feeds the load. +static int AnalyzeLoadFromClobberingWrite(LoadInst *L, Value *WritePtr, + uint64_t WriteSizeInBits, const TargetData &TD) { // If the loaded or stored value is an first class array or struct, don't try // to transform them. We need to be able to bitcast to integer. - if (isa(L->getType()) || isa(L->getType()) || - isa(DepSI->getOperand(0)->getType()) || - isa(DepSI->getOperand(0)->getType())) + if (isa(L->getType()) || isa(L->getType())) return -1; int64_t StoreOffset = 0, LoadOffset = 0; - Value *StoreBase = - GetBaseWithConstantOffset(DepSI->getPointerOperand(), StoreOffset, TD); + Value *StoreBase = GetBaseWithConstantOffset(WritePtr, StoreOffset, TD); Value *LoadBase = GetBaseWithConstantOffset(L->getPointerOperand(), LoadOffset, TD); if (StoreBase != LoadBase) @@ -1018,8 +1018,8 @@ #if 0 errs() << "STORE/LOAD DEP WITH COMMON POINTER MISSED:\n" << "Base = " << *StoreBase << "\n" - << "Store Ptr = " << *DepSI->getPointerOperand() << "\n" - << "Store Offs = " << StoreOffset << " - " << *DepSI << "\n" + << "Store Ptr = " << *WritePtr << "\n" + << "Store Offs = " << StoreOffset << "\n" << "Load Ptr = " << *L->getPointerOperand() << "\n" << "Load Offs = " << LoadOffset << " - " << *L << "\n\n"; errs() << "'" << L->getParent()->getParent()->getName() << "'" @@ -1033,12 +1033,11 @@ // must have gotten confused. // FIXME: Investigate cases where this bails out, e.g. rdar://7238614. Then // remove this check, as it is duplicated with what we have below. - uint64_t StoreSize = TD.getTypeSizeInBits(DepSI->getOperand(0)->getType()); uint64_t LoadSize = TD.getTypeSizeInBits(L->getType()); - if ((StoreSize & 7) | (LoadSize & 7)) + if ((WriteSizeInBits & 7) | (LoadSize & 7)) return -1; - StoreSize >>= 3; // Convert to bytes. + uint64_t StoreSize = WriteSizeInBits >> 3; // Convert to bytes. LoadSize >>= 3; @@ -1052,8 +1051,8 @@ #if 0 errs() << "STORE LOAD DEP WITH COMMON BASE:\n" << "Base = " << *StoreBase << "\n" - << "Store Ptr = " << *DepSI->getPointerOperand() << "\n" - << "Store Offs = " << StoreOffset << " - " << *DepSI << "\n" + << "Store Ptr = " << *WritePtr << "\n" + << "Store Offs = " << StoreOffset << "\n" << "Load Ptr = " << *L->getPointerOperand() << "\n" << "Load Offs = " << LoadOffset << " - " << *L << "\n\n"; errs() << "'" << L->getParent()->getParent()->getName() << "'" @@ -1075,6 +1074,34 @@ return LoadOffset-StoreOffset; } +/// AnalyzeLoadFromClobberingStore - This function is called when we have a +/// memdep query of a load that ends up being a clobbering store. +static int AnalyzeLoadFromClobberingStore(LoadInst *L, StoreInst *DepSI, + const TargetData &TD) { + // Cannot handle reading from store of first-class aggregate yet. + if (isa(DepSI->getOperand(0)->getType()) || + isa(DepSI->getOperand(0)->getType())) + return -1; + + Value *StorePtr = DepSI->getPointerOperand(); + uint64_t StoreSize = TD.getTypeSizeInBits(StorePtr->getType()); + return AnalyzeLoadFromClobberingWrite(L, StorePtr, StoreSize, TD); +} + +static int AnalyzeLoadFromClobberingMemInst(LoadInst *L, MemIntrinsic *MI, + const TargetData &TD) { + // If the mem operation is a non-constant size, we can't handle it. + ConstantInt *SizeCst = dyn_cast(MI->getLength()); + if (SizeCst == 0) return -1; + uint64_t MemSizeInBits = SizeCst->getZExtValue()*8; + + if (MI->getIntrinsicID() == Intrinsic::memset) + return AnalyzeLoadFromClobberingWrite(L, MI->getDest(), MemSizeInBits, TD); + + // Unhandled memcpy/memmove. + return -1; +} + /// GetStoreValueForLoad - This function is called when we have a /// memdep query of a load that ends up being a clobbering store. This means @@ -1100,11 +1127,10 @@ // Shift the bits to the least significant depending on endianness. unsigned ShiftAmt; - if (TD.isLittleEndian()) { + if (TD.isLittleEndian()) ShiftAmt = Offset*8; - } else { + else ShiftAmt = (StoreSize-LoadSize-Offset)*8; - } if (ShiftAmt) SrcVal = BinaryOperator::CreateLShr(SrcVal, @@ -1117,6 +1143,52 @@ return CoerceAvailableValueToLoadType(SrcVal, LoadTy, InsertPt, TD); } +/// GetMemInstValueForLoad - This function is called when we have a +/// memdep query of a load that ends up being a clobbering mem intrinsic. +static Value *GetMemInstValueForLoad(MemIntrinsic *SrcInst, unsigned Offset, + const Type *LoadTy, Instruction *InsertPt, + const TargetData &TD){ + LLVMContext &Ctx = LoadTy->getContext(); + uint64_t LoadSize = TD.getTypeSizeInBits(LoadTy)/8; + + IRBuilder<> Builder(InsertPt->getParent(), InsertPt); + + // We know that this method is only called when the mem transfer fully + // provides the bits for the load. + if (MemSetInst *MSI = dyn_cast(SrcInst)) { + // memset(P, 'x', 1234) -> splat('x'), even if x is a variable, and + // independently of what the offset is. + Value *Val = MSI->getValue(); + if (LoadSize != 1) + Val = Builder.CreateZExt(Val, IntegerType::get(Ctx, LoadSize*8)); + + Value *OneElt = Val; + + // Splat the value out to the right number of bits. + for (unsigned NumBytesSet = 1; NumBytesSet != LoadSize; ) { + // If we can double the number of bytes set, do it. + if (NumBytesSet*2 <= LoadSize) { + Value *ShVal = Builder.CreateShl(Val, NumBytesSet*8); + Val = Builder.CreateOr(Val, ShVal); + NumBytesSet <<= 1; + continue; + } + + // Otherwise insert one byte at a time. + Value *ShVal = Builder.CreateShl(Val, 1*8); + Val = Builder.CreateOr(OneElt, ShVal); + ++NumBytesSet; + } + + return CoerceAvailableValueToLoadType(Val, LoadTy, InsertPt, TD); + } + + // ABORT; + return 0; +} + + + struct AvailableValueInBlock { /// BB - The basic block in question. BasicBlock *BB; @@ -1251,8 +1323,21 @@ } } } + +#if 0 + // If the clobbering value is a memset/memcpy/memmove, see if we can + // forward a value on from it. + if (MemIntrinsic *DepMI = dyn_cast(Dep.getInst())) { + if (TD == 0) + TD = getAnalysisIfAvailable(); + if (TD) { + int Offset = AnalyzeLoadFromClobberingMemInst(L, DepMI, *TD); + if (Offset != -1) + AvailVal = GetMemInstValueForLoad(DepMI, Offset, L->getType(), L,*TD); + } + } +#endif - // FIXME: Handle memset/memcpy. UnavailableBlocks.push_back(DepBB); continue; } @@ -1526,11 +1611,6 @@ // If the value isn't available, don't do anything! if (Dep.isClobber()) { - // FIXME: We should handle memset/memcpy/memmove as dependent instructions - // to forward the value if available. - //if (isa(Dep.getInst())) - //errs() << "LOAD DEPENDS ON MEM: " << *L << "\n" << *Dep.getInst()<<"\n\n"; - // Check to see if we have something like this: // store i32 123, i32* %P // %A = bitcast i32* %P to i8* @@ -1541,25 +1621,38 @@ // a common base + constant offset, and if the previous store (or memset) // completely covers this load. This sort of thing can happen in bitfield // access code. + Value *AvailVal = 0; if (StoreInst *DepSI = dyn_cast(Dep.getInst())) if (const TargetData *TD = getAnalysisIfAvailable()) { int Offset = AnalyzeLoadFromClobberingStore(L, DepSI, *TD); - if (Offset != -1) { - Value *AvailVal = GetStoreValueForLoad(DepSI->getOperand(0), Offset, - L->getType(), L, *TD); - DEBUG(errs() << "GVN COERCED STORE BITS:\n" << *DepSI << '\n' - << *AvailVal << '\n' << *L << "\n\n\n"); - - // Replace the load! - L->replaceAllUsesWith(AvailVal); - if (isa(AvailVal->getType())) - MD->invalidateCachedPointerInfo(AvailVal); - toErase.push_back(L); - NumGVNLoad++; - return true; - } + if (Offset != -1) + AvailVal = GetStoreValueForLoad(DepSI->getOperand(0), Offset, + L->getType(), L, *TD); } + // If the clobbering value is a memset/memcpy/memmove, see if we can forward + // a value on from it. + if (MemIntrinsic *DepMI = dyn_cast(Dep.getInst())) { + if (const TargetData *TD = getAnalysisIfAvailable()) { + int Offset = AnalyzeLoadFromClobberingMemInst(L, DepMI, *TD); + if (Offset != -1) + AvailVal = GetMemInstValueForLoad(DepMI, Offset, L->getType(), L,*TD); + } + } + + if (AvailVal) { + DEBUG(errs() << "GVN COERCED INST:\n" << *Dep.getInst() << '\n' + << *AvailVal << '\n' << *L << "\n\n\n"); + + // Replace the load! + L->replaceAllUsesWith(AvailVal); + if (isa(AvailVal->getType())) + MD->invalidateCachedPointerInfo(AvailVal); + toErase.push_back(L); + NumGVNLoad++; + return true; + } + DEBUG( // fast print dep, using operator<< on instruction would be too slow errs() << "GVN: load "; Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=90695&r1=90694&r2=90695&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Sat Dec 5 19:57:02 2009 @@ -131,6 +131,43 @@ ; CHECK: ret i8* } +; memset -> i16 forwarding. +define signext i16 @memset_to_i16_local(i16* %A) nounwind ssp { +entry: + %conv = bitcast i16* %A to i8* + tail call void @llvm.memset.i64(i8* %conv, i8 1, i64 200, i32 1) + %arrayidx = getelementptr inbounds i16* %A, i64 42 + %tmp2 = load i16* %arrayidx + ret i16 %tmp2 +; CHECK: @memset_to_i16_local +; CHECK-NOT: load +; CHECK: ret i16 257 +} + +; memset -> float forwarding. +define float @memset_to_float_local(float* %A, i8 %Val) nounwind ssp { +entry: + %conv = bitcast float* %A to i8* ; [#uses=1] + tail call void @llvm.memset.i64(i8* %conv, i8 %Val, i64 400, i32 1) + %arrayidx = getelementptr inbounds float* %A, i64 42 ; [#uses=1] + %tmp2 = load float* %arrayidx ; [#uses=1] + ret float %tmp2 +; CHECK: @memset_to_float_local +; CHECK-NOT: load +; CHECK: zext +; CHECK-NEXT: shl +; CHECK-NEXT: or +; CHECK-NEXT: shl +; CHECK-NEXT: or +; CHECK-NEXT: bitcast +; CHECK-NEXT: ret float +} + +declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind + + + + ;; non-local i32/float -> i8 load forwarding. define i8 @coerce_mustalias_nonlocal0(i32* %P, i1 %cond) { %P2 = bitcast i32* %P to float* From sabre at nondot.org Sat Dec 5 22:16:07 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 04:16:07 -0000 Subject: [llvm-commits] [llvm] r90696 - /llvm/trunk/test/Analysis/BasicAA/modref.ll Message-ID: <200912060416.nB64G7fE015194@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 22:16:05 2009 New Revision: 90696 URL: http://llvm.org/viewvc/llvm-project?rev=90696&view=rev Log: gvn is optimizing this better now. Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=90696&r1=90695&r2=90696&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Sat Dec 5 22:16:05 2009 @@ -60,8 +60,8 @@ call void @llvm.memset.i8(i8* %P, i8 2, i8 127, i32 0) %A = load i8* %P2 ret i8 %A -; CHECK: %A = load i8* %P2 -; CHECK: ret i8 %A +; CHECK-NOT: load +; CHECK: ret i8 2 } define void @test3(i8* %P, i8 %X) { From sabre at nondot.org Sat Dec 5 22:54:32 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 04:54:32 -0000 Subject: [llvm-commits] [llvm] r90697 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll Message-ID: <200912060454.nB64sWDn016360@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 22:54:31 2009 New Revision: 90697 URL: http://llvm.org/viewvc/llvm-project?rev=90697&view=rev Log: add support for forwarding mem intrinsic values to non-local loads. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90697&r1=90696&r2=90697&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Dec 5 22:54:31 2009 @@ -1192,19 +1192,47 @@ struct AvailableValueInBlock { /// BB - The basic block in question. BasicBlock *BB; + enum ValType { + SimpleVal, // A simple offsetted value that is accessed. + MemIntrin // A memory intrinsic which is loaded from. + }; + /// V - The value that is live out of the block. - Value *V; - /// Offset - The byte offset in V that is interesting for the load query. + PointerIntPair Val; + + /// Offset - The byte offset in Val that is interesting for the load query. unsigned Offset; static AvailableValueInBlock get(BasicBlock *BB, Value *V, unsigned Offset = 0) { AvailableValueInBlock Res; Res.BB = BB; - Res.V = V; + Res.Val.setPointer(V); + Res.Val.setInt(SimpleVal); + Res.Offset = Offset; + return Res; + } + + static AvailableValueInBlock getMI(BasicBlock *BB, MemIntrinsic *MI, + unsigned Offset = 0) { + AvailableValueInBlock Res; + Res.BB = BB; + Res.Val.setPointer(MI); + Res.Val.setInt(MemIntrin); Res.Offset = Offset; return Res; } + + bool isSimpleValue() const { return Val.getInt() == SimpleVal; } + Value *getSimpleValue() const { + assert(isSimpleValue() && "Wrong accessor"); + return Val.getPointer(); + } + + MemIntrinsic *getMemIntrinValue() const { + assert(!isSimpleValue() && "Wrong accessor"); + return cast(Val.getPointer()); + } }; /// ConstructSSAForLoadSet - Given a set of loads specified by ValuesPerBlock, @@ -1221,30 +1249,33 @@ const Type *LoadTy = LI->getType(); for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i) { - BasicBlock *BB = ValuesPerBlock[i].BB; - Value *AvailableVal = ValuesPerBlock[i].V; - unsigned Offset = ValuesPerBlock[i].Offset; + const AvailableValueInBlock &AV = ValuesPerBlock[i]; + BasicBlock *BB = AV.BB; if (SSAUpdate.HasValueForBlock(BB)) continue; - - if (AvailableVal->getType() != LoadTy) { - assert(TD && "Need target data to handle type mismatch case"); - AvailableVal = GetStoreValueForLoad(AvailableVal, Offset, LoadTy, - BB->getTerminator(), *TD); - - if (Offset) { - DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\n" - << *ValuesPerBlock[i].V << '\n' + + unsigned Offset = AV.Offset; + + Value *AvailableVal; + if (AV.isSimpleValue()) { + AvailableVal = AV.getSimpleValue(); + if (AvailableVal->getType() != LoadTy) { + assert(TD && "Need target data to handle type mismatch case"); + AvailableVal = GetStoreValueForLoad(AvailableVal, Offset, LoadTy, + BB->getTerminator(), *TD); + + DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " " + << *AV.getSimpleValue() << '\n' << *AvailableVal << '\n' << "\n\n\n"); } - - - DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\n" - << *ValuesPerBlock[i].V << '\n' + } else { + AvailableVal = GetMemInstValueForLoad(AV.getMemIntrinValue(), Offset, + LoadTy, BB->getTerminator(), *TD); + DEBUG(errs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset + << " " << *AV.getMemIntrinValue() << '\n' << *AvailableVal << '\n' << "\n\n\n"); } - SSAUpdate.AddAvailableValue(BB, AvailableVal); } @@ -1324,19 +1355,20 @@ } } -#if 0 // If the clobbering value is a memset/memcpy/memmove, see if we can // forward a value on from it. - if (MemIntrinsic *DepMI = dyn_cast(Dep.getInst())) { + if (MemIntrinsic *DepMI = dyn_cast(DepInfo.getInst())) { if (TD == 0) TD = getAnalysisIfAvailable(); if (TD) { - int Offset = AnalyzeLoadFromClobberingMemInst(L, DepMI, *TD); - if (Offset != -1) - AvailVal = GetMemInstValueForLoad(DepMI, Offset, L->getType(), L,*TD); + int Offset = AnalyzeLoadFromClobberingMemInst(LI, DepMI, *TD); + if (Offset != -1) { + ValuesPerBlock.push_back(AvailableValueInBlock::getMI(DepBB, DepMI, + Offset)); + continue; + } } } -#endif UnavailableBlocks.push_back(DepBB); continue; @@ -1462,19 +1494,25 @@ // to eliminate LI even if we insert uses in the other predecessors, we will // end up increasing code size. Reject this by scanning for LI. for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i) - if (ValuesPerBlock[i].V == LI) + if (ValuesPerBlock[i].isSimpleValue() && + ValuesPerBlock[i].getSimpleValue() == LI) return false; + // FIXME: It is extremely unclear what this loop is doing, other than + // artificially restricting loadpre. if (isSinglePred) { bool isHot = false; - for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i) - if (Instruction *I = dyn_cast(ValuesPerBlock[i].V)) + for (unsigned i = 0, e = ValuesPerBlock.size(); i != e; ++i) { + const AvailableValueInBlock &AV = ValuesPerBlock[i]; + if (AV.isSimpleValue()) // "Hot" Instruction is in some loop (because it dominates its dep. // instruction). - if (DT->dominates(LI, I)) { - isHot = true; - break; - } + if (Instruction *I = dyn_cast(AV.getSimpleValue())) + if (DT->dominates(LI, I)) { + isHot = true; + break; + } + } // We are interested only in "hot" instructions. We don't want to do any // mis-optimizations here. Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=90697&r1=90696&r2=90697&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Sat Dec 5 22:54:31 2009 @@ -163,6 +163,31 @@ ; CHECK-NEXT: ret float } +;; non-local memset -> i16 load forwarding. +define i16 @memset_to_i16_nonlocal0(i16* %P, i1 %cond) { + %P3 = bitcast i16* %P to i8* + br i1 %cond, label %T, label %F +T: + tail call void @llvm.memset.i64(i8* %P3, i8 1, i64 400, i32 1) + br label %Cont + +F: + tail call void @llvm.memset.i64(i8* %P3, i8 2, i64 400, i32 1) + br label %Cont + +Cont: + %P2 = getelementptr i16* %P, i32 4 + %A = load i16* %P2 + ret i16 %A + +; CHECK: @memset_to_i16_nonlocal0 +; CHECK: Cont: +; CHECK-NEXT: %A = phi i16 [ 514, %F ], [ 257, %T ] +; CHECK-NOT: load +; CHECK: ret i16 %A +} + + declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind @@ -192,6 +217,7 @@ ; CHECK: ret i8 %A } + ;; non-local i32/float -> i8 load forwarding. This also tests that the "P3" ;; bitcast equivalence can be properly phi translated. define i8 @coerce_mustalias_nonlocal1(i32* %P, i1 %cond) { From sabre at nondot.org Sat Dec 5 23:29:56 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 05:29:56 -0000 Subject: [llvm-commits] [llvm] r90698 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll Message-ID: <200912060529.nB65TuUs017567@zion.cs.uiuc.edu> Author: lattner Date: Sat Dec 5 23:29:56 2009 New Revision: 90698 URL: http://llvm.org/viewvc/llvm-project?rev=90698&view=rev Log: constant fold loads from memcpy's from global constants. This is important because clang lowers nontrivial automatic struct/array inits to memcpy from a global array. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90698&r1=90697&r2=90698&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sat Dec 5 23:29:56 2009 @@ -31,8 +31,9 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/Analysis/ConstantFolding.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/MemoryDependenceAnalysis.h" #include "llvm/Support/CFG.h" @@ -1094,11 +1095,39 @@ ConstantInt *SizeCst = dyn_cast(MI->getLength()); if (SizeCst == 0) return -1; uint64_t MemSizeInBits = SizeCst->getZExtValue()*8; - + + // If this is memset, we just need to see if the offset is valid in the size + // of the memset.. if (MI->getIntrinsicID() == Intrinsic::memset) return AnalyzeLoadFromClobberingWrite(L, MI->getDest(), MemSizeInBits, TD); - // Unhandled memcpy/memmove. + // If we have a memcpy/memmove, the only case we can handle is if this is a + // copy from constant memory. In that case, we can read directly from the + // constant memory. + MemTransferInst *MTI = cast(MI); + + Constant *Src = dyn_cast(MTI->getSource()); + if (Src == 0) return -1; + + GlobalVariable *GV = dyn_cast(Src->getUnderlyingObject()); + if (GV == 0 || !GV->isConstant()) return -1; + + // See if the access is within the bounds of the transfer. + int Offset = + AnalyzeLoadFromClobberingWrite(L, MI->getDest(), MemSizeInBits, TD); + if (Offset == -1) + return Offset; + + // Otherwise, see if we can constant fold a load from the constant with the + // offset applied as appropriate. + Src = ConstantExpr::getBitCast(Src, + llvm::Type::getInt8PtrTy(Src->getContext())); + Constant *OffsetCst = + ConstantInt::get(Type::getInt64Ty(Src->getContext()), (unsigned)Offset); + Src = ConstantExpr::getGetElementPtr(Src, &OffsetCst, 1); + Src = ConstantExpr::getBitCast(Src, PointerType::getUnqual(L->getType())); + if (ConstantFoldLoadFromConstPtr(Src, &TD)) + return Offset; return -1; } @@ -1182,9 +1211,20 @@ return CoerceAvailableValueToLoadType(Val, LoadTy, InsertPt, TD); } - - // ABORT; - return 0; + + // Otherwise, this is a memcpy/memmove from a constant global. + MemTransferInst *MTI = cast(SrcInst); + Constant *Src = cast(MTI->getSource()); + + // Otherwise, see if we can constant fold a load from the constant with the + // offset applied as appropriate. + Src = ConstantExpr::getBitCast(Src, + llvm::Type::getInt8PtrTy(Src->getContext())); + Constant *OffsetCst = + ConstantInt::get(Type::getInt64Ty(Src->getContext()), (unsigned)Offset); + Src = ConstantExpr::getGetElementPtr(Src, &OffsetCst, 1); + Src = ConstantExpr::getBitCast(Src, PointerType::getUnqual(LoadTy)); + return ConstantFoldLoadFromConstPtr(Src, &TD); } Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=90698&r1=90697&r2=90698&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Sat Dec 5 23:29:56 2009 @@ -187,8 +187,24 @@ ; CHECK: ret i16 %A } + at GCst = constant {i32, float, i32 } { i32 42, float 14., i32 97 } + +; memset -> float forwarding. +define float @memcpy_to_float_local(float* %A) nounwind ssp { +entry: + %conv = bitcast float* %A to i8* ; [#uses=1] + tail call void @llvm.memcpy.i64(i8* %conv, i8* bitcast ({i32, float, i32 }* @GCst to i8*), i64 12, i32 1) + %arrayidx = getelementptr inbounds float* %A, i64 1 ; [#uses=1] + %tmp2 = load float* %arrayidx ; [#uses=1] + ret float %tmp2 +; CHECK: @memcpy_to_float_local +; CHECK-NOT: load +; CHECK: ret float 1.400000e+01 +} + declare void @llvm.memset.i64(i8* nocapture, i8, i64, i32) nounwind +declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind From baldrick at free.fr Sun Dec 6 02:35:54 2009 From: baldrick at free.fr (Duncan Sands) Date: Sun, 06 Dec 2009 09:35:54 +0100 Subject: [llvm-commits] [PATCH] New external2availableexternally pass (issue166075) In-Reply-To: <00163691fbf3bc89a9047a032500@google.com> References: <00163691fbf3bc89a9047a032500@google.com> Message-ID: <4B1B6CEA.9060306@free.fr> Hi, > When we have a runtime library, it's useful to expose that library to > the optimizers, but it's bad to ask LLVM to actually codegen the > library's code a second time. I didn't look at the code, but it sounds like it gives functions available_externally linkage. Why not have the front-end output the functions with available_externally linkage in the first place? Ciao, Duncan. From jyasskin at gmail.com Sun Dec 6 04:32:06 2009 From: jyasskin at gmail.com (Jeffrey Yasskin) Date: Sun, 6 Dec 2009 02:32:06 -0800 Subject: [llvm-commits] [PATCH] New external2availableexternally pass (issue166075) In-Reply-To: <4B1B6CEA.9060306@free.fr> References: <00163691fbf3bc89a9047a032500@google.com> <4B1B6CEA.9060306@free.fr> Message-ID: <5d44f72f0912060232k217b3cej98aeb29280bf0bc4@mail.gmail.com> On Sun, Dec 6, 2009 at 12:35 AM, Duncan Sands wrote: > Hi, > >> When we have a runtime library, it's useful to expose that library to >> the optimizers, but it's bad to ask LLVM to actually codegen the >> library's code a second time. > > I didn't look at the code, but it sounds like it gives functions > available_externally linkage. Yes. >?Why not have the front-end output > the functions with available_externally linkage in the first place? 1. I knew how to write this pass; modifying clang would have required learning more. 2. It seems useful to be able to compile the runtime library to .bc with external functions, codegen the .o from that for the real runtime library, and then convert it to the available_externally form for use by application optimizers and JITs. A front-end flag would require compiling from C twice. 3. dgregor endorsed the idea of this patch, although I didn't mention the possibility of a clang flag. But let me know if an extra clang flag would be preferable. I'll probably wind up writing a standalone tool for Unladen instead of shaving that yak, but I wouldn't object strongly to dropping this patch. From anton at korobeynikov.info Sun Dec 6 06:05:29 2009 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sun, 6 Dec 2009 15:05:29 +0300 Subject: [llvm-commits] [patch] Change the alignment in the X86.Windows subtarget In-Reply-To: <20091206012255.145970@gmx.net> References: <20091206012255.145970@gmx.net> Message-ID: Hello, Michael > the following patch changes the data-alignment of the 32bit Windows subtarget to values used by the MSVC compiler. > I assume this is the right subtarget for MSVC builds, as isCygwin and isMingw exists and at least cmake build have it ... Could you please point me to some document defining these settings? Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From sabre at nondot.org Sun Dec 6 10:58:42 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 16:58:42 -0000 Subject: [llvm-commits] [llvm] r90707 - /llvm/trunk/include/llvm/ADT/DenseSet.h Message-ID: <200912061658.nB6GwgZB011510@zion.cs.uiuc.edu> Author: lattner Date: Sun Dec 6 10:58:41 2009 New Revision: 90707 URL: http://llvm.org/viewvc/llvm-project?rev=90707&view=rev Log: remove extraneous comma clang warns about Modified: llvm/trunk/include/llvm/ADT/DenseSet.h Modified: llvm/trunk/include/llvm/ADT/DenseSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=90707&r1=90706&r2=90707&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseSet.h (original) +++ llvm/trunk/include/llvm/ADT/DenseSet.h Sun Dec 6 10:58:41 2009 @@ -60,7 +60,7 @@ ValueT& operator*() { return I->first; } ValueT* operator->() { return &I->first; } - Iterator& operator++() { ++I; return *this; }; + Iterator& operator++() { ++I; return *this; } bool operator==(const Iterator& X) const { return I == X.I; } bool operator!=(const Iterator& X) const { return I != X.I; } }; From sabre at nondot.org Sun Dec 6 11:17:23 2009 From: sabre at nondot.org (Chris Lattner) Date: Sun, 06 Dec 2009 17:17:23 -0000 Subject: [llvm-commits] [llvm] r90708 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll Message-ID: <200912061717.nB6HHNwF012057@zion.cs.uiuc.edu> Author: lattner Date: Sun Dec 6 11:17:23 2009 New Revision: 90708 URL: http://llvm.org/viewvc/llvm-project?rev=90708&view=rev Log: fix PR5698 Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp llvm/trunk/test/Transforms/JumpThreading/crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=90708&r1=90707&r2=90708&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sun Dec 6 11:17:23 2009 @@ -718,6 +718,11 @@ 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. Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=90708&r1=90707&r2=90708&view=diff ============================================================================== --- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original) +++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Sun Dec 6 11:17:23 2009 @@ -212,3 +212,25 @@ bb61: ret void } + + +; PR5698 +define void @test7(i32 %x) { +tailrecurse: + switch i32 %x, label %return [ + i32 2, label %bb2 + i32 3, label %bb + ] + +bb: + switch i32 %x, label %return [ + i32 2, label %bb2 + i32 3, label %tailrecurse + ] + +bb2: + ret void + +return: + ret void +} From John.Tytgat at aaug.net Sun Dec 6 12:01:45 2009 From: John.Tytgat at aaug.net (John Tytgat) Date: Sun, 06 Dec 2009 19:01:45 +0100 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in Message-ID: <1260122505.12622.8.camel@zoef> Hi, Aren't there a couple of typos here ? > [...] > Index: Makefile.config.in > =================================================================== > --- Makefile.config.in (revision 86954) > +++ Makefile.config.in (revision 86955) > @@ -313,6 +313,8 @@ > # Location of the plugin header file for gold. > BINUTILS_INCDIR := @BINUTILS_INCDIR@ > > +C_INCLUDE_DIRS := @C_INCLUDE_DISR@ ^^^^ ?? > [...] > Index: autoconf/configure.ac > =================================================================== > --- autoconf/configure.ac (revision 86954) > +++ autoconf/configure.ac (revision 86955) > @@ -667,6 +667,13 @@ > *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;; > esac > > +AC_ARG_WITH(c-include-dir, ^^^^ ?? "AC_ARG_WITH(c-include-dirs", no ? > + AS_HELP_STRING([--with-c-include-dirs], > + [Colon separated list of directories clang will search for headers]),, > + withval="") > +AC_DEFINE_UNQUOTED(C_INCLUDE_DIRS,"$withval", > + [Directories clang will search for headers]) > + John. From asl at math.spbu.ru Sun Dec 6 16:39:50 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Sun, 06 Dec 2009 22:39:50 -0000 Subject: [llvm-commits] [llvm] r90724 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp test/CodeGen/Thumb2/large-stack.ll test/CodeGen/Thumb2/thumb2-spill-q.ll Message-ID: <200912062239.nB6MdpFA023485@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 16:39:50 2009 New Revision: 90724 URL: http://llvm.org/viewvc/llvm-project?rev=90724&view=rev Log: Dynamic stack realignment use of sp register as source/dest register in "bic sp, sp, #15" leads to unpredicatble behaviour in Thumb2 mode. Emit the following code instead: mov r4, sp bic r4, r4, #15 mov sp, r4 Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/test/CodeGen/Thumb2/large-stack.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-spill-q.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=90724&r1=90723&r2=90724&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Sun Dec 6 16:39:50 2009 @@ -578,6 +578,13 @@ MFI->calculateMaxStackAlignment(); } + // Spill R4 if Thumb2 function requires stack realignment - it will be used as + // scratch register. + // FIXME: It will be better just to find spare register here. + if (needsStackRealignment(MF) && + AFI->isThumb2Function()) + MF.getRegInfo().setPhysRegUsed(ARM::R4); + // Don't spill FP if the frame can be eliminated. This is determined // by scanning the callee-save registers to see if any is used. const unsigned *CSRegs = getCalleeSavedRegs(); @@ -1351,14 +1358,30 @@ // If we need dynamic stack realignment, do it here. if (needsStackRealignment(MF)) { - unsigned Opc; unsigned MaxAlign = MFI->getMaxAlignment(); assert (!AFI->isThumb1OnlyFunction()); - Opc = AFI->isThumbFunction() ? ARM::t2BICri : ARM::BICri; - - AddDefaultCC(AddDefaultPred(BuildMI(MBB, MBBI, dl, TII.get(Opc), ARM::SP) + if (!AFI->isThumbFunction()) { + // Emit bic sp, sp, MaxAlign + AddDefaultCC(AddDefaultPred(BuildMI(MBB, MBBI, dl, + TII.get(ARM::BICri), ARM::SP) .addReg(ARM::SP, RegState::Kill) .addImm(MaxAlign-1))); + } else { + // We cannot use sp as source/dest register here, thus we're emitting the + // following sequence: + // mov r4, sp + // bic r4, r4, MaxAlign + // mov sp, r4 + // FIXME: It will be better just to find spare register here. + BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVtgpr2gpr), ARM::R4) + .addReg(ARM::SP, RegState::Kill); + AddDefaultCC(AddDefaultPred(BuildMI(MBB, MBBI, dl, + TII.get(ARM::t2BICri), ARM::R4) + .addReg(ARM::R4, RegState::Kill) + .addImm(MaxAlign-1))); + BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVtgpr2gpr), ARM::SP) + .addReg(ARM::R4, RegState::Kill); + } } } Modified: llvm/trunk/test/CodeGen/Thumb2/large-stack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/large-stack.ll?rev=90724&r1=90723&r2=90724&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/large-stack.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/large-stack.ll Sun Dec 6 16:39:50 2009 @@ -18,7 +18,7 @@ define i32 @test3() { ; CHECK: test3: ; CHECK: sub.w sp, sp, #805306368 -; CHECK: sub sp, #24 +; CHECK: sub sp, #20 %retval = alloca i32, align 4 %tmp = alloca i32, align 4 %a = alloca [805306369 x i8], align 16 Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-spill-q.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-spill-q.ll?rev=90724&r1=90723&r2=90724&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-spill-q.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-spill-q.ll Sun Dec 6 16:39:50 2009 @@ -11,7 +11,7 @@ define arm_apcscc void @aaa(%quuz* %this, i8* %block) { ; CHECK: aaa: -; CHECK: bic sp, sp, #15 +; CHECK: bic r4, r4, #15 ; CHECK: vst1.64 {{.*}}sp, :128 ; CHECK: vld1.64 {{.*}}sp, :128 entry: From rafael.espindola at gmail.com Sun Dec 6 18:27:35 2009 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 07 Dec 2009 00:27:35 -0000 Subject: [llvm-commits] [llvm] r90728 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure Message-ID: <200912070027.nB70RaVr027000@zion.cs.uiuc.edu> Author: rafael Date: Sun Dec 6 18:27:35 2009 New Revision: 90728 URL: http://llvm.org/viewvc/llvm-project?rev=90728&view=rev Log: Fix typos. Thanks to John Tytgat for noticing it! Modified: llvm/trunk/Makefile.config.in llvm/trunk/autoconf/configure.ac llvm/trunk/configure Modified: llvm/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.config.in?rev=90728&r1=90727&r2=90728&view=diff ============================================================================== --- llvm/trunk/Makefile.config.in (original) +++ llvm/trunk/Makefile.config.in Sun Dec 6 18:27:35 2009 @@ -313,7 +313,7 @@ # Location of the plugin header file for gold. BINUTILS_INCDIR := @BINUTILS_INCDIR@ -C_INCLUDE_DIRS := @C_INCLUDE_DISR@ +C_INCLUDE_DIRS := @C_INCLUDE_DIRS@ CXX_INCLUDE_ROOT := @CXX_INCLUDE_ROOT@ CXX_INCLUDE_ARCH := @CXX_INCLUDE_ARCH@ CXX_INCLUDE_32BIT_DIR = @CXX_INCLUDE_32BIT_DIR@ Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=90728&r1=90727&r2=90728&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Sun Dec 6 18:27:35 2009 @@ -672,7 +672,7 @@ *) AC_MSG_ERROR([Invalid path for --with-ocaml-libdir. Provide full path]) ;; esac -AC_ARG_WITH(c-include-dir, +AC_ARG_WITH(c-include-dirs, AS_HELP_STRING([--with-c-include-dirs], [Colon separated list of directories clang will search for headers]),, withval="") Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=90728&r1=90727&r2=90728&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Sun Dec 6 18:27:35 2009 @@ -5286,9 +5286,9 @@ esac -# Check whether --with-c-include-dir was given. -if test "${with_c_include_dir+set}" = set; then - withval=$with_c_include_dir; +# Check whether --with-c-include-dirs was given. +if test "${with_c_include_dirs+set}" = set; then + withval=$with_c_include_dirs; else withval="" fi From rafael.espindola at gmail.com Sun Dec 6 18:40:08 2009 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Sun, 6 Dec 2009 19:40:08 -0500 Subject: [llvm-commits] [llvm] r86955 - in /llvm/trunk: Makefile.config.in autoconf/configure.ac configure include/llvm/Config/config.h.in In-Reply-To: <1260122505.12622.8.camel@zoef> References: <1260122505.12622.8.camel@zoef> Message-ID: <564d96fb0912061640y79d9ce6dh1f82461862c13456@mail.gmail.com> On Sun, Dec 6, 2009 at 1:01 PM, John Tytgat wrote: > Hi, > > Aren't there a couple of typos here ? Yes. Fixes on 90728. Thanks! I tested it with ../llvm/configure --with-c-include-dirs=/foo:/bar --with-cxx-include-root=/root --with-cxx-include-arch=arch --with-cxx-include-32bit-dir=32 --with-cxx-include-64bit-dir=64 > John. Cheers, Rafael From asl at math.spbu.ru Sun Dec 6 20:27:08 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:27:08 -0000 Subject: [llvm-commits] [llvm] r90737 - /llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Message-ID: <200912070227.nB72R87n030983@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:27:08 2009 New Revision: 90737 URL: http://llvm.org/viewvc/llvm-project?rev=90737&view=rev Log: Add ability to select hw multiplier mode and select appropriate libcalls. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=90737&r1=90736&r2=90737&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sun Dec 6 20:27:08 2009 @@ -32,12 +32,32 @@ #include "llvm/CodeGen/SelectionDAGISel.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/VectorExtras.h" using namespace llvm; +typedef enum { + NoHWMult, + HWMultIntr, + HWMultNoIntr +} HWMultUseMode; + +static cl::opt +HWMultMode("msp430-hwmult-mode", + cl::desc("Hardware multiplier use mode"), + cl::init(HWMultNoIntr), + cl::values( + clEnumValN(NoHWMult, "no", + "Do not use hardware multiplier"), + clEnumValN(HWMultIntr, "interrupts", + "Assume hardware multiplier can be used inside interrupts"), + clEnumValN(HWMultNoIntr, "use", + "Assume hardware multiplier cannot be used inside interrupts"), + clEnumValEnd)); + MSP430TargetLowering::MSP430TargetLowering(MSP430TargetMachine &tm) : TargetLowering(tm, new TargetLoweringObjectFileELF()), Subtarget(*tm.getSubtargetImpl()), TM(tm) { @@ -142,6 +162,15 @@ setOperationAction(ISD::SDIV, MVT::i16, Expand); setOperationAction(ISD::SDIVREM, MVT::i16, Expand); setOperationAction(ISD::SREM, MVT::i16, Expand); + + // Libcalls names. + if (HWMultMode == HWMultIntr) { + setLibcallName(RTLIB::MUL_I8, "__mulqi3hw"); + setLibcallName(RTLIB::MUL_I16, "__mulhi3hw"); + } else if (HWMultMode == HWMultNoIntr) { + setLibcallName(RTLIB::MUL_I8, "__mulqi3hw_noint"); + setLibcallName(RTLIB::MUL_I16, "__mulhi3hw_noint"); + } } SDValue MSP430TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) { From asl at math.spbu.ru Sun Dec 6 20:27:35 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:27:35 -0000 Subject: [llvm-commits] [llvm] r90738 - in /llvm/trunk: include/llvm/CallingConv.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/VMCore/AsmWriter.cpp Message-ID: <200912070227.nB72RZ7l031008@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:27:35 2009 New Revision: 90738 URL: http://llvm.org/viewvc/llvm-project?rev=90738&view=rev Log: Add MSP430 interrupt calling conv. No functionality change yet. Modified: llvm/trunk/include/llvm/CallingConv.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/include/llvm/CallingConv.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallingConv.h?rev=90738&r1=90737&r2=90738&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallingConv.h (original) +++ llvm/trunk/include/llvm/CallingConv.h Sun Dec 6 20:27:35 2009 @@ -68,7 +68,10 @@ ARM_AAPCS = 67, /// ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI. - ARM_AAPCS_VFP = 68 + ARM_AAPCS_VFP = 68, + + /// MSP430_INTR - Calling convention used for MSP430 interrupt routines. + MSP430_INTR = 69 }; } // End CallingConv namespace Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=90738&r1=90737&r2=90738&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Sun Dec 6 20:27:35 2009 @@ -540,6 +540,7 @@ KEYWORD(arm_apcscc); KEYWORD(arm_aapcscc); KEYWORD(arm_aapcs_vfpcc); + KEYWORD(msp430_intrcc); KEYWORD(cc); KEYWORD(c); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=90738&r1=90737&r2=90738&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Sun Dec 6 20:27:35 2009 @@ -1074,6 +1074,7 @@ /// ::= 'arm_apcscc' /// ::= 'arm_aapcscc' /// ::= 'arm_aapcs_vfpcc' +/// ::= 'msp430_intrcc' /// ::= 'cc' UINT /// bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) { @@ -1087,6 +1088,7 @@ case lltok::kw_arm_apcscc: CC = CallingConv::ARM_APCS; break; case lltok::kw_arm_aapcscc: CC = CallingConv::ARM_AAPCS; break; case lltok::kw_arm_aapcs_vfpcc:CC = CallingConv::ARM_AAPCS_VFP; break; + case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break; case lltok::kw_cc: { unsigned ArbitraryCC; Lex.Lex(); Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=90738&r1=90737&r2=90738&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Sun Dec 6 20:27:35 2009 @@ -69,6 +69,7 @@ kw_cc, kw_ccc, kw_fastcc, kw_coldcc, kw_x86_stdcallcc, kw_x86_fastcallcc, kw_arm_apcscc, kw_arm_aapcscc, kw_arm_aapcs_vfpcc, + kw_msp430_intrcc, kw_signext, kw_zeroext, Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=90738&r1=90737&r2=90738&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Sun Dec 6 20:27:35 2009 @@ -1660,6 +1660,7 @@ case CallingConv::ARM_APCS: Out << "arm_apcscc "; break; case CallingConv::ARM_AAPCS: Out << "arm_aapcscc "; break; case CallingConv::ARM_AAPCS_VFP:Out << "arm_aapcs_vfpcc "; break; + case CallingConv::MSP430_INTR: Out << "msp430_intrcc "; break; default: Out << "cc" << F->getCallingConv() << " "; break; } @@ -1927,6 +1928,7 @@ case CallingConv::ARM_APCS: Out << " arm_apcscc "; break; case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break; case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break; + case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; default: Out << " cc" << CI->getCallingConv(); break; } @@ -1977,6 +1979,7 @@ case CallingConv::ARM_APCS: Out << " arm_apcscc "; break; case CallingConv::ARM_AAPCS: Out << " arm_aapcscc "; break; case CallingConv::ARM_AAPCS_VFP:Out << " arm_aapcs_vfpcc "; break; + case CallingConv::MSP430_INTR: Out << " msp430_intrcc "; break; default: Out << " cc" << II->getCallingConv(); break; } From asl at math.spbu.ru Sun Dec 6 20:27:53 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:27:53 -0000 Subject: [llvm-commits] [llvm] r90739 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430ISelLowering.h MSP430InstrInfo.td MSP430RegisterInfo.cpp Message-ID: <200912070227.nB72RrVH031029@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:27:53 2009 New Revision: 90739 URL: http://llvm.org/viewvc/llvm-project?rev=90739&view=rev Log: Initial codegen support for MSP430 ISRs Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=90739&r1=90738&r2=90739&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sun Dec 6 20:27:53 2009 @@ -254,6 +254,13 @@ case CallingConv::C: case CallingConv::Fast: return LowerCCCArguments(Chain, CallConv, isVarArg, Ins, dl, DAG, InVals); + case CallingConv::MSP430_INTR: + if (Ins.empty()) + return Chain; + else { + llvm_report_error("ISRs cannot have arguments"); + return SDValue(); + } } } @@ -273,6 +280,9 @@ case CallingConv::C: return LowerCCCCallTo(Chain, Callee, CallConv, isVarArg, isTailCall, Outs, Ins, dl, DAG, InVals); + case CallingConv::MSP430_INTR: + llvm_report_error("ISRs cannot be called directly"); + return SDValue(); } } @@ -369,6 +379,12 @@ // CCValAssign - represent the assignment of the return value to a location SmallVector RVLocs; + // ISRs cannot return any value. + if (CallConv == CallingConv::MSP430_INTR && !Outs.empty()) { + llvm_report_error("ISRs cannot return any value"); + return SDValue(); + } + // CCState - Info about the registers and stack slot. CCState CCInfo(CallConv, isVarArg, getTargetMachine(), RVLocs, *DAG.getContext()); @@ -399,11 +415,14 @@ Flag = Chain.getValue(1); } + unsigned Opc = (CallConv == CallingConv::MSP430_INTR ? + MSP430ISD::RETI_FLAG : MSP430ISD::RET_FLAG); + if (Flag.getNode()) - return DAG.getNode(MSP430ISD::RET_FLAG, dl, MVT::Other, Chain, Flag); + return DAG.getNode(Opc, dl, MVT::Other, Chain, Flag); // Return Void - return DAG.getNode(MSP430ISD::RET_FLAG, dl, MVT::Other, Chain); + return DAG.getNode(Opc, dl, MVT::Other, Chain); } /// LowerCCCCallTo - functions arguments are copied from virtual regs to Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h?rev=90739&r1=90738&r2=90739&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h Sun Dec 6 20:27:53 2009 @@ -27,6 +27,9 @@ /// Return with a flag operand. Operand 0 is the chain operand. RET_FLAG, + /// Same as RET_FLAG, but used for returning from ISRs. + RETI_FLAG, + /// Y = R{R,L}A X, rotate right (left) arithmetically RRA, RLA, Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td?rev=90739&r1=90738&r2=90739&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.td Sun Dec 6 20:27:53 2009 @@ -35,8 +35,10 @@ //===----------------------------------------------------------------------===// // MSP430 Specific Node Definitions. //===----------------------------------------------------------------------===// -def MSP430retflag : SDNode<"MSP430ISD::RET_FLAG", SDTNone, - [SDNPHasChain, SDNPOptInFlag]>; +def MSP430retflag : SDNode<"MSP430ISD::RET_FLAG", SDTNone, + [SDNPHasChain, SDNPOptInFlag]>; +def MSP430retiflag : SDNode<"MSP430ISD::RETI_FLAG", SDTNone, + [SDNPHasChain, SDNPOptInFlag]>; def MSP430rra : SDNode<"MSP430ISD::RRA", SDTIntUnaryOp, []>; def MSP430rla : SDNode<"MSP430ISD::RLA", SDTIntUnaryOp, []>; @@ -128,7 +130,8 @@ // FIXME: Provide proper encoding! let isReturn = 1, isTerminator = 1, isBarrier = 1 in { - def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>; + def RET : Pseudo<(outs), (ins), "ret", [(MSP430retflag)]>; + def RETI : Pseudo<(outs), (ins), "reti", [(MSP430retiflag)]>; } let isBranch = 1, isTerminator = 1 in { Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp?rev=90739&r1=90738&r2=90739&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.cpp Sun Dec 6 20:27:53 2009 @@ -17,6 +17,7 @@ #include "MSP430MachineFunctionInfo.h" #include "MSP430RegisterInfo.h" #include "MSP430TargetMachine.h" +#include "llvm/Function.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -37,17 +38,26 @@ const unsigned* MSP430RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const { + const Function* F = MF->getFunction(); static const unsigned CalleeSavedRegs[] = { MSP430::FPW, MSP430::R5W, MSP430::R6W, MSP430::R7W, MSP430::R8W, MSP430::R9W, MSP430::R10W, MSP430::R11W, 0 }; + static const unsigned CalleeSavedRegsIntr[] = { + MSP430::FPW, MSP430::R5W, MSP430::R6W, MSP430::R7W, + MSP430::R8W, MSP430::R9W, MSP430::R10W, MSP430::R11W, + MSP430::R12W, MSP430::R13W, MSP430::R14W, MSP430::R15W, + 0 + }; - return CalleeSavedRegs; + return (F->getCallingConv() == CallingConv::MSP430_INTR ? + CalleeSavedRegsIntr : CalleeSavedRegs); } const TargetRegisterClass *const * MSP430RegisterInfo::getCalleeSavedRegClasses(const MachineFunction *MF) const { + const Function* F = MF->getFunction(); static const TargetRegisterClass * const CalleeSavedRegClasses[] = { &MSP430::GR16RegClass, &MSP430::GR16RegClass, &MSP430::GR16RegClass, &MSP430::GR16RegClass, @@ -55,8 +65,18 @@ &MSP430::GR16RegClass, &MSP430::GR16RegClass, 0 }; + static const TargetRegisterClass * const CalleeSavedRegClassesIntr[] = { + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + &MSP430::GR16RegClass, &MSP430::GR16RegClass, + 0 + }; - return CalleeSavedRegClasses; + return (F->getCallingConv() == CallingConv::MSP430_INTR ? + CalleeSavedRegClassesIntr : CalleeSavedRegClasses); } BitVector MSP430RegisterInfo::getReservedRegs(const MachineFunction &MF) const { @@ -292,7 +312,8 @@ DebugLoc DL = MBBI->getDebugLoc(); switch (RetOpcode) { - case MSP430::RET: break; // These are ok + case MSP430::RET: + case MSP430::RETI: break; // These are ok default: llvm_unreachable("Can only insert epilog into returning blocks"); } From asl at math.spbu.ru Sun Dec 6 20:28:11 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:28:11 -0000 Subject: [llvm-commits] [llvm] r90740 - in /llvm/trunk/lib/Target/MSP430: MSP430ISelLowering.cpp MSP430ISelLowering.h MSP430MachineFunctionInfo.h Message-ID: <200912070228.nB72SB9J031055@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:28:10 2009 New Revision: 90740 URL: http://llvm.org/viewvc/llvm-project?rev=90740&view=rev Log: Add lowering of returnaddr and frameaddr intrinsics. Shamelessly stolen from x86 :) Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h llvm/trunk/lib/Target/MSP430/MSP430MachineFunctionInfo.h Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=90740&r1=90739&r2=90740&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sun Dec 6 20:28:10 2009 @@ -15,6 +15,7 @@ #include "MSP430ISelLowering.h" #include "MSP430.h" +#include "MSP430MachineFunctionInfo.h" #include "MSP430TargetMachine.h" #include "MSP430Subtarget.h" #include "llvm/DerivedTypes.h" @@ -62,6 +63,8 @@ TargetLowering(tm, new TargetLoweringObjectFileELF()), Subtarget(*tm.getSubtargetImpl()), TM(tm) { + TD = getTargetData(); + // Set up the register classes. addRegisterClass(MVT::i8, MSP430::GR8RegisterClass); addRegisterClass(MVT::i16, MSP430::GR16RegisterClass); @@ -183,6 +186,8 @@ case ISD::BR_CC: return LowerBR_CC(Op, DAG); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); case ISD::SIGN_EXTEND: return LowerSIGN_EXTEND(Op, DAG); + case ISD::RETURNADDR: return LowerRETURNADDR(Op, DAG); + case ISD::FRAMEADDR: return LowerFRAMEADDR(Op, DAG); default: llvm_unreachable("unimplemented operand"); return SDValue(); @@ -730,6 +735,55 @@ DAG.getValueType(Val.getValueType())); } +SDValue MSP430TargetLowering::getReturnAddressFrameIndex(SelectionDAG &DAG) { + MachineFunction &MF = DAG.getMachineFunction(); + MSP430MachineFunctionInfo *FuncInfo = MF.getInfo(); + int ReturnAddrIndex = FuncInfo->getRAIndex(); + + if (ReturnAddrIndex == 0) { + // Set up a frame object for the return address. + uint64_t SlotSize = TD->getPointerSize(); + ReturnAddrIndex = MF.getFrameInfo()->CreateFixedObject(SlotSize, -SlotSize, + true, false); + FuncInfo->setRAIndex(ReturnAddrIndex); + } + + return DAG.getFrameIndex(ReturnAddrIndex, getPointerTy()); +} + +SDValue MSP430TargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) { + unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); + DebugLoc dl = Op.getDebugLoc(); + + if (Depth > 0) { + SDValue FrameAddr = LowerFRAMEADDR(Op, DAG); + SDValue Offset = + DAG.getConstant(TD->getPointerSize(), MVT::i16); + return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), + DAG.getNode(ISD::ADD, dl, getPointerTy(), + FrameAddr, Offset), + NULL, 0); + } + + // Just load the return address. + SDValue RetAddrFI = getReturnAddressFrameIndex(DAG); + return DAG.getLoad(getPointerTy(), dl, DAG.getEntryNode(), + RetAddrFI, NULL, 0); +} + +SDValue MSP430TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + MFI->setFrameAddressIsTaken(true); + EVT VT = Op.getValueType(); + DebugLoc dl = Op.getDebugLoc(); // FIXME probably not meaningful + unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); + SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), dl, + MSP430::FPW, VT); + while (Depth--) + FrameAddr = DAG.getLoad(VT, dl, DAG.getEntryNode(), FrameAddr, NULL, 0); + return FrameAddr; +} + /// getPostIndexedAddressParts - returns true by value, base pointer and /// offset pointer and addressing mode by reference if this node can be /// combined with a load / store to form a post-indexed load / store. Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h?rev=90740&r1=90739&r2=90740&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.h Sun Dec 6 20:28:10 2009 @@ -86,6 +86,9 @@ SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG); SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG); SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG); + SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG); + SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG); + SDValue getReturnAddressFrameIndex(SelectionDAG &DAG); TargetLowering::ConstraintType getConstraintType(const std::string &Constraint) const; @@ -147,6 +150,7 @@ const MSP430Subtarget &Subtarget; const MSP430TargetMachine &TM; + const TargetData *TD; }; } // namespace llvm Modified: llvm/trunk/lib/Target/MSP430/MSP430MachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430MachineFunctionInfo.h?rev=90740&r1=90739&r2=90740&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430MachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430MachineFunctionInfo.h Sun Dec 6 20:28:10 2009 @@ -25,14 +25,20 @@ /// stack frame in bytes. unsigned CalleeSavedFrameSize; + /// ReturnAddrIndex - FrameIndex for return slot. + int ReturnAddrIndex; + public: MSP430MachineFunctionInfo() : CalleeSavedFrameSize(0) {} explicit MSP430MachineFunctionInfo(MachineFunction &MF) - : CalleeSavedFrameSize(0) {} + : CalleeSavedFrameSize(0), ReturnAddrIndex(0) {} unsigned getCalleeSavedFrameSize() const { return CalleeSavedFrameSize; } void setCalleeSavedFrameSize(unsigned bytes) { CalleeSavedFrameSize = bytes; } + + int getRAIndex() const { return ReturnAddrIndex; } + void setRAIndex(int Index) { ReturnAddrIndex = Index; } }; } // End llvm namespace From asl at math.spbu.ru Sun Dec 6 20:28:27 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:28:27 -0000 Subject: [llvm-commits] [llvm] r90741 - in /llvm/trunk/lib/CodeGen/SelectionDAG: LegalizeIntegerTypes.cpp LegalizeTypes.h Message-ID: <200912070228.nB72SRXS031075@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:28:26 2009 New Revision: 90741 URL: http://llvm.org/viewvc/llvm-project?rev=90741&view=rev Log: Truncate the arguments of llvm.frameaddress / llvm.returnaddress intrinsics from i32 to platform's largest native type Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp?rev=90741&r1=90740&r2=90741&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp Sun Dec 6 20:28:26 2009 @@ -1996,7 +1996,9 @@ case ISD::SRA: case ISD::SRL: case ISD::ROTL: - case ISD::ROTR: Res = ExpandIntOp_Shift(N); break; + case ISD::ROTR: Res = ExpandIntOp_Shift(N); break; + case ISD::RETURNADDR: + case ISD::FRAMEADDR: Res = ExpandIntOp_RETURNADDR(N); break; } // If the result is null, the sub-method took care of registering results etc. @@ -2180,6 +2182,15 @@ return DAG.UpdateNodeOperands(SDValue(N, 0), N->getOperand(0), Lo); } +SDValue DAGTypeLegalizer::ExpandIntOp_RETURNADDR(SDNode *N) { + // The argument of RETURNADDR / FRAMEADDR builtin is 32 bit contant. This + // surely makes pretty nice problems on 8/16 bit targets. Just truncate this + // constant to valid type. + SDValue Lo, Hi; + GetExpandedInteger(N->getOperand(0), Lo, Hi); + return DAG.UpdateNodeOperands(SDValue(N, 0), Lo); +} + SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(SDNode *N) { SDValue Op = N->getOperand(0); EVT DstVT = N->getValueType(0); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=90741&r1=90740&r2=90741&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Sun Dec 6 20:28:26 2009 @@ -362,6 +362,7 @@ SDValue ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo); SDValue ExpandIntOp_TRUNCATE(SDNode *N); SDValue ExpandIntOp_UINT_TO_FP(SDNode *N); + SDValue ExpandIntOp_RETURNADDR(SDNode *N); void IntegerExpandSetCCOperands(SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, DebugLoc dl); From asl at math.spbu.ru Sun Dec 6 20:28:42 2009 From: asl at math.spbu.ru (Anton Korobeynikov) Date: Mon, 07 Dec 2009 02:28:42 -0000 Subject: [llvm-commits] [llvm] r90742 - /llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Message-ID: <200912070228.nB72SgjF031093@zion.cs.uiuc.edu> Author: asl Date: Sun Dec 6 20:28:41 2009 New Revision: 90742 URL: http://llvm.org/viewvc/llvm-project?rev=90742&view=rev Log: Some pretty-printing Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Modified: llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp?rev=90742&r1=90741&r2=90742&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430ISelLowering.cpp Sun Dec 6 20:28:41 2009 @@ -824,6 +824,7 @@ switch (Opcode) { default: return NULL; case MSP430ISD::RET_FLAG: return "MSP430ISD::RET_FLAG"; + case MSP430ISD::RETI_FLAG: return "MSP430ISD::RETI_FLAG"; case MSP430ISD::RRA: return "MSP430ISD::RRA"; case MSP430ISD::RLA: return "MSP430ISD::RLA"; case MSP430ISD::RRC: return "MSP430ISD::RRC"; From evan.cheng at apple.com Sun Dec 6 21:07:01 2009 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 07 Dec 2009 03:07:01 -0000 Subject: [llvm-commits] [llvm] r90744 - /llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Message-ID: <200912070307.nB7371IY032371@zion.cs.uiuc.edu> Author: evancheng Date: Sun Dec 6 21:07:01 2009 New Revision: 90744 URL: http://llvm.org/viewvc/llvm-project?rev=90744&view=rev Log: If BB is empty, insert PHI before end() instead of front(). Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Modified: llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp?rev=90744&r1=90743&r2=90744&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineSSAUpdater.cpp Sun Dec 6 21:07:01 2009 @@ -157,8 +157,9 @@ return SingularValue; // Otherwise, we do need a PHI: insert one now. + MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front(); MachineInstr *InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, - BB->front(), VRC, MRI, TII); + Loc, VRC, MRI, TII); // Fill in all the predecessors of the PHI. MachineInstrBuilder MIB(InsertedPHI); @@ -231,7 +232,8 @@ // that we have a cycle. Handle this by inserting a PHI node and returning // it. When we get back to the first instance of the recursion we will fill // in the PHI node. - MachineInstr *NewPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(), + MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front(); + MachineInstr *NewPHI = InsertNewDef(TargetInstrInfo::PHI, BB, Loc, VRC, MRI,TII); unsigned NewVR = NewPHI->getOperand(0).getReg(); InsertRes.first->second = NewVR; @@ -311,7 +313,8 @@ // Otherwise, we do need a PHI: insert one now if we don't already have one. MachineInstr *InsertedPHI; if (InsertedVal == 0) { - InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, BB->front(), + MachineBasicBlock::iterator Loc = BB->empty() ? BB->end() : BB->front(); + InsertedPHI = InsertNewDef(TargetInstrInfo::PHI, BB, Loc, VRC, MRI, TII); InsertedVal = InsertedPHI->getOperand(0).getReg(); } else { From ofv at wanadoo.es Sun Dec 6 23:29:59 2009 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 07 Dec 2009 05:29:59 -0000 Subject: [llvm-commits] [llvm] r90748 - in /llvm/trunk: include/llvm/System/Atomic.h lib/System/Atomic.cpp Message-ID: <200912070529.nB75TxXt004420@zion.cs.uiuc.edu> Author: ofv Date: Sun Dec 6 23:29:59 2009 New Revision: 90748 URL: http://llvm.org/viewvc/llvm-project?rev=90748&view=rev Log: Fixes the Atomic implementation if compiled by MSVC compiler. sys::cas_flag should be long on this platform, InterlockedAdd() is defined only for the Itanium architecture (according to MSDN). Patch by Michael Beck! Modified: llvm/trunk/include/llvm/System/Atomic.h llvm/trunk/lib/System/Atomic.cpp Modified: llvm/trunk/include/llvm/System/Atomic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Atomic.h?rev=90748&r1=90747&r2=90748&view=diff ============================================================================== --- llvm/trunk/include/llvm/System/Atomic.h (original) +++ llvm/trunk/include/llvm/System/Atomic.h Sun Dec 6 23:29:59 2009 @@ -20,7 +20,11 @@ namespace sys { void MemoryFence(); +#ifdef _MSC_VER + typedef long cas_flag; +#else typedef uint32_t cas_flag; +#endif cas_flag CompareAndSwap(volatile cas_flag* ptr, cas_flag new_value, cas_flag old_value); Modified: llvm/trunk/lib/System/Atomic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Atomic.cpp?rev=90748&r1=90747&r2=90748&view=diff ============================================================================== --- llvm/trunk/lib/System/Atomic.cpp (original) +++ llvm/trunk/lib/System/Atomic.cpp Sun Dec 6 23:29:59 2009 @@ -85,7 +85,7 @@ #elif defined(__GNUC__) return __sync_add_and_fetch(ptr, val); #elif defined(_MSC_VER) - return InterlockedAdd(ptr, val); + return InterlockedExchangeAdd(ptr, val) + val; #else # error No atomic add implementation for your platform! #endif From ofv at wanadoo.es Sun Dec 6 23:31:16 2009 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Mon, 07 Dec 2009 06:31:16 +0100 Subject: [llvm-commits] [patch] Fix Windows Atomic implementation References: <20091206004605.19300@gmx.net> Message-ID: <87ocmbxsd7.fsf@telefonica.net> "Michael Beck" writes: > The following patch fixes the Atomic implementation if compiled by > MSVC compiler. sys::cas_flag should be long on this platform, > InterlockedAdd() is defined only for the Itanium architecture > (according to MSDN). > > If this and my previous patch to cmake/modules/CheckAtomic.cmake are > applied, cmake builds with MSVC will contain multithreading support. Applied in r90748. Thanks! -- ?scar