From nicholas at mxc.ca Mon May 2 00:05:29 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 02 May 2011 05:05:29 -0000 Subject: [llvm-commits] [llvm] r130684 - /llvm/trunk/lib/Object/COFFObjectFile.cpp Message-ID: <20110502050529.F046D2A6C138@llvm.org> Author: nicholas Date: Mon May 2 00:05:29 2011 New Revision: 130684 URL: http://llvm.org/viewvc/llvm-project?rev=130684&view=rev Log: Remove dead variable pointed out by GCC 4.6 warnings, and reflow this a little to scope a variable more tightly per llvm coding style. No functional change. Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=130684&r1=130683&r2=130684&view=diff ============================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Mon May 2 00:05:29 2011 @@ -186,11 +186,8 @@ return ret; uint32_t Characteristics = 0; - uint32_t PointerToRawData = 0; - const coff_section *Section = getSection(symb->SectionNumber); - if (Section) { + if (const coff_section *Section = getSection(symb->SectionNumber)) { Characteristics = Section->Characteristics; - PointerToRawData = Section->PointerToRawData; } switch (symb->SectionNumber) { From nicholas at mxc.ca Mon May 2 00:24:48 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 02 May 2011 05:24:48 -0000 Subject: [llvm-commits] [llvm] r130685 - /llvm/trunk/lib/Support/CommandLine.cpp Message-ID: <20110502052448.116592A6C138@llvm.org> Author: nicholas Date: Mon May 2 00:24:47 2011 New Revision: 130685 URL: http://llvm.org/viewvc/llvm-project?rev=130685&view=rev Log: In option typo correction, consider -foo=VALUE flags as two distinct parts. The comments claimed it did this, but the LHS value was actually an unused variable. The new system considers only the '-foo' part when comparing it for typos against flags that have values, but still look at the whole string for flags that don't. That way, we'll still correct '-inst=combine' to '-instcombine'. 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=130685&r1=130684&r2=130685&view=diff ============================================================================== --- llvm/trunk/lib/Support/CommandLine.cpp (original) +++ llvm/trunk/lib/Support/CommandLine.cpp Mon May 2 00:24:47 2011 @@ -186,12 +186,14 @@ /// have already been stripped. static Option *LookupNearestOption(StringRef Arg, const StringMap &OptionsMap, - const char *&NearestString) { + std::string &NearestString) { // Reject all dashes. if (Arg.empty()) return 0; // Split on any equal sign. - StringRef LHS = Arg.split('=').first; + std::pair SplitArg = Arg.split('='); + StringRef &LHS = SplitArg.first; // LHS == Arg when no '=' is present. + StringRef &RHS = SplitArg.second; // Find the closest match. Option *Best = 0; @@ -204,14 +206,19 @@ if (O->ArgStr[0]) OptionNames.push_back(O->ArgStr); + bool PermitValue = O->getValueExpectedFlag() != cl::ValueDisallowed; + StringRef Flag = PermitValue ? LHS : Arg; for (size_t i = 0, e = OptionNames.size(); i != e; ++i) { StringRef Name = OptionNames[i]; unsigned Distance = StringRef(Name).edit_distance( - Arg, /*AllowReplacements=*/true, /*MaxEditDistance=*/BestDistance); + Flag, /*AllowReplacements=*/true, /*MaxEditDistance=*/BestDistance); if (!Best || Distance < BestDistance) { Best = O; - NearestString = OptionNames[i]; BestDistance = Distance; + if (RHS.empty() || !PermitValue) + NearestString = OptionNames[i]; + else + NearestString = std::string(OptionNames[i]) + "=" + RHS.str(); } } } @@ -611,7 +618,7 @@ for (int i = 1; i < argc; ++i) { Option *Handler = 0; Option *NearestHandler = 0; - const char *NearestHandlerString = 0; + std::string NearestHandlerString; StringRef Value; StringRef ArgName = ""; From stoklund at 2pi.dk Mon May 2 00:29:56 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 02 May 2011 05:29:56 -0000 Subject: [llvm-commits] [llvm] r130686 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <20110502052956.57A992A6C138@llvm.org> Author: stoklund Date: Mon May 2 00:29:56 2011 New Revision: 130686 URL: http://llvm.org/viewvc/llvm-project?rev=130686&view=rev Log: Add a SlotIndexes::insertMachineInstrInMaps to insert the instruction after any null indexes. This makes a difference if a live interval is referring to a deleted instruction. It can be important to insert an instruction before or after a deleted instruction to avoid interference. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=130686&r1=130685&r2=130686&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Mon May 2 00:29:56 2011 @@ -511,6 +511,40 @@ return nextNonNull; } + /// getIndexBefore - Returns the index of the last indexed instruction + /// before MI, or the the start index of its basic block. + /// MI is not required to have an index. + SlotIndex getIndexBefore(const MachineInstr *MI) const { + const MachineBasicBlock *MBB = MI->getParent(); + assert(MBB && "MI must be inserted inna basic block"); + MachineBasicBlock::const_iterator I = MI, B = MBB->begin(); + for (;;) { + if (I == B) + return getMBBStartIdx(MBB); + --I; + Mi2IndexMap::const_iterator MapItr = mi2iMap.find(I); + if (MapItr != mi2iMap.end()) + return MapItr->second; + } + } + + /// getIndexAfter - Returns the index of the first indexed instruction + /// after MI, or the end index of its basic block. + /// MI is not required to have an index. + SlotIndex getIndexAfter(const MachineInstr *MI) const { + const MachineBasicBlock *MBB = MI->getParent(); + assert(MBB && "MI must be inserted inna basic block"); + MachineBasicBlock::const_iterator I = MI, E = MBB->end(); + for (;;) { + ++I; + if (I == E) + return getMBBEndIdx(MBB); + Mi2IndexMap::const_iterator MapItr = mi2iMap.find(I); + if (MapItr != mi2iMap.end()) + return MapItr->second; + } + } + /// Return the (start,end) range of the given basic block number. const std::pair & getMBBRange(unsigned Num) const { @@ -604,7 +638,10 @@ /// Insert the given machine instruction into the mapping. Returns the /// assigned index. - SlotIndex insertMachineInstrInMaps(MachineInstr *mi) { + /// If Late is set and there are null indexes between mi's neighboring + /// instructions, create the new index after the null indexes instead of + /// before them. + SlotIndex insertMachineInstrInMaps(MachineInstr *mi, bool Late = false) { assert(mi2iMap.find(mi) == mi2iMap.end() && "Instr already indexed."); // Numbering DBG_VALUE instructions could cause code generation to be // affected by debug information. @@ -614,34 +651,25 @@ assert(mbb != 0 && "Instr must be added to function."); - MachineBasicBlock::iterator miItr(mi); - IndexListEntry *newEntry; - // Get previous index, considering that not all instructions are indexed. - IndexListEntry *prevEntry; - for (;;) { - // If mi is at the mbb beginning, get the prev index from the mbb. - if (miItr == mbb->begin()) { - prevEntry = &getMBBStartIdx(mbb).entry(); - break; - } - // Otherwise rewind until we find a mapped instruction. - Mi2IndexMap::const_iterator itr = mi2iMap.find(--miItr); - if (itr != mi2iMap.end()) { - prevEntry = &itr->second.entry(); - break; - } + // Get the entries where mi should be inserted. + IndexListEntry *prevEntry, *nextEntry; + if (Late) { + // Insert mi's index immediately before the following instruction. + nextEntry = &getIndexAfter(mi).entry(); + prevEntry = nextEntry->getPrev(); + } else { + // Insert mi's index immediately after the preceeding instruction. + prevEntry = &getIndexBefore(mi).entry(); + nextEntry = prevEntry->getNext(); } - // Get next entry from previous entry. - IndexListEntry *nextEntry = prevEntry->getNext(); - // Get a number for the new instr, or 0 if there's no room currently. // In the latter case we'll force a renumber later. unsigned dist = ((nextEntry->getIndex() - prevEntry->getIndex())/2) & ~3u; unsigned newNumber = prevEntry->getIndex() + dist; // Insert a new list entry for mi. - newEntry = createEntry(mi, newNumber); + IndexListEntry *newEntry = createEntry(mi, newNumber); insert(nextEntry, newEntry); // Renumber locally if we need to. From stoklund at 2pi.dk Mon May 2 00:29:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 02 May 2011 05:29:59 -0000 Subject: [llvm-commits] [llvm] r130687 - in /llvm/trunk/lib/CodeGen: LiveRangeEdit.cpp LiveRangeEdit.h SplitKit.cpp Message-ID: <20110502052959.22D8D2A6C139@llvm.org> Author: stoklund Date: Mon May 2 00:29:58 2011 New Revision: 130687 URL: http://llvm.org/viewvc/llvm-project?rev=130687&view=rev Log: Minimize the slot indexes spanned by register ranges created when splitting. When an interfering live range ends at a dead slot index between two instructions, make sure that the inserted copy instruction gets a slot index after the dead ones. This makes it possible to avoid the interference. Ideally, there shouldn't be interference ending at a deleted instruction, but physical register coalescing can sometimes do that to sub-registers. This fixes PR9823. Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp llvm/trunk/lib/CodeGen/LiveRangeEdit.h llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=130687&r1=130686&r2=130687&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Mon May 2 00:29:58 2011 @@ -140,11 +140,13 @@ const Remat &RM, LiveIntervals &lis, const TargetInstrInfo &tii, - const TargetRegisterInfo &tri) { + const TargetRegisterInfo &tri, + bool Late) { assert(RM.OrigMI && "Invalid remat"); tii.reMaterialize(MBB, MI, DestReg, 0, RM.OrigMI, tri); rematted_.insert(RM.ParentVNI); - return lis.InsertMachineInstrInMaps(--MI).getDefIndex(); + return lis.getSlotIndexes()->insertMachineInstrInMaps(--MI, Late) + .getDefIndex(); } void LiveRangeEdit::eraseVirtReg(unsigned Reg, LiveIntervals &LIS) { Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=130687&r1=130686&r2=130687&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Mon May 2 00:29:58 2011 @@ -165,7 +165,8 @@ const Remat &RM, LiveIntervals&, const TargetInstrInfo&, - const TargetRegisterInfo&); + const TargetRegisterInfo&, + bool Late = false); /// markRematerialized - explicitly mark a value as rematerialized after doing /// it manually. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=130687&r1=130686&r2=130687&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Mon May 2 00:29:58 2011 @@ -579,15 +579,20 @@ SlotIndex Def; LiveInterval *LI = Edit->get(RegIdx); + // We may be trying to avoid interference that ends at a deleted instruction, + // so always begin RegIdx 0 early and all others late. + bool Late = RegIdx != 0; + // Attempt cheap-as-a-copy rematerialization. LiveRangeEdit::Remat RM(ParentVNI); if (Edit->canRematerializeAt(RM, UseIdx, true, LIS)) { - Def = Edit->rematerializeAt(MBB, I, LI->reg, RM, LIS, TII, TRI); + Def = Edit->rematerializeAt(MBB, I, LI->reg, RM, LIS, TII, TRI, Late); } else { // Can't remat, just insert a copy from parent. CopyMI = BuildMI(MBB, I, DebugLoc(), TII.get(TargetOpcode::COPY), LI->reg) .addReg(Edit->getReg()); - Def = LIS.InsertMachineInstrInMaps(CopyMI).getDefIndex(); + Def = LIS.getSlotIndexes()->insertMachineInstrInMaps(CopyMI, Late) + .getDefIndex(); } // Define the value in Reg. From chandlerc at gmail.com Mon May 2 00:49:01 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Mon, 02 May 2011 05:49:01 -0000 Subject: [llvm-commits] [llvm] r130688 - /llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Message-ID: <20110502054901.DC6E42A6C139@llvm.org> Author: chandlerc Date: Mon May 2 00:49:01 2011 New Revision: 130688 URL: http://llvm.org/viewvc/llvm-project?rev=130688&view=rev Log: Remove an unused variable in NDEBUG (found with -Wunused-variable). Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=130688&r1=130687&r2=130688&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Mon May 2 00:49:01 2011 @@ -647,9 +647,7 @@ // affected by debug information. assert(!mi->isDebugValue() && "Cannot number DBG_VALUE instructions."); - MachineBasicBlock *mbb = mi->getParent(); - - assert(mbb != 0 && "Instr must be added to function."); + assert(mi->getParent() != 0 && "Instr must be added to function."); // Get the entries where mi should be inserted. IndexListEntry *prevEntry, *nextEntry; From grosser at fim.uni-passau.de Mon May 2 02:48:30 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Mon, 02 May 2011 07:48:30 -0000 Subject: [llvm-commits] [polly] r130689 - in /polly/trunk/www: ./ experiments/ experiments/matmul/ images/ images/performance/ publications/ Message-ID: <20110502074833.BA7AB2A6C139@llvm.org> Author: grosser Date: Mon May 2 02:48:29 2011 New Revision: 130689 URL: http://llvm.org/viewvc/llvm-project?rev=130689&view=rev Log: Add new website for Polly Use the content of the Polly wiki page[1] to create a new website. I do not yet plan to officially promote this website, but it is already a solid base that we can improve and peer review. [1] http://wiki.llvm.org/Polly Added: polly/trunk/www/ polly/trunk/www/content.css polly/trunk/www/contributors.html polly/trunk/www/examples.html polly/trunk/www/experiments/ polly/trunk/www/experiments/matmul/ polly/trunk/www/experiments/matmul/init_array___%1---%19.jscop polly/trunk/www/experiments/matmul/main___%1---%17.jscop polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled+vector polly/trunk/www/experiments/matmul/matmul.c polly/trunk/www/experiments/matmul/matmul.normalopt.exe (with props) polly/trunk/www/experiments/matmul/matmul.normalopt.ll polly/trunk/www/experiments/matmul/matmul.normalopt.s polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.exe (with props) polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.ll polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.s polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.exe (with props) polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.ll polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.s polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.exe (with props) polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.ll polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.s polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe (with props) polly/trunk/www/experiments/matmul/matmul.polly.interchanged.ll polly/trunk/www/experiments/matmul/matmul.polly.interchanged.s polly/trunk/www/experiments/matmul/matmul.preopt.ll polly/trunk/www/experiments/matmul/matmul.s polly/trunk/www/experiments/matmul/runall.sh (with props) polly/trunk/www/experiments/matmul/scops.init_array.dot polly/trunk/www/experiments/matmul/scops.init_array.dot.png polly/trunk/www/experiments/matmul/scops.main.dot polly/trunk/www/experiments/matmul/scops.main.dot.png polly/trunk/www/experiments/matmul/scops.print_array.dot polly/trunk/www/experiments/matmul/scops.print_array.dot.png polly/trunk/www/experiments/matmul/scopsonly.init_array.dot polly/trunk/www/experiments/matmul/scopsonly.init_array.dot.png polly/trunk/www/experiments/matmul/scopsonly.main.dot polly/trunk/www/experiments/matmul/scopsonly.main.dot.png polly/trunk/www/experiments/matmul/scopsonly.print_array.dot polly/trunk/www/experiments/matmul/scopsonly.print_array.dot.png polly/trunk/www/get_started.html polly/trunk/www/images/ polly/trunk/www/images/architecture.png polly/trunk/www/images/iit-madras.png polly/trunk/www/images/osu.png polly/trunk/www/images/performance/ polly/trunk/www/images/performance/parallel-large.png polly/trunk/www/images/performance/parallel-small.png polly/trunk/www/images/performance/sequential-large.png polly/trunk/www/images/performance/sequential-small.png polly/trunk/www/images/sys-uni.png polly/trunk/www/images/uni-passau.png polly/trunk/www/index.html polly/trunk/www/menu.css polly/trunk/www/menu.html.incl polly/trunk/www/passes.html polly/trunk/www/performance.html polly/trunk/www/publications/ polly/trunk/www/publications.html polly/trunk/www/publications/grosser-impact-2011-slides.pdf polly/trunk/www/publications/grosser-impact-2011.pdf polly/trunk/www/todo.html Added: polly/trunk/www/content.css URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/content.css?rev=130689&view=auto ============================================================================== --- polly/trunk/www/content.css (added) +++ polly/trunk/www/content.css Mon May 2 02:48:29 2011 @@ -0,0 +1,33 @@ +html { margin: 0px; } body { margin: 8px; } + +html, body { + padding:0px; + font-size:small; font-family:"Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, Helvetica, sans-serif; background-color: #fff; color: #222; + line-height:1.5; +} + +h1, h2, h3, tt { color: #000 } + +h1 { padding-top:0px; margin-top:0px;} +h2 { color:#333333; padding-top:0.5em; } +h3 { padding-top: 0.5em; margin-bottom: -0.25em; color:#2d58b7} +li { padding-bottom: 0.5em; } +ul { padding-left:1.5em; } + +PRE.code {padding-left: 0.5em; background-color: #eeeeee} +PRE {padding-left: 0.5em} + +/* Slides */ +IMG.img_slide { + display: block; + margin-left: auto; + margin-right: auto +} + +.itemTitle { color:#2d58b7 } + +span.error { color:red } +span.caret { color:green; font-weight:bold } + +/* Tables */ +tr { vertical-align:top } Added: polly/trunk/www/contributors.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/contributors.html?rev=130689&view=auto ============================================================================== --- polly/trunk/www/contributors.html (added) +++ polly/trunk/www/contributors.html Mon May 2 02:48:29 2011 @@ -0,0 +1,55 @@ + + + + + Polly - Contributors + + + + + + + +
+ +

Polly: Contributors

+ +Polly is developed by a team of students supported by different universities. + +

People

+

Raghesh Aloor

+

Raghesh works on OpenMP code generation. He is funded as Google Summer of Code +Student 2011.

+ +

Tobias Grosser

+

Tobias is one of the two Co-founders of Polly. He designed the overall +architecture and contributed to almost every part of Polly. He did his work +during his diploma studies at University of Passau. Furthermore, he spent 6 +months at Ohio State University where he was founded by the U.S. National +Science Foundation through awards 0811781 and 0926688.

+ +

Website: www.grosser.es

+ + +

Andreas Simbuerger

+

+Andreas works on the profiling infrastructure during his PhD at University of +Passau. +

+

Website: +http://www.infosun.fim.uni-passau.de/cl/staff/simbuerger/

+

Hongbin Zheng

+

Hongbin Zheng is one of the two Co-founders of Polly. He was funded as a +Google Summer of Code Student 2010 and implemented parts of the Polly frontends +as well as the automake/cmake infrastructure.

+ +

Universities

+ +

Polly is supported by the following Universities.

+ + + + + + Added: polly/trunk/www/examples.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/examples.html?rev=130689&view=auto ============================================================================== --- polly/trunk/www/examples.html (added) +++ polly/trunk/www/examples.html Mon May 2 02:48:29 2011 @@ -0,0 +1,317 @@ + + + + + + Polly - Examples + + + + + +
+ +

Polly: Examples

+ + +

Optimize Matrix Multiplication Manually

+ + +

Polly does not yet focus on end user, but on research and the development of +new optimizations. Hence for the users of Polly it is often necessary to +understand how Polly works internally. To get an overview of the different steps +taken during polyhedral compilation, we give a step by step example on how to +use the different Polly passes. For this we optimize a simple matrix +multiplication kernel. In case you look for a more automated way of executing +Polly, check out the pollycc tool in utils/pollycc.

+ +The files used and created in this example are available here. + +
    +
  1. Create LLVM-IR from the C code

    + +Polly works on LLVM-IR. Hence it is necessary to translate the source files into +LLVM-IR. If more than on file should be optimized the files can be combined into +a single file with llvm-link. + +
    clang -S -emit-llvm matmul.c -o matmul.s
    +
  2. + + +
  3. Load Polly automatically when calling the 'opt' tool

    + +Polly is not built into opt or bugpoint, but it is a shared library that needs +to be loaded into these tools explicitally. The Polly library is called +LVMPolly.so. For a cmake build it is available in the build/lib/ directory, +autoconf creates the same file in +build/tools/polly/{Release+Asserts|Asserts|Debug}/lib. For convenience we create +an alias that automatically loads Polly if 'opt' is called. +
    +export PATH_TO_POLLY_LIB="~/polly/build/lib/"
    +alias opt="opt -load ${PATH_TO_POLLY_LIB}/LLVMPolly.so"
    +
  4. + +
  5. Prepare the LLVM-IR for Polly

    + +Polly is only able to work with code that matches a canonical form. To translate +the LLVM-IR into this form we use a set of canonicalication passes. For this +example only three passes are necessary. To get good coverage on a larger set +of input files a larger set is needed. pollycc contains a set of passes that has +shown to be beneficial. +
    opt -S -mem2reg -loop-simplify -indvars matmul.s > matmul.preopt.ll
  6. + +
  7. Show the SCoPs detected by Polly (optional)

    + +To understand if Polly was able to detect some SCoPs, we print the +structure of the detected SCoPs. In our example two SCoPs were detected. One in +'init_array' the other in 'main'. + +
    opt -basicaa -polly-cloog -analyze -q matmul.preopt.ll
    + +
    +init_array():
    +for (c2=0;c2<=1023;c2++) {
    +  for (c4=0;c4<=1023;c4++) {
    +    Stmt_5(c2,c4);
    +  }
    +}
    +
    +main():
    +for (c2=0;c2<=1023;c2++) {
    +  for (c4=0;c4<=1023;c4++) {
    +    Stmt_4(c2,c4);
    +    for (c6=0;c6<=1023;c6++) {
    +      Stmt_6(c2,c4,c6);
    +    }
    +  }
    +}
    +
    +
  8. +
  9. Highlight the detected SCoPs in the CFGs of the program (requires graphviz/dotty)

    + +Polly can use graphviz to graphically show a CFG in which the detected SCoPs are +highlighted. It can also create '.dot' files that can be translated by +the 'dot' utility into various graphic formats. + +
    opt -basicaa -view-scops -disable-output matmul.preopt.ll
    +opt -basicaa -view-scops-only -disable-output matmul.preopt.ll
    +The output for the different functions
    +view-scops: +main, +init_array, +print_array
    +view-scops-only: +main, +init_array, +print_array +
  10. + +
  11. View the polyhedral representation of the SCoPs

    +
    opt -basicaa -polly-scops -analyze matmul.preopt.ll
    +
    +[...]
    +Printing analysis 'Polly - Create polyhedral description of Scops' for region: '%1 => %17' in function 'init_array':
    +   Context:
    +   { [] }
    +   Statements {
    +   	Stmt_5
    +           Domain :=
    +               { Stmt_5[i0, i1] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 };
    +           Scattering :=
    +               { Stmt_5[i0, i1] -> scattering[0, i0, 0, i1, 0] };
    +           WriteAccess := 
    +               { Stmt_5[i0, i1] -> MemRef_A[1037i0 + i1] };
    +           WriteAccess := 
    +               { Stmt_5[i0, i1] -> MemRef_B[1047i0 + i1] };
    +   	FinalRead
    +           Domain :=
    +               { FinalRead[0] };
    +           Scattering :=
    +               { FinalRead[i0] -> scattering[200000000, o1, o2, o3, o4] };
    +           ReadAccess := 
    +               { FinalRead[i0] -> MemRef_A[o0] };
    +           ReadAccess := 
    +               { FinalRead[i0] -> MemRef_B[o0] };
    +   }
    +Printing analysis 'Polly - Create polyhedral description of Scops' for region: '%0 => <Function  Return>' in function 'init_array':
    +[...]
    +Printing analysis 'Polly - Create polyhedral description of Scops' for region: '%1 => %17' in function 'main':
    +   Context:
    +   { [] }
    +   Statements {
    +   	Stmt_4
    +           Domain :=
    +               { Stmt_4[i0, i1] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 };
    +           Scattering :=
    +               { Stmt_4[i0, i1] -> scattering[0, i0, 0, i1, 0, 0, 0] };
    +           WriteAccess := 
    +               { Stmt_4[i0, i1] -> MemRef_C[1067i0 + i1] };
    +   	Stmt_6
    +           Domain :=
    +               { Stmt_6[i0, i1, i2] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023 };
    +           Scattering :=
    +               { Stmt_6[i0, i1, i2] -> scattering[0, i0, 0, i1, 1, i2, 0] };
    +           ReadAccess := 
    +               { Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] };
    +           ReadAccess := 
    +               { Stmt_6[i0, i1, i2] -> MemRef_A[1037i0 + i2] };
    +           ReadAccess := 
    +               { Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1047i2] };
    +           WriteAccess := 
    +               { Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] };
    +   	FinalRead
    +           Domain :=
    +               { FinalRead[0] };
    +           Scattering :=
    +               { FinalRead[i0] -> scattering[200000000, o1, o2, o3, o4, o5, o6] };
    +           ReadAccess := 
    +               { FinalRead[i0] -> MemRef_C[o0] };
    +           ReadAccess := 
    +               { FinalRead[i0] -> MemRef_A[o0] };
    +           ReadAccess := 
    +               { FinalRead[i0] -> MemRef_B[o0] };
    +   }
    +Printing analysis 'Polly - Create polyhedral description of Scops' for region: '%0 => <Function  Return>' in function 'main':
    +Invalid Scop!
    +
    +
  12. + +
  13. Show the dependences for the SCoPs

    +
    opt -basicaa -polly-dependences -analyze matmul.preopt.ll
    +
    Printing analysis 'Polly - Calculate dependences for SCoP' for region: 'for.cond => for.end28' in function 'init_array':
    +   Must dependences:
    +       {  }
    +   May dependences:
    +       {  }
    +   Must no source:
    +       {  }
    +   May no source:
    +       {  }
    +Printing analysis 'Polly - Calculate dependences for SCoP' for region: 'for.cond => for.end48' in function 'main':
    +   Must dependences:
    +       {  Stmt_4[i0, i1] -> Stmt_6[i0, i1, 0] :
    +              i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023;
    +          Stmt_6[i0, i1, i2] -> Stmt_6[i0, i1, 1 + i2] :
    +              i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1022; 
    +          Stmt_6[i0, i1, 1023] -> FinalRead[0] :
    +              i1 <= 1091540 - 1067i0 and i1 >= -1067i0 and i1 >= 0 and i1 <= 1023;
    +          Stmt_6[1023, i1, 1023] -> FinalRead[0] :
    +              i1 >= 0 and i1 <= 1023 
    +       }
    +   May dependences:
    +       {  }
    +   Must no source:
    +       {  Stmt_6[i0, i1, i2] -> MemRef_A[1037i0 + i2] :
    +              i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023; 
    +          Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1047i2] :
    +              i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023; 
    +          FinalRead[0] -> MemRef_A[o0];
    +          FinalRead[0] -> MemRef_B[o0]
    +          FinalRead[0] -> MemRef_C[o0] :
    +              o0 >= 1092565 or (exists (e0 = [(o0)/1067]: o0 <= 1091540 and o0 >= 0
    +              and 1067e0 <= -1024 + o0 and 1067e0 >= -1066 + o0)) or o0 <= -1;
    +       }
    +   May no source:
    +       {  }
    +
  14. + +
  15. Export jscop files

    + +Polly can export the polyhedral representation in so called jscop files. Jscop +files contain the polyhedral representation stored in a JSON file. +
    opt -basicaa -polly-export-jscop matmul.preopt.ll
    +
    Writing SCoP 'for.cond => for.end28' in function 'init_array' to './init_array___%for.cond---%for.end28.jscop'.
    +Writing SCoP 'for.cond => for.end48' in function 'main' to './main___%for.cond---%for.end48.jscop'.
    +
  16. + +
  17. Import the changed jscop files and print the updated SCoP structure +(optional)

    +

    Polly can import jscop files, where the schedules of the statements were +changed. With the help of these updated files we can import transformations into +Polly. It is possible to import different jscop files by providing the postfix +of the jscop file that is imported.

    +

    The optimized jscop files for this example are hand written. The schedule +used was inspired by looking at the optimizations PoCC performs. If PoCC is +installed Polly can often calculate such schedules fully automatically.

    + + +
    opt -basicaa -polly-import-jscop -polly-print -disable-output matmul.preopt.ll -polly-import-jscop-postfix=.opt
    +
    Cannot open file: ./init_array___%for.cond---%for.end28.jscop.opt
    +Skipping import.
    +In function: 'init_array' SCoP: for.cond => for.end28:
    +for (c2=0;c2<=1023;c2++) {
    +  for (c4=0;c4<=1023;c4++) {
    +    %for.body4(c2,c4);
    +  }
    +}
    +Reading SCoP 'for.cond => for.end48' in function 'main' from './main___%for.cond---%for.end48.scop.opt.opt'.
    +In function: 'main' SCoP: for.cond => for.end48:
    +for (c2=0;c2<=1023;c2++) {
    +  for (c4=0;c4<=1023;c4++) {
    +    %for.body4(c2,c4);
    +  }
    +}
    +for (c2=0;c2<=1023;c2++) {
    +  for (c3=0;c3<=1023;c3++) {
    +    for (c4=0;c4<=1023;c4++) {
    +      %for.body12(c2,c4,c3);
    +    }
    +  }
    +}
    +
  18. + +
  19. Codegenerate the SCoPs

    +This generates new code for the SCoPs detected by polly. +If -polly-import is present, transformations specified in the imported openscop +files will be applied. +
    opt -basicaa -polly-import -polly-import-postfix=.opt -polly-codegen matmul.preopt.ll | opt -O3 > matmul.pollyopt.ll
    +
    +Cannot open file: ./init_array___%for.cond---%for.end28.scop.opt
    +Skipping import.
    +Reading SCoP 'for.cond => for.end48' in function 'main' from './main___%for.cond---%for.end48.scop.opt'.
    + +
    opt matmul.preopt.ll | opt -O3 > matmul.normalopt.ll
  20. + +
  21. Create the executables

    + +Create one executable optimized with plain -O3 as well as a set of executables +optimized in different ways with Polly. One changes only the loop structure, the +other adds tiling, the next adds vectorization and finally we use OpenMP +parallelism. +
    +llc matmul.normalopt.ll -o matmul.normalopt.s && \
    +    gcc matmul.normalopt.s -o matmul.normalopt.exe
    +llc matmul.polly.interchanged.ll -o matmul.polly.interchanged.s && \
    +    gcc matmul.polly.interchanged.s -o matmul.polly.interchanged.exe
    +llc matmul.polly.interchanged+tiled.ll -o matmul.polly.interchanged+tiled.s && \
    +    gcc matmul.polly.interchanged+tiled.s -o matmul.polly.interchanged+tiled.exe
    +llc matmul.polly.interchanged+tiled+vector.ll -o matmul.polly.interchanged+tiled+vector.s && \
    +    gcc matmul.polly.interchanged+tiled+vector.s -o matmul.polly.interchanged+tiled+vector.exe
    +llc matmul.polly.interchanged+tiled+vector+openmp.ll -o matmul.polly.interchanged+tiled+vector+openmp.s && \
    +    gcc -lgomp matmul.polly.interchanged+tiled+vector+openmp.s -o matmul.polly.interchanged+tiled+vector+openmp.exe
    +    
    + +
  22. Compare the runtime of the executables

    + +By comparing the runtimes of the different code snippets we see that a simple +loop interchange gives here the largest performance boost. However by adding +vectorization and by using OpenMP we can further improve the performance +significantly. +
    time ./matmul.normalopt.exe
    +
    42.68 real, 42.55 user, 0.00 sys
    +
    time ./matmul.polly.interchanged.exe
    +
    04.33 real, 4.30 user, 0.01 sys
    +
    time ./matmul.polly.interchanged+tiled.exe
    +
    04.11 real, 4.10 user, 0.00 sys
    +
    time ./matmul.polly.interchanged+tiled+vector.exe
    +
    01.39 real, 1.36 user, 0.01 sys
    +
    time ./matmul.polly.interchanged+tiled+vector+openmp.exe
    +
    00.66 real, 2.58 user, 0.02 sys
    +
  23. +
+ +
+ + Added: polly/trunk/www/experiments/matmul/init_array___%1---%19.jscop URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/init_array___%251---%2519.jscop?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/init_array___%1---%19.jscop (added) +++ polly/trunk/www/experiments/matmul/init_array___%1---%19.jscop Mon May 2 02:48:29 2011 @@ -0,0 +1,21 @@ +{ + "context" : "{ [] }", + "name" : "%1 => %19", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "{ Stmt_5[i0, i1] -> MemRef_A[1536i0 + i1] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_5[i0, i1] -> MemRef_B[1536i0 + i1] }" + } + ], + "domain" : "{ Stmt_5[i0, i1] : i0 >= 0 and i0 <= 1535 and i1 >= 0 and i1 <= 1535 }", + "name" : "Stmt_5", + "schedule" : "{ Stmt_5[i0, i1] -> scattering[0, i0, 0, i1, 0] }" + } + ] +} Added: polly/trunk/www/experiments/matmul/main___%1---%17.jscop URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/main___%251---%2517.jscop?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/main___%1---%17.jscop (added) +++ polly/trunk/www/experiments/matmul/main___%1---%17.jscop Mon May 2 02:48:29 2011 @@ -0,0 +1,40 @@ +{ + "context" : "{ [] }", + "name" : "%1 => %17", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "{ Stmt_4[i0, i1] -> MemRef_C[1536i0 + i1] }" + } + ], + "domain" : "{ Stmt_4[i0, i1] : i0 >= 0 and i0 <= 1535 and i1 >= 0 and i1 <= 1535 }", + "name" : "Stmt_4", + "schedule" : "{ Stmt_4[i0, i1] -> scattering[0, i0, 0, i1, 0, 0, 0] }" + }, + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1536i0 + i1] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_A[1536i0 + i2] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1536i2] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1536i0 + i1] }" + } + ], + "domain" : "{ Stmt_6[i0, i1, i2] : i0 >= 0 and i0 <= 1535 and i1 >= 0 and i1 <= 1535 and i2 >= 0 and i2 <= 1535 }", + "name" : "Stmt_6", + "schedule" : "{ Stmt_6[i0, i1, i2] -> scattering[0, i0, 0, i1, 1, i2, 0] }" + } + ] +} Added: polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/main___%251---%2517.jscop.interchanged?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged (added) +++ polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged Mon May 2 02:48:29 2011 @@ -0,0 +1,40 @@ +{ + "context" : "{ [] }", + "name" : "%1 => %17", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "{ Stmt_4[i0, i1] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_4[i0, i1] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 }", + "name" : "Stmt_4", + "schedule" : "{ Stmt_4[i0, i1] -> scattering[0, i0, 0, i1, 0, 0, 0] }" + }, + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_A[1037i0 + i2] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1047i2] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_6[i0, i1, i2] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023 }", + "name" : "Stmt_6", + "schedule" : "{ Stmt_6[i0, i1, i2] -> scattering[1, i0, 0, i2, 0, i1, 0] }" + } + ] +} Added: polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/main___%251---%2517.jscop.interchanged%2Btiled?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled (added) +++ polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled Mon May 2 02:48:29 2011 @@ -0,0 +1,40 @@ +{ + "context" : "{ [] }", + "name" : "%1 => %17", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "{ Stmt_4[i0, i1] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_4[i0, i1] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 }", + "name" : "Stmt_4", + "schedule" : "{ Stmt_4[i0, i1] -> scattering[0, i0, 0, i1, 0, 0, 0] }" + }, + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_A[1037i0 + i2] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1047i2] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_6[i0, i1, i2] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023 }", + "name" : "Stmt_6", + "schedule" : "{ Stmt_6[i0, i1, i2] -> scattering[1, o0, o1, o2, i0, i2, i1]: o0 <= i0 < o0 + 64 and o1 <= i1 < o1 + 64 and o2 <= i2 < o2 + 64 and o0 % 64 = 0 and o1 % 64 = 0 and o2 % 64 = 0 }" + } + ] +} Added: polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled+vector URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/main___%251---%2517.jscop.interchanged%2Btiled%2Bvector?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled+vector (added) +++ polly/trunk/www/experiments/matmul/main___%1---%17.jscop.interchanged+tiled+vector Mon May 2 02:48:29 2011 @@ -0,0 +1,40 @@ +{ + "context" : "{ [] }", + "name" : "%1 => %17", + "statements" : [ + { + "accesses" : [ + { + "kind" : "write", + "relation" : "{ Stmt_4[i0, i1] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_4[i0, i1] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 }", + "name" : "Stmt_4", + "schedule" : "{ Stmt_4[i0, i1] -> scattering[0, i0, 0, i1, 0, 0, 0, 0] }" + }, + { + "accesses" : [ + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_A[1037i0 + i2] }" + }, + { + "kind" : "read", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_B[i1 + 1047i2] }" + }, + { + "kind" : "write", + "relation" : "{ Stmt_6[i0, i1, i2] -> MemRef_C[1067i0 + i1] }" + } + ], + "domain" : "{ Stmt_6[i0, i1, i2] : i0 >= 0 and i0 <= 1023 and i1 >= 0 and i1 <= 1023 and i2 >= 0 and i2 <= 1023 }", + "name" : "Stmt_6", + "schedule" : "{ Stmt_6[i0, i1, i2] -> scattering[1, o0, o1, o2, i0, i2, ii1, i1]: o0 <= i0 < o0 + 64 and o1 <= i1 < o1 + 64 and o2 <= i2 < o2 + 64 and o0 % 64 = 0 and o1 % 64 = 0 and o2 % 64 = 0 and ii1 % 4 = 0 and ii1 <= i1 < ii1 + 4}" + } + ] +} Added: polly/trunk/www/experiments/matmul/matmul.c URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.c?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.c (added) +++ polly/trunk/www/experiments/matmul/matmul.c Mon May 2 02:48:29 2011 @@ -0,0 +1,52 @@ +#include + +#define N 1536 +float A[N][N]; +float B[N][N]; +float C[N][N]; + +void init_array() +{ + int i, j; + + for (i=0; iThis Loop Header: Depth=1 + # Child Loop BB0_2 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB0_2: # Parent Loop BB0_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB0_2 +# BB#3: # in Loop: Header=BB0_1 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB0_1 +# BB#4: + ret +.Ltmp0: + .size init_array, .Ltmp0-init_array + + .globl print_array + .align 16, 0x90 + .type print_array, at function +print_array: # @print_array +# BB#0: + pushq %r14 + pushq %rbx + pushq %rax + movq $-9437184, %rbx # imm = 0xFFFFFFFFFF700000 + .align 16, 0x90 +.LBB1_1: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB1_2 Depth 2 + xorl %r14d, %r14d + movq stdout(%rip), %rdi + .align 16, 0x90 +.LBB1_2: # Parent Loop BB1_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movss C+9437184(%rbx,%r14,4), %xmm0 + cvtss2sd %xmm0, %xmm0 + movl $.L.str, %esi + movb $1, %al + callq fprintf + movslq %r14d, %rax + imulq $1717986919, %rax, %rcx # imm = 0x66666667 + movq %rcx, %rdx + shrq $63, %rdx + sarq $37, %rcx + addl %edx, %ecx + imull $80, %ecx, %ecx + subl %ecx, %eax + cmpl $79, %eax + jne .LBB1_4 +# BB#3: # in Loop: Header=BB1_2 Depth=2 + movq stdout(%rip), %rsi + movl $10, %edi + callq fputc +.LBB1_4: # in Loop: Header=BB1_2 Depth=2 + incq %r14 + movq stdout(%rip), %rsi + cmpq $1536, %r14 # imm = 0x600 + movq %rsi, %rdi + jne .LBB1_2 +# BB#5: # in Loop: Header=BB1_1 Depth=1 + movl $10, %edi + callq fputc + addq $6144, %rbx # imm = 0x1800 + jne .LBB1_1 +# BB#6: + addq $8, %rsp + popq %rbx + popq %r14 + ret +.Ltmp1: + .size print_array, .Ltmp1-print_array + + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI2_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl main + .align 16, 0x90 + .type main, at function +main: # @main +# BB#0: + xorl %eax, %eax + movsd .LCPI2_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB2_1: # %.preheader.i + # =>This Loop Header: Depth=1 + # Child Loop BB2_2 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB2_2: # Parent Loop BB2_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB2_2 +# BB#3: # in Loop: Header=BB2_1 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + xorl %edx, %edx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB2_1 + .align 16, 0x90 +.LBB2_4: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB2_5 Depth 2 + # Child Loop BB2_6 Depth 3 + xorl %eax, %eax + xorl %ecx, %ecx + .align 16, 0x90 +.LBB2_5: # Parent Loop BB2_4 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB2_6 Depth 3 + movl $0, C(%rcx,%rdx) + leaq B(%rcx), %rsi + pxor %xmm0, %xmm0 + movq %rax, %rdi + .align 16, 0x90 +.LBB2_6: # Parent Loop BB2_4 Depth=1 + # Parent Loop BB2_5 Depth=2 + # => This Inner Loop Header: Depth=3 + movss A(%rdx,%rdi,4), %xmm1 + mulss (%rsi), %xmm1 + addss %xmm1, %xmm0 + addq $6144, %rsi # imm = 0x1800 + incq %rdi + cmpq $1536, %rdi # imm = 0x600 + jne .LBB2_6 +# BB#7: # in Loop: Header=BB2_5 Depth=2 + movss %xmm0, C(%rcx,%rdx) + addq $4, %rcx + cmpq $6144, %rcx # imm = 0x1800 + jne .LBB2_5 +# BB#8: # %init_array.exit + # in Loop: Header=BB2_4 Depth=1 + addq $6144, %rdx # imm = 0x1800 + cmpq $9437184, %rdx # imm = 0x900000 + jne .LBB2_4 +# BB#9: + xorl %eax, %eax + ret +.Ltmp2: + .size main, .Ltmp2-main + + .type A, at object # @A + .comm A,9437184,16 + .type B, at object # @B + .comm B,9437184,16 + .type .L.str, at object # @.str + .section .rodata.str1.1,"aMS", at progbits,1 +.L.str: + .asciz "%lf " + .size .L.str, 5 + + .type C, at object # @C + .comm C,9437184,16 + + .section ".note.GNU-stack","", at progbits Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.exe URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector%2Bopenmp.exe?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.exe (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.exe Mon May 2 02:48:29 2011 differ Propchange: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.exe ------------------------------------------------------------------------------ svn:executable = * Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector%2Bopenmp.ll?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.ll (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.ll Mon May 2 02:48:29 2011 differ Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.s URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector%2Bopenmp.s?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.s (added) +++ polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector+openmp.s Mon May 2 02:48:29 2011 @@ -0,0 +1,628 @@ + .file "matmul.polly.interchanged+tiled+vector+openmp.ll" + .text + .globl init_array + .align 16, 0x90 + .type init_array, at function +init_array: # @init_array +# BB#0: # %pollyBB + pushq %rbx + subq $16, %rsp + movq $A, (%rsp) + movq $B, 8(%rsp) + movl $init_array.omp_subfn, %edi + leaq (%rsp), %rbx + xorl %edx, %edx + xorl %ecx, %ecx + movl $1536, %r8d # imm = 0x600 + movl $1, %r9d + movq %rbx, %rsi + callq GOMP_parallel_loop_runtime_start + movq %rbx, %rdi + callq init_array.omp_subfn + callq GOMP_parallel_end + addq $16, %rsp + popq %rbx + ret +.Ltmp0: + .size init_array, .Ltmp0-init_array + + .globl print_array + .align 16, 0x90 + .type print_array, at function +print_array: # @print_array +# BB#0: + pushq %r14 + pushq %rbx + pushq %rax + movq $-9437184, %rbx # imm = 0xFFFFFFFFFF700000 + .align 16, 0x90 +.LBB1_1: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB1_2 Depth 2 + xorl %r14d, %r14d + movq stdout(%rip), %rdi + .align 16, 0x90 +.LBB1_2: # Parent Loop BB1_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movss C+9437184(%rbx,%r14,4), %xmm0 + cvtss2sd %xmm0, %xmm0 + movl $.L.str, %esi + movb $1, %al + callq fprintf + movslq %r14d, %rax + imulq $1717986919, %rax, %rcx # imm = 0x66666667 + movq %rcx, %rdx + shrq $63, %rdx + sarq $37, %rcx + addl %edx, %ecx + imull $80, %ecx, %ecx + subl %ecx, %eax + cmpl $79, %eax + jne .LBB1_4 +# BB#3: # in Loop: Header=BB1_2 Depth=2 + movq stdout(%rip), %rsi + movl $10, %edi + callq fputc +.LBB1_4: # in Loop: Header=BB1_2 Depth=2 + incq %r14 + movq stdout(%rip), %rsi + cmpq $1536, %r14 # imm = 0x600 + movq %rsi, %rdi + jne .LBB1_2 +# BB#5: # in Loop: Header=BB1_1 Depth=1 + movl $10, %edi + callq fputc + addq $6144, %rbx # imm = 0x1800 + jne .LBB1_1 +# BB#6: + addq $8, %rsp + popq %rbx + popq %r14 + ret +.Ltmp1: + .size print_array, .Ltmp1-print_array + + .globl main + .align 16, 0x90 + .type main, at function +main: # @main +# BB#0: # %pollyBB + pushq %rbp + movq %rsp, %rbp + pushq %r15 + pushq %r14 + pushq %r13 + pushq %r12 + pushq %rbx + subq $56, %rsp + movq $A, -72(%rbp) + movq $B, -64(%rbp) + movl $init_array.omp_subfn, %edi + leaq -72(%rbp), %rbx + movq %rbx, %rsi + xorl %edx, %edx + xorl %ecx, %ecx + movl $1536, %r8d # imm = 0x600 + movl $1, %r9d + callq GOMP_parallel_loop_runtime_start + movq %rbx, %rdi + callq init_array.omp_subfn + callq GOMP_parallel_end + movl $main.omp_subfn, %edi + leaq -96(%rbp), %rsi + movq $C, -96(%rbp) + movq $A, -88(%rbp) + movq $B, -80(%rbp) + xorl %edx, %edx + xorl %ecx, %ecx + movl $1536, %r8d # imm = 0x600 + movl $1, %r9d + callq GOMP_parallel_loop_runtime_start + leaq -48(%rbp), %rdi + leaq -56(%rbp), %rsi + callq GOMP_loop_runtime_next + testb $1, %al + je .LBB2_6 +# BB#1: + leaq -48(%rbp), %rbx + leaq -56(%rbp), %r14 + .align 16, 0x90 +.LBB2_3: # %omp.loadIVBounds.i + # =>This Loop Header: Depth=1 + # Child Loop BB2_5 Depth 2 + movq -56(%rbp), %r15 + decq %r15 + movq -48(%rbp), %r12 + cmpq %r15, %r12 + jg .LBB2_2 +# BB#4: # %polly.loop_header2.preheader.lr.ph.i + # in Loop: Header=BB2_3 Depth=1 + leaq (%r12,%r12,2), %rax + shlq $11, %rax + leaq C(%rax), %r13 + .align 16, 0x90 +.LBB2_5: # %polly.loop_header2.preheader.i + # Parent Loop BB2_3 Depth=1 + # => This Inner Loop Header: Depth=2 + movq %r13, %rdi + xorl %esi, %esi + movl $6144, %edx # imm = 0x1800 + callq memset + addq $6144, %r13 # imm = 0x1800 + incq %r12 + cmpq %r15, %r12 + jle .LBB2_5 +.LBB2_2: # %omp.checkNext.loopexit.i + # in Loop: Header=BB2_3 Depth=1 + movq %rbx, %rdi + movq %r14, %rsi + callq GOMP_loop_runtime_next + testb $1, %al + jne .LBB2_3 +.LBB2_6: # %main.omp_subfn.exit + callq GOMP_loop_end_nowait + callq GOMP_parallel_end + movq %rsp, %rax + leaq -32(%rax), %rbx + movl $main.omp_subfn1, %edi + xorl %ecx, %ecx + movl $1536, %r8d # imm = 0x600 + movl $64, %r9d + movq %rbx, %rsp + movq $C, -32(%rax) + movq $A, -24(%rax) + movq $B, -16(%rax) + movq %rbx, %rsi + xorl %edx, %edx + callq GOMP_parallel_loop_runtime_start + movq %rbx, %rdi + callq main.omp_subfn1 + callq GOMP_parallel_end + xorl %eax, %eax + leaq -40(%rbp), %rsp + popq %rbx + popq %r12 + popq %r13 + popq %r14 + popq %r15 + popq %rbp + ret +.Ltmp2: + .size main, .Ltmp2-main + + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI3_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .align 16, 0x90 + .type init_array.omp_subfn, at function +init_array.omp_subfn: # @init_array.omp_subfn +.Leh_func_begin3: +.Ltmp6: + .cfi_startproc +# BB#0: # %omp.setup + pushq %r14 +.Ltmp7: + .cfi_def_cfa_offset 16 + pushq %rbx +.Ltmp8: + .cfi_def_cfa_offset 24 + subq $24, %rsp +.Ltmp9: + .cfi_def_cfa_offset 48 +.Ltmp10: + .cfi_offset 3, -24 +.Ltmp11: + .cfi_offset 14, -16 + leaq 16(%rsp), %rdi + leaq 8(%rsp), %rsi + callq GOMP_loop_runtime_next + testb $1, %al + je .LBB3_2 +# BB#1: + leaq 16(%rsp), %rbx + leaq 8(%rsp), %r14 + jmp .LBB3_4 +.LBB3_2: # %omp.exit + callq GOMP_loop_end_nowait + addq $24, %rsp + popq %rbx + popq %r14 + ret + .align 16, 0x90 +.LBB3_3: # %omp.checkNext.loopexit + # in Loop: Header=BB3_4 Depth=1 + movq %rbx, %rdi + movq %r14, %rsi + callq GOMP_loop_runtime_next + testb $1, %al + je .LBB3_2 +.LBB3_4: # %omp.loadIVBounds + # =>This Loop Header: Depth=1 + # Child Loop BB3_7 Depth 2 + # Child Loop BB3_8 Depth 3 + movq 8(%rsp), %rax + decq %rax + movq 16(%rsp), %rcx + cmpq %rax, %rcx + jg .LBB3_3 +# BB#5: # %polly.loop_header2.preheader.lr.ph + # in Loop: Header=BB3_4 Depth=1 + movq %rcx, %rdx + shlq $11, %rdx + leaq (%rdx,%rdx,2), %rdx + jmp .LBB3_7 + .align 16, 0x90 +.LBB3_6: # %polly.loop_header.loopexit + # in Loop: Header=BB3_7 Depth=2 + addq $6144, %rdx # imm = 0x1800 + incq %rcx + cmpq %rax, %rcx + jg .LBB3_3 +.LBB3_7: # %polly.loop_header2.preheader + # Parent Loop BB3_4 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB3_8 Depth 3 + movq $-1536, %rsi # imm = 0xFFFFFFFFFFFFFA00 + xorl %edi, %edi + .align 16, 0x90 +.LBB3_8: # %polly.loop_body3 + # Parent Loop BB3_4 Depth=1 + # Parent Loop BB3_7 Depth=2 + # => This Inner Loop Header: Depth=3 + movl %edi, %r8d + sarl $31, %r8d + shrl $22, %r8d + addl %edi, %r8d + andl $-1024, %r8d # imm = 0xFFFFFFFFFFFFFC00 + negl %r8d + leal 1(%rdi,%r8), %r8d + cvtsi2sd %r8d, %xmm0 + mulsd .LCPI3_0(%rip), %xmm0 + cvtsd2ss %xmm0, %xmm0 + movss %xmm0, A+6144(%rdx,%rsi,4) + movss %xmm0, B+6144(%rdx,%rsi,4) + addl %ecx, %edi + incq %rsi + jne .LBB3_8 + jmp .LBB3_6 +.Ltmp12: + .size init_array.omp_subfn, .Ltmp12-init_array.omp_subfn +.Ltmp13: + .cfi_endproc +.Leh_func_end3: + + .align 16, 0x90 + .type main.omp_subfn, at function +main.omp_subfn: # @main.omp_subfn +.Leh_func_begin4: +.Ltmp20: + .cfi_startproc +# BB#0: # %omp.setup + pushq %r15 +.Ltmp21: + .cfi_def_cfa_offset 16 + pushq %r14 +.Ltmp22: + .cfi_def_cfa_offset 24 + pushq %r13 +.Ltmp23: + .cfi_def_cfa_offset 32 + pushq %r12 +.Ltmp24: + .cfi_def_cfa_offset 40 + pushq %rbx +.Ltmp25: + .cfi_def_cfa_offset 48 + subq $16, %rsp +.Ltmp26: + .cfi_def_cfa_offset 64 +.Ltmp27: + .cfi_offset 3, -48 +.Ltmp28: + .cfi_offset 12, -40 +.Ltmp29: + .cfi_offset 13, -32 +.Ltmp30: + .cfi_offset 14, -24 +.Ltmp31: + .cfi_offset 15, -16 + leaq 8(%rsp), %rdi + leaq (%rsp), %rsi + callq GOMP_loop_runtime_next + testb $1, %al + je .LBB4_2 +# BB#1: + leaq 8(%rsp), %rbx + leaq (%rsp), %r14 + jmp .LBB4_4 +.LBB4_2: # %omp.exit + callq GOMP_loop_end_nowait + addq $16, %rsp + popq %rbx + popq %r12 + popq %r13 + popq %r14 + popq %r15 + ret + .align 16, 0x90 +.LBB4_3: # %omp.checkNext.loopexit + # in Loop: Header=BB4_4 Depth=1 + movq %rbx, %rdi + movq %r14, %rsi + callq GOMP_loop_runtime_next + testb $1, %al + je .LBB4_2 +.LBB4_4: # %omp.loadIVBounds + # =>This Loop Header: Depth=1 + # Child Loop BB4_6 Depth 2 + movq (%rsp), %r15 + decq %r15 + movq 8(%rsp), %r12 + cmpq %r15, %r12 + jg .LBB4_3 +# BB#5: # %polly.loop_header2.preheader.lr.ph + # in Loop: Header=BB4_4 Depth=1 + leaq (%r12,%r12,2), %rax + shlq $11, %rax + leaq C(%rax), %r13 + .align 16, 0x90 +.LBB4_6: # %polly.loop_header2.preheader + # Parent Loop BB4_4 Depth=1 + # => This Inner Loop Header: Depth=2 + movq %r13, %rdi + xorl %esi, %esi + movl $6144, %edx # imm = 0x1800 + callq memset + addq $6144, %r13 # imm = 0x1800 + incq %r12 + cmpq %r15, %r12 + jle .LBB4_6 + jmp .LBB4_3 +.Ltmp32: + .size main.omp_subfn, .Ltmp32-main.omp_subfn +.Ltmp33: + .cfi_endproc +.Leh_func_end4: + + .align 16, 0x90 + .type main.omp_subfn1, at function +main.omp_subfn1: # @main.omp_subfn1 +.Leh_func_begin5: +.Ltmp41: + .cfi_startproc +# BB#0: # %omp.setup + pushq %rbp +.Ltmp42: + .cfi_def_cfa_offset 16 + pushq %r15 +.Ltmp43: + .cfi_def_cfa_offset 24 + pushq %r14 +.Ltmp44: + .cfi_def_cfa_offset 32 + pushq %r13 +.Ltmp45: + .cfi_def_cfa_offset 40 + pushq %r12 +.Ltmp46: + .cfi_def_cfa_offset 48 + pushq %rbx +.Ltmp47: + .cfi_def_cfa_offset 56 + subq $40, %rsp +.Ltmp48: + .cfi_def_cfa_offset 96 +.Ltmp49: + .cfi_offset 3, -56 +.Ltmp50: + .cfi_offset 12, -48 +.Ltmp51: + .cfi_offset 13, -40 +.Ltmp52: + .cfi_offset 14, -32 +.Ltmp53: + .cfi_offset 15, -24 +.Ltmp54: + .cfi_offset 6, -16 + leaq 32(%rsp), %rdi + leaq 24(%rsp), %rsi + jmp .LBB5_1 + .align 16, 0x90 +.LBB5_4: # %omp.loadIVBounds + # in Loop: Header=BB5_1 Depth=1 + movq 24(%rsp), %rax + decq %rax + movq %rax, (%rsp) # 8-byte Spill + movq 32(%rsp), %rcx + cmpq %rax, %rcx + jg .LBB5_3 +# BB#5: # %polly.loop_header2.preheader.lr.ph + # in Loop: Header=BB5_1 Depth=1 + leaq (%rcx,%rcx,2), %rax + movq %rcx, %rdx + shlq $9, %rdx + leaq (%rdx,%rdx,2), %rdx + movq %rdx, 16(%rsp) # 8-byte Spill + shlq $11, %rax + leaq A(%rax), %rax + movq %rax, 8(%rsp) # 8-byte Spill + jmp .LBB5_7 + .align 16, 0x90 +.LBB5_6: # %polly.loop_header.loopexit + # in Loop: Header=BB5_7 Depth=2 + addq $98304, 16(%rsp) # 8-byte Folded Spill + # imm = 0x18000 + addq $393216, 8(%rsp) # 8-byte Folded Spill + # imm = 0x60000 + addq $64, %rcx + cmpq (%rsp), %rcx # 8-byte Folded Reload + jg .LBB5_3 +.LBB5_7: # %polly.loop_header2.preheader + # Parent Loop BB5_1 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB5_9 Depth 3 + # Child Loop BB5_11 Depth 4 + # Child Loop BB5_14 Depth 5 + # Child Loop BB5_18 Depth 6 + # Child Loop BB5_19 Depth 7 + leaq 63(%rcx), %rax + xorl %edx, %edx + jmp .LBB5_9 + .align 16, 0x90 +.LBB5_8: # %polly.loop_header2.loopexit + # in Loop: Header=BB5_9 Depth=3 + addq $64, %rdx + cmpq $1536, %rdx # imm = 0x600 + je .LBB5_6 +.LBB5_9: # %polly.loop_header7.preheader + # Parent Loop BB5_1 Depth=1 + # Parent Loop BB5_7 Depth=2 + # => This Loop Header: Depth=3 + # Child Loop BB5_11 Depth 4 + # Child Loop BB5_14 Depth 5 + # Child Loop BB5_18 Depth 6 + # Child Loop BB5_19 Depth 7 + movq 16(%rsp), %rsi # 8-byte Reload + leaq (%rsi,%rdx), %rsi + leaq 63(%rdx), %rdi + xorl %r8d, %r8d + movq 8(%rsp), %r9 # 8-byte Reload + movq %rdx, %r10 + jmp .LBB5_11 + .align 16, 0x90 +.LBB5_10: # %polly.loop_header7.loopexit + # in Loop: Header=BB5_11 Depth=4 + addq $256, %r9 # imm = 0x100 + addq $98304, %r10 # imm = 0x18000 + addq $64, %r8 + cmpq $1536, %r8 # imm = 0x600 + je .LBB5_8 +.LBB5_11: # %polly.loop_body8 + # Parent Loop BB5_1 Depth=1 + # Parent Loop BB5_7 Depth=2 + # Parent Loop BB5_9 Depth=3 + # => This Loop Header: Depth=4 + # Child Loop BB5_14 Depth 5 + # Child Loop BB5_18 Depth 6 + # Child Loop BB5_19 Depth 7 + movabsq $9223372036854775744, %r11 # imm = 0x7FFFFFFFFFFFFFC0 + cmpq %r11, %rcx + jg .LBB5_10 +# BB#12: # %polly.loop_body13.lr.ph + # in Loop: Header=BB5_11 Depth=4 + leaq 63(%r8), %r11 + movq %rcx, %rbx + movq %rsi, %r14 + movq %r9, %r15 + jmp .LBB5_14 + .align 16, 0x90 +.LBB5_13: # %polly.loop_header12.loopexit + # in Loop: Header=BB5_14 Depth=5 + addq $1536, %r14 # imm = 0x600 + addq $6144, %r15 # imm = 0x1800 + incq %rbx + cmpq %rax, %rbx + jg .LBB5_10 +.LBB5_14: # %polly.loop_body13 + # Parent Loop BB5_1 Depth=1 + # Parent Loop BB5_7 Depth=2 + # Parent Loop BB5_9 Depth=3 + # Parent Loop BB5_11 Depth=4 + # => This Loop Header: Depth=5 + # Child Loop BB5_18 Depth 6 + # Child Loop BB5_19 Depth 7 + cmpq %r11, %r8 + jg .LBB5_13 +# BB#15: # %polly.loop_body13 + # in Loop: Header=BB5_14 Depth=5 + cmpq %rdi, %rdx + jg .LBB5_13 +# BB#16: # %polly.loop_body23.lr.ph.preheader + # in Loop: Header=BB5_14 Depth=5 + xorl %r12d, %r12d + movq %r10, %r13 + jmp .LBB5_18 + .align 16, 0x90 +.LBB5_17: # %polly.loop_header17.loopexit + # in Loop: Header=BB5_18 Depth=6 + addq $1536, %r13 # imm = 0x600 + incq %r12 + cmpq $64, %r12 + je .LBB5_13 +.LBB5_18: # %polly.loop_body23.lr.ph + # Parent Loop BB5_1 Depth=1 + # Parent Loop BB5_7 Depth=2 + # Parent Loop BB5_9 Depth=3 + # Parent Loop BB5_11 Depth=4 + # Parent Loop BB5_14 Depth=5 + # => This Loop Header: Depth=6 + # Child Loop BB5_19 Depth 7 + movss (%r15,%r12,4), %xmm0 + pshufd $0, %xmm0, %xmm0 # xmm0 = xmm0[0,0,0,0] + xorl %ebp, %ebp + .align 16, 0x90 +.LBB5_19: # %polly.loop_body23 + # Parent Loop BB5_1 Depth=1 + # Parent Loop BB5_7 Depth=2 + # Parent Loop BB5_9 Depth=3 + # Parent Loop BB5_11 Depth=4 + # Parent Loop BB5_14 Depth=5 + # Parent Loop BB5_18 Depth=6 + # => This Inner Loop Header: Depth=7 + movaps B(%rbp,%r13,4), %xmm1 + mulps %xmm0, %xmm1 + addps C(%rbp,%r14,4), %xmm1 + movaps %xmm1, C(%rbp,%r14,4) + addq $16, %rbp + cmpq $256, %rbp # imm = 0x100 + jne .LBB5_19 + jmp .LBB5_17 +.LBB5_3: # %omp.checkNext.loopexit + # in Loop: Header=BB5_1 Depth=1 + leaq 32(%rsp), %rax + movq %rax, %rdi + leaq 24(%rsp), %rax + movq %rax, %rsi +.LBB5_1: # %omp.setup + # =>This Loop Header: Depth=1 + # Child Loop BB5_7 Depth 2 + # Child Loop BB5_9 Depth 3 + # Child Loop BB5_11 Depth 4 + # Child Loop BB5_14 Depth 5 + # Child Loop BB5_18 Depth 6 + # Child Loop BB5_19 Depth 7 + callq GOMP_loop_runtime_next + testb $1, %al + jne .LBB5_4 +# BB#2: # %omp.exit + callq GOMP_loop_end_nowait + addq $40, %rsp + popq %rbx + popq %r12 + popq %r13 + popq %r14 + popq %r15 + popq %rbp + ret +.Ltmp55: + .size main.omp_subfn1, .Ltmp55-main.omp_subfn1 +.Ltmp56: + .cfi_endproc +.Leh_func_end5: + + .type A, at object # @A + .comm A,9437184,16 + .type B, at object # @B + .comm B,9437184,16 + .type .L.str, at object # @.str + .section .rodata.str1.1,"aMS", at progbits,1 +.L.str: + .asciz "%lf " + .size .L.str, 5 + + .type C, at object # @C + .comm C,9437184,16 + + .section ".note.GNU-stack","", at progbits Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.exe URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector.exe?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.exe (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.exe Mon May 2 02:48:29 2011 differ Propchange: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.exe ------------------------------------------------------------------------------ svn:executable = * Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector.ll?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.ll (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.ll Mon May 2 02:48:29 2011 differ Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.s URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled%2Bvector.s?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.s (added) +++ polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled+vector.s Mon May 2 02:48:29 2011 @@ -0,0 +1,318 @@ + .file "matmul.polly.interchanged+tiled+vector.ll" + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI0_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl init_array + .align 16, 0x90 + .type init_array, at function +init_array: # @init_array +# BB#0: # %pollyBB + xorl %eax, %eax + movsd .LCPI0_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB0_2: # %polly.loop_header1.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB0_3 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB0_3: # %polly.loop_body2 + # Parent Loop BB0_2 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB0_3 +# BB#1: # %polly.loop_header.loopexit + # in Loop: Header=BB0_2 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB0_2 +# BB#4: # %polly.after_loop + ret +.Ltmp0: + .size init_array, .Ltmp0-init_array + + .globl print_array + .align 16, 0x90 + .type print_array, at function +print_array: # @print_array +# BB#0: + pushq %r14 + pushq %rbx + pushq %rax + movq $-9437184, %rbx # imm = 0xFFFFFFFFFF700000 + .align 16, 0x90 +.LBB1_1: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB1_2 Depth 2 + xorl %r14d, %r14d + movq stdout(%rip), %rdi + .align 16, 0x90 +.LBB1_2: # Parent Loop BB1_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movss C+9437184(%rbx,%r14,4), %xmm0 + cvtss2sd %xmm0, %xmm0 + movl $.L.str, %esi + movb $1, %al + callq fprintf + movslq %r14d, %rax + imulq $1717986919, %rax, %rcx # imm = 0x66666667 + movq %rcx, %rdx + shrq $63, %rdx + sarq $37, %rcx + addl %edx, %ecx + imull $80, %ecx, %ecx + subl %ecx, %eax + cmpl $79, %eax + jne .LBB1_4 +# BB#3: # in Loop: Header=BB1_2 Depth=2 + movq stdout(%rip), %rsi + movl $10, %edi + callq fputc +.LBB1_4: # in Loop: Header=BB1_2 Depth=2 + incq %r14 + movq stdout(%rip), %rsi + cmpq $1536, %r14 # imm = 0x600 + movq %rsi, %rdi + jne .LBB1_2 +# BB#5: # in Loop: Header=BB1_1 Depth=1 + movl $10, %edi + callq fputc + addq $6144, %rbx # imm = 0x1800 + jne .LBB1_1 +# BB#6: + addq $8, %rsp + popq %rbx + popq %r14 + ret +.Ltmp1: + .size print_array, .Ltmp1-print_array + + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI2_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl main + .align 16, 0x90 + .type main, at function +main: # @main +# BB#0: # %pollyBB + pushq %rbp + pushq %r15 + pushq %r14 + pushq %r13 + pushq %r12 + pushq %rbx + subq $24, %rsp + xorl %eax, %eax + movsd .LCPI2_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB2_1: # %polly.loop_header1.preheader.i + # =>This Loop Header: Depth=1 + # Child Loop BB2_2 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB2_2: # %polly.loop_body2.i + # Parent Loop BB2_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB2_2 +# BB#3: # %polly.loop_header.loopexit.i + # in Loop: Header=BB2_1 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB2_1 +# BB#4: # %polly.loop_header.preheader + movl $C, %edi + xorl %esi, %esi + movl $9437184, %edx # imm = 0x900000 + callq memset + xorl %eax, %eax + movq %rax, 16(%rsp) # 8-byte Spill + movq %rax, (%rsp) # 8-byte Spill + jmp .LBB2_6 + .align 16, 0x90 +.LBB2_5: # %polly.loop_header7.loopexit + # in Loop: Header=BB2_6 Depth=1 + addq $393216, (%rsp) # 8-byte Folded Spill + # imm = 0x60000 + movq 16(%rsp), %rax # 8-byte Reload + addq $64, %rax + movq %rax, 16(%rsp) # 8-byte Spill + cmpq $1536, %rax # imm = 0x600 + je .LBB2_7 +.LBB2_6: # %polly.loop_header12.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB2_9 Depth 2 + # Child Loop BB2_11 Depth 3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + movq 16(%rsp), %rax # 8-byte Reload + leaq 63(%rax), %rax + movq (%rsp), %rcx # 8-byte Reload + leaq A(%rcx), %rdx + movq %rdx, 8(%rsp) # 8-byte Spill + xorl %edx, %edx + jmp .LBB2_9 + .align 16, 0x90 +.LBB2_8: # %polly.loop_header12.loopexit + # in Loop: Header=BB2_9 Depth=2 + addq $256, %rcx # imm = 0x100 + addq $64, %rdx + cmpq $1536, %rdx # imm = 0x600 + je .LBB2_5 +.LBB2_9: # %polly.loop_header17.preheader + # Parent Loop BB2_6 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB2_11 Depth 3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + leaq 63(%rdx), %rsi + xorl %edi, %edi + movq 8(%rsp), %r8 # 8-byte Reload + movq %rdx, %r9 + jmp .LBB2_11 + .align 16, 0x90 +.LBB2_10: # %polly.loop_header17.loopexit + # in Loop: Header=BB2_11 Depth=3 + addq $256, %r8 # imm = 0x100 + addq $98304, %r9 # imm = 0x18000 + addq $64, %rdi + cmpq $1536, %rdi # imm = 0x600 + je .LBB2_8 +.LBB2_11: # %polly.loop_body18 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # => This Loop Header: Depth=3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + cmpq %rax, 16(%rsp) # 8-byte Folded Reload + jg .LBB2_10 +# BB#12: # %polly.loop_body23.lr.ph + # in Loop: Header=BB2_11 Depth=3 + leaq 63(%rdi), %r10 + xorl %r11d, %r11d + jmp .LBB2_14 + .align 16, 0x90 +.LBB2_13: # %polly.loop_header22.loopexit + # in Loop: Header=BB2_14 Depth=4 + addq $6144, %r11 # imm = 0x1800 + cmpq $393216, %r11 # imm = 0x60000 + je .LBB2_10 +.LBB2_14: # %polly.loop_body23 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # => This Loop Header: Depth=4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + cmpq %r10, %rdi + jg .LBB2_13 +# BB#15: # %polly.loop_body23 + # in Loop: Header=BB2_14 Depth=4 + cmpq %rsi, %rdx + jg .LBB2_13 +# BB#16: # %polly.loop_body33.lr.ph.preheader + # in Loop: Header=BB2_14 Depth=4 + leaq (%r8,%r11), %rbx + xorl %r14d, %r14d + movq %r9, %r15 + movq %r14, %r12 + jmp .LBB2_18 + .align 16, 0x90 +.LBB2_17: # %polly.loop_header27.loopexit + # in Loop: Header=BB2_18 Depth=5 + addq $1536, %r15 # imm = 0x600 + incq %r12 + cmpq $64, %r12 + je .LBB2_13 +.LBB2_18: # %polly.loop_body33.lr.ph + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # Parent Loop BB2_14 Depth=4 + # => This Loop Header: Depth=5 + # Child Loop BB2_19 Depth 6 + movss (%rbx,%r12,4), %xmm0 + pshufd $0, %xmm0, %xmm0 # xmm0 = xmm0[0,0,0,0] + movq %r14, %r13 + .align 16, 0x90 +.LBB2_19: # %polly.loop_body33 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # Parent Loop BB2_14 Depth=4 + # Parent Loop BB2_18 Depth=5 + # => This Inner Loop Header: Depth=6 + movaps B(%r13,%r15,4), %xmm1 + mulps %xmm0, %xmm1 + leaq (%r11,%r13), %rbp + addps C(%rcx,%rbp), %xmm1 + movaps %xmm1, C(%rcx,%rbp) + addq $16, %r13 + cmpq $256, %r13 # imm = 0x100 + jne .LBB2_19 + jmp .LBB2_17 +.LBB2_7: # %polly.after_loop9 + xorl %eax, %eax + addq $24, %rsp + popq %rbx + popq %r12 + popq %r13 + popq %r14 + popq %r15 + popq %rbp + ret +.Ltmp2: + .size main, .Ltmp2-main + + .type A, at object # @A + .comm A,9437184,16 + .type B, at object # @B + .comm B,9437184,16 + .type .L.str, at object # @.str + .section .rodata.str1.1,"aMS", at progbits,1 +.L.str: + .asciz "%lf " + .size .L.str, 5 + + .type C, at object # @C + .comm C,9437184,16 + + .section ".note.GNU-stack","", at progbits Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.exe URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled.exe?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.exe (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.exe Mon May 2 02:48:29 2011 differ Propchange: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.exe ------------------------------------------------------------------------------ svn:executable = * Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled.ll?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.ll (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.ll Mon May 2 02:48:29 2011 differ Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.s URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged%2Btiled.s?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.s (added) +++ polly/trunk/www/experiments/matmul/matmul.polly.interchanged+tiled.s Mon May 2 02:48:29 2011 @@ -0,0 +1,323 @@ + .file "matmul.polly.interchanged+tiled.ll" + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI0_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl init_array + .align 16, 0x90 + .type init_array, at function +init_array: # @init_array +# BB#0: # %pollyBB + xorl %eax, %eax + movsd .LCPI0_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB0_2: # %polly.loop_header1.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB0_3 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB0_3: # %polly.loop_body2 + # Parent Loop BB0_2 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB0_3 +# BB#1: # %polly.loop_header.loopexit + # in Loop: Header=BB0_2 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB0_2 +# BB#4: # %polly.after_loop + ret +.Ltmp0: + .size init_array, .Ltmp0-init_array + + .globl print_array + .align 16, 0x90 + .type print_array, at function +print_array: # @print_array +# BB#0: + pushq %r14 + pushq %rbx + pushq %rax + movq $-9437184, %rbx # imm = 0xFFFFFFFFFF700000 + .align 16, 0x90 +.LBB1_1: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB1_2 Depth 2 + xorl %r14d, %r14d + movq stdout(%rip), %rdi + .align 16, 0x90 +.LBB1_2: # Parent Loop BB1_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movss C+9437184(%rbx,%r14,4), %xmm0 + cvtss2sd %xmm0, %xmm0 + movl $.L.str, %esi + movb $1, %al + callq fprintf + movslq %r14d, %rax + imulq $1717986919, %rax, %rcx # imm = 0x66666667 + movq %rcx, %rdx + shrq $63, %rdx + sarq $37, %rcx + addl %edx, %ecx + imull $80, %ecx, %ecx + subl %ecx, %eax + cmpl $79, %eax + jne .LBB1_4 +# BB#3: # in Loop: Header=BB1_2 Depth=2 + movq stdout(%rip), %rsi + movl $10, %edi + callq fputc +.LBB1_4: # in Loop: Header=BB1_2 Depth=2 + incq %r14 + movq stdout(%rip), %rsi + cmpq $1536, %r14 # imm = 0x600 + movq %rsi, %rdi + jne .LBB1_2 +# BB#5: # in Loop: Header=BB1_1 Depth=1 + movl $10, %edi + callq fputc + addq $6144, %rbx # imm = 0x1800 + jne .LBB1_1 +# BB#6: + addq $8, %rsp + popq %rbx + popq %r14 + ret +.Ltmp1: + .size print_array, .Ltmp1-print_array + + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI2_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl main + .align 16, 0x90 + .type main, at function +main: # @main +# BB#0: # %pollyBB + pushq %rbp + pushq %r15 + pushq %r14 + pushq %r13 + pushq %r12 + pushq %rbx + subq $40, %rsp + xorl %eax, %eax + movsd .LCPI2_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB2_1: # %polly.loop_header1.preheader.i + # =>This Loop Header: Depth=1 + # Child Loop BB2_2 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB2_2: # %polly.loop_body2.i + # Parent Loop BB2_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB2_2 +# BB#3: # %polly.loop_header.loopexit.i + # in Loop: Header=BB2_1 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB2_1 +# BB#4: # %polly.loop_header.preheader + movl $C, %eax + movq %rax, 8(%rsp) # 8-byte Spill + xorl %esi, %esi + movl $9437184, %edx # imm = 0x900000 + movl $C, %edi + callq memset + movl $A, %eax + movq %rax, 16(%rsp) # 8-byte Spill + movq $0, 32(%rsp) # 8-byte Folded Spill + jmp .LBB2_6 + .align 16, 0x90 +.LBB2_5: # %polly.loop_header7.loopexit + # in Loop: Header=BB2_6 Depth=1 + addq $393216, 16(%rsp) # 8-byte Folded Spill + # imm = 0x60000 + addq $393216, 8(%rsp) # 8-byte Folded Spill + # imm = 0x60000 + movq 32(%rsp), %rax # 8-byte Reload + addq $64, %rax + movq %rax, 32(%rsp) # 8-byte Spill + cmpq $1536, %rax # imm = 0x600 + je .LBB2_7 +.LBB2_6: # %polly.loop_header12.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB2_9 Depth 2 + # Child Loop BB2_11 Depth 3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + movq 32(%rsp), %rax # 8-byte Reload + leaq 63(%rax), %rax + movl $B, %ecx + movq %rcx, 24(%rsp) # 8-byte Spill + xorl %ecx, %ecx + movq 8(%rsp), %rdx # 8-byte Reload + jmp .LBB2_9 + .align 16, 0x90 +.LBB2_8: # %polly.loop_header12.loopexit + # in Loop: Header=BB2_9 Depth=2 + addq $256, %rdx # imm = 0x100 + addq $256, 24(%rsp) # 8-byte Folded Spill + # imm = 0x100 + addq $64, %rcx + cmpq $1536, %rcx # imm = 0x600 + je .LBB2_5 +.LBB2_9: # %polly.loop_header17.preheader + # Parent Loop BB2_6 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB2_11 Depth 3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + leaq 63(%rcx), %rsi + xorl %edi, %edi + movq 16(%rsp), %r8 # 8-byte Reload + movq 24(%rsp), %r9 # 8-byte Reload + jmp .LBB2_11 + .align 16, 0x90 +.LBB2_10: # %polly.loop_header17.loopexit + # in Loop: Header=BB2_11 Depth=3 + addq $256, %r8 # imm = 0x100 + addq $393216, %r9 # imm = 0x60000 + addq $64, %rdi + cmpq $1536, %rdi # imm = 0x600 + je .LBB2_8 +.LBB2_11: # %polly.loop_body18 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # => This Loop Header: Depth=3 + # Child Loop BB2_14 Depth 4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + cmpq %rax, 32(%rsp) # 8-byte Folded Reload + jg .LBB2_10 +# BB#12: # %polly.loop_body23.lr.ph + # in Loop: Header=BB2_11 Depth=3 + leaq 63(%rdi), %r10 + xorl %r11d, %r11d + jmp .LBB2_14 + .align 16, 0x90 +.LBB2_13: # %polly.loop_header22.loopexit + # in Loop: Header=BB2_14 Depth=4 + addq $6144, %r11 # imm = 0x1800 + cmpq $393216, %r11 # imm = 0x60000 + je .LBB2_10 +.LBB2_14: # %polly.loop_body23 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # => This Loop Header: Depth=4 + # Child Loop BB2_18 Depth 5 + # Child Loop BB2_19 Depth 6 + cmpq %r10, %rdi + jg .LBB2_13 +# BB#15: # %polly.loop_body23 + # in Loop: Header=BB2_14 Depth=4 + cmpq %rsi, %rcx + jg .LBB2_13 +# BB#16: # %polly.loop_body33.lr.ph.preheader + # in Loop: Header=BB2_14 Depth=4 + leaq (%rdx,%r11), %rbx + leaq (%r8,%r11), %r14 + xorl %r15d, %r15d + movq %r9, %r12 + movq %r15, %r13 + jmp .LBB2_18 + .align 16, 0x90 +.LBB2_17: # %polly.loop_header27.loopexit + # in Loop: Header=BB2_18 Depth=5 + addq $6144, %r12 # imm = 0x1800 + incq %r13 + cmpq $64, %r13 + je .LBB2_13 +.LBB2_18: # %polly.loop_body33.lr.ph + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # Parent Loop BB2_14 Depth=4 + # => This Loop Header: Depth=5 + # Child Loop BB2_19 Depth 6 + movss (%r14,%r13,4), %xmm0 + movq %r15, %rbp + .align 16, 0x90 +.LBB2_19: # %polly.loop_body33 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # Parent Loop BB2_11 Depth=3 + # Parent Loop BB2_14 Depth=4 + # Parent Loop BB2_18 Depth=5 + # => This Inner Loop Header: Depth=6 + movss (%r12,%rbp,4), %xmm1 + mulss %xmm0, %xmm1 + addss (%rbx,%rbp,4), %xmm1 + movss %xmm1, (%rbx,%rbp,4) + incq %rbp + cmpq $64, %rbp + jne .LBB2_19 + jmp .LBB2_17 +.LBB2_7: # %polly.after_loop9 + xorl %eax, %eax + addq $40, %rsp + popq %rbx + popq %r12 + popq %r13 + popq %r14 + popq %r15 + popq %rbp + ret +.Ltmp2: + .size main, .Ltmp2-main + + .type A, at object # @A + .comm A,9437184,16 + .type B, at object # @B + .comm B,9437184,16 + .type .L.str, at object # @.str + .section .rodata.str1.1,"aMS", at progbits,1 +.L.str: + .asciz "%lf " + .size .L.str, 5 + + .type C, at object # @C + .comm C,9437184,16 + + .section ".note.GNU-stack","", at progbits Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe Mon May 2 02:48:29 2011 differ Propchange: polly/trunk/www/experiments/matmul/matmul.polly.interchanged.exe ------------------------------------------------------------------------------ svn:executable = * Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged.ll?rev=130689&view=auto ============================================================================== Binary files polly/trunk/www/experiments/matmul/matmul.polly.interchanged.ll (added) and polly/trunk/www/experiments/matmul/matmul.polly.interchanged.ll Mon May 2 02:48:29 2011 differ Added: polly/trunk/www/experiments/matmul/matmul.polly.interchanged.s URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.polly.interchanged.s?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.polly.interchanged.s (added) +++ polly/trunk/www/experiments/matmul/matmul.polly.interchanged.s Mon May 2 02:48:29 2011 @@ -0,0 +1,217 @@ + .file "matmul.polly.interchanged.ll" + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI0_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl init_array + .align 16, 0x90 + .type init_array, at function +init_array: # @init_array +# BB#0: # %pollyBB + xorl %eax, %eax + movsd .LCPI0_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB0_2: # %polly.loop_header1.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB0_3 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB0_3: # %polly.loop_body2 + # Parent Loop BB0_2 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB0_3 +# BB#1: # %polly.loop_header.loopexit + # in Loop: Header=BB0_2 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB0_2 +# BB#4: # %polly.after_loop + ret +.Ltmp0: + .size init_array, .Ltmp0-init_array + + .globl print_array + .align 16, 0x90 + .type print_array, at function +print_array: # @print_array +# BB#0: + pushq %r14 + pushq %rbx + pushq %rax + movq $-9437184, %rbx # imm = 0xFFFFFFFFFF700000 + .align 16, 0x90 +.LBB1_1: # %.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB1_2 Depth 2 + xorl %r14d, %r14d + movq stdout(%rip), %rdi + .align 16, 0x90 +.LBB1_2: # Parent Loop BB1_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movss C+9437184(%rbx,%r14,4), %xmm0 + cvtss2sd %xmm0, %xmm0 + movl $.L.str, %esi + movb $1, %al + callq fprintf + movslq %r14d, %rax + imulq $1717986919, %rax, %rcx # imm = 0x66666667 + movq %rcx, %rdx + shrq $63, %rdx + sarq $37, %rcx + addl %edx, %ecx + imull $80, %ecx, %ecx + subl %ecx, %eax + cmpl $79, %eax + jne .LBB1_4 +# BB#3: # in Loop: Header=BB1_2 Depth=2 + movq stdout(%rip), %rsi + movl $10, %edi + callq fputc +.LBB1_4: # in Loop: Header=BB1_2 Depth=2 + incq %r14 + movq stdout(%rip), %rsi + cmpq $1536, %r14 # imm = 0x600 + movq %rsi, %rdi + jne .LBB1_2 +# BB#5: # in Loop: Header=BB1_1 Depth=1 + movl $10, %edi + callq fputc + addq $6144, %rbx # imm = 0x1800 + jne .LBB1_1 +# BB#6: + addq $8, %rsp + popq %rbx + popq %r14 + ret +.Ltmp1: + .size print_array, .Ltmp1-print_array + + .section .rodata.cst8,"aM", at progbits,8 + .align 8 +.LCPI2_0: + .quad 4602678819172646912 # double 5.000000e-01 + .text + .globl main + .align 16, 0x90 + .type main, at function +main: # @main +# BB#0: # %pollyBB + pushq %rax + xorl %eax, %eax + movsd .LCPI2_0(%rip), %xmm0 + movq %rax, %rcx + .align 16, 0x90 +.LBB2_1: # %polly.loop_header1.preheader.i + # =>This Loop Header: Depth=1 + # Child Loop BB2_2 Depth 2 + movq $-1536, %rdx # imm = 0xFFFFFFFFFFFFFA00 + xorl %esi, %esi + .align 16, 0x90 +.LBB2_2: # %polly.loop_body2.i + # Parent Loop BB2_1 Depth=1 + # => This Inner Loop Header: Depth=2 + movl %esi, %edi + sarl $31, %edi + shrl $22, %edi + addl %esi, %edi + andl $-1024, %edi # imm = 0xFFFFFFFFFFFFFC00 + negl %edi + leal 1(%rsi,%rdi), %edi + cvtsi2sd %edi, %xmm1 + mulsd %xmm0, %xmm1 + cvtsd2ss %xmm1, %xmm1 + movss %xmm1, A+6144(%rax,%rdx,4) + movss %xmm1, B+6144(%rax,%rdx,4) + addl %ecx, %esi + incq %rdx + jne .LBB2_2 +# BB#3: # %polly.loop_header.loopexit.i + # in Loop: Header=BB2_1 Depth=1 + addq $6144, %rax # imm = 0x1800 + incq %rcx + cmpq $1536, %rcx # imm = 0x600 + jne .LBB2_1 +# BB#4: # %polly.loop_header.preheader + movl $C, %edi + xorl %esi, %esi + movl $9437184, %edx # imm = 0x900000 + callq memset + xorl %eax, %eax + jmp .LBB2_6 + .align 16, 0x90 +.LBB2_5: # %polly.loop_header7.loopexit + # in Loop: Header=BB2_6 Depth=1 + addq $6144, %rax # imm = 0x1800 + cmpq $9437184, %rax # imm = 0x900000 + je .LBB2_7 +.LBB2_6: # %polly.loop_header12.preheader + # =>This Loop Header: Depth=1 + # Child Loop BB2_9 Depth 2 + # Child Loop BB2_10 Depth 3 + leaq A(%rax), %rcx + movq $-9437184, %rdx # imm = 0xFFFFFFFFFF700000 + jmp .LBB2_9 + .align 16, 0x90 +.LBB2_8: # %polly.loop_header12.loopexit + # in Loop: Header=BB2_9 Depth=2 + addq $4, %rcx + addq $6144, %rdx # imm = 0x1800 + je .LBB2_5 +.LBB2_9: # %polly.loop_header17.preheader + # Parent Loop BB2_6 Depth=1 + # => This Loop Header: Depth=2 + # Child Loop BB2_10 Depth 3 + movss (%rcx), %xmm0 + xorl %esi, %esi + .align 16, 0x90 +.LBB2_10: # %polly.loop_body18 + # Parent Loop BB2_6 Depth=1 + # Parent Loop BB2_9 Depth=2 + # => This Inner Loop Header: Depth=3 + movss B+9437184(%rdx,%rsi,4), %xmm1 + mulss %xmm0, %xmm1 + addss C(%rax,%rsi,4), %xmm1 + movss %xmm1, C(%rax,%rsi,4) + incq %rsi + cmpq $1536, %rsi # imm = 0x600 + jne .LBB2_10 + jmp .LBB2_8 +.LBB2_7: # %polly.after_loop9 + xorl %eax, %eax + popq %rdx + ret +.Ltmp2: + .size main, .Ltmp2-main + + .type A, at object # @A + .comm A,9437184,16 + .type B, at object # @B + .comm B,9437184,16 + .type .L.str, at object # @.str + .section .rodata.str1.1,"aMS", at progbits,1 +.L.str: + .asciz "%lf " + .size .L.str, 5 + + .type C, at object # @C + .comm C,9437184,16 + + .section ".note.GNU-stack","", at progbits Added: polly/trunk/www/experiments/matmul/matmul.preopt.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/experiments/matmul/matmul.preopt.ll?rev=130689&view=auto ============================================================================== --- polly/trunk/www/experiments/matmul/matmul.preopt.ll (added) +++ polly/trunk/www/experiments/matmul/matmul.preopt.ll Mon May 2 02:48:29 2011 @@ -0,0 +1,180 @@ +; ModuleID = 'matmul.s' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-unknown-linux-gnu" + +%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] } +%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 } + + at A = common global [1536 x [1536 x float]] zeroinitializer, align 16 + at B = common global [1536 x [1536 x float]] zeroinitializer, align 16 + at stdout = external global %struct._IO_FILE* + at .str = private unnamed_addr constant [5 x i8] c"%lf \00" + at C = common global [1536 x [1536 x float]] zeroinitializer, align 16 + at .str1 = private unnamed_addr constant [2 x i8] c"\0A\00" + +define void @init_array() nounwind { +;
Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=130756&r1=130755&r2=130756&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue May 3 11:18:28 2011 @@ -51,6 +51,10 @@ ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer) }; TheCU = DICompileUnit(MDNode::get(VMContext, Elts)); + + // Create a named metadata so that it is easier to find cu in a module. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); + NMD->addOperand(TheCU); } /// createFile - Create a file descriptor to hold debugging information From dpatel at apple.com Tue May 3 11:45:22 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 03 May 2011 16:45:22 -0000 Subject: [llvm-commits] [llvm] r130759 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110503164522.EB4642A6C12C@llvm.org> Author: dpatel Date: Tue May 3 11:45:22 2011 New Revision: 130759 URL: http://llvm.org/viewvc/llvm-project?rev=130759&view=rev Log: If the front end has emitted llvm.dbg.cu and other debug info anchors (clang does it now) then use them directly. This saves one scan of entire module, to collect debug info, which in turns saves few machine cycles at compile time. 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=130759&r1=130758&r2=130759&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue May 3 11:45:22 2011 @@ -1113,44 +1113,66 @@ if (DisableDebugInfoPrinting) return; - DebugInfoFinder DbgFinder; - DbgFinder.processModule(*M); - bool HasDebugInfo = false; - // Scan all the compile-units to see if there are any marked as the main unit. - // if not, we do not generate debug info. - for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), - E = DbgFinder.compile_unit_end(); I != E; ++I) { - if (DICompileUnit(*I).isMain()) { + // If module has named metadata anchors then use them, otherwise scan the module + // using debug info finder to collect debug info. + NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu"); + if (CU_Nodes) { + for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { HasDebugInfo = true; - break; + constructCompileUnit(CU_Nodes->getOperand(i)); } - } + if (!HasDebugInfo) + return; - if (!HasDebugInfo) return; + if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv")) + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) + constructGlobalVariableDIE(NMD->getOperand(i)); + + if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp")) + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) + constructSubprogramDIE(NMD->getOperand(i)); + + } else { + DebugInfoFinder DbgFinder; + DbgFinder.processModule(*M); + + // Scan all the compile-units to see if there are any marked as the main unit. + // if not, we do not generate debug info. + for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), + E = DbgFinder.compile_unit_end(); I != E; ++I) { + if (DICompileUnit(*I).isMain()) { + HasDebugInfo = true; + break; + } + } + + // Create all the compile unit DIEs. + for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), + E = DbgFinder.compile_unit_end(); I != E; ++I) + constructCompileUnit(*I); + + // Create DIEs for each global variable. + for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(), + E = DbgFinder.global_variable_end(); I != E; ++I) + constructGlobalVariableDIE(*I); + + // Create DIEs for each subprogram. + for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(), + E = DbgFinder.subprogram_end(); I != E; ++I) + constructSubprogramDIE(*I); + } + + if (!HasDebugInfo) return; + // Tell MMI that we have debug info. MMI->setDebugInfoAvailability(true); - + // Emit initial sections. EmitSectionLabels(); - // Create all the compile unit DIEs. - for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), - E = DbgFinder.compile_unit_end(); I != E; ++I) - constructCompileUnit(*I); - - // Create DIEs for each global variable. - for (DebugInfoFinder::iterator I = DbgFinder.global_variable_begin(), - E = DbgFinder.global_variable_end(); I != E; ++I) - constructGlobalVariableDIE(*I); - - // Create DIEs for each subprogram. - for (DebugInfoFinder::iterator I = DbgFinder.subprogram_begin(), - E = DbgFinder.subprogram_end(); I != E; ++I) - constructSubprogramDIE(*I); - //getOrCreateTypeDIE if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum")) for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { From bob.wilson at apple.com Tue May 3 12:22:56 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 May 2011 17:22:56 -0000 Subject: [llvm-commits] [llvm] r130761 - /llvm/trunk/include/llvm/ADT/Triple.h Message-ID: <20110503172256.638DB2A6C12C@llvm.org> Author: bwilson Date: Tue May 3 12:22:56 2011 New Revision: 130761 URL: http://llvm.org/viewvc/llvm-project?rev=130761&view=rev Log: Fix a comment. Modified: llvm/trunk/include/llvm/ADT/Triple.h Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=130761&r1=130760&r2=130761&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Tue May 3 12:22:56 2011 @@ -225,7 +225,7 @@ /// if the environment component is present). StringRef getOSAndEnvironmentName() const; - /// getOSNumber - Parse the version number from the OS name component of the + /// getOSVersion - Parse the version number from the OS name component of the /// triple, if present. /// /// For example, "fooos1.2.3" would return (1, 2, 3). From bruno.cardoso at gmail.com Tue May 3 12:29:22 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 03 May 2011 17:29:22 -0000 Subject: [llvm-commits] [llvm] r130763 - in /llvm/trunk: include/llvm/IntrinsicsARM.td lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/intrinsics.ll Message-ID: <20110503172922.A8E992A6C12C@llvm.org> Author: bruno Date: Tue May 3 12:29:22 2011 New Revision: 130763 URL: http://llvm.org/viewvc/llvm-project?rev=130763&view=rev Log: Add a few ARM coprocessor intrinsics. Testcases included Added: llvm/trunk/test/CodeGen/ARM/intrinsics.ll Modified: llvm/trunk/include/llvm/IntrinsicsARM.td llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/include/llvm/IntrinsicsARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsARM.td?rev=130763&r1=130762&r2=130763&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsARM.td (original) +++ llvm/trunk/include/llvm/IntrinsicsARM.td Tue May 3 12:29:22 2011 @@ -50,6 +50,43 @@ } //===----------------------------------------------------------------------===// +// Coprocessor + +let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". + // Move to coprocessor + def int_arm_mcr : GCCBuiltin<"__builtin_arm_mcr">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + def int_arm_mcr2 : GCCBuiltin<"__builtin_arm_mcr2">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + + // Move from coprocessor + def int_arm_mrc : GCCBuiltin<"__builtin_arm_mrc">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty], []>; + def int_arm_mrc2 : GCCBuiltin<"__builtin_arm_mrc2">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty], []>; + + // Coprocessor data processing + def int_arm_cdp : GCCBuiltin<"__builtin_arm_cdp">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + def int_arm_cdp2 : GCCBuiltin<"__builtin_arm_cdp2">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + + // Move from two registers to coprocessor + def int_arm_mcrr : GCCBuiltin<"__builtin_arm_mcrr">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty], []>; + def int_arm_mcrr2 : GCCBuiltin<"__builtin_arm_mcrr2">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, + llvm_i32_ty, llvm_i32_ty], []>; +} + +//===----------------------------------------------------------------------===// // Advanced SIMD (NEON) let TargetPrefix = "arm" in { // All intrinsics start with "llvm.arm.". Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=130763&r1=130762&r2=130763&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue May 3 12:29:22 2011 @@ -860,6 +860,9 @@ class ARMPat : Pat { list Predicates = [IsARM]; } +class ARMV5TPat : Pat { + list Predicates = [IsARM, HasV5T]; +} class ARMV5TEPat : Pat { list Predicates = [IsARM, HasV5TE]; } @@ -1208,6 +1211,11 @@ list Predicates = [IsThumb, IsThumb1Only]; } +// T2v6Pat - Same as Pat<>, but requires V6T2 Thumb2 mode. +class T2v6Pat : Pat { + list Predicates = [IsThumb2, HasV6T2]; +} + // T2Pat - Same as Pat<>, but requires that the compiler be in Thumb2 mode. class T2Pat : Pat { list Predicates = [IsThumb2]; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130763&r1=130762&r2=130763&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue May 3 12:29:22 2011 @@ -3415,6 +3415,10 @@ let Inst{23-20} = opc1; } +def : ARMPat<(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2), + (CDP imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, imm:$CRm,imm:$opc2)>; + def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", @@ -3436,6 +3440,11 @@ let Inst{23-20} = opc1; } +def : ARMPat<(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2), + (CDP2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, imm:$CRm, + imm:$opc2)>; + class ACI : InoP; +def : ARMPat<(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2), + (MCR imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, imm:$CRm, imm:$opc2)>; +def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), + (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; + class MovRCopro2 : ABXI<0b1110, oops, iops, NoItinerary, !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), @@ -3604,6 +3619,14 @@ c_imm:$CRn, c_imm:$CRm, i32imm:$opc2)>; +def : ARMV5TPat<(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2), + (MCR2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)>; +def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, + imm:$CRm, imm:$opc2), + (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; + class MovRRCopro : ABI<0b1100, (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), @@ -3628,6 +3651,10 @@ def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */>; def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>; +def : ARMV5TEPat<(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, + imm:$CRm), + (MCRR imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; + class MovRRCopro2 : ABXI<0b1100, (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), @@ -3653,6 +3680,9 @@ def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */>; def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>; +def : ARMV6Pat<(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), + (MCRR2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; + //===----------------------------------------------------------------------===// // Move between special register and ARM core register -- for disassembly only // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=130763&r1=130762&r2=130763&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue May 3 12:29:22 2011 @@ -1381,6 +1381,14 @@ (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2)>; +def : Pat<(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2), + (tMCR imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)>, Requires<[IsThumb, HasV6T2]>; +def : Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), + (tMRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>, + Requires<[IsThumb, HasV6T2]>; + class tMovRRCopro : T1Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), @@ -1405,6 +1413,10 @@ def tMCRR : tMovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */>; def tMRRC : tMovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>; +def : Pat<(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), + (tMCRR imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>, + Requires<[IsThumb, HasV6T2]>; + //===----------------------------------------------------------------------===// // Other Coprocessor Instructions. For disassembly only. // @@ -1430,6 +1442,11 @@ let Inst{23-20} = opc1; } +def : Pat<(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2), + (tCDP imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)>, Requires<[IsThumb, HasV6T2]>; + //===----------------------------------------------------------------------===// // TLS Instructions // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130763&r1=130762&r2=130763&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue May 3 12:29:22 2011 @@ -3376,6 +3376,14 @@ (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2)>; +def : T2v6Pat<(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2), + (t2MCR2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)>; +def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, + imm:$CRm, imm:$opc2), + (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; + class t2MovRRCopro : T2Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), @@ -3402,6 +3410,9 @@ def t2MRRC2 : t2MovRRCopro<"mrrc2", 1 /* from coprocessor to ARM core register */>; +def : T2v6Pat<(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), + (t2MCRR2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; + //===----------------------------------------------------------------------===// // Other Coprocessor Instructions. For disassembly only. // @@ -3427,3 +3438,8 @@ let Inst{19-16} = CRn; let Inst{23-20} = opc1; } + +def : T2v6Pat<(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2), + (t2CDP2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)>; Added: llvm/trunk/test/CodeGen/ARM/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/intrinsics.ll?rev=130763&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/intrinsics.ll (added) +++ llvm/trunk/test/CodeGen/ARM/intrinsics.ll Tue May 3 12:29:22 2011 @@ -0,0 +1,39 @@ +; RUN: llc < %s -mtriple=armv7-eabi -mcpu=cortex-a8 | FileCheck %s +; RUN: llc < %s -march=thumb -mtriple=thumbv7-eabi -mcpu=cortex-a8 | FileCheck %s + +define void @coproc() nounwind { +entry: + ; CHECK: mrc + %0 = tail call i32 @llvm.arm.mrc(i32 7, i32 1, i32 1, i32 1, i32 4) nounwind + ; CHECK: mcr + tail call void @llvm.arm.mcr(i32 7, i32 1, i32 %0, i32 1, i32 1, i32 4) nounwind + ; CHECK: mrc2 + %1 = tail call i32 @llvm.arm.mrc2(i32 7, i32 1, i32 1, i32 1, i32 4) nounwind + ; CHECK: mcr2 + tail call void @llvm.arm.mcr2(i32 7, i32 1, i32 %1, i32 1, i32 1, i32 4) nounwind + ; CHECK: mcrr + tail call void @llvm.arm.mcrr(i32 7, i32 1, i32 %0, i32 %1, i32 1) nounwind + ; CHECK: mcrr2 + tail call void @llvm.arm.mcrr2(i32 7, i32 1, i32 %0, i32 %1, i32 1) nounwind + ; CHECK: cdp + tail call void @llvm.arm.cdp(i32 7, i32 3, i32 1, i32 1, i32 1, i32 5) nounwind + ; CHECK: cdp2 + tail call void @llvm.arm.cdp2(i32 7, i32 3, i32 1, i32 1, i32 1, i32 5) nounwind + ret void +} + +declare void @llvm.arm.cdp2(i32, i32, i32, i32, i32, i32) nounwind + +declare void @llvm.arm.cdp(i32, i32, i32, i32, i32, i32) nounwind + +declare void @llvm.arm.mcrr2(i32, i32, i32, i32, i32) nounwind + +declare void @llvm.arm.mcrr(i32, i32, i32, i32, i32) nounwind + +declare void @llvm.arm.mcr2(i32, i32, i32, i32, i32, i32) nounwind + +declare i32 @llvm.arm.mrc2(i32, i32, i32, i32, i32) nounwind + +declare void @llvm.arm.mcr(i32, i32, i32, i32, i32, i32) nounwind + +declare i32 @llvm.arm.mrc(i32, i32, i32, i32, i32) nounwind From bruno.cardoso at gmail.com Tue May 3 12:29:29 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 03 May 2011 17:29:29 -0000 Subject: [llvm-commits] [llvm] r130764 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <20110503172930.1DF902A6C12C@llvm.org> Author: bruno Date: Tue May 3 12:29:29 2011 New Revision: 130764 URL: http://llvm.org/viewvc/llvm-project?rev=130764&view=rev Log: Fold ARM coprocessor intrinsics patterns into the instructions defs whenever it's possible. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130764&r1=130763&r2=130764&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue May 3 12:29:29 2011 @@ -3398,7 +3398,8 @@ def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", - [/* For disassembly only; pattern left blank */]> { + [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)]> { bits<4> opc1; bits<4> CRn; bits<4> CRd; @@ -3415,14 +3416,11 @@ let Inst{23-20} = opc1; } -def : ARMPat<(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2), - (CDP imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, imm:$CRm,imm:$opc2)>; - def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", - [/* For disassembly only; pattern left blank */]> { + [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)]> { let Inst{31-28} = 0b1111; bits<4> opc1; bits<4> CRn; @@ -3440,11 +3438,6 @@ let Inst{23-20} = opc1; } -def : ARMPat<(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2), - (CDP2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, imm:$CRm, - imm:$opc2)>; - class ACI : InoP +class MovRCopro pattern> : ABI<0b1110, oops, iops, NoItinerary, opc, - "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", - [/* For disassembly only; pattern left blank */]> { + "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> { let Inst{20} = direction; let Inst{4} = 1; @@ -3574,23 +3567,23 @@ } def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */, - (outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, - i32imm:$opc2)>; + (outs), + (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2), + [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)]>; def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */, - (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, - c_imm:$CRn, c_imm:$CRm, i32imm:$opc2)>; + (outs GPR:$Rt), + (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, c_imm:$CRm, + i32imm:$opc2), []>; -def : ARMPat<(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2), - (MCR imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, imm:$CRm, imm:$opc2)>; def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; -class MovRCopro2 +class MovRCopro2 pattern> : ABXI<0b1110, oops, iops, NoItinerary, - !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), - [/* For disassembly only; pattern left blank */]> { + !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> { let Inst{31-28} = 0b1111; let Inst{20} = direction; let Inst{4} = 1; @@ -3611,27 +3604,25 @@ } def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */, - (outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, - i32imm:$opc2)>; + (outs), + (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2), + [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)]>; def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */, - (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, - c_imm:$CRn, c_imm:$CRm, - i32imm:$opc2)>; + (outs GPR:$Rt), + (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, c_imm:$CRm, + i32imm:$opc2), []>; -def : ARMV5TPat<(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2), - (MCR2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2)>; def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; -class MovRRCopro +class MovRRCopro pattern = [/* For disassembly only */]> : ABI<0b1100, (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), - NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", - [/* For disassembly only; pattern left blank */]> { + NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> { let Inst{23-21} = 0b010; let Inst{20} = direction; @@ -3648,18 +3639,16 @@ let Inst{3-0} = CRm; } -def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */>; +def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */, + [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, + imm:$CRm)]>; def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>; -def : ARMV5TEPat<(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, - imm:$CRm), - (MCRR imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; - -class MovRRCopro2 +class MovRRCopro2 pattern = [/* For disassembly only */]> : ABXI<0b1100, (outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, GPR:$Rt2, c_imm:$CRm), - NoItinerary, !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), - [/* For disassembly only; pattern left blank */]> { + GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary, + !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> { let Inst{31-28} = 0b1111; let Inst{23-21} = 0b010; let Inst{20} = direction; @@ -3677,12 +3666,11 @@ let Inst{3-0} = CRm; } -def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */>; +def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */, + [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, + imm:$CRm)]>; def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>; -def : ARMV6Pat<(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), - (MCRR2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; - //===----------------------------------------------------------------------===// // Move between special register and ARM core register -- for disassembly only // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=130764&r1=130763&r2=130764&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue May 3 12:29:29 2011 @@ -1352,9 +1352,10 @@ // Move between coprocessor and ARM core register -- for disassembly only // -class tMovRCopro +class tMovRCopro pattern> : T1Cop { + pattern> { let Inst{27-24} = 0b1110; let Inst{20} = direction; let Inst{4} = 1; @@ -1375,24 +1376,24 @@ } def tMCR : tMovRCopro<"mcr", 0 /* from ARM core register to coprocessor */, - (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, - c_imm:$CRm, i32imm:$opc2)>; + (outs), + (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2), + [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)]>; def tMRC : tMovRCopro<"mrc", 1 /* from coprocessor to ARM core register */, - (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, - c_imm:$CRm, i32imm:$opc2)>; + (outs GPR:$Rt), + (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), + []>; -def : Pat<(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2), - (tMCR imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2)>, Requires<[IsThumb, HasV6T2]>; def : Pat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), (tMRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>, Requires<[IsThumb, HasV6T2]>; -class tMovRRCopro +class tMovRRCopro pattern = [/* For disassembly only */]> : T1Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), - !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), - [/* For disassembly only; pattern left blank */]> { + !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> { let Inst{27-24} = 0b1100; let Inst{23-21} = 0b010; let Inst{20} = direction; @@ -1410,20 +1411,19 @@ let Inst{3-0} = CRm; } -def tMCRR : tMovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */>; +def tMCRR : tMovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */, + [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, + imm:$CRm)]>; def tMRRC : tMovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>; -def : Pat<(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), - (tMCRR imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>, - Requires<[IsThumb, HasV6T2]>; - //===----------------------------------------------------------------------===// // Other Coprocessor Instructions. For disassembly only. // def tCDP : T1Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), "cdp\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", - [/* For disassembly only; pattern left blank */]> { + [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)]> { let Inst{27-24} = 0b1110; bits<4> opc1; @@ -1442,11 +1442,6 @@ let Inst{23-20} = opc1; } -def : Pat<(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2), - (tCDP imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2)>, Requires<[IsThumb, HasV6T2]>; - //===----------------------------------------------------------------------===// // TLS Instructions // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130764&r1=130763&r2=130764&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue May 3 12:29:29 2011 @@ -3347,9 +3347,10 @@ // Move between coprocessor and ARM core register -- for disassembly only // -class t2MovRCopro +class t2MovRCopro pattern> : T2Cop { + pattern> { let Inst{27-24} = 0b1110; let Inst{20} = direction; let Inst{4} = 1; @@ -3371,23 +3372,21 @@ def t2MCR2 : t2MovRCopro<"mcr2", 0 /* from ARM core register to coprocessor */, (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, - c_imm:$CRm, i32imm:$opc2)>; + c_imm:$CRm, i32imm:$opc2), + [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, + imm:$CRm, imm:$opc2)]>; def t2MRC2 : t2MovRCopro<"mrc2", 1 /* from coprocessor to ARM core register */, (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, - c_imm:$CRm, i32imm:$opc2)>; + c_imm:$CRm, i32imm:$opc2), []>; -def : T2v6Pat<(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2), - (t2MCR2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn, - imm:$CRm, imm:$opc2)>; def : T2v6Pat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2), (t2MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>; -class t2MovRRCopro +class t2MovRRCopro pattern = [/* For disassembly only */]> : T2Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), - !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), - [/* For disassembly only; pattern left blank */]> { + !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> { let Inst{27-24} = 0b1100; let Inst{23-21} = 0b010; let Inst{20} = direction; @@ -3406,13 +3405,12 @@ } def t2MCRR2 : t2MovRRCopro<"mcrr2", - 0 /* from ARM core register to coprocessor */>; + 0 /* from ARM core register to coprocessor */, + [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, + GPR:$Rt2, imm:$CRm)]>; def t2MRRC2 : t2MovRRCopro<"mrrc2", 1 /* from coprocessor to ARM core register */>; -def : T2v6Pat<(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm), - (t2MCRR2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2, imm:$CRm)>; - //===----------------------------------------------------------------------===// // Other Coprocessor Instructions. For disassembly only. // @@ -3420,7 +3418,8 @@ def t2CDP2 : T2Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2", - [/* For disassembly only; pattern left blank */]> { + [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, + imm:$CRm, imm:$opc2)]> { let Inst{27-24} = 0b1110; bits<4> opc1; @@ -3438,8 +3437,3 @@ let Inst{19-16} = CRn; let Inst{23-20} = opc1; } - -def : T2v6Pat<(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2), - (t2CDP2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn, - imm:$CRm, imm:$opc2)>; From bob.wilson at apple.com Tue May 3 12:33:22 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 May 2011 17:33:22 -0000 Subject: [llvm-commits] [llvm] r130766 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20110503173322.A71232A6C12C@llvm.org> Author: bwilson Date: Tue May 3 12:33:22 2011 New Revision: 130766 URL: http://llvm.org/viewvc/llvm-project?rev=130766&view=rev Log: Temporarily disable use of divmod compiler-rt functions for iOS. 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=130766&r1=130765&r2=130766&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue May 3 12:33:22 2011 @@ -398,12 +398,6 @@ setLibcallCallingConv(RTLIB::UDIV_I32, CallingConv::ARM_AAPCS); } - // Use divmod iOS compiler-rt calls. - if (Subtarget->getTargetTriple().getOS() == Triple::IOS) { - setLibcallName(RTLIB::SDIVREM_I32, "__divmodsi4"); - setLibcallName(RTLIB::UDIVREM_I32, "__udivmodsi4"); - } - if (Subtarget->isThumb1Only()) addRegisterClass(MVT::i32, ARM::tGPRRegisterClass); else From bob.wilson at apple.com Tue May 3 12:54:49 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 03 May 2011 17:54:49 -0000 Subject: [llvm-commits] [llvm] r130769 - /llvm/trunk/test/CodeGen/ARM/divmod.ll Message-ID: <20110503175449.7C9142A6C12C@llvm.org> Author: bwilson Date: Tue May 3 12:54:49 2011 New Revision: 130769 URL: http://llvm.org/viewvc/llvm-project?rev=130769&view=rev Log: Remove test for iOS divmod function, since that is disabled for now. Removed: llvm/trunk/test/CodeGen/ARM/divmod.ll Removed: llvm/trunk/test/CodeGen/ARM/divmod.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/divmod.ll?rev=130768&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/divmod.ll (original) +++ llvm/trunk/test/CodeGen/ARM/divmod.ll (removed) @@ -1,58 +0,0 @@ -; RUN: llc < %s -mtriple=arm-apple-ios | FileCheck %s - -define void @foo(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp { -entry: -; CHECK: foo: -; CHECK: bl ___divmodsi4 -; CHECK-NOT: bl ___divmodsi4 - %div = sdiv i32 %x, %y - store i32 %div, i32* %P, align 4 - %rem = srem i32 %x, %y - %arrayidx6 = getelementptr inbounds i32* %P, i32 1 - store i32 %rem, i32* %arrayidx6, align 4 - ret void -} - -define void @bar(i32 %x, i32 %y, i32* nocapture %P) nounwind ssp { -entry: -; CHECK: bar: -; CHECK: bl ___udivmodsi4 -; CHECK-NOT: bl ___udivmodsi4 - %div = udiv i32 %x, %y - store i32 %div, i32* %P, align 4 - %rem = urem i32 %x, %y - %arrayidx6 = getelementptr inbounds i32* %P, i32 1 - store i32 %rem, i32* %arrayidx6, align 4 - ret void -} - -; rdar://9280991 - at flags = external unnamed_addr global i32 - at tabsize = external unnamed_addr global i32 - -define void @do_indent(i32 %cols) nounwind { -entry: -; CHECK: do_indent: - %0 = load i32* @flags, align 4 - %1 = and i32 %0, 67108864 - %2 = icmp eq i32 %1, 0 - br i1 %2, label %bb1, label %bb - -bb: -; CHECK: bl ___divmodsi4 - %3 = load i32* @tabsize, align 4 - %4 = srem i32 %cols, %3 - %5 = sdiv i32 %cols, %3 - %6 = tail call i32 @llvm.objectsize.i32(i8* null, i1 false) - %7 = tail call i8* @__memset_chk(i8* null, i32 9, i32 %5, i32 %6) nounwind - br label %bb1 - -bb1: - %line_indent_len.0 = phi i32 [ %4, %bb ], [ 0, %entry ] - %8 = getelementptr inbounds i8* null, i32 %line_indent_len.0 - store i8 0, i8* %8, align 1 - ret void -} - -declare i32 @llvm.objectsize.i32(i8*, i1) nounwind readnone -declare i8* @__memset_chk(i8*, i32, i32, i32) nounwind From ahatanak at gmail.com Tue May 3 13:41:55 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Tue, 03 May 2011 18:41:55 -0000 Subject: [llvm-commits] [llvm] r130774 - /llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Message-ID: <20110503184155.2AD7B2A6C12C@llvm.org> Author: ahatanak Date: Tue May 3 13:41:54 2011 New Revision: 130774 URL: http://llvm.org/viewvc/llvm-project?rev=130774&view=rev Log: Fix function MipsRegisterInfo::getRegisterNumbering. Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Modified: llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp?rev=130774&r1=130773&r2=130774&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsRegisterInfo.cpp Tue May 3 13:41:54 2011 @@ -65,16 +65,16 @@ case Mips::T5 : case Mips::F13: return 13; case Mips::T6 : case Mips::F14: case Mips::D7: return 14; case Mips::T7 : case Mips::F15: return 15; - case Mips::T8 : case Mips::F16: case Mips::D8: return 16; - case Mips::T9 : case Mips::F17: return 17; - case Mips::S0 : case Mips::F18: case Mips::D9: return 18; - case Mips::S1 : case Mips::F19: return 19; - case Mips::S2 : case Mips::F20: case Mips::D10: return 20; - case Mips::S3 : case Mips::F21: return 21; - case Mips::S4 : case Mips::F22: case Mips::D11: return 22; - case Mips::S5 : case Mips::F23: return 23; - case Mips::S6 : case Mips::F24: case Mips::D12: return 24; - case Mips::S7 : case Mips::F25: return 25; + case Mips::S0 : case Mips::F16: case Mips::D8: return 16; + case Mips::S1 : case Mips::F17: return 17; + case Mips::S2 : case Mips::F18: case Mips::D9: return 18; + case Mips::S3 : case Mips::F19: return 19; + case Mips::S4 : case Mips::F20: case Mips::D10: return 20; + case Mips::S5 : case Mips::F21: return 21; + case Mips::S6 : case Mips::F22: case Mips::D11: return 22; + case Mips::S7 : case Mips::F23: return 23; + case Mips::T8 : case Mips::F24: case Mips::D12: return 24; + case Mips::T9 : case Mips::F25: return 25; case Mips::K0 : case Mips::F26: case Mips::D13: return 26; case Mips::K1 : case Mips::F27: return 27; case Mips::GP : case Mips::F28: case Mips::D14: return 28; From evan.cheng at apple.com Tue May 3 14:09:32 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 03 May 2011 19:09:32 -0000 Subject: [llvm-commits] [llvm] r130778 - /llvm/trunk/test/CodeGen/ARM/fnmscs.ll Message-ID: <20110503190932.E0D132A6C12C@llvm.org> Author: evancheng Date: Tue May 3 14:09:32 2011 New Revision: 130778 URL: http://llvm.org/viewvc/llvm-project?rev=130778&view=rev Log: Make the test less likely to fail with minor changes. Modified: llvm/trunk/test/CodeGen/ARM/fnmscs.ll Modified: llvm/trunk/test/CodeGen/ARM/fnmscs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fnmscs.ll?rev=130778&r1=130777&r2=130778&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fnmscs.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fnmscs.ll Tue May 3 14:09:32 2011 @@ -29,7 +29,7 @@ ; NEON: vnmla.f32 ; A8: t2: -; A8: vnmul.f32 s{{[0123]}}, s{{[0123]}}, s{{[0123]}} +; A8: vnmul.f32 s{{[01234]}}, s{{[01234]}}, s{{[01234]}} ; A8: vsub.f32 d{{[0-9]}}, d{{[0-9]}}, d{{[0-9]}} %0 = fmul float %a, %b %1 = fmul float -1.0, %0 From grosbach at apple.com Tue May 3 14:09:57 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 03 May 2011 19:09:57 -0000 Subject: [llvm-commits] [llvm] r130779 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <20110503190957.0F4782A6C12C@llvm.org> Author: grosbach Date: Tue May 3 14:09:56 2011 New Revision: 130779 URL: http://llvm.org/viewvc/llvm-project?rev=130779&view=rev Log: Tidy up. Add missing newline to generated file. Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=130779&r1=130778&r2=130779&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue May 3 14:09:56 2011 @@ -2321,7 +2321,7 @@ OS << " for (unsigned i = 0; i != " << MaxNumOperands << "; ++i) {\n"; OS << " if (i + 1 >= Operands.size()) {\n"; OS << " OperandsValid = (it->Classes[i] == " <<"InvalidMatchClass);\n"; - OS << " break;"; + OS << " break;\n"; OS << " }\n"; OS << " if (ValidateOperandClass(Operands[i+1], it->Classes[i]))\n"; OS << " continue;\n"; From baldrick at free.fr Tue May 3 14:53:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 03 May 2011 19:53:10 -0000 Subject: [llvm-commits] [llvm] r130780 - in /llvm/trunk: include/llvm/Support/PatternMatch.h lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/maxmin.ll Message-ID: <20110503195310.C41B42A6C12C@llvm.org> Author: baldrick Date: Tue May 3 14:53:10 2011 New Revision: 130780 URL: http://llvm.org/viewvc/llvm-project?rev=130780&view=rev Log: Implement some basic simplifications involving min/max, for example max(a,b) >= a -> true. According to my super-optimizer, these are by far the most common simplifications (of the -instsimplify kind) that occur in the testsuite and aren't caught by -std-compile-opts. Added: llvm/trunk/test/Transforms/InstSimplify/maxmin.ll Modified: llvm/trunk/include/llvm/Support/PatternMatch.h llvm/trunk/lib/Analysis/InstructionSimplify.cpp Modified: llvm/trunk/include/llvm/Support/PatternMatch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PatternMatch.h?rev=130780&r1=130779&r2=130780&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PatternMatch.h (original) +++ llvm/trunk/include/llvm/Support/PatternMatch.h Tue May 3 14:53:10 2011 @@ -694,6 +694,99 @@ return brc_match(C, T, F); } + +//===----------------------------------------------------------------------===// +// Matchers for max/min idioms, eg: "select (sgt x, y), x, y" -> smax(x,y). +// + +template +struct MaxMin_match { + LHS_t L; + RHS_t R; + + MaxMin_match(const LHS_t &LHS, const RHS_t &RHS) + : L(LHS), R(RHS) {} + + template + bool match(OpTy *V) { + // Look for "(x pred y) ? x : y" or "(x pred y) ? y : x". + SelectInst *SI = dyn_cast(V); + if (!SI) + return false; + ICmpInst *Cmp = dyn_cast(SI->getCondition()); + if (!Cmp) + return false; + // At this point we have a select conditioned on a comparison. Check that + // it is the values returned by the select that are being compared. + Value *TrueVal = SI->getTrueValue(); + Value *FalseVal = SI->getFalseValue(); + Value *LHS = Cmp->getOperand(0); + Value *RHS = Cmp->getOperand(1); + if ((TrueVal != LHS || FalseVal != RHS) && + (TrueVal != RHS || FalseVal != LHS)) + return false; + ICmpInst::Predicate Pred = LHS == TrueVal ? + Cmp->getPredicate() : Cmp->getSwappedPredicate(); + // Does "(x pred y) ? x : y" represent the desired max/min operation? + if (!Pred_t::match(Pred)) + return false; + // It does! Bind the operands. + return L.match(LHS) && R.match(RHS); + } +}; + +/// smax_pred_ty - Helper class for identifying signed max predicates. +struct smax_pred_ty { + static bool match(ICmpInst::Predicate Pred) { + return Pred == CmpInst::ICMP_SGT || Pred == CmpInst::ICMP_SGE; + } +}; + +/// smin_pred_ty - Helper class for identifying signed min predicates. +struct smin_pred_ty { + static bool match(ICmpInst::Predicate Pred) { + return Pred == CmpInst::ICMP_SLT || Pred == CmpInst::ICMP_SLE; + } +}; + +/// umax_pred_ty - Helper class for identifying unsigned max predicates. +struct umax_pred_ty { + static bool match(ICmpInst::Predicate Pred) { + return Pred == CmpInst::ICMP_UGT || Pred == CmpInst::ICMP_UGE; + } +}; + +/// umin_pred_ty - Helper class for identifying unsigned min predicates. +struct umin_pred_ty { + static bool match(ICmpInst::Predicate Pred) { + return Pred == CmpInst::ICMP_ULT || Pred == CmpInst::ICMP_ULE; + } +}; + +template +inline MaxMin_match +m_SMax(const LHS &L, const RHS &R) { + return MaxMin_match(L, R); +} + +template +inline MaxMin_match +m_SMin(const LHS &L, const RHS &R) { + return MaxMin_match(L, R); +} + +template +inline MaxMin_match +m_UMax(const LHS &L, const RHS &R) { + return MaxMin_match(L, R); +} + +template +inline MaxMin_match +m_UMin(const LHS &L, const RHS &R) { + return MaxMin_match(L, R); +} + } // end namespace PatternMatch } // end namespace llvm Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=130780&r1=130779&r2=130780&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Tue May 3 14:53:10 2011 @@ -1868,6 +1868,124 @@ } } + // Simplify comparisons involving max/min. + Value *A, *B; + CmpInst::Predicate P = CmpInst::BAD_ICMP_PREDICATE; + CmpInst::Predicate EqP; // Chosen so that "A == max/min(A,B)" iff "A EqP B". + + // Signed max/min. + if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { + if (A != RHS) std::swap(A, B); // smax(A, B) pred A. + EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B". + // We analyze this as smax(A, B) pred A. + P = Pred; + } else if (match(RHS, m_SMax(m_Value(A), m_Value(B))) && + (A == LHS || B == LHS)) { + if (A != LHS) std::swap(A, B); // A pred smax(A, B). + EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B". + // We analyze this as smax(A, B) swapped-pred A. + P = CmpInst::getSwappedPredicate(Pred); + } else if (match(LHS, m_SMin(m_Value(A), m_Value(B))) && + (A == RHS || B == RHS)) { + if (A != RHS) std::swap(A, B); // smin(A, B) pred A. + EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" iff "A sle B". + // We analyze this as smax(-A, -B) swapped-pred -A. + // Note that we do not need to actually form -A or -B thanks to EqP. + P = CmpInst::getSwappedPredicate(Pred); + } else if (match(RHS, m_SMin(m_Value(A), m_Value(B))) && + (A == LHS || B == LHS)) { + if (A != LHS) std::swap(A, B); // A pred smin(A, B). + EqP = CmpInst::ICMP_SLE; // "A == smin(A, B)" iff "A sle B". + // We analyze this as smax(-A, -B) pred -A. + // Note that we do not need to actually form -A or -B thanks to EqP. + P = Pred; + } + if (P != CmpInst::BAD_ICMP_PREDICATE) { + // Cases correspond to "max(A, B) p A". + switch (P) { + default: + break; + case CmpInst::ICMP_EQ: + case CmpInst::ICMP_SLE: + // Equivalent to "A EqP B". + if (MaxRecurse) + if (Value *V = SimplifyICmpInst(EqP, A, B, TD, DT, MaxRecurse-1)) + return V; + break; + case CmpInst::ICMP_NE: + case CmpInst::ICMP_SGT: + // Equivalent to "A inverse-EqP B". + if (MaxRecurse) + if (Value *V = SimplifyICmpInst(CmpInst::getInversePredicate(EqP), A, B, + TD, DT, MaxRecurse-1)) + return V; + break; + case CmpInst::ICMP_SGE: + // Always true. + return Constant::getAllOnesValue(ITy); + case CmpInst::ICMP_SLT: + // Always false. + return Constant::getNullValue(ITy); + } + } + + // Unsigned max/min. + P = CmpInst::BAD_ICMP_PREDICATE; + if (match(LHS, m_UMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { + if (A != RHS) std::swap(A, B); // umax(A, B) pred A. + EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" iff "A uge B". + // We analyze this as umax(A, B) pred A. + P = Pred; + } else if (match(RHS, m_UMax(m_Value(A), m_Value(B))) && + (A == LHS || B == LHS)) { + if (A != LHS) std::swap(A, B); // A pred umax(A, B). + EqP = CmpInst::ICMP_UGE; // "A == umax(A, B)" iff "A uge B". + // We analyze this as umax(A, B) swapped-pred A. + P = CmpInst::getSwappedPredicate(Pred); + } else if (match(LHS, m_UMin(m_Value(A), m_Value(B))) && + (A == RHS || B == RHS)) { + if (A != RHS) std::swap(A, B); // umin(A, B) pred A. + EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" iff "A ule B". + // We analyze this as umax(-A, -B) swapped-pred -A. + // Note that we do not need to actually form -A or -B thanks to EqP. + P = CmpInst::getSwappedPredicate(Pred); + } else if (match(RHS, m_UMin(m_Value(A), m_Value(B))) && + (A == LHS || B == LHS)) { + if (A != LHS) std::swap(A, B); // A pred umin(A, B). + EqP = CmpInst::ICMP_ULE; // "A == umin(A, B)" iff "A ule B". + // We analyze this as umax(-A, -B) pred -A. + // Note that we do not need to actually form -A or -B thanks to EqP. + P = Pred; + } + if (P != CmpInst::BAD_ICMP_PREDICATE) { + // Cases correspond to "max(A, B) p A". + switch (P) { + default: + break; + case CmpInst::ICMP_EQ: + case CmpInst::ICMP_ULE: + // Equivalent to "A EqP B". + if (MaxRecurse) + if (Value *V = SimplifyICmpInst(EqP, A, B, TD, DT, MaxRecurse-1)) + return V; + break; + case CmpInst::ICMP_NE: + case CmpInst::ICMP_UGT: + // Equivalent to "A inverse-EqP B". + if (MaxRecurse) + if (Value *V = SimplifyICmpInst(CmpInst::getInversePredicate(EqP), A, B, + TD, DT, MaxRecurse-1)) + return V; + break; + case CmpInst::ICMP_UGE: + // Always true. + return Constant::getAllOnesValue(ITy); + case CmpInst::ICMP_ULT: + // Always false. + return Constant::getNullValue(ITy); + } + } + // If the comparison is with the result of a select instruction, check whether // comparing with either branch of the select always yields the same value. if (isa(LHS) || isa(RHS)) Added: llvm/trunk/test/Transforms/InstSimplify/maxmin.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/maxmin.ll?rev=130780&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstSimplify/maxmin.ll (added) +++ llvm/trunk/test/Transforms/InstSimplify/maxmin.ll Tue May 3 14:53:10 2011 @@ -0,0 +1,145 @@ +; RUN: opt < %s -instsimplify -S | FileCheck %s + +define i1 @max1(i32 %x, i32 %y) { +; CHECK: @max1 + %c = icmp sgt i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp slt i32 %m, %x + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @max2(i32 %x, i32 %y) { +; CHECK: @max2 + %c = icmp sge i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp sge i32 %m, %x + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @max3(i32 %x, i32 %y) { +; CHECK: @max3 + %c = icmp ugt i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp ult i32 %m, %x + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @max4(i32 %x, i32 %y) { +; CHECK: @max4 + %c = icmp uge i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp uge i32 %m, %x + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @max5(i32 %x, i32 %y) { +; CHECK: @max5 + %c = icmp sgt i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp sgt i32 %x, %m + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @max6(i32 %x, i32 %y) { +; CHECK: @max6 + %c = icmp sge i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp sle i32 %x, %m + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @max7(i32 %x, i32 %y) { +; CHECK: @max7 + %c = icmp ugt i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp ugt i32 %x, %m + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @max8(i32 %x, i32 %y) { +; CHECK: @max8 + %c = icmp uge i32 %x, %y + %m = select i1 %c, i32 %x, i32 %y + %r = icmp ule i32 %x, %m + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @min1(i32 %x, i32 %y) { +; CHECK: @min1 + %c = icmp sgt i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp sgt i32 %m, %x + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @min2(i32 %x, i32 %y) { +; CHECK: @min2 + %c = icmp sge i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp sle i32 %m, %x + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @min3(i32 %x, i32 %y) { +; CHECK: @min3 + %c = icmp ugt i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp ugt i32 %m, %x + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @min4(i32 %x, i32 %y) { +; CHECK: @min4 + %c = icmp uge i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp ule i32 %m, %x + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @min5(i32 %x, i32 %y) { +; CHECK: @min5 + %c = icmp sgt i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp slt i32 %x, %m + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @min6(i32 %x, i32 %y) { +; CHECK: @min6 + %c = icmp sge i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp sge i32 %x, %m + ret i1 %r +; CHECK: ret i1 true +} + +define i1 @min7(i32 %x, i32 %y) { +; CHECK: @min7 + %c = icmp ugt i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp ult i32 %x, %m + ret i1 %r +; CHECK: ret i1 false +} + +define i1 @min8(i32 %x, i32 %y) { +; CHECK: @min8 + %c = icmp uge i32 %x, %y + %m = select i1 %c, i32 %y, i32 %x + %r = icmp uge i32 %x, %m + ret i1 %r +; CHECK: ret i1 true +} From rafael.espindola at gmail.com Tue May 3 15:26:43 2011 From: rafael.espindola at gmail.com (Rafael Avila de Espindola) Date: Tue, 03 May 2011 16:26:43 -0400 Subject: [llvm-commits] What requires __debug_frame? In-Reply-To: <84C9465D-9B69-429D-8631-FB15463CC930@apple.com> References: <4DC01EC0.7080101@gmail.com> <84C9465D-9B69-429D-8631-FB15463CC930@apple.com> Message-ID: <4DC06503.3030306@gmail.com> On 11-05-03 12:12 PM, Devang Patel wrote: > > On May 3, 2011, at 8:26 AM, Rafael Avila de Espindola wrote: > >> I was wondering what software requires __debug_frame. I decided to >> try changing the default and see what would break. Surprisingly, it >> was just a a single test that I needed to update to expect cfi >> directives. >> >> I used a clang modified with the attached patch to build a debug >> version of clang itself and gdb is happy with it. I can set >> breakpoints, get backtraces, etc. > > It is used by unwinder, so you want to test eh unwinding also. The unwinder uses __eh_frame, no? > - Devang Cheers, Rafael From fjahanian at apple.com Tue May 3 15:22:13 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Tue, 03 May 2011 20:22:13 -0000 Subject: [llvm-commits] [test-suite] r130784 - /test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Message-ID: <20110503202213.CAFCA2A6C12C@llvm.org> Author: fjahanian Date: Tue May 3 15:22:13 2011 New Revision: 130784 URL: http://llvm.org/viewvc/llvm-project?rev=130784&view=rev Log: Test related to rules for zero-length bitfields in ms_struct structs. // rdar://8823265 Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c?rev=130784&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c (added) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Tue May 3 15:22:13 2011 @@ -0,0 +1,56 @@ +#include + +#define ATTR __attribute__((__ms_struct__)) + +struct { + unsigned int bf_1 : 12; + unsigned int : 0; + unsigned int bf_2 : 12; +} ATTR t1 = {1,2}; +static int a1[(sizeof(t1) == 8) -1]; + +struct +{ + char foo : 4; + short : 0; + char bar; +} ATTR t2 = {3,4}; +static int a2[(sizeof(t2) == 4) -1]; + +#pragma ms_struct on +struct +{ + char foo : 4; + short : 0; + char bar; +} t3 = {5,6}; +#pragma ms_struct off +static int a3[(sizeof(t3) == 4) -1]; + +struct +{ + char foo : 6; + int : 0; +} ATTR t4; +static int a4[(sizeof(t4) == 4) -1]; + +struct +{ + char foo : 4; + short : 0; + char bar : 8; +} ATTR t5 = {7,8}; +static int a5[(sizeof(t5) == 4) -1]; + +int main() { + if (t1.bf_1 != 1 || t1.bf_2 != 2) + abort(); + if (t2.foo != 3 || t2.bar != 4) + abort(); + if (t3.foo != 5 || t3.bar != 6) + abort(); + if (t5.foo != 7 || t5.bar != 8) + abort(); + return 0; +} + From stoklund at 2pi.dk Tue May 3 15:42:14 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 03 May 2011 20:42:14 -0000 Subject: [llvm-commits] [llvm] r130787 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SplitKit.cpp SplitKit.h Message-ID: <20110503204214.149402A6C12C@llvm.org> Author: stoklund Date: Tue May 3 15:42:13 2011 New Revision: 130787 URL: http://llvm.org/viewvc/llvm-project?rev=130787&view=rev Log: Gracefully handle invalid live ranges. Fix PR9831. Register coalescing can sometimes create live ranges that end in the middle of a basic block without any killing instruction. When SplitKit detects this, it will repair the live range by shrinking it to its uses. Live range splitting also needs to know about this. When the range shrinks so much that it becomes allocatable, live range splitting fails because it can't find a good split point. It is paranoid about making progress, so an allocatable range is considered an error. The coalescer should really not be creating these bad live ranges. They appear when coalescing dead copies. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=130787&r1=130786&r2=130787&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue May 3 15:42:13 2011 @@ -1315,6 +1315,19 @@ SA->analyze(&VirtReg); + // FIXME: SplitAnalysis may repair broken live ranges coming from the + // coalescer. That may cause the range to become allocatable which means that + // tryRegionSplit won't be making progress. This check should be replaced with + // an assertion when the coalescer is fixed. + if (SA->didRepairRange()) { + // VirtReg has changed, so all cached queries are invalid. + Order.rewind(); + while (unsigned PhysReg = Order.next()) + query(VirtReg, PhysReg).clear(); + if (unsigned PhysReg = tryAssign(VirtReg, Order, NewVRegs)) + return PhysReg; + } + // First try to split around a region spanning multiple blocks. unsigned PhysReg = tryRegionSplit(VirtReg, Order, NewVRegs); if (PhysReg || !NewVRegs.empty()) Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=130787&r1=130786&r2=130787&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue May 3 15:42:13 2011 @@ -51,6 +51,7 @@ UseBlocks.clear(); ThroughBlocks.clear(); CurLI = 0; + DidRepairRange = false; } SlotIndex SplitAnalysis::computeLastSplitPoint(unsigned Num) { @@ -119,6 +120,7 @@ if (!calcLiveBlockInfo()) { // FIXME: calcLiveBlockInfo found inconsistencies in the live range. // I am looking at you, SimpleRegisterCoalescing! + DidRepairRange = true; DEBUG(dbgs() << "*** Fixing inconsistent live interval! ***\n"); const_cast(LIS) .shrinkToUses(const_cast(CurLI)); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=130787&r1=130786&r2=130787&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue May 3 15:42:13 2011 @@ -97,6 +97,9 @@ /// NumThroughBlocks - Number of live-through blocks. unsigned NumThroughBlocks; + /// DidRepairRange - analyze was forced to shrinkToUses(). + bool DidRepairRange; + SlotIndex computeLastSplitPoint(unsigned Num); // Sumarize statistics by counting instructions using CurLI. @@ -113,6 +116,11 @@ /// split. void analyze(const LiveInterval *li); + /// didRepairRange() - Returns true if CurLI was invalid and has been repaired + /// by analyze(). This really shouldn't happen, but sometimes the coalescer + /// can create live ranges that end in mid-air. + bool didRepairRange() const { return DidRepairRange; } + /// clear - clear all data structures so SplitAnalysis is ready to analyze a /// new interval. void clear(); From isanbard at gmail.com Tue May 3 16:11:17 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 03 May 2011 21:11:17 -0000 Subject: [llvm-commits] [llvm] r130791 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp test/Assembler/AutoUpgradeIntrinsics.ll test/CodeGen/X86/nontemporal.ll Message-ID: <20110503211117.54AA62A6C12C@llvm.org> Author: void Date: Tue May 3 16:11:17 2011 New Revision: 130791 URL: http://llvm.org/viewvc/llvm-project?rev=130791&view=rev Log: Replace the "movnt" intrinsics with a native store + nontemporal metadata bit. Added: llvm/trunk/test/CodeGen/X86/nontemporal.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/Assembler/AutoUpgradeIntrinsics.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=130791&r1=130790&r2=130791&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue May 3 16:11:17 2011 @@ -1875,21 +1875,6 @@ // SSE 1 & 2 - Non-temporal stores //===----------------------------------------------------------------------===// -def VMOVNTPSmr_Int : VPSI<0x2B, MRMDestMem, (outs), - (ins i128mem:$dst, VR128:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>, VEX; -def VMOVNTPDmr_Int : VPDI<0x2B, MRMDestMem, (outs), - (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>, VEX; - -let ExeDomain = SSEPackedInt in - def VMOVNTDQmr_Int : VPDI<0xE7, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>, VEX; - let AddedComplexity = 400 in { // Prefer non-temporal versions def VMOVNTPSmr : VPSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), @@ -1906,12 +1891,16 @@ "movntdq\t{$src, $dst|$dst, $src}", [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>, VEX; + let ExeDomain = SSEPackedInt in - def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f32 VR128:$src), - addr:$dst)]>, VEX; + def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), + addr:$dst)]>, VEX; + + def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), + (VMOVNTDQmr addr:$dst, VR128:$src)>; def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src), @@ -1943,18 +1932,6 @@ def : Pat<(int_x86_avx_movnt_ps_256 addr:$dst, VR256:$src), (VMOVNTPSYmr addr:$dst, VR256:$src)>; -def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; -def MOVNTPDmr_Int : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; - -let ExeDomain = SSEPackedInt in -def MOVNTDQmr_Int : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; - let AddedComplexity = 400 in { // Prefer non-temporal versions def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movntps\t{$src, $dst|$dst, $src}", @@ -1972,22 +1949,19 @@ "movntdq\t{$src, $dst|$dst, $src}", [(alignednontemporalstore (v4f32 VR128:$src), addr:$dst)]>; +def : Pat<(alignednontemporalstore (v2i64 VR128:$src), addr:$dst), + (MOVNTDQmr addr:$dst, VR128:$src)>; + // There is no AVX form for instructions below this point def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), "movnti\t{$src, $dst|$dst, $src}", [(nontemporalstore (i32 GR32:$src), addr:$dst)]>, TB, Requires<[HasSSE2]>; - def MOVNTI_64mr : RI<0xC3, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), "movnti\t{$src, $dst|$dst, $src}", [(nontemporalstore (i64 GR64:$src), addr:$dst)]>, TB, Requires<[HasSSE2]>; - } -def MOVNTImr_Int : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), - "movnti\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, - TB, Requires<[HasSSE2]>; //===----------------------------------------------------------------------===// // SSE 1 & 2 - Misc Instructions (No AVX form) Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=130791&r1=130790&r2=130791&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue May 3 16:11:17 2011 @@ -533,6 +533,13 @@ // Calls to these instructions are transformed into unaligned loads. NewFn = 0; return true; + } else if (Name.compare(5, 16, "x86.sse.movnt.ps", 16) == 0 || + Name.compare(5, 17, "x86.sse2.movnt.dq", 17) == 0 || + Name.compare(5, 17, "x86.sse2.movnt.pd", 17) == 0 || + Name.compare(5, 17, "x86.sse2.movnt.i", 16) == 0) { + // Calls to these instructions are transformed into nontemporal stores. + NewFn = 0; + return true; } else if (Name.compare(5, 17, "x86.ssse3.pshuf.w", 17) == 0) { // This is an SSE/MMX instruction. const Type *X86_MMXTy = VectorType::getX86_MMXTy(FTy->getContext()); @@ -975,6 +982,31 @@ // Remove intrinsic. CI->eraseFromParent(); + } else if (F->getName() == "llvm.x86.sse.movnt.ps" || + F->getName() == "llvm.x86.sse2.movnt.dq" || + F->getName() == "llvm.x86.sse2.movnt.pd" || + F->getName() == "llvm.x86.sse2.movnt.i") { + IRBuilder<> Builder(C); + Builder.SetInsertPoint(CI->getParent(), CI); + + Module *M = F->getParent(); + SmallVector Elts; + Elts.push_back(ConstantInt::get(Type::getInt32Ty(C), 1)); + MDNode *Node = MDNode::get(C, Elts); + + Value *Arg0 = CI->getArgOperand(0); + Value *Arg1 = CI->getArgOperand(1); + + // Convert the type of the pointer to a pointer to the stored type. + Value *BC = Builder.CreateBitCast(Arg0, + PointerType::getUnqual(Arg1->getType()), + "cast"); + StoreInst *SI = Builder.CreateStore(Arg1, BC); + SI->setMetadata(M->getMDKindID("nontemporal"), Node); + SI->setAlignment(16); + + // Remove intrinsic. + CI->eraseFromParent(); } else { llvm_unreachable("Unknown function for CallInst upgrade."); } Modified: llvm/trunk/test/Assembler/AutoUpgradeIntrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/AutoUpgradeIntrinsics.ll?rev=130791&r1=130790&r2=130791&view=diff ============================================================================== --- llvm/trunk/test/Assembler/AutoUpgradeIntrinsics.ll (original) +++ llvm/trunk/test/Assembler/AutoUpgradeIntrinsics.ll Tue May 3 16:11:17 2011 @@ -10,6 +10,7 @@ ; RUN: not grep {llvm\\.x86\\.sse2\\.loadu} ; RUN: llvm-as < %s | llvm-dis | \ ; RUN: grep {llvm\\.x86\\.mmx\\.ps} | grep {x86_mmx} | count 16 +; RUN: llvm-as < %s | llvm-dis | FileCheck %s declare i32 @llvm.ctpop.i28(i28 %val) declare i32 @llvm.cttz.i29(i29 %val) @@ -91,3 +92,20 @@ %v2 = call <2 x double> @llvm.x86.sse2.loadu.pd(double* %b) ret void } + +declare void @llvm.x86.sse.movnt.ps(i8*, <4 x float>) nounwind readnone +declare void @llvm.x86.sse2.movnt.dq(i8*, <2 x double>) nounwind readnone +declare void @llvm.x86.sse2.movnt.pd(i8*, <2 x double>) nounwind readnone +declare void @llvm.x86.sse2.movnt.i(i8*, i32) nounwind readnone + +define void @f(<4 x float> %A, i8* %B, <2 x double> %C, i32 %D) { +; CHECK: store{{.*}}nontemporal + call void @llvm.x86.sse.movnt.ps(i8* %B, <4 x float> %A) +; CHECK: store{{.*}}nontemporal + call void @llvm.x86.sse2.movnt.dq(i8* %B, <2 x double> %C) +; CHECK: store{{.*}}nontemporal + call void @llvm.x86.sse2.movnt.pd(i8* %B, <2 x double> %C) +; CHECK: store{{.*}}nontemporal + call void @llvm.x86.sse2.movnt.i(i8* %B, i32 %D) + ret void +} Added: llvm/trunk/test/CodeGen/X86/nontemporal.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/nontemporal.ll?rev=130791&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/nontemporal.ll (added) +++ llvm/trunk/test/CodeGen/X86/nontemporal.ll Tue May 3 16:11:17 2011 @@ -0,0 +1,19 @@ +; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s + +define void @f(<4 x float> %A, i8* %B, <2 x double> %C, i32 %D, <2 x i64> %E) { +; CHECK: movntps + %cast = bitcast i8* %B to <4 x float>* + store <4 x float> %A, <4 x float>* %cast, align 16, !nontemporal !0 +; CHECK: movntdq + %cast1 = bitcast i8* %B to <2 x i64>* + store <2 x i64> %E, <2 x i64>* %cast1, align 16, !nontemporal !0 +; CHECK: movntpd + %cast2 = bitcast i8* %B to <2 x double>* + store <2 x double> %C, <2 x double>* %cast2, align 16, !nontemporal !0 +; CHECK: movnti + %cast3 = bitcast i8* %B to i32* + store i32 %D, i32* %cast3, align 16, !nontemporal !0 + ret void +} + +!0 = metadata !{i32 1} From daniel at zuster.org Tue May 3 16:33:37 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 03 May 2011 21:33:37 -0000 Subject: [llvm-commits] [llvm] r130793 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110503213337.D7F902A6C12C@llvm.org> Author: ddunbar Date: Tue May 3 16:33:37 2011 New Revision: 130793 URL: http://llvm.org/viewvc/llvm-project?rev=130793&view=rev Log: MCDwarf: Don't save Twine to local variable, this is almost never safe to do (and should thus never be done). - Should fix a crash on win32. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130793&r1=130792&r2=130793&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue May 3 16:33:37 2011 @@ -740,8 +740,8 @@ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { - Twine EHName = frame.Function->getName() + Twine(".eh"); - MCSymbol *EHSym = context.GetOrCreateSymbol(EHName); + MCSymbol *EHSym = context.GetOrCreateSymbol( + frame.Function->getName() + Twine(".eh")); streamer.EmitEHSymAttributes(frame.Function, EHSym); streamer.EmitLabel(EHSym); } From daniel at zuster.org Tue May 3 16:41:27 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 3 May 2011 14:41:27 -0700 Subject: [llvm-commits] [llvm] r130375 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/MC/MCDwarf.cpp In-Reply-To: <20110428024642.C47FF2A6C135@llvm.org> References: <20110428024642.C47FF2A6C135@llvm.org> Message-ID: Hi Rafael, On Wed, Apr 27, 2011 at 7:46 PM, Rafael Espindola wrote: > Author: rafael > Date: Wed Apr 27 21:46:42 2011 > New Revision: 130375 > > URL: http://llvm.org/viewvc/llvm-project?rev=130375&view=rev > Log: > Forward isFunctionEHFrameSymbolPrivate. If it is false, produce the foo.eh > symbols. > > Modified: > ? ?llvm/trunk/include/llvm/Target/TargetAsmInfo.h > ? ?llvm/trunk/lib/MC/MCDwarf.cpp > > Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=130375&r1=130374&r2=130375&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) > +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Apr 27 21:46:42 2011 > @@ -62,6 +62,10 @@ > ? ? return TLOF->getFDEEncoding(); > ? } > > + ?bool isFunctionEHFrameSymbolPrivate() const { > + ? ?return TLOF->isFunctionEHFrameSymbolPrivate(); > + ?} > + > ? unsigned getDwarfRARegNum(bool isEH) const { > ? ? return TRI->getDwarfRegNum(TRI->getRARegister(), isEH); > ? } > > Modified: llvm/trunk/lib/MC/MCDwarf.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130375&r1=130374&r2=130375&view=diff > ============================================================================== > --- llvm/trunk/lib/MC/MCDwarf.cpp (original) > +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Apr 27 21:46:42 2011 > @@ -17,6 +17,7 @@ > ?#include "llvm/MC/MCContext.h" > ?#include "llvm/MC/MCObjectWriter.h" > ?#include "llvm/ADT/SmallString.h" > +#include "llvm/ADT/Twine.h" > ?#include "llvm/Support/Debug.h" > ?#include "llvm/Support/ErrorHandling.h" > ?#include "llvm/Support/raw_ostream.h" > @@ -713,6 +714,12 @@ > ? MCSymbol *fdeEnd = context.CreateTempSymbol(); > ? const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); > > + ?if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { > + ? ?Twine EHName = frame.Function->getName() + Twine(".eh"); > + ? ?MCSymbol *EHSym = context.GetOrCreateSymbol(EHName); > + ? ?streamer.EmitLabel(EHSym); Note that this use of Twine is not safe (I fixed in r130793). You can almost never safely store local variables of Twine type. >From Twine.h: -- /// A Twine is not intended for use directly and should not be stored, its /// implementation relies on the ability to store pointers to temporary stack /// objects which may be deallocated at the end of a statement. Twines should /// only be used accepted as const references in arguments, when an API wishes /// to accept possibly-concatenated strings. -- - Daniel > + ?} > + > ? // Length > ? const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0); > ? streamer.EmitAbsValue(Length, 4); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Tue May 3 16:50:35 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 03 May 2011 21:50:35 -0000 Subject: [llvm-commits] [llvm] r130794 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110503215035.321BF2A6C12C@llvm.org> Author: dpatel Date: Tue May 3 16:50:34 2011 New Revision: 130794 URL: http://llvm.org/viewvc/llvm-project?rev=130794&view=rev Log: Even if the subprogram is going to use AT_specification, emit DW_AT_MIPS_linkage_name. This helps gdb and fixes var-path-expr.exp regression reported by gdb testsuite. 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=130794&r1=130793&r2=130794&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue May 3 16:50:34 2011 @@ -332,6 +332,11 @@ // Add function template parameters. SPCU->addTemplateParams(*SPDie, SP.getTemplateParams()); + StringRef LinkageName = SP.getLinkageName(); + if (!LinkageName.empty()) + SPCU->addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, + getRealLinkageName(LinkageName)); + // If this DIE is going to refer declaration info using AT_specification // then there is no need to add other attributes. if (SP.getFunctionDeclaration().isSubprogram()) @@ -342,11 +347,6 @@ SPCU->addString(SPDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, SP.getName()); - StringRef LinkageName = SP.getLinkageName(); - if (!LinkageName.empty()) - SPCU->addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - getRealLinkageName(LinkageName)); - SPCU->addSourceLine(SPDie, SP); if (SP.isPrototyped()) From fjahanian at apple.com Tue May 3 17:17:46 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Tue, 03 May 2011 22:17:46 -0000 Subject: [llvm-commits] [test-suite] r130798 - /test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Message-ID: <20110503221746.DC9342A6C12C@llvm.org> Author: fjahanian Date: Tue May 3 17:17:46 2011 New Revision: 130798 URL: http://llvm.org/viewvc/llvm-project?rev=130798&view=rev Log: More unit tests for ms_struct and zero-length bitfield alignment rules. Modified: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Modified: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c?rev=130798&r1=130797&r2=130798&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c (original) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init-1.c Tue May 3 17:17:46 2011 @@ -42,6 +42,44 @@ } ATTR t5 = {7,8}; static int a5[(sizeof(t5) == 4) -1]; +struct +{ + char foo : 4; + short : 0; + long :0; + char bar; +} ATTR t6 = {5, 10}; +static int a6[(sizeof(t6) == 4) -1]; + +struct +{ + char foo : 4; + int :0; + short : 0; + char bar; +} ATTR t7 = {5, 10}; +static int a7[(sizeof(t7) == 8) -1]; + +struct +{ + char foo : 4; + short : 0; + int :0; + char bar:7; +} ATTR t8 = {5, 10}; +static int a8[(sizeof(t8) == 4) -1]; + +struct +{ + char foo : 4; + char : 0; + short : 0; + int : 0; + long :0; + char bar; +} ATTR t10 = {5, 10}; +static int a10[(sizeof(t10) == 2) -1]; + int main() { if (t1.bf_1 != 1 || t1.bf_2 != 2) abort(); @@ -51,6 +89,14 @@ abort(); if (t5.foo != 7 || t5.bar != 8) abort(); + if (t6.foo != 5 || t6.bar != 10) + abort(); + if (t7.foo != 5 || t7.bar != 10) + abort(); + if (t8.foo != 5 || t8.bar != 10) + abort(); + if (t10.foo != 5 || t10.bar != 10) + abort(); return 0; } From atrick at apple.com Tue May 3 17:24:10 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 03 May 2011 22:24:10 -0000 Subject: [llvm-commits] [llvm] r130799 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110503222410.395582A6C12C@llvm.org> Author: atrick Date: Tue May 3 17:24:10 2011 New Revision: 130799 URL: http://llvm.org/viewvc/llvm-project?rev=130799&view=rev Log: indvars: Added canExpandBackEdgeTakenCount. Only create a canonical IV for backedge taken count if it will actually be used by LinearFunctionTestReplace. And some related cleanup, preparing to reduce dependence on canonical IVs. No significant effect on x86 or arm in the test-suite. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=130799&r1=130798&r2=130799&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue May 3 17:24:10 2011 @@ -105,11 +105,12 @@ void EliminateIVRemainders(); void RewriteNonIntegerIVs(Loop *L); + bool canExpandBackedgeTakenCount(Loop *L, + const SCEV *BackedgeTakenCount); + ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV *BackedgeTakenCount, - PHINode *IndVar, - BasicBlock *ExitingBlock, - BranchInst *BI, - SCEVExpander &Rewriter); + PHINode *IndVar, + SCEVExpander &Rewriter); void RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter); void RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter); @@ -183,17 +184,24 @@ return true; } -/// LinearFunctionTestReplace - This method rewrites the exit condition of the -/// loop to be a canonical != comparison against the incremented loop induction -/// variable. This pass is able to rewrite the exit tests of any loop where the -/// SCEV analysis can determine a loop-invariant trip count of the loop, which -/// is actually a much broader range than just linear tests. -ICmpInst *IndVarSimplify::LinearFunctionTestReplace(Loop *L, - const SCEV *BackedgeTakenCount, - PHINode *IndVar, - BasicBlock *ExitingBlock, - BranchInst *BI, - SCEVExpander &Rewriter) { +/// canExpandBackedgeTakenCount - Return true if this loop's backedge taken +/// count expression can be safely and cheaply expanded into an instruction +/// sequence that can be used by LinearFunctionTestReplace. +bool IndVarSimplify:: +canExpandBackedgeTakenCount(Loop *L, + const SCEV *BackedgeTakenCount) { + if (isa(BackedgeTakenCount) || + BackedgeTakenCount->isZero()) + return false; + + if (!L->getExitingBlock()) + return false; + + // Can't rewrite non-branch yet. + BranchInst *BI = dyn_cast(L->getExitingBlock()->getTerminator()); + if (!BI) + return false; + // Special case: If the backedge-taken count is a UDiv, it's very likely a // UDiv that ScalarEvolution produced in order to compute a precise // expression, rather than a UDiv from the user's code. If we can't find a @@ -208,16 +216,31 @@ const SCEV *L = SE->getSCEV(OrigCond->getOperand(0)); L = SE->getMinusSCEV(L, SE->getConstant(L->getType(), 1)); if (L != BackedgeTakenCount) - return 0; + return false; } } + return true; +} + +/// LinearFunctionTestReplace - This method rewrites the exit condition of the +/// loop to be a canonical != comparison against the incremented loop induction +/// variable. This pass is able to rewrite the exit tests of any loop where the +/// SCEV analysis can determine a loop-invariant trip count of the loop, which +/// is actually a much broader range than just linear tests. +ICmpInst *IndVarSimplify:: +LinearFunctionTestReplace(Loop *L, + const SCEV *BackedgeTakenCount, + PHINode *IndVar, + SCEVExpander &Rewriter) { + assert(canExpandBackedgeTakenCount(L, BackedgeTakenCount) && "precondition"); + BranchInst *BI = cast(L->getExitingBlock()->getTerminator()); // If the exiting block is not the same as the backedge block, we must compare // against the preincremented value, otherwise we prefer to compare against // the post-incremented value. Value *CmpIndVar; const SCEV *RHS = BackedgeTakenCount; - if (ExitingBlock == L->getLoopLatch()) { + if (L->getExitingBlock() == L->getLoopLatch()) { // Add one to the "backedge-taken" count to get the trip count. // If this addition may overflow, we have to be more pessimistic and // cast the induction variable before doing the add. @@ -240,7 +263,7 @@ // The BackedgeTaken expression contains the number of times that the // backedge branches to the loop header. This is one less than the // number of times the loop executes, so use the incremented indvar. - CmpIndVar = IndVar->getIncomingValueForBlock(ExitingBlock); + CmpIndVar = IndVar->getIncomingValueForBlock(L->getExitingBlock()); } else { // We have to use the preincremented value... RHS = SE->getTruncateOrZeroExtend(BackedgeTakenCount, @@ -533,7 +556,6 @@ // transform them to use integer recurrences. RewriteNonIntegerIVs(L); - BasicBlock *ExitingBlock = L->getExitingBlock(); // may be null const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); // Create a rewriter object which we'll use to transform the code with. @@ -558,23 +580,26 @@ // a canonical induction variable should be inserted. const Type *LargestType = 0; bool NeedCannIV = false; - if (!isa(BackedgeTakenCount)) { - LargestType = BackedgeTakenCount->getType(); - LargestType = SE->getEffectiveSCEVType(LargestType); + bool ExpandBECount = canExpandBackedgeTakenCount(L, BackedgeTakenCount); + if (ExpandBECount) { // If we have a known trip count and a single exit block, we'll be // rewriting the loop exit test condition below, which requires a // canonical induction variable. - if (ExitingBlock) - NeedCannIV = true; + NeedCannIV = true; + const Type *Ty = BackedgeTakenCount->getType(); + if (!LargestType || + SE->getTypeSizeInBits(Ty) > + SE->getTypeSizeInBits(LargestType)) + LargestType = SE->getEffectiveSCEVType(Ty); } for (IVUsers::const_iterator I = IU->begin(), E = IU->end(); I != E; ++I) { + NeedCannIV = true; const Type *Ty = SE->getEffectiveSCEVType(I->getOperandValToReplace()->getType()); if (!LargestType || SE->getTypeSizeInBits(Ty) > SE->getTypeSizeInBits(LargestType)) LargestType = Ty; - NeedCannIV = true; } // Now that we know the largest of the induction variable expressions @@ -614,15 +639,13 @@ // If we have a trip count expression, rewrite the loop's exit condition // using it. We can currently only handle loops with a single exit. ICmpInst *NewICmp = 0; - if (!isa(BackedgeTakenCount) && - !BackedgeTakenCount->isZero() && - ExitingBlock) { + if (ExpandBECount) { + assert(canExpandBackedgeTakenCount(L, BackedgeTakenCount) && + "canonical IV disrupted BackedgeTaken expansion"); assert(NeedCannIV && "LinearFunctionTestReplace requires a canonical induction variable"); - // Can't rewrite non-branch yet. - if (BranchInst *BI = dyn_cast(ExitingBlock->getTerminator())) - NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, - ExitingBlock, BI, Rewriter); + NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, + Rewriter); } // Rewrite IV-derived expressions. From stoklund at 2pi.dk Tue May 3 17:31:21 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 03 May 2011 22:31:21 -0000 Subject: [llvm-commits] [llvm] r130800 - in /llvm/trunk/test/CodeGen/ARM: 2011-04-07-schediv.ll 2011-04-11-MachineLICMBug.ll bfi.ll fcopysign.ll ldst-f32-2-i32.ll select-imm.ll stm.ll vldlane.ll Message-ID: <20110503223122.0AE5B2A6C12C@llvm.org> Author: stoklund Date: Tue May 3 17:31:21 2011 New Revision: 130800 URL: http://llvm.org/viewvc/llvm-project?rev=130800&view=rev Log: Fix a bunch of ARM tests to be register allocation independent. Modified: llvm/trunk/test/CodeGen/ARM/2011-04-07-schediv.ll llvm/trunk/test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll llvm/trunk/test/CodeGen/ARM/bfi.ll llvm/trunk/test/CodeGen/ARM/fcopysign.ll llvm/trunk/test/CodeGen/ARM/ldst-f32-2-i32.ll llvm/trunk/test/CodeGen/ARM/select-imm.ll llvm/trunk/test/CodeGen/ARM/stm.ll llvm/trunk/test/CodeGen/ARM/vldlane.ll Modified: llvm/trunk/test/CodeGen/ARM/2011-04-07-schediv.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-04-07-schediv.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-04-07-schediv.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2011-04-07-schediv.ll Tue May 3 17:31:21 2011 @@ -13,6 +13,7 @@ ; Make sure the scheduler schedules all uses of the preincrement ; induction variable before defining the postincrement value. ; CHECK: t: +; CHECK: %bb ; CHECK-NOT: mov bb: ; preds = %entry, %bb %j.05 = phi i32 [ %2, %bb ], [ 0, %entry ] Modified: llvm/trunk/test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2011-04-11-MachineLICMBug.ll Tue May 3 17:31:21 2011 @@ -14,15 +14,15 @@ br i1 %cmp, label %for.body, label %return for.body: -; CHECK: %for.body -; CHECK: movs r{{[0-9]+}}, #1 +; CHECK: %for. +; CHECK: movs r{{[0-9]+}}, #{{[01]}} %arrayidx = getelementptr i32* %A, i32 %0 %tmp4 = load i32* %arrayidx, align 4 %cmp6 = icmp eq i32 %tmp4, %value br i1 %cmp6, label %return, label %for.inc -; CHECK: %for.cond -; CHECK: movs r{{[0-9]+}}, #0 +; CHECK: %for. +; CHECK: movs r{{[0-9]+}}, #{{[01]}} for.inc: %inc = add i32 %0, 1 Modified: llvm/trunk/test/CodeGen/ARM/bfi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/bfi.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/bfi.ll (original) +++ llvm/trunk/test/CodeGen/ARM/bfi.ll Tue May 3 17:31:21 2011 @@ -31,8 +31,7 @@ entry: ; CHECK: f3 ; CHECK: lsr{{.*}} #7 -; CHECK: mov r0, r1 -; CHECK: bfi r0, r2, #7, #16 +; CHECK: bfi {{.*}}, #7, #16 %and = and i32 %A, 8388480 ; [#uses=1] %and2 = and i32 %B, -8388481 ; [#uses=1] %or = or i32 %and2, %and ; [#uses=1] @@ -42,8 +41,8 @@ ; rdar://8752056 define i32 @f4(i32 %a) nounwind { ; CHECK: f4 -; CHECK: movw r1, #3137 -; CHECK: bfi r1, r0, #15, #5 +; CHECK: movw [[R1:r[0-9]+]], #3137 +; CHECK: bfi [[R1]], {{r[0-9]+}}, #15, #5 %1 = shl i32 %a, 15 %ins7 = and i32 %1, 1015808 %ins12 = or i32 %ins7, 3137 Modified: llvm/trunk/test/CodeGen/ARM/fcopysign.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fcopysign.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fcopysign.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fcopysign.ll Tue May 3 17:31:21 2011 @@ -10,7 +10,7 @@ ; HARD: test1: ; HARD: vmov.i32 [[REG1:(d[0-9]+)]], #0x80000000 -; HARD: vbsl [[REG1]], d2, d0 +; HARD: vbsl [[REG1]], d %0 = tail call float @copysignf(float %x, float %y) nounwind ret float %0 } Modified: llvm/trunk/test/CodeGen/ARM/ldst-f32-2-i32.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ldst-f32-2-i32.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ldst-f32-2-i32.ll (original) +++ llvm/trunk/test/CodeGen/ARM/ldst-f32-2-i32.ll Tue May 3 17:31:21 2011 @@ -10,8 +10,8 @@ br i1 %0, label %return, label %bb bb: -; CHECK: ldr [[REGISTER:(r[0-9]+)]], [r1], r3 -; CHECK: str [[REGISTER]], [r2], #4 +; CHECK: ldr [[REGISTER:(r[0-9]+)]], [{{r[0-9]+}}], {{r[0-9]+}} +; CHECK: str [[REGISTER]], [{{r[0-9]+}}], #4 %j.05 = phi i32 [ %2, %bb ], [ 0, %entry ] %tmp = mul i32 %j.05, %index %uglygep = getelementptr i8* %src6, i32 %tmp Modified: llvm/trunk/test/CodeGen/ARM/select-imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select-imm.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/select-imm.ll (original) +++ llvm/trunk/test/CodeGen/ARM/select-imm.ll Tue May 3 17:31:21 2011 @@ -5,8 +5,8 @@ define i32 @t1(i32 %c) nounwind readnone { entry: ; ARM: t1: -; ARM: mov r1, #101 -; ARM: orr r1, r1, #1, #24 +; ARM: mov [[R1:r[0-9]+]], #101 +; ARM: orr [[R1b:r[0-9]+]], [[R1]], #1, #24 ; ARM: movgt r0, #123 ; ARMT2: t1: @@ -34,7 +34,7 @@ ; ARMT2: movwgt r0, #357 ; THUMB2: t2: -; THUMB2: mov.w r0, #123 +; THUMB2: mov{{(s|\.w)}} r0, #123 ; THUMB2: movwgt r0, #357 %0 = icmp sgt i32 %c, 1 @@ -53,7 +53,7 @@ ; ARMT2: moveq r0, #1 ; THUMB2: t3: -; THUMB2: mov.w r0, #0 +; THUMB2: mov{{(s|\.w)}} r0, #0 ; THUMB2: moveq r0, #1 %0 = icmp eq i32 %a, 160 %1 = zext i1 %0 to i32 @@ -67,11 +67,11 @@ ; ARM: movlt ; ARMT2: t4: -; ARMT2: movwlt r0, #65365 -; ARMT2: movtlt r0, #65365 +; ARMT2: movwlt [[R0:r[0-9]+]], #65365 +; ARMT2: movtlt [[R0]], #65365 ; THUMB2: t4: -; THUMB2: mvnlt.w r0, #11141290 +; THUMB2: mvnlt.w [[R0:r[0-9]+]], #11141290 %0 = icmp slt i32 %a, %b %1 = select i1 %0, i32 4283826005, i32 %x ret i32 %1 Modified: llvm/trunk/test/CodeGen/ARM/stm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/stm.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/stm.ll (original) +++ llvm/trunk/test/CodeGen/ARM/stm.ll Tue May 3 17:31:21 2011 @@ -9,7 +9,7 @@ entry: ; CHECK: main ; CHECK: push -; CHECK: stmib +; CHECK: stm %0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([26 x i8]* @"\01LC1", i32 0, i32 0), i32 -2, i32 -3, i32 2, i32 -6) nounwind ; [#uses=0] %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([32 x i8]* @"\01LC", i32 0, i32 0), i32 0, i32 1, i32 0, i32 1, i32 0, i32 1) nounwind ; [#uses=0] ret i32 0 Modified: llvm/trunk/test/CodeGen/ARM/vldlane.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vldlane.ll?rev=130800&r1=130799&r2=130800&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vldlane.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vldlane.ll Tue May 3 17:31:21 2011 @@ -125,7 +125,7 @@ ;Check for a post-increment updating load. define <2 x i32> @vld2lanei32_update(i32** %ptr, <2 x i32>* %B) nounwind { ;CHECK: vld2lanei32_update: -;CHECK: vld2.32 {d16[1], d17[1]}, [r1]! +;CHECK: vld2.32 {d16[1], d17[1]}, [{{r[0-9]+}}]! %A = load i32** %ptr %tmp0 = bitcast i32* %A to i8* %tmp1 = load <2 x i32>* %B @@ -153,7 +153,7 @@ define <8 x i16> @vld2laneQi16(i16* %A, <8 x i16>* %B) nounwind { ;CHECK: vld2laneQi16: ;Check the (default) alignment. -;CHECK: vld2.16 {d17[1], d19[1]}, [r0] +;CHECK: vld2.16 {d17[1], d19[1]}, [{{r[0-9]+}}] %tmp0 = bitcast i16* %A to i8* %tmp1 = load <8 x i16>* %B %tmp2 = call %struct.__neon_int16x8x2_t @llvm.arm.neon.vld2lane.v8i16(i8* %tmp0, <8 x i16> %tmp1, <8 x i16> %tmp1, i32 5, i32 1) @@ -166,7 +166,7 @@ define <4 x i32> @vld2laneQi32(i32* %A, <4 x i32>* %B) nounwind { ;CHECK: vld2laneQi32: ;Check the alignment value. Max for this instruction is 64 bits: -;CHECK: vld2.32 {d17[0], d19[0]}, [r0, :64] +;CHECK: vld2.32 {d17[0], d19[0]}, [{{r[0-9]+}}, :64] %tmp0 = bitcast i32* %A to i8* %tmp1 = load <4 x i32>* %B %tmp2 = call %struct.__neon_int32x4x2_t @llvm.arm.neon.vld2lane.v4i32(i8* %tmp0, <4 x i32> %tmp1, <4 x i32> %tmp1, i32 2, i32 16) @@ -222,7 +222,7 @@ define <4 x i16> @vld3lanei16(i16* %A, <4 x i16>* %B) nounwind { ;CHECK: vld3lanei16: ;Check the (default) alignment value. VLD3 does not support alignment. -;CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [r0] +;CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [{{r[0-9]+}}] %tmp0 = bitcast i16* %A to i8* %tmp1 = load <4 x i16>* %B %tmp2 = call %struct.__neon_int16x4x3_t @llvm.arm.neon.vld3lane.v4i16(i8* %tmp0, <4 x i16> %tmp1, <4 x i16> %tmp1, <4 x i16> %tmp1, i32 1, i32 8) @@ -265,7 +265,7 @@ define <8 x i16> @vld3laneQi16(i16* %A, <8 x i16>* %B) nounwind { ;CHECK: vld3laneQi16: ;Check the (default) alignment value. VLD3 does not support alignment. -;CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [r0] +;CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [{{r[0-9]+}}] %tmp0 = bitcast i16* %A to i8* %tmp1 = load <8 x i16>* %B %tmp2 = call %struct.__neon_int16x8x3_t @llvm.arm.neon.vld3lane.v8i16(i8* %tmp0, <8 x i16> %tmp1, <8 x i16> %tmp1, <8 x i16> %tmp1, i32 1, i32 8) @@ -344,7 +344,7 @@ define <8 x i8> @vld4lanei8(i8* %A, <8 x i8>* %B) nounwind { ;CHECK: vld4lanei8: ;Check the alignment value. Max for this instruction is 32 bits: -;CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0, :32] +;CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [{{r[0-9]+}}, :32] %tmp1 = load <8 x i8>* %B %tmp2 = call %struct.__neon_int8x8x4_t @llvm.arm.neon.vld4lane.v8i8(i8* %A, <8 x i8> %tmp1, <8 x i8> %tmp1, <8 x i8> %tmp1, <8 x i8> %tmp1, i32 1, i32 8) %tmp3 = extractvalue %struct.__neon_int8x8x4_t %tmp2, 0 @@ -360,7 +360,7 @@ ;Check for a post-increment updating load. define <8 x i8> @vld4lanei8_update(i8** %ptr, <8 x i8>* %B) nounwind { ;CHECK: vld4lanei8_update: -;CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r1, :32]! +;CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [{{r[0-9]+}}, :32]! %A = load i8** %ptr %tmp1 = load <8 x i8>* %B %tmp2 = call %struct.__neon_int8x8x4_t @llvm.arm.neon.vld4lane.v8i8(i8* %A, <8 x i8> %tmp1, <8 x i8> %tmp1, <8 x i8> %tmp1, <8 x i8> %tmp1, i32 1, i32 8) @@ -380,7 +380,7 @@ ;CHECK: vld4lanei16: ;Check that a power-of-two alignment smaller than the total size of the memory ;being loaded is ignored. -;CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] +;CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [{{r[0-9]+}}] %tmp0 = bitcast i16* %A to i8* %tmp1 = load <4 x i16>* %B %tmp2 = call %struct.__neon_int16x4x4_t @llvm.arm.neon.vld4lane.v4i16(i8* %tmp0, <4 x i16> %tmp1, <4 x i16> %tmp1, <4 x i16> %tmp1, <4 x i16> %tmp1, i32 1, i32 4) @@ -398,7 +398,7 @@ ;CHECK: vld4lanei32: ;Check the alignment value. An 8-byte alignment is allowed here even though ;it is smaller than the total size of the memory being loaded. -;CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0, :64] +;CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [{{r[0-9]+}}, :64] %tmp0 = bitcast i32* %A to i8* %tmp1 = load <2 x i32>* %B %tmp2 = call %struct.__neon_int32x2x4_t @llvm.arm.neon.vld4lane.v2i32(i8* %tmp0, <2 x i32> %tmp1, <2 x i32> %tmp1, <2 x i32> %tmp1, <2 x i32> %tmp1, i32 1, i32 8) @@ -431,7 +431,7 @@ define <8 x i16> @vld4laneQi16(i16* %A, <8 x i16>* %B) nounwind { ;CHECK: vld4laneQi16: ;Check the alignment value. Max for this instruction is 64 bits: -;CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0, :64] +;CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [{{r[0-9]+}}, :64] %tmp0 = bitcast i16* %A to i8* %tmp1 = load <8 x i16>* %B %tmp2 = call %struct.__neon_int16x8x4_t @llvm.arm.neon.vld4lane.v8i16(i8* %tmp0, <8 x i16> %tmp1, <8 x i16> %tmp1, <8 x i16> %tmp1, <8 x i16> %tmp1, i32 1, i32 16) @@ -448,7 +448,7 @@ define <4 x i32> @vld4laneQi32(i32* %A, <4 x i32>* %B) nounwind { ;CHECK: vld4laneQi32: ;Check the (default) alignment. -;CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] +;CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [{{r[0-9]+}}] %tmp0 = bitcast i32* %A to i8* %tmp1 = load <4 x i32>* %B %tmp2 = call %struct.__neon_int32x4x4_t @llvm.arm.neon.vld4lane.v4i32(i8* %tmp0, <4 x i32> %tmp1, <4 x i32> %tmp1, <4 x i32> %tmp1, <4 x i32> %tmp1, i32 2, i32 1) From stoklund at 2pi.dk Tue May 3 17:31:24 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 03 May 2011 22:31:24 -0000 Subject: [llvm-commits] [llvm] r130801 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <20110503223124.EF5252A6C12D@llvm.org> Author: stoklund Date: Tue May 3 17:31:24 2011 New Revision: 130801 URL: http://llvm.org/viewvc/llvm-project?rev=130801&view=rev Log: Mark ultra-super-registers QQQQ as call-clobbered instead of the D sub-registers. LiveVariables doesn't understand that clobbering D0 and D1 completely overwrites Q0, so if Q0 is live-in to a function, its live range will extend beyond a function call that only clobbers D0 and D1. This shows up in the ARM/2009-11-01-NeonMoves test case. LiveVariables should probably implement the much stricter rules for physreg liveness that RAFast imposes - a physreg is killed by the first use of any alias. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130801&r1=130800&r2=130801&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue May 3 17:31:24 2011 @@ -1321,10 +1321,7 @@ // FIXME: Do we really need a non-predicated version? If so, it should // at least be a pseudo instruction expanding to the predicated version // at MC lowering time. - Defs = [R0, R1, R2, R3, R12, LR, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, - D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR], + Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR], Uses = [SP] in { def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops), IIC_Br, "bl\t$func", @@ -1378,10 +1375,7 @@ // On Darwin R9 is call-clobbered. // R7 is marked as a use to prevent frame-pointer assignments from being // moved above / below calls. - Defs = [R0, R1, R2, R3, R9, R12, LR, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, - D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR], + Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR], Uses = [R7, SP] in { def BLr9 : ARMPseudoInst<(outs), (ins bltarget:$func, variable_ops), Size4Bytes, IIC_Br, @@ -1420,10 +1414,7 @@ // FIXME: The Thumb versions of these should live in ARMInstrThumb.td let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in { // Darwin versions. - let Defs = [R0, R1, R2, R3, R9, R12, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, - D27, D28, D29, D30, D31, PC], + let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC], Uses = [SP] in { def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops), IIC_Br, []>, Requires<[IsDarwin]>; @@ -1449,10 +1440,7 @@ } // Non-Darwin versions (the difference is R9). - let Defs = [R0, R1, R2, R3, R12, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, - D27, D28, D29, D30, D31, PC], + let Defs = [R0, R1, R2, R3, R12, QQQQ0, QQQQ2, QQQQ3, PC], Uses = [SP] in { def TCRETURNdiND : PseudoInst<(outs), (ins i32imm:$dst, variable_ops), IIC_Br, []>, Requires<[IsNotDarwin]>; @@ -3757,10 +3745,8 @@ // These are pseudo-instructions and are lowered to individual MC-insts, so // no encoding information is necessary. let Defs = - [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0, - D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, - D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, - D31 ], hasSideEffects = 1, isBarrier = 1 in { + [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, + QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], hasSideEffects = 1, isBarrier = 1 in { def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val), NoItinerary, [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>, Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=130801&r1=130800&r2=130801&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue May 3 17:31:24 2011 @@ -423,10 +423,7 @@ // potentially appearing dead. let isCall = 1, // On non-Darwin platforms R9 is callee-saved. - Defs = [R0, R1, R2, R3, R12, LR, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, - D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR], + Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR], Uses = [SP] in { // Also used for Thumb2 def tBL : TIx2<0b11110, 0b11, 1, @@ -476,10 +473,7 @@ // On Darwin R9 is call-clobbered. // R7 is marked as a use to prevent frame-pointer assignments from being // moved above / below calls. - Defs = [R0, R1, R2, R3, R9, R12, LR, - D0, D1, D2, D3, D4, D5, D6, D7, - D16, D17, D18, D19, D20, D21, D22, D23, - D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR], + Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR], Uses = [R7, SP] in { // Also used for Thumb2 def tBLr9 : TIx2<0b11110, 0b11, 1, Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130801&r1=130800&r2=130801&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue May 3 17:31:24 2011 @@ -2965,10 +2965,9 @@ // all of the callee-saved resgisters, which is exactly what we want. // $val is a scratch register for our use. let Defs = - [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0, - D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, - D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, - D31 ], hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in { + [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, + QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], + hasSideEffects = 1, isBarrier = 1, isCodeGenOnly = 1 in { def t2Int_eh_sjlj_setjmp : Thumb2XI<(outs), (ins tGPR:$src, tGPR:$val), AddrModeNone, SizeSpecial, NoItinerary, "", "", [(set R0, (ARMeh_sjlj_setjmp tGPR:$src, tGPR:$val))]>, From pichet2000 at gmail.com Tue May 3 17:39:46 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 3 May 2011 18:39:46 -0400 Subject: [llvm-commits] [llvm] r130793 - /llvm/trunk/lib/MC/MCDwarf.cpp In-Reply-To: <20110503213337.D7F902A6C12C@llvm.org> References: <20110503213337.D7F902A6C12C@llvm.org> Message-ID: On Tue, May 3, 2011 at 5:33 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Tue May ?3 16:33:37 2011 > New Revision: 130793 > > URL: http://llvm.org/viewvc/llvm-project?rev=130793&view=rev > Log: > MCDwarf: Don't save Twine to local variable, this is almost never safe to do > (and should thus never be done). > ?- Should fix a crash on win32. Yes crash is gone. great From ahatanak at gmail.com Tue May 3 18:18:12 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Tue, 3 May 2011 16:18:12 -0700 Subject: [llvm-commits] [PATCH] Mips backend. Emit $gp restore instructions. Message-ID: This patch prevents instructions using $gp from being placed between a jalr and the instruction that restores the clobbered $gp (please see the following example). The current implementation creates load nodes that restore $gp when call instructions are lowered in MipsISelLowering::LowerCall. However, it does not add chains or glues that are needed to make sure load/store nodes that have $gp as an operand are not scheduled between JALR nodes and nodes that restore $gp after the call. This patch runs a pre-regalloc pass that emits $gp restore instructions instead. - bitcode @p = external global i32 ... tail call void (...)* @f1() nounwind %tmp = load i32* @p, align 4, !tbaa !0 - currently produces following code: ... lw $25, %call16(f1)($gp) jalr $25 # calls f1. $gp is clobbered. nop lw $3, 16($sp) # load $gp from stack. lw $2, %got(p)($gp) # this instr uses a clobbered $gp. addu $gp, $zero, $3 # $gp is restored here. ... - produces following code after patch is applied. ... lw $25, %call16(f1)($gp) lw $16, %got(p)($gp) # $gp has correct value here. jalr $25 # calls f1. clobbers $gp. nop lw $gp, 16($sp) # $gp restored. ... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/a7102878/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: gprestore.patch Type: text/x-patch Size: 4971 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/a7102878/attachment.bin From clattner at apple.com Tue May 3 19:46:31 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 03 May 2011 17:46:31 -0700 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <2E25739D-6707-4365-9DC5-E22C7C8E9644@apple.com> References: <20110429081541.B7F422A6C138@llvm.org> <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> <5F0816C4-4FC4-4F02-8B7E-51858107AC6D@googlemail.com> <2E25739D-6707-4365-9DC5-E22C7C8E9644@apple.com> Message-ID: <1A474230-04EB-4BA5-9B1C-A14B6117C315@apple.com> On May 2, 2011, at 2:33 PM, Devang Patel wrote: > Evan, > > On May 2, 2011, at 2:00 PM, Evan Cheng wrote: > >>> More generally, we don't want to sprinkle setDebugLoc calls into *every* instcombine xform. We need a better solution. >> >> I believe there is a long term plan being discussed. Devang, can you share what's being discussed so far? > > As I understand, the long term plan being discussed will not help here. Instead, the plan assumes that all instructions and machine instruction will have DebugLoc. So in other words, the plan requires that we solve this particular issue first. Ok. Instcombine has an IRBuilder that it uses, changing xforms to use the IRBuilder is vastly preferable to using setDebugLoc everywhere. > Without further delay, the plan being discussed seeks to find easier way to preserve debug values during code gen passes. > - The idea is to make position of DBG_VALUE machine instructions in instruction stream irrelevant by using a new mechanism (we have not detailed what exactly, but it could be just another intrinsic or metadata pair or something else...) to pair a LLVM definition to respective source level variable information. > - At the end of compilation just before emitting out put, a super intelligent pass is employed to > a) look at variable info, > b) find corresponding value definitions, > c) find scopes and ranges of these definitions based on line number info attached with each machine instruction > d) construct complete debug info picture based on these information. > > I am sure, others will correct me if I am missing something. It's hard to really comment on this without more details, but as long as there aren't tons of new setDebugLoc calls in InstCombine, I'll be happy :) -Chris From echristo at apple.com Tue May 3 19:48:02 2011 From: echristo at apple.com (Eric Christopher) Date: Wed, 04 May 2011 00:48:02 -0000 Subject: [llvm-commits] [llvm] r130812 - /llvm/trunk/test/MC/X86/x86-32-coverage.s Message-ID: <20110504004803.20F272A6C12C@llvm.org> Author: echristo Date: Tue May 3 19:48:02 2011 New Revision: 130812 URL: http://llvm.org/viewvc/llvm-project?rev=130812&view=rev Log: Remove some random comments that snuck in from somewhere. Modified: llvm/trunk/test/MC/X86/x86-32-coverage.s Modified: llvm/trunk/test/MC/X86/x86-32-coverage.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-32-coverage.s?rev=130812&r1=130811&r2=130812&view=diff ============================================================================== --- llvm/trunk/test/MC/X86/x86-32-coverage.s (original) +++ llvm/trunk/test/MC/X86/x86-32-coverage.s Tue May 3 19:48:02 2011 @@ -1,7 +1,3 @@ -# Build output for (null) -# Generated at (null) -# Using (null) configuration, (null) architecture for (null) target of (null) project - // RUN: llvm-mc -triple i386-unknown-unknown %s --show-encoding | FileCheck %s // CHECK: movb $127, 3735928559(%ebx,%ecx,8) From stoklund at 2pi.dk Tue May 3 20:01:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 01:01:36 -0000 Subject: [llvm-commits] [llvm] r130814 - /llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h Message-ID: <20110504010136.D21662A6C12C@llvm.org> Author: stoklund Date: Tue May 3 20:01:36 2011 New Revision: 130814 URL: http://llvm.org/viewvc/llvm-project?rev=130814&view=rev Log: Implement MSP430RegisterInfo::getMatchingSuperRegClass to enable cross-class coalescing. Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h Modified: llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h?rev=130814&r1=130813&r2=130814&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h (original) +++ llvm/trunk/lib/Target/MSP430/MSP430RegisterInfo.h Tue May 3 20:01:36 2011 @@ -39,6 +39,13 @@ BitVector getReservedRegs(const MachineFunction &MF) const; const TargetRegisterClass* getPointerRegClass(unsigned Kind = 0) const; + const TargetRegisterClass * + getMatchingSuperRegClass(const TargetRegisterClass *A, + const TargetRegisterClass *B, unsigned Idx) const { + // No sub-classes makes this really easy. + return A; + } + void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; From stoklund at 2pi.dk Tue May 3 20:01:39 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 01:01:39 -0000 Subject: [llvm-commits] [llvm] r130815 - /llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll Message-ID: <20110504010139.75E6C2A6C12D@llvm.org> Author: stoklund Date: Tue May 3 20:01:39 2011 New Revision: 130815 URL: http://llvm.org/viewvc/llvm-project?rev=130815&view=rev Log: Fix register-dependent test in MSP430. Modified: llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll Modified: llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll?rev=130815&r1=130814&r2=130815&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll (original) +++ llvm/trunk/test/CodeGen/MSP430/Inst8rr.ll Tue May 3 20:01:39 2011 @@ -10,7 +10,7 @@ define i8 @add(i8 %a, i8 %b) nounwind { ; CHECK: add: -; CHECK: add.b r12, r15 +; CHECK: add.b %1 = add i8 %a, %b ret i8 %1 } From stoklund at 2pi.dk Tue May 3 20:01:41 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 01:01:41 -0000 Subject: [llvm-commits] [llvm] r130816 - /llvm/trunk/test/CodeGen/XCore/mul64.ll Message-ID: <20110504010141.D9F6C2A6C12E@llvm.org> Author: stoklund Date: Tue May 3 20:01:41 2011 New Revision: 130816 URL: http://llvm.org/viewvc/llvm-project?rev=130816&view=rev Log: Fix register-dependent XCore tests Modified: llvm/trunk/test/CodeGen/XCore/mul64.ll Modified: llvm/trunk/test/CodeGen/XCore/mul64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/XCore/mul64.ll?rev=130816&r1=130815&r2=130816&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/XCore/mul64.ll (original) +++ llvm/trunk/test/CodeGen/XCore/mul64.ll Tue May 3 20:01:41 2011 @@ -9,7 +9,7 @@ } ; CHECK: umul_lohi: ; CHECK: ldc [[REG:r[0-9]+]], 0 -; CHECK-NEXT: lmul r1, r0, r1, r0, [[REG]], [[REG]] +; CHECK-NEXT: lmul {{.*}}, [[REG]], [[REG]] ; CHECK-NEXT: retsp 0 define i64 @smul_lohi(i32 %a, i32 %b) { @@ -23,9 +23,7 @@ ; CHECK: ldc ; CHECK-NEXT: mov ; CHECK-NEXT: maccs -; CHECK-NEXT: mov r0, -; CHECK-NEXT: mov r1, -; CHECK-NEXT: retsp 0 +; CHECK: retsp 0 define i64 @mul64(i64 %a, i64 %b) { entry: @@ -37,7 +35,6 @@ ; CHECK-NEXT: lmul ; CHECK-NEXT: mul ; CHECK-NEXT: lmul -; CHECK-NEXT: mov r0, define i64 @mul64_2(i64 %a, i32 %b) { entry: @@ -50,4 +47,4 @@ ; CHECK-NEXT: lmul ; CHECK-NEXT: mul ; CHECK-NEXT: add r1, -; CHECK-NEXT: retsp 0 +; CHECK: retsp 0 From stoklund at 2pi.dk Tue May 3 20:01:44 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 01:01:44 -0000 Subject: [llvm-commits] [llvm] r130817 - /llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll Message-ID: <20110504010144.70AF22A6C12C@llvm.org> Author: stoklund Date: Tue May 3 20:01:44 2011 New Revision: 130817 URL: http://llvm.org/viewvc/llvm-project?rev=130817&view=rev Log: Don't run this test through -regalloc=basic. The basic allocator is really bad about hinting, so it doesn't eliminate all copies when physreg joining is disabled. Modified: llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll Modified: llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll?rev=130817&r1=130816&r2=130817&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll (original) +++ llvm/trunk/test/CodeGen/Mips/o32_cc_vararg.ll Tue May 3 20:01:44 2011 @@ -1,5 +1,4 @@ ; RUN: llc -march=mipsel -mcpu=mips2 -pre-RA-sched=source < %s | FileCheck %s -; RUN: llc -march=mipsel -mcpu=mips2 -pre-RA-sched=source < %s -regalloc=basic | FileCheck %s ; All test functions do the same thing - they return the first variable From stoklund at 2pi.dk Tue May 3 20:01:47 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 01:01:47 -0000 Subject: [llvm-commits] [llvm] r130818 - in /llvm/trunk/test/CodeGen/X86: x86-64-extend-shift.ll xor.ll Message-ID: <20110504010147.42DA62A6C12D@llvm.org> Author: stoklund Date: Tue May 3 20:01:47 2011 New Revision: 130818 URL: http://llvm.org/viewvc/llvm-project?rev=130818&view=rev Log: Don't depend on the physreg coalescing order. Modified: llvm/trunk/test/CodeGen/X86/x86-64-extend-shift.ll llvm/trunk/test/CodeGen/X86/xor.ll Modified: llvm/trunk/test/CodeGen/X86/x86-64-extend-shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-extend-shift.ll?rev=130818&r1=130817&r2=130818&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/x86-64-extend-shift.ll (original) +++ llvm/trunk/test/CodeGen/X86/x86-64-extend-shift.ll Tue May 3 20:01:47 2011 @@ -2,7 +2,7 @@ ; Formerly there were two shifts. define i64 @baz(i32 %A) nounwind { -; CHECK: shlq $49, %rax +; CHECK: shlq $49, %r %tmp1 = shl i32 %A, 17 %tmp2 = zext i32 %tmp1 to i64 %tmp3 = shl i64 %tmp2, 32 Modified: llvm/trunk/test/CodeGen/X86/xor.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor.ll?rev=130818&r1=130817&r2=130818&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/xor.ll (original) +++ llvm/trunk/test/CodeGen/X86/xor.ll Tue May 3 20:01:47 2011 @@ -29,9 +29,8 @@ ret i32 %tmp4 ; X64: test3: -; X64: notl [[A1:%esi|%edx]] -; X64: andl [[A0:%edi|%ecx]], [[A1]] -; X64: movl [[A1]], %eax +; X64: notl +; X64: andl ; X64: shrl %eax ; X64: ret @@ -139,7 +138,7 @@ %t2 = add i32 %t1, -1 ret i32 %t2 ; X64: test8: -; X64: notl %eax +; X64: notl {{%eax|%edi|%ecx}} ; X32: test8: ; X32: notl %eax } From nicholas at mxc.ca Tue May 3 20:03:02 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 04 May 2011 01:03:02 -0000 Subject: [llvm-commits] [llvm] r130819 - in /llvm/trunk/utils/valgrind: i386-pc-linux-gnu.supp x86_64-pc-linux-gnu.supp Message-ID: <20110504010302.A8DDD2A6C12C@llvm.org> Author: nicholas Date: Tue May 3 20:03:02 2011 New Revision: 130819 URL: http://llvm.org/viewvc/llvm-project?rev=130819&view=rev Log: The system suppression file should catch these, but since they *once again* are not, I'll just add them here and be done with it. Modified: llvm/trunk/utils/valgrind/i386-pc-linux-gnu.supp llvm/trunk/utils/valgrind/x86_64-pc-linux-gnu.supp Modified: llvm/trunk/utils/valgrind/i386-pc-linux-gnu.supp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/valgrind/i386-pc-linux-gnu.supp?rev=130819&r1=130818&r2=130819&view=diff ============================================================================== --- llvm/trunk/utils/valgrind/i386-pc-linux-gnu.supp (original) +++ llvm/trunk/utils/valgrind/i386-pc-linux-gnu.supp Tue May 3 20:03:02 2011 @@ -39,3 +39,10 @@ fun:malloc obj:/usr/bin/python* } + +{ + We don't care about anything ld.so does. + Memcheck:Cond + obj:/lib/ld*.so +} + Modified: llvm/trunk/utils/valgrind/x86_64-pc-linux-gnu.supp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/valgrind/x86_64-pc-linux-gnu.supp?rev=130819&r1=130818&r2=130819&view=diff ============================================================================== --- llvm/trunk/utils/valgrind/x86_64-pc-linux-gnu.supp (original) +++ llvm/trunk/utils/valgrind/x86_64-pc-linux-gnu.supp Tue May 3 20:03:02 2011 @@ -44,3 +44,10 @@ fun:malloc obj:/usr/bin/python* } + +{ + We don't care about anything ld.so does. + Memcheck:Cond + obj:/lib/ld*.so +} + From srhines at google.com Tue May 3 20:24:04 2011 From: srhines at google.com (Stephen Hines) Date: Tue, 3 May 2011 18:24:04 -0700 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path Message-ID: Hi, I am sending this patch because I found that the non-MC ARM path was incorrectly encoding ARM PKH* instructions. They would essentially be encoded twice, where the second encoding would unwrap the shift amount in a way that register fields could be clobbered (by the shift amount/encoding). I do not have commit privileges, so I would appreciate it if someone could submit this for me. All current tests pass with this change, since I am using the non-MC path. Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/83aaf4db/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: pkh.patch Type: text/x-patch Size: 543 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/83aaf4db/attachment.bin From bruno.cardoso at gmail.com Tue May 3 20:31:24 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 3 May 2011 22:31:24 -0300 Subject: [llvm-commits] [PATCH] Mips backend. Emit $gp restore instructions. In-Reply-To: References: Message-ID: On Tue, May 3, 2011 at 8:18 PM, Akira Hatanaka wrote: > This patch prevents instructions using $gp from being placed between a jalr > and the instruction that restores the clobbered $gp (please see the > following example). > > The current implementation creates load nodes that restore $gp when call > instructions are lowered in MipsISelLowering::LowerCall. However, it does > not add chains or glues that are needed to make sure load/store nodes that > have $gp as an operand are not scheduled between JALR nodes and nodes that > restore $gp after the call. > > This patch runs a pre-regalloc pass that emits $gp restore instructions > instead. > > - bitcode > @p = external global i32 > ... > tail call void (...)* @f1() nounwind > %tmp = load i32* @p, align 4, !tbaa !0 > > - currently produces following code: > ... > lw? $25, %call16(f1)($gp) > jalr? $25??????????????????????? # calls f1. $gp is clobbered. > nop > lw? $3, 16($sp)????????????? # load $gp from stack. > lw? $2, %got(p)($gp)????? # this instr uses a clobbered $gp. > addu? $gp, $zero, $3???? # $gp is restored here. > ... > > - produces following code after patch is applied. > ... > lw? $25, %call16(f1)($gp) > lw? $16, %got(p)($gp)? # $gp has correct value here. > jalr? $25???????????????????? # calls f1. clobbers $gp. > nop > lw? $gp, 16($sp)????????? # $gp restored. > ... I've tried other approaches to solve this issue but they we're not clean enough, I can't figure out now another way besides doing a separate pass. If someone else knows a better a approach we can go for it, but in the meantime go for it. Please commit. -- Bruno Cardoso Lopes http://www.brunocardoso.cc From bruno.cardoso at gmail.com Tue May 3 20:34:22 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 3 May 2011 22:34:22 -0300 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path In-Reply-To: References: Message-ID: Hi Stephen, On Tue, May 3, 2011 at 10:24 PM, Stephen Hines wrote: > Hi, > I am sending this patch because I found that the non-MC ARM path was > incorrectly encoding ARM PKH* instructions. They would essentially be > encoded twice, where the second encoding would unwrap the shift amount in a > way that register fields could be clobbered (by the shift amount/encoding). > I do not have commit privileges, so I would appreciate it if someone could > submit this for me. All current tests pass with this change, since I am > using the non-MC path. Nice! Could you add an encoding test to the patch? See test/MC/ARM for examples. -- Bruno Cardoso Lopes http://www.brunocardoso.cc From srhines at google.com Tue May 3 20:35:21 2011 From: srhines at google.com (Stephen Hines) Date: Tue, 3 May 2011 18:35:21 -0700 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path In-Reply-To: References: Message-ID: The MC path is actually fine. This is for the non-MC path which seems to not have any tests. Steve On Tue, May 3, 2011 at 6:34 PM, Bruno Cardoso Lopes wrote: > Hi Stephen, > > On Tue, May 3, 2011 at 10:24 PM, Stephen Hines wrote: > > Hi, > > I am sending this patch because I found that the non-MC ARM path was > > incorrectly encoding ARM PKH* instructions. They would essentially be > > encoded twice, where the second encoding would unwrap the shift amount in > a > > way that register fields could be clobbered (by the shift > amount/encoding). > > I do not have commit privileges, so I would appreciate it if someone > could > > submit this for me. All current tests pass with this change, since I am > > using the non-MC path. > > Nice! Could you add an encoding test to the patch? See test/MC/ARM for > examples. > > -- > Bruno Cardoso Lopes > http://www.brunocardoso.cc > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/588c21a3/attachment-0001.html From srhines at google.com Tue May 3 20:50:22 2011 From: srhines at google.com (Stephen Hines) Date: Tue, 3 May 2011 18:50:22 -0700 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path In-Reply-To: References: Message-ID: I should be a bit more clear with my answer. The file test/CodeGen/ARM/pack.ll does contain tests for pkhbt and pkhtb, but they do not test the actual encoding of the instruction bits. The readable assembly code is correct, but it is the encoding where the problem shows up. If there are actual encoding tests for the classic code generation path on ARM, I would be more than happy to update them. The MC version does correctly generate the proper encoding (as seen in test/MC/ARM/simple-encoding.ll). Steve On Tue, May 3, 2011 at 6:35 PM, Stephen Hines wrote: > The MC path is actually fine. This is for the non-MC path which seems to > not have any tests. > > Steve > > > On Tue, May 3, 2011 at 6:34 PM, Bruno Cardoso Lopes < > bruno.cardoso at gmail.com> wrote: > >> Hi Stephen, >> >> On Tue, May 3, 2011 at 10:24 PM, Stephen Hines >> wrote: >> > Hi, >> > I am sending this patch because I found that the non-MC ARM path was >> > incorrectly encoding ARM PKH* instructions. They would essentially be >> > encoded twice, where the second encoding would unwrap the shift amount >> in a >> > way that register fields could be clobbered (by the shift >> amount/encoding). >> > I do not have commit privileges, so I would appreciate it if someone >> could >> > submit this for me. All current tests pass with this change, since I am >> > using the non-MC path. >> >> Nice! Could you add an encoding test to the patch? See test/MC/ARM for >> examples. >> >> -- >> Bruno Cardoso Lopes >> http://www.brunocardoso.cc >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110503/bc5b040b/attachment.html From daniel at zuster.org Tue May 3 20:48:36 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 04 May 2011 01:48:36 -0000 Subject: [llvm-commits] [zorg] r130825 - /zorg/trunk/lnt/lnt/lnttool/__init__.py Message-ID: <20110504014836.B3A4B2A6C12C@llvm.org> Author: ddunbar Date: Tue May 3 20:48:36 2011 New Revision: 130825 URL: http://llvm.org/viewvc/llvm-project?rev=130825&view=rev Log: lnt: Add a --version argument. Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=130825&r1=130824&r2=130825&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/__init__.py (original) +++ zorg/trunk/lnt/lnt/lnttool/__init__.py Tue May 3 20:48:36 2011 @@ -5,6 +5,7 @@ from optparse import OptionParser, OptionGroup import StringIO +import lnt from lnt import testing from lnt.db import perfdb @@ -401,28 +402,27 @@ commands = dict((name[7:], f) for name,f in locals().items() if name.startswith('action_')) - -def usage(): - print >>sys.stderr, "Usage: %s command [options]" % ( - os.path.basename(sys.argv[0])) - print >>sys.stderr - print >>sys.stderr, "Available commands:" +def main(): cmds_width = max(map(len, commands)) - for name,func in sorted(commands.items()): - print >>sys.stderr, " %-*s - %s" % (cmds_width, name, func.__doc__) - sys.exit(1) + parser = OptionParser("""\ +%%prog [options] ... arguments ... -def main(): - import sys +Available commands: +%s""" % ("\n".join(" %-*s - %s" % (cmds_width, name, func.__doc__) + for name, func in sorted(commands.items()))), + version = "lnt version %s" % lnt.__version__) + parser.disable_interspersed_args() + (opts, args) = parser.parse_args() - if len(sys.argv) < 2 or sys.argv[1] not in commands: - if len(sys.argv) >= 2: - print >>sys.stderr,"error: invalid command %r\n" % sys.argv[1] + if not args: + parser.print_usage() + return - usage() + cmd = args[0] + if cmd not in commands: + parser.error("invalid command: %r" % cmd) - cmd = sys.argv[1] - commands[cmd](cmd, sys.argv[2:]) + commands[cmd](cmd, args[1:]) if __name__ == '__main__': main() From daniel at zuster.org Tue May 3 20:48:39 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 04 May 2011 01:48:39 -0000 Subject: [llvm-commits] [zorg] r130826 - /zorg/trunk/lnt/lnt/lnttool/__init__.py Message-ID: <20110504014839.C1A7C2A6C12D@llvm.org> Author: ddunbar Date: Tue May 3 20:48:39 2011 New Revision: 130826 URL: http://llvm.org/viewvc/llvm-project?rev=130826&view=rev Log: lnt runserver: Switch --use-flask-app to default. Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=130826&r1=130825&r2=130826&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/__init__.py (original) +++ zorg/trunk/lnt/lnt/lnttool/__init__.py Tue May 3 20:48:39 2011 @@ -27,9 +27,6 @@ parser.add_option("", "--processes", dest="processes", type=int, metavar="N", help="number of processes to use [%default]", default=1) - parser.add_option("", "--use-flask-app", dest="use_flask_app", - help="use the Flask based UI [%default]", - action="store_true", default=False) (opts, args) = parser.parse_args(args) if len(args) != 1: @@ -46,23 +43,16 @@ if not config or not os.path.exists(config): raise SystemExit,"error: invalid config: %r" % config - if opts.use_flask_app: - import lnt.server.ui.app - instance = lnt.server.ui.app.App.create_standalone( - config_path = config) - if opts.debugger: - instance.debug = True - instance.run(opts.hostname, opts.port, - use_reloader = opts.reloader, - use_debugger = opts.debugger, - threaded = opts.threaded, - processes = opts.processes) - else: - from werkzeug import run_simple - from lnt.viewer import app - run_simple(opts.hostname, opts.port, app.create_app(config), - opts.reloader, opts.debugger, - False, None, 1, opts.threaded, opts.processes) + import lnt.server.ui.app + instance = lnt.server.ui.app.App.create_standalone( + config_path = config) + if opts.debugger: + instance.debug = True + instance.run(opts.hostname, opts.port, + use_reloader = opts.reloader, + use_debugger = opts.debugger, + threaded = opts.threaded, + processes = opts.processes) from create import action_create from convert import action_convert From daniel at zuster.org Tue May 3 20:48:42 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 04 May 2011 01:48:42 -0000 Subject: [llvm-commits] [zorg] r130827 - /zorg/trunk/lnt/lnt/db/runinfo.py Message-ID: <20110504014842.22F312A6C12E@llvm.org> Author: ddunbar Date: Tue May 3 20:48:41 2011 New Revision: 130827 URL: http://llvm.org/viewvc/llvm-project?rev=130827&view=rev Log: lnt.db.runinfo: Change default value_precision to match current output of LLVM test suite, and add an argument to allow disabling the logic which ignores any change under 1%. Modified: zorg/trunk/lnt/lnt/db/runinfo.py Modified: zorg/trunk/lnt/lnt/db/runinfo.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/runinfo.py?rev=130827&r1=130826&r2=130827&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/runinfo.py (original) +++ zorg/trunk/lnt/lnt/db/runinfo.py Tue May 3 20:48:41 2011 @@ -37,7 +37,8 @@ else: return UNCHANGED_PASS - def get_value_status(self, confidence_interval=2.576, value_precision=0.01): + def get_value_status(self, confidence_interval=2.576, + value_precision=0.0001, ignore_small=True): if self.current is None or self.previous is None: return None @@ -61,7 +62,7 @@ # Always ignore percentage changes below 1%, for now, we just don't have # enough time to investigate that level of stuff. - if abs(self.pct_delta) < .01: + if ignore_small and abs(self.pct_delta) < .01: return UNCHANGED_PASS # If we have a comparison window, then measure using a symmetic From eli.friedman at gmail.com Tue May 3 21:07:09 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 3 May 2011 19:07:09 -0700 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path In-Reply-To: References: Message-ID: On Tue, May 3, 2011 at 6:50 PM, Stephen Hines wrote: > I should be a bit more clear with my answer. The > file?test/CodeGen/ARM/pack.ll does contain tests for pkhbt and pkhtb, but > they do not test the actual encoding of the instruction bits. The readable > assembly code is correct, but it is the encoding where the problem shows up. > If there are actual encoding tests for the classic code generation path on > ARM, I would be more than happy to update them. The MC version does > correctly generate the proper encoding (as seen in > test/MC/ARM/simple-encoding.ll). We don't really have any in-tree tests for the old JIT codepath. -Eli From atrick at apple.com Tue May 3 21:10:14 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 04 May 2011 02:10:14 -0000 Subject: [llvm-commits] [llvm] r130829 - in /llvm/trunk/lib: Analysis/IVUsers.cpp Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110504021014.1C1302A6C12C@llvm.org> Author: atrick Date: Tue May 3 21:10:13 2011 New Revision: 130829 URL: http://llvm.org/viewvc/llvm-project?rev=130829&view=rev Log: indvars: Added DisableIVRewrite and WidenIVs. This adds functionality to remove size/zero extension during indvars without generating a canonical IV and rewriting all IV users. It's disabled by default so should have no effect on codegen. Work in progress. Modified: llvm/trunk/lib/Analysis/IVUsers.cpp llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Analysis/IVUsers.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IVUsers.cpp?rev=130829&r1=130828&r2=130829&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IVUsers.cpp (original) +++ llvm/trunk/lib/Analysis/IVUsers.cpp Tue May 3 21:10:13 2011 @@ -21,6 +21,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Target/TargetData.h" #include "llvm/Assembly/Writer.h" #include "llvm/ADT/STLExtras.h" @@ -38,6 +39,15 @@ INITIALIZE_PASS_END(IVUsers, "iv-users", "Induction Variable Users", false, true) +// IVUsers behavior currently depends on this temporary indvars mode. The +// option must be defined upstream from its uses. +namespace llvm { + bool DisableIVRewrite = false; +} +cl::opt DisableIVRewriteOpt( + "disable-iv-rewrite", cl::Hidden, cl::location(llvm::DisableIVRewrite), + cl::desc("Disable canonical induction variable rewriting")); + Pass *llvm::createIVUsersPass() { return new IVUsers(); } @@ -90,6 +100,11 @@ if (Width > 64 || (TD && !TD->isLegalInteger(Width))) return false; + // We expect Sign/Zero extension to be eliminated from the IR before analyzing + // any downstream uses. + if (DisableIVRewrite && (isa(I) || isa(I))) + return false; + if (!Processed.insert(I)) return true; // Instruction already handled. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=130829&r1=130828&r2=130829&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Tue May 3 21:10:13 2011 @@ -52,33 +52,41 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Support/CFG.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" +#include "llvm/Target/TargetData.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" using namespace llvm; STATISTIC(NumRemoved , "Number of aux indvars removed"); +STATISTIC(NumWidened , "Number of indvars widened"); STATISTIC(NumInserted, "Number of canonical indvars added"); STATISTIC(NumReplaced, "Number of exit values replaced"); STATISTIC(NumLFTR , "Number of loop exit tests replaced"); +// DisableIVRewrite mode currently affects IVUsers, so is defined in libAnalysis +// and referenced here. +namespace llvm { + extern bool DisableIVRewrite; +} + namespace { class IndVarSimplify : public LoopPass { IVUsers *IU; LoopInfo *LI; ScalarEvolution *SE; DominatorTree *DT; + TargetData *TD; SmallVector DeadInsts; bool Changed; public: static char ID; // Pass identification, replacement for typeid - IndVarSimplify() : LoopPass(ID) { + IndVarSimplify() : LoopPass(ID), IU(0), LI(0), SE(0), DT(0), TD(0) { initializeIndVarSimplifyPass(*PassRegistry::getPassRegistry()); } @@ -104,6 +112,7 @@ void EliminateIVComparisons(); void EliminateIVRemainders(); void RewriteNonIntegerIVs(Loop *L); + const Type *WidenIVs(Loop *L, SCEVExpander &Rewriter); bool canExpandBackedgeTakenCount(Loop *L, const SCEV *BackedgeTakenCount); @@ -111,6 +120,7 @@ ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV *BackedgeTakenCount, PHINode *IndVar, SCEVExpander &Rewriter); + void RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter); void RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter); @@ -123,7 +133,7 @@ char IndVarSimplify::ID = 0; INITIALIZE_PASS_BEGIN(IndVarSimplify, "indvars", - "Canonicalize Induction Variables", false, false) + "Induction Variable Simplification", false, false) INITIALIZE_PASS_DEPENDENCY(DominatorTree) INITIALIZE_PASS_DEPENDENCY(LoopInfo) INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) @@ -131,7 +141,7 @@ INITIALIZE_PASS_DEPENDENCY(LCSSA) INITIALIZE_PASS_DEPENDENCY(IVUsers) INITIALIZE_PASS_END(IndVarSimplify, "indvars", - "Canonicalize Induction Variables", false, false) + "Induction Variable Simplification", false, false) Pass *llvm::createIndVarSimplifyPass() { return new IndVarSimplify(); @@ -209,7 +219,7 @@ // rewriting the loop. if (isa(BackedgeTakenCount)) { ICmpInst *OrigCond = dyn_cast(BI->getCondition()); - if (!OrigCond) return 0; + if (!OrigCond) return false; const SCEV *R = SE->getSCEV(OrigCond->getOperand(1)); R = SE->getMinusSCEV(R, SE->getConstant(R->getType(), 1)); if (R != BackedgeTakenCount) { @@ -549,6 +559,8 @@ LI = &getAnalysis(); SE = &getAnalysis(); DT = &getAnalysis(); + TD = getAnalysisIfAvailable(); + DeadInsts.clear(); Changed = false; @@ -560,6 +572,13 @@ // Create a rewriter object which we'll use to transform the code with. SCEVExpander Rewriter(*SE); + if (DisableIVRewrite) + Rewriter.disableCanonicalMode(); + + const Type *LargestType = 0; + if (DisableIVRewrite) { + LargestType = WidenIVs(L, Rewriter); + } // Check to see if this loop has a computable loop-invariant execution count. // If so, this means that we can compute the final value of any expressions @@ -578,7 +597,6 @@ // Compute the type of the largest recurrence expression, and decide whether // a canonical induction variable should be inserted. - const Type *LargestType = 0; bool NeedCannIV = false; bool ExpandBECount = canExpandBackedgeTakenCount(L, BackedgeTakenCount); if (ExpandBECount) { @@ -598,8 +616,19 @@ SE->getEffectiveSCEVType(I->getOperandValToReplace()->getType()); if (!LargestType || SE->getTypeSizeInBits(Ty) > + SE->getTypeSizeInBits(LargestType)) + LargestType = SE->getEffectiveSCEVType(Ty); + } + if (!DisableIVRewrite) { + for (IVUsers::const_iterator I = IU->begin(), E = IU->end(); I != E; ++I) { + NeedCannIV = true; + const Type *Ty = + SE->getEffectiveSCEVType(I->getOperandValToReplace()->getType()); + if (!LargestType || + SE->getTypeSizeInBits(Ty) > SE->getTypeSizeInBits(LargestType)) - LargestType = Ty; + LargestType = Ty; + } } // Now that we know the largest of the induction variable expressions @@ -647,9 +676,9 @@ NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, Rewriter); } - // Rewrite IV-derived expressions. - RewriteIVExpressions(L, Rewriter); + if (!DisableIVRewrite) + RewriteIVExpressions(L, Rewriter); // Clear the rewriter cache, because values that are in the rewriter's cache // can be deleted in the loop below, causing the AssertingVH in the cache to @@ -721,6 +750,83 @@ return false; } +/// Widen the type of any induction variables that are sign/zero extended and +/// remove the [sz]ext uses. +/// +/// FIXME: This may currently create extra IVs which could increase regpressure +/// (without LSR to cleanup). +/// +/// FIXME: may factor this with RewriteIVExpressions once it stabilizes. +const Type *IndVarSimplify::WidenIVs(Loop *L, SCEVExpander &Rewriter) { + const Type *LargestType = 0; + for (IVUsers::iterator UI = IU->begin(), E = IU->end(); UI != E; ++UI) { + Instruction *ExtInst = UI->getUser(); + if (!isa(ExtInst) && !isa(ExtInst)) + continue; + const SCEV *AR = SE->getSCEV(ExtInst); + // Only widen this IV is SCEV tells us it's safe. + if (!isa(AR) && !isa(AR)) + continue; + + if (!L->contains(UI->getUser())) { + const SCEV *ExitVal = SE->getSCEVAtScope(AR, L->getParentLoop()); + if (SE->isLoopInvariant(ExitVal, L)) + AR = ExitVal; + } + + // Only expand affine recurences. + if (!isSafe(AR, L, SE)) + continue; + + const Type *Ty = + SE->getEffectiveSCEVType(ExtInst->getType()); + + // Only remove [sz]ext if the wide IV is still a native type. + // + // FIXME: We may be able to remove the copy of this logic in + // IVUsers::AddUsersIfInteresting. + uint64_t Width = SE->getTypeSizeInBits(Ty); + if (Width > 64 || (TD && !TD->isLegalInteger(Width))) + continue; + + // Now expand it into actual Instructions and patch it into place. + // + // FIXME: avoid creating a new IV. + Value *NewVal = Rewriter.expandCodeFor(AR, Ty, ExtInst); + + DEBUG(dbgs() << "INDVARS: Widened IV '" << *AR << "' " << *ExtInst << '\n' + << " into = " << *NewVal << "\n"); + + if (!isValidRewrite(ExtInst, NewVal)) { + DeadInsts.push_back(NewVal); + continue; + } + + ++NumWidened; + Changed = true; + + if (!LargestType || + SE->getTypeSizeInBits(Ty) > + SE->getTypeSizeInBits(LargestType)) + LargestType = Ty; + + SE->forgetValue(ExtInst); + + // Patch the new value into place. + if (ExtInst->hasName()) + NewVal->takeName(ExtInst); + ExtInst->replaceAllUsesWith(NewVal); + + // The old value may be dead now. + DeadInsts.push_back(ExtInst); + + // UI is a linked list iterator, so AddUsersIfInteresting effectively pushes + // nodes on the worklist. + IU->AddUsersIfInteresting(ExtInst); + } + return LargestType; +} + void IndVarSimplify::RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter) { // Rewrite all induction variable expressions in terms of the canonical // induction variable. From bruno.cardoso at gmail.com Tue May 3 21:28:31 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 3 May 2011 23:28:31 -0300 Subject: [llvm-commits] Fix an encoding issue with ARM PKH* instructions for non-MC path In-Reply-To: References: Message-ID: On Tue, May 3, 2011 at 10:50 PM, Stephen Hines wrote: > I should be a bit more clear with my answer. The > file?test/CodeGen/ARM/pack.ll does contain tests for pkhbt and pkhtb, but > they do not test the actual encoding of the instruction bits. The readable > assembly code is correct, but it is the encoding where the problem shows up. > If there are actual encoding tests for the classic code generation path on > ARM, I would be more than happy to update them. The MC version does > correctly generate the proper encoding (as seen in > test/MC/ARM/simple-encoding.ll). I misread the "non-MC path" on the subject :) -- Bruno Cardoso Lopes http://www.brunocardoso.cc From isanbard at gmail.com Tue May 3 21:40:54 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 04 May 2011 02:40:54 -0000 Subject: [llvm-commits] [llvm] r130831 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20110504024054.312C82A6C12C@llvm.org> Author: void Date: Tue May 3 21:40:54 2011 New Revision: 130831 URL: http://llvm.org/viewvc/llvm-project?rev=130831&view=rev Log: Remove dead intrinsics. 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=130831&r1=130830&r2=130831&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue May 3 21:40:54 2011 @@ -224,9 +224,6 @@ // Cacheability support ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_sse_movnt_ps : GCCBuiltin<"__builtin_ia32_movntps">, - Intrinsic<[], [llvm_ptr_ty, - llvm_v4f32_ty], []>; def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">, Intrinsic<[], [], []>; } @@ -536,19 +533,6 @@ llvm_v4i32_ty], []>; } -// Cacheability support ops -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_sse2_movnt_dq : GCCBuiltin<"__builtin_ia32_movntdq">, - Intrinsic<[], [llvm_ptr_ty, - llvm_v2i64_ty], []>; - def int_x86_sse2_movnt_pd : GCCBuiltin<"__builtin_ia32_movntpd">, - Intrinsic<[], [llvm_ptr_ty, - llvm_v2f64_ty], []>; - def int_x86_sse2_movnt_i : GCCBuiltin<"__builtin_ia32_movnti">, - Intrinsic<[], [llvm_ptr_ty, - llvm_i32_ty], []>; -} - // Misc. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">, From nicholas at mxc.ca Tue May 3 22:58:45 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 04 May 2011 03:58:45 -0000 Subject: [llvm-commits] [llvm] r130834 - /llvm/trunk/runtime/libprofile/GCDAProfiling.c Message-ID: <20110504035845.4191F2A6C12C@llvm.org> Author: nicholas Date: Tue May 3 22:58:45 2011 New Revision: 130834 URL: http://llvm.org/viewvc/llvm-project?rev=130834&view=rev Log: Fix crash when not setting GCOV_PREFIX. Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130834&r1=130833&r2=130834&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Tue May 3 22:58:45 2011 @@ -54,7 +54,7 @@ prefix = getenv("GCOV_PREFIX"); if (!prefix) - return strdup(filename); + return strdup(orig_filename); filename = malloc(strlen(prefix) + 1 + strlen(orig_filename) + 1); strcpy(filename, prefix); From nicholas at mxc.ca Tue May 3 23:03:04 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 04 May 2011 04:03:04 -0000 Subject: [llvm-commits] [llvm] r130835 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Message-ID: <20110504040304.AAAF72A6C12C@llvm.org> Author: nicholas Date: Tue May 3 23:03:04 2011 New Revision: 130835 URL: http://llvm.org/viewvc/llvm-project?rev=130835&view=rev Log: Emit gcov data files to the directory specified in the metadata produced by the frontend, if applicable. Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130835&r1=130834&r2=130835&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Tue May 3 23:03:04 2011 @@ -40,7 +40,6 @@ namespace { class GCOVProfiler : public ModulePass { - bool runOnModule(Module &M); public: static char ID; GCOVProfiler() @@ -57,6 +56,8 @@ } private: + bool runOnModule(Module &M); + // Create the GCNO files for the Module based on DebugInfo. void emitGCNO(DebugInfoFinder &DIF); @@ -88,6 +89,8 @@ SmallVector, 8> &); + std::string mangleName(DICompileUnit CU, std::string NewStem); + bool EmitNotes; bool EmitData; @@ -323,6 +326,22 @@ return (sys::path::stem(OrigFilename) + "." + NewStem).str(); } +std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) { + if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) { + for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { + MDNode *N = GCov->getOperand(i); + if (N->getNumOperands() != 2) continue; + MDString *Path = dyn_cast(N->getOperand(0)); + MDNode *CompileUnit = dyn_cast(N->getOperand(1)); + if (!Path || !CompileUnit) continue; + if (CompileUnit == CU) + return (Path->getString() + "/" + + replaceStem(CU.getFilename(), NewStem)).str(); + } + } + return replaceStem(CU.getFilename(), NewStem); +} + bool GCOVProfiler::runOnModule(Module &M) { this->M = &M; Ctx = &M.getContext(); @@ -346,8 +365,8 @@ DICompileUnit CU(*I); raw_fd_ostream *&out = GcnoFiles[CU]; std::string ErrorInfo; - out = new raw_fd_ostream(replaceStem(CU.getFilename(), "gcno").c_str(), - ErrorInfo, raw_fd_ostream::F_Binary); + out = new raw_fd_ostream(mangleName(CU, "gcno").c_str(), ErrorInfo, + raw_fd_ostream::F_Binary); out->write("oncg*404MVLL", 12); } @@ -615,7 +634,7 @@ for (DebugInfoFinder::iterator CUI = DIF.compile_unit_begin(), CUE = DIF.compile_unit_end(); CUI != CUE; ++CUI) { DICompileUnit compile_unit(*CUI); - std::string FilenameGcda = replaceStem(compile_unit.getFilename(), "gcda"); + std::string FilenameGcda = mangleName(compile_unit, "gcda"); Builder.CreateCall(StartFile, Builder.CreateGlobalStringPtr(FilenameGcda)); for (SmallVector, 8>::iterator From baldrick at free.fr Wed May 4 11:05:05 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 May 2011 16:05:05 -0000 Subject: [llvm-commits] [llvm] r130840 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp test/Transforms/InstSimplify/maxmin.ll Message-ID: <20110504160505.F0B572A6C12C@llvm.org> Author: baldrick Date: Wed May 4 11:05:05 2011 New Revision: 130840 URL: http://llvm.org/viewvc/llvm-project?rev=130840&view=rev Log: Add variations on: max(x,y) >= min(x,z) folds to true. This isn't that common, but according to my super-optimizer there are only two missed simplifications of -instsimplify kind when compiling bzip2, and this is one of them. It amuses me to have bzip2 be perfectly optimized as far as instsimplify goes! Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/test/Transforms/InstSimplify/maxmin.ll Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=130840&r1=130839&r2=130840&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Wed May 4 11:05:05 2011 @@ -1873,7 +1873,7 @@ CmpInst::Predicate P = CmpInst::BAD_ICMP_PREDICATE; CmpInst::Predicate EqP; // Chosen so that "A == max/min(A,B)" iff "A EqP B". - // Signed max/min. + // Signed variants on "max(a,b)>=a -> true". if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { if (A != RHS) std::swap(A, B); // smax(A, B) pred A. EqP = CmpInst::ICMP_SGE; // "A == smax(A, B)" iff "A sge B". @@ -1929,7 +1929,7 @@ } } - // Unsigned max/min. + // Unsigned variants on "max(a,b)>=a -> true". P = CmpInst::BAD_ICMP_PREDICATE; if (match(LHS, m_UMax(m_Value(A), m_Value(B))) && (A == RHS || B == RHS)) { if (A != RHS) std::swap(A, B); // umax(A, B) pred A. @@ -1986,6 +1986,50 @@ } } + // Variants on "max(x,y) >= min(x,z)". + Value *C, *D; + if (match(LHS, m_SMax(m_Value(A), m_Value(B))) && + match(RHS, m_SMin(m_Value(C), m_Value(D))) && + (A == C || A == D || B == C || B == D)) { + // max(x, ?) pred min(x, ?). + if (Pred == CmpInst::ICMP_SGE) + // Always true. + return Constant::getAllOnesValue(ITy); + if (Pred == CmpInst::ICMP_SLT) + // Always false. + return Constant::getNullValue(ITy); + } else if (match(LHS, m_SMin(m_Value(A), m_Value(B))) && + match(RHS, m_SMax(m_Value(C), m_Value(D))) && + (A == C || A == D || B == C || B == D)) { + // min(x, ?) pred max(x, ?). + if (Pred == CmpInst::ICMP_SLE) + // Always true. + return Constant::getAllOnesValue(ITy); + if (Pred == CmpInst::ICMP_SGT) + // Always false. + return Constant::getNullValue(ITy); + } else if (match(LHS, m_UMax(m_Value(A), m_Value(B))) && + match(RHS, m_UMin(m_Value(C), m_Value(D))) && + (A == C || A == D || B == C || B == D)) { + // max(x, ?) pred min(x, ?). + if (Pred == CmpInst::ICMP_UGE) + // Always true. + return Constant::getAllOnesValue(ITy); + if (Pred == CmpInst::ICMP_ULT) + // Always false. + return Constant::getNullValue(ITy); + } else if (match(LHS, m_UMin(m_Value(A), m_Value(B))) && + match(RHS, m_UMax(m_Value(C), m_Value(D))) && + (A == C || A == D || B == C || B == D)) { + // min(x, ?) pred max(x, ?). + if (Pred == CmpInst::ICMP_ULE) + // Always true. + return Constant::getAllOnesValue(ITy); + if (Pred == CmpInst::ICMP_UGT) + // Always false. + return Constant::getNullValue(ITy); + } + // If the comparison is with the result of a select instruction, check whether // comparing with either branch of the select always yields the same value. if (isa(LHS) || isa(RHS)) Modified: llvm/trunk/test/Transforms/InstSimplify/maxmin.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/maxmin.ll?rev=130840&r1=130839&r2=130840&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstSimplify/maxmin.ll (original) +++ llvm/trunk/test/Transforms/InstSimplify/maxmin.ll Wed May 4 11:05:05 2011 @@ -143,3 +143,91 @@ ret i1 %r ; CHECK: ret i1 true } + +define i1 @maxmin1(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin1 + %c1 = icmp sge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp sge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp sge i32 %max, %min + ret i1 %c +; CHECK: ret i1 true +} + +define i1 @maxmin2(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin2 + %c1 = icmp sge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp sge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp sgt i32 %min, %max + ret i1 %c +; CHECK: ret i1 false +} + +define i1 @maxmin3(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin3 + %c1 = icmp sge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp sge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp sle i32 %min, %max + ret i1 %c +; CHECK: ret i1 true +} + +define i1 @maxmin4(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin4 + %c1 = icmp sge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp sge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp slt i32 %max, %min + ret i1 %c +; CHECK: ret i1 false +} + +define i1 @maxmin5(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin5 + %c1 = icmp uge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp uge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp uge i32 %max, %min + ret i1 %c +; CHECK: ret i1 true +} + +define i1 @maxmin6(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin6 + %c1 = icmp uge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp uge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp ugt i32 %min, %max + ret i1 %c +; CHECK: ret i1 false +} + +define i1 @maxmin7(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin7 + %c1 = icmp uge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp uge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp ule i32 %min, %max + ret i1 %c +; CHECK: ret i1 true +} + +define i1 @maxmin8(i32 %x, i32 %y, i32 %z) { +; CHECK: @maxmin8 + %c1 = icmp uge i32 %x, %y + %max = select i1 %c1, i32 %x, i32 %y + %c2 = icmp uge i32 %x, %z + %min = select i1 %c2, i32 %z, i32 %x + %c = icmp ult i32 %max, %min + ret i1 %c +; CHECK: ret i1 false +} From dpatel at apple.com Wed May 4 11:34:02 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 16:34:02 -0000 Subject: [llvm-commits] [llvm] r130842 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110504163402.BC0312A6C12C@llvm.org> Author: dpatel Date: Wed May 4 11:34:02 2011 New Revision: 130842 URL: http://llvm.org/viewvc/llvm-project?rev=130842&view=rev Log: Tighten up check for empty (i.e. no meaningful debug info) module. This fixes dwarf-die2.c test case from gcc test suite. 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=130842&r1=130841&r2=130842&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May 4 11:34:02 2011 @@ -1113,32 +1113,35 @@ if (DisableDebugInfoPrinting) return; - bool HasDebugInfo = false; - // If module has named metadata anchors then use them, otherwise scan the module // using debug info finder to collect debug info. NamedMDNode *CU_Nodes = M->getNamedMetadata("llvm.dbg.cu"); if (CU_Nodes) { - for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { - HasDebugInfo = true; - constructCompileUnit(CU_Nodes->getOperand(i)); - } - if (!HasDebugInfo) + + NamedMDNode *GV_Nodes = M->getNamedMetadata("llvm.dbg.gv"); + NamedMDNode *SP_Nodes = M->getNamedMetadata("llvm.dbg.sp"); + if (!GV_Nodes && !SP_Nodes) + // If there are not any global variables or any functions then + // there is not any debug info in this module. return; - if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv")) - for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) - constructGlobalVariableDIE(NMD->getOperand(i)); - - if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.sp")) - for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) - constructSubprogramDIE(NMD->getOperand(i)); + for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) + constructCompileUnit(CU_Nodes->getOperand(i)); + + if (GV_Nodes) + for (unsigned i = 0, e = GV_Nodes->getNumOperands(); i != e; ++i) + constructGlobalVariableDIE(GV_Nodes->getOperand(i)); + + if (SP_Nodes) + for (unsigned i = 0, e = SP_Nodes->getNumOperands(); i != e; ++i) + constructSubprogramDIE(SP_Nodes->getOperand(i)); } else { DebugInfoFinder DbgFinder; DbgFinder.processModule(*M); + bool HasDebugInfo = false; // Scan all the compile-units to see if there are any marked as the main unit. // if not, we do not generate debug info. for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), @@ -1148,6 +1151,7 @@ break; } } + if (!HasDebugInfo) return; // Create all the compile unit DIEs. for (DebugInfoFinder::iterator I = DbgFinder.compile_unit_begin(), @@ -1165,8 +1169,6 @@ constructSubprogramDIE(*I); } - if (!HasDebugInfo) return; - // Tell MMI that we have debug info. MMI->setDebugInfoAvailability(true); From dpatel at apple.com Wed May 4 11:39:26 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 09:39:26 -0700 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <1A474230-04EB-4BA5-9B1C-A14B6117C315@apple.com> References: <20110429081541.B7F422A6C138@llvm.org> <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> <5F0816C4-4FC4-4F02-8B7E-51858107AC6D@googlemail.com> <2E25739D-6707-4365-9DC5-E22C7C8E9644@apple.com> <1A474230-04EB-4BA5-9B1C-A14B6117C315@apple.com> Message-ID: On May 3, 2011, at 5:46 PM, Chris Lattner wrote: > Ok. Instcombine has an IRBuilder that it uses, changing xforms to use the IRBuilder is vastly preferable to using setDebugLoc everywhere. ... ... > It's hard to really comment on this without more details, but as long as there aren't tons of new setDebugLoc calls in InstCombine, I'll be happy :) ok :) - Devang From stoklund at 2pi.dk Wed May 4 11:45:05 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 16:45:05 -0000 Subject: [llvm-commits] [llvm] r130844 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Message-ID: <20110504164505.C7B9A2A6C12C@llvm.org> Author: stoklund Date: Wed May 4 11:45:05 2011 New Revision: 130844 URL: http://llvm.org/viewvc/llvm-project?rev=130844&view=rev Log: Rename -disable-physical-join to -join-physregs and invert it. Physreg joining is still on by default, but I will turn it off shortly. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=130844&r1=130843&r2=130844&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed May 4 11:45:05 2011 @@ -61,9 +61,9 @@ cl::init(false), cl::Hidden); static cl::opt -DisablePhysicalJoin("disable-physical-join", - cl::desc("Avoid coalescing physical register copies"), - cl::init(false), cl::Hidden); +EnablePhysicalJoin("join-physregs", + cl::desc("Join physical register copies"), + cl::init(true), cl::Hidden); static cl::opt VerifyCoalescing("verify-coalescing", @@ -927,7 +927,7 @@ if (!Allocatable && CP.isFlipped() && JoinVInt.containsOneValue()) return true; - if (DisablePhysicalJoin) { + if (!EnablePhysicalJoin) { DEBUG(dbgs() << "\tPhysreg joins disabled.\n"); return false; } From aggarwa4 at illinois.edu Wed May 4 11:56:12 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 04 May 2011 16:56:12 -0000 Subject: [llvm-commits] [poolalloc] r130845 - /poolalloc/trunk/lib/DSA/StdLibPass.cpp Message-ID: <20110504165612.C73F22A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 4 11:56:12 2011 New Revision: 130845 URL: http://llvm.org/viewvc/llvm-project?rev=130845&view=rev Log: Add comment to identify index/rindex functions as similiar to strchr/strrchr. This might he helpful if we make changes to either's summary. Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=130845&r1=130844&r2=130845&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Wed May 4 11:56:12 2011 @@ -270,8 +270,12 @@ {"pool_strncpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_stpcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + // strchr and index have same functionality {"pool_strchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_index", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + // strrchr and rindex have same functionality {"pool_strrchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_rindex", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, {"pool_strcat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strncat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strstr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, @@ -289,8 +293,6 @@ {"pool_strncasecmp",{NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"pool_bcopy", {NRET_NNYARGS, NRET_NNNYARGS, NRET_NARGS, NRET_NNYARGS, true}}, {"pool_bcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, - {"pool_index", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, - {"pool_rindex", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, #if 0 {"wait", {false, false, false, false, true, false, false, false, false}}, From rafael.espindola at gmail.com Wed May 4 12:44:07 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 04 May 2011 17:44:07 -0000 Subject: [llvm-commits] [llvm] r130846 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp test/DebugInfo/stmt-list.ll Message-ID: <20110504174407.2F66D2A6C12C@llvm.org> Author: rafael Date: Wed May 4 12:44:06 2011 New Revision: 130846 URL: http://llvm.org/viewvc/llvm-project?rev=130846&view=rev Log: Producing a DW_FORM_addr for DW_AT_stmt_list is probably correct, but it is both inefficient and unexpected by dwarfdump. Change to a DW_FORM_data4. While in here, change the predicate name to reflect that the position is not really absolute (it is an offset), just that the linker needs a relocation. Added: llvm/trunk/test/DebugInfo/stmt-list.ll Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130846&r1=130845&r2=130846&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Wed May 4 12:44:06 2011 @@ -279,9 +279,9 @@ /// DwarfSectionOffsetDirective - Special section offset directive. const char* DwarfSectionOffsetDirective; // Defaults to NULL - /// DwarfUsesAbsoluteLabelForStmtList - True if DW_AT_stmt_list needs - /// absolute label instead of offset. - bool DwarfUsesAbsoluteLabelForStmtList; // Defaults to true; + /// DwarfRequiresRelocationForStmtList - True if DW_AT_stmt_list needs + /// a relocation to the correct offset. + bool DwarfRequiresRelocationForStmtList; // Defaults to true; // DwarfUsesLabelOffsetDifference - True if Dwarf2 output can // use EmitLabelOffsetDifference. @@ -476,8 +476,8 @@ const char *getDwarfSectionOffsetDirective() const { return DwarfSectionOffsetDirective; } - bool doesDwarfUsesAbsoluteLabelForStmtList() const { - return DwarfUsesAbsoluteLabelForStmtList; + bool doesDwarfRequireRelocationForStmtList() const { + return DwarfRequiresRelocationForStmtList; } bool doesDwarfUsesLabelOffsetForRanges() const { return DwarfUsesLabelOffsetForRanges; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130846&r1=130845&r2=130846&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed May 4 12:44:06 2011 @@ -896,8 +896,8 @@ NewCU->addUInt(Die, dwarf::DW_AT_entry_pc, dwarf::DW_FORM_addr, 0); // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. - if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) - NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, + if(Asm->MAI->doesDwarfRequireRelocationForStmtList()) + NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, Asm->GetTempSymbol("section_line")); else NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130846&r1=130845&r2=130846&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Wed May 4 12:44:06 2011 @@ -76,7 +76,7 @@ ExceptionsType = ExceptionHandling::None; DwarfRequiresFrameSection = true; DwarfUsesInlineInfoSection = false; - DwarfUsesAbsoluteLabelForStmtList = true; + DwarfRequiresRelocationForStmtList = true; DwarfSectionOffsetDirective = 0; DwarfUsesLabelOffsetForRanges = true; HasMicrosoftFastStdCallMangling = false; Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=130846&r1=130845&r2=130846&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Wed May 4 12:44:06 2011 @@ -56,6 +56,6 @@ HasNoDeadStrip = true; HasSymbolResolver = true; - DwarfUsesAbsoluteLabelForStmtList = false; + DwarfRequiresRelocationForStmtList = false; DwarfUsesLabelOffsetForRanges = false; } Added: llvm/trunk/test/DebugInfo/stmt-list.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/stmt-list.ll?rev=130846&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/stmt-list.ll (added) +++ llvm/trunk/test/DebugInfo/stmt-list.ll Wed May 4 12:44:06 2011 @@ -0,0 +1,19 @@ +; RUN: llc -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s + +; CHECK: .section .debug_line,"", at progbits +; CHECK-NEXT: .Lsection_line: + +; CHECK: .long .Lsection_line # DW_AT_stmt_list + +define void @f() { +entry: + ret void +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @f, null, null} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} From ahatanak at gmail.com Wed May 4 12:54:28 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Wed, 04 May 2011 17:54:28 -0000 Subject: [llvm-commits] [llvm] r130847 - in /llvm/trunk: lib/Target/Mips/Mips.h lib/Target/Mips/MipsEmitGPRestore.cpp lib/Target/Mips/MipsISelLowering.cpp lib/Target/Mips/MipsTargetMachine.cpp lib/Target/Mips/MipsTargetMachine.h test/CodeGen/Mips/gprestore.ll test/CodeGen/Mips/internalfunc.ll Message-ID: <20110504175428.349262A6C12C@llvm.org> Author: ahatanak Date: Wed May 4 12:54:27 2011 New Revision: 130847 URL: http://llvm.org/viewvc/llvm-project?rev=130847&view=rev Log: Prevent instructions using $gp from being placed between a jalr and the instruction that restores the clobbered $gp. Added: llvm/trunk/lib/Target/Mips/MipsEmitGPRestore.cpp llvm/trunk/test/CodeGen/Mips/gprestore.ll Modified: llvm/trunk/lib/Target/Mips/Mips.h llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp llvm/trunk/lib/Target/Mips/MipsTargetMachine.h llvm/trunk/test/CodeGen/Mips/internalfunc.ll Modified: llvm/trunk/lib/Target/Mips/Mips.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips.h?rev=130847&r1=130846&r2=130847&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips.h (original) +++ llvm/trunk/lib/Target/Mips/Mips.h Wed May 4 12:54:27 2011 @@ -26,6 +26,7 @@ FunctionPass *createMipsISelDag(MipsTargetMachine &TM); FunctionPass *createMipsDelaySlotFillerPass(MipsTargetMachine &TM); FunctionPass *createMipsExpandPseudoPass(MipsTargetMachine &TM); + FunctionPass *createMipsEmitGPRestorePass(MipsTargetMachine &TM); extern Target TheMipsTarget; extern Target TheMipselTarget; Added: llvm/trunk/lib/Target/Mips/MipsEmitGPRestore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsEmitGPRestore.cpp?rev=130847&view=auto ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsEmitGPRestore.cpp (added) +++ llvm/trunk/lib/Target/Mips/MipsEmitGPRestore.cpp Wed May 4 12:54:27 2011 @@ -0,0 +1,80 @@ +//===-- MipsEmitGPRestore.cpp - Emit GP restore instruction-----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===-----------------------------------------------------------------------===// +// +// This pass emits instructions that restore $gp right +// after jalr instructions. +// +//===-----------------------------------------------------------------------===// + +#define DEBUG_TYPE "emit-gp-restore" + +#include "Mips.h" +#include "MipsTargetMachine.h" +#include "MipsMachineFunction.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/ADT/Statistic.h" + +using namespace llvm; + +namespace { + struct Inserter : public MachineFunctionPass { + + TargetMachine &TM; + const TargetInstrInfo *TII; + + static char ID; + Inserter(TargetMachine &tm) + : MachineFunctionPass(ID), TM(tm), TII(tm.getInstrInfo()) { } + + virtual const char *getPassName() const { + return "Mips Emit GP Restore"; + } + + bool runOnMachineBasicBlock(MachineBasicBlock &MBB); + bool runOnMachineFunction(MachineFunction &F); + }; + char Inserter::ID = 0; +} // end of anonymous namespace + +bool Inserter::runOnMachineFunction(MachineFunction &F) { + if (TM.getRelocationModel() != Reloc::PIC_) + return false; + + bool Changed = false; + int FI = F.getInfo()->getGPFI(); + + for (MachineFunction::iterator MFI = F.begin(), MFE = F.end(); + MFI != MFE; ++MFI) { + MachineBasicBlock& MBB = *MFI; + MachineBasicBlock::iterator I = MFI->begin(); + + while (I != MFI->end()) { + if (I->getOpcode() != Mips::JALR) { + ++I; + continue; + } + + DebugLoc dl = I->getDebugLoc(); + // emit lw $gp, ($gp save slot on stack) after jalr + BuildMI(MBB, ++I, dl, TII->get(Mips::LW), Mips::GP).addImm(0).addFrameIndex(FI); + Changed = true; + } + } + + return Changed; +} + +/// createMipsEmitGPRestorePass - Returns a pass that emits instructions that +/// restores $gp clobbered by jalr instructions. +FunctionPass *llvm::createMipsEmitGPRestorePass(MipsTargetMachine &tm) { + return new Inserter(tm); +} + Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=130847&r1=130846&r2=130847&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Wed May 4 12:54:27 2011 @@ -1298,17 +1298,6 @@ } MipsFI->setGPStackOffset(LastArgStackLoc); } - - // Reload GP value. - FI = MipsFI->getGPFI(); - SDValue FIN = DAG.getFrameIndex(FI, getPointerTy()); - SDValue GPLoad = DAG.getLoad(MVT::i32, dl, Chain, FIN, - MachinePointerInfo::getFixedStack(FI), - false, false, 0); - Chain = GPLoad.getValue(1); - Chain = DAG.getCopyToReg(Chain, dl, DAG.getRegister(Mips::GP, MVT::i32), - GPLoad, SDValue(0,0)); - InFlag = Chain.getValue(1); } // Create the CALLSEQ_END node. Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp?rev=130847&r1=130846&r2=130847&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp Wed May 4 12:54:27 2011 @@ -77,6 +77,12 @@ } bool MipsTargetMachine:: +addPreRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { + PM.add(createMipsEmitGPRestorePass(*this)); + return true; +} + +bool MipsTargetMachine:: addPostRegAlloc(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { PM.add(createMipsExpandPseudoPass(*this)); return true; Modified: llvm/trunk/lib/Target/Mips/MipsTargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetMachine.h?rev=130847&r1=130846&r2=130847&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.h (original) +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.h Wed May 4 12:54:27 2011 @@ -63,6 +63,8 @@ CodeGenOpt::Level OptLevel); virtual bool addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel); + virtual bool addPreRegAlloc(PassManagerBase &PM, + CodeGenOpt::Level OptLevel); virtual bool addPostRegAlloc(PassManagerBase &, CodeGenOpt::Level); }; Added: llvm/trunk/test/CodeGen/Mips/gprestore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/gprestore.ll?rev=130847&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Mips/gprestore.ll (added) +++ llvm/trunk/test/CodeGen/Mips/gprestore.ll Wed May 4 12:54:27 2011 @@ -0,0 +1,35 @@ +; RUN: llc -march=mips < %s | FileCheck %s + + at p = external global i32 + at q = external global i32 + at r = external global i32 + +define void @f0() nounwind { +entry: +; CHECK: jalr +; CHECK-NOT: got({{.*}})($gp) +; CHECK: lw $gp +; CHECK: jalr +; CHECK-NOT: got({{.*}})($gp) +; CHECK: lw $gp +; CHECK: jalr +; CHECK-NOT: got({{.*}})($gp) +; CHECK: lw $gp + tail call void (...)* @f1() nounwind + %tmp = load i32* @p, align 4, !tbaa !0 + tail call void @f2(i32 %tmp) nounwind + %tmp1 = load i32* @q, align 4, !tbaa !0 + %tmp2 = load i32* @r, align 4, !tbaa !0 + tail call void @f3(i32 %tmp1, i32 %tmp2) nounwind + ret void +} + +declare void @f1(...) + +declare void @f2(i32) + +declare void @f3(i32, i32) + +!0 = metadata !{metadata !"int", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA", null} Modified: llvm/trunk/test/CodeGen/Mips/internalfunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/internalfunc.ll?rev=130847&r1=130846&r2=130847&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/internalfunc.ll (original) +++ llvm/trunk/test/CodeGen/Mips/internalfunc.ll Wed May 4 12:54:27 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=mips | FileCheck %s +; RUN: llc < %s -march=mipsel -mcpu=4ke | FileCheck %s @caller.sf1 = internal unnamed_addr global void (...)* null, align 4 @gf1 = external global void (...)* From ahatanak at gmail.com Wed May 4 13:28:36 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Wed, 04 May 2011 18:28:36 -0000 Subject: [llvm-commits] [llvm] r130849 - /llvm/trunk/test/CodeGen/Mips/gprestore.ll Message-ID: <20110504182836.5E6BB2A6C12C@llvm.org> Author: ahatanak Date: Wed May 4 13:28:36 2011 New Revision: 130849 URL: http://llvm.org/viewvc/llvm-project?rev=130849&view=rev Log: Remove LLVM IR metadata in test case committed in r130847. Modified: llvm/trunk/test/CodeGen/Mips/gprestore.ll Modified: llvm/trunk/test/CodeGen/Mips/gprestore.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/gprestore.ll?rev=130849&r1=130848&r2=130849&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/gprestore.ll (original) +++ llvm/trunk/test/CodeGen/Mips/gprestore.ll Wed May 4 13:28:36 2011 @@ -16,10 +16,10 @@ ; CHECK-NOT: got({{.*}})($gp) ; CHECK: lw $gp tail call void (...)* @f1() nounwind - %tmp = load i32* @p, align 4, !tbaa !0 + %tmp = load i32* @p, align 4 tail call void @f2(i32 %tmp) nounwind - %tmp1 = load i32* @q, align 4, !tbaa !0 - %tmp2 = load i32* @r, align 4, !tbaa !0 + %tmp1 = load i32* @q, align 4 + %tmp2 = load i32* @r, align 4 tail call void @f3(i32 %tmp1, i32 %tmp2) nounwind ret void } @@ -30,6 +30,3 @@ declare void @f3(i32, i32) -!0 = metadata !{metadata !"int", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA", null} From rafael.espindola at gmail.com Wed May 4 13:46:57 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 04 May 2011 18:46:57 -0000 Subject: [llvm-commits] [llvm] r130850 - /llvm/trunk/lib/Target/Mips/CMakeLists.txt Message-ID: <20110504184657.0D3C22A6C12C@llvm.org> Author: rafael Date: Wed May 4 13:46:56 2011 New Revision: 130850 URL: http://llvm.org/viewvc/llvm-project?rev=130850&view=rev Log: Fix cmake build. Modified: llvm/trunk/lib/Target/Mips/CMakeLists.txt Modified: llvm/trunk/lib/Target/Mips/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/CMakeLists.txt?rev=130850&r1=130849&r2=130850&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/Mips/CMakeLists.txt Wed May 4 13:46:56 2011 @@ -13,6 +13,7 @@ add_llvm_target(MipsCodeGen MipsAsmPrinter.cpp MipsDelaySlotFiller.cpp + MipsEmitGPRestore.cpp MipsExpandPseudo.cpp MipsInstrInfo.cpp MipsISelDAGToDAG.cpp From fjahanian at apple.com Wed May 4 13:57:05 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Wed, 04 May 2011 18:57:05 -0000 Subject: [llvm-commits] [test-suite] r130852 - /test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c Message-ID: <20110504185705.148DE2A6C12C@llvm.org> Author: fjahanian Date: Wed May 4 13:57:04 2011 New Revision: 130852 URL: http://llvm.org/viewvc/llvm-project?rev=130852&view=rev Log: Test for packing of ms_struct bitfields. // rdar://8823265 Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c?rev=130852&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c (added) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield.c Wed May 4 13:57:04 2011 @@ -0,0 +1,160 @@ +extern void abort (); + +#define ATTR __attribute__((__ms_struct__)) + +#define size_struct_0 1 +#define size_struct_1 4 +#define size_struct_2 24 +#define size_struct_3 8 +#define size_struct_4 32 +#define size_struct_5 12 +#define size_struct_6 40 +#define size_struct_7 8 +#define size_struct_8 20 +#define size_struct_9 32 + +struct _struct_0 +{ + char member_0; +} ATTR; +typedef struct _struct_0 struct_0; + +struct _struct_1 +{ + char member_0; + short member_1:13; +} ATTR; +typedef struct _struct_1 struct_1; + +struct _struct_2 +{ + double member_0; + unsigned char member_1:8; + int member_2:32; + unsigned char member_3:5; + short member_4:14; + short member_5:13; + unsigned char:0; +} ATTR; +typedef struct _struct_2 struct_2; + +struct _struct_3 +{ + unsigned int member_0:26; + unsigned char member_1:2; + +} ATTR; +typedef struct _struct_3 struct_3; + +struct _struct_4 +{ + unsigned char member_0:7; + double member_1; + double member_2; + short member_3:5; + char member_4:2; + +} ATTR; +typedef struct _struct_4 struct_4; + +struct _struct_5 +{ + unsigned short member_0:12; + int member_1:1; + unsigned short member_2:6; + +} ATTR; +typedef struct _struct_5 struct_5; + +struct _struct_6 +{ + unsigned char member_0:7; + unsigned int member_1:25; + char member_2:1; + double member_3; + short member_4:9; + double member_5; + +} ATTR; +typedef struct _struct_6 struct_6; + +struct _struct_7 +{ + double member_0; + +} ATTR; +typedef struct _struct_7 struct_7; + +struct _struct_8 +{ + unsigned char member_0:7; + int member_1:11; + int member_2:5; + int:0; + char member_4:8; + unsigned short member_5:4; + unsigned char member_6:3; + int member_7:23; + +} ATTR; +typedef struct _struct_8 struct_8; + +struct _struct_9 +{ + double member_0; + unsigned int member_1:6; + int member_2:17; + double member_3; + unsigned int member_4:22; + +} ATTR; +typedef struct _struct_9 struct_9; + +struct_0 test_struct_0 = { 123 }; +struct_1 test_struct_1 = { 82, 1081 }; +struct_2 test_struct_2 = { 20.0, 31, 407760, 1, 14916, 6712 }; +struct_3 test_struct_3 = { 64616999, 1 }; +struct_4 test_struct_4 = { 61, 20.0, 20.0, 12, 0 }; +struct_5 test_struct_5 = { 909, 1, 57 }; +struct_6 test_struct_6 = { 12, 21355796, 0, 20.0, 467, 20.0 }; +struct_7 test_struct_7 = { 20.0 }; +struct_8 test_struct_8 = { 126, 1821, 22, 125, 6, 0, 2432638 }; +struct_9 test_struct_9 = { 20.0, 3, 23957, 20.0, 1001631 }; + + +int +main (void) +{ + + if (size_struct_0 != sizeof (struct_0)) + abort (); + + if (size_struct_1 != sizeof (struct_1)) + abort (); + + if (size_struct_2 != sizeof (struct_2)) + abort (); + + if (size_struct_3 != sizeof (struct_3)) + abort (); + + if (size_struct_4 != sizeof (struct_4)) + abort (); + + if (size_struct_5 != sizeof (struct_5)) + abort (); + + if (size_struct_6 != sizeof (struct_6)) + abort (); + + if (size_struct_7 != sizeof (struct_7)) + abort (); + + if (size_struct_8 != sizeof (struct_8)) + abort (); + + if (size_struct_9 != sizeof (struct_9)) + abort (); + + return 0; +} From dpatel at apple.com Wed May 4 14:00:57 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 19:00:57 -0000 Subject: [llvm-commits] [llvm] r130854 - in /llvm/trunk: lib/Target/ARM/ARMAsmPrinter.cpp test/CodeGen/ARM/debug-info-sreg2.ll Message-ID: <20110504190057.EB3AE2A6C12C@llvm.org> Author: dpatel Date: Wed May 4 14:00:57 2011 New Revision: 130854 URL: http://llvm.org/viewvc/llvm-project?rev=130854&view=rev Log: Do not emit location expression size twice. Added: llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=130854&r1=130853&r2=130854&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed May 4 14:00:57 2011 @@ -188,7 +188,6 @@ unsigned SReg = Reg - ARM::S0; unsigned Rx = 256 + (SReg >> 1); - OutStreamer.AddComment("Loc expr size"); // DW_OP_regx + ULEB + DW_OP_bit_piece + ULEB + ULEB // 1 + ULEB(Rx) + 1 + 1 + 1 return 4 + MCAsmInfo::getULEB128Size(Rx); @@ -203,7 +202,6 @@ unsigned D1 = 256 + 2 * QReg; unsigned D2 = D1 + 1; - OutStreamer.AddComment("Loc expr size"); // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8) + // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8); // 6 + ULEB(D1) + ULEB(D2) @@ -229,10 +227,6 @@ unsigned SReg = Reg - ARM::S0; bool odd = SReg & 0x1; unsigned Rx = 256 + (SReg >> 1); - OutStreamer.AddComment("Loc expr size"); - // DW_OP_regx + ULEB + DW_OP_bit_piece + ULEB + ULEB - // 1 + ULEB(Rx) + 1 + 1 + 1 - EmitInt16(4 + MCAsmInfo::getULEB128Size(Rx)); OutStreamer.AddComment("DW_OP_regx for S register"); EmitInt8(dwarf::DW_OP_regx); @@ -260,12 +254,6 @@ unsigned D1 = 256 + 2 * QReg; unsigned D2 = D1 + 1; - OutStreamer.AddComment("Loc expr size"); - // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8) + - // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8); - // 6 + ULEB(D1) + ULEB(D2) - EmitInt16(6 + MCAsmInfo::getULEB128Size(D1) + MCAsmInfo::getULEB128Size(D2)); - OutStreamer.AddComment("DW_OP_regx for Q register: D1"); EmitInt8(dwarf::DW_OP_regx); EmitULEB128(D1); Added: llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll?rev=130854&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll (added) +++ llvm/trunk/test/CodeGen/ARM/debug-info-sreg2.ll Wed May 4 14:00:57 2011 @@ -0,0 +1,59 @@ +; RUN: llc < %s - | FileCheck %s +; Radar 9376013 +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:32:64-v128:32:128-a0:0:32-n32" +target triple = "thumbv7-apple-macosx10.6.7" + +;CHECK: Ldebug_loc0: +;CHECK-NEXT: .long Ltmp0 +;CHECK-NEXT: .long Ltmp2 +;CHECK-NEXT: .short 6 @ Loc expr size +;CHECK-NEXT: .byte 144 @ DW_OP_regx for S register + +define void @_Z3foov() optsize ssp { +entry: + %call = tail call float @_Z3barv() optsize, !dbg !11 + tail call void @llvm.dbg.value(metadata !{float %call}, i64 0, metadata !5), !dbg !11 + %call16 = tail call float @_Z2f2v() optsize, !dbg !12 + %cmp7 = fcmp olt float %call, %call16, !dbg !12 + br i1 %cmp7, label %for.body, label %for.end, !dbg !12 + +for.body: ; preds = %entry, %for.body + %k.08 = phi float [ %inc, %for.body ], [ %call, %entry ] + %call4 = tail call float @_Z2f3f(float %k.08) optsize, !dbg !13 + %inc = fadd float %k.08, 1.000000e+00, !dbg !14 + %call1 = tail call float @_Z2f2v() optsize, !dbg !12 + %cmp = fcmp olt float %inc, %call1, !dbg !12 + br i1 %cmp, label %for.body, label %for.end, !dbg !12 + +for.end: ; preds = %for.body, %entry + ret void, !dbg !15 +} + +declare float @_Z3barv() optsize + +declare float @_Z2f2v() optsize + +declare float @_Z2f3f(float) optsize + +declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone + +!llvm.dbg.cu = !{!0} +!llvm.dbg.sp = !{!1} +!llvm.dbg.lv._Z3foov = !{!5, !8} + +!0 = metadata !{i32 589841, i32 0, i32 4, metadata !"k.cc", metadata !"/private/tmp", metadata !"clang version 3.0 (trunk 130845)", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!1 = metadata !{i32 589870, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"_Z3foov", metadata !2, i32 5, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @_Z3foov, null, null} ; [ DW_TAG_subprogram ] +!2 = metadata !{i32 589865, metadata !"k.cc", metadata !"/private/tmp", metadata !0} ; [ DW_TAG_file_type ] +!3 = metadata !{i32 589845, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} +!5 = metadata !{i32 590080, metadata !6, metadata !"k", metadata !2, i32 6, metadata !7, i32 0} ; [ DW_TAG_auto_variable ] +!6 = metadata !{i32 589835, metadata !1, i32 5, i32 12, metadata !2, i32 0} ; [ DW_TAG_lexical_block ] +!7 = metadata !{i32 589860, metadata !0, metadata !"float", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] +!8 = metadata !{i32 590080, metadata !9, metadata !"y", metadata !2, i32 8, metadata !7, i32 0} ; [ DW_TAG_auto_variable ] +!9 = metadata !{i32 589835, metadata !10, i32 7, i32 25, metadata !2, i32 2} ; [ DW_TAG_lexical_block ] +!10 = metadata !{i32 589835, metadata !6, i32 7, i32 3, metadata !2, i32 1} ; [ DW_TAG_lexical_block ] +!11 = metadata !{i32 6, i32 18, metadata !6, null} +!12 = metadata !{i32 7, i32 3, metadata !6, null} +!13 = metadata !{i32 8, i32 20, metadata !9, null} +!14 = metadata !{i32 7, i32 20, metadata !10, null} +!15 = metadata !{i32 10, i32 1, metadata !6, null} From stoklund at 2pi.dk Wed May 4 14:01:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 19:01:59 -0000 Subject: [llvm-commits] [llvm] r130855 - in /llvm/trunk/test: CodeGen/PowerPC/2010-03-09-indirect-call.ll MC/ARM/simple-encoding.ll Message-ID: <20110504190159.564432A6C12C@llvm.org> Author: stoklund Date: Wed May 4 14:01:59 2011 New Revision: 130855 URL: http://llvm.org/viewvc/llvm-project?rev=130855&view=rev Log: Explicitly request -join-physregs for some tests that depend on it. Modified: llvm/trunk/test/CodeGen/PowerPC/2010-03-09-indirect-call.ll llvm/trunk/test/MC/ARM/simple-encoding.ll Modified: llvm/trunk/test/CodeGen/PowerPC/2010-03-09-indirect-call.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2010-03-09-indirect-call.ll?rev=130855&r1=130854&r2=130855&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2010-03-09-indirect-call.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/2010-03-09-indirect-call.ll Wed May 4 14:01:59 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=ppc32 -mcpu=g5 -mtriple=powerpc-apple-darwin10.0 | FileCheck %s +; RUN: llc < %s -march=ppc32 -mcpu=g5 -mtriple=powerpc-apple-darwin10.0 -join-physregs | FileCheck %s ; ModuleID = 'nn.c' 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-f128:64:128" target triple = "powerpc-apple-darwin11.0" Modified: llvm/trunk/test/MC/ARM/simple-encoding.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-encoding.ll?rev=130855&r1=130854&r2=130855&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/simple-encoding.ll (original) +++ llvm/trunk/test/MC/ARM/simple-encoding.ll Wed May 4 14:01:59 2011 @@ -1,4 +1,4 @@ -;RUN: llc -mtriple=armv7-apple-darwin -show-mc-encoding -disable-cgp-branch-opts < %s | FileCheck %s +;RUN: llc -mtriple=armv7-apple-darwin -show-mc-encoding -disable-cgp-branch-opts -join-physregs < %s | FileCheck %s ;FIXME: Once the ARM integrated assembler is up and going, these sorts of tests From stoklund at 2pi.dk Wed May 4 14:02:04 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 19:02:04 -0000 Subject: [llvm-commits] [llvm] r130857 - in /llvm/trunk/lib/Target/SystemZ: SystemZRegisterInfo.cpp SystemZRegisterInfo.h Message-ID: <20110504190204.690B02A6C12E@llvm.org> Author: stoklund Date: Wed May 4 14:02:04 2011 New Revision: 130857 URL: http://llvm.org/viewvc/llvm-project?rev=130857&view=rev Log: Implement SystemZRegisterInfo::getMatchingSuperRegClass to enable cross-class joins. Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp?rev=130857&r1=130856&r2=130857&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.cpp Wed May 4 14:02:04 2011 @@ -58,6 +58,20 @@ return Reserved; } +const TargetRegisterClass* +SystemZRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, + const TargetRegisterClass *B, + unsigned Idx) const { + switch(Idx) { + // Exact sub-classes don't exist for the other sub-register indexes. + default: return 0; + case SystemZ::subreg_32bit: + if (B == SystemZ::ADDR32RegisterClass) + return A->getSize() == 8 ? SystemZ::ADDR64RegisterClass : 0; + return A; + } +} + void SystemZRegisterInfo:: eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { Modified: llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h?rev=130857&r1=130856&r2=130857&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZRegisterInfo.h Wed May 4 14:02:04 2011 @@ -34,6 +34,10 @@ BitVector getReservedRegs(const MachineFunction &MF) const; + const TargetRegisterClass* + getMatchingSuperRegClass(const TargetRegisterClass *A, + const TargetRegisterClass *B, unsigned Idx) const; + void eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const; From stoklund at 2pi.dk Wed May 4 14:02:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 19:02:01 -0000 Subject: [llvm-commits] [llvm] r130856 - /llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll Message-ID: <20110504190201.CE1232A6C12D@llvm.org> Author: stoklund Date: Wed May 4 14:02:01 2011 New Revision: 130856 URL: http://llvm.org/viewvc/llvm-project?rev=130856&view=rev Log: FileCheckize and break dependence on coalescing order. Modified: llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll Modified: llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll?rev=130856&r1=130855&r2=130856&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/big-endian-formal-args.ll Wed May 4 14:02:01 2011 @@ -1,14 +1,12 @@ -; RUN: llc < %s -march=ppc32 -mtriple=powerpc-unknown-linux-gnu | \ -; RUN: grep {li 6, 3} -; RUN: llc < %s -march=ppc32 -mtriple=powerpc-unknown-linux-gnu | \ -; RUN: grep {li 4, 2} -; RUN: llc < %s -march=ppc32 -mtriple=powerpc-unknown-linux-gnu | \ -; RUN: grep {li 3, 0} -; RUN: llc < %s -march=ppc32 -mtriple=powerpc-unknown-linux-gnu | \ -; RUN: grep {mr 5, 3} +; RUN: llc < %s -march=ppc32 -mtriple=powerpc-unknown-linux-gnu | FileCheck %s declare void @bar(i64 %x, i64 %y) +; CHECK: li 4, 2 +; CHECK: li {{[53]}}, 0 +; CHECK: li 6, 3 +; CHECK: mr {{[53]}}, {{[53]}} + define void @foo() { call void @bar(i64 2, i64 3) ret void From stoklund at 2pi.dk Wed May 4 14:02:07 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 19:02:07 -0000 Subject: [llvm-commits] [llvm] r130858 - in /llvm/trunk/test/CodeGen/Thumb2: thumb2-cmn.ll thumb2-cmp.ll thumb2-cmp2.ll thumb2-teq.ll thumb2-teq2.ll thumb2-tst.ll thumb2-tst2.ll Message-ID: <20110504190207.DA84B2A6C12C@llvm.org> Author: stoklund Date: Wed May 4 14:02:07 2011 New Revision: 130858 URL: http://llvm.org/viewvc/llvm-project?rev=130858&view=rev Log: Explicitly request physreg coalesing for a bunch of Thumb2 unit tests. These tests all follow the same pattern: mov r2, r0 movs r0, #0 $CMP r2, r1 it eq moveq r0, #1 bx lr The first 'mov' can be eliminated by rematerializing 'movs r0, #0' below the test instruction: $CMP r0, r1 mov.w r0, #0 it eq moveq r0, #1 bx lr So far, only physreg coalescing can do that. The register allocators won't yet split live ranges just to eliminate copies. They can learn, but this particular problem is not likely to show up in real code. It only appears because r0 is used for both the function argument and return value. Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cmn.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp2.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-teq.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-teq2.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-tst.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-tst2.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cmn.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cmn.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cmn.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cmn.ll Wed May 4 14:02:07 2011 @@ -1,4 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s + +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; test as 'mov.w r0, #0'. So far, that requires physreg joining. define i1 @f1(i32 %a, i32 %b) { %nb = sub i32 0, %b Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp.ll Wed May 4 14:02:07 2011 @@ -1,4 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s + +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; test as 'mov.w r0, #0'. So far, that requires physreg joining. ; 0x000000bb = 187 define i1 @f1(i32 %a) { Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp2.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cmp2.ll Wed May 4 14:02:07 2011 @@ -1,4 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s + +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; test as 'mov.w r0, #0'. So far, that requires physreg joining. define i1 @f1(i32 %a, i32 %b) { ; CHECK: f1: Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-teq.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-teq.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-teq.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-teq.ll Wed May 4 14:02:07 2011 @@ -1,5 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; test as 'mov.w r0, #0'. So far, that requires physreg joining. ; 0x000000bb = 187 define i1 @f1(i32 %a) { Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-teq2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-teq2.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-teq2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-teq2.ll Wed May 4 14:02:07 2011 @@ -1,4 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s + +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; tst as 'mov.w r0, #0'. So far, that requires physreg joining. define i1 @f1(i32 %a, i32 %b) { ; CHECK: f1 Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tst.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-tst.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-tst.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-tst.ll Wed May 4 14:02:07 2011 @@ -1,5 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; tst as 'mov.w r0, #0'. So far, that requires physreg joining. ; 0x000000bb = 187 define i1 @f1(i32 %a) { Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-tst2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-tst2.ll?rev=130858&r1=130857&r2=130858&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-tst2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-tst2.ll Wed May 4 14:02:07 2011 @@ -1,4 +1,7 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+thumb2 -join-physregs | FileCheck %s + +; These tests implicitly depend on 'movs r0, #0' being rematerialized below the +; tst as 'mov.w r0, #0'. So far, that requires physreg joining. define i1 @f1(i32 %a, i32 %b) { ; CHECK: f1: From stoklund at 2pi.dk Wed May 4 14:02:11 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 19:02:11 -0000 Subject: [llvm-commits] [llvm] r130859 - in /llvm/trunk/test/CodeGen: SPARC/2011-01-22-SRet.ll Thumb/2009-08-20-ISelBug.ll Thumb2/2010-08-10-VarSizedAllocaBug.ll Thumb2/bfi.ll Message-ID: <20110504190211.3F63F2A6C12D@llvm.org> Author: stoklund Date: Wed May 4 14:02:11 2011 New Revision: 130859 URL: http://llvm.org/viewvc/llvm-project?rev=130859&view=rev Log: Fix more register and coalescing dependencies. Modified: llvm/trunk/test/CodeGen/SPARC/2011-01-22-SRet.ll llvm/trunk/test/CodeGen/Thumb/2009-08-20-ISelBug.ll llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll llvm/trunk/test/CodeGen/Thumb2/bfi.ll Modified: llvm/trunk/test/CodeGen/SPARC/2011-01-22-SRet.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2011-01-22-SRet.ll?rev=130859&r1=130858&r2=130859&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/SPARC/2011-01-22-SRet.ll (original) +++ llvm/trunk/test/CodeGen/SPARC/2011-01-22-SRet.ll Wed May 4 14:02:11 2011 @@ -6,7 +6,6 @@ entry: ;CHECK: make_foo ;CHECK: ld [%fp+64], {{.+}} -;CHECK: or {{.+}}, {{.+}}, %i0 ;CHECK: jmp %i7+12 %0 = getelementptr inbounds %struct.foo_t* %agg.result, i32 0, i32 0 store i32 %a, i32* %0, align 4 Modified: llvm/trunk/test/CodeGen/Thumb/2009-08-20-ISelBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2009-08-20-ISelBug.ll?rev=130859&r1=130858&r2=130859&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/2009-08-20-ISelBug.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/2009-08-20-ISelBug.ll Wed May 4 14:02:11 2011 @@ -11,7 +11,7 @@ define i32 @t(%struct.asl_file_t* %s, i64 %off, i64* %out) nounwind optsize { ; CHECK: t: -; CHECK: adds r0, #8 +; CHECK: adds {{r[0-7]}}, #8 entry: %val = alloca i64, align 4 ; [#uses=3] %0 = icmp eq %struct.asl_file_t* %s, null ; [#uses=1] Modified: llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll?rev=130859&r1=130858&r2=130859&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll Wed May 4 14:02:11 2011 @@ -7,8 +7,8 @@ ; CHECK: Callee: ; CHECK: push ; CHECK: mov r4, sp -; CHECK: sub.w r12, r4, #1000 -; CHECK: mov sp, r12 +; CHECK: sub.w [[R12:r[0-9]+]], r4, #1000 +; CHECK: mov sp, [[R12]] %0 = icmp eq i32 %i, 0 ; [#uses=1] br i1 %0, label %bb2, label %bb Modified: llvm/trunk/test/CodeGen/Thumb2/bfi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/bfi.ll?rev=130859&r1=130858&r2=130859&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/bfi.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/bfi.ll Wed May 4 14:02:11 2011 @@ -30,9 +30,8 @@ define i32 @f3(i32 %A, i32 %B) nounwind readnone optsize { entry: ; CHECK: f3 -; CHECK: lsrs r2, r0, #7 -; CHECK: mov r0, r1 -; CHECK: bfi r0, r2, #7, #16 +; CHECK: lsrs {{.*}}, #7 +; CHECK: bfi {{.*}}, #7, #16 %and = and i32 %A, 8388480 ; [#uses=1] %and2 = and i32 %B, -8388481 ; [#uses=1] %or = or i32 %and2, %and ; [#uses=1] @@ -42,8 +41,8 @@ ; rdar://8752056 define i32 @f4(i32 %a) nounwind { ; CHECK: f4 -; CHECK: movw r1, #3137 -; CHECK: bfi r1, r0, #15, #5 +; CHECK: movw [[R1:r[0-9]+]], #3137 +; CHECK: bfi [[R1]], {{.*}}, #15, #5 %1 = shl i32 %a, 15 %ins7 = and i32 %1, 1015808 %ins12 = or i32 %ins7, 3137 From baldrick at free.fr Wed May 4 14:13:01 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 May 2011 19:13:01 -0000 Subject: [llvm-commits] [llvm] r130860 - /llvm/trunk/tools/gold/gold-plugin.cpp Message-ID: <20110504191301.9102F2A6C12C@llvm.org> Author: baldrick Date: Wed May 4 14:13:01 2011 New Revision: 130860 URL: http://llvm.org/viewvc/llvm-project?rev=130860&view=rev Log: Remove an unused variable. Modified: llvm/trunk/tools/gold/gold-plugin.cpp Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=130860&r1=130859&r2=130860&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Wed May 4 14:13:01 2011 @@ -408,7 +408,6 @@ if (options::generate_bc_file == options::BC_ONLY) exit(0); } - size_t bufsize = 0; const char *objPath; if (lto_codegen_compile_to_file(code_gen, &objPath)) { (*message)(LDPL_ERROR, "Could not produce a combined object file\n"); From eli.friedman at gmail.com Wed May 4 14:54:24 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 04 May 2011 19:54:24 -0000 Subject: [llvm-commits] [llvm] r130862 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll Message-ID: <20110504195424.C53702A6C12C@llvm.org> Author: efriedma Date: Wed May 4 14:54:24 2011 New Revision: 130862 URL: http://llvm.org/viewvc/llvm-project?rev=130862&view=rev Log: Teach MachineCSE how to do simple cross-block CSE involving physregs. This allows, for example, eliminating duplicate cmpl's on x86. Part of rdar://problem/8259436 . Added: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=130862&r1=130861&r2=130862&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Wed May 4 14:54:24 2011 @@ -82,7 +82,8 @@ MachineBasicBlock::const_iterator E) const ; bool hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs) const; + SmallSet &PhysRefs, + SmallVector &PhysDefs) const; bool PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const; bool isCSECandidate(MachineInstr *MI); @@ -189,7 +190,8 @@ /// instruction does not uses a physical register. bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs) const { + SmallSet &PhysRefs, + SmallVector &PhysDefs) const{ MachineBasicBlock::const_iterator I = MI; I = llvm::next(I); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); @@ -206,6 +208,7 @@ if (MO.isDef() && (MO.isDead() || isPhysDefTriviallyDead(Reg, I, MBB->end()))) continue; + PhysDefs.push_back(Reg); PhysRefs.insert(Reg); for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) PhysRefs.insert(*Alias); @@ -216,35 +219,40 @@ bool MachineCSE::PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const { - // For now conservatively returns false if the common subexpression is - // not in the same basic block as the given instruction. - MachineBasicBlock *MBB = MI->getParent(); - if (CSMI->getParent() != MBB) - return false; - MachineBasicBlock::const_iterator I = CSMI; I = llvm::next(I); - MachineBasicBlock::const_iterator E = MI; + // Look backward from MI to find CSMI. unsigned LookAheadLeft = LookAheadLimit; + MachineBasicBlock::const_reverse_iterator I(MI); + MachineBasicBlock::const_reverse_iterator E(MI->getParent()->rend()); while (LookAheadLeft) { - // Skip over dbg_value's. - while (I != E && I->isDebugValue()) - ++I; - - if (I == E) - return true; + while (LookAheadLeft && I != E) { + // Skip over dbg_value's. + while (I != E && I->isDebugValue()) + ++I; + + if (&*I == CSMI) + return true; + + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = I->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + unsigned MOReg = MO.getReg(); + if (TargetRegisterInfo::isVirtualRegister(MOReg)) + continue; + if (PhysRefs.count(MOReg)) + return false; + } - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = I->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - unsigned MOReg = MO.getReg(); - if (TargetRegisterInfo::isVirtualRegister(MOReg)) - continue; - if (PhysRefs.count(MOReg)) - return false; + --LookAheadLeft; + ++I; } - - --LookAheadLeft; - ++I; + // Go back another BB; for now, only go back at most one BB. + MachineBasicBlock *CSBB = CSMI->getParent(); + MachineBasicBlock *BB = MI->getParent(); + if (!CSBB->isSuccessor(BB) || BB->pred_size() != 1) + return false; + I = CSBB->rbegin(); + E = CSBB->rend(); } return false; @@ -395,7 +403,8 @@ // used, then it's not safe to replace it with a common subexpression. // It's also not safe if the instruction uses physical registers. SmallSet PhysRefs; - if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs)) { + SmallVector DirectPhysRefs; + if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs, DirectPhysRefs)) { FoundCSE = false; // ... Unless the CS is local and it also defines the physical register @@ -448,6 +457,13 @@ MRI->clearKillFlags(CSEPairs[i].second); } MI->eraseFromParent(); + if (!DirectPhysRefs.empty() && CSMI->getParent() != MBB) { + assert(CSMI->getParent()->isSuccessor(MBB)); + SmallVector::iterator PI = DirectPhysRefs.begin(), + PE = DirectPhysRefs.end(); + for (; PI != PE; ++PI) + MBB->addLiveIn(*PI); + } ++NumCSEs; if (!PhysRefs.empty()) ++NumPhysCSEs; Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=130862&r1=130861&r2=130862&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Wed May 4 14:54:24 2011 @@ -21,8 +21,8 @@ bb9: ; preds = %bb7 ; CHECK: cmp r0, #0 -; CHECK: cmp r0, #0 -; CHECK-NEXT: cbnz +; CHECK-NOT: cmp +; CHECK: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 Added: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp-redundant.ll?rev=130862&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (added) +++ llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Wed May 4 14:54:24 2011 @@ -0,0 +1,22 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s + +define i32 @cmp(i32* %aa, i32* %bb) nounwind readnone ssp { +entry: + %a = load i32* %aa + %b = load i32* %bb + %cmp = icmp sgt i32 %a, %b + br i1 %cmp, label %return, label %if.end +; CHECK: cmp: +; CHECK: cmpl +; CHECK: jg +if.end: ; preds = %entry +; CHECK-NOT: cmpl +; CHECK: cmov + %cmp4 = icmp slt i32 %a, %b + %. = select i1 %cmp4, i32 2, i32 111 + br label %return + +return: ; preds = %if.end, %entry + %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] + ret i32 %retval.0 +} From dmalyshev at accesssoftek.com Wed May 4 15:05:27 2011 From: dmalyshev at accesssoftek.com (Danil Malyshev) Date: Wed, 4 May 2011 13:05:27 -0700 Subject: [llvm-commits] Check output stream opened in binary mode instead of text mode on MinGW Message-ID: <6AE1604EE3EC5F4296C096518C6B77EE17E4EAF874@mail.accesssoftek.com> Hello everyone, Many LLVM tests relies on standard output stream be in the binary mode. Which is not always the case (on Windows in particular). The proposed patch adds a test to verify that the standard output stream is actually in the binary mode. This will save us a lot of troubleshooting time. Please review. Thank you, Danil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110504/3415d5de/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: test-archive-binary-output-03.diff Type: application/octet-stream Size: 467 bytes Desc: test-archive-binary-output-03.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110504/3415d5de/attachment.obj From baldrick at free.fr Wed May 4 15:16:08 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 04 May 2011 20:16:08 -0000 Subject: [llvm-commits] [dragonegg] r130863 - in /dragonegg/trunk: README src/Backend.cpp Message-ID: <20110504201608.739932A6C12C@llvm.org> Author: baldrick Date: Wed May 4 15:16:08 2011 New Revision: 130863 URL: http://llvm.org/viewvc/llvm-project?rev=130863&view=rev Log: Remove the -fplugin-arg-dragonegg-disable-llvm-optzns option, and instead make it possible to specify any desired LLVM optimization level using the -fplugin-arg-dragonegg-llvm-ir-optimize=N and -fplugin-arg-dragonegg-llvm-codegen-optimize=N flags. Modified: dragonegg/trunk/README dragonegg/trunk/src/Backend.cpp Modified: dragonegg/trunk/README URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/README?rev=130863&r1=130862&r2=130863&view=diff ============================================================================== --- dragonegg/trunk/README (original) +++ dragonegg/trunk/README Wed May 4 15:16:08 2011 @@ -125,8 +125,19 @@ -fplugin-arg-dragonegg-debug-pass-structure Output information about the passes being run. --fplugin-arg-dragonegg-disable-llvm-optzns - Do not perform any LLVM IR optimizations even if compiling at -O1, -O2 etc. +-fplugin-arg-dragonegg-llvm-ir-optimize=N + Run the LLVM IR optimizers at optimization level N, overriding the GCC + optimization level. Usually if you pass -O1, -O2 etc to GCC then the + LLVM IR level optimizers are also run at -O1, -O2 etc. Use this option + to change this, disassociating the LLVM optimization level from the GCC + one. For example, -fplugin-arg-dragonegg-llvm-ir-optimize=0 disables + all LLVM IR optimizations. + +-fplugin-arg-dragonegg-llvm-codegen-optimize=N + Run the LLVM code generator optimizers at optimization level N, overriding + the GCC optimization level. Usually if you pass -O1, -O2 etc to GCC then + the LLVM code generators optimize at a corresponding level. Use this option + to change this, disassociating the LLVM optimization level from the GCC one. -fplugin-arg-dragonegg-enable-gcc-optzns Run the GCC tree optimizers as well as the LLVM IR optimizers. Only early GCC Modified: dragonegg/trunk/src/Backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=130863&r1=130862&r2=130863&view=diff ============================================================================== --- dragonegg/trunk/src/Backend.cpp (original) +++ dragonegg/trunk/src/Backend.cpp Wed May 4 15:16:08 2011 @@ -103,10 +103,11 @@ static bool DebugPassArguments; static bool DebugPassStructure; -static bool DisableLLVMOptimizations; static bool EnableGCCOptimizations; static bool EmitIR; static bool SaveGCCOutput; +static int LLVMCodeGenOptimizeArg = -1; +static int LLVMIROptimizeArg = -1; std::vector > StaticCtors, StaticDtors; SmallSetVector AttributeUsedGlobals; @@ -265,6 +266,24 @@ } } +/// CodeGenOptLevel - The optimization level to be used by the code generators. +static CodeGenOpt::Level CodeGenOptLevel() { + int OptLevel = LLVMCodeGenOptimizeArg >= 0 ? + LLVMCodeGenOptimizeArg : optimize; + if (OptLevel <= 0) + return CodeGenOpt::None; + if (OptLevel == 1) + return CodeGenOpt::Less; + if (OptLevel == 2) // Includes -Os. + return CodeGenOpt::Default; + return CodeGenOpt::Aggressive; +} + +/// IROptLevel - The optimization level to be used by the IR level optimizers. +static int IROptLevel() { + return LLVMIROptimizeArg >= 0 ? LLVMIROptimizeArg : optimize; +} + // GuessAtInliningThreshold - Figure out a reasonable threshold to pass llvm's // inliner. gcc has many options that control inlining, but we have decided // not to support anything like that for llvm-gcc. @@ -273,7 +292,7 @@ // Reduce inline limit. return 75; - if (optimize >= 3) + if (IROptLevel() >= 3) return 275; return 225; } @@ -688,7 +707,7 @@ HasPerFunctionPasses = true; #endif - if (optimize > 0 && !DisableLLVMOptimizations) { + if (IROptLevel() > 0) { HasPerFunctionPasses = true; TargetLibraryInfo *TLI = @@ -698,7 +717,7 @@ PerFunctionPasses->add(TLI); PerFunctionPasses->add(createCFGSimplificationPass()); - if (optimize == 1) + if (IROptLevel() == 1) PerFunctionPasses->add(createPromoteMemoryToRegisterPass()); else PerFunctionPasses->add(createScalarReplAggregatesPass()); @@ -715,15 +734,6 @@ FunctionPassManager *PM = PerFunctionPasses; HasPerFunctionPasses = true; - CodeGenOpt::Level OptLevel = CodeGenOpt::Default; // -O2, -Os, and -Oz - if (optimize == 0) - OptLevel = CodeGenOpt::None; - else if (optimize == 1) - OptLevel = CodeGenOpt::Less; - else if (optimize == 3) - // -O3 and above. - OptLevel = CodeGenOpt::Aggressive; - // Request that addPassesToEmitFile run the Verifier after running // passes which modify the IR. #ifndef NDEBUG @@ -737,7 +747,7 @@ InitializeOutputStreams(false); if (TheTarget->addPassesToEmitFile(*PM, FormattedOutStream, TargetMachine::CGFT_AssemblyFile, - OptLevel, DisableVerify)) + CodeGenOptLevel(), DisableVerify)) DieAbjectly("Error interfacing to target machine!"); } @@ -759,40 +769,38 @@ PerModulePasses->add(new TargetData(*TheTarget->getTargetData())); bool HasPerModulePasses = false; - if (!DisableLLVMOptimizations) { - TargetLibraryInfo *TLI = - new TargetLibraryInfo(Triple(TheModule->getTargetTriple())); - if (flag_no_simplify_libcalls) - TLI->disableAllFunctions(); - PerModulePasses->add(TLI); - - bool NeedAlwaysInliner = false; - llvm::Pass *InliningPass = 0; - if (flag_inline_small_functions && !flag_no_inline) { - InliningPass = createFunctionInliningPass(); // Inline small functions - } else { - // If full inliner is not run, check if always-inline is needed to handle - // functions that are marked as always_inline. - // TODO: Consider letting the GCC inliner do this. - for (Module::iterator I = TheModule->begin(), E = TheModule->end(); - I != E; ++I) - if (I->hasFnAttr(Attribute::AlwaysInline)) { - NeedAlwaysInliner = true; - break; - } - - if (NeedAlwaysInliner) - InliningPass = createAlwaysInlinerPass(); // Inline always_inline funcs - } + TargetLibraryInfo *TLI = + new TargetLibraryInfo(Triple(TheModule->getTargetTriple())); + if (flag_no_simplify_libcalls) + TLI->disableAllFunctions(); + PerModulePasses->add(TLI); + + bool NeedAlwaysInliner = false; + llvm::Pass *InliningPass = 0; + if (flag_inline_small_functions && !flag_no_inline) { + InliningPass = createFunctionInliningPass(); // Inline small functions + } else { + // If full inliner is not run, check if always-inline is needed to handle + // functions that are marked as always_inline. + // TODO: Consider letting the GCC inliner do this. + for (Module::iterator I = TheModule->begin(), E = TheModule->end(); + I != E; ++I) + if (I->hasFnAttr(Attribute::AlwaysInline)) { + NeedAlwaysInliner = true; + break; + } - HasPerModulePasses = true; - createStandardModulePasses(PerModulePasses, optimize, - optimize_size, - flag_unit_at_a_time, flag_unroll_loops, - !flag_no_simplify_libcalls, flag_exceptions, - InliningPass); + if (NeedAlwaysInliner) + InliningPass = createAlwaysInlinerPass(); // Inline always_inline funcs } + HasPerModulePasses = true; + createStandardModulePasses(PerModulePasses, IROptLevel(), + optimize_size, + flag_unit_at_a_time, flag_unroll_loops, + !flag_no_simplify_libcalls, flag_exceptions, + InliningPass); + if (EmitIR && 0) { // Emit an LLVM .bc file to the output. This is used when passed // -emit-llvm -c to the GCC driver. @@ -817,14 +825,6 @@ new FunctionPassManager(TheModule); PM->add(new TargetData(*TheTarget->getTargetData())); - CodeGenOpt::Level OptLevel = CodeGenOpt::Default; - - switch (optimize) { - default: break; - case 0: OptLevel = CodeGenOpt::None; break; - case 3: OptLevel = CodeGenOpt::Aggressive; break; - } - // Request that addPassesToEmitFile run the Verifier after running // passes which modify the IR. #ifndef NDEBUG @@ -838,7 +838,7 @@ InitializeOutputStreams(false); if (TheTarget->addPassesToEmitFile(*PM, FormattedOutStream, TargetMachine::CGFT_AssemblyFile, - OptLevel, DisableVerify)) + CodeGenOptLevel(), DisableVerify)) DieAbjectly("Error interfacing to target machine!"); } } @@ -2400,7 +2400,6 @@ static FlagDescriptor PluginFlags[] = { { "debug-pass-structure", &DebugPassStructure}, { "debug-pass-arguments", &DebugPassArguments}, - { "disable-llvm-optzns", &DisableLLVMOptimizations }, { "enable-gcc-optzns", &EnableGCCOptimizations }, { "emit-ir", &EmitIR }, { "save-gcc-output", &SaveGCCOutput }, @@ -2454,27 +2453,47 @@ int argc = plugin_info->argc; for (int i = 0; i < argc; ++i) { - bool Found = false; + if (!strcmp (argv[i].key, "llvm-ir-optimize") || + !strcmp (argv[i].key, "llvm-codegen-optimize")) { + if (!argv[i].value) { + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), + plugin_name, argv[i].key); + return 1; + } + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || argv[i].value[1]) { + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), + plugin_name, argv[i].key, argv[i].value); + return 1; + } + int OptLevel = argv[i].value[0] - '0'; + if (argv[i].key[5] == 'i') + LLVMIROptimizeArg = OptLevel; + else + LLVMCodeGenOptimizeArg = OptLevel; + continue; + } + + // All remaining options are flags, so complain if there is an argument. + if (argv[i].value) { + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), + plugin_name, argv[i].key, argv[i].value); + return 1; + } // Look for a matching flag. - for (FlagDescriptor *F = PluginFlags; F->Key; ++F) { - if (strcmp (argv[i].key, F->Key)) - continue; - - if (argv[i].value) - warning (0, G_("option '-fplugin-arg-%s-%s=%s' ignored" - " (superfluous '=%s')"), - plugin_name, argv[i].key, argv[i].value, argv[i].value); - else + bool Found = false; + for (FlagDescriptor *F = PluginFlags; F->Key; ++F) + if (!strcmp (argv[i].key, F->Key)) { + Found = true; *F->Flag = true; + break; + } - Found = true; - break; + if (!Found) { + error(G_("invalid option '-fplugin-arg-%s-%s'"), + plugin_name, argv[i].key); + return 1; } - - if (!Found) - warning (0, G_("plugin %qs: unrecognized argument %qs ignored"), - plugin_name, argv[i].key); } } From eli.friedman at gmail.com Wed May 4 15:48:42 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 04 May 2011 20:48:42 -0000 Subject: [llvm-commits] [llvm] r130867 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll Message-ID: <20110504204842.5DD162A6C12C@llvm.org> Author: efriedma Date: Wed May 4 15:48:42 2011 New Revision: 130867 URL: http://llvm.org/viewvc/llvm-project?rev=130867&view=rev Log: Back out r130862; it appears to be breaking bootstrap. Removed: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=130867&r1=130866&r2=130867&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Wed May 4 15:48:42 2011 @@ -82,8 +82,7 @@ MachineBasicBlock::const_iterator E) const ; bool hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs, - SmallVector &PhysDefs) const; + SmallSet &PhysRefs) const; bool PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const; bool isCSECandidate(MachineInstr *MI); @@ -190,8 +189,7 @@ /// instruction does not uses a physical register. bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs, - SmallVector &PhysDefs) const{ + SmallSet &PhysRefs) const { MachineBasicBlock::const_iterator I = MI; I = llvm::next(I); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); @@ -208,7 +206,6 @@ if (MO.isDef() && (MO.isDead() || isPhysDefTriviallyDead(Reg, I, MBB->end()))) continue; - PhysDefs.push_back(Reg); PhysRefs.insert(Reg); for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) PhysRefs.insert(*Alias); @@ -219,40 +216,35 @@ bool MachineCSE::PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const { - // Look backward from MI to find CSMI. + // For now conservatively returns false if the common subexpression is + // not in the same basic block as the given instruction. + MachineBasicBlock *MBB = MI->getParent(); + if (CSMI->getParent() != MBB) + return false; + MachineBasicBlock::const_iterator I = CSMI; I = llvm::next(I); + MachineBasicBlock::const_iterator E = MI; unsigned LookAheadLeft = LookAheadLimit; - MachineBasicBlock::const_reverse_iterator I(MI); - MachineBasicBlock::const_reverse_iterator E(MI->getParent()->rend()); while (LookAheadLeft) { - while (LookAheadLeft && I != E) { - // Skip over dbg_value's. - while (I != E && I->isDebugValue()) - ++I; - - if (&*I == CSMI) - return true; - - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = I->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - unsigned MOReg = MO.getReg(); - if (TargetRegisterInfo::isVirtualRegister(MOReg)) - continue; - if (PhysRefs.count(MOReg)) - return false; - } - - --LookAheadLeft; + // Skip over dbg_value's. + while (I != E && I->isDebugValue()) ++I; + + if (I == E) + return true; + + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = I->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + unsigned MOReg = MO.getReg(); + if (TargetRegisterInfo::isVirtualRegister(MOReg)) + continue; + if (PhysRefs.count(MOReg)) + return false; } - // Go back another BB; for now, only go back at most one BB. - MachineBasicBlock *CSBB = CSMI->getParent(); - MachineBasicBlock *BB = MI->getParent(); - if (!CSBB->isSuccessor(BB) || BB->pred_size() != 1) - return false; - I = CSBB->rbegin(); - E = CSBB->rend(); + + --LookAheadLeft; + ++I; } return false; @@ -403,8 +395,7 @@ // used, then it's not safe to replace it with a common subexpression. // It's also not safe if the instruction uses physical registers. SmallSet PhysRefs; - SmallVector DirectPhysRefs; - if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs, DirectPhysRefs)) { + if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs)) { FoundCSE = false; // ... Unless the CS is local and it also defines the physical register @@ -457,13 +448,6 @@ MRI->clearKillFlags(CSEPairs[i].second); } MI->eraseFromParent(); - if (!DirectPhysRefs.empty() && CSMI->getParent() != MBB) { - assert(CSMI->getParent()->isSuccessor(MBB)); - SmallVector::iterator PI = DirectPhysRefs.begin(), - PE = DirectPhysRefs.end(); - for (; PI != PE; ++PI) - MBB->addLiveIn(*PI); - } ++NumCSEs; if (!PhysRefs.empty()) ++NumPhysCSEs; Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=130867&r1=130866&r2=130867&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Wed May 4 15:48:42 2011 @@ -21,8 +21,8 @@ bb9: ; preds = %bb7 ; CHECK: cmp r0, #0 -; CHECK-NOT: cmp -; CHECK: cbnz +; CHECK: cmp r0, #0 +; CHECK-NEXT: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 Removed: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp-redundant.ll?rev=130866&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (original) +++ llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (removed) @@ -1,22 +0,0 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s - -define i32 @cmp(i32* %aa, i32* %bb) nounwind readnone ssp { -entry: - %a = load i32* %aa - %b = load i32* %bb - %cmp = icmp sgt i32 %a, %b - br i1 %cmp, label %return, label %if.end -; CHECK: cmp: -; CHECK: cmpl -; CHECK: jg -if.end: ; preds = %entry -; CHECK-NOT: cmpl -; CHECK: cmov - %cmp4 = icmp slt i32 %a, %b - %. = select i1 %cmp4, i32 2, i32 111 - br label %return - -return: ; preds = %if.end, %entry - %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] - ret i32 %retval.0 -} From aggarwa4 at illinois.edu Wed May 4 16:20:18 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 04 May 2011 21:20:18 -0000 Subject: [llvm-commits] [poolalloc] r130868 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/Local.cpp Message-ID: <20110504212018.80FF22A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 4 16:20:18 2011 New Revision: 130868 URL: http://llvm.org/viewvc/llvm-project?rev=130868&view=rev Log: Allow PtrToInt and IntToPtr values to be used locally for compares, without setting those flags. This should help improve type safety for some subset of the program in SAFECode Modified: poolalloc/trunk/include/dsa/DSNode.h poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/include/dsa/DSNode.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=130868&r1=130867&r2=130868&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSNode.h (original) +++ poolalloc/trunk/include/dsa/DSNode.h Wed May 4 16:20:18 2011 @@ -103,8 +103,11 @@ ArrayNode = 1 << 9, // This node is treated like an array CollapsedNode = 1 << 10, // This node is collapsed ExternalNode = 1 << 11, // This node comes from an external source - IntToPtrNode = 1 << 12, // This node comes from an int cast - PtrToIntNode = 1 << 13, // This node escapes to an int cast + IntToPtrNode = 1 << 12, // This node comes from an int cast + // and is used in pointer operations + // like geps, loads, stores + PtrToIntNode = 1 << 13, // This node escapes to an int cast + // and DSA does not track it further. VAStartNode = 1 << 14, // This node is from a vastart call //#ifndef NDEBUG Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=130868&r1=130867&r2=130868&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Wed May 4 16:20:18 2011 @@ -433,12 +433,10 @@ void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) { DSNode *N = createNode(); - if(TypeInferenceOptimize) { - if(I.getNumUses() == 1) { - if(isa(I.use_begin())) { - NumBoringIntToPtr++; - return; - } + if(I.getNumUses() == 1) { + if(isa(I.use_begin())) { + NumBoringIntToPtr++; + return; } } else { N->setIntToPtrMarker(); @@ -449,30 +447,26 @@ void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) { DSNode* N = getValueDest(I.getOperand(0)).getNode(); - if(TypeInferenceOptimize) { - if(I.getNumUses() == 1) { - if(isa(I.use_begin())) { - NumBoringIntToPtr++; - return; - } + if(I.getNumUses() == 1) { + if(isa(I.use_begin())) { + NumBoringIntToPtr++; + return; } } - if(TypeInferenceOptimize) { - if(I.getNumUses() == 1) { - Value *V = dyn_cast(I.use_begin()); - while(V && V->getNumUses() == 1) { - if(isa(V)) - break; - if(isa(V)) - break; - if(isa(V)) - break; - V = dyn_cast(V->use_begin()); - } - if(isa(V)){ - NumBoringIntToPtr++; - return; - } + if(I.getNumUses() == 1) { + Value *V = dyn_cast(I.use_begin()); + while(V && V->getNumUses() == 1) { + if(isa(V)) + break; + if(isa(V)) + break; + if(isa(V)) + break; + V = dyn_cast(V->use_begin()); + } + if(isa(V)){ + NumBoringIntToPtr++; + return; } } if(N) From vladimir.stefanovic at rt-rk.com Wed May 4 12:01:43 2011 From: vladimir.stefanovic at rt-rk.com (Vladimir Stefanovic) Date: Wed, 04 May 2011 19:01:43 +0200 Subject: [llvm-commits] [llvm] [PATCH] Mips JIT implementation Message-ID: <4DC18677.20706@rt-rk.com> -------------- next part -------------- A non-text attachment was scrubbed... Name: Mips-JIT.diff Type: text/x-patch Size: 39036 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110504/f41d63a9/attachment.bin From dpatel at apple.com Wed May 4 16:37:05 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 21:37:05 -0000 Subject: [llvm-commits] [llvm] r130869 - /llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Message-ID: <20110504213705.B676A2A6C12C@llvm.org> Author: dpatel Date: Wed May 4 16:37:05 2011 New Revision: 130869 URL: http://llvm.org/viewvc/llvm-project?rev=130869&view=rev Log: preserve line number info. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=130869&r1=130868&r2=130869&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Wed May 4 16:37:05 2011 @@ -589,14 +589,15 @@ Value *NumBytes = Expander.expandCodeFor(NumBytesS, IntPtr, Preheader->getTerminator()); - Value *NewCall = + CallInst *NewCall = Builder.CreateMemCpy(StoreBasePtr, LoadBasePtr, NumBytes, std::min(SI->getAlignment(), LI->getAlignment())); + NewCall->setDebugLoc(SI->getDebugLoc()); DEBUG(dbgs() << " Formed memcpy: " << *NewCall << "\n" << " from load ptr=" << *LoadEv << " at: " << *LI << "\n" << " from store ptr=" << *StoreEv << " at: " << *SI << "\n"); - (void)NewCall; + // Okay, the memset has been formed. Zap the original store and anything that // feeds into it. From dpatel at apple.com Wed May 4 16:57:22 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 21:57:22 -0000 Subject: [llvm-commits] [llvm] r130874 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <20110504215722.CDF272A6C12C@llvm.org> Author: dpatel Date: Wed May 4 16:57:22 2011 New Revision: 130874 URL: http://llvm.org/viewvc/llvm-project?rev=130874&view=rev Log: If builder is initialized using an instruction as insertion point, then use the instruction's debug location as current debug location. 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=130874&r1=130873&r2=130874&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed May 4 16:57:22 2011 @@ -324,6 +324,7 @@ explicit IRBuilder(Instruction *IP) : IRBuilderBase(IP->getContext()), Folder() { SetInsertPoint(IP); + SetCurrentDebugLocation(IP->getDebugLoc()); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) From gkistanova at gmail.com Wed May 4 16:57:45 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Wed, 04 May 2011 21:57:45 -0000 Subject: [llvm-commits] [llvm] r130875 - /llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Message-ID: <20110504215745.2F6B42A6C12C@llvm.org> Author: gkistanova Date: Wed May 4 16:57:44 2011 New Revision: 130875 URL: http://llvm.org/viewvc/llvm-project?rev=130875&view=rev Log: This test fails on ARM. The test shouldn't explicitly specify alignment (and alignment 4 is wrong) and requires hard-float. Modified: llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Modified: llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll?rev=130875&r1=130874&r2=130875&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll Wed May 4 16:57:44 2011 @@ -1,16 +1,16 @@ -; RUN: llc -O1 -march=arm -mattr=+vfp2 < %s | FileCheck %s +; RUN: llc -O1 -march=arm -mattr=+vfp2 -float-abi=hard < %s | FileCheck %s ; pr4939 define void @test(double* %x, double* %y) nounwind { - %1 = load double* %x, align 4 - %2 = load double* %y, align 4 + %1 = load double* %x + %2 = load double* %y %3 = fsub double -0.000000e+00, %1 %4 = fcmp ugt double %2, %3 br i1 %4, label %bb1, label %bb2 bb1: ;CHECK: vstrhi.64 - store double %1, double* %y, align 4 + store double %1, double* %y br label %bb2 bb2: From dpatel at apple.com Wed May 4 16:58:58 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 21:58:58 -0000 Subject: [llvm-commits] [llvm] r130876 - /llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <20110504215858.5FE812A6C12C@llvm.org> Author: dpatel Date: Wed May 4 16:58:58 2011 New Revision: 130876 URL: http://llvm.org/viewvc/llvm-project?rev=130876&view=rev Log: Preserve line number info. Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=130876&r1=130875&r2=130876&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Wed May 4 16:58:58 2011 @@ -459,7 +459,10 @@ for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) dbgs() << *Range.TheStores[i] << '\n'; dbgs() << "With: " << *AMemSet << '\n'); - + + if (!Range.TheStores.empty()) + AMemSet->setDebugLoc(Range.TheStores[0]->getDebugLoc()); + // Zap all the stores. for (SmallVector::const_iterator SI = Range.TheStores.begin(), From anton at korobeynikov.info Wed May 4 17:13:24 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 5 May 2011 02:13:24 +0400 Subject: [llvm-commits] [llvm] r130875 - /llvm/trunk/test/CodeGen/ARM/2009-09-09-fpcmp-ole.ll In-Reply-To: <20110504215745.2F6B42A6C12C@llvm.org> References: <20110504215745.2F6B42A6C12C@llvm.org> Message-ID: Hi Galina, > This test fails on ARM. The test shouldn't explicitly specify alignment (and alignment 4 is wrong) and requires hard-float. In fact it doesn't. The difference is just APCS vs AAPCS, so, explicit target triplet would be fine :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From eli.friedman at gmail.com Wed May 4 17:10:37 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 04 May 2011 22:10:37 -0000 Subject: [llvm-commits] [llvm] r130877 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll Message-ID: <20110504221037.2B8C92A6C12C@llvm.org> Author: efriedma Date: Wed May 4 17:10:36 2011 New Revision: 130877 URL: http://llvm.org/viewvc/llvm-project?rev=130877&view=rev Log: Re-commit r130862 with a minor change to avoid an iterator running off the edge in some cases. Original message: Teach MachineCSE how to do simple cross-block CSE involving physregs. This allows, for example, eliminating duplicate cmpl's on x86. Part of rdar://problem/8259436 . Added: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=130877&r1=130876&r2=130877&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Wed May 4 17:10:36 2011 @@ -33,6 +33,8 @@ STATISTIC(NumCSEs, "Number of common subexpression eliminated"); STATISTIC(NumPhysCSEs, "Number of physreg referencing common subexpr eliminated"); +STATISTIC(NumCrossBlockPhysCSEs, + "Number of physreg common subexprs cross-block eliminated"); STATISTIC(NumCommutes, "Number of copies coalesced after commuting"); namespace { @@ -82,7 +84,8 @@ MachineBasicBlock::const_iterator E) const ; bool hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs) const; + SmallSet &PhysRefs, + SmallVector &PhysDefs) const; bool PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const; bool isCSECandidate(MachineInstr *MI); @@ -189,7 +192,8 @@ /// instruction does not uses a physical register. bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs) const { + SmallSet &PhysRefs, + SmallVector &PhysDefs) const{ MachineBasicBlock::const_iterator I = MI; I = llvm::next(I); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); @@ -206,6 +210,7 @@ if (MO.isDef() && (MO.isDead() || isPhysDefTriviallyDead(Reg, I, MBB->end()))) continue; + PhysDefs.push_back(Reg); PhysRefs.insert(Reg); for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) PhysRefs.insert(*Alias); @@ -216,35 +221,43 @@ bool MachineCSE::PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const { - // For now conservatively returns false if the common subexpression is - // not in the same basic block as the given instruction. - MachineBasicBlock *MBB = MI->getParent(); - if (CSMI->getParent() != MBB) - return false; - MachineBasicBlock::const_iterator I = CSMI; I = llvm::next(I); - MachineBasicBlock::const_iterator E = MI; + // Look backward from MI to find CSMI. unsigned LookAheadLeft = LookAheadLimit; + MachineBasicBlock *CurBB = MI->getParent(); + MachineBasicBlock::const_reverse_iterator I(MI); + MachineBasicBlock::const_reverse_iterator E(CurBB->rend()); while (LookAheadLeft) { - // Skip over dbg_value's. - while (I != E && I->isDebugValue()) - ++I; - - if (I == E) - return true; + while (LookAheadLeft && I != E) { + // Skip over dbg_value's. + while (I != E && I->isDebugValue()) + ++I; + + if (I == E) break; + + if (&*I == CSMI) + return true; + + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = I->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + unsigned MOReg = MO.getReg(); + if (TargetRegisterInfo::isVirtualRegister(MOReg)) + continue; + if (PhysRefs.count(MOReg)) + return false; + } - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = I->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - unsigned MOReg = MO.getReg(); - if (TargetRegisterInfo::isVirtualRegister(MOReg)) - continue; - if (PhysRefs.count(MOReg)) - return false; + --LookAheadLeft; + ++I; } - - --LookAheadLeft; - ++I; + // Go back another BB; for now, only go back at most one BB. + MachineBasicBlock *CSBB = CSMI->getParent(); + if (!CSBB->isSuccessor(CurBB) || CurBB->pred_size() != 1) + return false; + CurBB = CSBB; + I = CSBB->rbegin(); + E = CSBB->rend(); } return false; @@ -395,7 +408,8 @@ // used, then it's not safe to replace it with a common subexpression. // It's also not safe if the instruction uses physical registers. SmallSet PhysRefs; - if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs)) { + SmallVector DirectPhysRefs; + if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs, DirectPhysRefs)) { FoundCSE = false; // ... Unless the CS is local and it also defines the physical register @@ -448,6 +462,14 @@ MRI->clearKillFlags(CSEPairs[i].second); } MI->eraseFromParent(); + if (!DirectPhysRefs.empty() && CSMI->getParent() != MBB) { + assert(CSMI->getParent()->isSuccessor(MBB)); + ++NumCrossBlockPhysCSEs; + SmallVector::iterator PI = DirectPhysRefs.begin(), + PE = DirectPhysRefs.end(); + for (; PI != PE; ++PI) + MBB->addLiveIn(*PI); + } ++NumCSEs; if (!PhysRefs.empty()) ++NumPhysCSEs; Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=130877&r1=130876&r2=130877&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Wed May 4 17:10:36 2011 @@ -21,8 +21,8 @@ bb9: ; preds = %bb7 ; CHECK: cmp r0, #0 -; CHECK: cmp r0, #0 -; CHECK-NEXT: cbnz +; CHECK-NOT: cmp +; CHECK: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 Added: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp-redundant.ll?rev=130877&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (added) +++ llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Wed May 4 17:10:36 2011 @@ -0,0 +1,22 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s + +define i32 @cmp(i32* %aa, i32* %bb) nounwind readnone ssp { +entry: + %a = load i32* %aa + %b = load i32* %bb + %cmp = icmp sgt i32 %a, %b + br i1 %cmp, label %return, label %if.end +; CHECK: cmp: +; CHECK: cmpl +; CHECK: jg +if.end: ; preds = %entry +; CHECK-NOT: cmpl +; CHECK: cmov + %cmp4 = icmp slt i32 %a, %b + %. = select i1 %cmp4, i32 2, i32 111 + br label %return + +return: ; preds = %if.end, %entry + %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] + ret i32 %retval.0 +} From nicholas at mxc.ca Wed May 4 17:34:29 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 04 May 2011 22:34:29 -0000 Subject: [llvm-commits] [llvm] r130879 - /llvm/trunk/runtime/libprofile/GCDAProfiling.c Message-ID: <20110504223430.089502A6C12C@llvm.org> Author: nicholas Date: Wed May 4 17:34:29 2011 New Revision: 130879 URL: http://llvm.org/viewvc/llvm-project?rev=130879&view=rev Log: Create the parent directories to place the .gcda files in if they don't exist. That's kinda weird because the .gcno files are supposed to already be there, but libgcov does this and somehow Google has managed to depend on it. Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130879&r1=130878&r2=130879&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Wed May 4 17:34:29 2011 @@ -24,6 +24,8 @@ #include #include #include +#include +#include /* #define DEBUG_GCDAPROFILING */ @@ -64,6 +66,21 @@ return filename; } +static void recursive_mkdir(const char *filename) { + char *pathname; + int i, e; + + for (i = 1, e = strlen(filename); i != e; ++i) { + if (filename[i] == '/') { + pathname = malloc(i + 1); + strncpy(pathname, filename, i); + pathname[i] = '\0'; + mkdir(pathname, 0750); /* some of these will fail, ignore it. */ + free(pathname); + } + } +} + /* * --- LLVM line counter API --- */ @@ -75,6 +92,7 @@ void llvm_gcda_start_file(const char *orig_filename) { char *filename; filename = mangle_filename(orig_filename); + recursive_mkdir(filename); output_file = fopen(filename, "wb"); /* gcda file, version 404*, stamp LLVM. */ From dpatel at apple.com Wed May 4 17:48:19 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 22:48:19 -0000 Subject: [llvm-commits] [llvm] r130880 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Message-ID: <20110504224819.CC6C32A6C12C@llvm.org> Author: dpatel Date: Wed May 4 17:48:19 2011 New Revision: 130880 URL: http://llvm.org/viewvc/llvm-project?rev=130880&view=rev Log: Preserve line number information while threading jumps. Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=130880&r1=130879&r2=130880&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Wed May 4 17:48:19 2011 @@ -929,9 +929,10 @@ if (UnavailablePred) { assert(UnavailablePred->getTerminator()->getNumSuccessors() == 1 && "Can't handle critical edge here!"); - Value *NewVal = new LoadInst(LoadedPtr, LI->getName()+".pr", false, + LoadInst *NewVal = new LoadInst(LoadedPtr, LI->getName()+".pr", false, LI->getAlignment(), UnavailablePred->getTerminator()); + NewVal->setDebugLoc(LI->getDebugLoc()); AvailablePreds.push_back(std::make_pair(UnavailablePred, NewVal)); } @@ -944,6 +945,7 @@ PHINode *PN = PHINode::Create(LI->getType(), std::distance(PB, PE), "", LoadBB->begin()); PN->takeName(LI); + PN->setDebugLoc(LI->getDebugLoc()); // Insert new entries into the PHI for each predecessor. A single block may // have multiple entries here. @@ -1375,7 +1377,8 @@ // We didn't copy the terminator from BB over to NewBB, because there is now // an unconditional jump to SuccBB. Insert the unconditional jump. - BranchInst::Create(SuccBB, NewBB); + BranchInst *NewBI =BranchInst::Create(SuccBB, NewBB); + NewBI->setDebugLoc(BB->getTerminator()->getDebugLoc()); // Check to see if SuccBB has PHI nodes. If so, we need to add entries to the // PHI nodes for NewBB now. From isanbard at gmail.com Wed May 4 17:54:05 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 04 May 2011 22:54:05 -0000 Subject: [llvm-commits] [llvm] r130881 - in /llvm/trunk: lib/CodeGen/MachineVerifier.cpp test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll Message-ID: <20110504225405.ABD3E2A6C12C@llvm.org> Author: void Date: Wed May 4 17:54:05 2011 New Revision: 130881 URL: http://llvm.org/viewvc/llvm-project?rev=130881&view=rev Log: SjLj EH could produce a machine basic block that legitimately has more than one landing pad as its successor. SjLj exception handling jumps to the correct landing pad via a switch statement that's generated right before code-gen. Loosen the constraint in the machine instruction verifier to allow for this. Note, this isn't the most rigorous check since we cannot determine where that switch statement came from. But it's marginally better than turning this check off when SjLj exceptions are used. Added: llvm/trunk/test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp Modified: llvm/trunk/lib/CodeGen/MachineVerifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineVerifier.cpp?rev=130881&r1=130880&r2=130881&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineVerifier.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineVerifier.cpp Wed May 4 17:54:05 2011 @@ -23,6 +23,7 @@ // the verifier errors. //===----------------------------------------------------------------------===// +#include "llvm/Instructions.h" #include "llvm/Function.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/LiveVariables.h" @@ -32,6 +33,7 @@ #include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" @@ -394,7 +396,13 @@ if ((*I)->isLandingPad()) LandingPadSuccs.insert(*I); } - if (LandingPadSuccs.size() > 1) + + const MCAsmInfo *AsmInfo = TM->getMCAsmInfo(); + const BasicBlock *BB = MBB->getBasicBlock(); + if (LandingPadSuccs.size() > 1 && + !(AsmInfo && + AsmInfo->getExceptionHandlingType() == ExceptionHandling::SjLj && + BB && isa(BB->getTerminator()))) report("MBB has more than one landing pad successor", MBB); // Call AnalyzeBranch. If it succeeds, there several more conditions to check. Added: llvm/trunk/test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll?rev=130881&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2011-05-04-MultipleLandingPadSuccs.ll Wed May 4 17:54:05 2011 @@ -0,0 +1,93 @@ +; RUN: llc < %s -verify-machineinstrs +; +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 = "thumbv7-apple-darwin" + +define void @func() unnamed_addr align 2 { +entry: + br label %for.cond + +for.cond: + %tmp2 = phi i32 [ 0, %entry ], [ %add, %for.cond.backedge ] + %cmp = icmp ult i32 %tmp2, 14 + br i1 %cmp, label %for.body, label %for.end + +for.body: + %add = add i32 %tmp2, 1 + switch i32 %tmp2, label %sw.default [ + i32 0, label %sw.bb + i32 1, label %sw.bb + i32 2, label %sw.bb + i32 4, label %sw.bb + i32 5, label %sw.bb + i32 10, label %sw.bb + ] + +sw.bb: + invoke void @foo() + to label %invoke.cont17 unwind label %lpad + +invoke.cont17: + invoke void @foo() + to label %for.cond.backedge unwind label %lpad26 + +for.cond.backedge: + br label %for.cond + +lpad: + %exn = tail call i8* @llvm.eh.exception() nounwind + %eh.selector = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn, i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*), i8* null) nounwind + invoke void @foo() + to label %eh.resume unwind label %terminate.lpad + +lpad26: + %exn27 = tail call i8* @llvm.eh.exception() nounwind + %eh.selector28 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn27, i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*), i8* null) nounwind + invoke void @foo() + to label %eh.resume unwind label %terminate.lpad + +sw.default: + br label %for.cond.backedge + +for.end: + invoke void @foo() + to label %call8.i.i.i.noexc unwind label %lpad44 + +call8.i.i.i.noexc: + ret void + +lpad44: + %exn45 = tail call i8* @llvm.eh.exception() nounwind + %eh.selector46 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn45, i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*), i8* null) nounwind + invoke void @foo() + to label %eh.resume unwind label %terminate.lpad + +eh.resume: + %exn.slot.0 = phi i8* [ %exn27, %lpad26 ], [ %exn, %lpad ], [ %exn45, %lpad44 ] + tail call void @_Unwind_SjLj_Resume_or_Rethrow(i8* %exn.slot.0) noreturn + unreachable + +terminate.lpad: + %exn51 = tail call i8* @llvm.eh.exception() nounwind + %eh.selector52 = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn51, i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*), i8* null) nounwind + tail call void @_ZSt9terminatev() noreturn nounwind + unreachable +} + +declare void @foo() + +declare i8* @llvm.eh.exception() nounwind readonly + +declare i32 @__gxx_personality_sj0(...) + +declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind + +declare void @_Unwind_SjLj_Resume_or_Rethrow(i8*) + +declare void @_ZSt9terminatev() + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA", null} +!3 = metadata !{metadata !"bool", metadata !1} +!4 = metadata !{metadata !"int", metadata !1} From gohman at apple.com Wed May 4 18:14:02 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 04 May 2011 23:14:02 -0000 Subject: [llvm-commits] [llvm] r130883 - /llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll Message-ID: <20110504231402.AA0462A6C12C@llvm.org> Author: djg Date: Wed May 4 18:14:02 2011 New Revision: 130883 URL: http://llvm.org/viewvc/llvm-project?rev=130883&view=rev Log: Give this test an explicit register allocator, so that it can work even if the default register allocator is changed. Modified: llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll Modified: llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll?rev=130883&r1=130882&r2=130883&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll (original) +++ llvm/trunk/test/CodeGen/ARM/lsr-unfolded-offset.ll Wed May 4 18:14:02 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s | FileCheck %s +; RUN: llc -regalloc=greedy < %s | FileCheck %s ; LSR shouldn't introduce more induction variables than needed, increasing ; register pressure and therefore spilling. There is more room for improvement From kremenek at apple.com Wed May 4 18:26:59 2011 From: kremenek at apple.com (Ted Kremenek) Date: Wed, 04 May 2011 23:26:59 -0000 Subject: [llvm-commits] [llvm] r130885 - /llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Message-ID: <20110504232659.841E42A6C12C@llvm.org> Author: kremenek Date: Wed May 4 18:26:59 2011 New Revision: 130885 URL: http://llvm.org/viewvc/llvm-project?rev=130885&view=rev Log: Add explicit 'unregister' method to CrashRecoveryConextCleanupRegistrar. Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=130885&r1=130884&r2=130885&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original) +++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Wed May 4 18:26:59 2011 @@ -186,8 +186,13 @@ } ~CrashRecoveryContextCleanupRegistrar() { + unregister(); + } + + void unregister() { if (cleanup && !cleanup->cleanupFired) - cleanup->getContext()->unregisterCleanup(cleanup); + cleanup->getContext()->unregisterCleanup(cleanup); + cleanup = 0; } }; } From isanbard at gmail.com Wed May 4 18:40:14 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 04 May 2011 23:40:14 -0000 Subject: [llvm-commits] [llvm] r130889 - /llvm/trunk/docs/CodeGenerator.html Message-ID: <20110504234014.DE33B2A6C12C@llvm.org> Author: void Date: Wed May 4 18:40:14 2011 New Revision: 130889 URL: http://llvm.org/viewvc/llvm-project?rev=130889&view=rev Log: Document the automatic alias printing of InstAliases. Modified: llvm/trunk/docs/CodeGenerator.html Modified: llvm/trunk/docs/CodeGenerator.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CodeGenerator.html?rev=130889&r1=130888&r2=130889&view=diff ============================================================================== --- llvm/trunk/docs/CodeGenerator.html (original) +++ llvm/trunk/docs/CodeGenerator.html Wed May 4 18:40:14 2011 @@ -2019,6 +2019,11 @@

Instruction aliases can also have a Requires clause to make them subtarget specific.

+

If the back-end supports it, the instruction printer can automatically emit + the alias rather than what's being aliased. It typically leads to better, + more readable code. If it's better to print out what's being aliased, then + pass a '0' as the third parameter to the InstAlias definition.

+ From stoklund at 2pi.dk Wed May 4 18:54:51 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 23:54:51 -0000 Subject: [llvm-commits] [llvm] r130891 - in /llvm/trunk/test/CodeGen/X86: sse3.ll sse42.ll tail-opts.ll use-add-flags.ll vec_shuffle-16.ll win64_alloca_dynalloca.ll x86-64-and-mask.ll Message-ID: <20110504235451.C29F32A6C12C@llvm.org> Author: stoklund Date: Wed May 4 18:54:51 2011 New Revision: 130891 URL: http://llvm.org/viewvc/llvm-project?rev=130891&view=rev Log: Fix a batch of x86 tests to be coalescer independent. Most of these tests require a single mov instruction that can come either before or after a 2-addr instruction. -join-physregs changes the behavior, but the results are equivalent. Modified: llvm/trunk/test/CodeGen/X86/sse3.ll llvm/trunk/test/CodeGen/X86/sse42.ll llvm/trunk/test/CodeGen/X86/tail-opts.ll llvm/trunk/test/CodeGen/X86/use-add-flags.ll llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll Modified: llvm/trunk/test/CodeGen/X86/sse3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse3.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse3.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse3.ll Wed May 4 18:54:51 2011 @@ -62,11 +62,10 @@ %tmp = shufflevector <8 x i16> %A, <8 x i16> %B, <8 x i32> < i32 0, i32 7, i32 2, i32 3, i32 1, i32 5, i32 6, i32 5 > ret <8 x i16> %tmp ; X64: t4: -; X64: pextrw $7, %xmm0, %eax -; X64: pshufhw $100, %xmm0, %xmm1 -; X64: pinsrw $1, %eax, %xmm1 -; X64: pextrw $1, %xmm0, %eax -; X64: movdqa %xmm1, %xmm0 +; X64: pextrw $7, [[XMM0:%xmm[0-9]+]], %eax +; X64: pshufhw $100, [[XMM0]], [[XMM1:%xmm[0-9]+]] +; X64: pinsrw $1, %eax, [[XMM1]] +; X64: pextrw $1, [[XMM0]], %eax ; X64: pinsrw $4, %eax, %xmm0 ; X64: ret } @@ -251,13 +250,13 @@ %tmp9 = shufflevector <16 x i8> %tmp8, <16 x i8> %T0, <16 x i32> < i32 0, i32 1, i32 2, i32 17, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef , i32 undef > ret <16 x i8> %tmp9 ; X64: t16: -; X64: pinsrw $0, %eax, %xmm1 -; X64: pextrw $8, %xmm0, %eax -; X64: pinsrw $1, %eax, %xmm1 -; X64: pextrw $1, %xmm1, %ecx -; X64: movd %xmm1, %edx -; X64: pinsrw $0, %edx, %xmm1 -; X64: pinsrw $1, %eax, %xmm0 +; X64: pinsrw $0, %eax, [[X1:%xmm[0-9]+]] +; X64: pextrw $8, [[X0:%xmm[0-9]+]], %eax +; X64: pinsrw $1, %eax, [[X1]] +; X64: pextrw $1, [[X1]], %ecx +; X64: movd [[X1]], %edx +; X64: pinsrw $0, %edx, %xmm +; X64: pinsrw $1, %eax, %xmm ; X64: ret } Modified: llvm/trunk/test/CodeGen/X86/sse42.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse42.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse42.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse42.ll Wed May 4 18:54:51 2011 @@ -12,7 +12,7 @@ ; X32: crc32b 8(%esp), %eax ; X64: _crc32_8: -; X64: crc32b %sil, %eax +; X64: crc32b %sil, } @@ -23,7 +23,7 @@ ; X32: crc32w 8(%esp), %eax ; X64: _crc32_16: -; X64: crc32w %si, %eax +; X64: crc32w %si, } @@ -34,5 +34,5 @@ ; X32: crc32l 8(%esp), %eax ; X64: _crc32_32: -; X64: crc32l %esi, %eax +; X64: crc32l %esi, } Modified: llvm/trunk/test/CodeGen/X86/tail-opts.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tail-opts.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/tail-opts.ll (original) +++ llvm/trunk/test/CodeGen/X86/tail-opts.ll Wed May 4 18:54:51 2011 @@ -412,9 +412,9 @@ ; can fall-through into the ret and the other side has to branch anyway. ; CHECK: TESTE: -; CHECK: imulq -; CHECK-NEXT: LBB8_2: -; CHECK-NEXT: ret +; CHECK: ret +; CHECK-NOT: ret +; CHECK: size TESTE define i64 @TESTE(i64 %parami, i64 %paraml) nounwind readnone { entry: Modified: llvm/trunk/test/CodeGen/X86/use-add-flags.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/use-add-flags.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/use-add-flags.ll (original) +++ llvm/trunk/test/CodeGen/X86/use-add-flags.ll Wed May 4 18:54:51 2011 @@ -7,10 +7,10 @@ ; Use the flags on the add. ; CHECK: test1: -; CHECK: addl (%r[[A0:di|cx]]), {{%esi|%edx}} -; CHECK-NEXT: movl {{%edx|%r8d}}, %eax -; CHECK-NEXT: cmovnsl {{%ecx|%r9d}}, %eax -; CHECK-NEXT: ret +; CHECK: addl +; CHECK-NOT: test +; CHECK: cmovnsl +; CHECK: ret define i32 @test1(i32* %x, i32 %y, i32 %a, i32 %b) nounwind { %tmp2 = load i32* %x, align 4 ; [#uses=1] @@ -42,7 +42,7 @@ ; Do use the flags result of the and here, since the and has another use. ; CHECK: test3: -; CHECK: andl $16, %e[[A0]] +; CHECK: andl $16, %e ; CHECK-NEXT: jne define void @test3(i32 %x) nounwind { Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-16.ll Wed May 4 18:54:51 2011 @@ -1,8 +1,9 @@ ; RUN: llc < %s -march=x86 -mattr=+sse,-sse2 -mtriple=i386-apple-darwin | FileCheck %s -check-prefix=sse ; RUN: llc < %s -march=x86 -mattr=+sse2 -mtriple=i386-apple-darwin | FileCheck %s -check-prefix=sse2 +; sse: t1: +; sse2: t1: define <4 x float> @t1(<4 x float> %a, <4 x float> %b) nounwind { -; sse: movaps ; sse: shufps ; sse2: pshufd ; sse2-NEXT: ret @@ -10,6 +11,8 @@ ret <4 x float> %tmp1 } +; sse: t2: +; sse2: t2: define <4 x float> @t2(<4 x float> %A, <4 x float> %B) nounwind { ; sse: shufps ; sse2: pshufd @@ -18,8 +21,9 @@ ret <4 x float> %tmp } +; sse: t3: +; sse2: t3: define <4 x float> @t3(<4 x float> %A, <4 x float> %B) nounwind { -; sse: movaps ; sse: shufps ; sse2: pshufd ; sse2-NEXT: ret @@ -27,7 +31,10 @@ ret <4 x float> %tmp } +; sse: t4: +; sse2: t4: define <4 x float> @t4(<4 x float> %A, <4 x float> %B) nounwind { + ; sse: shufps ; sse2: pshufd ; sse2-NEXT: ret Modified: llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll (original) +++ llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll Wed May 4 18:54:51 2011 @@ -1,9 +1,12 @@ -; RUN: llc < %s -mtriple=x86_64-mingw32 | FileCheck %s -check-prefix=M64 -; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=W64 -; RUN: llc < %s -mtriple=x86_64-win32-macho | FileCheck %s -check-prefix=EFI +; RUN: llc < %s -join-physregs -mtriple=x86_64-mingw32 | FileCheck %s -check-prefix=M64 +; RUN: llc < %s -join-physregs -mtriple=x86_64-win32 | FileCheck %s -check-prefix=W64 +; RUN: llc < %s -join-physregs -mtriple=x86_64-win32-macho | FileCheck %s -check-prefix=EFI ; PR8777 ; PR8778 +; Passing the same value in two registers creates a false interference that +; only -join-physregs resolves. It could also be handled by a parallel copy. + define i64 @foo(i64 %n, i64 %x) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll?rev=130891&r1=130890&r2=130891&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll (original) +++ llvm/trunk/test/CodeGen/X86/x86-64-and-mask.ll Wed May 4 18:54:51 2011 @@ -39,7 +39,7 @@ ; This requires a mov and a 64-bit and. ; CHECK: ddd: -; CHECK: movabsq $4294967296, %rax +; CHECK: movabsq $4294967296, %r ; CHECK: andq %rax, %rdi define void @ddd(i64 %x) nounwind { From stoklund at 2pi.dk Wed May 4 18:54:54 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 23:54:54 -0000 Subject: [llvm-commits] [llvm] r130892 - /llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <20110504235454.85D702A6C12D@llvm.org> Author: stoklund Date: Wed May 4 18:54:54 2011 New Revision: 130892 URL: http://llvm.org/viewvc/llvm-project?rev=130892&view=rev Log: Fix X86RegisterInfo::getMatchingSuperRegClass for sub_8bit_hi. It is OK for B to be any GR8_ABCD_H superclass, the returned register class doesn't have to map surjectively onto B. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=130892&r1=130891&r2=130892&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed May 4 18:54:54 2011 @@ -229,19 +229,14 @@ } break; case X86::sub_8bit_hi: - if (B == &X86::GR8_ABCD_HRegClass) { - if (A == &X86::GR64RegClass || A == &X86::GR64_ABCDRegClass || - A == &X86::GR64_NOREXRegClass || - A == &X86::GR64_NOSPRegClass || - A == &X86::GR64_NOREX_NOSPRegClass) - return &X86::GR64_ABCDRegClass; - else if (A == &X86::GR32RegClass || A == &X86::GR32_ABCDRegClass || - A == &X86::GR32_NOREXRegClass || A == &X86::GR32_NOSPRegClass) - return &X86::GR32_ABCDRegClass; - else if (A == &X86::GR16RegClass || A == &X86::GR16_ABCDRegClass || - A == &X86::GR16_NOREXRegClass) - return &X86::GR16_ABCDRegClass; - } + if (B == &X86::GR8_ABCD_HRegClass || + B->hasSubClass(&X86::GR8_ABCD_HRegClass)) + switch (A->getSize()) { + case 2: return getCommonSubClass(A, &X86::GR16_ABCDRegClass); + case 4: return getCommonSubClass(A, &X86::GR32_ABCDRegClass); + case 8: return getCommonSubClass(A, &X86::GR64_ABCDRegClass); + default: return 0; + } break; case X86::sub_16bit: if (B == &X86::GR16RegClass) { From stoklund at 2pi.dk Wed May 4 18:54:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 23:54:59 -0000 Subject: [llvm-commits] [llvm] r130893 - in /llvm/trunk/test/CodeGen/X86: 2008-12-19-EarlyClobberBug.ll 2009-03-13-PHIElimBug.ll abi-isel.ll add.ll andimm8.ll byval7.ll coalescer-commute2.ll dbg-value-range.ll optimize-max-3.ll phys_subreg_coalesce-2.ll phys_subreg_coalesce-3.ll pmul.ll pr2659.ll sibcall.ll sse-minmax.ll Message-ID: <20110504235459.9CCB82A6C12C@llvm.org> Author: stoklund Date: Wed May 4 18:54:59 2011 New Revision: 130893 URL: http://llvm.org/viewvc/llvm-project?rev=130893&view=rev Log: Prepare remaining tests for -join-physreg going away. Modified: llvm/trunk/test/CodeGen/X86/2008-12-19-EarlyClobberBug.ll llvm/trunk/test/CodeGen/X86/2009-03-13-PHIElimBug.ll llvm/trunk/test/CodeGen/X86/abi-isel.ll llvm/trunk/test/CodeGen/X86/add.ll llvm/trunk/test/CodeGen/X86/andimm8.ll llvm/trunk/test/CodeGen/X86/byval7.ll llvm/trunk/test/CodeGen/X86/coalescer-commute2.ll llvm/trunk/test/CodeGen/X86/dbg-value-range.ll llvm/trunk/test/CodeGen/X86/optimize-max-3.ll llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-2.ll llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-3.ll llvm/trunk/test/CodeGen/X86/pmul.ll llvm/trunk/test/CodeGen/X86/pr2659.ll llvm/trunk/test/CodeGen/X86/sibcall.ll llvm/trunk/test/CodeGen/X86/sse-minmax.ll Modified: llvm/trunk/test/CodeGen/X86/2008-12-19-EarlyClobberBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-12-19-EarlyClobberBug.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-12-19-EarlyClobberBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-12-19-EarlyClobberBug.ll Wed May 4 18:54:59 2011 @@ -4,7 +4,7 @@ ; CHECK: ## InlineAsm End ; CHECK-NEXT: BB0_2: -; CHECK-NEXT: movl %esi, %eax +; CHECK-NEXT: {{movl %esi, %eax|addl %edi, %esi}} @"\01LC" = internal constant [7 x i8] c"n0=%d\0A\00" ; <[7 x i8]*> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2009-03-13-PHIElimBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-03-13-PHIElimBug.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-03-13-PHIElimBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-03-13-PHIElimBug.ll Wed May 4 18:54:59 2011 @@ -28,5 +28,5 @@ } ; CHECK: call{{.*}}f -; CHECK-NEXT: Ltmp0: -; CHECK-NEXT: movl %eax, %esi +; CHECK: movl %eax, %esi +; CHECK: call{{.*}}g Modified: llvm/trunk/test/CodeGen/X86/abi-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/abi-isel.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/abi-isel.ll (original) +++ llvm/trunk/test/CodeGen/X86/abi-isel.ll Wed May 4 18:54:59 2011 @@ -12,16 +12,16 @@ ; RUN: llc < %s -asm-verbose=0 -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=dynamic-no-pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-DYNAMIC ; RUN: llc < %s -asm-verbose=0 -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-PIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=i686-unknown-linux-gnu -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-32-STATIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=i686-unknown-linux-gnu -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-32-PIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-64-STATIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=LINUX-64-PIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=i686-apple-darwin -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=DARWIN-32-STATIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=i686-apple-darwin -march=x86 -relocation-model=dynamic-no-pic -code-model=small | FileCheck %s -check-prefix=DARWIN-32-DYNAMIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=i686-apple-darwin -march=x86 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=DARWIN-32-PIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=DARWIN-64-STATIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=dynamic-no-pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-DYNAMIC -; RUN: llc < %s -asm-verbose=0 -regalloc=basic -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-PIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=i686-unknown-linux-gnu -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-32-STATIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=i686-unknown-linux-gnu -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-32-PIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=LINUX-64-STATIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=x86_64-unknown-linux-gnu -march=x86-64 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=LINUX-64-PIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=i686-apple-darwin -march=x86 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=DARWIN-32-STATIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=i686-apple-darwin -march=x86 -relocation-model=dynamic-no-pic -code-model=small | FileCheck %s -check-prefix=DARWIN-32-DYNAMIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=i686-apple-darwin -march=x86 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=DARWIN-32-PIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=static -code-model=small | FileCheck %s -check-prefix=DARWIN-64-STATIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=dynamic-no-pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-DYNAMIC +; RUN: llc < %s -asm-verbose=0 -regalloc=basic -join-physregs -mtriple=x86_64-apple-darwin -march=x86-64 -relocation-model=pic -code-model=small | FileCheck %s -check-prefix=DARWIN-64-PIC @src = external global [131072 x i32] @dst = external global [131072 x i32] Modified: llvm/trunk/test/CodeGen/X86/add.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/add.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/add.ll (original) +++ llvm/trunk/test/CodeGen/X86/add.ll Wed May 4 18:54:59 2011 @@ -1,6 +1,8 @@ ; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X32 -; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=X64 -; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -mtriple=x86_64-linux -join-physregs | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -mtriple=x86_64-win32 -join-physregs | FileCheck %s -check-prefix=X64 + +; Some of these tests depend on -join-physregs to commute instructions. ; The immediate can be encoded in a smaller way if the ; instruction is a sub instead of an add. Modified: llvm/trunk/test/CodeGen/X86/andimm8.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/andimm8.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/andimm8.ll (original) +++ llvm/trunk/test/CodeGen/X86/andimm8.ll Wed May 4 18:54:59 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 -mtriple=x86_64-pc-linux-gnu -show-mc-encoding | FileCheck %s +; RUN: llc < %s -march=x86-64 -mtriple=x86_64-pc-linux-gnu -show-mc-encoding -join-physregs | FileCheck %s ; PR8365 ; CHECK: andl $-64, %edi # encoding: [0x83,0xe7,0xc0] Modified: llvm/trunk/test/CodeGen/X86/byval7.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/byval7.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/byval7.ll (original) +++ llvm/trunk/test/CodeGen/X86/byval7.ll Wed May 4 18:54:59 2011 @@ -9,7 +9,6 @@ ; CHECK: main: ; CHECK: movl $1, (%esp) ; CHECK: leal 16(%esp), %edi -; CHECK: movl $36, %ecx ; CHECK: leal 160(%esp), %esi ; CHECK: rep;movsl %s = alloca %struct.S ; <%struct.S*> [#uses=2] Modified: llvm/trunk/test/CodeGen/X86/coalescer-commute2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/coalescer-commute2.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/coalescer-commute2.ll (original) +++ llvm/trunk/test/CodeGen/X86/coalescer-commute2.ll Wed May 4 18:54:59 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-linux -join-physregs | FileCheck %s ; CHECK-NOT: mov ; CHECK: paddw ; CHECK-NOT: mov Modified: llvm/trunk/test/CodeGen/X86/dbg-value-range.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-value-range.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-value-range.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Wed May 4 18:54:59 2011 @@ -1,5 +1,5 @@ ; RUN: llc -mtriple=x86_64-apple-darwin10 < %s | FileCheck %s -; RUN: llc -mtriple=x86_64-apple-darwin10 -regalloc=basic < %s | FileCheck %s +; RUN: llc -mtriple=x86_64-apple-darwin10 -regalloc=basic -join-physregs < %s | FileCheck %s %struct.a = type { i32 } Modified: llvm/trunk/test/CodeGen/X86/optimize-max-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/optimize-max-3.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/optimize-max-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/optimize-max-3.ll Wed May 4 18:54:59 2011 @@ -41,14 +41,13 @@ ; CHECK: jle ; CHECK-NOT: cmov -; CHECK: xorl {{%edi, %edi|%ecx, %ecx}} +; CHECK: xorl {{%edi, %edi|%ecx, %ecx|%eax, %eax}} ; CHECK-NEXT: align ; CHECK-NEXT: BB1_2: -; CHECK-NEXT: callq +; CHECK: callq ; CHECK-NEXT: incl [[BX:%[a-z0-9]+]] ; CHECK-NEXT: cmpl [[R14:%[a-z0-9]+]], [[BX]] -; CHECK-NEXT: movq %rax, %r{{di|cx}} -; CHECK-NEXT: jl +; CHECK: jl define void @_Z18GenerateStatusPagei(i32 %jobs_to_display) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-2.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-2.ll Wed May 4 18:54:59 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 | grep mov | count 4 +; RUN: llc < %s -march=x86 | FileCheck %s ; PR2659 define i32 @binomial(i32 %n, i32 %k) nounwind { @@ -12,7 +12,8 @@ ifthen: ; preds = %entry ret i32 0 - +; CHECK: forbody +; CHECK-NOT: mov forbody: ; preds = %forbody, %forcond.preheader %indvar = phi i32 [ 0, %forcond.preheader ], [ %divisor.02, %forbody ] ; [#uses=3] %accumulator.01 = phi i32 [ 1, %forcond.preheader ], [ %div, %forbody ] ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-3.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-3.ll (original) +++ llvm/trunk/test/CodeGen/X86/phys_subreg_coalesce-3.ll Wed May 4 18:54:59 2011 @@ -1,6 +1,11 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin | FileCheck %s +; RUN: llc < %s -mtriple=i386-apple-darwin -join-physregs | FileCheck %s ; rdar://5571034 +; This requires physreg joining, %vreg13 is live everywhere: +; 304L %CL = COPY %vreg13:sub_8bit; GR32_ABCD:%vreg13 +; 320L %vreg15 = COPY %vreg19; GR32:%vreg15 GR32_NOSP:%vreg19 +; 336L %vreg15 = SAR32rCL %vreg15, %EFLAGS, %CL; GR32:%vreg15 + define void @foo(i32* nocapture %quadrant, i32* nocapture %ptr, i32 %bbSize, i32 %bbStart, i32 %shifts) nounwind ssp { ; CHECK: foo: entry: Modified: llvm/trunk/test/CodeGen/X86/pmul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pmul.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pmul.ll (original) +++ llvm/trunk/test/CodeGen/X86/pmul.ll Wed May 4 18:54:59 2011 @@ -1,7 +1,9 @@ -; RUN: llc < %s -march=x86 -mattr=sse41 -stack-alignment=16 > %t +; RUN: llc < %s -march=x86 -mattr=sse41 -stack-alignment=16 -join-physregs > %t ; RUN: grep pmul %t | count 12 ; RUN: grep mov %t | count 11 +; The f() arguments in %xmm0 and %xmm1 cause an extra movdqa without -join-physregs. + define <4 x i32> @a(<4 x i32> %i) nounwind { %A = mul <4 x i32> %i, < i32 117, i32 117, i32 117, i32 117 > ret <4 x i32> %A Modified: llvm/trunk/test/CodeGen/X86/pr2659.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr2659.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pr2659.ll (original) +++ llvm/trunk/test/CodeGen/X86/pr2659.ll Wed May 4 18:54:59 2011 @@ -1,5 +1,4 @@ -; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin9.4.0 | grep movl | count 4 -; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin9.4.0 | FileCheck %s +; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin9.4.0 -disable-branch-fold | FileCheck %s ; PR2659 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" @@ -19,7 +18,11 @@ ; CHECK-NOT: xorl ; CHECK-NOT: movl ; CHECK-NOT: LBB -; CHECK: je +; CHECK: jne + +; There should be no moves required in the for loop body. +; CHECK: %forbody +; CHECK-NOT: mov ifthen: ; preds = %entry ret i32 0 Modified: llvm/trunk/test/CodeGen/X86/sibcall.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sibcall.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sibcall.ll (original) +++ llvm/trunk/test/CodeGen/X86/sibcall.ll Wed May 4 18:54:59 2011 @@ -229,7 +229,7 @@ ; 64: t14: ; 64: movq 32(%rdi) ; 64-NOT: movq 16(%rdi) -; 64: jmpq *16(%rdi) +; 64: jmpq *16({{%rdi|%rax}}) %0 = getelementptr inbounds %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; [#uses=1] %1 = load void ()** %0, align 8 ; [#uses=2] %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/sse-minmax.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-minmax.ll?rev=130893&r1=130892&r2=130893&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse-minmax.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse-minmax.ll Wed May 4 18:54:59 2011 @@ -1,6 +1,6 @@ -; RUN: llc < %s -march=x86-64 -asm-verbose=false | FileCheck %s -; RUN: llc < %s -march=x86-64 -asm-verbose=false -enable-unsafe-fp-math -enable-no-nans-fp-math | FileCheck -check-prefix=UNSAFE %s -; RUN: llc < %s -march=x86-64 -asm-verbose=false -enable-no-nans-fp-math | FileCheck -check-prefix=FINITE %s +; RUN: llc < %s -march=x86-64 -asm-verbose=false -join-physregs | FileCheck %s +; RUN: llc < %s -march=x86-64 -asm-verbose=false -join-physregs -enable-unsafe-fp-math -enable-no-nans-fp-math | FileCheck -check-prefix=UNSAFE %s +; RUN: llc < %s -march=x86-64 -asm-verbose=false -join-physregs -enable-no-nans-fp-math | FileCheck -check-prefix=FINITE %s ; Some of these patterns can be matched as SSE min or max. Some of ; then can be matched provided that the operands are swapped. @@ -12,6 +12,9 @@ ; y_ : use -0.0 instead of %y ; _inverse : swap the arms of the select. +; Some of these tests depend on -join-physregs commuting instructions to +; eliminate copies. + ; CHECK: ogt: ; CHECK-NEXT: maxsd %xmm1, %xmm0 ; CHECK-NEXT: ret From dpatel at apple.com Wed May 4 18:58:22 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 23:58:22 -0000 Subject: [llvm-commits] [llvm] r130894 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Message-ID: <20110504235822.F2B842A6C12C@llvm.org> Author: dpatel Date: Wed May 4 18:58:22 2011 New Revision: 130894 URL: http://llvm.org/viewvc/llvm-project?rev=130894&view=rev Log: Set debug location for new PHI nodes created in exit block. Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=130894&r1=130893&r2=130894&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Wed May 4 18:58:22 2011 @@ -36,6 +36,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" @@ -226,6 +227,7 @@ PredCache.GetNumPreds(ExitBB), Inst->getName()+".lcssa", ExitBB->begin()); + PN->setDebugLoc(GetFirstDebugLocInBasicBlock(ExitBB)); // Add inputs from inside the loop for this PHI. for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) { From dpatel at apple.com Wed May 4 18:58:50 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 04 May 2011 23:58:50 -0000 Subject: [llvm-commits] [llvm] r130895 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <20110504235850.785C62A6C12C@llvm.org> Author: dpatel Date: Wed May 4 18:58:50 2011 New Revision: 130895 URL: http://llvm.org/viewvc/llvm-project?rev=130895&view=rev Log: Set debug loc for new instructions. 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=130895&r1=130894&r2=130895&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed May 4 18:58:50 2011 @@ -952,12 +952,12 @@ IntegerType::get(LoadTy->getContext(), NewLoadSize*8); DestPTy = PointerType::get(DestPTy, cast(PtrVal->getType())->getAddressSpace()); - + Builder.SetCurrentDebugLocation(SrcVal->getDebugLoc()); PtrVal = Builder.CreateBitCast(PtrVal, DestPTy); LoadInst *NewLoad = Builder.CreateLoad(PtrVal); NewLoad->takeName(SrcVal); NewLoad->setAlignment(SrcVal->getAlignment()); - + DEBUG(dbgs() << "GVN WIDENED LOAD: " << *SrcVal << "\n"); DEBUG(dbgs() << "TO: " << *NewLoad << "\n"); @@ -2118,7 +2118,7 @@ VN.add(Phi, ValNo); addToLeaderTable(ValNo, Phi, CurrentBlock); - + Phi->setDebugLoc(CurInst->getDebugLoc()); CurInst->replaceAllUsesWith(Phi); if (Phi->getType()->isPointerTy()) { // Because we have added a PHI-use of the pointer value, it has now From stoklund at 2pi.dk Wed May 4 18:59:00 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 04 May 2011 23:59:00 -0000 Subject: [llvm-commits] [llvm] r130896 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Message-ID: <20110504235900.5441D2A6C12C@llvm.org> Author: stoklund Date: Wed May 4 18:59:00 2011 New Revision: 130896 URL: http://llvm.org/viewvc/llvm-project?rev=130896&view=rev Log: Disable physical register coalescing by default. Joining physregs is inherently dangerous because it uses a heuristic to avoid creating invalid code. Linear scan had an emergency spilling mechanism to deal with those rare cases. The new greedy allocator does not. The greedy register allocator is much better at taking hints, so this has almost no impact on code size and quality. The few cases where it matters show up as unit tests that now have -join-physregs enabled explicitly. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=130896&r1=130895&r2=130896&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Wed May 4 18:59:00 2011 @@ -63,7 +63,7 @@ static cl::opt EnablePhysicalJoin("join-physregs", cl::desc("Join physical register copies"), - cl::init(true), cl::Hidden); + cl::init(false), cl::Hidden); static cl::opt VerifyCoalescing("verify-coalescing", From nicholas at mxc.ca Wed May 4 19:03:30 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 05 May 2011 00:03:30 -0000 Subject: [llvm-commits] [llvm] r130897 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Message-ID: <20110505000330.4157E2A6C12C@llvm.org> Author: nicholas Date: Wed May 4 19:03:30 2011 New Revision: 130897 URL: http://llvm.org/viewvc/llvm-project?rev=130897&view=rev Log: When the path wasn't emitted by the frontend, discard any path on the source filename. Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130897&r1=130896&r2=130897&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed May 4 19:03:30 2011 @@ -331,15 +331,20 @@ for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { MDNode *N = GCov->getOperand(i); if (N->getNumOperands() != 2) continue; - MDString *Path = dyn_cast(N->getOperand(0)); + MDString *GCovFile = dyn_cast(N->getOperand(0)); MDNode *CompileUnit = dyn_cast(N->getOperand(1)); - if (!Path || !CompileUnit) continue; - if (CompileUnit == CU) - return (Path->getString() + "/" + - replaceStem(CU.getFilename(), NewStem)).str(); + if (!GCovFile || !CompileUnit) continue; + if (CompileUnit == CU) { + SmallString<128> Filename = GCovFile->getString(); + sys::path::replace_extension(Filename, NewStem); + return Filename.str(); + } } } - return replaceStem(CU.getFilename(), NewStem); + + SmallString<128> Filename = CU.getFilename(); + sys::path::replace_extension(Filename, NewStem); + return sys::path::filename(Filename.str()); } bool GCOVProfiler::runOnModule(Module &M) { From aggarwa4 at illinois.edu Wed May 4 19:09:39 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 00:09:39 -0000 Subject: [llvm-commits] [poolalloc] r130900 - in /poolalloc/trunk/lib/AssistDS: GEPExprArg.cpp LoadArgs.cpp Message-ID: <20110505000939.EB2782A6C12D@llvm.org> Author: aggarwa4 Date: Wed May 4 19:09:39 2011 New Revision: 130900 URL: http://llvm.org/viewvc/llvm-project?rev=130900&view=rev Log: Lower the number of clones to control code size. Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp?rev=130900&r1=130899&r2=130900&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (original) +++ poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Wed May 4 19:09:39 2011 @@ -88,7 +88,7 @@ const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); Function *NewF; numSimplified++; - if(numSimplified > 1000) + if(numSimplified > 800) return true; NewF = Function::Create(NewFTy, Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130900&r1=130899&r2=130900&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Wed May 4 19:09:39 2011 @@ -108,7 +108,7 @@ const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); Function *NewF; numSimplified++; - if(numSimplified > 500) //26 + if(numSimplified > 400) //26 return true; NewF = Function::Create(NewFTy, From aggarwa4 at illinois.edu Wed May 4 19:10:15 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 00:10:15 -0000 Subject: [llvm-commits] [poolalloc] r130901 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Message-ID: <20110505001015.161022A6C12D@llvm.org> Author: aggarwa4 Date: Wed May 4 19:10:14 2011 New Revision: 130901 URL: http://llvm.org/viewvc/llvm-project?rev=130901&view=rev Log: Remove unnessary comment Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130901&r1=130900&r2=130901&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Wed May 4 19:10:14 2011 @@ -108,7 +108,7 @@ const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); Function *NewF; numSimplified++; - if(numSimplified > 400) //26 + if(numSimplified > 400) return true; NewF = Function::Create(NewFTy, From nicholas at mxc.ca Wed May 4 19:17:34 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 05 May 2011 00:17:34 -0000 Subject: [llvm-commits] [llvm] r130903 - /llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Message-ID: <20110505001734.BB7A82A6C12C@llvm.org> Author: nicholas Date: Wed May 4 19:17:34 2011 New Revision: 130903 URL: http://llvm.org/viewvc/llvm-project?rev=130903&view=rev Log: Remove dead function. Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130903&r1=130902&r2=130903&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed May 4 19:17:34 2011 @@ -321,11 +321,6 @@ }; } -// Replace the stem of a file, or add one if missing. -static std::string replaceStem(std::string OrigFilename, std::string NewStem) { - return (sys::path::stem(OrigFilename) + "." + NewStem).str(); -} - std::string GCOVProfiler::mangleName(DICompileUnit CU, std::string NewStem) { if (NamedMDNode *GCov = M->getNamedMetadata("llvm.gcov")) { for (int i = 0, e = GCov->getNumOperands(); i != e; ++i) { From eli.friedman at gmail.com Wed May 4 19:35:04 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 4 May 2011 17:35:04 -0700 Subject: [llvm-commits] [llvm] r130877 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll In-Reply-To: <20110504221037.2B8C92A6C12C@llvm.org> References: <20110504221037.2B8C92A6C12C@llvm.org> Message-ID: On Wed, May 4, 2011 at 3:10 PM, Eli Friedman wrote: > Author: efriedma > Date: Wed May ?4 17:10:36 2011 > New Revision: 130877 > > URL: http://llvm.org/viewvc/llvm-project?rev=130877&view=rev > Log: > Re-commit r130862 with a minor change to avoid an iterator running off the edge in some cases. > > Original message: > > Teach MachineCSE how to do simple cross-block CSE involving physregs. ?This allows, for example, eliminating duplicate cmpl's on x86. Part of rdar://problem/8259436 . > > This is breaking a few of the buildbots with the following assertion: lib/CodeGen/LiveInterval.cpp:267: llvm::LiveRange* llvm::LiveInterval::addRangeFrom(llvm::LiveRange, llvm::LiveRange*): Assertion `B->end <= Start && "Cannot overlap two LiveRanges with differing ValID's" " (did you def the same reg twice in a MachineInstr?)"' failed. I'm not sure how to go about reproducing this, so it would be very much appreciated if someone could send me a bitcode file where this reproduces. Thanks, Eli From echristo at apple.com Wed May 4 19:46:19 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 05 May 2011 00:46:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130905 - /llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h Message-ID: <20110505004619.717212A6C12C@llvm.org> Author: echristo Date: Wed May 4 19:46:19 2011 New Revision: 130905 URL: http://llvm.org/viewvc/llvm-project?rev=130905&view=rev Log: Fix extra long comment. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h?rev=130905&r1=130904&r2=130905&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h Wed May 4 19:46:19 2011 @@ -48,9 +48,10 @@ #define REGISTER_PREFIX "" -/* The assembler's names for the registers. Note that the ?xx registers are * there so that VFPv3/NEON registers D16-D31 have the same spacing as D0-D15 - * (each of which is overlaid on two S registers), although there are no - * actual single-precision registers which correspond to D16-D31. */ +/* The assembler's names for the registers. Note that the ?xx registers are + there so that VFPv3/NEON registers D16-D31 have the same spacing as D0-D15 + (each of which is overlaid on two S registers), although there are no + actual single-precision registers which correspond to D16-D31. */ #ifndef REGISTER_NAMES #define REGISTER_NAMES \ { \ From clattner at apple.com Wed May 4 19:57:02 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 04 May 2011 17:57:02 -0700 Subject: [llvm-commits] [llvm] r130894 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp In-Reply-To: <20110504235822.F2B842A6C12C@llvm.org> References: <20110504235822.F2B842A6C12C@llvm.org> Message-ID: <5B056F2B-45B0-44A5-B5E0-7F26BBBDC2A6@apple.com> On May 4, 2011, at 4:58 PM, Devang Patel wrote: > Author: dpatel > Date: Wed May 4 18:58:22 2011 > New Revision: 130894 > > URL: http://llvm.org/viewvc/llvm-project?rev=130894&view=rev > Log: > Set debug location for new PHI nodes created in exit block. Devang, What does a debug loc even mean for a PHI node? Conceptually a phi node is a copy in each of the predecessors, certainly it can't have a single debug loc? -Chris > > Modified: > llvm/trunk/lib/Transforms/Utils/LCSSA.cpp > > Modified: llvm/trunk/lib/Transforms/Utils/LCSSA.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LCSSA.cpp?rev=130894&r1=130893&r2=130894&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/LCSSA.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/LCSSA.cpp Wed May 4 18:58:22 2011 > @@ -36,6 +36,7 @@ > #include "llvm/Analysis/Dominators.h" > #include "llvm/Analysis/LoopPass.h" > #include "llvm/Analysis/ScalarEvolution.h" > +#include "llvm/Transforms/Utils/BasicBlockUtils.h" > #include "llvm/Transforms/Utils/SSAUpdater.h" > #include "llvm/ADT/Statistic.h" > #include "llvm/ADT/STLExtras.h" > @@ -226,6 +227,7 @@ > PredCache.GetNumPreds(ExitBB), > Inst->getName()+".lcssa", > ExitBB->begin()); > + PN->setDebugLoc(GetFirstDebugLocInBasicBlock(ExitBB)); > > // Add inputs from inside the loop for this PHI. > for (BasicBlock **PI = PredCache.GetPreds(ExitBB); *PI; ++PI) { > > > _______________________________________________ > 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 May 4 19:58:08 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 04 May 2011 17:58:08 -0700 Subject: [llvm-commits] [llvm] r130791 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp test/Assembler/AutoUpgradeIntrinsics.ll test/CodeGen/X86/nontemporal.ll In-Reply-To: <20110503211117.54AA62A6C12C@llvm.org> References: <20110503211117.54AA62A6C12C@llvm.org> Message-ID: On May 3, 2011, at 2:11 PM, Bill Wendling wrote: > Author: void > Date: Tue May 3 16:11:17 2011 > New Revision: 130791 > > URL: http://llvm.org/viewvc/llvm-project?rev=130791&view=rev > Log: > Replace the "movnt" intrinsics with a native store + nontemporal metadata bit. > Thanks Bill, This is probably worth mentioning in the X86 section of CodeGenerator.html if it isn't already, -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110504/dab91797/attachment.html From aggarwa4 at illinois.edu Wed May 4 20:47:38 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 01:47:38 -0000 Subject: [llvm-commits] [poolalloc] r130908 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp Message-ID: <20110505014738.AB9EC2A6C12C@llvm.org> Author: aggarwa4 Date: Wed May 4 20:47:38 2011 New Revision: 130908 URL: http://llvm.org/viewvc/llvm-project?rev=130908&view=rev Log: Also handle Invoke Insts. Modified: poolalloc/trunk/include/assistDS/TypeChecks.h poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/include/assistDS/TypeChecks.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=130908&r1=130907&r2=130908&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/TypeChecks.h (original) +++ poolalloc/trunk/include/assistDS/TypeChecks.h Wed May 4 20:47:38 2011 @@ -57,11 +57,12 @@ bool initShadow(Module &M, Instruction &I); bool unmapShadow(Module &M, Instruction &I); bool visitCallInst(Module &M, CallInst &CI); + bool visitInvokeInst(Module &M, InvokeInst &CI); bool visitCallSite(Module &M, CallSite CS); bool visitLoadInst(Module &M, LoadInst &LI); + bool visitStoreInst(Module &M, StoreInst &SI); bool visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset); - bool visitStoreInst(Module &M, StoreInst &SI); bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS); bool visitInputFunctionValue(Module &M, Value *V, Instruction *CI); Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130908&r1=130907&r2=130908&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Wed May 4 20:47:38 2011 @@ -133,6 +133,9 @@ } } else if (CallInst *CI = dyn_cast(&I)) { modified |= visitCallInst(M, *CI); + } else if (InvokeInst *II = dyn_cast(&I)) { + II->dump(); + modified |= visitInvokeInst(M, *II); } } } @@ -276,6 +279,11 @@ return visitCallSite(M, &CI); } +// Insert runtime checks for certain call instructions +bool TypeChecks::visitInvokeInst(Module &M, InvokeInst &II) { + return visitCallSite(M, &II); +} + bool TypeChecks::visitCallSite(Module &M, CallSite CS) { // // Get the called value. Strip off any casts which are lossless. From nicholas at mxc.ca Wed May 4 21:46:38 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 05 May 2011 02:46:38 -0000 Subject: [llvm-commits] [llvm] r130911 - in /llvm/trunk: lib/Transforms/Instrumentation/GCOVProfiling.cpp runtime/libprofile/GCDAProfiling.c Message-ID: <20110505024638.CD7872A6C12C@llvm.org> Author: nicholas Date: Wed May 4 21:46:38 2011 New Revision: 130911 URL: http://llvm.org/viewvc/llvm-project?rev=130911&view=rev Log: Update the gcov version used slightly, to make it stop causing modern gcov's to crash. Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/runtime/libprofile/GCDAProfiling.c Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130911&r1=130910&r2=130911&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Wed May 4 21:46:38 2011 @@ -87,7 +87,7 @@ // list. void insertCounterWriteout(DebugInfoFinder &, SmallVector, 8> &); + MDNode *>, 8> &); std::string mangleName(DICompileUnit CU, std::string NewStem); @@ -261,12 +261,13 @@ ReturnBlock = new GCOVBlock(i++, os); writeBytes(FunctionTag, 4); - uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) + + uint32_t BlockLen = 1 + 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) + 1 + lengthOfGCOVString(SP.getFilename()) + 1; write(BlockLen); uint32_t Ident = reinterpret_cast((MDNode*)SP); write(Ident); - write(0); // checksum + write(0); // checksum #1 + write(0); // checksum #2 writeGCOVString(SP.getName()); writeGCOVString(SP.getFilename()); write(SP.getLineNumber()); @@ -418,7 +419,7 @@ if (DIF.subprogram_begin() == DIF.subprogram_end()) return false; - SmallVector, 8> CountersByIdent; + SmallVector, 8> CountersBySP; for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(), SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) { DISubprogram SP(*SPI); @@ -441,8 +442,7 @@ GlobalValue::InternalLinkage, Constant::getNullValue(CounterTy), "__llvm_gcov_ctr", 0, false, 0); - CountersByIdent.push_back( - std::make_pair(Counters, reinterpret_cast((MDNode*)SP))); + CountersBySP.push_back(std::make_pair(Counters, (MDNode*)SP)); UniqueVector ComplexEdgePreds; UniqueVector ComplexEdgeSuccs; @@ -509,7 +509,7 @@ } } - insertCounterWriteout(DIF, CountersByIdent); + insertCounterWriteout(DIF, CountersBySP); return true; } @@ -580,7 +580,10 @@ } Constant *GCOVProfiler::getEmitFunctionFunc() { - const Type *Args[] = { Type::getInt32Ty(*Ctx) }; + const Type *Args[2] = { + Type::getInt32Ty(*Ctx), // uint32_t ident + Type::getInt8PtrTy(*Ctx), // const char *function_name + }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); return M->getOrInsertFunction("llvm_gcda_emit_function", FTy); @@ -616,7 +619,7 @@ void GCOVProfiler::insertCounterWriteout( DebugInfoFinder &DIF, - SmallVector, 8> &CountersByIdent) { + SmallVector, 8> &CountersBySP) { const FunctionType *WriteoutFTy = FunctionType::get(Type::getVoidTy(*Ctx), false); Function *WriteoutF = Function::Create(WriteoutFTy, @@ -637,11 +640,15 @@ std::string FilenameGcda = mangleName(compile_unit, "gcda"); Builder.CreateCall(StartFile, Builder.CreateGlobalStringPtr(FilenameGcda)); - for (SmallVector, 8>::iterator - I = CountersByIdent.begin(), E = CountersByIdent.end(); + for (SmallVector, 8>::iterator + I = CountersBySP.begin(), E = CountersBySP.end(); I != E; ++I) { - Builder.CreateCall(EmitFunction, ConstantInt::get(Type::getInt32Ty(*Ctx), - I->second)); + DISubprogram SP(I->second); + intptr_t ident = reinterpret_cast(I->second); + Builder.CreateCall2(EmitFunction, + ConstantInt::get(Type::getInt32Ty(*Ctx), ident), + Builder.CreateGlobalStringPtr(SP.getName())); + GlobalVariable *GV = I->first; unsigned Arcs = cast(GV->getType()->getElementType())->getNumElements(); Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130911&r1=130910&r2=130911&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Wed May 4 21:46:38 2011 @@ -48,6 +48,17 @@ write_int32(hi); } +static uint32_t length_of_string(const char *s) { + return (strlen(s) + 5) / 4; +} + +static void write_string(const char *s) { + uint32_t len = length_of_string(s); + write_int32(len); + fwrite(s, strlen(s), 1, output_file); + fwrite("\0\0\0\0", 4 - (strlen(s) % 4), 1, output_file); +} + static char *mangle_filename(const char *orig_filename) { /* TODO: handle GCOV_PREFIX_STRIP */ const char *prefix; @@ -129,16 +140,18 @@ #endif } -void llvm_gcda_emit_function(uint32_t ident) { +void llvm_gcda_emit_function(uint32_t ident, const char *function_name) { #ifdef DEBUG_GCDAPROFILING printf("llvmgcda: function id=%x\n", ident); #endif /* function tag */ fwrite("\0\0\0\1", 4, 1, output_file); - write_int32(2); + write_int32(3 + 1 + length_of_string(function_name)); write_int32(ident); write_int32(0); + write_int32(0); + write_string(function_name); } void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) { From foldr at codedgers.com Wed May 4 23:24:58 2011 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Thu, 05 May 2011 04:24:58 -0000 Subject: [llvm-commits] [llvm] r130914 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <20110505042458.7E5A92A6C12C@llvm.org> Author: foldr Date: Wed May 4 23:24:58 2011 New Revision: 130914 URL: http://llvm.org/viewvc/llvm-project?rev=130914&view=rev Log: llvmc: Make it possible to provide an argument to (join). Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=130914&r1=130913&r2=130914&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Wed May 4 23:24:58 2011 @@ -74,6 +74,25 @@ return val.getValue(); } +bool InitPtrToBool(const Init* ptr) { + bool ret = false; + const DefInit& val = dynamic_cast(*ptr); + const std::string& str = val.getAsString(); + + if (str == "true") { + ret = true; + } + else if (str == "false") { + ret = false; + } + else { + throw "Incorrect boolean value: '" + str + + "': must be either 'true' or 'false'"; + } + + return ret; +} + const std::string& InitPtrToString(const Init* ptr) { const StringInit& val = dynamic_cast(*ptr); return val.getValue(); @@ -95,13 +114,7 @@ /// CheckBooleanConstant - Check that the provided value is a boolean constant. void CheckBooleanConstant(const Init* I) { - const DefInit& val = dynamic_cast(*I); - const std::string& str = val.getAsString(); - - if (str != "true" && str != "false") { - throw "Incorrect boolean value: '" + str + - "': must be either 'true' or 'false'"; - } + InitPtrToBool(I); } // CheckNumberOfArguments - Ensure that the number of args in d is @@ -935,8 +948,22 @@ } void onJoin (const DagInit& d) { - CheckNumberOfArguments(d, 0); - toolDesc_.setJoin(); + bool isReallyJoin = false; + + if (d.getNumArgs() == 0) { + isReallyJoin = true; + } + else { + Init* I = d.getArg(0); + isReallyJoin = InitPtrToBool(I); + } + + // Is this *really* a join tool? We allow (join false) for generating two + // tool descriptions from a single generic one. + // TOFIX: come up with a cleaner solution. + if (isReallyJoin) { + toolDesc_.setJoin(); + } } void onOutLanguage (const DagInit& d) { From foldr at codedgers.com Wed May 4 23:25:03 2011 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Thu, 05 May 2011 04:25:03 -0000 Subject: [llvm-commits] [llvm] r130915 - /llvm/trunk/include/llvm/CompilerDriver/Common.td Message-ID: <20110505042503.AB7812A6C12D@llvm.org> Author: foldr Date: Wed May 4 23:25:03 2011 New Revision: 130915 URL: http://llvm.org/viewvc/llvm-project?rev=130915&view=rev Log: llvmc: Make 'true' and 'false' instances of a 'Bool' class. Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=130915&r1=130914&r2=130915&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Common.td (original) +++ llvm/trunk/include/llvm/CompilerDriver/Common.td Wed May 4 23:25:03 2011 @@ -56,8 +56,11 @@ def case; // Boolean constants. -def true; -def false; +class Bool { + bit Value = val; +} +def true : Bool<1>; +def false : Bool<0>; // Boolean operators. def and; From aggarwa4 at illinois.edu Thu May 5 00:11:12 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 05:11:12 -0000 Subject: [llvm-commits] [poolalloc] r130917 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110505051113.0684F2A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 5 00:11:12 2011 New Revision: 130917 URL: http://llvm.org/viewvc/llvm-project?rev=130917&view=rev Log: Added some preliminary tracking of byval arguments. Assumes they are all TOP. Also makes sure we clear the metadata when we return. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130917&r1=130916&r2=130917&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 5 00:11:12 2011 @@ -21,6 +21,9 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Intrinsics.h" +#include +#include + using namespace llvm; char TypeChecks::ID = 0; @@ -109,7 +112,8 @@ IncorporateType(MI->getType()); Function &F = *MI; - // Loop over all of the instructions in the function, adding their return type as well as the types of their operands. + // Loop over all of the instructions in the function, + // adding their return type as well as the types of their operands. for (inst_iterator II = inst_begin(F), IE = inst_end(F); II != IE; ++II) { Instruction &I = *II; @@ -140,6 +144,71 @@ } } + // Record types for byval arguments. + + // Split fn into 2 clones. One internal, such that + // we can find all call sites to it, and also pass in the + // original ptr/metadata. + // One that sets it just to initialized memory + // so that it can be calle from external code. + for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { + Function &F = *MI; + typedef SmallVector RegisteredArgTy; + RegisteredArgTy registeredArguments; + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { + if (I->hasByValAttr()) { + assert (isa(I->getType())); + const PointerType * PT = cast(I->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + Instruction * InsertBefore = &(F.getEntryBlock().front()); + CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy, "", InsertBefore); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", InsertBefore); + registeredArguments.push_back(&*I); + } + } + // + // Find all basic blocks which terminate the function. + // + std::set exitBlocks; + for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { + if (isa(*I) || isa(*I)) { + exitBlocks.insert(I->getParent()); + } + } + + // + // At each function exit, insert code to deregister all byval arguments. + // + for (std::set::const_iterator BI = exitBlocks.begin(), + BE = exitBlocks.end(); + BI != BE; ++BI) { + for (RegisteredArgTy::const_iterator I = registeredArguments.begin(), + E = registeredArguments.end(); + I != E; ++I) { + SmallVector args; + Instruction * Pt = &((*BI)->back()); + const PointerType * PT = cast((*I)->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + CastInst *BCI = BitCastInst::CreatePointerCast(*I, VoidPtrTy, "", Pt); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackUnInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", Pt); + } + } + + + } + return modified; } @@ -184,7 +253,7 @@ bool TypeChecks::visitGlobal(Module &M, GlobalVariable &GV, Constant *C, Instruction &I, unsigned offset) { - + if(ConstantArray *CA = dyn_cast(C)) { const Type * ElementType = CA->getType()->getElementType(); unsigned int t = TD->getTypeStoreSize(ElementType); Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=130917&r1=130916&r2=130917&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Thu May 5 00:11:12 2011 @@ -123,6 +123,11 @@ p &= 0xFFFFFFFF; memset(&shadow_begin[p], 0xFF, size); } +void trackUnInitInst(void *ptr, uint64_t size, uint32_t tag) { + uintptr_t p = (uintptr_t)ptr; + p &= 0xFFFFFFFF; + memset(&shadow_begin[p], 0x00, size); +} /** * Copy size bits of metadata from src ptr to dest ptr. From isanbard at gmail.com Thu May 5 01:49:15 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 05 May 2011 06:49:15 -0000 Subject: [llvm-commits] [llvm] r130918 - in /llvm/trunk: include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfTableException.cpp lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/TargetLoweringObjectFile.cpp Message-ID: <20110505064915.62BE32A6C12C@llvm.org> Author: void Date: Thu May 5 01:49:15 2011 New Revision: 130918 URL: http://llvm.org/viewvc/llvm-project?rev=130918&view=rev Log: Remove a flag that would set the ".eh" symbol as .globl. MachO was the only one who used this flag, and it now emits CFI and doesn't emit this anymore. All other targets left this flag "false". Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=130918&r1=130917&r2=130918&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Thu May 5 01:49:15 2011 @@ -97,10 +97,6 @@ /// weak_definition of constant 0 for an omitted EH frame. bool SupportsWeakOmittedEHFrame; - /// IsFunctionEHSymbolGlobal - This flag is set to true if the ".eh" symbol - /// for a function should be marked .globl. - bool IsFunctionEHSymbolGlobal; - /// IsFunctionEHFrameSymbolPrivate - This flag is set to true if the /// "EH_frame" symbol for EH information should be an assembler temporary (aka /// private linkage, aka an L or .L label) or false if it should be a normal @@ -119,9 +115,6 @@ Ctx = &ctx; } - bool isFunctionEHSymbolGlobal() const { - return IsFunctionEHSymbolGlobal; - } bool isFunctionEHFrameSymbolPrivate() const { return IsFunctionEHFrameSymbolPrivate; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp?rev=130918&r1=130917&r2=130918&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp Thu May 5 01:49:15 2011 @@ -172,11 +172,6 @@ Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); - // Externally visible entry into the functions eh frame info. If the - // corresponding function is static, this should not be externally visible. - if (!TheFunc->hasLocalLinkage() && TLOF.isFunctionEHSymbolGlobal()) - Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,MCSA_Global); - // If corresponding function is weak definition, this should be too. if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective()) Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym, Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=130918&r1=130917&r2=130918&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu May 5 01:49:15 2011 @@ -484,11 +484,6 @@ void TargetLoweringObjectFileMachO::Initialize(MCContext &Ctx, const TargetMachine &TM) { - // _foo.eh symbols are currently always exported so that the linker knows - // about them. This is not necessary on 10.6 and later, but it - // doesn't hurt anything. - // FIXME: I need to get this from Triple. - IsFunctionEHSymbolGlobal = true; IsFunctionEHFrameSymbolPrivate = false; SupportsWeakOmittedEHFrame = false; Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=130918&r1=130917&r2=130918&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Thu May 5 01:49:15 2011 @@ -58,7 +58,6 @@ DwarfRangesSection = 0; DwarfMacroInfoSection = 0; - IsFunctionEHSymbolGlobal = false; IsFunctionEHFrameSymbolPrivate = true; SupportsWeakOmittedEHFrame = true; } From etherzhhb at gmail.com Thu May 5 03:03:42 2011 From: etherzhhb at gmail.com (ether zhhb) Date: Thu, 5 May 2011 16:03:42 +0800 Subject: [llvm-commits] [PATCH 1/2] Minor change: Fix the typo in RegionPass.h and RegionPass.cpp. Message-ID: hi, This patch fix two typo in RegionPass.h and RegionPass.cpp. best regards ether --- include/llvm/Analysis/RegionPass.h | 2 +- lib/Analysis/RegionPass.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/llvm/Analysis/RegionPass.h b/include/llvm/Analysis/RegionPass.h index aedc06a..6c4e226 100644 --- a/include/llvm/Analysis/RegionPass.h +++ b/include/llvm/Analysis/RegionPass.h @@ -109,7 +109,7 @@ public: /// @brief Print passes managed by this manager. void dumpPassStructure(unsigned Offset); - /// @brief Print passes contained by this manager. + /// @brief Get passes contained by this manager. Pass *getContainedPass(unsigned N) { assert(N < PassVector.size() && "Pass number out of range!"); Pass *FP = static_cast(PassVector[N]); diff --git a/lib/Analysis/RegionPass.cpp b/lib/Analysis/RegionPass.cpp index 3269dcc..80eda79 100644 --- a/lib/Analysis/RegionPass.cpp +++ b/lib/Analysis/RegionPass.cpp @@ -249,7 +249,7 @@ void RegionPass::assignPassManager(PMStack &PMS, assert (!PMS.empty() && "Unable to create Region Pass Manager"); PMDataManager *PMD = PMS.top(); - // [1] Create new Call Graph Pass Manager + // [1] Create new Region Pass Manager RGPM = new RGPassManager(PMD->getDepth() + 1); RGPM->populateInheritedAnalysis(PMS); -- 1.7.4 -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Minor-change-Fix-the-typo-in-RegionPass.h-and-Region.patch Type: application/octet-stream Size: 1514 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110505/2bc8a341/attachment.obj From etherzhhb at gmail.com Thu May 5 03:07:41 2011 From: etherzhhb at gmail.com (ether zhhb) Date: Thu, 5 May 2011 16:07:41 +0800 Subject: [llvm-commits] [PATCH 2/2] Allow RegionPass to do post processing after all passes have run. Message-ID: hi, This patch add a module level finalization function to regionpass. best regards ether --- include/llvm/Analysis/RegionPass.h | 16 ++++++++++++++-- lib/Analysis/RegionPass.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/llvm/Analysis/RegionPass.h b/include/llvm/Analysis/RegionPass.h index 6c4e226..82f4f76 100644 --- a/include/llvm/Analysis/RegionPass.h +++ b/include/llvm/Analysis/RegionPass.h @@ -61,6 +61,12 @@ public: virtual bool doInitialization(Region *R, RGPassManager &RGM) { return false; } virtual bool doFinalization() { return false; } + + /// @brief Virtual method overridden by subclasses to do any post processing + /// needed after all passes have run. + /// + /// @return True if the pass modifies the module. + virtual bool doFinalization(Module &M) { return false; } //@} //===--------------------------------------------------------------------===// @@ -95,6 +101,12 @@ public: /// @return True if any of the passes modifies the function. bool runOnFunction(Function &F); + /// @brief Execute all of the passes to do any post processing needed after + /// all passes have run. + /// + /// @return True if any of the passes modifies the module. + bool doFinalization(Module &M); + /// Pass Manager itself does not invalidate any analysis info. /// RGPassManager needs RegionInfo. void getAnalysisUsage(AnalysisUsage &Info) const; @@ -110,9 +122,9 @@ public: void dumpPassStructure(unsigned Offset); /// @brief Get passes contained by this manager. - Pass *getContainedPass(unsigned N) { + RegionPass *getContainedPass(unsigned N) { assert(N < PassVector.size() && "Pass number out of range!"); - Pass *FP = static_cast(PassVector[N]); + RegionPass *FP = static_cast(PassVector[N]); return FP; } diff --git a/lib/Analysis/RegionPass.cpp b/lib/Analysis/RegionPass.cpp index 80eda79..9b1c3ab 100644 --- a/lib/Analysis/RegionPass.cpp +++ b/lib/Analysis/RegionPass.cpp @@ -165,6 +165,15 @@ bool RGPassManager::runOnFunction(Function &F) { return Changed; } +bool RGPassManager::doFinalization(Module &M) { + bool Changed = false; + + for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) + Changed |= getContainedPass(Index)->doFinalization(M); + + return Changed; +} + /// Print passes managed by this manager void RGPassManager::dumpPassStructure(unsigned Offset) { errs().indent(Offset*2) << "Region Pass Manager\n"; -- 1.7.4 -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-Allow-RegionPass-to-do-post-processing-after-all-pas.patch Type: application/octet-stream Size: 2691 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110505/254921d5/attachment.obj From nadav.rotem at intel.com Thu May 5 06:32:27 2011 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Thu, 5 May 2011 14:32:27 +0300 Subject: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 Message-ID: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> This patch addresses 9597. --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110505/1695e3c2/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: sra_llvm_trunk.diff Type: application/octet-stream Size: 11610 bytes Desc: sra_llvm_trunk.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110505/1695e3c2/attachment.obj From tobias at grosser.es Thu May 5 06:55:40 2011 From: tobias at grosser.es (Tobias Grosser) Date: Thu, 05 May 2011 13:55:40 +0200 Subject: [llvm-commits] [PATCH 1/2] Minor change: Fix the typo in RegionPass.h and RegionPass.cpp. In-Reply-To: References: Message-ID: <4DC2903C.6080104@grosser.es> On 05/05/2011 10:03 AM, ether zhhb wrote: > hi, > > This patch fix two typo in RegionPass.h and RegionPass.cpp. Nice. Please commit. Tobi From tobias at grosser.es Thu May 5 07:04:54 2011 From: tobias at grosser.es (Tobias Grosser) Date: Thu, 05 May 2011 14:04:54 +0200 Subject: [llvm-commits] [PATCH 2/2] Allow RegionPass to do post processing after all passes have run. In-Reply-To: References: Message-ID: <4DC29266.3090105@grosser.es> On 05/05/2011 10:07 AM, ether zhhb wrote: > hi, > > This patch add a module level finalization function to regionpass. Hi ether, this looks good. For what are you planning to use this? Are you planning to clean up the OpenMP code generation? Cheers Tobi From etherzhhb at gmail.com Thu May 5 08:07:26 2011 From: etherzhhb at gmail.com (ether zhhb) Date: Thu, 5 May 2011 21:07:26 +0800 Subject: [llvm-commits] [PATCH 1/2] Minor change: Fix the typo in RegionPass.h and RegionPass.cpp. In-Reply-To: <4DC2903C.6080104@grosser.es> References: <4DC2903C.6080104@grosser.es> Message-ID: hi tobi, sorry i do not have the commit access, please commit it for me :) best regards ether On Thu, May 5, 2011 at 7:55 PM, Tobias Grosser wrote: > On 05/05/2011 10:03 AM, ether zhhb wrote: >> >> hi, >> >> This patch fix two typo in RegionPass.h and RegionPass.cpp. > > Nice. Please commit. > > Tobi > From etherzhhb at gmail.com Thu May 5 08:16:32 2011 From: etherzhhb at gmail.com (ether zhhb) Date: Thu, 5 May 2011 21:16:32 +0800 Subject: [llvm-commits] [PATCH 2/2] Allow RegionPass to do post processing after all passes have run. In-Reply-To: <4DC29266.3090105@grosser.es> References: <4DC29266.3090105@grosser.es> Message-ID: hi tobi, this provide one possible way to clean up the OpenMP codegen, but not a very straight forward way, i figure out another "just work" approach to decouple OpenMP code generation and ScopDetection slightly. I will list them in polly-dev list later. best regards ether On Thu, May 5, 2011 at 8:04 PM, Tobias Grosser wrote: > On 05/05/2011 10:07 AM, ether zhhb wrote: >> >> hi, >> >> This patch add a module level finalization function to regionpass. > > Hi ether, > > this looks good. > > For what are you planning to use this? Are you planning to clean up the > OpenMP code generation? > > Cheers > Tobi > From tobias at grosser.es Thu May 5 08:23:26 2011 From: tobias at grosser.es (Tobias Grosser) Date: Thu, 05 May 2011 15:23:26 +0200 Subject: [llvm-commits] [PATCH 1/2] Minor change: Fix the typo in RegionPass.h and RegionPass.cpp. In-Reply-To: References: <4DC2903C.6080104@grosser.es> Message-ID: <4DC2A4CE.9050707@grosser.es> On 05/05/2011 03:07 PM, ether zhhb wrote: > hi tobi, > > sorry i do not have the commit access, please commit it for me :) Did you try? I believe your svn account for polly may already work for llvm. Cheers Tobi From nadav.rotem at intel.com Thu May 5 08:47:30 2011 From: nadav.rotem at intel.com (Rotem, Nadav) Date: Thu, 5 May 2011 16:47:30 +0300 Subject: [llvm-commits] [PATCH] Initial work on vector-select and modified type legalization Message-ID: <6594DDFF12B03D4E89690887C2486994027D601FBA@hasmsx504.ger.corp.intel.com> Hi, I started working on implementing vector select in LLVM. Codegen support for vector-select is very important for vectorizing compilers. I followed Duncan's design proposal and implemented vector-integer promotion in the type-legalizer. This required changes all over the codegen. The work is not complete and there are several bugs and missing features, but I am now able to compile the basic vector-select code below. Almost all of the LIT tests pass and a good number of vectorized programs run successfully. This is a big patch and I would like other LLVM developers to go over it and review it. Thanks, Nadav define <4 x float> @vector_code(<4 x i64> %A, <4 x i64> %B, <4 x float> %R0, <4 x float> %R1 ) { %C = icmp eq <4 x i64> %A, %B %K = xor <4 x i1> , %C %D = select <4 x i1> %K, <4 x float> %R1, <4 x float> %R0 ret <4 x float> %D } pcmpeqq XMM1, XMM3 pcmpeqq XMM0, XMM2 shufps XMM0, XMM1, -120 xorps XMM0, XMMWORD PTR [LCPI0_0] pslld XMM0, 31 movdqa XMM1, XMMWORD PTR [ESP + 4] movdqa XMM2, XMMWORD PTR [ESP + 20] blendvps XMM2, XMM1, %xmm0 movdqa XMM0, XMM2 ret --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -------------- next part -------------- A non-text attachment was scrubbed... Name: legalize.diff Type: application/octet-stream Size: 92207 bytes Desc: legalize.diff Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110505/b4df8e94/attachment-0001.obj From etherzhhb at gmail.com Thu May 5 08:59:38 2011 From: etherzhhb at gmail.com (Hongbin Zheng) Date: Thu, 05 May 2011 13:59:38 -0000 Subject: [llvm-commits] [llvm] r130920 - in /llvm/trunk: include/llvm/Analysis/RegionPass.h lib/Analysis/RegionPass.cpp Message-ID: <20110505135938.99D742A6C12C@llvm.org> Author: ether Date: Thu May 5 08:59:38 2011 New Revision: 130920 URL: http://llvm.org/viewvc/llvm-project?rev=130920&view=rev Log: Minor change: Fix the typo in RegionPass.h and RegionPass.cpp. Modified: llvm/trunk/include/llvm/Analysis/RegionPass.h llvm/trunk/lib/Analysis/RegionPass.cpp Modified: llvm/trunk/include/llvm/Analysis/RegionPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionPass.h?rev=130920&r1=130919&r2=130920&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/RegionPass.h (original) +++ llvm/trunk/include/llvm/Analysis/RegionPass.h Thu May 5 08:59:38 2011 @@ -109,7 +109,7 @@ /// @brief Print passes managed by this manager. void dumpPassStructure(unsigned Offset); - /// @brief Print passes contained by this manager. + /// @brief Get passes contained by this manager. Pass *getContainedPass(unsigned N) { assert(N < PassVector.size() && "Pass number out of range!"); Pass *FP = static_cast(PassVector[N]); Modified: llvm/trunk/lib/Analysis/RegionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionPass.cpp?rev=130920&r1=130919&r2=130920&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/RegionPass.cpp (original) +++ llvm/trunk/lib/Analysis/RegionPass.cpp Thu May 5 08:59:38 2011 @@ -249,7 +249,7 @@ assert (!PMS.empty() && "Unable to create Region Pass Manager"); PMDataManager *PMD = PMS.top(); - // [1] Create new Call Graph Pass Manager + // [1] Create new Region Pass Manager RGPM = new RGPassManager(PMD->getDepth() + 1); RGPM->populateInheritedAnalysis(PMS); From eli.friedman at gmail.com Thu May 5 10:24:08 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 5 May 2011 08:24:08 -0700 Subject: [llvm-commits] [PATCH] A patch to add vector SHL/SRL/SRA support for x86 In-Reply-To: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> References: <6594DDFF12B03D4E89690887C2486994027D601E8B@hasmsx504.ger.corp.intel.com> Message-ID: On Thu, May 5, 2011 at 4:32 AM, Rotem, Nadav wrote: > This patch addresses 9597. Your testcase passes without your patch. See PerformShiftCombine in X86ISelLowering.cpp. I woiuldn't be opposed to moving that code to legalization if that works, though. (I think it will because of the separation of vector legalization.) -Eli From aggarwa4 at illinois.edu Thu May 5 10:59:11 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 15:59:11 -0000 Subject: [llvm-commits] [poolalloc] r130923 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110505155911.6831E2A6C12E@llvm.org> Author: aggarwa4 Date: Thu May 5 10:59:11 2011 New Revision: 130923 URL: http://llvm.org/viewvc/llvm-project?rev=130923&view=rev Log: Formatting changes. No functionality changed. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130923&r1=130922&r2=130923&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 5 10:59:11 2011 @@ -150,7 +150,7 @@ // we can find all call sites to it, and also pass in the // original ptr/metadata. // One that sets it just to initialized memory - // so that it can be calle from external code. + // so that it can be called from external code. for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { Function &F = *MI; typedef SmallVector RegisteredArgTy; @@ -205,8 +205,6 @@ CallInst::Create(F, Args.begin(), Args.end(), "", Pt); } } - - } return modified; From eli.friedman at gmail.com Thu May 5 11:18:11 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 05 May 2011 16:18:11 -0000 Subject: [llvm-commits] [llvm] r130925 - /llvm/trunk/lib/CodeGen/MachineCSE.cpp Message-ID: <20110505161812.9E67F2A6C12C@llvm.org> Author: efriedma Date: Thu May 5 11:18:11 2011 New Revision: 130925 URL: http://llvm.org/viewvc/llvm-project?rev=130925&view=rev Log: Minor correction to r130877; fixes PR9846 and hopefully the buildbot failures. Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=130925&r1=130924&r2=130925&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Thu May 5 11:18:11 2011 @@ -468,7 +468,8 @@ SmallVector::iterator PI = DirectPhysRefs.begin(), PE = DirectPhysRefs.end(); for (; PI != PE; ++PI) - MBB->addLiveIn(*PI); + if (!MBB->isLiveIn(*PI)) + MBB->addLiveIn(*PI); } ++NumCSEs; if (!PhysRefs.empty()) From eli.friedman at gmail.com Thu May 5 11:25:23 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 05 May 2011 16:25:23 -0000 Subject: [llvm-commits] [llvm] r130926 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <20110505162523.2F84D2A6C12C@llvm.org> Author: efriedma Date: Thu May 5 11:25:23 2011 New Revision: 130926 URL: http://llvm.org/viewvc/llvm-project?rev=130926&view=rev Log: Small syntax cleanup; we don't need to #define constants in C++. No functionality change intended. 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=130926&r1=130925&r2=130926&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 5 11:25:23 2011 @@ -225,9 +225,10 @@ "vfork", "getcontext" }; -#define NUM_RETURNS_TWICE_FNS sizeof(ReturnsTwiceFns) / sizeof(const char *) + static const size_t NumReturnsTwiceFns = sizeof(ReturnsTwiceFns) / + sizeof(const char *); - for (unsigned I = 0; I < NUM_RETURNS_TWICE_FNS; ++I) + for (unsigned I = 0; I < NumReturnsTwiceFns; ++I) if (const Function *Callee = M->getFunction(ReturnsTwiceFns[I])) { if (!Callee->use_empty()) for (Value::const_use_iterator @@ -239,7 +240,6 @@ } return false; -#undef NUM_RETURNS_TWICE_FNS } /// SplitCriticalSideEffectEdges - Look for critical edges with a PHI value that From dpatel at apple.com Thu May 5 11:31:16 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 May 2011 09:31:16 -0700 Subject: [llvm-commits] [llvm] r130894 - /llvm/trunk/lib/Transforms/Utils/LCSSA.cpp In-Reply-To: <5B056F2B-45B0-44A5-B5E0-7F26BBBDC2A6@apple.com> References: <20110504235822.F2B842A6C12C@llvm.org> <5B056F2B-45B0-44A5-B5E0-7F26BBBDC2A6@apple.com> Message-ID: <27357309-4B90-4742-BDB7-01A6F51BD608@apple.com> On May 4, 2011, at 5:57 PM, Chris Lattner wrote: > > On May 4, 2011, at 4:58 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Wed May 4 18:58:22 2011 >> New Revision: 130894 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130894&view=rev >> Log: >> Set debug location for new PHI nodes created in exit block. > > Devang, > > What does a debug loc even mean for a PHI node? Conceptually a phi node is a copy in each of the predecessors, certainly it can't have a single debug loc? > True, but the copy needs a location. Do you have any thoughts on better alternative? - Devang From stoklund at 2pi.dk Thu May 5 11:48:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 05 May 2011 16:48:01 -0000 Subject: [llvm-commits] [llvm] r130927 - /llvm/trunk/test/FrontendC/2010-05-18-asmsched.c Message-ID: <20110505164801.201992A6C12C@llvm.org> Author: stoklund Date: Thu May 5 11:48:00 2011 New Revision: 130927 URL: http://llvm.org/viewvc/llvm-project?rev=130927&view=rev Log: Fix test to be less sensitive to coalescing. This should unbreak llvm-gcc-i386-linux-selfhost. Modified: llvm/trunk/test/FrontendC/2010-05-18-asmsched.c Modified: llvm/trunk/test/FrontendC/2010-05-18-asmsched.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-05-18-asmsched.c?rev=130927&r1=130926&r2=130927&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2010-05-18-asmsched.c (original) +++ llvm/trunk/test/FrontendC/2010-05-18-asmsched.c Thu May 5 11:48:00 2011 @@ -3,8 +3,9 @@ void foo(int x, int y) { // CHECK: bar -// CHECK: movq %r9, %r10 -// CHECK: movq %rdi, %r9 +// CHECK-NOT: {{, %r9$}} +// CHECK: movq %r9, +// CHECK: movq {{.*}}, %r9 // CHECK: bar register int lr9 asm("r9") = x; register int lr10 asm("r10") = y; From stoklund at 2pi.dk Thu May 5 11:55:39 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 05 May 2011 09:55:39 -0700 Subject: [llvm-commits] [llvm] r130926 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp In-Reply-To: <20110505162523.2F84D2A6C12C@llvm.org> References: <20110505162523.2F84D2A6C12C@llvm.org> Message-ID: <900F9FD1-82E7-4618-83EC-02186BBE658C@2pi.dk> On May 5, 2011, at 9:25 AM, Eli Friedman wrote: > Author: efriedma > Date: Thu May 5 11:25:23 2011 > New Revision: 130926 > > URL: http://llvm.org/viewvc/llvm-project?rev=130926&view=rev > Log: > Small syntax cleanup; we don't need to #define constants in C++. No functionality change intended. > > > 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=130926&r1=130925&r2=130926&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Thu May 5 11:25:23 2011 > @@ -225,9 +225,10 @@ > "vfork", > "getcontext" > }; > -#define NUM_RETURNS_TWICE_FNS sizeof(ReturnsTwiceFns) / sizeof(const char *) > + static const size_t NumReturnsTwiceFns = sizeof(ReturnsTwiceFns) / > + sizeof(const char *); Note that we have array_lengthof() in STLExtras.h. From eli.friedman at gmail.com Thu May 5 11:53:34 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 05 May 2011 16:53:34 -0000 Subject: [llvm-commits] [llvm] r130928 - in /llvm/trunk: lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll test/CodeGen/X86/cmp-redundant.ll Message-ID: <20110505165334.D32B72A6C12C@llvm.org> Author: efriedma Date: Thu May 5 11:53:34 2011 New Revision: 130928 URL: http://llvm.org/viewvc/llvm-project?rev=130928&view=rev Log: Avoid extra vreg copies for arguments passed in registers. Specifically, this can make MachineCSE more effective in some cases (especially in small functions). PR8361 / part of rdar://problem/8259436 . Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=130928&r1=130927&r2=130928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Thu May 5 11:53:34 2011 @@ -54,25 +54,6 @@ return false; } -/// isOnlyUsedInEntryBlock - If the specified argument is only used in the -/// entry block, return true. This includes arguments used by switches, since -/// the switch may expand into multiple basic blocks. -static bool isOnlyUsedInEntryBlock(const Argument *A, bool EnableFastISel) { - // With FastISel active, we may be splitting blocks, so force creation - // of virtual registers for all non-dead arguments. - if (EnableFastISel) - return A->use_empty(); - - const BasicBlock *Entry = A->getParent()->begin(); - for (Value::const_use_iterator UI = A->use_begin(), E = A->use_end(); - UI != E; ++UI) { - const User *U = *UI; - if (cast(U)->getParent() != Entry || isa(U)) - return false; // Use not in entry block. - } - return true; -} - FunctionLoweringInfo::FunctionLoweringInfo(const TargetLowering &tli) : TLI(tli) { } @@ -89,13 +70,6 @@ CanLowerReturn = TLI.CanLowerReturn(Fn->getCallingConv(), Fn->isVarArg(), Outs, Fn->getContext()); - // Create a vreg for each argument register that is not dead and is used - // outside of the entry block for the function. - for (Function::const_arg_iterator AI = Fn->arg_begin(), E = Fn->arg_end(); - AI != E; ++AI) - if (!isOnlyUsedInEntryBlock(AI, EnableFastISel)) - InitializeRegForValue(AI); - // Initialize the mapping of values to registers. This is only set up for // instruction values that are used outside of the block that defines // them. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=130928&r1=130927&r2=130928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Thu May 5 11:53:34 2011 @@ -6232,6 +6232,25 @@ #include "llvm/CodeGen/SelectionDAGISel.h" +/// isOnlyUsedInEntryBlock - If the specified argument is only used in the +/// entry block, return true. This includes arguments used by switches, since +/// the switch may expand into multiple basic blocks. +static bool isOnlyUsedInEntryBlock(const Argument *A) { + // With FastISel active, we may be splitting blocks, so force creation + // of virtual registers for all non-dead arguments. + if (EnableFastISel) + return A->use_empty(); + + const BasicBlock *Entry = A->getParent()->begin(); + for (Value::const_use_iterator UI = A->use_begin(), E = A->use_end(); + UI != E; ++UI) { + const User *U = *UI; + if (cast(U)->getParent() != Entry || isa(U)) + return false; // Use not in entry block. + } + return true; +} + void SelectionDAGISel::LowerArguments(const BasicBlock *LLVMBB) { // If this is the entry block, emit arguments. const Function &F = *LLVMBB->getParent(); @@ -6375,8 +6394,8 @@ if (I->use_empty() && NumValues) SDB->setUnusedArgValue(I, InVals[i]); - for (unsigned Value = 0; Value != NumValues; ++Value) { - EVT VT = ValueVTs[Value]; + for (unsigned Val = 0; Val != NumValues; ++Val) { + EVT VT = ValueVTs[Val]; EVT PartVT = TLI.getRegisterType(*CurDAG->getContext(), VT); unsigned NumParts = TLI.getNumRegisters(*CurDAG->getContext(), VT); @@ -6395,21 +6414,34 @@ i += NumParts; } + // We don't need to do anything else for unused arguments. + if (ArgValues.empty()) + continue; + // Note down frame index for byval arguments. - if (I->hasByValAttr() && !ArgValues.empty()) + if (I->hasByValAttr()) if (FrameIndexSDNode *FI = dyn_cast(ArgValues[0].getNode())) FuncInfo->setByValArgumentFrameIndex(I, FI->getIndex()); - if (!I->use_empty()) { - SDValue Res; - if (!ArgValues.empty()) - Res = DAG.getMergeValues(&ArgValues[0], NumValues, - SDB->getCurDebugLoc()); - SDB->setValue(I, Res); - - // If this argument is live outside of the entry block, insert a copy from - // wherever we got it to the vreg that other BB's will reference it as. + SDValue Res = DAG.getMergeValues(&ArgValues[0], NumValues, + SDB->getCurDebugLoc()); + SDB->setValue(I, Res); + + // If this argument is live outside of the entry block, insert a copy from + // wherever we got it to the vreg that other BB's will reference it as. + if (Res.getOpcode() == ISD::CopyFromReg) { + // If we can, though, try to skip creating an unnecessary vreg. + // FIXME: This isn't very clean... it would be nice to make this more + // general. + unsigned Reg = cast(Res.getOperand(1))->getReg(); + if (TargetRegisterInfo::isVirtualRegister(Reg)) { + FuncInfo->ValueMap[I] = Reg; + continue; + } + } + if (!isOnlyUsedInEntryBlock(I)) { + FuncInfo->InitializeRegForValue(I); SDB->CopyToExportRegsIfNeeded(I); } } Modified: llvm/trunk/test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll?rev=130928&r1=130927&r2=130928&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-06-25-CoalescerSubRegDefDead.ll Thu May 5 11:53:34 2011 @@ -22,7 +22,7 @@ ; it is. ; ; CHECK: # %bb -; CHECK: addq $64036, %rdi +; CHECK: leaq 64036(%rdx), %rdi ; CHECK: rep;stosl %tmp5 = bitcast i32* %tmp4 to i8* Modified: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp-redundant.ll?rev=130928&r1=130927&r2=130928&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (original) +++ llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Thu May 5 11:53:34 2011 @@ -9,6 +9,27 @@ ; CHECK: cmp: ; CHECK: cmpl ; CHECK: jg + +if.end: ; preds = %entry +; CHECK-NOT: cmpl +; CHECK: cmov + %cmp4 = icmp slt i32 %a, %b + %. = select i1 %cmp4, i32 2, i32 111 + br label %return + +return: ; preds = %if.end, %entry + %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] + ret i32 %retval.0 +} + +define i32 @cmp2(i32 %a, i32 %b) nounwind readnone ssp { +entry: + %cmp = icmp sgt i32 %a, %b + br i1 %cmp, label %return, label %if.end +; CHECK: cmp2: +; CHECK: cmpl +; CHECK: jg + if.end: ; preds = %entry ; CHECK-NOT: cmpl ; CHECK: cmov From stoklund at 2pi.dk Thu May 5 12:22:53 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 05 May 2011 17:22:53 -0000 Subject: [llvm-commits] [llvm] r130931 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp LiveRangeEdit.cpp SplitKit.cpp Message-ID: <20110505172254.088FD2A6C12C@llvm.org> Author: stoklund Date: Thu May 5 12:22:53 2011 New Revision: 130931 URL: http://llvm.org/viewvc/llvm-project?rev=130931&view=rev Log: Add some statistics to the splitting and spilling frameworks. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=130931&r1=130930&r2=130931&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Thu May 5 12:22:53 2011 @@ -16,6 +16,7 @@ #include "Spiller.h" #include "LiveRangeEdit.h" #include "VirtRegMap.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/LiveStackAnalysis.h" @@ -31,6 +32,18 @@ using namespace llvm; +STATISTIC(NumSpilledRanges, "Number of spilled live ranges"); +STATISTIC(NumSnippets, "Number of snippets included in spills"); +STATISTIC(NumSpills, "Number of spills inserted"); +STATISTIC(NumReloads, "Number of reloads inserted"); +STATISTIC(NumFolded, "Number of folded stack accesses"); +STATISTIC(NumFoldedLoads, "Number of folded loads"); +STATISTIC(NumRemats, "Number of rematerialized defs for spilling"); +STATISTIC(NumOmitReloadSpill, "Number of omitted spills after reloads"); +STATISTIC(NumHoistLocal, "Number of locally hoisted spills"); +STATISTIC(NumHoistGlobal, "Number of globally hoisted spills"); +STATISTIC(NumRedundantSpills, "Number of redundant spills identified"); + namespace { class InlineSpiller : public Spiller { MachineFunctionPass &Pass; @@ -247,10 +260,11 @@ if (!isSnippet(SnipLI)) continue; SnippetCopies.insert(MI); - if (!isRegToSpill(SnipReg)) - RegsToSpill.push_back(SnipReg); - + if (isRegToSpill(SnipReg)) + continue; + RegsToSpill.push_back(SnipReg); DEBUG(dbgs() << "\talso spill snippet " << SnipLI << '\n'); + ++NumSnippets; } } @@ -469,9 +483,10 @@ << *StackInt << '\n'); // Already spilled everywhere. - if (SVI.AllDefsAreReloads) + if (SVI.AllDefsAreReloads) { + ++NumOmitReloadSpill; return true; - + } // We are going to spill SVI.SpillVNI immediately after its def, so clear out // any later spills of the same value. eliminateRedundantSpills(SibLI, SVI.SpillVNI); @@ -493,6 +508,11 @@ LIS.InsertMachineInstrInMaps(MII); VRM.addSpillSlotUse(StackSlot, MII); DEBUG(dbgs() << "\thoisted: " << SVI.SpillVNI->def << '\t' << *MII); + + if (MBB == CopyMI->getParent()) + ++NumHoistLocal; + else + ++NumHoistGlobal; return true; } @@ -547,6 +567,7 @@ // eliminateDeadDefs won't normally remove stores, so switch opcode. MI->setDesc(TII.get(TargetOpcode::KILL)); DeadDefs.push_back(MI); + ++NumRedundantSpills; } } } while (!WorkList.empty()); @@ -642,6 +663,7 @@ if (RM.OrigMI->getDesc().canFoldAsLoad() && foldMemoryOperand(MI, Ops, RM.OrigMI)) { Edit->markRematerialized(RM.ParentVNI); + ++NumFoldedLoads; return true; } @@ -668,6 +690,7 @@ VNInfo *DefVNI = NewLI.getNextValue(DefIdx, 0, LIS.getVNInfoAllocator()); NewLI.addRange(LiveRange(DefIdx, UseIdx.getDefIndex(), DefVNI)); DEBUG(dbgs() << "\tinterval: " << NewLI << '\n'); + ++NumRemats; return true; } @@ -794,6 +817,7 @@ VRM.addSpillSlotUse(StackSlot, FoldMI); MI->eraseFromParent(); DEBUG(dbgs() << "\tfolded: " << *FoldMI); + ++NumFolded; return true; } @@ -811,6 +835,7 @@ VNInfo *LoadVNI = NewLI.getNextValue(LoadIdx, 0, LIS.getVNInfoAllocator()); NewLI.addRange(LiveRange(LoadIdx, Idx, LoadVNI)); + ++NumReloads; } /// insertSpill - Insert a spill of NewLI.reg after MI. @@ -825,6 +850,7 @@ DEBUG(dbgs() << "\tspilled: " << StoreIdx << '\t' << *MI); VNInfo *StoreVNI = NewLI.getNextValue(Idx, 0, LIS.getVNInfoAllocator()); NewLI.addRange(LiveRange(Idx, StoreIdx, StoreVNI)); + ++NumSpills; } /// spillAroundUses - insert spill code around each use of Reg. @@ -972,6 +998,7 @@ } void InlineSpiller::spill(LiveRangeEdit &edit) { + ++NumSpilledRanges; Edit = &edit; assert(!TargetRegisterInfo::isStackSlot(edit.getReg()) && "Trying to spill a stack slot."); Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=130931&r1=130930&r2=130931&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Thu May 5 12:22:53 2011 @@ -15,6 +15,7 @@ #include "LiveRangeEdit.h" #include "VirtRegMap.h" #include "llvm/ADT/SetVector.h" +#include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/CalcSpillWeights.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/MachineRegisterInfo.h" @@ -24,6 +25,10 @@ using namespace llvm; +STATISTIC(NumDCEDeleted, "Number of instructions deleted by DCE"); +STATISTIC(NumDCEFoldedLoads, "Number of single use loads folded after DCE"); +STATISTIC(NumFracRanges, "Number of live ranges fractured by DCE"); + LiveInterval &LiveRangeEdit::createFrom(unsigned OldReg, LiveIntervals &LIS, VirtRegMap &VRM) { @@ -199,6 +204,7 @@ UseMI->eraseFromParent(); DefMI->addRegisterDead(LI->reg, 0); Dead.push_back(DefMI); + ++NumDCEFoldedLoads; return true; } @@ -269,6 +275,7 @@ delegate_->LRE_WillEraseInstruction(MI); LIS.RemoveMachineInstrFromMaps(MI); MI->eraseFromParent(); + ++NumDCEDeleted; } if (ToShrink.empty()) @@ -290,6 +297,7 @@ unsigned NumComp = ConEQ.Classify(LI); if (NumComp <= 1) continue; + ++NumFracRanges; DEBUG(dbgs() << NumComp << " components: " << *LI << '\n'); SmallVector Dups(1, LI); for (unsigned i = 1; i != NumComp; ++i) { Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=130931&r1=130930&r2=130931&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu May 5 12:22:53 2011 @@ -30,6 +30,8 @@ STATISTIC(NumFinished, "Number of splits finished"); STATISTIC(NumSimple, "Number of splits that were simple"); +STATISTIC(NumCopies, "Number of copies inserted for splitting"); +STATISTIC(NumRemats, "Number of rematerialized defs for splitting"); //===----------------------------------------------------------------------===// // Split Analysis @@ -589,12 +591,14 @@ LiveRangeEdit::Remat RM(ParentVNI); if (Edit->canRematerializeAt(RM, UseIdx, true, LIS)) { Def = Edit->rematerializeAt(MBB, I, LI->reg, RM, LIS, TII, TRI, Late); + ++NumRemats; } else { // Can't remat, just insert a copy from parent. CopyMI = BuildMI(MBB, I, DebugLoc(), TII.get(TargetOpcode::COPY), LI->reg) .addReg(Edit->getReg()); Def = LIS.getSlotIndexes()->insertMachineInstrInMaps(CopyMI, Late) .getDefIndex(); + ++NumCopies; } // Define the value in Reg. From eli.friedman at gmail.com Thu May 5 12:45:31 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 05 May 2011 17:45:31 -0000 Subject: [llvm-commits] [llvm] r130932 - /llvm/trunk/lib/Target/X86/X86InstrMMX.td Message-ID: <20110505174531.7FFD02A6C12C@llvm.org> Author: efriedma Date: Thu May 5 12:45:31 2011 New Revision: 130932 URL: http://llvm.org/viewvc/llvm-project?rev=130932&view=rev Log: PR9848: pandn is not commutative. No test because I can't think of any way to write one that won't break quickly. Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td Modified: llvm/trunk/lib/Target/X86/X86InstrMMX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrMMX.td?rev=130932&r1=130931&r2=130932&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrMMX.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrMMX.td Thu May 5 12:45:31 2011 @@ -285,7 +285,7 @@ defm MMX_PAND : MMXI_binop_rm_int<0xDB, "pand", int_x86_mmx_pand, 1>; defm MMX_POR : MMXI_binop_rm_int<0xEB, "por" , int_x86_mmx_por, 1>; defm MMX_PXOR : MMXI_binop_rm_int<0xEF, "pxor", int_x86_mmx_pxor, 1>; -defm MMX_PANDN : MMXI_binop_rm_int<0xDF, "pandn", int_x86_mmx_pandn, 1>; +defm MMX_PANDN : MMXI_binop_rm_int<0xDF, "pandn", int_x86_mmx_pandn>; // Shift Instructions defm MMX_PSRLW : MMXI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", From dpatel at apple.com Thu May 5 12:54:26 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 May 2011 17:54:26 -0000 Subject: [llvm-commits] [llvm] r130933 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110505175426.3BC972A6C12C@llvm.org> Author: dpatel Date: Thu May 5 12:54:26 2011 New Revision: 130933 URL: http://llvm.org/viewvc/llvm-project?rev=130933&view=rev Log: If debug info for inlined function is missing then handle it gracefully. 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=130933&r1=130932&r2=130933&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu May 5 12:54:26 2011 @@ -588,12 +588,14 @@ if (!Scope->getScopeNode()) return NULL; DIScope DS(Scope->getScopeNode()); - DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); - DISubprogram InlinedSP = getDISubprogram(DS); CompileUnit *TheCU = getCompileUnit(InlinedSP); DIE *OriginDIE = TheCU->getDIE(InlinedSP); - assert(OriginDIE && "Unable to find Origin DIE!"); + if (!OriginDIE) { + DEBUG(dbgs() << "Unable to find original DIE for inlined subprogram."); + return NULL; + } + DIE *ScopeDIE = new DIE(dwarf::DW_TAG_inlined_subroutine); TheCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, dwarf::DW_FORM_ref4, OriginDIE); From resistor at mac.com Thu May 5 12:59:04 2011 From: resistor at mac.com (Owen Anderson) Date: Thu, 05 May 2011 17:59:04 -0000 Subject: [llvm-commits] [llvm] r130934 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp Message-ID: <20110505175904.5B4D42A6C12C@llvm.org> Author: resistor Date: Thu May 5 12:59:04 2011 New Revision: 130934 URL: http://llvm.org/viewvc/llvm-project?rev=130934&view=rev Log: Allow FastISel of three-register-operand instructions. Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=130934&r1=130933&r2=130934&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Thu May 5 12:59:04 2011 @@ -241,6 +241,15 @@ unsigned Op0, bool Op0IsKill, unsigned Op1, bool Op1IsKill); + /// FastEmitInst_rrr - Emit a MachineInstr with three register operands + /// and a result register in the given register class. + /// + unsigned FastEmitInst_rrr(unsigned MachineInstOpcode, + const TargetRegisterClass *RC, + unsigned Op0, bool Op0IsKill, + unsigned Op1, bool Op1IsKill, + unsigned Op2, bool Op2IsKill); + /// FastEmitInst_ri - Emit a MachineInstr with a register operand, /// an immediate, and a result register in the given register class. /// Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130934&r1=130933&r2=130934&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Thu May 5 12:59:04 2011 @@ -1097,6 +1097,30 @@ return ResultReg; } +unsigned FastISel::FastEmitInst_rrr(unsigned MachineInstOpcode, + const TargetRegisterClass *RC, + unsigned Op0, bool Op0IsKill, + unsigned Op1, bool Op1IsKill, + unsigned Op2, bool Op2IsKill) { + unsigned ResultReg = createResultReg(RC); + const TargetInstrDesc &II = TII.get(MachineInstOpcode); + + if (II.getNumDefs() >= 1) + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) + .addReg(Op0, Op0IsKill * RegState::Kill) + .addReg(Op1, Op1IsKill * RegState::Kill) + .addReg(Op2, Op2IsKill * RegState::Kill); + else { + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) + .addReg(Op0, Op0IsKill * RegState::Kill) + .addReg(Op1, Op1IsKill * RegState::Kill) + .addReg(Op2, Op2IsKill * RegState::Kill); + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), + ResultReg).addReg(II.ImplicitDefs[0]); + } + return ResultReg; +} + unsigned FastISel::FastEmitInst_ri(unsigned MachineInstOpcode, const TargetRegisterClass *RC, unsigned Op0, bool Op0IsKill, From gkistanova at gmail.com Thu May 5 13:40:27 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Thu, 05 May 2011 18:40:27 -0000 Subject: [llvm-commits] [llvm] r130936 - /llvm/trunk/test/Archive/check_binary_output.ll Message-ID: <20110505184027.A6DFE2A6C12C@llvm.org> Author: gkistanova Date: Thu May 5 13:40:27 2011 New Revision: 130936 URL: http://llvm.org/viewvc/llvm-project?rev=130936&view=rev Log: Many LLVM tests relies on standard output stream be in the binary mode. Which is not always the case (on Windows in particular). The patch adds a test to verify that the standard output stream is actually in the binary mode. Added: llvm/trunk/test/Archive/check_binary_output.ll Added: llvm/trunk/test/Archive/check_binary_output.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Archive/check_binary_output.ll?rev=130936&view=auto ============================================================================== --- llvm/trunk/test/Archive/check_binary_output.ll (added) +++ llvm/trunk/test/Archive/check_binary_output.ll Thu May 5 13:40:27 2011 @@ -0,0 +1,4 @@ +; This is not an assembly file, this is just to run the test. +; The test verifies that llvm-ar produces a binary output. + +;RUN: llvm-ar p %p/GNU.a very_long_bytecode_file_name.bc | cmp -s %p/very_long_bytecode_file_name.bc - From rafael.espindola at gmail.com Thu May 5 13:43:39 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 18:43:39 -0000 Subject: [llvm-commits] [llvm] r130937 - in /llvm/trunk: lib/MC/MCAsmInfo.cpp test/CodeGen/X86/empty-functions.ll Message-ID: <20110505184339.EB0382A6C12C@llvm.org> Author: rafael Date: Thu May 5 13:43:39 2011 New Revision: 130937 URL: http://llvm.org/viewvc/llvm-project?rev=130937&view=rev Log: Don't produce a __debug_frame. I tested both gdb on a bootstrapped clang and and the gdb testsuite on OS X (snow leopard) and both are happy using __eh_frame. Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/test/CodeGen/X86/empty-functions.ll Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130937&r1=130936&r2=130937&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Thu May 5 13:43:39 2011 @@ -74,7 +74,7 @@ HasLEB128 = false; SupportsDebugInformation = false; ExceptionsType = ExceptionHandling::None; - DwarfRequiresFrameSection = true; + DwarfRequiresFrameSection = false; DwarfUsesInlineInfoSection = false; DwarfRequiresRelocationForStmtList = true; DwarfSectionOffsetDirective = 0; Modified: llvm/trunk/test/CodeGen/X86/empty-functions.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/empty-functions.ll?rev=130937&r1=130936&r2=130937&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/empty-functions.ll (original) +++ llvm/trunk/test/CodeGen/X86/empty-functions.ll Thu May 5 13:43:39 2011 @@ -6,10 +6,24 @@ unreachable } ; CHECK-NO-FP: _func: -; CHECK-NO-FP-NOT: movq %rsp, %rbp +; CHECK-NO-FP-NEXT: : +; CHECK-NO-FP-NEXT: .cfi_startproc ; CHECK-NO-FP: nop +; CHECK-NO-FP-NEXT: : +; CHECK-NO-FP-NEXT: .cfi_endproc ; CHECK-FP: _func: -; CHECK-FP: movq %rsp, %rbp -; CHECK-FP-NEXT: Ltmp1: -; CHECK-FP: nop +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: .cfi_startproc +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: pushq %rbp +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: .cfi_def_cfa_offset 16 +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: .cfi_offset 6, -16 +; CHECK-FP-NEXT: movq %rsp, %rbp +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: .cfi_def_cfa_register 6 +; CHECK-FP-NEXT: nop +; CHECK-FP-NEXT: : +; CHECK-FP-NEXT: .cfi_endproc From gkistanova at gmail.com Thu May 5 13:50:20 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Thu, 5 May 2011 11:50:20 -0700 Subject: [llvm-commits] Check output stream opened in binary mode instead of text mode on MinGW In-Reply-To: <6AE1604EE3EC5F4296C096518C6B77EE17E4EAF874@mail.accesssoftek.com> References: <6AE1604EE3EC5F4296C096518C6B77EE17E4EAF874@mail.accesssoftek.com> Message-ID: Hi Danil, Your patch commited. Revision: 130936. Thanks Galina On Wed, May 4, 2011 at 1:05 PM, Danil Malyshev wrote: > Hello everyone, > > > > Many LLVM tests relies on standard output stream be in the binary mode. > > Which is not always the case (on Windows in particular). > > > > The proposed patch adds a test to verify that the standard output stream is > actually in the binary mode. > > This will save us a lot of troubleshooting time. > > > > Please review. > > > > > > Thank you, > > Danil > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From atrick at apple.com Thu May 5 14:24:06 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 05 May 2011 19:24:06 -0000 Subject: [llvm-commits] [llvm] r130942 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <20110505192406.A73372A6C12C@llvm.org> Author: atrick Date: Thu May 5 14:24:06 2011 New Revision: 130942 URL: http://llvm.org/viewvc/llvm-project?rev=130942&view=rev Log: whitespace Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=130942&r1=130941&r2=130942&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Thu May 5 14:24:06 2011 @@ -120,7 +120,7 @@ // such aliases. if (PSV->isAliased(MFI)) return 0; - + MayAlias = PSV->mayAlias(MFI); return V; } @@ -174,7 +174,7 @@ for (MachineBasicBlock::succ_iterator SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) for (MachineBasicBlock::livein_iterator I = (*SI)->livein_begin(), - E = (*SI)->livein_end(); I != E; ++I) { + E = (*SI)->livein_end(); I != E; ++I) { unsigned Reg = *I; if (Seen.insert(Reg)) Uses[Reg].push_back(&ExitSU); @@ -411,11 +411,11 @@ #define STORE_LOAD_LATENCY 1 unsigned TrueMemOrderLatency = 0; if (TID.isCall() || MI->hasUnmodeledSideEffects() || - (MI->hasVolatileMemoryRef() && + (MI->hasVolatileMemoryRef() && (!TID.mayLoad() || !MI->isInvariantLoad(AA)))) { // Be conservative with these and add dependencies on all memory // references, even those that are known to not alias. - for (std::map::iterator I = + for (std::map::iterator I = NonAliasMemDefs.begin(), E = NonAliasMemDefs.end(); I != E; ++I) { I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); } @@ -458,9 +458,9 @@ // A store to a specific PseudoSourceValue. Add precise dependencies. // Record the def in MemDefs, first adding a dep if there is // an existing def. - std::map::iterator I = + std::map::iterator I = ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V)); - std::map::iterator IE = + std::map::iterator IE = ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end()); if (I != IE) { I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, @@ -513,37 +513,37 @@ if (MI->isInvariantLoad(AA)) { // Invariant load, no chain dependencies needed! } else { - if (const Value *V = + if (const Value *V = getUnderlyingObjectForInstr(MI, MFI, MayAlias)) { // A load from a specific PseudoSourceValue. Add precise dependencies. - std::map::iterator I = + std::map::iterator I = ((MayAlias) ? AliasMemDefs.find(V) : NonAliasMemDefs.find(V)); - std::map::iterator IE = + std::map::iterator IE = ((MayAlias) ? AliasMemDefs.end() : NonAliasMemDefs.end()); if (I != IE) I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0, /*Reg=*/0, /*isNormalMemory=*/true)); if (MayAlias) AliasMemUses[V].push_back(SU); - else + else NonAliasMemUses[V].push_back(SU); } else { // A load with no underlying object. Depend on all // potentially aliasing stores. - for (std::map::iterator I = + for (std::map::iterator I = AliasMemDefs.begin(), E = AliasMemDefs.end(); I != E; ++I) I->second->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - + PendingLoads.push_back(SU); MayAlias = true; } - + // Add dependencies on alias and barrier chains, if needed. if (MayAlias && AliasChain) AliasChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); if (BarrierChain) BarrierChain->addPred(SDep(SU, SDep::Order, /*Latency=*/0)); - } + } } } @@ -572,11 +572,11 @@ } } -void ScheduleDAGInstrs::ComputeOperandLatency(SUnit *Def, SUnit *Use, +void ScheduleDAGInstrs::ComputeOperandLatency(SUnit *Def, SUnit *Use, SDep& dep) const { if (!InstrItins || InstrItins->isEmpty()) return; - + // For a data dependency with a known register... if ((dep.getKind() != SDep::Data) || (dep.getReg() == 0)) return; From atrick at apple.com Thu May 5 14:32:21 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 05 May 2011 19:32:21 -0000 Subject: [llvm-commits] [llvm] r130943 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Message-ID: <20110505193221.B847D2A6C12C@llvm.org> Author: atrick Date: Thu May 5 14:32:21 2011 New Revision: 130943 URL: http://llvm.org/viewvc/llvm-project?rev=130943&view=rev Log: ARM post RA scheduler compile time fix. BuildSchedGraph was quadratic in the number of calls in the basic block. After this fix, it keeps only a single call at the top of the DefList so compile time doesn't blow up on large blocks. This reduces postRA sched time on an external test case from 81s to 0.3s. Although r130800 (reduced ARM register alias defs) also partially fixes the issue by reducing the constant overhead of checking call interference by an order of magnitude. Fixes very poor compile time with post RA scheduling. Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=130943&r1=130942&r2=130943&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Thu May 5 14:32:21 2011 @@ -393,6 +393,18 @@ UseList.clear(); if (!MO.isDead()) DefList.clear(); + + // Calls will not be reordered because of chain dependencies (see + // below). Since call operands are dead, calls may continue to be added + // to the DefList making dependence checking quadratic in the size of + // the block. Instead, we leave only one call at the back of the + // DefList. + // + // NOTE: This assumes that the DefList is ordered! + if (SU->isCall) { + while (!DefList.empty() && DefList.back()->isCall) + DefList.pop_back(); + } DefList.push_back(SU); } else { UseList.push_back(SU); From rafael.espindola at gmail.com Thu May 5 14:48:34 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 19:48:34 -0000 Subject: [llvm-commits] [llvm] r130944 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <20110505194834.547A92A6C12C@llvm.org> Author: rafael Date: Thu May 5 14:48:34 2011 New Revision: 130944 URL: http://llvm.org/viewvc/llvm-project?rev=130944&view=rev Log: List all exception types in a switch. 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=130944&r1=130943&r2=130944&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu May 5 14:48:34 2011 @@ -189,21 +189,22 @@ if (MAI->doesSupportDebugInformation()) DD = new DwarfDebug(this, &M); - if (MAI->doesSupportExceptionHandling()) - switch (MAI->getExceptionHandlingType()) { - default: - case ExceptionHandling::DwarfTable: - DE = new DwarfTableException(this); - break; - case ExceptionHandling::DwarfCFI: - DE = new DwarfCFIException(this); - break; - case ExceptionHandling::ARM: - DE = new ARMException(this); - break; - } + switch (MAI->getExceptionHandlingType()) { + case ExceptionHandling::None: + return false; + case ExceptionHandling::SjLj: + case ExceptionHandling::DwarfTable: + DE = new DwarfTableException(this); + return false; + case ExceptionHandling::DwarfCFI: + DE = new DwarfCFIException(this); + return false; + case ExceptionHandling::ARM: + DE = new ARMException(this); + return false; + } - return false; + llvm_unreachable("Unknown exception type."); } void AsmPrinter::EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const { From gkistanova at gmail.com Thu May 5 14:58:15 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Thu, 5 May 2011 12:58:15 -0700 Subject: [llvm-commits] [llvm] r130877 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll In-Reply-To: References: <20110504221037.2B8C92A6C12C@llvm.org> Message-ID: I will look at this. Thanks Galina On Wed, May 4, 2011 at 5:35 PM, Eli Friedman wrote: > On Wed, May 4, 2011 at 3:10 PM, Eli Friedman wrote: >> Author: efriedma >> Date: Wed May ?4 17:10:36 2011 >> New Revision: 130877 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130877&view=rev >> Log: >> Re-commit r130862 with a minor change to avoid an iterator running off the edge in some cases. >> >> Original message: >> >> Teach MachineCSE how to do simple cross-block CSE involving physregs. ?This allows, for example, eliminating duplicate cmpl's on x86. Part of rdar://problem/8259436 . >> >> > > This is breaking a few of the buildbots with the following assertion: > > lib/CodeGen/LiveInterval.cpp:267: llvm::LiveRange* > llvm::LiveInterval::addRangeFrom(llvm::LiveRange, llvm::LiveRange*): > Assertion `B->end <= Start && "Cannot overlap two LiveRanges with > differing ValID's" " (did you def the same reg twice in a > MachineInstr?)"' failed. > > I'm not sure how to go about reproducing this, so it would be very > much appreciated if someone could send me a bitcode file where this > reproduces. > > Thanks, > Eli > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From eli.friedman at gmail.com Thu May 5 15:33:12 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 5 May 2011 13:33:12 -0700 Subject: [llvm-commits] [llvm] r130877 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll In-Reply-To: References: <20110504221037.2B8C92A6C12C@llvm.org> Message-ID: On Thu, May 5, 2011 at 12:58 PM, Galina Kistanova wrote: > I will look at this. Fortunately, I managed to get a testcase through other means; hopefully this is working with r130925. -Eli > On Wed, May 4, 2011 at 5:35 PM, Eli Friedman wrote: >> On Wed, May 4, 2011 at 3:10 PM, Eli Friedman wrote: >>> Author: efriedma >>> Date: Wed May ?4 17:10:36 2011 >>> New Revision: 130877 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=130877&view=rev >>> Log: >>> Re-commit r130862 with a minor change to avoid an iterator running off the edge in some cases. >>> >>> Original message: >>> >>> Teach MachineCSE how to do simple cross-block CSE involving physregs. ?This allows, for example, eliminating duplicate cmpl's on x86. Part of rdar://problem/8259436 . >>> >>> >> >> This is breaking a few of the buildbots with the following assertion: >> >> lib/CodeGen/LiveInterval.cpp:267: llvm::LiveRange* >> llvm::LiveInterval::addRangeFrom(llvm::LiveRange, llvm::LiveRange*): >> Assertion `B->end <= Start && "Cannot overlap two LiveRanges with >> differing ValID's" " (did you def the same reg twice in a >> MachineInstr?)"' failed. >> >> I'm not sure how to go about reproducing this, so it would be very >> much appreciated if someone could send me a bitcode file where this >> reproduces. >> >> Thanks, >> Eli >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From rafael.espindola at gmail.com Thu May 5 15:48:31 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 20:48:31 -0000 Subject: [llvm-commits] [llvm] r130947 - in /llvm/trunk/lib/CodeGen/AsmPrinter: AsmPrinter.cpp CMakeLists.txt DwarfException.h DwarfSjLjException.cpp Message-ID: <20110505204831.62E592A6C12C@llvm.org> Author: rafael Date: Thu May 5 15:48:31 2011 New Revision: 130947 URL: http://llvm.org/viewvc/llvm-project?rev=130947&view=rev Log: Implement a really simple DwarfSjLjException. Added: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130947&r1=130946&r2=130947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu May 5 15:48:31 2011 @@ -193,6 +193,8 @@ case ExceptionHandling::None: return false; case ExceptionHandling::SjLj: + DE = new DwarfSjLjException(this); + return false; case ExceptionHandling::DwarfTable: DE = new DwarfTableException(this); return false; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=130947&r1=130946&r2=130947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Thu May 5 15:48:31 2011 @@ -8,6 +8,7 @@ DwarfCompileUnit.cpp DwarfDebug.cpp DwarfException.cpp + DwarfSjLjException.cpp DwarfTableException.cpp OcamlGCPrinter.cpp ) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=130947&r1=130946&r2=130947&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Thu May 5 15:48:31 2011 @@ -238,6 +238,25 @@ virtual void EndFunction(); }; +class DwarfSjLjException : public DwarfException { +public: + //===--------------------------------------------------------------------===// + // Main entry points. + // + DwarfSjLjException(AsmPrinter *A); + virtual ~DwarfSjLjException(); + + /// EndModule - Emit all exception information that should come after the + /// content. + virtual void EndModule(); + + /// BeginFunction - Gather pre-function exception information. Assumes being + /// emitted immediately after the function entry point. + virtual void BeginFunction(const MachineFunction *MF); + + /// EndFunction - Gather and emit post-function exception information. + virtual void EndFunction(); +}; class ARMException : public DwarfException { /// shouldEmitTable - Per-function flag to indicate if EH tables should Added: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp?rev=130947&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp (added) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp Thu May 5 15:48:31 2011 @@ -0,0 +1,46 @@ +//===-- CodeGen/AsmPrinter/DwarfTableException.cpp - Dwarf Exception Impl --==// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a simple implementation of DwarfException that just produces +// the exception table for use with SjLj. +// +//===----------------------------------------------------------------------===// + +#include "DwarfException.h" +#include "llvm/CodeGen/MachineLocation.h" +#include "llvm/CodeGen/MachineModuleInfo.h" +using namespace llvm; + +DwarfSjLjException::DwarfSjLjException(AsmPrinter *A) : DwarfException(A) { +} + +DwarfSjLjException::~DwarfSjLjException() {} + +/// EndModule - Emit all exception information that should come after the +/// content. +void DwarfSjLjException::EndModule() { +} + +/// BeginFunction - Gather pre-function exception information. Assumes it's +/// being emitted immediately after the function entry point. +void DwarfSjLjException::BeginFunction(const MachineFunction *MF) { +} + +/// EndFunction - Gather and emit post-function exception information. +/// +void DwarfSjLjException::EndFunction() { + // Record if this personality index uses a landing pad. + bool HasLandingPad = !MMI->getLandingPads().empty(); + + // Map all labels and get rid of any dead landing pads. + MMI->TidyLandingPads(); + + if (HasLandingPad) + EmitExceptionTable(); +} From nicholas at mxc.ca Thu May 5 16:27:15 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 05 May 2011 21:27:15 -0000 Subject: [llvm-commits] [llvm] r130949 - /llvm/trunk/include/llvm/Support/StandardPasses.h Message-ID: <20110505212715.257E42A6C12C@llvm.org> Author: nicholas Date: Thu May 5 16:27:14 2011 New Revision: 130949 URL: http://llvm.org/viewvc/llvm-project?rev=130949&view=rev Log: Fix typo. No functional change. Modified: llvm/trunk/include/llvm/Support/StandardPasses.h Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=130949&r1=130948&r2=130949&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Thu May 5 16:27:14 2011 @@ -61,7 +61,7 @@ /// \arg SimplifyLibCalls - Allow library calls to be simplified. /// \arg HaveExceptions - Whether the module may have code using exceptions. /// \arg InliningPass - The inlining pass to use, if any, or null. This will - /// always be added, even at -O0.a + /// always be added, even at -O0. static inline void createStandardModulePasses(PassManagerBase *PM, unsigned OptimizationLevel, bool OptimizeSize, From isanbard at gmail.com Thu May 5 16:30:59 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 05 May 2011 21:30:59 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130950 - /llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Message-ID: <20110505213100.054422A6C12C@llvm.org> Author: void Date: Thu May 5 16:30:59 2011 New Revision: 130950 URL: http://llvm.org/viewvc/llvm-project?rev=130950&view=rev Log: ARM was generating C-strings that were unnecessarily well-aligned. This wastes memory because one aligned C-string makes *all* strings in that section aligned. But C-strings don't need to be so well-aligned. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=130950&r1=130949&r2=130950&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Thu May 5 16:30:59 2011 @@ -646,10 +646,15 @@ /* Make strings word-aligned so strcpy from constants will be faster. */ #define CONSTANT_ALIGNMENT_FACTOR (TARGET_THUMB || ! arm_tune_xscale ? 1 : 2) -#define CONSTANT_ALIGNMENT(EXP, ALIGN) \ - ((TREE_CODE (EXP) == STRING_CST \ - && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) \ - ? BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : (ALIGN)) +/* LLVM LOCAL begin - */ +#define CONSTANT_ALIGNMENT(EXP, ALIGN) \ + (TARGET_MACHO && TREE_CODE (EXP) == STRING_CST ? \ + (ALIGN) : \ + (TREE_CODE (EXP) == STRING_CST \ + && (ALIGN) < BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR) ? \ + BITS_PER_WORD * CONSTANT_ALIGNMENT_FACTOR : \ + (ALIGN)) +/* LLVM LOCAL end - */ /* Setting STRUCTURE_SIZE_BOUNDARY to 32 produces more efficient code, but the value set in previous versions of this toolchain was 8, which produces more From rafael.espindola at gmail.com Thu May 5 16:34:33 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 21:34:33 -0000 Subject: [llvm-commits] [llvm] r130951 - /llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp Message-ID: <20110505213433.542122A6C12C@llvm.org> Author: rafael Date: Thu May 5 16:34:33 2011 New Revision: 130951 URL: http://llvm.org/viewvc/llvm-project?rev=130951&view=rev Log: Move PPC Linux to CFI. Modified: llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp Modified: llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp?rev=130951&r1=130950&r2=130951&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCMCAsmInfo.cpp Thu May 5 16:34:33 2011 @@ -48,7 +48,7 @@ // Exceptions handling if (!is64Bit) - ExceptionsType = ExceptionHandling::DwarfTable; + ExceptionsType = ExceptionHandling::DwarfCFI; ZeroDirective = "\t.space\t"; Data64bitsDirective = is64Bit ? "\t.quad\t" : 0; From aggarwa4 at illinois.edu Thu May 5 16:48:50 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 21:48:50 -0000 Subject: [llvm-commits] [poolalloc] r130952 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Message-ID: <20110505214850.E00F92A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 5 16:48:50 2011 New Revision: 130952 URL: http://llvm.org/viewvc/llvm-project?rev=130952&view=rev Log: Minor cleanup. Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130952&r1=130951&r2=130952&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Thu May 5 16:48:50 2011 @@ -106,12 +106,11 @@ //return type is same as that of original instruction const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; numSimplified++; if(numSimplified > 400) return true; - NewF = Function::Create(NewFTy, + Function *NewF = Function::Create(NewFTy, GlobalValue::InternalLinkage, F->getNameStr() + ".TEST", &M); From eli.friedman at gmail.com Thu May 5 16:59:18 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 05 May 2011 21:59:18 -0000 Subject: [llvm-commits] [llvm] r130954 - in /llvm/trunk: lib/Analysis/InstructionSimplify.cpp lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110505215918.4F94A2A6C12C@llvm.org> Author: efriedma Date: Thu May 5 16:59:18 2011 New Revision: 130954 URL: http://llvm.org/viewvc/llvm-project?rev=130954&view=rev Log: PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift. Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=130954&r1=130953&r2=130954&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original) +++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Thu May 5 16:59:18 2011 @@ -1847,7 +1847,7 @@ // fall-through case Instruction::SDiv: case Instruction::AShr: - if (!LBO->isExact() && !RBO->isExact()) + if (!LBO->isExact() || !RBO->isExact()) break; if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0), RBO->getOperand(0), TD, DT, MaxRecurse-1)) Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=130954&r1=130953&r2=130954&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Thu May 5 16:59:18 2011 @@ -2400,7 +2400,7 @@ // fall-through case Instruction::SDiv: case Instruction::AShr: - if (!BO0->isExact() && !BO1->isExact()) + if (!BO0->isExact() || !BO1->isExact()) break; return new ICmpInst(I.getPredicate(), BO0->getOperand(0), BO1->getOperand(0)); Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=130954&r1=130953&r2=130954&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Thu May 5 16:59:18 2011 @@ -510,3 +510,14 @@ ret i1 %A } +; PR9838 +; CHECK: @test53 +; CHECK-NEXT: ashr exact +; CHECK-NEXT: ashr +; CHECK-NEXT: icmp +define i1 @test53(i32 %a, i32 %b) nounwind { + %x = ashr exact i32 %a, 30 + %y = ashr i32 %b, 30 + %z = icmp eq i32 %x, %y + ret i1 %z +} From dpatel at apple.com Thu May 5 17:00:09 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 May 2011 22:00:09 -0000 Subject: [llvm-commits] [llvm] r130955 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110505220009.256422A6C12C@llvm.org> Author: dpatel Date: Thu May 5 17:00:08 2011 New Revision: 130955 URL: http://llvm.org/viewvc/llvm-project?rev=130955&view=rev Log: Remove little used statistical counter. 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=130955&r1=130954&r2=130955&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu May 5 17:00:08 2011 @@ -56,10 +56,6 @@ cl::desc("Make an absence of debug location information explicit."), cl::init(false)); -#ifndef NDEBUG -STATISTIC(BlocksWithoutLineNo, "Number of blocks without any line number"); -#endif - namespace { const char *DWARFGroupName = "DWARF Emission"; const char *DbgTimerName = "DWARF Debug Writer"; @@ -1861,37 +1857,12 @@ return DebugLoc(); } -#ifndef NDEBUG -/// CheckLineNumbers - Count basicblocks whose instructions do not have any -/// line number information. -static void CheckLineNumbers(const MachineFunction *MF) { - for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); - I != E; ++I) { - bool FoundLineNo = false; - for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); - II != IE; ++II) { - const MachineInstr *MI = II; - if (!MI->getDebugLoc().isUnknown()) { - FoundLineNo = true; - break; - } - } - if (!FoundLineNo && I->size()) - ++BlocksWithoutLineNo; - } -} -#endif - /// beginFunction - Gather pre-function debug information. Assumes being /// emitted immediately after the function entry point. void DwarfDebug::beginFunction(const MachineFunction *MF) { if (!MMI->hasDebugInfo()) return; if (!extractScopeInformation()) return; -#ifndef NDEBUG - CheckLineNumbers(MF); -#endif - FunctionBeginSym = Asm->GetTempSymbol("func_begin", Asm->getFunctionNumber()); // Assumes in correct section after the entry point. From dpatel at apple.com Thu May 5 17:05:57 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 05 May 2011 22:05:57 -0000 Subject: [llvm-commits] [llvm] r130957 - /llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Message-ID: <20110505220557.DCDD62A6C12C@llvm.org> Author: dpatel Date: Thu May 5 17:05:57 2011 New Revision: 130957 URL: http://llvm.org/viewvc/llvm-project?rev=130957&view=rev Log: In debug output, clearly list new instructions without DebugLoc. Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugInfoProbe.cpp?rev=130957&r1=130956&r2=130957&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugInfoProbe.cpp (original) +++ llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Thu May 5 17:05:57 2011 @@ -51,7 +51,6 @@ unsigned NumDbgLineLost, NumDbgValueLost; std::string PassName; Function *TheFn; - std::set LineNos; std::set DbgVariables; std::set MissingDebugLoc; }; @@ -60,32 +59,13 @@ //===----------------------------------------------------------------------===// // DebugInfoProbeImpl -static void collect(Function &F, std::set &Lines) { - for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) - for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); - BI != BE; ++BI) { - const DebugLoc &DL = BI->getDebugLoc(); - unsigned LineNo = 0; - if (!DL.isUnknown()) { - if (MDNode *N = DL.getInlinedAt(F.getContext())) - LineNo = DebugLoc::getFromDILocation(N).getLine(); - else - LineNo = DL.getLine(); - - Lines.insert(LineNo); - } - } -} - /// initialize - Collect information before running an optimization pass. void DebugInfoProbeImpl::initialize(StringRef PName, Function &F) { if (!EnableDebugInfoProbe) return; PassName = PName; - LineNos.clear(); DbgVariables.clear(); TheFn = &F; - collect(F, LineNos); for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); @@ -130,30 +110,16 @@ /// must be used after initialization. void DebugInfoProbeImpl::finalize(Function &F) { if (!EnableDebugInfoProbe) return; - std::set LineNos2; - collect(F, LineNos2); assert (TheFn == &F && "Invalid function to measure!"); - for (std::set::iterator I = LineNos.begin(), - E = LineNos.end(); I != E; ++I) { - unsigned LineNo = *I; - if (LineNos2.count(LineNo) == 0) { - DEBUG(dbgs() - << "DebugInfoProbe(" - << PassName - << "): Losing dbg info for source line " - << LineNo << "\n"); - ++NumDbgLineLost; - } - } - std::setDbgVariables2; for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { if (BI->getDebugLoc().isUnknown() && MissingDebugLoc.count(BI) == 0) { - DEBUG(dbgs() << "DebugInfoProbe(" << PassName << "): --- "); + ++NumDbgLineLost; + DEBUG(dbgs() << "DebugInfoProbe (" << PassName << "): --- "); DEBUG(BI->print(dbgs())); DEBUG(dbgs() << "\n"); } From rafael.espindola at gmail.com Thu May 5 17:14:31 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 22:14:31 -0000 Subject: [llvm-commits] [llvm] r130959 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <20110505221431.A5FA82A6C12C@llvm.org> Author: rafael Date: Thu May 5 17:14:31 2011 New Revision: 130959 URL: http://llvm.org/viewvc/llvm-project?rev=130959&view=rev Log: Remove the DwarfTable enum. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130959&r1=130958&r2=130959&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Thu May 5 17:14:31 2011 @@ -29,7 +29,7 @@ /// MCAsmInfo - This class is intended to be used as a base class for asm /// properties and features specific to the target. namespace ExceptionHandling { - enum ExceptionsType { None, DwarfTable, DwarfCFI, SjLj, ARM }; + enum ExceptionsType { None, DwarfCFI, SjLj, ARM }; } class MCAsmInfo { @@ -462,8 +462,7 @@ } bool isExceptionHandlingDwarf() const { return - (ExceptionsType == ExceptionHandling::DwarfTable || - ExceptionsType == ExceptionHandling::DwarfCFI || + (ExceptionsType == ExceptionHandling::DwarfCFI || ExceptionsType == ExceptionHandling::ARM); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130959&r1=130958&r2=130959&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu May 5 17:14:31 2011 @@ -195,9 +195,6 @@ case ExceptionHandling::SjLj: DE = new DwarfSjLjException(this); return false; - case ExceptionHandling::DwarfTable: - DE = new DwarfTableException(this); - return false; case ExceptionHandling::DwarfCFI: DE = new DwarfCFIException(this); return false; Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=130959&r1=130958&r2=130959&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu May 5 17:14:31 2011 @@ -324,7 +324,6 @@ PM.add(createSjLjEHPass(getTargetLowering())); // FALLTHROUGH case ExceptionHandling::DwarfCFI: - case ExceptionHandling::DwarfTable: case ExceptionHandling::ARM: PM.add(createDwarfEHPass(this)); break; From aggarwa4 at illinois.edu Thu May 5 17:38:31 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 05 May 2011 22:38:31 -0000 Subject: [llvm-commits] [poolalloc] r130962 - in /poolalloc/trunk: include/assistDS/TypeChecks.h lib/AssistDS/TypeChecks.cpp Message-ID: <20110505223831.0E8272A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 5 17:38:30 2011 New Revision: 130962 URL: http://llvm.org/viewvc/llvm-project?rev=130962&view=rev Log: Updated handling of byval arguments, to take care of both internal/external functions, correctly. Detailed comments inline. Olden/bh now works. Modified: poolalloc/trunk/include/assistDS/TypeChecks.h poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/include/assistDS/TypeChecks.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=130962&r1=130961&r2=130962&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/TypeChecks.h (original) +++ poolalloc/trunk/include/assistDS/TypeChecks.h Thu May 5 17:38:30 2011 @@ -59,6 +59,9 @@ bool visitCallInst(Module &M, CallInst &CI); bool visitInvokeInst(Module &M, InvokeInst &CI); bool visitCallSite(Module &M, CallSite CS); + bool visitInternalFunction(Module &M, Function &F); + bool visitExternalFunction(Module &M, Function &F); + bool visitByValFunction(Module &M, Function &F); bool visitLoadInst(Module &M, LoadInst &LI); bool visitStoreInst(Module &M, StoreInst &SI); bool visitGlobal(Module &M, GlobalVariable &GV, Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130962&r1=130961&r2=130962&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 5 17:38:30 2011 @@ -13,6 +13,7 @@ #include "assistDS/TypeChecks.h" #include "llvm/Constants.h" +#include "llvm/Transforms/Utils/Cloning.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" @@ -108,9 +109,11 @@ modified |= visitGlobal(M, *I, I->getInitializer(), *MainI, 0); } + std::vector toProcess; for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { IncorporateType(MI->getType()); Function &F = *MI; + toProcess.push_back(&F); // Loop over all of the instructions in the function, // adding their return type as well as the types of their operands. @@ -138,7 +141,6 @@ } else if (CallInst *CI = dyn_cast(&I)) { modified |= visitCallInst(M, *CI); } else if (InvokeInst *II = dyn_cast(&I)) { - II->dump(); modified |= visitInvokeInst(M, *II); } } @@ -146,70 +148,259 @@ // Record types for byval arguments. - // Split fn into 2 clones. One internal, such that - // we can find all call sites to it, and also pass in the - // original ptr/metadata. - // One that sets it just to initialized memory - // so that it can be called from external code. - for (Module::iterator MI = M.begin(), ME = M.end(); MI != ME; ++MI) { - Function &F = *MI; - typedef SmallVector RegisteredArgTy; - RegisteredArgTy registeredArguments; - for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { - if (I->hasByValAttr()) { - assert (isa(I->getType())); - const PointerType * PT = cast(I->getType()); - const Type * ET = PT->getElementType(); - Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); - Instruction * InsertBefore = &(F.getEntryBlock().front()); - CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy, "", InsertBefore); - std::vector Args; - Args.push_back(BCI); - Args.push_back(AllocSize); - Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); - Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); - CallInst::Create(F, Args.begin(), Args.end(), "", InsertBefore); - registeredArguments.push_back(&*I); - } + while(!toProcess.empty()) { + Function *F = toProcess.back(); + toProcess.pop_back(); + if(F->isDeclaration()) + continue; + modified |= visitByValFunction(M, *F); + } + + return modified; +} + +bool +TypeChecks::visitByValFunction(Module &M, Function &F) { + + bool hasByValArg = false; + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { + if (I->hasByValAttr()) { + hasByValArg = true; + break; } - // - // Find all basic blocks which terminate the function. - // - std::set exitBlocks; - for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { - if (isa(*I) || isa(*I)) { - exitBlocks.insert(I->getParent()); - } + } + if(!hasByValArg) + return false; + + // For internal functions + // Replace with a cloned function with extra arguments + // That takes as argument the original pointers without a byval parameter too + // Use them to copy the metadata over to the byval arguments + // Also update all the call sites. + + // For external functions + // Create an internal clone (treated same as internal functions) + // Modify the original function + // To assume that the metadata for the byval arguments is TOP + + if(F.hasInternalLinkage()) { + visitInternalFunction(M, F); + } else { + // create internal clone + Function *F_clone = CloneFunction(&F); + F_clone->setName(F.getNameStr() + "internal"); + F.setLinkage(GlobalValue::InternalLinkage); + F.getParent()->getFunctionList().push_back(F_clone); + visitInternalFunction(M, *F_clone); + visitExternalFunction(M, F); + } + return true; +} + +bool TypeChecks::visitInternalFunction(Module &M, Function &F) { + + // Create a list of the argument types in the new function. + std::vectorTP; + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { + TP.push_back(I->getType()); + // for every byval argument, add a new argument that indicates the source of + // the metadata. It is of the same type as the byval argument. + if (I->hasByValAttr()) + TP.push_back(I->getType()); + } + // Create the new function prototype + const FunctionType *NewFTy = FunctionType::get(F.getReturnType(), TP, false); + Function *NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F.getNameStr() + ".INT", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + DenseMap ValueMap; + for (Function::arg_iterator II = F.arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + // Each new argument maps to the argument in the old function + // For these arguments, also copy over the attributes + ValueMap[II] = NI; + NI->setName(II->getName()); + NI->addAttr(F.getAttributes().getParamAttributes(II->getArgNo() + 1)); + // If we have encountered a byval argument in the old function + // We must skip over the next argument in the new function, as that is + // the newly added source argument. + if(II->hasByValAttr()) { + NI++; + // Give this new argument some name, for clarity + NI->setName("src"); + } + } + // Copy over the attributes for the function. + NewF->setAttributes(NewF->getAttributes() + .addAttr(0, F.getAttributes().getRetAttributes())); + NewF->setAttributes(NewF->getAttributes().addAttr(~0, F.getAttributes().getFnAttributes())); + + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, &F, ValueMap, Returns); + + // Add calls to the runtime to copy metadata from source to the byval argument pointer. + typedef SmallVector RegisteredArgTy; + // Keep track of the byval arguments. + RegisteredArgTy registeredArguments; + for (Function::arg_iterator I = NewF->arg_begin(), E = NewF->arg_end(); I != E; ++I) { + if (I->hasByValAttr()) { + registeredArguments.push_back(&*I); + assert (isa(I->getType())); + const PointerType * PT = cast(I->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + Instruction * InsertBefore = &(NewF->getEntryBlock().front()); + // If I is the byval argument, the next argument is the source + CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I, VoidPtrTy, "", InsertBefore); + CastInst *BCI_Src = BitCastInst::CreatePointerCast(++I, VoidPtrTy, "", InsertBefore); + std::vector Args; + Args.push_back(BCI_Dest); + Args.push_back(BCI_Src); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("copyTypeInfo", VoidTy, VoidPtrTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", InsertBefore); + } + } + + // Find all basic blocks which terminate the function. + std::set exitBlocks; + for (inst_iterator I = inst_begin(NewF), E = inst_end(NewF); I != E; ++I) { + if (isa(*I) || isa(*I)) { + exitBlocks.insert(I->getParent()); } + } - // - // At each function exit, insert code to deregister all byval arguments. - // - for (std::set::const_iterator BI = exitBlocks.begin(), - BE = exitBlocks.end(); - BI != BE; ++BI) { - for (RegisteredArgTy::const_iterator I = registeredArguments.begin(), - E = registeredArguments.end(); - I != E; ++I) { - SmallVector args; - Instruction * Pt = &((*BI)->back()); - const PointerType * PT = cast((*I)->getType()); - const Type * ET = PT->getElementType(); - Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); - CastInst *BCI = BitCastInst::CreatePointerCast(*I, VoidPtrTy, "", Pt); - std::vector Args; - Args.push_back(BCI); - Args.push_back(AllocSize); - Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); - Constant *F = M.getOrInsertFunction("trackUnInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); - CallInst::Create(F, Args.begin(), Args.end(), "", Pt); - } + // At each function exit, insert code to set the metadata as uninitialized. + for (std::set::const_iterator BI = exitBlocks.begin(), + BE = exitBlocks.end(); + BI != BE; ++BI) { + for (RegisteredArgTy::const_iterator I = registeredArguments.begin(), + E = registeredArguments.end(); + I != E; ++I) { + SmallVector args; + Instruction * Pt = &((*BI)->back()); + const PointerType * PT = cast((*I)->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + CastInst *BCI = BitCastInst::CreatePointerCast(*I, VoidPtrTy, "", Pt); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackUnInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", Pt); } } - return modified; + // Update the call sites + for(Value::use_iterator ui = F.use_begin(), ue = F.use_end(); + ui != ue;) { + // Check that F is the called value + if(CallInst *CI = dyn_cast(ui++)) { + if(CI->getCalledFunction() == &F) { + SmallVector Args; + SmallVector AttributesVec; + + // Get the initial attributes of the call + AttrListPtr CallPAL = CI->getAttributes(); + Attributes RAttrs = CallPAL.getRetAttributes(); + Attributes FnAttrs = CallPAL.getFnAttributes(); + + Function::arg_iterator II = F.arg_begin(); + + for(unsigned j =1;jgetNumOperands();j++, II++) { + // Add the original argument + Args.push_back(CI->getOperand(j)); + // If there are attributes on this argument, copy them to the correct + // position in the AttributesVec + if (Attributes Attrs = CallPAL.getParamAttributes(j)) + AttributesVec.push_back(AttributeWithIndex::get(Args.size(), Attrs)); + // If it is a value passed as byval, add it again, as the source + if(II->hasByValAttr()) + Args.push_back(CI->getOperand(j)); + } + + // Create the new attributes vec. + if (FnAttrs != Attribute::None) + AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs)); + if (RAttrs) + AttributesVec.push_back(AttributeWithIndex::get(0, RAttrs)); + + AttrListPtr NewCallPAL = AttrListPtr::get(AttributesVec.begin(), + AttributesVec.end()); + + + // Create the substitute call + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CallI->setAttributes(NewCallPAL); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); + } + } + } + return true; } +bool TypeChecks::visitExternalFunction(Module &M, Function &F) { + + // A list of the byval arguments that we are setting metadata for + typedef SmallVector RegisteredArgTy; + RegisteredArgTy registeredArguments; + for (Function::arg_iterator I = F.arg_begin(), E = F.arg_end(); I != E; ++I) { + if (I->hasByValAttr()) { + assert (isa(I->getType())); + const PointerType * PT = cast(I->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + Instruction * InsertBefore = &(F.getEntryBlock().front()); + CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy, "", InsertBefore); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + // Set the metadata for the byval argument to TOP/Initialized + Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", InsertBefore); + registeredArguments.push_back(&*I); + } + } + + // Find all basic blocks which terminate the function. + std::set exitBlocks; + for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) { + if (isa(*I) || isa(*I)) { + exitBlocks.insert(I->getParent()); + } + } + + // At each function exit, insert code to set the metadata as uninitialized. + for (std::set::const_iterator BI = exitBlocks.begin(), + BE = exitBlocks.end(); + BI != BE; ++BI) { + for (RegisteredArgTy::const_iterator I = registeredArguments.begin(), + E = registeredArguments.end(); + I != E; ++I) { + SmallVector args; + Instruction * Pt = &((*BI)->back()); + const PointerType * PT = cast((*I)->getType()); + const Type * ET = PT->getElementType(); + Value * AllocSize = ConstantInt::get(Int64Ty, TD->getTypeAllocSize(ET)); + CastInst *BCI = BitCastInst::CreatePointerCast(*I, VoidPtrTy, "", Pt); + std::vector Args; + Args.push_back(BCI); + Args.push_back(AllocSize); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackUnInitInst", VoidTy, VoidPtrTy, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", Pt); + } + } + return true; +} // Print the types found in the module. If the optional Module parameter is // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. From rafael.espindola at gmail.com Thu May 5 18:20:24 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 05 May 2011 23:20:24 -0000 Subject: [llvm-commits] [llvm] r130964 - in /llvm/trunk/lib/CodeGen/AsmPrinter: CMakeLists.txt DwarfException.h DwarfSjLjException.cpp DwarfTableException.cpp Message-ID: <20110505232111.67B9F2A6C124@llvm.org> Author: rafael Date: Thu May 5 18:19:54 2011 New Revision: 130964 URL: http://llvm.org/viewvc/llvm-project?rev=130964&view=rev Log: Remove DwarfTableException. Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=130964&r1=130963&r2=130964&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Thu May 5 18:19:54 2011 @@ -9,7 +9,6 @@ DwarfDebug.cpp DwarfException.cpp DwarfSjLjException.cpp - DwarfTableException.cpp OcamlGCPrinter.cpp ) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=130964&r1=130963&r2=130964&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Thu May 5 18:19:54 2011 @@ -171,73 +171,6 @@ virtual void EndFunction(); }; -class DwarfTableException : public DwarfException { - /// shouldEmitTable - Per-function flag to indicate if EH tables should - /// be emitted. - bool shouldEmitTable; - - /// shouldEmitMoves - Per-function flag to indicate if frame moves info - /// should be emitted. - bool shouldEmitMoves; - - /// shouldEmitTableModule - Per-module flag to indicate if EH tables - /// should be emitted. - bool shouldEmitTableModule; - - /// shouldEmitMovesModule - Per-module flag to indicate if frame moves - /// should be emitted. - bool shouldEmitMovesModule; - - struct FunctionEHFrameInfo { - MCSymbol *FunctionEHSym; // L_foo.eh - unsigned Number; - unsigned PersonalityIndex; - bool adjustsStack; - bool hasLandingPads; - std::vector Moves; - const Function *function; - - FunctionEHFrameInfo(MCSymbol *EHSym, unsigned Num, unsigned P, - bool hC, bool hL, - const std::vector &M, - const Function *f): - FunctionEHSym(EHSym), Number(Num), PersonalityIndex(P), - adjustsStack(hC), hasLandingPads(hL), Moves(M), function (f) { } - }; - - std::vector EHFrames; - - /// UsesLSDA - Indicates whether an FDE that uses the CIE at the given index - /// uses an LSDA. If so, then we need to encode that information in the CIE's - /// augmentation. - DenseMap UsesLSDA; - - /// EmitCIE - Emit a Common Information Entry (CIE). This holds information - /// that is shared among many Frame Description Entries. There is at least - /// one CIE in every non-empty .debug_frame section. - void EmitCIE(const Function *Personality, unsigned Index); - - /// EmitFDE - Emit the Frame Description Entry (FDE) for the function. - void EmitFDE(const FunctionEHFrameInfo &EHFrameInfo); -public: - //===--------------------------------------------------------------------===// - // Main entry points. - // - DwarfTableException(AsmPrinter *A); - virtual ~DwarfTableException(); - - /// EndModule - Emit all exception information that should come after the - /// content. - virtual void EndModule(); - - /// BeginFunction - Gather pre-function exception information. Assumes being - /// emitted immediately after the function entry point. - virtual void BeginFunction(const MachineFunction *MF); - - /// EndFunction - Gather and emit post-function exception information. - virtual void EndFunction(); -}; - class DwarfSjLjException : public DwarfException { public: //===--------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp?rev=130964&r1=130963&r2=130964&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfSjLjException.cpp Thu May 5 18:19:54 2011 @@ -1,4 +1,4 @@ -//===-- CodeGen/AsmPrinter/DwarfTableException.cpp - Dwarf Exception Impl --==// +//===-- CodeGen/AsmPrinter/DwarfSjLjException.cpp - Dwarf Exception Impl --==// // // The LLVM Compiler Infrastructure // Removed: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp?rev=130963&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp (removed) @@ -1,344 +0,0 @@ -//===-- CodeGen/AsmPrinter/DwarfTableException.cpp - Dwarf Exception Impl --==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains support for writing DWARF exception info into asm files. -// The implementation emits all the necessary tables "by hands". -// -//===----------------------------------------------------------------------===// - -#include "DwarfException.h" -#include "llvm/Module.h" -#include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/CodeGen/MachineFrameInfo.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/CodeGen/MachineLocation.h" -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCContext.h" -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCSection.h" -#include "llvm/MC/MCStreamer.h" -#include "llvm/MC/MCSymbol.h" -#include "llvm/Target/Mangler.h" -#include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetFrameLowering.h" -#include "llvm/Target/TargetLoweringObjectFile.h" -#include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetOptions.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Support/Dwarf.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/Twine.h" -using namespace llvm; - -DwarfTableException::DwarfTableException(AsmPrinter *A) - : DwarfException(A), - shouldEmitTable(false), shouldEmitMoves(false), - shouldEmitTableModule(false), shouldEmitMovesModule(false) {} - -DwarfTableException::~DwarfTableException() {} - -/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that -/// is shared among many Frame Description Entries. There is at least one CIE -/// in every non-empty .debug_frame section. -void DwarfTableException::EmitCIE(const Function *PersonalityFn, unsigned Index) { - // Size and sign of stack growth. - int stackGrowth = Asm->getTargetData().getPointerSize(); - if (Asm->TM.getFrameLowering()->getStackGrowthDirection() == - TargetFrameLowering::StackGrowsDown) - stackGrowth *= -1; - - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - - // Begin eh frame section. - Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); - - MCSymbol *EHFrameSym; - if (TLOF.isFunctionEHFrameSymbolPrivate()) - EHFrameSym = Asm->GetTempSymbol("EH_frame", Index); - else - EHFrameSym = Asm->OutContext.GetOrCreateSymbol(Twine("EH_frame") + - Twine(Index)); - Asm->OutStreamer.EmitLabel(EHFrameSym); - - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_eh_frame", Index)); - - // Define base labels. - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common", Index)); - - // Define the eh frame length. - Asm->OutStreamer.AddComment("Length of Common Information Entry"); - Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_frame_common_end", Index), - Asm->GetTempSymbol("eh_frame_common_begin", Index), - 4); - - // EH frame header. - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_begin",Index)); - Asm->OutStreamer.AddComment("CIE Identifier Tag"); - Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/); - Asm->OutStreamer.AddComment("DW_CIE_VERSION"); - Asm->OutStreamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1/*size*/, 0/*addr*/); - - // The personality presence indicates that language specific information will - // show up in the eh frame. Find out how we are supposed to lower the - // personality function reference: - - unsigned LSDAEncoding = TLOF.getLSDAEncoding(); - unsigned FDEEncoding = TLOF.getFDEEncoding(false); - unsigned PerEncoding = TLOF.getPersonalityEncoding(); - - char Augmentation[6] = { 0 }; - unsigned AugmentationSize = 0; - char *APtr = Augmentation + 1; - - if (PersonalityFn) { - // There is a personality function. - *APtr++ = 'P'; - AugmentationSize += 1 + Asm->GetSizeOfEncodedValue(PerEncoding); - } - - if (UsesLSDA[Index]) { - // An LSDA pointer is in the FDE augmentation. - *APtr++ = 'L'; - ++AugmentationSize; - } - - if (FDEEncoding != dwarf::DW_EH_PE_absptr) { - // A non-default pointer encoding for the FDE. - *APtr++ = 'R'; - ++AugmentationSize; - } - - if (APtr != Augmentation + 1) - Augmentation[0] = 'z'; - - Asm->OutStreamer.AddComment("CIE Augmentation"); - Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0); - - // Round out reader. - Asm->EmitULEB128(1, "CIE Code Alignment Factor"); - Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); - Asm->OutStreamer.AddComment("CIE Return Address Column"); - - const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); - const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); - Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true)); - - if (Augmentation[0]) { - Asm->EmitULEB128(AugmentationSize, "Augmentation Size"); - - // If there is a personality, we need to indicate the function's location. - if (PersonalityFn) { - Asm->EmitEncodingByte(PerEncoding, "Personality"); - Asm->OutStreamer.AddComment("Personality"); - Asm->EmitReference(PersonalityFn, PerEncoding); - } - if (UsesLSDA[Index]) - Asm->EmitEncodingByte(LSDAEncoding, "LSDA"); - if (FDEEncoding != dwarf::DW_EH_PE_absptr) - Asm->EmitEncodingByte(FDEEncoding, "FDE"); - } - - // Indicate locations of general callee saved registers in frame. - std::vector Moves; - TFI->getInitialFrameState(Moves); - Asm->EmitFrameMoves(Moves, 0, true); - - // On Darwin the linker honors the alignment of eh_frame, which means it must - // be 8-byte on 64-bit targets to match what gcc does. Otherwise you get - // holes which confuse readers of eh_frame. - Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3); - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index)); -} - -/// EmitFDE - Emit the Frame Description Entry (FDE) for the function. -void DwarfTableException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) { - assert(!EHFrameInfo.function->hasAvailableExternallyLinkage() && - "Should not emit 'available externally' functions at all"); - - const Function *TheFunc = EHFrameInfo.function; - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - - unsigned LSDAEncoding = TLOF.getLSDAEncoding(); - unsigned FDEEncoding = TLOF.getFDEEncoding(false); - - Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); - - // If corresponding function is weak definition, this should be too. - if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective()) - Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym, - MCSA_WeakDefinition); - - // If corresponding function is hidden, this should be too. - if (TheFunc->hasHiddenVisibility()) - if (MCSymbolAttr HiddenAttr = Asm->MAI->getHiddenVisibilityAttr()) - Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym, - HiddenAttr); - - // If there are no calls then you can't unwind. This may mean we can omit the - // EH Frame, but some environments do not handle weak absolute symbols. If - // UnwindTablesMandatory is set we cannot do this optimization; the unwind - // info is to be available for non-EH uses. - if (!EHFrameInfo.adjustsStack && !UnwindTablesMandatory && - (!TheFunc->isWeakForLinker() || - !Asm->MAI->getWeakDefDirective() || - TLOF.getSupportsWeakOmittedEHFrame())) { - Asm->OutStreamer.EmitAssignment(EHFrameInfo.FunctionEHSym, - MCConstantExpr::Create(0, Asm->OutContext)); - // This name has no connection to the function, so it might get - // dead-stripped when the function is not, erroneously. Prohibit - // dead-stripping unconditionally. - if (Asm->MAI->hasNoDeadStrip()) - Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym, - MCSA_NoDeadStrip); - } else { - Asm->OutStreamer.EmitLabel(EHFrameInfo.FunctionEHSym); - - // EH frame header. - Asm->OutStreamer.AddComment("Length of Frame Information Entry"); - Asm->EmitLabelDifference( - Asm->GetTempSymbol("eh_frame_end", EHFrameInfo.Number), - Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number), 4); - - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_begin", - EHFrameInfo.Number)); - - Asm->OutStreamer.AddComment("FDE CIE offset"); - Asm->EmitLabelDifference( - Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number), - Asm->GetTempSymbol("eh_frame_common", - EHFrameInfo.PersonalityIndex), 4); - - MCSymbol *EHFuncBeginSym = - Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number); - - Asm->OutStreamer.AddComment("FDE initial location"); - Asm->EmitReference(EHFuncBeginSym, FDEEncoding); - - Asm->OutStreamer.AddComment("FDE address range"); - Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_func_end", - EHFrameInfo.Number), - EHFuncBeginSym, - Asm->GetSizeOfEncodedValue(FDEEncoding)); - - // If there is a personality and landing pads then point to the language - // specific data area in the exception table. - if (MMI->getPersonalities()[0] != NULL) { - unsigned Size = Asm->GetSizeOfEncodedValue(LSDAEncoding); - - Asm->EmitULEB128(Size, "Augmentation size"); - Asm->OutStreamer.AddComment("Language Specific Data Area"); - if (EHFrameInfo.hasLandingPads) - Asm->EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number), - LSDAEncoding); - else - Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/); - - } else { - Asm->EmitULEB128(0, "Augmentation size"); - } - - // Indicate locations of function specific callee saved registers in frame. - Asm->EmitFrameMoves(EHFrameInfo.Moves, EHFuncBeginSym, true); - - // On Darwin the linker honors the alignment of eh_frame, which means it - // must be 8-byte on 64-bit targets to match what gcc does. Otherwise you - // get holes which confuse readers of eh_frame. - Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3); - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end", - EHFrameInfo.Number)); - - // If the function is marked used, this table should be also. We cannot - // make the mark unconditional in this case, since retaining the table also - // retains the function in this case, and there is code around that depends - // on unused functions (calling undefined externals) being dead-stripped to - // link correctly. Yes, there really is. - if (MMI->isUsedFunction(EHFrameInfo.function)) - if (Asm->MAI->hasNoDeadStrip()) - Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym, - MCSA_NoDeadStrip); - } - Asm->OutStreamer.AddBlankLine(); -} - -/// EndModule - Emit all exception information that should come after the -/// content. -void DwarfTableException::EndModule() { - if (!Asm->MAI->isExceptionHandlingDwarf()) - return; - - if (!shouldEmitMovesModule && !shouldEmitTableModule) - return; - - const std::vector &Personalities = MMI->getPersonalities(); - - for (unsigned I = 0, E = Personalities.size(); I < E; ++I) - EmitCIE(Personalities[I], I); - - for (std::vector::iterator - I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I) - EmitFDE(*I); -} - -/// BeginFunction - Gather pre-function exception information. Assumes it's -/// being emitted immediately after the function entry point. -void DwarfTableException::BeginFunction(const MachineFunction *MF) { - shouldEmitTable = shouldEmitMoves = false; - - // If any landing pads survive, we need an EH table. - shouldEmitTable = !MMI->getLandingPads().empty(); - - // See if we need frame move info. - shouldEmitMoves = - !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory; - - if (shouldEmitMoves || shouldEmitTable) - // Assumes in correct section after the entry point. - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin", - Asm->getFunctionNumber())); - - shouldEmitTableModule |= shouldEmitTable; - shouldEmitMovesModule |= shouldEmitMoves; -} - -/// EndFunction - Gather and emit post-function exception information. -/// -void DwarfTableException::EndFunction() { - if (!shouldEmitMoves && !shouldEmitTable) return; - - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end", - Asm->getFunctionNumber())); - - // Record if this personality index uses a landing pad. - bool HasLandingPad = !MMI->getLandingPads().empty(); - UsesLSDA[MMI->getPersonalityIndex()] |= HasLandingPad; - - // Map all labels and get rid of any dead landing pads. - MMI->TidyLandingPads(); - - if (HasLandingPad) - EmitExceptionTable(); - - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - MCSymbol *FunctionEHSym = - Asm->GetSymbolWithGlobalValueBase(Asm->MF->getFunction(), ".eh", - TLOF.isFunctionEHFrameSymbolPrivate()); - - // Save EH frame information - EHFrames. - push_back(FunctionEHFrameInfo(FunctionEHSym, - Asm->getFunctionNumber(), - MMI->getPersonalityIndex(), - Asm->MF->getFrameInfo()->adjustsStack(), - !MMI->getLandingPads().empty(), - MMI->getFrameMoves(), - Asm->MF->getFunction())); -} From nicholas at mxc.ca Thu May 5 18:52:18 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 05 May 2011 23:52:18 -0000 Subject: [llvm-commits] [llvm] r130967 - in /llvm/trunk: lib/Transforms/Instrumentation/GCOVProfiling.cpp runtime/libprofile/GCDAProfiling.c Message-ID: <20110505235218.44D1F2A6C12C@llvm.org> Author: nicholas Date: Thu May 5 18:52:18 2011 New Revision: 130967 URL: http://llvm.org/viewvc/llvm-project?rev=130967&view=rev Log: The computation of string length is not that complicated. Fix it, again. :) Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/runtime/libprofile/GCDAProfiling.c Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130967&r1=130966&r2=130967&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu May 5 18:52:18 2011 @@ -140,7 +140,7 @@ // A GCOV string is a length, followed by a NUL, then between 0 and 3 NULs // padding out to the next 4-byte word. The length is measured in 4-byte // words including padding, not bytes of actual string. - return (s.size() + 5) / 4; + return (s.size() / 4) + 1; } void writeGCOVString(StringRef s) { Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130967&r1=130966&r2=130967&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Thu May 5 18:52:18 2011 @@ -49,7 +49,7 @@ } static uint32_t length_of_string(const char *s) { - return (strlen(s) + 5) / 4; + return (strlen(s) / 4) + 1; } static void write_string(const char *s) { From isanbard at gmail.com Thu May 5 19:14:25 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 06 May 2011 00:14:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130969 - /llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Message-ID: <20110506001425.A2EBB2A6C12C@llvm.org> Author: void Date: Thu May 5 19:14:25 2011 New Revision: 130969 URL: http://llvm.org/viewvc/llvm-project?rev=130969&view=rev Log: This is the llvm-gcc version of the "packing ivar offsets together" fix for clang (r130870). Basically, we place all ivars into their own section so that if they slide, they don't dirty as many pages as when they are mixed in with other objects that don't "slide". Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=130969&r1=130968&r2=130969&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Thu May 5 19:14:25 2011 @@ -7725,6 +7725,14 @@ by the front-end. Otherwise, FE asserts when attempting to do futher math on the tree whose one operand is one of these offsets. */ offset = create_extern_decl (TREE_TYPE (size_zero_node), var_offset_name); + + /* APPLE LOCAL begin - radar 9393640 */ + { + const char string[] = "__DATA,__objc_ivar"; + DECL_SECTION_NAME (offset) = build_string (strlen(string), string); + } + /* APPLE LOCAL end - radar 9393640 */ + return offset; } @@ -7802,6 +7810,13 @@ /* APPLE LOCAL radar 4441049 */ offset = create_extern_decl (TREE_TYPE (size_zero_node), var_offset_name); + /* APPLE LOCAL begin - radar 9393640 */ + { + const char string[] = "__DATA,__objc_ivar"; + DECL_SECTION_NAME (offset) = build_string (strlen(string), string); + } + /* APPLE LOCAL end - radar 9393640 */ + ftype = TREE_TYPE (field); /* (char*)datum */ @@ -11148,6 +11163,13 @@ /* APPLE LOCAL begin radar 4441049 */ *chain = tree_cons (decl, byte_position (field_decl), NULL_TREE); /* APPLE LOCAL end radar 4441049 */ + + /* APPLE LOCAL begin - radar 9393640 */ + { + const char string[] = "__DATA,__objc_ivar"; + DECL_SECTION_NAME (decl) = build_string (strlen(string), string); + } + /* APPLE LOCAL end - radar 9393640 */ return decl; } From mttjwl at gmail.com Thu May 5 20:18:20 2011 From: mttjwl at gmail.com (Matthew Wala) Date: Fri, 06 May 2011 01:18:20 -0000 Subject: [llvm-commits] [poolalloc] r130972 - in /poolalloc/trunk: include/dsa/CStdLib.h lib/DSA/StdLibPass.cpp Message-ID: <20110506011820.209272A6C12C@llvm.org> Author: wala1 Date: Thu May 5 20:18:19 2011 New Revision: 130972 URL: http://llvm.org/viewvc/llvm-project?rev=130972&view=rev Log: Added entries for pool_strcasestr(). Modified: poolalloc/trunk/include/dsa/CStdLib.h poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/include/dsa/CStdLib.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/CStdLib.h?rev=130972&r1=130971&r2=130972&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/CStdLib.h (original) +++ poolalloc/trunk/include/dsa/CStdLib.h Thu May 5 20:18:19 2011 @@ -44,6 +44,7 @@ { "pool_bcopy", 2 }, { "pool_index", 1 }, { "pool_rindex", 1 }, + { "pool_strcasestr", 2 }, { 0, 0 } }; Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=130972&r1=130971&r2=130972&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Thu May 5 20:18:19 2011 @@ -279,6 +279,7 @@ {"pool_strcat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strncat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, {"pool_strstr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, + {"pool_strcasestr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, {"pool_strpbrk", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, {"pool_strspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, {"pool_strcspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, From etherzhhb at gmail.com Thu May 5 21:38:20 2011 From: etherzhhb at gmail.com (Hongbin Zheng) Date: Fri, 06 May 2011 02:38:20 -0000 Subject: [llvm-commits] [polly] r130975 - in /polly/trunk: include/polly/ScopDetection.h lib/Analysis/ScopDetection.cpp lib/CodeGeneration.cpp test/CodeGen/OpenMP/invalidate_subfn_scops.ll Message-ID: <20110506023820.391392A6C12C@llvm.org> Author: ether Date: Thu May 5 21:38:20 2011 New Revision: 130975 URL: http://llvm.org/viewvc/llvm-project?rev=130975&view=rev Log: ScopDetection: Remember the functions generated by backend in a pointer set, so we do not re-generate code for these functions. Modified: polly/trunk/include/polly/ScopDetection.h polly/trunk/lib/Analysis/ScopDetection.cpp polly/trunk/lib/CodeGeneration.cpp polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll Modified: polly/trunk/include/polly/ScopDetection.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopDetection.h?rev=130975&r1=130974&r2=130975&view=diff ============================================================================== --- polly/trunk/include/polly/ScopDetection.h (original) +++ polly/trunk/include/polly/ScopDetection.h Thu May 5 21:38:20 2011 @@ -102,6 +102,10 @@ typedef std::set RegionSet; RegionSet ValidRegions; + // Remember the invalid functions producted by backends; + typedef std::set FunctionSet; + FunctionSet InvalidFunctions; + // Try to expand the region R. If R can be expanded return the expanded // region, NULL otherwise. Region *expandRegion(Region &R); @@ -248,6 +252,14 @@ ValidRegions.erase(&R); } + /// @brief Mark the function as invalid so we will not extract any scop from + /// the function. + /// + /// @param F The function to mark as invalid. + void markFunctionAsInvalid(const Function *F) { + InvalidFunctions.insert(F); + } + /// @brief Verify if all valid Regions in this Function are still valid /// after some transformations. void verifyAnalysis() const; Modified: polly/trunk/lib/Analysis/ScopDetection.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=130975&r1=130974&r2=130975&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopDetection.cpp (original) +++ polly/trunk/lib/Analysis/ScopDetection.cpp Thu May 5 21:38:20 2011 @@ -594,12 +594,7 @@ } bool ScopDetection::isValidFunction(llvm::Function &F) { - const std::string &Name = F.getNameStr(); - size_t found = Name.find(".omp_subfn"); - if (found != std::string::npos) - return false; - else - return true; + return !InvalidFunctions.count(&F); } bool ScopDetection::runOnFunction(llvm::Function &F) { @@ -650,6 +645,7 @@ void ScopDetection::releaseMemory() { ValidRegions.clear(); + // Do not clear the invalid function set. } char ScopDetection::ID = 0; Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=130975&r1=130974&r2=130975&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Thu May 5 21:38:20 2011 @@ -678,8 +678,8 @@ // The Scop we code generate. Scop *S; ScalarEvolution &SE; - DominatorTree *DT; + ScopDetection *SD; Dependences *DP; TargetData *TD; @@ -834,6 +834,8 @@ std::vector Arguments(1, Builder.getInt8PtrTy()); FunctionType *FT = FunctionType::get(Builder.getVoidTy(), Arguments, false); Function *FN = Function::Create(FT, Function::InternalLinkage, Name, M); + // Do not run any polly pass on the new function. + SD->markFunctionAsInvalid(FN); Function::arg_iterator AI = FN->arg_begin(); AI->setName("omp.userContext"); @@ -1251,8 +1253,10 @@ } ClastStmtCodeGen(Scop *scop, ScalarEvolution &se, DominatorTree *dt, - Dependences *dp, TargetData *td, IRBuilder<> &B) : - S(scop), SE(se), DT(dt), DP(dp), TD(td), Builder(B), ExpGen(Builder, NULL) {} + ScopDetection *sd, Dependences *dp, TargetData *td, + IRBuilder<> &B) : + S(scop), SE(se), DT(dt), SD(sd), DP(dp), TD(td), Builder(B), + ExpGen(Builder, NULL) {} }; } @@ -1369,7 +1373,7 @@ const clast_root *clast = (const clast_root *) C->getClast(); - ClastStmtCodeGen CodeGen(S, *SE, DT, DP, TD, Builder); + ClastStmtCodeGen CodeGen(S, *SE, DT, SD, DP, TD, Builder); if (OpenMP) addOpenMPDefinitions(Builder); Modified: polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll?rev=130975&r1=130974&r2=130975&view=diff ============================================================================== --- polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll (original) +++ polly/trunk/test/CodeGen/OpenMP/invalidate_subfn_scops.ll Thu May 5 21:38:20 2011 @@ -1,5 +1,5 @@ ; ModuleID = 'test.ll' -; RUN: opt %loadPolly %defaultOpts -basicaa -polly-codegen -enable-polly-openmp < %s | not FileCheck %s +; RUN: opt %loadPolly %defaultOpts -polly-codegen -enable-polly-openmp -analyze %s -debug-only=polly-detect 2>&1 | not 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:32:32-n8:16:32" target triple = "i386-pc-linux-gnu" @@ -35,4 +35,4 @@ } -; CHECK: define internal void @main.omp_subfn.omp_subfn +; CHECK: Checking region: omp.setup From aggarwa4 at illinois.edu Thu May 5 21:51:38 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Fri, 06 May 2011 02:51:38 -0000 Subject: [llvm-commits] [poolalloc] r130976 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110506025138.2A9062A6C12C@llvm.org> Author: aggarwa4 Date: Thu May 5 21:51:37 2011 New Revision: 130976 URL: http://llvm.org/viewvc/llvm-project?rev=130976&view=rev Log: Add support for read. Needed for gzip. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130976&r1=130975&r2=130976&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Thu May 5 21:51:37 2011 @@ -578,6 +578,16 @@ CallInst::Create(F, Args.begin(), Args.end(), "", I); break; } + } else if(F->getNameStr() == std::string("read")) { + CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(2), VoidPtrTy); + BCI->insertAfter(I); + std::vector Args; + Args.push_back(BCI); + Args.push_back(I); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, I->getType(), Int32Ty, NULL); + CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); + CI->insertAfter(BCI); } else if(F->getNameStr() == std::string("calloc")) { CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy); BCI->insertAfter(I); @@ -596,8 +606,6 @@ F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, I->getOperand(2)->getType(), I->getOperand(1)->getType(), Int32Ty, NULL); CallInst *CI_Arr = CallInst::Create(F, Args1.begin(), Args1.end()); CI_Arr->insertAfter(CI); - - } else if(F->getNameStr() == std::string("realloc")) { CastInst *BCI_Src = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy); CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I, VoidPtrTy); From nobled at dreamwidth.org Thu May 5 22:41:16 2011 From: nobled at dreamwidth.org (nobled) Date: Thu, 5 May 2011 23:41:16 -0400 Subject: [llvm-commits] [PATCHES] fix duplication and FIXMEs in JIT code In-Reply-To: References: Message-ID: ping? On Sun, Apr 24, 2011 at 6:20 PM, nobled wrote: > Whoops, forgot to join the mailing list, so this got stuck in the > moderation queue... > > ---------- Forwarded message ---------- > From: nobled > Date: Sun, Apr 24, 2011 at 11:05 AM > Subject: [PATCHES] fix duplication and FIXMEs in JIT code > To: llvm-commits at cs.uiuc.edu > > > (Just so you know, I do have commit access.) > > These patches address this comment from the MCJIT code: > > ?// FIXME: This should be lifted out of here, it isn't something which should > ?// be part of the JIT policy, rather the burden for this selection should be > ?// pushed to clients. > ==== > [PATCH 1/3] ExecutionEngine: fix JIT/MCJIT selectTarget() duplication > > (Merges the near-identical files lib/EE/JIT/TargetSelect.cpp and > lib/EE/MCJIT/TargetSelect.cpp into lib/EE/TargetSelect.cpp.) > > This prepares for making JITCtor/MCJITCtor take a > TargetMachine* directly from clients like EngineBuilder. > ==== > [PATCH 2/3] ExecutionEngine: push TargetMachine creation into clients > > In particular, into EngineBuilder. This should only impact > the private API between the EE and EB classes, not external > clients, since JITCtor and MCJITCtor are both protected members. > ==== > [PATCH 3/3] ExecutionEngine: move createJIT definition > > As an ExecutionEngine class function, its definition > really belongs in ExecutionEngine.cpp instead of in JIT.cpp. > ==== > > As for this comment: > > ? // Try to register the program as a source of symbols to resolve against. > ? // > ? // FIXME: Don't do this here. > ? sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); > > where in the stack *should* that go, ideally? > From eli.friedman at gmail.com Fri May 6 00:23:07 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 06 May 2011 05:23:07 -0000 Subject: [llvm-commits] [llvm] r130977 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/Thumb2/thumb2-cbnz.ll test/CodeGen/X86/cmp-redundant.ll Message-ID: <20110506052307.7FEE82A6C12C@llvm.org> Author: efriedma Date: Fri May 6 00:23:07 2011 New Revision: 130977 URL: http://llvm.org/viewvc/llvm-project?rev=130977&view=rev Log: Re-revert r130877; it's apparently causing a regression on 197.parser, possibly related to cbnz formation. Removed: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Modified: llvm/trunk/lib/CodeGen/MachineCSE.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineCSE.cpp?rev=130977&r1=130976&r2=130977&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Fri May 6 00:23:07 2011 @@ -33,8 +33,6 @@ STATISTIC(NumCSEs, "Number of common subexpression eliminated"); STATISTIC(NumPhysCSEs, "Number of physreg referencing common subexpr eliminated"); -STATISTIC(NumCrossBlockPhysCSEs, - "Number of physreg common subexprs cross-block eliminated"); STATISTIC(NumCommutes, "Number of copies coalesced after commuting"); namespace { @@ -84,8 +82,7 @@ MachineBasicBlock::const_iterator E) const ; bool hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs, - SmallVector &PhysDefs) const; + SmallSet &PhysRefs) const; bool PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const; bool isCSECandidate(MachineInstr *MI); @@ -192,8 +189,7 @@ /// instruction does not uses a physical register. bool MachineCSE::hasLivePhysRegDefUses(const MachineInstr *MI, const MachineBasicBlock *MBB, - SmallSet &PhysRefs, - SmallVector &PhysDefs) const{ + SmallSet &PhysRefs) const { MachineBasicBlock::const_iterator I = MI; I = llvm::next(I); for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); @@ -210,7 +206,6 @@ if (MO.isDef() && (MO.isDead() || isPhysDefTriviallyDead(Reg, I, MBB->end()))) continue; - PhysDefs.push_back(Reg); PhysRefs.insert(Reg); for (const unsigned *Alias = TRI->getAliasSet(Reg); *Alias; ++Alias) PhysRefs.insert(*Alias); @@ -221,43 +216,35 @@ bool MachineCSE::PhysRegDefsReach(MachineInstr *CSMI, MachineInstr *MI, SmallSet &PhysRefs) const { - // Look backward from MI to find CSMI. + // For now conservatively returns false if the common subexpression is + // not in the same basic block as the given instruction. + MachineBasicBlock *MBB = MI->getParent(); + if (CSMI->getParent() != MBB) + return false; + MachineBasicBlock::const_iterator I = CSMI; I = llvm::next(I); + MachineBasicBlock::const_iterator E = MI; unsigned LookAheadLeft = LookAheadLimit; - MachineBasicBlock *CurBB = MI->getParent(); - MachineBasicBlock::const_reverse_iterator I(MI); - MachineBasicBlock::const_reverse_iterator E(CurBB->rend()); while (LookAheadLeft) { - while (LookAheadLeft && I != E) { - // Skip over dbg_value's. - while (I != E && I->isDebugValue()) - ++I; - - if (I == E) break; - - if (&*I == CSMI) - return true; - - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - const MachineOperand &MO = I->getOperand(i); - if (!MO.isReg() || !MO.isDef()) - continue; - unsigned MOReg = MO.getReg(); - if (TargetRegisterInfo::isVirtualRegister(MOReg)) - continue; - if (PhysRefs.count(MOReg)) - return false; - } - - --LookAheadLeft; + // Skip over dbg_value's. + while (I != E && I->isDebugValue()) ++I; + + if (I == E) + return true; + + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { + const MachineOperand &MO = I->getOperand(i); + if (!MO.isReg() || !MO.isDef()) + continue; + unsigned MOReg = MO.getReg(); + if (TargetRegisterInfo::isVirtualRegister(MOReg)) + continue; + if (PhysRefs.count(MOReg)) + return false; } - // Go back another BB; for now, only go back at most one BB. - MachineBasicBlock *CSBB = CSMI->getParent(); - if (!CSBB->isSuccessor(CurBB) || CurBB->pred_size() != 1) - return false; - CurBB = CSBB; - I = CSBB->rbegin(); - E = CSBB->rend(); + + --LookAheadLeft; + ++I; } return false; @@ -408,8 +395,7 @@ // used, then it's not safe to replace it with a common subexpression. // It's also not safe if the instruction uses physical registers. SmallSet PhysRefs; - SmallVector DirectPhysRefs; - if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs, DirectPhysRefs)) { + if (FoundCSE && hasLivePhysRegDefUses(MI, MBB, PhysRefs)) { FoundCSE = false; // ... Unless the CS is local and it also defines the physical register @@ -462,15 +448,6 @@ MRI->clearKillFlags(CSEPairs[i].second); } MI->eraseFromParent(); - if (!DirectPhysRefs.empty() && CSMI->getParent() != MBB) { - assert(CSMI->getParent()->isSuccessor(MBB)); - ++NumCrossBlockPhysCSEs; - SmallVector::iterator PI = DirectPhysRefs.begin(), - PE = DirectPhysRefs.end(); - for (; PI != PE; ++PI) - if (!MBB->isLiveIn(*PI)) - MBB->addLiveIn(*PI); - } ++NumCSEs; if (!PhysRefs.empty()) ++NumPhysCSEs; Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll?rev=130977&r1=130976&r2=130977&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-cbnz.ll Fri May 6 00:23:07 2011 @@ -21,8 +21,8 @@ bb9: ; preds = %bb7 ; CHECK: cmp r0, #0 -; CHECK-NOT: cmp -; CHECK: cbnz +; CHECK: cmp r0, #0 +; CHECK-NEXT: cbnz %0 = tail call double @floor(double %b) nounwind readnone ; [#uses=0] br label %bb11 Removed: llvm/trunk/test/CodeGen/X86/cmp-redundant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmp-redundant.ll?rev=130976&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (original) +++ llvm/trunk/test/CodeGen/X86/cmp-redundant.ll (removed) @@ -1,43 +0,0 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin10 | FileCheck %s - -define i32 @cmp(i32* %aa, i32* %bb) nounwind readnone ssp { -entry: - %a = load i32* %aa - %b = load i32* %bb - %cmp = icmp sgt i32 %a, %b - br i1 %cmp, label %return, label %if.end -; CHECK: cmp: -; CHECK: cmpl -; CHECK: jg - -if.end: ; preds = %entry -; CHECK-NOT: cmpl -; CHECK: cmov - %cmp4 = icmp slt i32 %a, %b - %. = select i1 %cmp4, i32 2, i32 111 - br label %return - -return: ; preds = %if.end, %entry - %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] - ret i32 %retval.0 -} - -define i32 @cmp2(i32 %a, i32 %b) nounwind readnone ssp { -entry: - %cmp = icmp sgt i32 %a, %b - br i1 %cmp, label %return, label %if.end -; CHECK: cmp2: -; CHECK: cmpl -; CHECK: jg - -if.end: ; preds = %entry -; CHECK-NOT: cmpl -; CHECK: cmov - %cmp4 = icmp slt i32 %a, %b - %. = select i1 %cmp4, i32 2, i32 111 - br label %return - -return: ; preds = %if.end, %entry - %retval.0 = phi i32 [ 1, %entry ], [ %., %if.end ] - ret i32 %retval.0 -} From baldrick at free.fr Fri May 6 01:24:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 06 May 2011 08:24:10 +0200 Subject: [llvm-commits] [llvm] r130943 - /llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp In-Reply-To: <20110505193221.B847D2A6C12C@llvm.org> References: <20110505193221.B847D2A6C12C@llvm.org> Message-ID: <4DC3940A.2070800@free.fr> Hi Andrew, > --- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original) > +++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Thu May 5 14:32:21 2011 > @@ -393,6 +393,18 @@ > UseList.clear(); > if (!MO.isDead()) > DefList.clear(); > + > + // Calls will not be reordered because of chain dependencies (see > + // below). Since call operands are dead, calls may continue to be added > + // to the DefList making dependence checking quadratic in the size of > + // the block. Instead, we leave only one call at the back of the > + // DefList. > + // > + // NOTE: This assumes that the DefList is ordered! that suggests adding a check that DefList is ordered. Ciao, Duncan. From baldrick at free.fr Fri May 6 05:30:37 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 06 May 2011 10:30:37 -0000 Subject: [llvm-commits] [llvm] r130979 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll Message-ID: <20110506103037.EF3D02A6C12E@llvm.org> Author: baldrick Date: Fri May 6 05:30:37 2011 New Revision: 130979 URL: http://llvm.org/viewvc/llvm-project?rev=130979&view=rev Log: Fix PR9820: a read-only call differs from a load in that a load doesn't return the pointer being dereferenced, it returns the pointee, but a call might return the pointer itself. Added: llvm/trunk/test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll 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=130979&r1=130978&r2=130979&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri May 6 05:30:37 2011 @@ -2481,19 +2481,22 @@ } if (CallSite CS = U) { - // If this is a readonly/readnone call site, then we know it is just a - // load and we can ignore it. - if (CS.onlyReadsMemory()) - continue; - // If this is the function being called then we treat it like a load and // ignore it. if (CS.isCallee(UI)) continue; + // If this is a readonly/readnone call site, then we know it is just a + // load (but one that potentially returns the value itself), so we can + // ignore it if we know that the value isn't captured. + unsigned ArgNo = CS.getArgumentNo(UI); + if (CS.onlyReadsMemory() && + (CS.getInstruction()->use_empty() || + CS.paramHasAttr(ArgNo+1, Attribute::NoCapture))) + continue; + // If this is being passed as a byval argument, the caller is making a // copy, so it is only a read of the alloca. - unsigned ArgNo = CS.getArgumentNo(UI); if (CS.paramHasAttr(ArgNo+1, Attribute::ByVal)) continue; } Added: llvm/trunk/test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll?rev=130979&view=auto ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll (added) +++ llvm/trunk/test/Transforms/ScalarRepl/2011-05-06-CapturedAlloca.ll Fri May 6 05:30:37 2011 @@ -0,0 +1,26 @@ +; RUN: opt < %s -instcombine -S | FileCheck %s +; PR9820 + +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-unknown-linux-gnu" + + at func_1.l_10 = internal unnamed_addr constant [4 x i32] [i32 1, i32 0, i32 0, i32 0], align 16 + +define i32* @noop(i32* %p_29) nounwind readnone { +entry: + ret i32* %p_29 +} + +define i32 @main() nounwind { +entry: + %l_10 = alloca [4 x i32], align 16 + %tmp = bitcast [4 x i32]* %l_10 to i8* + call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([4 x i32]* @func_1.l_10 to i8*), i64 16, i32 16, i1 false) +; CHECK: call void @llvm.memcpy + %arrayidx = getelementptr inbounds [4 x i32]* %l_10, i64 0, i64 0 + %call = call i32* @noop(i32* %arrayidx) + store i32 0, i32* %call + ret i32 0 +} + +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind From justin.holewinski at gmail.com Fri May 6 06:40:36 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Fri, 06 May 2011 11:40:36 -0000 Subject: [llvm-commits] [llvm] r130980 - in /llvm/trunk: lib/Target/PTX/PTX.td lib/Target/PTX/PTXSubtarget.cpp lib/Target/PTX/PTXSubtarget.h test/CodeGen/PTX/options.ll Message-ID: <20110506114036.3F86A2A6C12C@llvm.org> Author: jholewinski Date: Fri May 6 06:40:36 2011 New Revision: 130980 URL: http://llvm.org/viewvc/llvm-project?rev=130980&view=rev Log: PTX: add PTX 2.3 language target Patch by Wei-Ren Chen Modified: llvm/trunk/lib/Target/PTX/PTX.td llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp llvm/trunk/lib/Target/PTX/PTXSubtarget.h llvm/trunk/test/CodeGen/PTX/options.ll Modified: llvm/trunk/lib/Target/PTX/PTX.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTX.td?rev=130980&r1=130979&r2=130980&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTX.td (original) +++ llvm/trunk/lib/Target/PTX/PTX.td Fri May 6 06:40:36 2011 @@ -38,6 +38,10 @@ "Use PTX Language Version 2.2", [FeaturePTX21]>; +def FeaturePTX23 : SubtargetFeature<"ptx23", "PTXVersion", "PTX_VERSION_2_3", + "Use PTX Language Version 2.3", + [FeaturePTX22]>; + //===- PTX Shader Model ---------------------------------------------------===// def FeatureSM10 : SubtargetFeature<"sm10", "PTXShaderModel", "PTX_SM_1_0", Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp?rev=130980&r1=130979&r2=130980&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.cpp Fri May 6 06:40:36 2011 @@ -41,6 +41,7 @@ case PTX_VERSION_2_0: return "2.0"; case PTX_VERSION_2_1: return "2.1"; case PTX_VERSION_2_2: return "2.2"; + case PTX_VERSION_2_3: return "2.3"; } } Modified: llvm/trunk/lib/Target/PTX/PTXSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXSubtarget.h?rev=130980&r1=130979&r2=130980&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXSubtarget.h (original) +++ llvm/trunk/lib/Target/PTX/PTXSubtarget.h Fri May 6 06:40:36 2011 @@ -37,7 +37,8 @@ enum PTXVersionEnum { PTX_VERSION_2_0, /*< PTX Version 2.0 */ PTX_VERSION_2_1, /*< PTX Version 2.1 */ - PTX_VERSION_2_2 /*< PTX Version 2.2 */ + PTX_VERSION_2_2, /*< PTX Version 2.2 */ + PTX_VERSION_2_3 /*< PTX Version 2.3 */ }; /// Shader Model supported on the target GPU. Modified: llvm/trunk/test/CodeGen/PTX/options.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/options.ll?rev=130980&r1=130979&r2=130980&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/options.ll (original) +++ llvm/trunk/test/CodeGen/PTX/options.ll Fri May 6 06:40:36 2011 @@ -1,6 +1,7 @@ ; RUN: llc < %s -march=ptx32 -mattr=ptx20 | grep ".version 2.0" ; RUN: llc < %s -march=ptx32 -mattr=ptx21 | grep ".version 2.1" ; RUN: llc < %s -march=ptx32 -mattr=ptx22 | grep ".version 2.2" +; RUN: llc < %s -march=ptx32 -mattr=ptx23 | grep ".version 2.3" ; RUN: llc < %s -march=ptx32 -mattr=sm10 | grep ".target sm_10" ; RUN: llc < %s -march=ptx32 -mattr=sm13 | grep ".target sm_13" ; RUN: llc < %s -march=ptx32 -mattr=sm20 | grep ".target sm_20" From justin.holewinski at gmail.com Fri May 6 06:46:48 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Fri, 6 May 2011 07:46:48 -0400 Subject: [llvm-commits] [LLVMdev] [PATCH ]Add Subtarget ptx23 In-Reply-To: <20110506093714.GA41682@cs.nctu.edu.tw> References: <20110506093714.GA41682@cs.nctu.edu.tw> Message-ID: On Fri, May 6, 2011 at 5:37 AM, ??? wrote: > Hi, Justin > > PTX version in CUDA 4.0 has changed from 2.2 to 2.3. > I add ptx23 subtarget and update a testcase. > > Is that O.K.? > Looks good. Committed in r130980. Thanks! In the future, patches should be sent to llvm-commits instead of llvmdev. > > Regards, > chenwj > > -- > Wei-Ren Chen (???) > Computer Systems Lab, Institute of Information Science, > Academia Sinica, Taiwan (R.O.C.) > Tel:886-2-2788-3799 #1667 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110506/2d0a992c/attachment.html From rafael.espindola at gmail.com Fri May 6 09:56:22 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 14:56:22 -0000 Subject: [llvm-commits] [llvm] r130984 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/MC/MCAsmInfo.cpp lib/Target/ARM/ARMMCAsmInfo.cpp lib/Target/X86/X86MCAsmInfo.cpp Message-ID: <20110506145623.0C0792A6C12C@llvm.org> Author: rafael Date: Fri May 6 09:56:22 2011 New Revision: 130984 URL: http://llvm.org/viewvc/llvm-project?rev=130984&view=rev Log: Dead code elimination. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/Target/ARM/ARMMCAsmInfo.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Fri May 6 09:56:22 2011 @@ -269,9 +269,6 @@ /// SupportsExceptionHandling - True if target supports exception handling. ExceptionHandling::ExceptionsType ExceptionsType; // Defaults to None - /// RequiresFrameSection - true if the Dwarf2 output needs a frame section - bool DwarfRequiresFrameSection; // Defaults to true. - /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to /// encode inline subroutine information. bool DwarfUsesInlineInfoSection; // Defaults to false. @@ -465,10 +462,6 @@ (ExceptionsType == ExceptionHandling::DwarfCFI || ExceptionsType == ExceptionHandling::ARM); } - - bool doesDwarfRequireFrameSection() const { - return DwarfRequiresFrameSection; - } bool doesDwarfUsesInlineInfoSection() const { return DwarfUsesInlineInfoSection; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri May 6 09:56:22 2011 @@ -596,7 +596,7 @@ if (UnwindTablesMandatory) return true; - if (MMI->hasDebugInfo() && !MAI->doesDwarfRequireFrameSection()) + if (MMI->hasDebugInfo()) return true; if (MF->getFunction()->doesNotThrow()) @@ -608,8 +608,7 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { MCSymbol *Label = MI.getOperand(0).getMCSymbol(); - if (MAI->doesDwarfRequireFrameSection() || - MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) + if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) OutStreamer.EmitLabel(Label); if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri May 6 09:56:22 2011 @@ -256,7 +256,7 @@ CurrentFnDbgScope(0), PrevLabel(NULL) { NextStringPoolNumber = 0; - DwarfFrameSectionSym = DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0; + DwarfInfoSectionSym = DwarfAbbrevSectionSym = 0; DwarfStrSectionSym = TextSectionSym = 0; DwarfDebugRangeSectionSym = DwarfDebugLocSectionSym = 0; FunctionBeginSym = FunctionEndSym = 0; @@ -1261,14 +1261,6 @@ Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_end", i)); } - // Emit common frame information. - emitCommonDebugFrame(); - - // Emit function debug frame information - for (std::vector::iterator I = DebugFrames.begin(), - E = DebugFrames.end(); I != E; ++I) - emitFunctionDebugFrame(*I); - // Compute DIE offsets and sizes. computeSizeAndOffsets(); @@ -2261,11 +2253,6 @@ const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); // Dwarf sections base addresses. - if (Asm->MAI->doesDwarfRequireFrameSection()) { - DwarfFrameSectionSym = - EmitSectionSym(Asm, TLOF.getDwarfFrameSection(), "section_debug_frame"); - } - DwarfInfoSectionSym = EmitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info"); DwarfAbbrevSectionSym = @@ -2473,91 +2460,6 @@ Asm->EmitInt8(1); } -/// emitCommonDebugFrame - Emit common frame info into a debug frame section. -/// -void DwarfDebug::emitCommonDebugFrame() { - if (!Asm->MAI->doesDwarfRequireFrameSection()) - return; - - int stackGrowth = Asm->getTargetData().getPointerSize(); - if (Asm->TM.getFrameLowering()->getStackGrowthDirection() == - TargetFrameLowering::StackGrowsDown) - stackGrowth *= -1; - - // Start the dwarf frame section. - Asm->OutStreamer.SwitchSection( - Asm->getObjFileLowering().getDwarfFrameSection()); - - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common")); - Asm->OutStreamer.AddComment("Length of Common Information Entry"); - Asm->EmitLabelDifference(Asm->GetTempSymbol("debug_frame_common_end"), - Asm->GetTempSymbol("debug_frame_common_begin"), 4); - - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common_begin")); - Asm->OutStreamer.AddComment("CIE Identifier Tag"); - Asm->EmitInt32((int)dwarf::DW_CIE_ID); - Asm->OutStreamer.AddComment("CIE Version"); - Asm->EmitInt8(dwarf::DW_CIE_VERSION); - Asm->OutStreamer.AddComment("CIE Augmentation"); - Asm->OutStreamer.EmitIntValue(0, 1, /*addrspace*/0); // nul terminator. - Asm->EmitULEB128(1, "CIE Code Alignment Factor"); - Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor"); - Asm->OutStreamer.AddComment("CIE RA Column"); - const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); - const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); - Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), false)); - - std::vector Moves; - TFI->getInitialFrameState(Moves); - - Asm->EmitFrameMoves(Moves, 0, false); - - Asm->EmitAlignment(2); - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("debug_frame_common_end")); -} - -/// emitFunctionDebugFrame - Emit per function frame info into a debug frame -/// section. -void DwarfDebug:: -emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo) { - if (!Asm->MAI->doesDwarfRequireFrameSection()) - return; - - // Start the dwarf frame section. - Asm->OutStreamer.SwitchSection( - Asm->getObjFileLowering().getDwarfFrameSection()); - - Asm->OutStreamer.AddComment("Length of Frame Information Entry"); - MCSymbol *DebugFrameBegin = - Asm->GetTempSymbol("debug_frame_begin", DebugFrameInfo.Number); - MCSymbol *DebugFrameEnd = - Asm->GetTempSymbol("debug_frame_end", DebugFrameInfo.Number); - Asm->EmitLabelDifference(DebugFrameEnd, DebugFrameBegin, 4); - - Asm->OutStreamer.EmitLabel(DebugFrameBegin); - - Asm->OutStreamer.AddComment("FDE CIE offset"); - Asm->EmitSectionOffset(Asm->GetTempSymbol("debug_frame_common"), - DwarfFrameSectionSym); - - Asm->OutStreamer.AddComment("FDE initial location"); - MCSymbol *FuncBeginSym = - Asm->GetTempSymbol("func_begin", DebugFrameInfo.Number); - Asm->OutStreamer.EmitSymbolValue(FuncBeginSym, - Asm->getTargetData().getPointerSize(), - 0/*AddrSpace*/); - - - Asm->OutStreamer.AddComment("FDE address range"); - Asm->EmitLabelDifference(Asm->GetTempSymbol("func_end",DebugFrameInfo.Number), - FuncBeginSym, Asm->getTargetData().getPointerSize()); - - Asm->EmitFrameMoves(DebugFrameInfo.Moves, FuncBeginSym, false); - - Asm->EmitAlignment(2); - Asm->OutStreamer.EmitLabel(DebugFrameEnd); -} - /// emitDebugPubNames - Emit visible names into a debug pubnames section. /// void DwarfDebug::emitDebugPubNames() { Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri May 6 09:56:22 2011 @@ -269,7 +269,7 @@ // Section Symbols: these are assembler temporary labels that are emitted at // the beginning of each supported dwarf section. These are used to form // section offsets and are created by EmitSectionLabels. - MCSymbol *DwarfFrameSectionSym, *DwarfInfoSectionSym, *DwarfAbbrevSectionSym; + MCSymbol *DwarfInfoSectionSym, *DwarfAbbrevSectionSym; MCSymbol *DwarfStrSectionSym, *TextSectionSym, *DwarfDebugRangeSectionSym; MCSymbol *DwarfDebugLocSectionSym; MCSymbol *FunctionBeginSym, *FunctionEndSym; @@ -338,14 +338,6 @@ /// void emitEndOfLineMatrix(unsigned SectionEnd); - /// emitCommonDebugFrame - Emit common frame info into a debug frame section. - /// - void emitCommonDebugFrame(); - - /// emitFunctionDebugFrame - Emit per function frame info into a debug frame - /// section. - void emitFunctionDebugFrame(const FunctionDebugFrameInfo &DebugFrameInfo); - /// emitDebugPubNames - Emit visible names into a debug pubnames section. /// void emitDebugPubNames(); Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Fri May 6 09:56:22 2011 @@ -74,7 +74,6 @@ HasLEB128 = false; SupportsDebugInformation = false; ExceptionsType = ExceptionHandling::None; - DwarfRequiresFrameSection = false; DwarfUsesInlineInfoSection = false; DwarfRequiresRelocationForStmtList = true; DwarfSectionOffsetDirective = 0; Modified: llvm/trunk/lib/Target/ARM/ARMMCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCAsmInfo.cpp?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCAsmInfo.cpp Fri May 6 09:56:22 2011 @@ -70,8 +70,6 @@ WeakRefDirective = "\t.weak\t"; HasLCOMMDirective = true; - DwarfRequiresFrameSection = false; - SupportsDebugInformation = true; // Exceptions handling Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130984&r1=130983&r2=130984&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Fri May 6 09:56:22 2011 @@ -108,8 +108,6 @@ // Exceptions handling ExceptionsType = ExceptionHandling::DwarfCFI; - DwarfRequiresFrameSection = false; - // OpenBSD has buggy support for .quad in 32-bit mode, just split into two // .words. if (T.getOS() == Triple::OpenBSD && T.getArch() == Triple::x86) From rafael.espindola at gmail.com Fri May 6 10:22:26 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 15:22:26 -0000 Subject: [llvm-commits] [llvm] r130985 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Message-ID: <20110506152226.BAA132A6C12C@llvm.org> Author: rafael Date: Fri May 6 10:22:26 2011 New Revision: 130985 URL: http://llvm.org/viewvc/llvm-project?rev=130985&view=rev Log: More dead code elimination. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130985&r1=130984&r2=130985&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri May 6 10:22:26 2011 @@ -398,8 +398,6 @@ /// EmitFrameMoves - Emit frame instructions to describe the layout of the /// frame. - void EmitFrameMoves(const std::vector &Moves, - MCSymbol *BaseLabel, bool isEH) const; void EmitCFIFrameMove(const MachineMove &Move) const; void EmitCFIFrameMoves(const std::vector &Moves) const; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=130985&r1=130984&r2=130985&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Fri May 6 10:22:26 2011 @@ -206,77 +206,6 @@ // Dwarf Lowering Routines //===----------------------------------------------------------------------===// - -/// EmitFrameMoves - Emit frame instructions to describe the layout of the -/// frame. -void AsmPrinter::EmitFrameMoves(const std::vector &Moves, - MCSymbol *BaseLabel, bool isEH) const { - const TargetRegisterInfo *RI = TM.getRegisterInfo(); - - int stackGrowth = TM.getTargetData()->getPointerSize(); - if (TM.getFrameLowering()->getStackGrowthDirection() != - TargetFrameLowering::StackGrowsUp) - stackGrowth *= -1; - - for (unsigned i = 0, N = Moves.size(); i < N; ++i) { - const MachineMove &Move = Moves[i]; - MCSymbol *Label = Move.getLabel(); - // Throw out move if the label is invalid. - if (Label && !Label->isDefined()) continue; // Not emitted, in dead code. - - const MachineLocation &Dst = Move.getDestination(); - const MachineLocation &Src = Move.getSource(); - - // Advance row if new location. - if (BaseLabel && Label) { - MCSymbol *ThisSym = Label; - if (ThisSym != BaseLabel) { - EmitCFAByte(dwarf::DW_CFA_advance_loc4); - EmitLabelDifference(ThisSym, BaseLabel, 4); - BaseLabel = ThisSym; - } - } - - // If advancing cfa. - if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) { - assert(!Src.isReg() && "Machine move not supported yet."); - - if (Src.getReg() == MachineLocation::VirtualFP) { - EmitCFAByte(dwarf::DW_CFA_def_cfa_offset); - } else { - EmitCFAByte(dwarf::DW_CFA_def_cfa); - EmitULEB128(RI->getDwarfRegNum(Src.getReg(), isEH), "Register"); - } - - EmitULEB128(-Src.getOffset(), "Offset"); - continue; - } - - if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) { - assert(Dst.isReg() && "Machine move not supported yet."); - EmitCFAByte(dwarf::DW_CFA_def_cfa_register); - EmitULEB128(RI->getDwarfRegNum(Dst.getReg(), isEH), "Register"); - continue; - } - - unsigned Reg = RI->getDwarfRegNum(Src.getReg(), isEH); - int Offset = Dst.getOffset() / stackGrowth; - - if (Offset < 0) { - EmitCFAByte(dwarf::DW_CFA_offset_extended_sf); - EmitULEB128(Reg, "Reg"); - EmitSLEB128(Offset, "Offset"); - } else if (Reg < 64) { - EmitCFAByte(dwarf::DW_CFA_offset + Reg); - EmitULEB128(Offset, "Offset"); - } else { - EmitCFAByte(dwarf::DW_CFA_offset_extended); - EmitULEB128(Reg, "Reg"); - EmitULEB128(Offset, "Offset"); - } - } -} - /// EmitFrameMoves - Emit a frame instruction. void AsmPrinter::EmitCFIFrameMove(const MachineMove &Move) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); From rafael.espindola at gmail.com Fri May 6 10:28:56 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 15:28:56 -0000 Subject: [llvm-commits] [llvm] r130987 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Message-ID: <20110506152856.875362A6C12C@llvm.org> Author: rafael Date: Fri May 6 10:28:56 2011 New Revision: 130987 URL: http://llvm.org/viewvc/llvm-project?rev=130987&view=rev Log: Update comments. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130987&r1=130986&r2=130987&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri May 6 10:28:56 2011 @@ -396,9 +396,12 @@ // Dwarf Lowering Routines //===------------------------------------------------------------------===// - /// EmitFrameMoves - Emit frame instructions to describe the layout of the + /// EmitCFIFrameMove - Emit frame instruction to describe the layout of the /// frame. void EmitCFIFrameMove(const MachineMove &Move) const; + + /// EmitCFIFrameMoves - Emit frame instructions to describe the layout of + /// the frame. void EmitCFIFrameMoves(const std::vector &Moves) const; //===------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=130987&r1=130986&r2=130987&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Fri May 6 10:28:56 2011 @@ -206,7 +206,7 @@ // Dwarf Lowering Routines //===----------------------------------------------------------------------===// -/// EmitFrameMoves - Emit a frame instruction. +/// EmitCFIFrameMove - Emit a frame instruction. void AsmPrinter::EmitCFIFrameMove(const MachineMove &Move) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); @@ -233,7 +233,7 @@ } } -/// EmitFrameMoves - Emit frame instructions to describe the layout of the +/// EmitCFIFrameMoves - Emit frame instructions to describe the layout of the /// frame. void AsmPrinter::EmitCFIFrameMoves(const std::vector &Moves) const { for (unsigned i = 0, N = Moves.size(); i < N; ++i) { From rafael.espindola at gmail.com Fri May 6 10:31:55 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 15:31:55 -0000 Subject: [llvm-commits] [llvm] r130988 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Message-ID: <20110506153155.847D32A6C12C@llvm.org> Author: rafael Date: Fri May 6 10:31:55 2011 New Revision: 130988 URL: http://llvm.org/viewvc/llvm-project?rev=130988&view=rev Log: Yet more dead code. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130988&r1=130987&r2=130988&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri May 6 10:31:55 2011 @@ -400,10 +400,6 @@ /// frame. void EmitCFIFrameMove(const MachineMove &Move) const; - /// EmitCFIFrameMoves - Emit frame instructions to describe the layout of - /// the frame. - void EmitCFIFrameMoves(const std::vector &Moves) const; - //===------------------------------------------------------------------===// // Inline Asm Support //===------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=130988&r1=130987&r2=130988&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Fri May 6 10:31:55 2011 @@ -232,16 +232,3 @@ Dst.getOffset()); } } - -/// EmitCFIFrameMoves - Emit frame instructions to describe the layout of the -/// frame. -void AsmPrinter::EmitCFIFrameMoves(const std::vector &Moves) const { - for (unsigned i = 0, N = Moves.size(); i < N; ++i) { - const MachineMove &Move = Moves[i]; - MCSymbol *Label = Move.getLabel(); - // Throw out move if the label is invalid. - if (Label && !Label->isDefined()) continue; // Not emitted, in dead code. - - EmitCFIFrameMove(Move); - } -} From rafael.espindola at gmail.com Fri May 6 10:44:29 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 15:44:29 -0000 Subject: [llvm-commits] [llvm] r130989 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <20110506154429.422FD2A6C12C@llvm.org> Author: rafael Date: Fri May 6 10:44:29 2011 New Revision: 130989 URL: http://llvm.org/viewvc/llvm-project?rev=130989&view=rev Log: Nothing else uses this label. 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=130989&r1=130988&r2=130989&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri May 6 10:44:29 2011 @@ -609,9 +609,6 @@ MCSymbol *Label = MI.getOperand(0).getMCSymbol(); if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) - OutStreamer.EmitLabel(Label); - - if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) return; if (!needsCFIMoves()) From dpatel at apple.com Fri May 6 11:57:54 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 06 May 2011 16:57:54 -0000 Subject: [llvm-commits] [llvm] r130991 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfDebug.cpp Message-ID: <20110506165754.60A322A6C12C@llvm.org> Author: dpatel Date: Fri May 6 11:57:54 2011 New Revision: 130991 URL: http://llvm.org/viewvc/llvm-project?rev=130991&view=rev Log: Move CompileUnit::getOrCreateNameSpace() and CompileUnit::addPubType() from DwarfDebug.cpp to DwarfCompileUnit.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=130991&r1=130990&r2=130991&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Fri May 6 11:57:54 2011 @@ -585,6 +585,27 @@ Entity->addValue(dwarf::DW_AT_type, dwarf::DW_FORM_ref4, Entry); } +/// addPubTypes - Add type for pubtypes section. +void CompileUnit::addPubTypes(DISubprogram SP) { + DICompositeType SPTy = SP.getType(); + unsigned SPTag = SPTy.getTag(); + if (SPTag != dwarf::DW_TAG_subroutine_type) + return; + + DIArray Args = SPTy.getTypeArray(); + for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) { + DIType ATy(Args.getElement(i)); + if (!ATy.Verify()) + continue; + DICompositeType CATy = getDICompositeType(ATy); + if (DIDescriptor(CATy).Verify() && !CATy.getName().empty() + && !CATy.isForwardDecl()) { + if (DIEEntry *Entry = getDIEEntry(CATy)) + addGlobalType(CATy.getName(), Entry->getEntry()); + } + } +} + /// constructTypeDIE - Construct basic type die from DIBasicType. void CompileUnit::constructTypeDIE(DIE &Buffer, DIBasicType BTy) { // Get core information. @@ -809,6 +830,20 @@ return ParamDIE; } +/// getOrCreateNameSpace - Create a DIE for DINameSpace. +DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) { + DIE *NDie = getDIE(NS); + if (NDie) + return NDie; + NDie = new DIE(dwarf::DW_TAG_namespace); + insertDIE(NS, NDie); + if (!NS.getName().empty()) + addString(NDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, NS.getName()); + addSourceLine(NDie, NS); + addToContextOwner(NDie, NS.getContext()); + return NDie; +} + /// constructSubrangeDIE - Construct subrange DIE from DISubrange. void CompileUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy){ DIE *DW_Subrange = new DIE(dwarf::DW_TAG_subrange_type); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130991&r1=130990&r2=130991&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri May 6 11:57:54 2011 @@ -748,26 +748,6 @@ } -void CompileUnit::addPubTypes(DISubprogram SP) { - DICompositeType SPTy = SP.getType(); - unsigned SPTag = SPTy.getTag(); - if (SPTag != dwarf::DW_TAG_subroutine_type) - return; - - DIArray Args = SPTy.getTypeArray(); - for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) { - DIType ATy(Args.getElement(i)); - if (!ATy.Verify()) - continue; - DICompositeType CATy = getDICompositeType(ATy); - if (DIDescriptor(CATy).Verify() && !CATy.getName().empty() - && !CATy.isForwardDecl()) { - if (DIEEntry *Entry = getDIEEntry(CATy)) - addGlobalType(CATy.getName(), Entry->getEntry()); - } - } -} - /// constructScopeDIE - Construct a DIE for this scope. DIE *DwarfDebug::constructScopeDIE(DbgScope *Scope) { if (!Scope || !Scope->getScopeNode()) @@ -860,20 +840,6 @@ return SrcId; } -/// getOrCreateNameSpace - Create a DIE for DINameSpace. -DIE *CompileUnit::getOrCreateNameSpace(DINameSpace NS) { - DIE *NDie = getDIE(NS); - if (NDie) - return NDie; - NDie = new DIE(dwarf::DW_TAG_namespace); - insertDIE(NS, NDie); - if (!NS.getName().empty()) - addString(NDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, NS.getName()); - addSourceLine(NDie, NS); - addToContextOwner(NDie, NS.getContext()); - return NDie; -} - /// constructCompileUnit - Create new CompileUnit for the given /// metadata node with tag DW_TAG_compile_unit. void DwarfDebug::constructCompileUnit(const MDNode *N) { From atrick at apple.com Fri May 6 12:09:08 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 06 May 2011 17:09:08 -0000 Subject: [llvm-commits] [llvm] r130992 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Message-ID: <20110506170908.3920D2A6C12C@llvm.org> Author: atrick Date: Fri May 6 12:09:08 2011 New Revision: 130992 URL: http://llvm.org/viewvc/llvm-project?rev=130992&view=rev Log: Post-RA scheduler compile time fix. Quadratic computation of DAG node depth. The post-ra scheduler was explicitly updating the depth of a node's successors after scheduling it, regardless of whether the successor was ready. This is quadratic for DAGs with transitively redundant edges. I simply removed the useless update of depth, which is lazilly computed later. Fixes compiler takes way too long to build TextInput. 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=130992&r1=130991&r2=130992&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Fri May 6 12:09:08 2011 @@ -540,10 +540,16 @@ #endif --SuccSU->NumPredsLeft; - // Compute how many cycles it will be before this actually becomes - // available. This is the max of the start time of all predecessors plus - // their latencies. - SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency()); + // Standard scheduler algorithms will recomute the depth of the successor + // here as such: + // SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency()); + // + // However, we lazily compute node depth instead. Note that + // ScheduleNodeTopDown has already updated the depth of this node which causes + // all descendents to be marked dirty. Setting the successor depth explicitly + // here would cause depth to be recomputed for all its ancestors. If the + // successor is not yet ready (because of a transitively redundant edge) then + // this causes depth computation to be quadratic in the size of the DAG. // If all the node's predecessors are scheduled, this node is ready // to be scheduled. Ignore the special ExitSU node. From arplynn at gmail.com Fri May 6 12:49:04 2011 From: arplynn at gmail.com (Alistair Lynn) Date: Fri, 6 May 2011 18:49:04 +0100 Subject: [llvm-commits] [llvm] r130992 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp In-Reply-To: <20110506170908.3920D2A6C12C@llvm.org> References: <20110506170908.3920D2A6C12C@llvm.org> Message-ID: Hi Andrew- > + // Standard scheduler algorithms will recomute the depth of the successor > + // here as such: ? recompute? Alistair From rafael.espindola at gmail.com Fri May 6 12:44:59 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 17:44:59 -0000 Subject: [llvm-commits] [llvm] r130995 - /llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c Message-ID: <20110506174459.1D0F12A6C12C@llvm.org> Author: rafael Date: Fri May 6 12:44:58 2011 New Revision: 130995 URL: http://llvm.org/viewvc/llvm-project?rev=130995&view=rev Log: Pass -disable-cfi. Modified: llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c Modified: llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c?rev=130995&r1=130994&r2=130995&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c (original) +++ llvm/trunk/test/FrontendC/2010-01-05-LinkageName.c Fri May 6 12:44:58 2011 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc -O2 -S -g %s -o - | llc -o 2010-01-05-LinkageName.s -O0 +// RUN: %llvmgcc -O2 -S -g %s -o - | llc -disable-cfi -o 2010-01-05-LinkageName.s -O0 // RUN: %compile_c 2010-01-05-LinkageName.s -o 2010-01-05-LinkageName.s struct tm {}; From stoklund at 2pi.dk Fri May 6 12:59:57 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 06 May 2011 17:59:57 -0000 Subject: [llvm-commits] [llvm] r130996 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp Message-ID: <20110506175957.6E5AD2A6C12C@llvm.org> Author: stoklund Date: Fri May 6 12:59:57 2011 New Revision: 130996 URL: http://llvm.org/viewvc/llvm-project?rev=130996&view=rev Log: Also count identity copies. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=130996&r1=130995&r2=130996&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Fri May 6 12:59:57 2011 @@ -42,6 +42,7 @@ using namespace llvm; STATISTIC(NumSpills , "Number of register spills"); +STATISTIC(NumIdCopies, "Number of identity moves eliminated after rewriting"); //===----------------------------------------------------------------------===// // VirtRegMap implementation @@ -318,6 +319,7 @@ // Finally, remove any identity copies. if (MI->isIdentityCopy()) { + ++NumIdCopies; if (MI->getNumOperands() == 2) { DEBUG(dbgs() << "Deleting identity copy.\n"); RemoveMachineInstrFromMaps(MI); From stoklund at 2pi.dk Fri May 6 12:59:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 06 May 2011 17:59:59 -0000 Subject: [llvm-commits] [llvm] r130997 - /llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Message-ID: <20110506180000.0DCD42A6C12E@llvm.org> Author: stoklund Date: Fri May 6 12:59:59 2011 New Revision: 130997 URL: http://llvm.org/viewvc/llvm-project?rev=130997&view=rev Log: Use TargetMachine hooks to properly print debug variable locations. Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=130997&r1=130996&r2=130997&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Fri May 6 12:59:59 2011 @@ -228,7 +228,7 @@ /// Only first one needs DebugLoc to identify variable's lexical scope /// in source file. DebugLoc findDebugLoc(); - void print(raw_ostream&, const TargetRegisterInfo*); + void print(raw_ostream&, const TargetMachine*); }; } // namespace @@ -300,7 +300,7 @@ }; } // namespace -void UserValue::print(raw_ostream &OS, const TargetRegisterInfo *TRI) { +void UserValue::print(raw_ostream &OS, const TargetMachine *TM) { if (const MDString *MDS = dyn_cast(variable->getOperand(2))) OS << "!\"" << MDS->getString() << "\"\t"; if (offset) @@ -312,15 +312,17 @@ else OS << I.value(); } - for (unsigned i = 0, e = locations.size(); i != e; ++i) - OS << " Loc" << i << '=' << locations[i]; + for (unsigned i = 0, e = locations.size(); i != e; ++i) { + OS << " Loc" << i << '='; + locations[i].print(OS, TM); + } OS << '\n'; } void LDVImpl::print(raw_ostream &OS) { OS << "********** DEBUG VARIABLES **********\n"; for (unsigned i = 0, e = userValues.size(); i != e; ++i) - userValues[i]->print(OS, TRI); + userValues[i]->print(OS, &MF->getTarget()); } void UserValue::coalesceLocation(unsigned LocNo) { @@ -701,7 +703,6 @@ } coalesceLocation(LocNo); } - DEBUG(print(dbgs(), &TRI)); } /// findInsertLocation - Find an iterator for inserting a DBG_VALUE From stoklund at 2pi.dk Fri May 6 13:00:02 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 06 May 2011 18:00:02 -0000 Subject: [llvm-commits] [llvm] r130998 - in /llvm/trunk/lib/CodeGen: LiveDebugVariables.cpp LiveDebugVariables.h LiveRangeEdit.h RegAllocGreedy.cpp Message-ID: <20110506180003.0C90B2A6C12F@llvm.org> Author: stoklund Date: Fri May 6 13:00:02 2011 New Revision: 130998 URL: http://llvm.org/viewvc/llvm-project?rev=130998&view=rev Log: Update LiveDebugVariables after live range splitting. After a virtual register is split, update any debug user variables that resided in the old register. This ensures that the LiveDebugVariables are still correct after register allocation. This may create DBG_VALUE instructions that place a user variable in a register in parts of the function and in a stack slot in other parts. DwarfDebug currently doesn't support that. Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp llvm/trunk/lib/CodeGen/LiveDebugVariables.h llvm/trunk/lib/CodeGen/LiveRangeEdit.h llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=130998&r1=130997&r2=130998&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Fri May 6 13:00:02 2011 @@ -101,9 +101,13 @@ void insertDebugValue(MachineBasicBlock *MBB, SlotIndex Idx, unsigned LocNo, LiveIntervals &LIS, const TargetInstrInfo &TII); + /// splitLocation - Replace OldLocNo ranges with NewRegs ranges where NewRegs + /// is live. Returns true if any changes were made. + bool splitLocation(unsigned OldLocNo, ArrayRef NewRegs); + public: /// UserValue - Create a new UserValue. - UserValue(const MDNode *var, unsigned o, DebugLoc L, + UserValue(const MDNode *var, unsigned o, DebugLoc L, LocMap::Allocator &alloc) : variable(var), offset(o), dl(L), leader(this), next(0), locInts(alloc) {} @@ -215,6 +219,10 @@ void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx, const TargetRegisterInfo *TRI); + /// splitRegister - Replace OldReg ranges with NewRegs ranges where NewRegs is + /// live. Returns true if any changes were made. + bool splitRegister(unsigned OldLocNo, ArrayRef NewRegs); + /// rewriteLocations - Rewrite virtual register locations according to the /// provided virtual register map. void rewriteLocations(VirtRegMap &VRM, const TargetRegisterInfo &TRI); @@ -293,6 +301,9 @@ /// renameRegister - Replace all references to OldReg with NewReg:SubIdx. void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx); + /// splitRegister - Replace all references to OldReg with NewRegs. + void splitRegister(unsigned OldReg, ArrayRef NewRegs); + /// emitDebugVariables - Recreate DBG_VALUE instruction from data structures. void emitDebugValues(VirtRegMap *VRM); @@ -679,6 +690,140 @@ static_cast(pImpl)->renameRegister(OldReg, NewReg, SubIdx); } +//===----------------------------------------------------------------------===// +// Live Range Splitting +//===----------------------------------------------------------------------===// + +bool +UserValue::splitLocation(unsigned OldLocNo, ArrayRef NewRegs) { + DEBUG({ + dbgs() << "Splitting Loc" << OldLocNo << '\t'; + print(dbgs(), 0); + }); + bool DidChange = false; + LocMap::iterator LocMapI; + LocMapI.setMap(locInts); + for (unsigned i = 0; i != NewRegs.size(); ++i) { + LiveInterval *LI = NewRegs[i]; + if (LI->empty()) + continue; + + // Don't allocate the new LocNo until it is needed. + unsigned NewLocNo = ~0u; + + // Iterate over the overlaps between locInts and LI. + LocMapI.find(LI->beginIndex()); + if (!LocMapI.valid()) + continue; + LiveInterval::iterator LII = LI->advanceTo(LI->begin(), LocMapI.start()); + LiveInterval::iterator LIE = LI->end(); + while (LocMapI.valid() && LII != LIE) { + // At this point, we know that LocMapI.stop() > LII->start. + LII = LI->advanceTo(LII, LocMapI.start()); + if (LII == LIE) + break; + + // Now LII->end > LocMapI.start(). Do we have an overlap? + if (LocMapI.value() == OldLocNo && LII->start < LocMapI.stop()) { + // Overlapping correct location. Allocate NewLocNo now. + if (NewLocNo == ~0u) { + MachineOperand MO = MachineOperand::CreateReg(LI->reg, false); + MO.setSubReg(locations[OldLocNo].getSubReg()); + NewLocNo = getLocationNo(MO); + DidChange = true; + } + + SlotIndex LStart = LocMapI.start(); + SlotIndex LStop = LocMapI.stop(); + + // Trim LocMapI down to the LII overlap. + if (LStart < LII->start) + LocMapI.setStartUnchecked(LII->start); + if (LStop > LII->end) + LocMapI.setStopUnchecked(LII->end); + + // Change the value in the overlap. This may trigger coalescing. + LocMapI.setValue(NewLocNo); + + // Re-insert any removed OldLocNo ranges. + if (LStart < LocMapI.start()) { + LocMapI.insert(LStart, LocMapI.start(), OldLocNo); + ++LocMapI; + assert(LocMapI.valid() && "Unexpected coalescing"); + } + if (LStop > LocMapI.stop()) { + ++LocMapI; + LocMapI.insert(LII->end, LStop, OldLocNo); + --LocMapI; + } + } + + // Advance to the next overlap. + if (LII->end < LocMapI.stop()) { + if (++LII == LIE) + break; + LocMapI.advanceTo(LII->start); + } else { + ++LocMapI; + if (!LocMapI.valid()) + break; + LII = LI->advanceTo(LII, LocMapI.start()); + } + } + } + + // Finally, remove any remaining OldLocNo intervals and OldLocNo itself. + locations.erase(locations.begin() + OldLocNo); + LocMapI.goToBegin(); + while (LocMapI.valid()) { + unsigned v = LocMapI.value(); + if (v == OldLocNo) { + DEBUG(dbgs() << "Erasing [" << LocMapI.start() << ';' + << LocMapI.stop() << ")\n"); + LocMapI.erase(); + } else { + if (v > OldLocNo) + LocMapI.setValueUnchecked(v-1); + ++LocMapI; + } + } + + DEBUG({dbgs() << "Split result: \t"; print(dbgs(), 0);}); + return DidChange; +} + +bool +UserValue::splitRegister(unsigned OldReg, ArrayRef NewRegs) { + bool DidChange = false; + for (unsigned LocNo = 0, E = locations.size(); LocNo != E; ++LocNo) { + const MachineOperand *Loc = &locations[LocNo]; + if (!Loc->isReg() || Loc->getReg() != OldReg) + continue; + DidChange |= splitLocation(LocNo, NewRegs); + } + return DidChange; +} + +void LDVImpl::splitRegister(unsigned OldReg, ArrayRef NewRegs) { + bool DidChange = false; + for (UserValue *UV = lookupVirtReg(OldReg); UV; UV = UV->getNext()) + DidChange |= UV->splitRegister(OldReg, NewRegs); + + if (!DidChange) + return; + + // Map all of the new virtual registers. + UserValue *UV = lookupVirtReg(OldReg); + for (unsigned i = 0; i != NewRegs.size(); ++i) + mapVirtReg(NewRegs[i]->reg, UV); +} + +void LiveDebugVariables:: +splitRegister(unsigned OldReg, ArrayRef NewRegs) { + if (pImpl) + static_cast(pImpl)->splitRegister(OldReg, NewRegs); +} + void UserValue::rewriteLocations(VirtRegMap &VRM, const TargetRegisterInfo &TRI) { // Iterate over locations in reverse makes it easier to handle coalescing. Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.h?rev=130998&r1=130997&r2=130998&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.h (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.h Fri May 6 13:00:02 2011 @@ -21,10 +21,12 @@ #ifndef LLVM_CODEGEN_LIVEDEBUGVARIABLES_H #define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/CodeGen/MachineFunctionPass.h" namespace llvm { +class LiveInterval; class VirtRegMap; class LiveDebugVariables : public MachineFunctionPass { @@ -42,6 +44,11 @@ /// register. void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx); + /// splitRegister - Move any user variables in OldReg to the live ranges in + /// NewRegs where they are live. Mark the values as unavailable where no new + /// register is live. + void splitRegister(unsigned OldReg, ArrayRef NewRegs); + /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes /// that happened during register allocation. /// @param VRM Rename virtual registers according to map. Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=130998&r1=130997&r2=130998&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Fri May 6 13:00:02 2011 @@ -18,8 +18,9 @@ #ifndef LLVM_CODEGEN_LIVERANGEEDIT_H #define LLVM_CODEGEN_LIVERANGEEDIT_H -#include "llvm/CodeGen/LiveInterval.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallPtrSet.h" +#include "llvm/CodeGen/LiveInterval.h" namespace llvm { @@ -113,6 +114,10 @@ bool empty() const { return size() == 0; } LiveInterval *get(unsigned idx) const { return newRegs_[idx+firstNew_]; } + ArrayRef regs() const { + return ArrayRef(newRegs_).slice(firstNew_); + } + /// FIXME: Temporary accessors until we can get rid of /// LiveIntervals::AddIntervalsForSpills SmallVectorImpl *getNewVRegs() { return &newRegs_; } Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=130998&r1=130997&r2=130998&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Fri May 6 13:00:02 2011 @@ -72,6 +72,7 @@ MachineLoopRanges *LoopRanges; EdgeBundles *Bundles; SpillPlacement *SpillPlacer; + LiveDebugVariables *DebugVars; // state std::auto_ptr SpillerInstance; @@ -920,6 +921,8 @@ SmallVector IntvMap; SE->finish(&IntvMap); + DebugVars->splitRegister(VirtReg.reg, LREdit.regs()); + LRStage.resize(MRI->getNumVirtRegs()); unsigned OrigBlocks = SA->getNumThroughBlocks() + SA->getUseBlocks().size(); @@ -1284,6 +1287,7 @@ SlotIndex SegStop = SE->leaveIntvAfter(Uses[BestAfter]); SE->useIntv(SegStart, SegStop); SE->finish(); + DebugVars->splitRegister(VirtReg.reg, LREdit.regs()); setStage(NewVRegs.begin(), NewVRegs.end(), RS_Local); ++NumLocalSplits; @@ -1415,6 +1419,7 @@ LoopRanges = &getAnalysis(); Bundles = &getAnalysis(); SpillPlacer = &getAnalysis(); + DebugVars = &getAnalysis(); SA.reset(new SplitAnalysis(*VRM, *LIS, *Loops)); SE.reset(new SplitEditor(*SA, *LIS, *VRM, *DomTree)); @@ -1433,7 +1438,7 @@ } // Write out new DBG_VALUE instructions. - getAnalysis().emitDebugValues(VRM); + DebugVars->emitDebugValues(VRM); // The pass output is in VirtRegMap. Release all the transient data. releaseMemory(); From rafael.espindola at gmail.com Fri May 6 13:01:58 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 06 May 2011 18:01:58 -0000 Subject: [llvm-commits] [llvm] r130999 - in /llvm/trunk/test: FrontendC++/2006-11-30-Pubnames.cpp FrontendC/2009-02-17-BitField-dbg.c FrontendC/2010-01-14-StaticVariable.c FrontendC/2010-02-16-DbgVarScope.c FrontendObjC/2009-08-17-DebugInfo.m Message-ID: <20110506180158.A61AF2A6C12C@llvm.org> Author: rafael Date: Fri May 6 13:01:58 2011 New Revision: 130999 URL: http://llvm.org/viewvc/llvm-project?rev=130999&view=rev Log: Pass -disable-cfi to llc. Modified: llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m 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=130999&r1=130998&r2=130999&view=diff ============================================================================== --- llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp (original) +++ llvm/trunk/test/FrontendC++/2006-11-30-Pubnames.cpp Fri May 6 13:01:58 2011 @@ -1,7 +1,7 @@ // 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 - | \ -// RUN: llc --disable-fp-elim -o %t.s -O0 +// RUN: llc -disable-cfi --disable-fp-elim -o %t.s -O0 // RUN: %compile_c %t.s -o %t.o // RUN: %link %t.o -o %t.exe // RUN: %llvmdsymutil %t.exe 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=130999&r1=130998&r2=130999&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c (original) +++ llvm/trunk/test/FrontendC/2009-02-17-BitField-dbg.c Fri May 6 13:01:58 2011 @@ -1,6 +1,6 @@ // Check bitfields. // RUN: %llvmgcc -S -O0 -g %s -o - | \ -// RUN: llc --disable-fp-elim -o 2009-02-17-BitField-dbg.s +// RUN: llc -disable-cfi --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 // RUN: gdb -q -batch -n -x %t2 2009-02-17-BitField-dbg.o | \ Modified: llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c?rev=130999&r1=130998&r2=130999&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c (original) +++ llvm/trunk/test/FrontendC/2010-01-14-StaticVariable.c Fri May 6 13:01:58 2011 @@ -1,7 +1,7 @@ // This is a regression test on debug info to make sure that llvm emitted // debug info does not crash gdb. // RUN: %llvmgcc -S -O0 -g %s -o - | \ -// RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic +// RUN: llc -disable-cfi --disable-fp-elim -o %t.s -O0 -relocation-model=pic // RUN: %compile_c %t.s -o %t.o // RUN: echo {quit\n} > %t.in // RUN: gdb -q -batch -n -x %t.in %t.o > /dev/null Modified: llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c?rev=130999&r1=130998&r2=130999&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c (original) +++ llvm/trunk/test/FrontendC/2010-02-16-DbgVarScope.c Fri May 6 13:01:58 2011 @@ -1,5 +1,5 @@ // RUN: %llvmgcc -S -O0 -g %s -o - | \ -// RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic +// RUN: llc -disable-cfi --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 // RUN: echo {break 24\nrun\np loc\n} > %t.in 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=130999&r1=130998&r2=130999&view=diff ============================================================================== --- llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m (original) +++ llvm/trunk/test/FrontendObjC/2009-08-17-DebugInfo.m Fri May 6 13:01:58 2011 @@ -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 - | llc -o %t.s -O0 +// RUN: %llvmgcc -S -O0 -g %s -o - | llc -disable-cfi -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 From atrick at apple.com Fri May 6 13:14:32 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 06 May 2011 18:14:32 -0000 Subject: [llvm-commits] [llvm] r131001 - /llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Message-ID: <20110506181433.05AA72A6C12C@llvm.org> Author: atrick Date: Fri May 6 13:14:32 2011 New Revision: 131001 URL: http://llvm.org/viewvc/llvm-project?rev=131001&view=rev Log: Typo: Reviewed by Alistair. 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=131001&r1=131000&r2=131001&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp (original) +++ llvm/trunk/lib/CodeGen/PostRASchedulerList.cpp Fri May 6 13:14:32 2011 @@ -540,7 +540,7 @@ #endif --SuccSU->NumPredsLeft; - // Standard scheduler algorithms will recomute the depth of the successor + // Standard scheduler algorithms will recompute the depth of the successor // here as such: // SuccSU->setDepthToAtLeast(SU->getDepth() + SuccEdge->getLatency()); // From gkistanova at gmail.com Fri May 6 13:24:46 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Fri, 06 May 2011 18:24:46 -0000 Subject: [llvm-commits] [llvm] r131002 - in /llvm/trunk/test: DebugInfo/X86/ DebugInfo/X86/dg.exp DebugInfo/X86/stmt-list.ll DebugInfo/stmt-list.ll Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll Transforms/LoopStrengthReduce/X86/ Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll Transforms/LoopStrengthReduce/X86/dg.exp Transforms/TailDup/X86/ Transforms/TailDup/X86/dg.exp Transforms/TailDup/X86/if-tail-dup.ll Transforms/TailDup/if-tail-dup.ll Message-ID: <20110506182446.E1BB92A6C12C@llvm.org> Author: gkistanova Date: Fri May 6 13:24:46 2011 New Revision: 131002 URL: http://llvm.org/viewvc/llvm-project?rev=131002&view=rev Log: Move few target-dependant tests to appropriate directories. Added: llvm/trunk/test/DebugInfo/X86/ llvm/trunk/test/DebugInfo/X86/dg.exp llvm/trunk/test/DebugInfo/X86/stmt-list.ll llvm/trunk/test/Transforms/LoopStrengthReduce/X86/ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll llvm/trunk/test/Transforms/LoopStrengthReduce/X86/dg.exp llvm/trunk/test/Transforms/TailDup/X86/ llvm/trunk/test/Transforms/TailDup/X86/dg.exp llvm/trunk/test/Transforms/TailDup/X86/if-tail-dup.ll Removed: llvm/trunk/test/DebugInfo/stmt-list.ll llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll llvm/trunk/test/Transforms/TailDup/if-tail-dup.ll Added: llvm/trunk/test/DebugInfo/X86/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dg.exp?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/X86/dg.exp (added) +++ llvm/trunk/test/DebugInfo/X86/dg.exp Fri May 6 13:24:46 2011 @@ -0,0 +1,5 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} Added: llvm/trunk/test/DebugInfo/X86/stmt-list.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/stmt-list.ll?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/X86/stmt-list.ll (added) +++ llvm/trunk/test/DebugInfo/X86/stmt-list.ll Fri May 6 13:24:46 2011 @@ -0,0 +1,19 @@ +; RUN: llc -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s + +; CHECK: .section .debug_line,"", at progbits +; CHECK-NEXT: .Lsection_line: + +; CHECK: .long .Lsection_line # DW_AT_stmt_list + +define void @f() { +entry: + ret void +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @f, null, null} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} Removed: llvm/trunk/test/DebugInfo/stmt-list.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/stmt-list.ll?rev=131001&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/stmt-list.ll (original) +++ llvm/trunk/test/DebugInfo/stmt-list.ll (removed) @@ -1,19 +0,0 @@ -; RUN: llc -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s - -; CHECK: .section .debug_line,"", at progbits -; CHECK-NEXT: .Lsection_line: - -; CHECK: .long .Lsection_line # DW_AT_stmt_list - -define void @f() { -entry: - ret void -} - -!llvm.dbg.sp = !{!0} - -!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"f", metadata !"f", metadata !"", metadata !1, i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 true, void ()* @f, null, null} ; [ DW_TAG_subprogram ] -!1 = metadata !{i32 589865, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !2} ; [ DW_TAG_file_type ] -!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"test2.c", metadata !"/home/espindola/llvm", metadata !"clang version 3.0 ()", i1 true, i1 true, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -!4 = metadata !{null} Removed: llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll?rev=131001&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll (original) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/2009-11-10-LSRCrash.ll (removed) @@ -1,130 +0,0 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin11 - -define void @_ZN4llvm20SelectionDAGLowering14visitInlineAsmENS_8CallSiteE() nounwind ssp align 2 { -entry: - br i1 undef, label %bb3.i, label %bb4.i - -bb3.i: ; preds = %entry - unreachable - -bb4.i: ; preds = %entry - br i1 undef, label %bb.i.i, label %_ZNK4llvm8CallSite14getCalledValueEv.exit - -bb.i.i: ; preds = %bb4.i - unreachable - -_ZNK4llvm8CallSite14getCalledValueEv.exit: ; preds = %bb4.i - br i1 undef, label %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit, label %bb6.i - -bb6.i: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit - unreachable - -_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit - br i1 undef, label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit, label %bb.i - -bb.i: ; preds = %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit - br label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit - -_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit: ; preds = %bb.i, %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit - br i1 undef, label %bb50, label %bb27 - -bb27: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit - br i1 undef, label %bb1.i727, label %bb.i.i726 - -bb.i.i726: ; preds = %bb27 - unreachable - -bb1.i727: ; preds = %bb27 - unreachable - -bb50: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit - br label %bb107 - -bb51: ; preds = %bb107 - br i1 undef, label %bb105, label %bb106 - -bb105: ; preds = %bb51 - unreachable - -bb106: ; preds = %bb51 - br label %bb107 - -bb107: ; preds = %bb106, %bb50 - br i1 undef, label %bb108, label %bb51 - -bb108: ; preds = %bb107 - br i1 undef, label %bb242, label %bb114 - -bb114: ; preds = %bb108 - br i1 undef, label %bb141, label %bb116 - -bb116: ; preds = %bb114 - br i1 undef, label %bb120, label %bb121 - -bb120: ; preds = %bb116 - unreachable - -bb121: ; preds = %bb116 - unreachable - -bb141: ; preds = %bb114 - br i1 undef, label %bb182, label %bb143 - -bb143: ; preds = %bb141 - br label %bb157 - -bb144: ; preds = %bb.i.i.i843 - switch i32 undef, label %bb155 [ - i32 2, label %bb153 - i32 6, label %bb153 - i32 4, label %bb153 - ] - -bb153: ; preds = %bb144, %bb144, %bb144 - %indvar.next = add i32 %indvar, 1 ; [#uses=1] - br label %bb157 - -bb155: ; preds = %bb144 - unreachable - -bb157: ; preds = %bb153, %bb143 - %indvar = phi i32 [ %indvar.next, %bb153 ], [ 0, %bb143 ] ; [#uses=2] - %0 = icmp eq i32 undef, %indvar ; [#uses=1] - switch i16 undef, label %bb6.i841 [ - i16 9, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit - i16 26, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit - ] - -bb6.i841: ; preds = %bb157 - unreachable - -_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit: ; preds = %bb157, %bb157 - br i1 undef, label %bb.i.i.i843, label %bb1.i.i.i844 - -bb.i.i.i843: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit - br i1 %0, label %bb158, label %bb144 - -bb1.i.i.i844: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit - unreachable - -bb158: ; preds = %bb.i.i.i843 - br i1 undef, label %bb177, label %bb176 - -bb176: ; preds = %bb158 - unreachable - -bb177: ; preds = %bb158 - br i1 undef, label %bb179, label %bb178 - -bb178: ; preds = %bb177 - unreachable - -bb179: ; preds = %bb177 - unreachable - -bb182: ; preds = %bb141 - unreachable - -bb242: ; preds = %bb108 - unreachable -} Added: llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/2009-11-10-LSRCrash.ll Fri May 6 13:24:46 2011 @@ -0,0 +1,130 @@ +; RUN: llc < %s -mtriple=i386-apple-darwin11 + +define void @_ZN4llvm20SelectionDAGLowering14visitInlineAsmENS_8CallSiteE() nounwind ssp align 2 { +entry: + br i1 undef, label %bb3.i, label %bb4.i + +bb3.i: ; preds = %entry + unreachable + +bb4.i: ; preds = %entry + br i1 undef, label %bb.i.i, label %_ZNK4llvm8CallSite14getCalledValueEv.exit + +bb.i.i: ; preds = %bb4.i + unreachable + +_ZNK4llvm8CallSite14getCalledValueEv.exit: ; preds = %bb4.i + br i1 undef, label %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit, label %bb6.i + +bb6.i: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit + unreachable + +_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit: ; preds = %_ZNK4llvm8CallSite14getCalledValueEv.exit + br i1 undef, label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit, label %bb.i + +bb.i: ; preds = %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit + br label %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + +_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit: ; preds = %bb.i, %_ZN4llvm4castINS_9InlineAsmEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_.exit + br i1 undef, label %bb50, label %bb27 + +bb27: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + br i1 undef, label %bb1.i727, label %bb.i.i726 + +bb.i.i726: ; preds = %bb27 + unreachable + +bb1.i727: ; preds = %bb27 + unreachable + +bb50: ; preds = %_ZL25hasInlineAsmMemConstraintRSt6vectorIN4llvm9InlineAsm14ConstraintInfoESaIS2_EERKNS0_14TargetLoweringE.exit + br label %bb107 + +bb51: ; preds = %bb107 + br i1 undef, label %bb105, label %bb106 + +bb105: ; preds = %bb51 + unreachable + +bb106: ; preds = %bb51 + br label %bb107 + +bb107: ; preds = %bb106, %bb50 + br i1 undef, label %bb108, label %bb51 + +bb108: ; preds = %bb107 + br i1 undef, label %bb242, label %bb114 + +bb114: ; preds = %bb108 + br i1 undef, label %bb141, label %bb116 + +bb116: ; preds = %bb114 + br i1 undef, label %bb120, label %bb121 + +bb120: ; preds = %bb116 + unreachable + +bb121: ; preds = %bb116 + unreachable + +bb141: ; preds = %bb114 + br i1 undef, label %bb182, label %bb143 + +bb143: ; preds = %bb141 + br label %bb157 + +bb144: ; preds = %bb.i.i.i843 + switch i32 undef, label %bb155 [ + i32 2, label %bb153 + i32 6, label %bb153 + i32 4, label %bb153 + ] + +bb153: ; preds = %bb144, %bb144, %bb144 + %indvar.next = add i32 %indvar, 1 ; [#uses=1] + br label %bb157 + +bb155: ; preds = %bb144 + unreachable + +bb157: ; preds = %bb153, %bb143 + %indvar = phi i32 [ %indvar.next, %bb153 ], [ 0, %bb143 ] ; [#uses=2] + %0 = icmp eq i32 undef, %indvar ; [#uses=1] + switch i16 undef, label %bb6.i841 [ + i16 9, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + i16 26, label %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + ] + +bb6.i841: ; preds = %bb157 + unreachable + +_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit: ; preds = %bb157, %bb157 + br i1 undef, label %bb.i.i.i843, label %bb1.i.i.i844 + +bb.i.i.i843: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + br i1 %0, label %bb158, label %bb144 + +bb1.i.i.i844: ; preds = %_ZN4llvm4castINS_14ConstantSDNodeENS_7SDValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS5_.exit + unreachable + +bb158: ; preds = %bb.i.i.i843 + br i1 undef, label %bb177, label %bb176 + +bb176: ; preds = %bb158 + unreachable + +bb177: ; preds = %bb158 + br i1 undef, label %bb179, label %bb178 + +bb178: ; preds = %bb177 + unreachable + +bb179: ; preds = %bb177 + unreachable + +bb182: ; preds = %bb141 + unreachable + +bb242: ; preds = %bb108 + unreachable +} Added: llvm/trunk/test/Transforms/LoopStrengthReduce/X86/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/X86/dg.exp?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/X86/dg.exp (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/X86/dg.exp Fri May 6 13:24:46 2011 @@ -0,0 +1,5 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} Added: llvm/trunk/test/Transforms/TailDup/X86/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailDup/X86/dg.exp?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailDup/X86/dg.exp (added) +++ llvm/trunk/test/Transforms/TailDup/X86/dg.exp Fri May 6 13:24:46 2011 @@ -0,0 +1,5 @@ +load_lib llvm.exp + +if { [llvm_supports_target X86] } { + RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] +} Added: llvm/trunk/test/Transforms/TailDup/X86/if-tail-dup.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailDup/X86/if-tail-dup.ll?rev=131002&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailDup/X86/if-tail-dup.ll (added) +++ llvm/trunk/test/Transforms/TailDup/X86/if-tail-dup.ll Fri May 6 13:24:46 2011 @@ -0,0 +1,49 @@ +; RUN: opt < %s -tailduplicate | \ +; RUN: llc -march=x86 -o %t +; RUN: grep {\\\} %t +; RUN: not grep jmp %t +; END. +; This should have no unconditional jumps in it. The C source is: + +;void foo(int c, int* P) { +; if (c & 1) P[0] = 1; +; if (c & 2) P[1] = 1; +; if (c & 4) P[2] = 1; +; if (c & 8) P[3] = 1; +;} + +define void @foo(i32 %c, i32* %P) { +entry: + %tmp1 = and i32 %c, 1 ; [#uses=1] + %tmp1.upgrd.1 = icmp eq i32 %tmp1, 0 ; [#uses=1] + br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true +cond_true: ; preds = %entry + store i32 1, i32* %P + br label %cond_next +cond_next: ; preds = %cond_true, %entry + %tmp5 = and i32 %c, 2 ; [#uses=1] + %tmp5.upgrd.2 = icmp eq i32 %tmp5, 0 ; [#uses=1] + br i1 %tmp5.upgrd.2, label %cond_next10, label %cond_true6 +cond_true6: ; preds = %cond_next + %tmp8 = getelementptr i32* %P, i32 1 ; [#uses=1] + store i32 1, i32* %tmp8 + br label %cond_next10 +cond_next10: ; preds = %cond_true6, %cond_next + %tmp13 = and i32 %c, 4 ; [#uses=1] + %tmp13.upgrd.3 = icmp eq i32 %tmp13, 0 ; [#uses=1] + br i1 %tmp13.upgrd.3, label %cond_next18, label %cond_true14 +cond_true14: ; preds = %cond_next10 + %tmp16 = getelementptr i32* %P, i32 2 ; [#uses=1] + store i32 1, i32* %tmp16 + br label %cond_next18 +cond_next18: ; preds = %cond_true14, %cond_next10 + %tmp21 = and i32 %c, 8 ; [#uses=1] + %tmp21.upgrd.4 = icmp eq i32 %tmp21, 0 ; [#uses=1] + br i1 %tmp21.upgrd.4, label %return, label %cond_true22 +cond_true22: ; preds = %cond_next18 + %tmp24 = getelementptr i32* %P, i32 3 ; [#uses=1] + store i32 1, i32* %tmp24 + ret void +return: ; preds = %cond_next18 + ret void +} Removed: llvm/trunk/test/Transforms/TailDup/if-tail-dup.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailDup/if-tail-dup.ll?rev=131001&view=auto ============================================================================== --- llvm/trunk/test/Transforms/TailDup/if-tail-dup.ll (original) +++ llvm/trunk/test/Transforms/TailDup/if-tail-dup.ll (removed) @@ -1,49 +0,0 @@ -; RUN: opt < %s -tailduplicate | \ -; RUN: llc -march=x86 -o %t -; RUN: grep {\\\} %t -; RUN: not grep jmp %t -; END. -; This should have no unconditional jumps in it. The C source is: - -;void foo(int c, int* P) { -; if (c & 1) P[0] = 1; -; if (c & 2) P[1] = 1; -; if (c & 4) P[2] = 1; -; if (c & 8) P[3] = 1; -;} - -define void @foo(i32 %c, i32* %P) { -entry: - %tmp1 = and i32 %c, 1 ; [#uses=1] - %tmp1.upgrd.1 = icmp eq i32 %tmp1, 0 ; [#uses=1] - br i1 %tmp1.upgrd.1, label %cond_next, label %cond_true -cond_true: ; preds = %entry - store i32 1, i32* %P - br label %cond_next -cond_next: ; preds = %cond_true, %entry - %tmp5 = and i32 %c, 2 ; [#uses=1] - %tmp5.upgrd.2 = icmp eq i32 %tmp5, 0 ; [#uses=1] - br i1 %tmp5.upgrd.2, label %cond_next10, label %cond_true6 -cond_true6: ; preds = %cond_next - %tmp8 = getelementptr i32* %P, i32 1 ; [#uses=1] - store i32 1, i32* %tmp8 - br label %cond_next10 -cond_next10: ; preds = %cond_true6, %cond_next - %tmp13 = and i32 %c, 4 ; [#uses=1] - %tmp13.upgrd.3 = icmp eq i32 %tmp13, 0 ; [#uses=1] - br i1 %tmp13.upgrd.3, label %cond_next18, label %cond_true14 -cond_true14: ; preds = %cond_next10 - %tmp16 = getelementptr i32* %P, i32 2 ; [#uses=1] - store i32 1, i32* %tmp16 - br label %cond_next18 -cond_next18: ; preds = %cond_true14, %cond_next10 - %tmp21 = and i32 %c, 8 ; [#uses=1] - %tmp21.upgrd.4 = icmp eq i32 %tmp21, 0 ; [#uses=1] - br i1 %tmp21.upgrd.4, label %return, label %cond_true22 -cond_true22: ; preds = %cond_next18 - %tmp24 = getelementptr i32* %P, i32 3 ; [#uses=1] - store i32 1, i32* %tmp24 - ret void -return: ; preds = %cond_next18 - ret void -} From grosbach at apple.com Fri May 6 13:39:28 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 06 May 2011 18:39:28 -0000 Subject: [llvm-commits] [llvm] r131004 - /llvm/trunk/utils/TableGen/TableGen.cpp Message-ID: <20110506183928.DB13A2A6C12C@llvm.org> Author: grosbach Date: Fri May 6 13:39:28 2011 New Revision: 131004 URL: http://llvm.org/viewvc/llvm-project?rev=131004&view=rev Log: ParseFile() may throw, so extend the try/catch to handle that. Modified: llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=131004&r1=131003&r2=131004&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Fri May 6 13:39:28 2011 @@ -228,19 +228,19 @@ cl::ParseCommandLineOptions(argc, argv); - // Parse the input file. - if (ParseFile(InputFilename, IncludeDirs, SrcMgr, Records)) - return 1; - - std::string Error; - tool_output_file Out(OutputFilename.c_str(), Error); - if (!Error.empty()) { - errs() << argv[0] << ": error opening " << OutputFilename - << ":" << Error << "\n"; - return 1; - } - try { + // Parse the input file. + if (ParseFile(InputFilename, IncludeDirs, SrcMgr, Records)) + return 1; + + std::string Error; + tool_output_file Out(OutputFilename.c_str(), Error); + if (!Error.empty()) { + errs() << argv[0] << ": error opening " << OutputFilename + << ":" << Error << "\n"; + return 1; + } + switch (Action) { case PrintRecords: Out.os() << Records; // No argument, dump all contents From grosbach at apple.com Fri May 6 13:47:45 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 06 May 2011 18:47:45 -0000 Subject: [llvm-commits] [llvm] r131005 - /llvm/trunk/utils/TableGen/Record.cpp Message-ID: <20110506184745.B92A52A6C12C@llvm.org> Author: grosbach Date: Fri May 6 13:47:45 2011 New Revision: 131005 URL: http://llvm.org/viewvc/llvm-project?rev=131005&view=rev Log: Improve diagnostics for some parse errors. Not asserting when a user input error is detected is a good thing. Modified: llvm/trunk/utils/TableGen/Record.cpp Modified: llvm/trunk/utils/TableGen/Record.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=131005&r1=131004&r2=131005&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.cpp (original) +++ llvm/trunk/utils/TableGen/Record.cpp Fri May 6 13:47:45 2011 @@ -583,9 +583,7 @@ if (Record *D = (CurRec->getRecords()).getDef(Name)) return new DefInit(D); - errs() << "Variable not defined: '" + Name + "'\n"; - assert(0 && "Variable not found"); - return 0; + throw TGError(CurRec->getLoc(), "Undefined reference:'" + Name + "'\n"); } } break; @@ -813,15 +811,13 @@ OpInit *RHSo = dynamic_cast(RHS); if (!RHSo) { - errs() << "!foreach requires an operator\n"; - assert(0 && "No operator for !foreach"); + throw TGError(CurRec->getLoc(), "!foreach requires an operator\n"); } TypedInit *LHSt = dynamic_cast(LHS); if (!LHSt) { - errs() << "!foreach requires typed variable\n"; - assert(0 && "No typed variable for !foreach"); + throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n"); } if ((MHSd && DagType) || (MHSl && ListType)) { From grosbach at apple.com Fri May 6 14:00:22 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 06 May 2011 12:00:22 -0700 Subject: [llvm-commits] Fwd: [PATCHES] fix duplication and FIXMEs in JIT code In-Reply-To: References: Message-ID: <435AECFF-2C0B-42BB-865C-05ECEA9080F5@apple.com> Looks reasonable to me. Thanks! -Jim On Apr 24, 2011, at 3:20 PM, nobled wrote: > Whoops, forgot to join the mailing list, so this got stuck in the > moderation queue... > > ---------- Forwarded message ---------- > From: nobled > Date: Sun, Apr 24, 2011 at 11:05 AM > Subject: [PATCHES] fix duplication and FIXMEs in JIT code > To: llvm-commits at cs.uiuc.edu > > > (Just so you know, I do have commit access.) > > These patches address this comment from the MCJIT code: > > // FIXME: This should be lifted out of here, it isn't something which should > // be part of the JIT policy, rather the burden for this selection should be > // pushed to clients. > ==== > [PATCH 1/3] ExecutionEngine: fix JIT/MCJIT selectTarget() duplication > > (Merges the near-identical files lib/EE/JIT/TargetSelect.cpp and > lib/EE/MCJIT/TargetSelect.cpp into lib/EE/TargetSelect.cpp.) > > This prepares for making JITCtor/MCJITCtor take a > TargetMachine* directly from clients like EngineBuilder. > ==== > [PATCH 2/3] ExecutionEngine: push TargetMachine creation into clients > > In particular, into EngineBuilder. This should only impact > the private API between the EE and EB classes, not external > clients, since JITCtor and MCJITCtor are both protected members. > ==== > [PATCH 3/3] ExecutionEngine: move createJIT definition > > As an ExecutionEngine class function, its definition > really belongs in ExecutionEngine.cpp instead of in JIT.cpp. > ==== > > As for this comment: > > // Try to register the program as a source of symbols to resolve against. > // > // FIXME: Don't do this here. > sys::DynamicLibrary::LoadLibraryPermanently(0, NULL); > > where in the stack *should* that go, ideally? > <0001-ExecutionEngine-fix-JIT-MCJIT-selectTarget-duplicati.patch.txt><0002-ExecutionEngine-push-TargetMachine-creation-into-cli.patch.txt><0003-ExecutionEngine-move-createJIT-definition.patch.txt>_______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From aggarwa4 at illinois.edu Fri May 6 14:26:18 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Fri, 06 May 2011 19:26:18 -0000 Subject: [llvm-commits] [poolalloc] r131006 - in /poolalloc/trunk: include/assistDS/ lib/AssistDS/ Message-ID: <20110506192618.A7DAE2A6C12C@llvm.org> Author: aggarwa4 Date: Fri May 6 14:26:18 2011 New Revision: 131006 URL: http://llvm.org/viewvc/llvm-project?rev=131006&view=rev Log: Split pass definitions into separate header files. Added: poolalloc/trunk/include/assistDS/ArgCast.h poolalloc/trunk/include/assistDS/FuncSpec.h poolalloc/trunk/include/assistDS/GEPExprArgs.h poolalloc/trunk/include/assistDS/Int2PtrCmp.h poolalloc/trunk/include/assistDS/LoadArgs.h poolalloc/trunk/include/assistDS/MergeGEP.h poolalloc/trunk/include/assistDS/SimplifyExtractValue.h poolalloc/trunk/include/assistDS/SimplifyGEP.h poolalloc/trunk/include/assistDS/SimplifyInsertValue.h poolalloc/trunk/include/assistDS/StructReturnToPointer.h poolalloc/trunk/include/assistDS/VarArgsFunc.h poolalloc/trunk/lib/AssistDS/GEPExprArgs.cpp poolalloc/trunk/lib/AssistDS/MergeGEP.cpp Removed: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp poolalloc/trunk/lib/AssistDS/MergeArrayIndexGEP.cpp Modified: poolalloc/trunk/lib/AssistDS/ArgCast.cpp poolalloc/trunk/lib/AssistDS/FuncSpec.cpp poolalloc/trunk/lib/AssistDS/Int2PtrCmp.cpp poolalloc/trunk/lib/AssistDS/LoadArgs.cpp poolalloc/trunk/lib/AssistDS/SimplifyExtractValue.cpp poolalloc/trunk/lib/AssistDS/SimplifyGEP.cpp poolalloc/trunk/lib/AssistDS/SimplifyInsertValue.cpp poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp poolalloc/trunk/lib/AssistDS/TypeAnalysis.cpp poolalloc/trunk/lib/AssistDS/VarArgsFunc.cpp Added: poolalloc/trunk/include/assistDS/ArgCast.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/ArgCast.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/ArgCast.h (added) +++ poolalloc/trunk/include/assistDS/ArgCast.h Fri May 6 14:26:18 2011 @@ -0,0 +1,34 @@ +//===-------- ArgCast.cpp - Cast Arguments to Calls -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// Convert +// call(bitcast (.., T1 arg, ...)F to(..., T2 arg, ...))(..., T2 val, ...) +// to +// val1 = bitcast T2 val to T1 +// call F (..., T1 val1, ...) +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: ArgCast + // + // Description: + // Implement an LLVM pass that cleans up call sites that take casted args + // + class ArgCast : public ModulePass { + public: + static char ID; + ArgCast() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/FuncSpec.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/FuncSpec.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/FuncSpec.h (added) +++ poolalloc/trunk/include/assistDS/FuncSpec.h Fri May 6 14:26:18 2011 @@ -0,0 +1,35 @@ +//===-- FuncSpec.cpp - Clone Functions With Constant Function Ptr Args ----===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass clones functions that take constant function pointers as arguments +// from some call sites. It changes those call sites to call cloned functions. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: FuncSpec + // + // Description: + // Implement an LLVM pass that clones functions which are passed + // as an argument + // + // + class FuncSpec : public ModulePass { + public: + static char ID; + FuncSpec() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/GEPExprArgs.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/GEPExprArgs.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/GEPExprArgs.h (added) +++ poolalloc/trunk/include/assistDS/GEPExprArgs.h Fri May 6 14:26:18 2011 @@ -0,0 +1,34 @@ +//===-- GEPExprArg.cpp - Promote args if they come from GEPs -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Identify GEPs used as arguments to call sites. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: GEPExprArgs + // + // Description: + // Implement an LLVM pass that clones functions which are passed GEPs + // as an argument + // + // + class GEPExprArgs : public ModulePass { + public: + static char ID; + GEPExprArgs() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/Int2PtrCmp.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/Int2PtrCmp.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/Int2PtrCmp.h (added) +++ poolalloc/trunk/include/assistDS/Int2PtrCmp.h Fri May 6 14:26:18 2011 @@ -0,0 +1,40 @@ +//===-- Int2PtrCmp.cpp - Merge inttoptr/ptrtoint --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Remove unnecessary inttoptr casts +// Specially ones used in just compares +// Most cases derived from InstCombine +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Target/TargetData.h" + + +namespace llvm { + // + // Class: Int2PtrCmp + // + // + class Int2PtrCmp : public ModulePass { + private: + TargetData * TD; + public: + static char ID; + Int2PtrCmp() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + } + + }; +} + Added: poolalloc/trunk/include/assistDS/LoadArgs.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/LoadArgs.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/LoadArgs.h (added) +++ poolalloc/trunk/include/assistDS/LoadArgs.h Fri May 6 14:26:18 2011 @@ -0,0 +1,36 @@ +//===-- LoadArgs.cpp - Promote args if they came from loads ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Identify calls, that are passed arguemtns that are LoadInsts. +// Pass the original pointer instead. Helps improve some +// context sensitivity. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: LoadArgs + // + // Description: + // Implement an LLVM pass that clones functions which are passed loads + // as an argument + // + // + class LoadArgs : public ModulePass { + public: + static char ID; + LoadArgs() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/MergeGEP.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/MergeGEP.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/MergeGEP.h (added) +++ poolalloc/trunk/include/assistDS/MergeGEP.h Fri May 6 14:26:18 2011 @@ -0,0 +1,30 @@ +//===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Merge chained GEPs; Specially useful for arrays inside structs +// +//===----------------------------------------------------------------------===// + +#include "llvm/Target/TargetData.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: MergeArrayGEP + // + class MergeArrayGEP : public ModulePass { + public: + static char ID; + MergeArrayGEP() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/SimplifyExtractValue.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyExtractValue.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/SimplifyExtractValue.h (added) +++ poolalloc/trunk/include/assistDS/SimplifyExtractValue.h Fri May 6 14:26:18 2011 @@ -0,0 +1,31 @@ +//===-- SimplifyExtractValue.cpp - Remove extraneous extractvalue insts----===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Simplify extractvalue +// +// Derived from InstCombine +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: SimplifyEV + // + class SimplifyEV : public ModulePass { + public: + static char ID; + SimplifyEV() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/SimplifyGEP.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyGEP.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/SimplifyGEP.h (added) +++ poolalloc/trunk/include/assistDS/SimplifyGEP.h Fri May 6 14:26:18 2011 @@ -0,0 +1,35 @@ +//===--------------- SimplifyGEP.cpp - Simplify GEPs types ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Simplify GEPs with bitcasts (mostly cloned from InstCombine) +// +//===----------------------------------------------------------------------===// + +#include "llvm/Target/TargetData.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: SimplifyGEP + // + class SimplifyGEP : public ModulePass { + private: + TargetData * TD; + public: + static char ID; + SimplifyGEP() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + } + }; +} + Added: poolalloc/trunk/include/assistDS/SimplifyInsertValue.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/SimplifyInsertValue.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/SimplifyInsertValue.h (added) +++ poolalloc/trunk/include/assistDS/SimplifyInsertValue.h Fri May 6 14:26:18 2011 @@ -0,0 +1,30 @@ +//===-- SimplifyInsertValue.cpp - Remove extraneous insertvalue insts------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Simplify insertvalue +// Replace insertvalue by storess where possible +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: SimplifyIV + // + class SimplifyIV : public ModulePass { + public: + static char ID; + SimplifyIV() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/StructReturnToPointer.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/StructReturnToPointer.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/StructReturnToPointer.h (added) +++ poolalloc/trunk/include/assistDS/StructReturnToPointer.h Fri May 6 14:26:18 2011 @@ -0,0 +1,30 @@ +//===-------- StructReturnToPointer.cpp ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// For functions that return structures, +// transform them to return a pointer to the structure instead. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: StructRet + // + class StructRet : public ModulePass { + public: + static char ID; + StructRet() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Added: poolalloc/trunk/include/assistDS/VarArgsFunc.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/VarArgsFunc.h?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/VarArgsFunc.h (added) +++ poolalloc/trunk/include/assistDS/VarArgsFunc.h Fri May 6 14:26:18 2011 @@ -0,0 +1,32 @@ +//===-- VarArgsFunc.cpp - Simplify calls to bitcasted const funcs --------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// Convert calls of type +// call(bitcast F to (...)*) () +// to +// call F() +// if the number and types of arguments passed matches. +//===----------------------------------------------------------------------===// + +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" + +namespace llvm { + // + // Class: VarArgsFunc + // + // + class VarArgsFunc : public ModulePass { + public: + static char ID; + VarArgsFunc() : ModulePass(&ID) {} + virtual bool runOnModule(Module& M); + }; +} + Modified: poolalloc/trunk/lib/AssistDS/ArgCast.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/ArgCast.cpp?rev=131006&r1=131005&r2=131006&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/ArgCast.cpp (original) +++ poolalloc/trunk/lib/AssistDS/ArgCast.cpp Fri May 6 14:26:18 2011 @@ -14,10 +14,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "argcast" -#include "llvm/Instructions.h" +#include "assistDS/ArgCast.h" #include "llvm/Attributes.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FormattedStream.h" @@ -32,144 +30,135 @@ // Pass statistics STATISTIC(numChanged, "Number of Args bitcasted"); -namespace { +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. +// Search for all call sites to casted functions. +// Check if they only differ in an argument type +// Cast the argument, and call the original function +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool ArgCast::runOnModule(Module& M) { + + std::vector worklist; + for (Module::iterator I = M.begin(); I != M.end(); ++I) + if (!I->isDeclaration() && !I->mayBeOverridden()) + // Find all uses of this function + for(Value::use_iterator ui = I->use_begin(), ue = I->use_end(); ui != ue; ++ui) + // check if is ever casted to a different function type + if (Constant *C = dyn_cast(ui)) + if (ConstantExpr *CE = dyn_cast(C)) + if (CE->getOpcode() == Instruction::BitCast) + if(CE->getOperand(0) == I) + if(const FunctionType *FTy = dyn_cast + ((cast(CE->getType()))->getElementType())) { + //casting to a varargs funtion + if(FTy->isVarArg()) + for(Value::use_iterator uii = CE->use_begin(), + uee = CE->use_end(); uii != uee; ++uii) { + // Find all uses of the casted value, and check if it is + // used in a Call Instruction + if (CallInst* CI = dyn_cast(uii)) { + // Check that it is the called value, and not an argument + if(CI->getCalledValue() != CE) + continue; + // Check that the number of arguments passed, and expected + // by the function are the same. + if(CI->getNumOperands() != I->arg_size() + 1) + continue; + // Check that the return type of the function matches that + // expected by the call inst(ensures that the reason for the + // cast is not the return type). + if(CI->getType() != I->getReturnType()) + continue; - class ArgCast : public ModulePass { - public: - static char ID; - ArgCast() : ModulePass(&ID) {} - - // - // Method: runOnModule() - // - // Description: - // Entry point for this LLVM pass. - // Search for all call sites to casted functions. - // Check if they only differ in an argument type - // Cast the argument, and call the original function - // - // Inputs: - // M - A reference to the LLVM module to transform - // - // Outputs: - // M - The transformed LLVM module. - // - // Return value: - // true - The module was modified. - // false - The module was not modified. - // - bool runOnModule(Module& M) { - - std::vector worklist; - for (Module::iterator I = M.begin(); I != M.end(); ++I) - if (!I->isDeclaration() && !I->mayBeOverridden()) - // Find all uses of this function - for(Value::use_iterator ui = I->use_begin(), ue = I->use_end(); ui != ue; ++ui) - // check if is ever casted to a different function type - if (Constant *C = dyn_cast(ui)) - if (ConstantExpr *CE = dyn_cast(C)) - if (CE->getOpcode() == Instruction::BitCast) - if(CE->getOperand(0) == I) - if(const FunctionType *FTy = dyn_cast - ((cast(CE->getType()))->getElementType())) { - //casting to a varargs funtion - if(FTy->isVarArg()) - for(Value::use_iterator uii = CE->use_begin(), - uee = CE->use_end(); uii != uee; ++uii) { - // Find all uses of the casted value, and check if it is - // used in a Call Instruction - if (CallInst* CI = dyn_cast(uii)) { - // Check that it is the called value, and not an argument - if(CI->getCalledValue() != CE) - continue; - // Check that the number of arguments passed, and expected - // by the function are the same. - if(CI->getNumOperands() != I->arg_size() + 1) - continue; - // Check that the return type of the function matches that - // expected by the call inst(ensures that the reason for the - // cast is not the return type). - if(CI->getType() != I->getReturnType()) - continue; - - // If so, add to worklist - worklist.push_back(CI); - } - } + // If so, add to worklist + worklist.push_back(CI); } - - // Proces the worklist of potential call sites to transform - while(!worklist.empty()) { - CallInst *CI = worklist.back(); - worklist.pop_back(); - // Get the called Function - Function *F = cast(CI->getCalledValue()->stripPointerCasts()); - const FunctionType *FTy = F->getFunctionType(); - - SmallVector Args; - unsigned i =0; - for(i =0; i< FTy->getNumParams(); ++i) { - const Type *ArgType = CI->getOperand(i+1)->getType(); - const Type *FormalType = FTy->getParamType(i); - // If the types for this argument match, just add it to the - // parameter list. No cast needs to be inserted. - if(ArgType == FormalType) { - Args.push_back(CI->getOperand(i+1)); - } - else if(ArgType->isPointerTy() && FormalType->isPointerTy()) { - CastInst *CastI = CastInst::CreatePointerCast(CI->getOperand(i+1), - FormalType, "", CI); + } + } + + // Proces the worklist of potential call sites to transform + while(!worklist.empty()) { + CallInst *CI = worklist.back(); + worklist.pop_back(); + // Get the called Function + Function *F = cast(CI->getCalledValue()->stripPointerCasts()); + const FunctionType *FTy = F->getFunctionType(); + + SmallVector Args; + unsigned i =0; + for(i =0; i< FTy->getNumParams(); ++i) { + const Type *ArgType = CI->getOperand(i+1)->getType(); + const Type *FormalType = FTy->getParamType(i); + // If the types for this argument match, just add it to the + // parameter list. No cast needs to be inserted. + if(ArgType == FormalType) { + Args.push_back(CI->getOperand(i+1)); + } + else if(ArgType->isPointerTy() && FormalType->isPointerTy()) { + CastInst *CastI = CastInst::CreatePointerCast(CI->getOperand(i+1), + FormalType, "", CI); + Args.push_back(CastI); + } else if (ArgType->isIntegerTy() && FormalType->isIntegerTy()) { + unsigned SrcBits = ArgType->getScalarSizeInBits(); + unsigned DstBits = FormalType->getScalarSizeInBits(); + if(SrcBits > DstBits) { + CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), + FormalType, true, "", CI); + Args.push_back(CastI); + } else { + if(F->paramHasAttr(i+1, Attribute::SExt)) { + CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), + FormalType, true, "", CI); + Args.push_back(CastI); + } else if(F->paramHasAttr(i+1, Attribute::ZExt)) { + CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), + FormalType, false, "", CI); Args.push_back(CastI); - } else if (ArgType->isIntegerTy() && FormalType->isIntegerTy()) { - unsigned SrcBits = ArgType->getScalarSizeInBits(); - unsigned DstBits = FormalType->getScalarSizeInBits(); - if(SrcBits > DstBits) { - CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), - FormalType, true, "", CI); - Args.push_back(CastI); - } else { - if(F->paramHasAttr(i+1, Attribute::SExt)) { - CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), - FormalType, true, "", CI); - Args.push_back(CastI); - } else if(F->paramHasAttr(i+1, Attribute::ZExt)) { - CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), - FormalType, false, "", CI); - Args.push_back(CastI); - } else { - // Use ZExt in default case. - // Derived from InstCombine. Also, the only reason this should happen - // is mismatched prototypes. - // Seen in case of integer constants which get interpreted as i32, - // even if being used as i64. - // TODO: is this correct? - CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), - FormalType, false, "", CI); - Args.push_back(CastI); - } - } } else { - DEBUG(ArgType->dump()); - DEBUG(FormalType->dump()); - break; - } - } - - // If we found an argument we could not cast, try the next instruction - if(i != FTy->getNumParams()) - continue; - - // else replace the call instruction - CallInst *CINew = CallInst::Create(F, Args.begin(), Args.end(), "", CI); - CINew->setCallingConv(CI->getCallingConv()); - CINew->setAttributes(CI->getAttributes()); - CI->replaceAllUsesWith(CINew); - CI->eraseFromParent(); - numChanged++; + // Use ZExt in default case. + // Derived from InstCombine. Also, the only reason this should happen + // is mismatched prototypes. + // Seen in case of integer constants which get interpreted as i32, + // even if being used as i64. + // TODO: is this correct? + CastInst *CastI = CastInst::CreateIntegerCast(CI->getOperand(i+1), + FormalType, false, "", CI); + Args.push_back(CastI); + } + } + } else { + DEBUG(ArgType->dump()); + DEBUG(FormalType->dump()); + break; } - return true; } - }; + + // If we found an argument we could not cast, try the next instruction + if(i != FTy->getNumParams()) + continue; + + // else replace the call instruction + CallInst *CINew = CallInst::Create(F, Args.begin(), Args.end(), "", CI); + CINew->setCallingConv(CI->getCallingConv()); + CINew->setAttributes(CI->getAttributes()); + CI->replaceAllUsesWith(CINew); + CI->eraseFromParent(); + numChanged++; + } + return true; } // Pass ID variable Modified: poolalloc/trunk/lib/AssistDS/FuncSpec.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/FuncSpec.cpp?rev=131006&r1=131005&r2=131006&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/FuncSpec.cpp (original) +++ poolalloc/trunk/lib/AssistDS/FuncSpec.cpp Fri May 6 14:26:18 2011 @@ -13,9 +13,8 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "funcspec" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" +#include "assistDS/FuncSpec.h" + #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FormattedStream.h" @@ -30,95 +29,87 @@ // Pass statistics STATISTIC(numCloned, "Number of Functions Cloned in FuncSpec"); STATISTIC(numReplaced, "Number of Calls Replaced"); - -namespace { - class FuncSpec : public ModulePass { - public: - static char ID; - FuncSpec() : ModulePass(&ID) {} - // - // Method: runOnModule() - // - // Description: - // Entry point for this LLVM pass. Search for call sites, that take functions as arguments - // Clone those functions, and pass the clone. - // - // Inputs: - // M - A reference to the LLVM module to transform - // - // Outputs: - // M - The transformed LLVM module. - // - // Return value: - // true - The module was modified. - // false - The module was not modified. - // - bool runOnModule(Module& M) { - std::map > > cloneSites; - std::map > >, Function* > toClone; - - for (Module::iterator I = M.begin(); I != M.end(); ++I) - if (!I->isDeclaration() && !I->mayBeOverridden()) { - std::vector FPArgs; - for (Function::arg_iterator ii = I->arg_begin(), ee = I->arg_end(); - ii != ee; ++ii) { - // check if this function has a FunctionType(or a pointer to) argument - if (const PointerType* Ty = dyn_cast(ii->getType())) { - if (isa(Ty->getElementType())) { - // Store the index of such an argument - FPArgs.push_back(ii->getArgNo()); - DEBUG(errs() << "Eligible: " << I->getNameStr() << "\n"); - } - } else if (isa(ii->getType())) { - // Store the index of such an argument - FPArgs.push_back(ii->getArgNo()); - DEBUG(errs() << "Eligible: " << I->getNameStr() << "\n"); - } +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. Search for call sites, that take functions as arguments +// Clone those functions, and pass the clone. +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool FuncSpec::runOnModule(Module& M) { + std::map > > cloneSites; + std::map > >, Function* > toClone; + + for (Module::iterator I = M.begin(); I != M.end(); ++I) + if (!I->isDeclaration() && !I->mayBeOverridden()) { + std::vector FPArgs; + for (Function::arg_iterator ii = I->arg_begin(), ee = I->arg_end(); + ii != ee; ++ii) { + // check if this function has a FunctionType(or a pointer to) argument + if (const PointerType* Ty = dyn_cast(ii->getType())) { + if (isa(Ty->getElementType())) { + // Store the index of such an argument + FPArgs.push_back(ii->getArgNo()); + DEBUG(errs() << "Eligible: " << I->getNameStr() << "\n"); } - // Now find all call sites that it is called from - for(Value::use_iterator ui = I->use_begin(), ue = I->use_end(); - ui != ue; ++ui) { - if (CallInst* CI = dyn_cast(ui)) { - // Check that it is the called value (and not an argument) - if(CI->getCalledValue()->stripPointerCasts() == I) { - std::vector > Consts; - for (unsigned x = 0; x < FPArgs.size(); ++x) - if (Constant* C = dyn_cast(ui->getOperand(FPArgs.at(x) + 1))) { - // If the argument passed, at any of the locations noted earlier - // is a constant function, store the pair - Consts.push_back(std::make_pair(FPArgs.at(x), C)); - } - if (!Consts.empty()) { - // If at least one of the arguments is a constant function, - // we must clone the function. - cloneSites[CI] = Consts; - toClone[std::make_pair(I, Consts)] = 0; - } + } else if (isa(ii->getType())) { + // Store the index of such an argument + FPArgs.push_back(ii->getArgNo()); + DEBUG(errs() << "Eligible: " << I->getNameStr() << "\n"); + } + } + // Now find all call sites that it is called from + for(Value::use_iterator ui = I->use_begin(), ue = I->use_end(); + ui != ue; ++ui) { + if (CallInst* CI = dyn_cast(ui)) { + // Check that it is the called value (and not an argument) + if(CI->getCalledValue()->stripPointerCasts() == I) { + std::vector > Consts; + for (unsigned x = 0; x < FPArgs.size(); ++x) + if (Constant* C = dyn_cast(ui->getOperand(FPArgs.at(x) + 1))) { + // If the argument passed, at any of the locations noted earlier + // is a constant function, store the pair + Consts.push_back(std::make_pair(FPArgs.at(x), C)); } + if (!Consts.empty()) { + // If at least one of the arguments is a constant function, + // we must clone the function. + cloneSites[CI] = Consts; + toClone[std::make_pair(I, Consts)] = 0; } } } - - numCloned += toClone.size(); - - for (std::map > >, Function* >::iterator I = toClone.begin(), E = toClone.end(); I != E; ++I) { - // Clone all the functions we need cloned - Function* DirectF = CloneFunction(I->first.first); - DirectF->setName(I->first.first->getNameStr() + "_SPEC"); - DirectF->setLinkage(GlobalValue::InternalLinkage); - I->first.first->getParent()->getFunctionList().push_back(DirectF); - I->second = DirectF; } + } - for (std::map > >::iterator ii = cloneSites.begin(), ee = cloneSites.end(); ii != ee; ++ii) { - // Transform the call sites, to call the clones - ii->first->setOperand(0, toClone[std::make_pair(cast(ii->first->getOperand(0)), ii->second)]); - ++numReplaced; - } + numCloned += toClone.size(); - return true; - } - }; + for (std::map > >, Function* >::iterator I = toClone.begin(), E = toClone.end(); I != E; ++I) { + // Clone all the functions we need cloned + Function* DirectF = CloneFunction(I->first.first); + DirectF->setName(I->first.first->getNameStr() + "_SPEC"); + DirectF->setLinkage(GlobalValue::InternalLinkage); + I->first.first->getParent()->getFunctionList().push_back(DirectF); + I->second = DirectF; + } + + for (std::map > >::iterator ii = cloneSites.begin(), ee = cloneSites.end(); ii != ee; ++ii) { + // Transform the call sites, to call the clones + ii->first->setOperand(0, toClone[std::make_pair(cast(ii->first->getOperand(0)), ii->second)]); + ++numReplaced; + } + + return true; } // Pass ID variable Removed: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp?rev=131005&view=auto ============================================================================== --- poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (original) +++ poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (removed) @@ -1,156 +0,0 @@ -//===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------ ----===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// -//===----------------------------------------------------------------------===// -#define DEBUG_TYPE "gepexprargs" - -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Instructions.h" -#include "llvm/Constants.h" -#include "llvm/Support/GetElementPtrTypeIterator.h" -#include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Debug.h" -#include "llvm/Use.h" -#include -#include - -using namespace llvm; -STATISTIC(numSimplified, "Number of Calls Modified"); - - -namespace { - class GEPExprArg : public ModulePass { - public: - static char ID; - GEPExprArg() : ModulePass(&ID) {} - bool runOnModule(Module& M) { - bool changed; - do { - changed = false; - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - CallInst *CI = dyn_cast(I++); - if(!CI) - continue; - - if(CI->hasByValArgument()) - continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); - - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; - - // find the argument we must replace - Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++, ++ai) { - if(ai->use_empty()) - continue; - if (isa(CI->getOperand(argNum))) - break; - } - - // if no argument was a GEP operator to be changed - if(ai == ae) - continue; - - GEPOperator *GEP = dyn_cast(CI->getOperand(argNum)); - if(!GEP->hasAllConstantIndices()) - continue; - - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(GEP->getPointerOperand()->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } - - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; - numSimplified++; - if(numSimplified > 800) - return true; - - NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } - - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - SmallVector Ops(CI->op_begin()+1, CI->op_end()); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - SmallVector Indices; - Indices.append(GEP->op_begin()+1, GEP->op_end()); - GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(GEP_new); - unsigned j = argNum + 1; - for(; j < CI->getNumOperands();j++) { - if(CI->getOperand(j) == GEP) - fargs.at(j)->replaceAllUsesWith(GEP_new); - } - - SmallVector Args; - Args.push_back(GEP->getPointerOperand()); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); - } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); - changed = true; - } - } - } - } while(changed); - return true; - } - }; -} - -char GEPExprArg::ID = 0; -static RegisterPass -X("gep-expr-arg", "Find GEP Exprs passed as args"); Added: poolalloc/trunk/lib/AssistDS/GEPExprArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArgs.cpp?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/lib/AssistDS/GEPExprArgs.cpp (added) +++ poolalloc/trunk/lib/AssistDS/GEPExprArgs.cpp Fri May 6 14:26:18 2011 @@ -0,0 +1,166 @@ +//===-- GEPExprArg.cpp - Promote args if they come from GEPs -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Identify GEPs used as arguments to call sites. +// +//===----------------------------------------------------------------------===// +#define DEBUG_TYPE "gepexprargs" + +#include "assistDS/GEPExprArgs.h" +#include "llvm/Constants.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Debug.h" +#include "llvm/Use.h" +#include +#include + +// Pass statistics +STATISTIC(numSimplified, "Number of Calls Modified"); + +using namespace llvm; + +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. +// Clone functions that take GEPs as arguments +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool GEPExprArgs::runOnModule(Module& M) { + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + CallInst *CI = dyn_cast(I++); + if(!CI) + continue; + + if(CI->hasByValArgument()) + continue; + // if the GEP calls a function, that is externally defined, + // or might be changed, ignore this call site. + Function *F = CI->getCalledFunction(); + + if (!F || (F->isDeclaration() || F->mayBeOverridden())) + continue; + if(F->hasStructRetAttr()) + continue; + if(F->isVarArg()) + continue; + + // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); + unsigned argNum = 1; + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) + continue; + if (isa(CI->getOperand(argNum))) + break; + } + + // if no argument was a GEP operator to be changed + if(ai == ae) + continue; + + GEPOperator *GEP = dyn_cast(CI->getOperand(argNum)); + if(!GEP->hasAllConstantIndices()) + continue; + + // Construct the new Type + // Appends the struct Type at the beginning + std::vectorTP; + TP.push_back(GEP->getPointerOperand()->getType()); + for(unsigned c = 1; c < CI->getNumOperands();c++) { + TP.push_back(CI->getOperand(c)->getType()); + } + + //return type is same as that of original instruction + const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); + Function *NewF; + numSimplified++; + if(numSimplified > 800) + return true; + + NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F->getNameStr() + ".TEST", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + NI->setName("Sarg"); + ++NI; + + DenseMap ValueMap; + + for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + ValueMap[II] = NI; + NI->setName(II->getName()); + } + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, F, ValueMap, Returns); + std::vector fargs; + for(Function::arg_iterator ai = NewF->arg_begin(), + ae= NewF->arg_end(); ai != ae; ++ai) { + fargs.push_back(ai); + } + + NewF->setAlignment(F->getAlignment()); + //Get the point to insert the GEP instr. + NI = NewF->arg_begin(); + SmallVector Ops(CI->op_begin()+1, CI->op_end()); + Instruction *InsertPoint; + for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} + + SmallVector Indices; + Indices.append(GEP->op_begin()+1, GEP->op_end()); + GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); + fargs.at(argNum)->replaceAllUsesWith(GEP_new); + unsigned j = argNum + 1; + for(; j < CI->getNumOperands();j++) { + if(CI->getOperand(j) == GEP) + fargs.at(j)->replaceAllUsesWith(GEP_new); + } + + SmallVector Args; + Args.push_back(GEP->getPointerOperand()); + for(unsigned j =1;jgetNumOperands();j++) { + Args.push_back(CI->getOperand(j)); + } + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); + changed = true; + } + } + } + } while(changed); + return true; +} + + +char GEPExprArgs::ID = 0; +static RegisterPass +X("gep-expr-arg", "Find GEP Exprs passed as args"); Modified: poolalloc/trunk/lib/AssistDS/Int2PtrCmp.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Int2PtrCmp.cpp?rev=131006&r1=131005&r2=131006&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/Int2PtrCmp.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Int2PtrCmp.cpp Fri May 6 14:26:18 2011 @@ -6,6 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// // Remove unnecessary inttoptr casts // Specially ones used in just compares // Most cases derived from InstCombine @@ -13,15 +14,11 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "int2ptr-cmp" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Transforms/Utils/Cloning.h" +#include "assistDS/Int2PtrCmp.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Debug.h" #include "llvm/Support/PatternMatch.h" -#include "llvm/Target/TargetData.h" #include #include @@ -30,71 +27,61 @@ using namespace llvm; using namespace PatternMatch; -namespace { - class Int2PtrCmp : public ModulePass { - private: - TargetData * TD; - public: - static char ID; - Int2PtrCmp() : ModulePass(&ID) {} - - // - // Method: runOnModule() - // - // Description: - // Entry point for this LLVM pass. - // Remove unnecessary inttoptr instructions. - // - // Inputs: - // M - A reference to the LLVM module to transform - // - // Outputs: - // M - The transformed LLVM module. - // - // Return value: - // true - The module was modified. - // false - The module was not modified. - // - bool runOnModule(Module& M) { - TD = &getAnalysis(); - for (Module::iterator F = M.begin(); F != M.end(); ++F) { - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - // ptrtoint(inttoptr ty Y) to ty -> Y - if(PtrToIntInst *P2I = dyn_cast(I++)) { - if(IntToPtrInst *I2P = dyn_cast(P2I->getOperand(0))) { - if(I2P->getSrcTy() == P2I->getDestTy()){ - P2I->replaceAllUsesWith(I2P->getOperand(0)); - P2I->eraseFromParent(); - if(I2P->use_empty()) { - // If this is the only use of the cast delete it. - I2P->eraseFromParent(); - } - } +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. +// Remove unnecessary inttoptr instructions. +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool Int2PtrCmp::runOnModule(Module& M) { + TD = &getAnalysis(); + for (Module::iterator F = M.begin(); F != M.end(); ++F) { + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + // ptrtoint(inttoptr ty Y) to ty -> Y + if(PtrToIntInst *P2I = dyn_cast(I++)) { + if(IntToPtrInst *I2P = dyn_cast(P2I->getOperand(0))) { + if(I2P->getSrcTy() == P2I->getDestTy()){ + P2I->replaceAllUsesWith(I2P->getOperand(0)); + P2I->eraseFromParent(); + if(I2P->use_empty()) { + // If this is the only use of the cast delete it. + I2P->eraseFromParent(); } } } - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - //icmp pred inttoptr(X), null -> icmp pred X 0 - if(ICmpInst *CI = dyn_cast(I++)) { - Value *Op0 = CI->getOperand(0); - Value *Op1 = CI->getOperand(1); - if (Constant *RHSC = dyn_cast(Op1)) { - if (Instruction *LHSI = dyn_cast(Op0)){ - if(LHSI->getOpcode() == Instruction::IntToPtr) { - if (RHSC->isNullValue() && TD && - TD->getIntPtrType(RHSC->getContext()) == - LHSI->getOperand(0)->getType()){ - ICmpInst *CI_new = new ICmpInst(CI, CI->getPredicate(), LHSI->getOperand(0), - Constant::getNullValue(LHSI->getOperand(0)->getType())); - - CI->replaceAllUsesWith(CI_new); - CI->eraseFromParent(); - if(LHSI->use_empty()) { - // If this is the only use of the cast delete it. - LHSI->eraseFromParent(); - } - } + } + } + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + //icmp pred inttoptr(X), null -> icmp pred X 0 + if(ICmpInst *CI = dyn_cast(I++)) { + Value *Op0 = CI->getOperand(0); + Value *Op1 = CI->getOperand(1); + if (Constant *RHSC = dyn_cast(Op1)) { + if (Instruction *LHSI = dyn_cast(Op0)){ + if(LHSI->getOpcode() == Instruction::IntToPtr) { + if (RHSC->isNullValue() && TD && + TD->getIntPtrType(RHSC->getContext()) == + LHSI->getOperand(0)->getType()){ + ICmpInst *CI_new = new ICmpInst(CI, CI->getPredicate(), LHSI->getOperand(0), + Constant::getNullValue(LHSI->getOperand(0)->getType())); + + CI->replaceAllUsesWith(CI_new); + CI->eraseFromParent(); + if(LHSI->use_empty()) { + // If this is the only use of the cast delete it. + LHSI->eraseFromParent(); } } } @@ -102,94 +89,91 @@ } } } + } + } - for (Module::iterator F = M.begin(); F != M.end(); ++F) { - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - if(ICmpInst *ICI = dyn_cast(I++)) { - Value *Op0 = ICI->getOperand(0); - Value *Op1 = ICI->getOperand(1); - if (ConstantInt *CI = dyn_cast(Op1)) { - // Since the RHS is a ConstantInt (CI), if the left hand side is an - // instruction, see if that instruction also has constants so that the - // instruction can be folded into the icmp - if (Instruction *LHSI = dyn_cast(Op0)){ - if(LHSI->getOpcode() == Instruction::Or) { - if (!ICI->isEquality() || !CI->isNullValue() || !LHSI->hasOneUse()) - break; - Value *P, *Q, *R; - if (match(LHSI, m_Or(m_PtrToInt(m_Value(P)), m_PtrToInt(m_Value(Q))))) { - // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0 - // -> and (icmp eq P, null), (icmp eq Q, null). - Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, - Constant::getNullValue(P->getType())); - Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, - Constant::getNullValue(Q->getType())); - Instruction *Op; - if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); - else - Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); - ICI->replaceAllUsesWith(Op); - - } else if(match(LHSI, m_Or(m_Or(m_PtrToInt(m_Value(P)), - m_PtrToInt(m_Value(Q))), - m_PtrToInt(m_Value(R))))) { - // Simplify icmp eq (or (or (ptrtoint P), (ptrtoint Q)), ptrtoint(R)), 0 - // -> and (and (icmp eq P, null), (icmp eq Q, null)), (icmp eq R, null). - Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, - Constant::getNullValue(P->getType())); - Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, - Constant::getNullValue(Q->getType())); - Value *ICIR = new ICmpInst(ICI, ICI->getPredicate(), R, - Constant::getNullValue(R->getType())); - Instruction *Op; - if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); - else - Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); - - if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Op = BinaryOperator::CreateAnd(Op, ICIR,"",ICI); - else - Op = BinaryOperator::CreateOr(Op, ICIR, "", ICI); - ICI->replaceAllUsesWith(Op); - - } else if(match(LHSI, m_Or(m_PtrToInt(m_Value(Q)), m_Or( - m_PtrToInt(m_Value(P)), m_PtrToInt(m_Value(R)))))) { - // Simplify icmp eq (or (ptrtoint P), or((ptrtoint Q), ptrtoint(R))), 0 - // -> and (icmp eq P, null), (and (icmp eq Q, null), (icmp eq R, null)). - Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, - Constant::getNullValue(P->getType())); - Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, - Constant::getNullValue(Q->getType())); - Value *ICIR = new ICmpInst(ICI, ICI->getPredicate(), R, - Constant::getNullValue(R->getType())); - Instruction *Op; - if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); - else - Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); - - if (ICI->getPredicate() == ICmpInst::ICMP_EQ) - Op = BinaryOperator::CreateAnd(Op, ICIR,"",ICI); - else - Op = BinaryOperator::CreateOr(Op, ICIR, "", ICI); - ICI->replaceAllUsesWith(Op); - } - } + for (Module::iterator F = M.begin(); F != M.end(); ++F) { + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + if(ICmpInst *ICI = dyn_cast(I++)) { + Value *Op0 = ICI->getOperand(0); + Value *Op1 = ICI->getOperand(1); + if (ConstantInt *CI = dyn_cast(Op1)) { + // Since the RHS is a ConstantInt (CI), if the left hand side is an + // instruction, see if that instruction also has constants so that the + // instruction can be folded into the icmp + if (Instruction *LHSI = dyn_cast(Op0)){ + if(LHSI->getOpcode() == Instruction::Or) { + if (!ICI->isEquality() || !CI->isNullValue() || !LHSI->hasOneUse()) + break; + Value *P, *Q, *R; + if (match(LHSI, m_Or(m_PtrToInt(m_Value(P)), m_PtrToInt(m_Value(Q))))) { + // Simplify icmp eq (or (ptrtoint P), (ptrtoint Q)), 0 + // -> and (icmp eq P, null), (icmp eq Q, null). + Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, + Constant::getNullValue(P->getType())); + Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, + Constant::getNullValue(Q->getType())); + Instruction *Op; + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); + else + Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); + ICI->replaceAllUsesWith(Op); + + } else if(match(LHSI, m_Or(m_Or(m_PtrToInt(m_Value(P)), + m_PtrToInt(m_Value(Q))), + m_PtrToInt(m_Value(R))))) { + // Simplify icmp eq (or (or (ptrtoint P), (ptrtoint Q)), ptrtoint(R)), 0 + // -> and (and (icmp eq P, null), (icmp eq Q, null)), (icmp eq R, null). + Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, + Constant::getNullValue(P->getType())); + Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, + Constant::getNullValue(Q->getType())); + Value *ICIR = new ICmpInst(ICI, ICI->getPredicate(), R, + Constant::getNullValue(R->getType())); + Instruction *Op; + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); + else + Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); + + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + Op = BinaryOperator::CreateAnd(Op, ICIR,"",ICI); + else + Op = BinaryOperator::CreateOr(Op, ICIR, "", ICI); + ICI->replaceAllUsesWith(Op); + + } else if(match(LHSI, m_Or(m_PtrToInt(m_Value(Q)), m_Or( + m_PtrToInt(m_Value(P)), m_PtrToInt(m_Value(R)))))) { + // Simplify icmp eq (or (ptrtoint P), or((ptrtoint Q), ptrtoint(R))), 0 + // -> and (icmp eq P, null), (and (icmp eq Q, null), (icmp eq R, null)). + Value *ICIP = new ICmpInst(ICI, ICI->getPredicate(), P, + Constant::getNullValue(P->getType())); + Value *ICIQ = new ICmpInst(ICI, ICI->getPredicate(), Q, + Constant::getNullValue(Q->getType())); + Value *ICIR = new ICmpInst(ICI, ICI->getPredicate(), R, + Constant::getNullValue(R->getType())); + Instruction *Op; + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + Op = BinaryOperator::CreateAnd(ICIP, ICIQ,"",ICI); + else + Op = BinaryOperator::CreateOr(ICIP, ICIQ, "", ICI); + + if (ICI->getPredicate() == ICmpInst::ICMP_EQ) + Op = BinaryOperator::CreateAnd(Op, ICIR,"",ICI); + else + Op = BinaryOperator::CreateOr(Op, ICIR, "", ICI); + ICI->replaceAllUsesWith(Op); } } } } } } - return true; - } - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); } - }; + } + return true; } // Pass ID variable Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=131006&r1=131005&r2=131006&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Fri May 6 14:26:18 2011 @@ -1,4 +1,4 @@ -//===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------ ----===// +//===-- LoadArgs.cpp - Promote args if they came from loads ---------------===// // // The LLVM Compiler Infrastructure // @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// // +// Identify calls, that are passed arguments that are LoadInsts. +// Pass the original pointer instead. Helps improve some +// context sensitivity. // //===----------------------------------------------------------------------===// #define DEBUG_TYPE "ld-args" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Instructions.h" +#include "assistDS/LoadArgs.h" #include "llvm/Constants.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Transforms/Utils/Cloning.h" @@ -25,142 +25,153 @@ #include #include -using namespace llvm; +// Pass statistics STATISTIC(numSimplified, "Number of Calls Modified"); +using namespace llvm; + +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. +// Clone functions that take LoadInsts as arguments +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool LoadArgs::runOnModule(Module& M) { + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + CallInst *CI = dyn_cast(I++); + if(!CI) + continue; + + if(CI->hasByValArgument()) + continue; + // if the GEP calls a function, that is externally defined, + // or might be changed, ignore this call site. + Function *F = CI->getCalledFunction(); + + if (!F || (F->isDeclaration() || F->mayBeOverridden())) + continue; + if(F->hasStructRetAttr()) + continue; + if(F->isVarArg()) + continue; + + // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); + unsigned argNum = 1; + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) + continue; + if(F->paramHasAttr(argNum, Attribute::SExt) || + F->paramHasAttr(argNum, Attribute::ZExt)) + continue; + if (isa(CI->getOperand(argNum))) + break; + } + + // if no argument was a GEP operator to be changed + if(ai == ae) + continue; + + LoadInst *LI = dyn_cast(CI->getOperand(argNum)); + if(LI->getParent() != CI->getParent()) + continue; + // Also check that there is no store after the load. + // TODO: Check if the load/store do not alias. + BasicBlock::iterator bii = LI->getParent()->begin(); + Instruction *BII = bii; + while(BII != LI) { + ++bii; + BII = bii; + } + while(BII != CI) { + if(isa(BII)) + break; + ++bii; + BII = bii; + } + if(isa(bii)){ + continue; + } + + // Construct the new Type + // Appends the struct Type at the beginning + std::vectorTP; + TP.push_back(LI->getOperand(0)->getType()); + for(unsigned c = 1; c < CI->getNumOperands();c++) { + TP.push_back(CI->getOperand(c)->getType()); + } + + //return type is same as that of original instruction + const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); + numSimplified++; + if(numSimplified > 400) + return true; + + Function *NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F->getNameStr() + ".TEST", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + NI->setName("Sarg"); + ++NI; + + DenseMap ValueMap; + + for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + ValueMap[II] = NI; + NI->setName(II->getName()); + } + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, F, ValueMap, Returns); + std::vector fargs; + for(Function::arg_iterator ai = NewF->arg_begin(), + ae= NewF->arg_end(); ai != ae; ++ai) { + fargs.push_back(ai); + } -namespace { - class LoadArgs : public ModulePass { - public: - static char ID; - LoadArgs() : ModulePass(&ID) {} - bool runOnModule(Module& M) { - bool changed; - do { - changed = false; - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - CallInst *CI = dyn_cast(I++); - if(!CI) - continue; - - if(CI->hasByValArgument()) - continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); - - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; - - // find the argument we must replace - Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++, ++ai) { - if(ai->use_empty()) - continue; - if(F->paramHasAttr(argNum, Attribute::SExt) || - F->paramHasAttr(argNum, Attribute::ZExt)) - continue; - if (isa(CI->getOperand(argNum))) - break; - } - - // if no argument was a GEP operator to be changed - if(ai == ae) - continue; - - LoadInst *LI = dyn_cast(CI->getOperand(argNum)); - if(LI->getParent() != CI->getParent()) - continue; - // Also check that there is no store after the load. - // TODO: Check if the load/store do not alias. - BasicBlock::iterator bii = LI->getParent()->begin(); - Instruction *BII = bii; - while(BII != LI) { - ++bii; - BII = bii; - } - while(BII != CI) { - if(isa(BII)) - break; - ++bii; - BII = bii; - } - if(isa(bii)){ - continue; - } - - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(LI->getOperand(0)->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } - - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - numSimplified++; - if(numSimplified > 400) - return true; - - Function *NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } - - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - SmallVector Ops(CI->op_begin()+1, CI->op_end()); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(LI_new); - - SmallVector Args; - Args.push_back(LI->getOperand(0)); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); - } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); - changed = true; - } + NewF->setAlignment(F->getAlignment()); + //Get the point to insert the GEP instr. + NI = NewF->arg_begin(); + SmallVector Ops(CI->op_begin()+1, CI->op_end()); + Instruction *InsertPoint; + for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} + + LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); + fargs.at(argNum)->replaceAllUsesWith(LI_new); + + SmallVector Args; + Args.push_back(LI->getOperand(0)); + for(unsigned j =1;jgetNumOperands();j++) { + Args.push_back(CI->getOperand(j)); } + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); + changed = true; } - } while(changed); - return true; + } } - }; + } while(changed); + return true; } char LoadArgs::ID = 0; Removed: poolalloc/trunk/lib/AssistDS/MergeArrayIndexGEP.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/MergeArrayIndexGEP.cpp?rev=131005&view=auto ============================================================================== --- poolalloc/trunk/lib/AssistDS/MergeArrayIndexGEP.cpp (original) +++ poolalloc/trunk/lib/AssistDS/MergeArrayIndexGEP.cpp (removed) @@ -1,164 +0,0 @@ -//===-- MergeArrayIndexGEP.cpp - Merge GEPs for indexing in arrays --------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Merge chained GEPs; Specially useful for arrays inside structs -// -//===----------------------------------------------------------------------===// -#define DEBUG_TYPE "merge-gep" - -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Instructions.h" -#include "llvm/Constants.h" -#include "llvm/Support/GetElementPtrTypeIterator.h" -#include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Debug.h" - -#include -// Pass statistics -STATISTIC(numMerged, "Number of GEPs merged"); - -using namespace llvm; - -namespace { - class MergeArrayGEP : public ModulePass { - public: - static char ID; - MergeArrayGEP() : ModulePass(&ID) {} - // - // Method: runOnModule() - // - // Description: - // Entry point for this LLVM pass. - // Merge chained GEPs into a single GEP - // - // Inputs: - // M - A reference to the LLVM module to transform - // - // Outputs: - // M - The transformed LLVM module. - // - // Return value: - // true - The module was modified. - // false - The module was not modified. - // - bool runOnModule(Module& M) { - bool changed; - do { - changed = false; - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - GetElementPtrInst *GEP = dyn_cast(I++); - if(GEP == NULL) - continue; - simplifyGEP(GEP); - } - } - } - } while(changed); - return true; - } - - // - // Method: simplifyGEP() - // - // Description: - // Check if this GEP's pointer argument is a GEP(Inst/ConstExpr) - // If so check if we can merge the two GEPs into a single GEP - // - // Inputs: - // GEP - A pointer to the GEP to simplify - // - static void simplifyGEP(GetElementPtrInst *GEP) { - Value *PtrOp = GEP->getOperand(0); - if (GEPOperator *Src = dyn_cast(PtrOp)) { - // Note that if our source is a gep chain itself that we wait for that - // chain to be resolved before we perform this transformation. This - // avoids us creating a TON of code in some cases. - // - if (GetElementPtrInst *SrcGEP = - dyn_cast(Src->getOperand(0))) - if (SrcGEP->getNumOperands() == 2) - return; // Wait until our source is folded to completion. - - SmallVector Indices; - - // Find out whether the last index in the source GEP is a sequential idx. - bool EndsWithSequential = false; - for (gep_type_iterator I = gep_type_begin(*Src), E = gep_type_end(*Src); - I != E; ++I) - EndsWithSequential = !(*I)->isStructTy(); - - // Can we combine the two pointer arithmetics offsets? - if (EndsWithSequential) { - // Replace: gep (gep %P, long B), long A, ... - // With: T = long A+B; gep %P, T, ... - // - Value *Sum; - Value *SO1 = Src->getOperand(Src->getNumOperands()-1); - Value *GO1 = GEP->getOperand(1); - if (SO1 == Constant::getNullValue(SO1->getType())) { - Sum = GO1; - } else if (GO1 == Constant::getNullValue(GO1->getType())) { - Sum = SO1; - } else { - // If they aren't the same type, then the input hasn't been processed - // by the loop above yet (which canonicalizes sequential index types to - // intptr_t). Just avoid transforming this until the input has been - // normalized. - if (SO1->getType() != GO1->getType()) - return; - Sum = llvm::BinaryOperator::Create(BinaryOperator::Add, - SO1, GO1, - PtrOp->getName()+".sum",GEP); - } - - // Update the GEP in place if possible. - if (Src->getNumOperands() == 2) { - GEP->setOperand(0, Src->getOperand(0)); - GEP->setOperand(1, Sum); - numMerged++; - return; - } - Indices.append(Src->op_begin()+1, Src->op_end()-1); - Indices.push_back(Sum); - Indices.append(GEP->op_begin()+2, GEP->op_end()); - } else if (isa(GEP->idx_begin()) && - cast(GEP->idx_begin())->isNullValue() && - Src->getNumOperands() != 1) { - // Otherwise we can do the fold if the first index of the GEP is a zero - Indices.append(Src->op_begin()+1, Src->op_end()); - Indices.append(GEP->idx_begin()+1, GEP->idx_end()); - } - - if (!Indices.empty()){ - GetElementPtrInst *GEPNew = (GEP->isInBounds() && Src->isInBounds()) ? - GetElementPtrInst::CreateInBounds(Src->getOperand(0), Indices.begin(), - Indices.end(), GEP->getName(), GEP) : - GetElementPtrInst::Create(Src->getOperand(0), Indices.begin(), - Indices.end(), GEP->getName(), GEP); - numMerged++; - GEP->replaceAllUsesWith(GEPNew); - GEP->eraseFromParent(); - } - } - } - }; -} - -// Pass ID variable -char MergeArrayGEP::ID = 0; - -// Register the pass -static RegisterPass -X("mergearrgep", "Merge GEPs for arrays indexing"); Added: poolalloc/trunk/lib/AssistDS/MergeGEP.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/MergeGEP.cpp?rev=131006&view=auto ============================================================================== --- poolalloc/trunk/lib/AssistDS/MergeGEP.cpp (added) +++ poolalloc/trunk/lib/AssistDS/MergeGEP.cpp Fri May 6 14:26:18 2011 @@ -0,0 +1,159 @@ +//===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Merge chained GEPs; Specially useful for arrays inside structs +// +//===----------------------------------------------------------------------===// +#define DEBUG_TYPE "merge-gep" + +#include "assistDS/MergeGEP.h" +#include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/Instructions.h" +#include "llvm/Constants.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Transforms/Utils/Cloning.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/FormattedStream.h" +#include "llvm/Support/Debug.h" + +#include +// Pass statistics +STATISTIC(numMerged, "Number of GEPs merged"); + +using namespace llvm; + +static void simplifyGEP(GetElementPtrInst *GEP); +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. +// Merge chained GEPs into a single GEP +// +// Inputs: +// M - A reference to the LLVM module to transform +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool MergeArrayGEP::runOnModule(Module& M) { + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + GetElementPtrInst *GEP = dyn_cast(I++); + if(GEP == NULL) + continue; + simplifyGEP(GEP); + } + } + } + } while(changed); + return true; +} + +// +// Method: simplifyGEP() +// +// Description: +// Check if this GEP's pointer argument is a GEP(Inst/ConstExpr) +// If so check if we can merge the two GEPs into a single GEP +// +// Inputs: +// GEP - A pointer to the GEP to simplify +// +static void simplifyGEP(GetElementPtrInst *GEP) { + Value *PtrOp = GEP->getOperand(0); + if (GEPOperator *Src = dyn_cast(PtrOp)) { + // Note that if our source is a gep chain itself that we wait for that + // chain to be resolved before we perform this transformation. This + // avoids us creating a TON of code in some cases. + // + if (GetElementPtrInst *SrcGEP = + dyn_cast(Src->getOperand(0))) + if (SrcGEP->getNumOperands() == 2) + return; // Wait until our source is folded to completion. + + SmallVector Indices; + + // Find out whether the last index in the source GEP is a sequential idx. + bool EndsWithSequential = false; + for (gep_type_iterator I = gep_type_begin(*Src), E = gep_type_end(*Src); + I != E; ++I) + EndsWithSequential = !(*I)->isStructTy(); + + // Can we combine the two pointer arithmetics offsets? + if (EndsWithSequential) { + // Replace: gep (gep %P, long B), long A, ... + // With: T = long A+B; gep %P, T, ... + // + Value *Sum; + Value *SO1 = Src->getOperand(Src->getNumOperands()-1); + Value *GO1 = GEP->getOperand(1); + if (SO1 == Constant::getNullValue(SO1->getType())) { + Sum = GO1; + } else if (GO1 == Constant::getNullValue(GO1->getType())) { + Sum = SO1; + } else { + // If they aren't the same type, then the input hasn't been processed + // by the loop above yet (which canonicalizes sequential index types to + // intptr_t). Just avoid transforming this until the input has been + // normalized. + if (SO1->getType() != GO1->getType()) + return; + Sum = llvm::BinaryOperator::Create(BinaryOperator::Add, + SO1, GO1, + PtrOp->getName()+".sum",GEP); + } + + // Update the GEP in place if possible. + if (Src->getNumOperands() == 2) { + GEP->setOperand(0, Src->getOperand(0)); + GEP->setOperand(1, Sum); + numMerged++; + return; + } + Indices.append(Src->op_begin()+1, Src->op_end()-1); + Indices.push_back(Sum); + Indices.append(GEP->op_begin()+2, GEP->op_end()); + } else if (isa(GEP->idx_begin()) && + cast(GEP->idx_begin())->isNullValue() && + Src->getNumOperands() != 1) { + // Otherwise we can do the fold if the first index of the GEP is a zero + Indices.append(Src->op_begin()+1, Src->op_end()); + Indices.append(GEP->idx_begin()+1, GEP->idx_end()); + } + + if (!Indices.empty()){ + GetElementPtrInst *GEPNew = (GEP->isInBounds() && Src->isInBounds()) ? + GetElementPtrInst::CreateInBounds(Src->getOperand(0), Indices.begin(), + Indices.end(), GEP->getName(), GEP) : + GetElementPtrInst::Create(Src->getOperand(0), Indices.begin(), + Indices.end(), GEP->getName(), GEP); + numMerged++; + GEP->replaceAllUsesWith(GEPNew); + GEP->eraseFromParent(); + } + } +} + +// Pass ID variable +char MergeArrayGEP::ID = 0; + +// Register the pass +static RegisterPass +X("mergearrgep", "Merge GEPs for arrays indexing"); Modified: poolalloc/trunk/lib/AssistDS/SimplifyExtractValue.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/SimplifyExtractValue.cpp?rev=131006&r1=131005&r2=131006&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/SimplifyExtractValue.cpp (original) +++ poolalloc/trunk/lib/AssistDS/SimplifyExtractValue.cpp Fri May 6 14:26:18 2011 @@ -14,9 +14,7 @@ //===----------------------------------------------------------------------===// #define DEBUG_TYPE "simplifyev" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" +#include "assistDS/SimplifyExtractValue.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/FormattedStream.h" @@ -33,42 +31,76 @@ // Pass statistic STATISTIC(numErased, "Number of Instructions Deleted"); -namespace { - class SimplifyEV : public ModulePass { - public: - static char ID; - SimplifyEV() : ModulePass(&ID) {} - // - // Method: runOnModule() - // - // Description: - // Entry point for this LLVM pass. Search for insert/extractvalue instructions - // that can be simplified. - // - // Inputs: - // M - A reference to the LLVM module to transform. - // - // Outputs: - // M - The transformed LLVM module. - // - // Return value: - // true - The module was modified. - // false - The module was not modified. - // - bool runOnModule(Module& M) { - // Repeat till no change - bool changed; - do { - changed = false; - for (Module::iterator F = M.begin(); F != M.end(); ++F) { - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - ExtractValueInst *EV = dyn_cast(I++); - if(!EV) - continue; - Value *Agg = EV->getAggregateOperand(); - if (!EV->hasIndices()) { - EV->replaceAllUsesWith(Agg); +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM pass. Search for insert/extractvalue instructions +// that can be simplified. +// +// Inputs: +// M - A reference to the LLVM module to transform. +// +// Outputs: +// M - The transformed LLVM module. +// +// Return value: +// true - The module was modified. +// false - The module was not modified. +// +bool SimplifyEV::runOnModule(Module& M) { + // Repeat till no change + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F) { + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + ExtractValueInst *EV = dyn_cast(I++); + if(!EV) + continue; + Value *Agg = EV->getAggregateOperand(); + if (!EV->hasIndices()) { + EV->replaceAllUsesWith(Agg); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + } + if (Constant *C = dyn_cast(Agg)) { + if (isa(C)) { + EV->replaceAllUsesWith(UndefValue::get(EV->getType())); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + } + if (isa(C)) { + EV->replaceAllUsesWith(Constant::getNullValue(EV->getType())); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + } + if (isa(C) || isa(C)) { + // Extract the element indexed by the first index out of the constant + Value *V = C->getOperand(*EV->idx_begin()); + if (EV->getNumIndices() > 1) { + // Extract the remaining indices out of the constant indexed by the + // first index + ExtractValueInst *EV_new = ExtractValueInst::Create(V, + EV->idx_begin() + 1, + EV->idx_end(), "", EV); + EV->replaceAllUsesWith(EV_new); DEBUG(errs() << "EV:"); DEBUG(errs() << "ERASE:"); DEBUG(EV->dump()); @@ -76,174 +108,133 @@ numErased++; changed = true; continue; - } - if (Constant *C = dyn_cast(Agg)) { - if (isa(C)) { - EV->replaceAllUsesWith(UndefValue::get(EV->getType())); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } - if (isa(C)) { - EV->replaceAllUsesWith(Constant::getNullValue(EV->getType())); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } - if (isa(C) || isa(C)) { - // Extract the element indexed by the first index out of the constant - Value *V = C->getOperand(*EV->idx_begin()); - if (EV->getNumIndices() > 1) { - // Extract the remaining indices out of the constant indexed by the - // first index - ExtractValueInst *EV_new = ExtractValueInst::Create(V, - EV->idx_begin() + 1, - EV->idx_end(), "", EV); - EV->replaceAllUsesWith(EV_new); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } else { - EV->replaceAllUsesWith(V); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } - } - continue; - } - if (LoadInst * LI = dyn_cast(Agg)) { - SmallVector Indices; - const Type *Int32Ty = Type::getInt32Ty(M.getContext()); - Indices.push_back(Constant::getNullValue(Int32Ty)); - for (ExtractValueInst::idx_iterator I = EV->idx_begin(), E = EV->idx_end(); - I != E; ++I) { - Indices.push_back(ConstantInt::get(Int32Ty, *I)); - } - - GetElementPtrInst *GEP = GetElementPtrInst::CreateInBounds(LI->getOperand(0), Indices.begin(), - Indices.end(), LI->getName(), LI) ; - LoadInst *LINew = new LoadInst(GEP, "", LI); - EV->replaceAllUsesWith(LINew); + } else { + EV->replaceAllUsesWith(V); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); EV->eraseFromParent(); - changed = true; numErased++; + changed = true; continue; - } - if (InsertValueInst *IV = dyn_cast(Agg)) { - bool done = false; - // We're extracting from an insertvalue instruction, compare the indices - const unsigned *exti, *exte, *insi, *inse; - for (exti = EV->idx_begin(), insi = IV->idx_begin(), - exte = EV->idx_end(), inse = IV->idx_end(); - exti != exte && insi != inse; - ++exti, ++insi) { - if (*insi != *exti) { - // The insert and extract both reference distinctly different elements. - // This means the extract is not influenced by the insert, and we can - // replace the aggregate operand of the extract with the aggregate - // operand of the insert. i.e., replace - // %I = insertvalue { i32, { i32 } } %A, { i32 } { i32 42 }, 1 - // %E = extractvalue { i32, { i32 } } %I, 0 - // with - // %E = extractvalue { i32, { i32 } } %A, 0 - ExtractValueInst *EV_new = ExtractValueInst::Create(IV->getAggregateOperand(), - EV->idx_begin(), EV->idx_end(),"", EV); - EV->replaceAllUsesWith(EV_new); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - done = true; - changed = true; - break; - } - } - if(done) - continue; - if (exti == exte && insi == inse) { - // Both iterators are at the end: Index lists are identical. Replace - // %B = insertvalue { i32, { i32 } } %A, i32 42, 1, 0 - // %C = extractvalue { i32, { i32 } } %B, 1, 0 - // with "i32 42" - EV->replaceAllUsesWith(IV->getInsertedValueOperand()); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - - } - if (exti == exte) { - // The extract list is a prefix of the insert list. i.e. replace - // %I = insertvalue { i32, { i32 } } %A, i32 42, 1, 0 - // %E = extractvalue { i32, { i32 } } %I, 1 - // with - // %X = extractvalue { i32, { i32 } } %A, 1 - // %E = insertvalue { i32 } %X, i32 42, 0 - // by switching the order of the insert and extract (though the - // insertvalue should be left in, since it may have other uses). - Value *NewEV = ExtractValueInst::Create(IV->getAggregateOperand(), - EV->idx_begin(), EV->idx_end(), "", EV); - Value *NewIV = InsertValueInst::Create(NewEV, IV->getInsertedValueOperand(), - insi, inse, "", EV); - EV->replaceAllUsesWith(NewIV); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } - if (insi == inse) { - // The insert list is a prefix of the extract list - // We can simply remove the common indices from the extract and make it - // operate on the inserted value instead of the insertvalue result. - // i.e., replace - // %I = insertvalue { i32, { i32 } } %A, { i32 } { i32 42 }, 1 - // %E = extractvalue { i32, { i32 } } %I, 1, 0 - // with - // %E extractvalue { i32 } { i32 42 }, 0 - ExtractValueInst *EV_new = ExtractValueInst::Create(IV->getInsertedValueOperand(), - exti, exte,"", EV); - EV->replaceAllUsesWith(EV_new); - DEBUG(errs() << "EV:"); - DEBUG(errs() << "ERASE:"); - DEBUG(EV->dump()); - EV->eraseFromParent(); - numErased++; - changed = true; - continue; - } + } + continue; + } + if (LoadInst * LI = dyn_cast(Agg)) { + SmallVector Indices; + const Type *Int32Ty = Type::getInt32Ty(M.getContext()); + Indices.push_back(Constant::getNullValue(Int32Ty)); + for (ExtractValueInst::idx_iterator I = EV->idx_begin(), E = EV->idx_end(); + I != E; ++I) { + Indices.push_back(ConstantInt::get(Int32Ty, *I)); + } + + GetElementPtrInst *GEP = GetElementPtrInst::CreateInBounds(LI->getOperand(0), Indices.begin(), + Indices.end(), LI->getName(), LI) ; + LoadInst *LINew = new LoadInst(GEP, "", LI); + EV->replaceAllUsesWith(LINew); + EV->eraseFromParent(); + changed = true; + numErased++; + continue; + + } + if (InsertValueInst *IV = dyn_cast(Agg)) { + bool done = false; + // We're extracting from an insertvalue instruction, compare the indices + const unsigned *exti, *exte, *insi, *inse; + for (exti = EV->idx_begin(), insi = IV->idx_begin(), + exte = EV->idx_end(), inse = IV->idx_end(); + exti != exte && insi != inse; + ++exti, ++insi) { + if (*insi != *exti) { + // The insert and extract both reference distinctly different elements. + // This means the extract is not influenced by the insert, and we can + // replace the aggregate operand of the extract with the aggregate + // operand of the insert. i.e., replace + // %I = insertvalue { i32, { i32 } } %A, { i32 } { i32 42 }, 1 + // %E = extractvalue { i32, { i32 } } %I, 0 + // with + // %E = extractvalue { i32, { i32 } } %A, 0 + ExtractValueInst *EV_new = ExtractValueInst::Create(IV->getAggregateOperand(), + EV->idx_begin(), EV->idx_end(),"", EV); + EV->replaceAllUsesWith(EV_new); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + done = true; + changed = true; + break; } } + if(done) + continue; + if (exti == exte && insi == inse) { + // Both iterators are at the end: Index lists are identical. Replace + // %B = insertvalue { i32, { i32 } } %A, i32 42, 1, 0 + // %C = extractvalue { i32, { i32 } } %B, 1, 0 + // with "i32 42" + EV->replaceAllUsesWith(IV->getInsertedValueOperand()); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + + } + if (exti == exte) { + // The extract list is a prefix of the insert list. i.e. replace + // %I = insertvalue { i32, { i32 } } %A, i32 42, 1, 0 + // %E = extractvalue { i32, { i32 } } %I, 1 + // with + // %X = extractvalue { i32, { i32 } } %A, 1 + // %E = insertvalue { i32 } %X, i32 42, 0 + // by switching the order of the insert and extract (though the + // insertvalue should be left in, since it may have other uses). + Value *NewEV = ExtractValueInst::Create(IV->getAggregateOperand(), + EV->idx_begin(), EV->idx_end(), "", EV); + Value *NewIV = InsertValueInst::Create(NewEV, IV->getInsertedValueOperand(), + insi, inse, "", EV); + EV->replaceAllUsesWith(NewIV); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + } + if (insi == inse) { + // The insert list is a prefix of the extract list + // We can simply remove the common indices from the extract and make it + // operate on the inserted value instead of the insertvalue result. + // i.e., replace + // %I = insertvalue { i32, { i32 } } %A, { i32 } { i32 42 }, 1 + // %E = extractvalue { i32, { i32 } } %I, 1, 0 + // with + // %E extractvalue { i32 } { i32 42 }, 0 + ExtractValueInst *EV_new = ExtractValueInst::Create(IV->getInsertedValueOperand(), + exti, exte,"", EV); + EV->replaceAllUsesWith(EV_new); + DEBUG(errs() << "EV:"); + DEBUG(errs() << "ERASE:"); + DEBUG(EV->dump()); + EV->eraseFromParent(); + numErased++; + changed = true; + continue; + } } } - } while(changed); - return (numErased > 0); + } } - }; + } while(changed); + return (numErased > 0); } // Pass ID variable Modified: poolalloc/trunk/lib/AssistDS/Simpli