From daniel at zuster.org Mon Mar 29 03:25:08 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 29 Mar 2010 08:25:08 -0000 Subject: [llvm-commits] [zorg] r99808 - /zorg/trunk/lnt/lnt/viewer/js/View2D.js Message-ID: <20100329082508.79F712A6C12C@llvm.org> Author: ddunbar Date: Mon Mar 29 03:25:08 2010 New Revision: 99808 URL: http://llvm.org/viewvc/llvm-project?rev=99808&view=rev Log: Graph2D: Add two new graph styles, points and simple error bars (lines). Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/js/View2D.js?rev=99808&r1=99807&r2=99808&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/js/View2D.js (original) +++ zorg/trunk/lnt/lnt/viewer/js/View2D.js Mon Mar 29 03:25:08 2010 @@ -532,6 +532,67 @@ }, }); +var Graph2D_PointPlotStyle = new Class ({ + Extends: Graph2D_PlotStyle, + + initialize: function(width, color) { + if (!width) + width = 1; + if (!color) + color = [0,0,0]; + + this.parent(); + this.width = width; + this.color = color; + }, + + plot: function(graph, ctx, data) { + if (data.length === 0) + return; + + ctx.beginPath(); + var radius = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + for (var i = 0, e = data.length; i != e; ++i) { + var co = graph.graphInfo.toNDC(data[i]); + ctx.moveTo(co[0], co[1]); + ctx.arc(co[0], co[1], radius, 0, Math.PI * 2, /*anticlockwise=*/false); + } + ctx.fillStyle = col3_to_rgb(this.color); + ctx.fill(); + }, +}); + +var Graph2D_ErrorBarPlotStyle = new Class ({ + Extends: Graph2D_PlotStyle, + + initialize: function(width, color) { + if (!width) + width = 1; + if (!color) + color = [0,0,0]; + + this.parent(); + this.width = width; + this.color = color; + }, + + plot: function(graph, ctx, data) { + if (data.length === 0) + return; + + ctx.beginPath(); + for (var i = 0, e = data.length; i != e; ++i) { + var co_min = graph.graphInfo.toNDC([data[i][0], data[i][1]]); + var co_max = graph.graphInfo.toNDC([data[i][0], data[i][2]]); + ctx.moveTo(co_min[0], co_min[1]); + ctx.lineTo(co_max[0], co_max[1]); + } + ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + ctx.strokeStyle = col3_to_rgb(this.color); + ctx.stroke(); + }, +}); + var Graph2D_Axis = new Class ({ // Static Methods formats: { From daniel at zuster.org Mon Mar 29 03:25:11 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 29 Mar 2010 08:25:11 -0000 Subject: [llvm-commits] [zorg] r99809 - in /zorg/trunk/lnt/lnt/viewer: NTStyleBrowser.ptl simple.ptl Message-ID: <20100329082511.2E0472A6C12D@llvm.org> Author: ddunbar Date: Mon Mar 29 03:25:11 2010 New Revision: 99809 URL: http://llvm.org/viewvc/llvm-project?rev=99809&view=rev Log: LNT: Add very basic 'simple' viewer support for the 'run_order' key. Modified: zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl zorg/trunk/lnt/lnt/viewer/simple.ptl Modified: zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl?rev=99809&r1=99808&r2=99809&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl Mon Mar 29 03:25:11 2010 @@ -55,6 +55,18 @@ # Find previous runs, ordered by time. runs = db.runs(run.machine).order_by(Run.start_time.desc()).all() + # Order by run_order info key, if given. + for r in runs: + if 'run_order' in r.info: + has_order = True + break + else: + has_order = False + if has_order: + runs.sort(key = lambda r: ('run_order' in r.info and + r.info['run_order'].value)) + runs.reverse() + # Find previous run to compare to. if compareTo is None: for r in runs: @@ -304,6 +316,21 @@ self.id = int(idstr) except ValueError, exc: raise TraversalError(str(exc)) + self.popupDepth = 0 + + def renderPopupBegin [html] (self, id, title, hidden): + self.popupDepth += 1 + """\ +

+ (%s) %s +

+ """ % (id, id, ("+","-")[hidden], title, id, ("","none")[hidden], + self.popupDepth) + + def renderPopupEnd [html] (self): + """ +
""" + self.popupDepth -= 1 def _q_index [html] (self): # Get a DB connection. @@ -319,6 +346,18 @@ # Find all runs on this machine. runs = db.runs(machine).order_by(Run.start_time.desc()).all() + # Order by run_order info key, if given. + for r in runs: + if 'run_order' in r.info: + has_order = True + break + else: + has_order = False + if has_order: + runs.sort(key = lambda r: ('run_order' in r.info and + r.info['run_order'].value)) + runs.reverse() + # FIXME: List previous machines with the same nickname? """ @@ -372,26 +411,31 @@ -
Machine ID %d
-

- - - """ % (machine.name, machine.id) +
""" % (machine.name, machine.id) + self.renderPopupBegin('machine_info', 'Machine Info', True) + """ + """ for mi in machine.info.values(): """ - - """ % (mi.key, mi.value) + """ % (mi.key, mi.value) + """ +
%s %s
""" + self.renderPopupEnd() # List associated runs. + """ -

- + """ + if has_order: + """ + """ + """ @@ -399,7 +443,15 @@ """ for r in runs: """ - + """ + if has_order: + if 'run_order' in r.info: + order_value = r.info['run_order'].value + else: + order_value = str(' ') + """ + """ % order_value + """ Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=99809&r1=99808&r2=99809&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/simple.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/simple.ptl Mon Mar 29 03:25:11 2010 @@ -19,6 +19,17 @@ from PerfDB import Machine, Run, Test +def median(l): + l = list(l) + l.sort() + N = len(l) + return (l[(N-1)//2] + l[N//2])*.5 + +def median_absolute_deviation(l, med = None): + if med is None: + med = median(l) + return median([abs(x - med) for x in l]) + class SimpleRunUI(Directory): _q_exports = ["", "graph"] @@ -62,15 +73,25 @@ runs = [r for r in runs if 'tag' in r.info and r.info['tag'].value == 'simple'] + # Order by run_order info key, if given. + for r in runs: + if 'run_order' in r.info: + has_order = True + break + else: + has_order = False + if has_order: + runs.sort(key = lambda r: ('run_order' in r.info and + r.info['run_order'].value)) + runs.reverse() + # Find previous run to compare to. if compareTo is None: - for r in runs: - # FIXME: Compare revisions, not times. - if r != run and r.start_time < run.start_time: - compareTo = r - break + run_index = runs.index(run) + if run_index < len(runs) - 1: + compareTo = runs[run_index + 1] - return run, runs, compareTo + return run, runs, has_order, compareTo def show_run_page [html] (self, db, run, runs, compareTo, contents_fn): machine = run.machine @@ -180,7 +201,7 @@ # Get a DB connection. db = self.root.getDB() - run,runs,compareTo = self.getInfo(db) + run,runs,has_order,compareTo = self.getInfo(db) machine = run.machine self.root.getHeader('Run Results', "../..", @@ -197,7 +218,7 @@ # Get a DB connection. db = self.root.getDB() - run,runs,compareTo = self.getInfo(db) + run,runs,has_order,compareTo = self.getInfo(db) machine = run.machine # Load the metadata. @@ -226,24 +247,36 @@ q = q.filter(Sample.test_id.in_(test_ids)) samples = list(q) - # Aggregate by test id and then run id. + # Aggregate by test id and then run key. # # FIXME: Pretty expensive. + run_id_map = dict([(r.id,r) for r in runs]) samples_by_test_id = {} for run_id,test_id,value in samples: d = samples_by_test_id.get(test_id) if d is None: d = samples_by_test_id[test_id] = Util.multidict() - d[run_id] = value + r = run_id_map.get(run_id) + if r is None: + continue + + if has_order: + # FIXME: What to do on failure? + run_key = int(r.info.get('run_order').value) + else: + run_key = time.mktime(r.start_time.timetuple()) + d[run_key] = value # Build the graph data - run_id_map = dict([(r.id,r) for r in runs]) pset_id_map = dict([(pset,i) for i,pset in enumerate(parameter_sets)]) legend = [] plots = "" num_plots = len(graph_tests) * len(graph_psets) num_points = 0 index = 0 + show_mad_error = has_order + show_points = has_order + show_all_points = False for name in graph_tests: for pset in graph_psets: test_id = test_map[(name,pset)].id @@ -251,21 +284,45 @@ # Get the plot for this test. # # FIXME: Support order by something other than time. + errorbar_data = [] + points_data = [] data = [] - for run_id,values in samples_by_test_id.get(test_id,{}).items(): - r = run_id_map.get(run_id) - if not r: - continue - timeval = time.mktime(r.start_time.timetuple()) - data.append((timeval, min(values))) + for x,values in samples_by_test_id.get(test_id,{}).items(): + min_value = min(values) + data.append((x, min_value)) + if show_points: + if show_all_points: + for v in values: + points_data.append((x, v)) + else: + points_data.append((x, min_value)) + if show_mad_error: + med = median(values) + mad = median_absolute_deviation(values, med) + errorbar_data.append((x, med - mad, med + mad)) data.sort() num_points += len(data) col = list(Util.makeDarkColor(float(index) / num_plots)) - pts = ','.join(['[%f,%f]' % (t,v) for t,v in data]) + pts = ','.join(['[%.3f,%.3f]' % (t,v) + for t,v in data]) style = "new Graph2D_LinePlotStyle(1, %r)" % col plots += " graph.addPlot([%s], %s);\n" % (pts,style) + if points_data: + pts_col = (0,0,0) + pts = ','.join(['[%.3f,%.3f]' % (t,v) + for t,v in points_data]) + style = "new Graph2D_PointPlotStyle(1, %r)" % (pts_col,) + plots += " graph.addPlot([%s], %s);\n" % (pts,style) + + if errorbar_data: + bar_col = [c*.7 for c in col] + pts = ','.join(['[%.3f,%.3f,%.3f]' % (x,y_min,y_max) + for x,y_min,y_max in errorbar_data]) + style = "new Graph2D_ErrorBarPlotStyle(1, %r)" % (bar_col,) + plots += " graph.addPlot([%s], %s);\n" % (pts,style) + legend.append(("%s : P%d" % (name, pset_id_map[pset]), col)) index += 1 @@ -301,15 +358,19 @@ Num Points: %d
""" % (num_plots, num_points) + if has_order: + xAxis_format = 'graph.xAxis.formats.normal' + else: + xAxis_format = 'graph.xAxis.formats.day' graph_init = """\ function init() { graph = new Graph2D("graph"); graph.clearColor = [1, 1, 1]; %s - graph.xAxis.format = graph.xAxis.formats.day; + graph.xAxis.format = %s; graph.draw(); } - """ % (plots,) + """ % (plots,xAxis_format) self.root.getHeader('Run Results', "..", components=(('simple','simple'), ('machine', From criswell at uiuc.edu Mon Mar 29 10:47:51 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 29 Mar 2010 15:47:51 -0000 Subject: [llvm-commits] [poolalloc] r99813 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20100329154752.056CA2A6C12C@llvm.org> Author: criswell Date: Mon Mar 29 10:47:51 2010 New Revision: 99813 URL: http://llvm.org/viewvc/llvm-project?rev=99813&view=rev Log: Taught DSA about the llvm.objectsize() intrinsic. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=99813&r1=99812&r2=99813&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Mon Mar 29 10:47:51 2010 @@ -717,6 +717,9 @@ case Intrinsic::prefetch: return true; + case Intrinsic::objectsize: + return true; + // // The return address aliases with the stack, is type-unknown, and should // have the unknown flag set since we don't know where it goes. From sabre at nondot.org Mon Mar 29 12:02:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 17:02:02 -0000 Subject: [llvm-commits] [llvm] r99815 - /llvm/trunk/lib/Target/ARM/README.txt Message-ID: <20100329170202.49D952A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 12:02:02 2010 New Revision: 99815 URL: http://llvm.org/viewvc/llvm-project?rev=99815&view=rev Log: add a note. Modified: llvm/trunk/lib/Target/ARM/README.txt Modified: llvm/trunk/lib/Target/ARM/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/README.txt?rev=99815&r1=99814&r2=99815&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/README.txt (original) +++ llvm/trunk/lib/Target/ARM/README.txt Mon Mar 29 12:02:02 2010 @@ -12,6 +12,9 @@ A few ARMv6T2 ops should be pattern matched: BFI, SBFX, and UBFX +Interesting optimization for PIC codegen on arm-linux: +http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43129 + //===---------------------------------------------------------------------===// Crazy idea: Consider code that uses lots of 8-bit or 16-bit values. By the From dpatel at apple.com Mon Mar 29 12:20:31 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 29 Mar 2010 17:20:31 -0000 Subject: [llvm-commits] [llvm] r99816 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h include/llvm/CodeGen/DwarfWriter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/AsmPrinter/DwarfWriter.cpp Message-ID: <20100329172031.493E82A6C131@llvm.org> Author: dpatel Date: Mon Mar 29 12:20:31 2010 New Revision: 99816 URL: http://llvm.org/viewvc/llvm-project?rev=99816&view=rev Log: Refactor code to push DILocation prcessing into DwarfDebug.cpp from AsmPrinter.cpp. This is same as r99772 (which was reverted) with just one meaningful difference where two source lines exchanged their positions. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/include/llvm/CodeGen/DwarfWriter.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/CodeGen/AsmPrinter/DwarfWriter.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Mar 29 12:20:31 2010 @@ -47,7 +47,6 @@ class MCSection; class MCStreamer; class MCSymbol; - class MDNode; class DwarfWriter; class Mangler; class MCAsmInfo; @@ -138,9 +137,6 @@ mutable unsigned Counter; mutable unsigned SetCounter; - // Private state for processDebugLoc() - mutable const MDNode *PrevDLT; - protected: explicit AsmPrinter(formatted_raw_ostream &o, TargetMachine &TM, MCStreamer &Streamer); Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original) +++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Mon Mar 29 12:20:31 2010 @@ -83,19 +83,11 @@ /// void EndFunction(const MachineFunction *MF); - /// RecordSourceLine - Register a source line with debug info. Returns the - /// unique label that was emitted and which provides correspondence to - /// the source line list. - MCSymbol *RecordSourceLine(unsigned Line, unsigned Col, MDNode *Scope); - - /// getRecordSourceLineCount - Count source lines. - unsigned getRecordSourceLineCount(); - /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should /// be emitted. bool ShouldEmitDwarfDebug() const; - void BeginScope(const MachineInstr *MI, MCSymbol *Label); + void BeginScope(const MachineInstr *MI); void EndScope(const MachineInstr *MI); }; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Mar 29 12:20:31 2010 @@ -62,7 +62,7 @@ TM(tm), MAI(tm.getMCAsmInfo()), TRI(tm.getRegisterInfo()), OutContext(Streamer.getContext()), OutStreamer(Streamer), - LastMI(0), LastFn(0), Counter(~0U), SetCounter(0), PrevDLT(NULL) { + LastMI(0), LastFn(0), Counter(~0U), SetCounter(0) { DW = 0; MMI = 0; VerboseAsm = Streamer.isVerboseAsm(); } @@ -1337,25 +1337,12 @@ if (!MAI || !DW || !MAI->doesSupportDebugInformation() || !DW->ShouldEmitDwarfDebug()) return; - if (MI->getOpcode() == TargetOpcode::DBG_VALUE) - return; - DebugLoc DL = MI->getDebugLoc(); - if (DL.isUnknown()) - return; - DILocation CurDLT = MF->getDILocation(DL); - if (!CurDLT.getScope().Verify()) - return; - if (!BeforePrintingInsn) { + if (!BeforePrintingInsn) // After printing instruction DW->EndScope(MI); - } else if (CurDLT.getNode() != PrevDLT) { - MCSymbol *L = DW->RecordSourceLine(CurDLT.getLineNumber(), - CurDLT.getColumnNumber(), - CurDLT.getScope().getNode()); - DW->BeginScope(MI, L); - PrevDLT = CurDLT.getNode(); - } + else + DW->BeginScope(MI); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 29 12:20:31 2010 @@ -296,7 +296,7 @@ : DwarfPrinter(OS, A, T), ModuleCU(0), AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(), DIEValues(), SectionSourceLines(), didInitial(false), shouldEmit(false), - CurrentFnDbgScope(0), DebugTimer(0) { + CurrentFnDbgScope(0), PrevDILoc(0), DebugTimer(0) { NextStringPoolNumber = 0; if (TimePassesIsEnabled) DebugTimer = new Timer("Dwarf Debug Writer"); @@ -2036,19 +2036,58 @@ } } -/// beginScope - Process beginning of a scope starting at Label. -void DwarfDebug::beginScope(const MachineInstr *MI, MCSymbol *Label) { +/// beginScope - Process beginning of a scope. +void DwarfDebug::beginScope(const MachineInstr *MI) { + // Ignore DBG_VALUE instructions. + if (MI->getOpcode() == TargetOpcode::DBG_VALUE) + return; + + // Check location. + DebugLoc DL = MI->getDebugLoc(); + if (DL.isUnknown()) + return; + DILocation DILoc = MF->getDILocation(DL); + if (!DILoc.getScope().Verify()) + return; + + // Check and update last known location info. + if(DILoc.getNode() == PrevDILoc) + return; + PrevDILoc = DILoc.getNode(); + + // Emit a label to indicate location change. This is used for line + // table even if this instruction does start a new scope. + MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), + DILoc.getColumnNumber(), + DILoc.getScope().getNode()); + + // update DbgScope if this instruction starts a new scope. InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI); if (I == DbgScopeBeginMap.end()) return; + ScopeVector &SD = I->second; for (ScopeVector::iterator SDI = SD.begin(), SDE = SD.end(); SDI != SDE; ++SDI) (*SDI)->setStartLabel(Label); + } /// endScope - Process end of a scope. void DwarfDebug::endScope(const MachineInstr *MI) { + // Ignore DBG_VALUE instruction. + if (MI->getOpcode() == TargetOpcode::DBG_VALUE) + return; + + // Check location. + DebugLoc DL = MI->getDebugLoc(); + if (DL.isUnknown()) + return; + DILocation DILoc = MF->getDILocation(DL); + if (!DILoc.getScope().Verify()) + return; + + // Emit a label and update DbgScope if this instruction ends a scope. InsnToDbgScopeMapTy::iterator I = DbgScopeEndMap.find(MI); if (I == DbgScopeEndMap.end()) return; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 29 12:20:31 2010 @@ -184,6 +184,10 @@ /// function. DenseMap CompileUnitOffsets; + /// Previous instruction's location information. This is used to determine + /// label location to indicate scope boundries in dwarf debug info. + mutable const MDNode *PrevDILoc; + /// DebugTimer - Timer for the Dwarf debug writer. Timer *DebugTimer; @@ -542,8 +546,8 @@ /// collectVariableInfo - Populate DbgScope entries with variables' info. void collectVariableInfo(); - /// beginScope - Process beginning of a scope starting at Label. - void beginScope(const MachineInstr *MI, MCSymbol *Label); + /// beginScope - Process beginning of a scope. + void beginScope(const MachineInstr *MI); /// endScope - Prcess end of a scope. void endScope(const MachineInstr *MI); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=99816&r1=99815&r2=99816&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Mon Mar 29 12:20:31 2010 @@ -73,27 +73,14 @@ MMI->EndFunction(); } -/// RecordSourceLine - Register a source line with debug info. Returns the -/// unique label that was emitted and which provides correspondence to -/// the source line list. -MCSymbol *DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col, - MDNode *Scope) { - return DD->recordSourceLine(Line, Col, Scope); -} - -/// getRecordSourceLineCount - Count source lines. -unsigned DwarfWriter::getRecordSourceLineCount() { - return DD->getSourceLineCount(); -} - /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should /// be emitted. bool DwarfWriter::ShouldEmitDwarfDebug() const { return DD && DD->ShouldEmitDwarfDebug(); } -void DwarfWriter::BeginScope(const MachineInstr *MI, MCSymbol *L) { - DD->beginScope(MI, L); +void DwarfWriter::BeginScope(const MachineInstr *MI) { + DD->beginScope(MI); } void DwarfWriter::EndScope(const MachineInstr *MI) { DD->endScope(MI); From sabre at nondot.org Mon Mar 29 12:36:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 17:36:02 -0000 Subject: [llvm-commits] [llvm] r99818 - in /llvm/trunk: lib/VMCore/Constants.cpp test/Feature/unions.ll Message-ID: <20100329173602.5A10C2A6C132@llvm.org> Author: lattner Date: Mon Mar 29 12:36:02 2010 New Revision: 99818 URL: http://llvm.org/viewvc/llvm-project?rev=99818&view=rev Log: add support for zero initialized unions, patch by Tim Northover! Modified: llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/test/Feature/unions.ll Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=99818&r1=99817&r2=99818&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Mar 29 12:36:02 2010 @@ -59,6 +59,7 @@ case Type::PointerTyID: return ConstantPointerNull::get(cast(Ty)); case Type::StructTyID: + case Type::UnionTyID: case Type::ArrayTyID: case Type::VectorTyID: return ConstantAggregateZero::get(Ty); @@ -944,7 +945,8 @@ // Factory Function Implementation ConstantAggregateZero* ConstantAggregateZero::get(const Type* Ty) { - assert((Ty->isStructTy() || Ty->isArrayTy() || Ty->isVectorTy()) && + assert((Ty->isStructTy() || Ty->isUnionTy() + || Ty->isArrayTy() || Ty->isVectorTy()) && "Cannot create an aggregate zero of non-aggregate type!"); LLVMContextImpl *pImpl = Ty->getContext().pImpl; Modified: llvm/trunk/test/Feature/unions.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/unions.ll?rev=99818&r1=99817&r2=99818&view=diff ============================================================================== --- llvm/trunk/test/Feature/unions.ll (original) +++ llvm/trunk/test/Feature/unions.ll Mon Mar 29 12:36:02 2010 @@ -6,7 +6,9 @@ @union1 = constant union { i32, i8 } { i32 4 } @union2 = constant union { i32, i8 } insertvalue(union { i32, i8 } undef, i32 4, 0) + at union3 = common global %union.anon zeroinitializer, align 8 define void @"Unions" () { ret void } + From sabre at nondot.org Mon Mar 29 12:38:47 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 17:38:47 -0000 Subject: [llvm-commits] [llvm] r99819 - in /llvm/trunk: lib/Target/CellSPU/SPU.h lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPURegisterInfo.cpp lib/Target/CellSPU/SPURegisterInfo.h test/CodeGen/CellSPU/bigstack.ll Message-ID: <20100329173847.EDD972A6C132@llvm.org> Author: lattner Date: Mon Mar 29 12:38:47 2010 New Revision: 99819 URL: http://llvm.org/viewvc/llvm-project?rev=99819&view=rev Log: >From Kalle Raiskila: "the bigstack patch for SPU, with testcase. It is essentially the patch committed as 97091, and reverted as 97099, but with the following additions: -in vararg handling, registers are marked to be live, to not confuse the register scavenger -function prologue and epilogue are not emitted, if the stack size is 16. 16 means it is empty - there is only the register scavenger emergency spill slot, which is not used as there is no stack." Added: llvm/trunk/test/CodeGen/CellSPU/bigstack.ll Modified: llvm/trunk/lib/Target/CellSPU/SPU.h llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h Modified: llvm/trunk/lib/Target/CellSPU/SPU.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPU.h?rev=99819&r1=99818&r2=99819&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPU.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPU.h Mon Mar 29 12:38:47 2010 @@ -66,9 +66,6 @@ //! Predicate test for an unsigned 10-bit value /*! \param Value The input value to be tested - - This predicate tests for an unsigned 10-bit value, returning the 10-bit value - as a short if true. */ inline bool isU10Constant(short Value) { return (Value == (Value & 0x3ff)); @@ -90,6 +87,70 @@ return (Value == (Value & 0x3ff)); } + //! Predicate test for a signed 14-bit value + /*! + \param Value The input value to be tested + */ + template + inline bool isS14Constant(T Value); + + template<> + inline bool isS14Constant(short Value) { + return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); + } + + template<> + inline bool isS14Constant(int Value) { + return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); + } + + template<> + inline bool isS14Constant(uint32_t Value) { + return (Value <= ((1 << 13) - 1)); + } + + template<> + inline bool isS14Constant(int64_t Value) { + return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); + } + + template<> + inline bool isS14Constant(uint64_t Value) { + return (Value <= ((1 << 13) - 1)); + } + + //! Predicate test for a signed 16-bit value + /*! + \param Value The input value to be tested + */ + template + inline bool isS16Constant(T Value); + + template<> + inline bool isS16Constant(short Value) { + return true; + } + + template<> + inline bool isS16Constant(int Value) { + return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); + } + + template<> + inline bool isS16Constant(uint32_t Value) { + return (Value <= ((1 << 15) - 1)); + } + + template<> + inline bool isS16Constant(int64_t Value) { + return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); + } + + template<> + inline bool isS16Constant(uint64_t Value) { + return (Value <= ((1 << 15) - 1)); + } + extern Target TheCellSPUTarget; } Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=99819&r1=99818&r2=99819&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Mon Mar 29 12:38:47 2010 @@ -1107,7 +1107,8 @@ VarArgsFrameIndex = MFI->CreateFixedObject(StackSlotSize, ArgOffset, true, false); SDValue FIN = DAG.getFrameIndex(VarArgsFrameIndex, PtrVT); - SDValue ArgVal = DAG.getRegister(ArgRegs[ArgRegIdx], MVT::v16i8); + unsigned VReg = MF.addLiveIn(ArgRegs[ArgRegIdx], &SPU::R32CRegClass); + SDValue ArgVal = DAG.getRegister(VReg, MVT::v16i8); SDValue Store = DAG.getStore(Chain, dl, ArgVal, FIN, NULL, 0, false, false, 0); Chain = Store.getOperand(0); Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp?rev=99819&r1=99818&r2=99819&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Mon Mar 29 12:38:47 2010 @@ -28,6 +28,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineLocation.h" #include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/RegisterScavenging.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" @@ -336,6 +337,7 @@ MachineBasicBlock &MBB = *MI.getParent(); MachineFunction &MF = *MBB.getParent(); MachineFrameInfo *MFI = MF.getFrameInfo(); + DebugLoc dl = II->getDebugLoc(); while (!MI.getOperand(i).isFI()) { ++i; @@ -364,11 +366,22 @@ // Replace the FrameIndex with base register with $sp (aka $r1) SPOp.ChangeToRegister(SPU::R1, false); - if (Offset > SPUFrameInfo::maxFrameOffset() - || Offset < SPUFrameInfo::minFrameOffset()) { - errs() << "Large stack adjustment (" - << Offset - << ") in SPURegisterInfo::eliminateFrameIndex."; + + // if 'Offset' doesn't fit to the D-form instruction's + // immediate, convert the instruction to X-form + // if the instruction is not an AI (which takes a s10 immediate), assume + // it is a load/store that can take a s14 immediate + if ( (MI.getOpcode() == SPU::AIr32 && !isS10Constant(Offset)) + || !isS14Constant(Offset) ) { + int newOpcode = convertDFormToXForm(MI.getOpcode()); + unsigned tmpReg = findScratchRegister(II, RS, &SPU::R32CRegClass, SPAdj); + BuildMI(MBB, II, dl, TII.get(SPU::ILr32), tmpReg ) + .addImm(Offset); + BuildMI(MBB, II, dl, TII.get(newOpcode), MI.getOperand(0).getReg()) + .addReg(tmpReg, RegState::Kill) + .addReg(SPU::R1); + // remove the replaced D-form instruction + MBB.erase(II); } else { MO.ChangeToImmediate(Offset); } @@ -423,6 +436,14 @@ MF.getRegInfo().setPhysRegUnused(SPU::R0); MF.getRegInfo().setPhysRegUnused(SPU::R1); MF.getRegInfo().setPhysRegUnused(SPU::R2); + + MachineFrameInfo *MFI = MF.getFrameInfo(); + const TargetRegisterClass *RC = &SPU::R32CRegClass; + RS->setScavengingFrameIndex(MFI->CreateStackObject(RC->getSize(), + RC->getAlignment(), + false)); + + } void SPURegisterInfo::emitPrologue(MachineFunction &MF) const @@ -448,7 +469,8 @@ assert((FrameSize & 0xf) == 0 && "SPURegisterInfo::emitPrologue: FrameSize not aligned"); - if (FrameSize > 0 || MFI->hasCalls()) { + // the "empty" frame size is 16 - just the register scavenger spill slot + if (FrameSize > 16 || MFI->hasCalls()) { FrameSize = -(FrameSize + SPUFrameInfo::minStackSize()); if (hasDebugInfo) { // Mark effective beginning of when frame pointer becomes valid. @@ -467,7 +489,7 @@ // Adjust $sp by required amout BuildMI(MBB, MBBI, dl, TII.get(SPU::AIr32), SPU::R1).addReg(SPU::R1) .addImm(FrameSize); - } else if (FrameSize <= (1 << 16) - 1 && FrameSize >= -(1 << 16)) { + } else if (isS16Constant(FrameSize)) { // Frame size can be loaded into ILr32n, so temporarily spill $r2 and use // $r2 to adjust $sp: BuildMI(MBB, MBBI, dl, TII.get(SPU::STQDr128), SPU::R2) @@ -475,7 +497,7 @@ .addReg(SPU::R1); BuildMI(MBB, MBBI, dl, TII.get(SPU::ILr32), SPU::R2) .addImm(FrameSize); - BuildMI(MBB, MBBI, dl, TII.get(SPU::STQDr32), SPU::R1) + BuildMI(MBB, MBBI, dl, TII.get(SPU::STQXr32), SPU::R1) .addReg(SPU::R2) .addReg(SPU::R1); BuildMI(MBB, MBBI, dl, TII.get(SPU::Ar32), SPU::R1) @@ -549,7 +571,9 @@ "Can only insert epilog into returning blocks"); assert((FrameSize & 0xf) == 0 && "SPURegisterInfo::emitEpilogue: FrameSize not aligned"); - if (FrameSize > 0 || MFI->hasCalls()) { + + // the "empty" frame size is 16 - just the register scavenger spill slot + if (FrameSize > 16 || MFI->hasCalls()) { FrameSize = FrameSize + SPUFrameInfo::minStackSize(); if (isS10Constant(FrameSize + LinkSlotOffset)) { // Reload $lr, adjust $sp by required amount @@ -574,7 +598,7 @@ .addReg(SPU::R2); BuildMI(MBB, MBBI, dl, TII.get(SPU::LQDr128), SPU::R0) .addImm(16) - .addReg(SPU::R2); + .addReg(SPU::R1); BuildMI(MBB, MBBI, dl, TII.get(SPU::SFIr32), SPU::R2). addReg(SPU::R2) .addImm(16); @@ -618,4 +642,43 @@ return SPUGenRegisterInfo::getDwarfRegNumFull(RegNum, 0); } +int +SPURegisterInfo::convertDFormToXForm(int dFormOpcode) const +{ + switch(dFormOpcode) + { + case SPU::AIr32: return SPU::Ar32; + case SPU::LQDr32: return SPU::LQXr32; + case SPU::LQDr128: return SPU::LQXr128; + case SPU::LQDv16i8: return SPU::LQXv16i8; + case SPU::LQDv4f32: return SPU::LQXv4f32; + case SPU::STQDr32: return SPU::STQXr32; + case SPU::STQDr128: return SPU::STQXr128; + case SPU::STQDv16i8: return SPU::STQXv16i8; + case SPU::STQDv4i32: return SPU::STQXv4i32; + case SPU::STQDv4f32: return SPU::STQXv4f32; + + default: assert( false && "Unhandled D to X-form conversion"); + } + // default will assert, but need to return something to keep the + // compiler happy. + return dFormOpcode; +} + +// TODO this is already copied from PPC. Could this convenience function +// be moved to the RegScavenger class? +unsigned +SPURegisterInfo::findScratchRegister(MachineBasicBlock::iterator II, + RegScavenger *RS, + const TargetRegisterClass *RC, + int SPAdj) const +{ + assert(RS && "Register scavenging must be on"); + unsigned Reg = RS->FindUnusedReg(RC); + if (Reg == 0) + Reg = RS->scavengeRegister(RC, II, SPAdj); + assert( Reg && "Register scavenger failed"); + return Reg; +} + #include "SPUGenRegisterInfo.inc" Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h?rev=99819&r1=99818&r2=99819&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.h Mon Mar 29 12:38:47 2010 @@ -53,6 +53,10 @@ virtual const TargetRegisterClass* const * getCalleeSavedRegClasses(const MachineFunction *MF) const; + //! Allow for scavenging, so we can get scratch registers when needed. + virtual bool requiresRegisterScavenging(const MachineFunction &MF) const + { return true; } + //! Return the reserved registers BitVector getReservedRegs(const MachineFunction &MF) const; @@ -97,6 +101,21 @@ //! Get DWARF debugging register number int getDwarfRegNum(unsigned RegNum, bool isEH) const; + + //! Convert D-form load/store to X-form load/store + /*! + Converts a regiser displacement load/store into a register-indexed + load/store for large stack frames, when the stack frame exceeds the + range of a s10 displacement. + */ + int convertDFormToXForm(int dFormOpcode) const; + + //! Acquire an unused register in an emergency. + unsigned findScratchRegister(MachineBasicBlock::iterator II, + RegScavenger *RS, + const TargetRegisterClass *RC, + int SPAdj) const; + }; } // end namespace llvm Added: llvm/trunk/test/CodeGen/CellSPU/bigstack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/bigstack.ll?rev=99819&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/bigstack.ll (added) +++ llvm/trunk/test/CodeGen/CellSPU/bigstack.ll Mon Mar 29 12:38:47 2010 @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=cellspu -o %t1.s +; RUN: grep lqx %t1.s | count 4 +; RUN: grep il %t1.s | grep -v file | count 7 +; RUN: grep stqx %t1.s | count 2 + +define i32 @bigstack() nounwind { +entry: + %avar = alloca i32 + %big_data = alloca [2048 x i32] + store i32 3840, i32* %avar, align 4 + br label %return + +return: + %retval = load i32* %avar + ret i32 %retval +} + From sabre at nondot.org Mon Mar 29 12:50:39 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 17:50:39 -0000 Subject: [llvm-commits] [llvm] r99820 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <20100329175039.7F1902A6C132@llvm.org> Author: lattner Date: Mon Mar 29 12:50:39 2010 New Revision: 99820 URL: http://llvm.org/viewvc/llvm-project?rev=99820&view=rev Log: add tce Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=99820&r1=99819&r2=99820&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Mon Mar 29 12:50:39 2010 @@ -404,6 +404,27 @@ + + + +
+

+TCE is a toolset for designing +application-specific processors (ASP) based on the Transport triggered +architecture (TTA). The toolset provides a complete co-design flow from C/C++ +programs down to synthesizable VHDL and parallel program binaries. Processor +customization points include the register files, function units, supported +operations, and the interconnection network.

+ +

TCE uses llvm-gcc/Clang and LLVM for C/C++ language support, target +independent optimizations and also for parts of code generation. It generates +new LLVM-based code generators "on the fly" for the designed TTA processors and +loads them in to the compiler backend as runtime libraries to avoid per-target +recompilation of larger parts of the compiler chain.

+ +
From criswell at uiuc.edu Mon Mar 29 12:59:31 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 29 Mar 2010 17:59:31 -0000 Subject: [llvm-commits] [poolalloc] r99822 - /poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Message-ID: <20100329175931.B570C2A6C12C@llvm.org> Author: criswell Date: Mon Mar 29 12:59:31 2010 New Revision: 99822 URL: http://llvm.org/viewvc/llvm-project?rev=99822&view=rev Log: Reenabled and updated the code for simple pool allocation to handle the fact that LLVM 2.7 no longer has malloc and free instructions. Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=99822&r1=99821&r2=99822&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon Mar 29 12:59:31 2010 @@ -156,9 +156,10 @@ void PoolAllocateSimple::ProcessFunctionBodySimple (Function& F, TargetData & TD) { + // Set of instructions to delete because they have been replaced. We record + // all instructions to delete first and then delete them later to avoid + // invalidating the iterators over the instruction list. std::vector toDelete; - std::vector Returns; - std::vector ToFree; // // Create a silly Function Info structure for this function. @@ -171,48 +172,67 @@ // DSGraph* ECG = Graphs->getDSGraph(F); - for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i) + for (Function::iterator i = F.begin(), e = F.end(); i != e; ++i) { for (BasicBlock::iterator ii = i->begin(), ee = i->end(); ii != ee; ++ii) { - if (false) { - //FIXME: malloc -#if 0 - if (MallocInst * MI = dyn_cast(ii)) { - // Associate the global pool decriptor with the DSNode - DSNode * Node = ECG->getNodeForValue(MI).getNode(); - FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool)); - - // Mark the malloc as an instruction to delete - toDelete.push_back(ii); - - // Create instructions to calculate the size of the allocation in - // bytes - Value * AllocSize; - if (MI->isArrayAllocation()) { - Value * NumElements = MI->getArraySize(); - Value * ElementSize = ConstantInt::get(Int32Type, - TD.getTypeAllocSize(MI->getAllocatedType())); - AllocSize = BinaryOperator::Create (Instruction::Mul, - ElementSize, - NumElements, - "sizetmp", - MI); - } else { - AllocSize = ConstantInt::get(Int32Type, - TD.getTypeAllocSize(MI->getAllocatedType())); - } - - Value* args[] = {TheGlobalPool, AllocSize}; - Instruction* x = CallInst::Create(PoolAlloc, &args[0], &args[2], MI->getName(), ii); - ii->replaceAllUsesWith(CastInst::CreatePointerCast(x, ii->getType(), "", ii)); - #endif - } else if (CallInst * CI = dyn_cast(ii)) { + if (CallInst * CI = dyn_cast(ii)) { + // + // Get the name of the called function. + // CallSite CS(CI); Function *CF = CS.getCalledFunction(); - if (ConstantExpr *CE = dyn_cast(CS.getCalledValue())) + if (ConstantExpr *CE = dyn_cast(CS.getCalledValue())) { if (CE->getOpcode() == Instruction::BitCast && - isa(CE->getOperand(0))) + isa(CE->getOperand(0))) { CF = cast(CE->getOperand(0)); - if (CF && (CF->isDeclaration()) && (CF->getName() == "realloc")) { + } + } + + // + // Process functions that we recognize as allocators. + // + if (CF && (CF->isDeclaration()) && (CF->getName() == "malloc")) { + // Associate the global pool decriptor with the DSNode + DSNode * Node = ECG->getNodeForValue(CI).getNode(); + FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool)); + + // Mark the call to malloc as an instruction to delete + toDelete.push_back(CI); + + // Insertion point - Instruction before which all our instructions go + Instruction *InsertPt = CI; + Value *Size = CS.getArgument(0); + + // Ensure the size and pointer arguments are of the correct type + if (Size->getType() != Int32Type) + Size = CastInst::CreateIntegerCast (Size, + Int32Type, + false, + Size->getName(), + InsertPt); + + // + // Remember the name of the old instruction and then clear it. This + // allows us to give the name to the new call to poolalloc(). + // + std::string Name = CI->getName(); CI->setName(""); + + // + // Insert the call to poolalloc() + // + Value* Opts[3] = {TheGlobalPool, Size}; + Instruction *V = CallInst::Create (PoolAlloc, + Opts, + Opts + 2, + Name, + InsertPt); + + Instruction *Casted = V; + if (V->getType() != CI->getType()) + Casted = CastInst::CreatePointerCast (V, CI->getType(), V->getName(), InsertPt); + + // Update def-use info + CI->replaceAllUsesWith(Casted); + } else if (CF && (CF->isDeclaration()) && (CF->getName() == "realloc")) { // Associate the global pool decriptor with the DSNode DSNode * Node = ECG->getNodeForValue(CI).getNode(); FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool)); @@ -328,33 +348,20 @@ // Update def-use info CI->replaceAllUsesWith(Casted); + } else if (CF && (CF->isDeclaration()) && (CF->getName() == "free")) { + Type * VoidPtrTy = PointerType::getUnqual(Int8Type); + Value * FreedNode = castTo (CI->getOperand(1), VoidPtrTy, "cast", ii); + toDelete.push_back(ii); + Value* args[] = {TheGlobalPool, FreedNode}; + CallInst::Create(PoolFree, &args[0], &args[2], "", ii); } - //FIXME: free - #if 0 - } else if (FreeInst * FI = dyn_cast(ii)) { - Type * VoidPtrTy = PointerType::getUnqual(Int8Type); - Value * FreedNode = castTo (FI->getPointerOperand(), VoidPtrTy, "cast", ii); - toDelete.push_back(ii); - Value* args[] = {TheGlobalPool, FreedNode}; - CallInst::Create(PoolFree, &args[0], &args[2], "", ii); - #endif - } else if (isa(ii)) { - Returns.push_back(cast(ii)); } } + } - //add frees at each return for the allocas - for (std::vector::iterator i = Returns.begin(), e = Returns.end(); - i != e; ++i) - for (std::vector::iterator ii = ToFree.begin(), ee = ToFree.end(); - ii != ee; ++ii) { - std::vector args; - args.push_back (TheGlobalPool); - args.push_back (*ii); - CallInst::Create(PoolFree, args.begin(), args.end(), "", *i); - } - - //delete malloc and alloca insts + // + // Delete all instructions that were previously scheduled for deletion. + // for (unsigned x = 0; x < toDelete.size(); ++x) toDelete[x]->eraseFromParent(); } From sabre at nondot.org Mon Mar 29 13:34:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 18:34:13 -0000 Subject: [llvm-commits] [llvm] r99824 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <20100329183413.624F32A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 13:34:13 2010 New Revision: 99824 URL: http://llvm.org/viewvc/llvm-project?rev=99824&view=rev Log: update the vmkit blurb Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=99824&r1=99823&r2=99824&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Mon Mar 29 13:34:13 2010 @@ -175,13 +175,23 @@ compilation.

-VMKit version ?? builds with LLVM 2.7 and you can find it on its -web page. The release includes -bug fixes, cleanup and new features. The major changes are:

+With the release of LLVM 2.7, VMKit has shifted to a great framework for writing +virtual machines. VMKit now offers precise and efficient garbage collection with +multi-threading support, thanks to the MMTk memory management toolkit, as well +as just in time and ahead of time compilation with LLVM. The major changes in +VMKit 0.27 are:

    -
  • ...
  • +
  • Garbage collection: VMKit now uses the MMTk toolkit for garbage collectors. + The first collector to be ported is the MarkSweep collector, which is precise, + and drastically improves the performance of VMKit.
  • +
  • Line number information in the JVM: by using the debug metadata of LLVM, the + JVM now supports precise line number information, useful when printing a stack + trace.
  • +
  • Interface calls in the JVM: we implemented a variant of the Interface Method + Table technique for interface calls in the JVM. +
From evan.cheng at apple.com Mon Mar 29 13:38:28 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 29 Mar 2010 11:38:28 -0700 Subject: [llvm-commits] [llvm] r99469 - in /llvm/trunk: include/llvm/CodeGen/MachineOperand.h include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/InstrEmitter.cpp lib/CodeGen/SelectionDAG/InstrEmitter.h lib/CodeGen/SelectionDAG/SDNodeDbgValue.h l In-Reply-To: References: Message-ID: <37F7E1A8-9AB0-4736-9C59-7C304AA2BB3A@apple.com> Looking. Evan On Mar 26, 2010, at 10:16 PM, Jeffrey Yasskin wrote: > Hey Evan, this change may have introduced the new memory leak in > DebugInfo/2010-02-01-DbgValueCrash.ll > (http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/7/steps/test-llvm/logs/stdio). > The whole valgrind error (run at r99590) is: > > ==8278== 56 bytes in 1 blocks are definitely lost in loss record 130 of 135 > ==8278== at 0x4C229C7: operator new(unsigned long) (vg_replace_malloc.c:220) > ==8278== by 0xD809F6: > llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst&, > unsigned int) (SelectionDAGBuilder.cpp:3840) > ==8278== by 0xD87327: > llvm::SelectionDAGBuilder::visitCall(llvm::CallInst&) > (SelectionDAGBuilder.cpp:4662) > ==8278== by 0xD62E31: llvm::SelectionDAGBuilder::visit(unsigned > int, llvm::User&) (Instruction.def:161) > ==8278== by 0xD6293D: > llvm::SelectionDAGBuilder::visit(llvm::Instruction&) > (SelectionDAGBuilder.cpp:617) > ==8278== by 0xDA455C: > llvm::SelectionDAGISel::SelectBasicBlock(llvm::BasicBlock*, > llvm::ilist_iterator, > llvm::ilist_iterator, bool&) > (SelectionDAGISel.cpp:407) > ==8278== by 0xDA7952: > llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function&, > llvm::MachineFunction&, llvm::MachineModuleInfo*, llvm::DwarfWriter*, > llvm::TargetInstrInfo const&) (SelectionDAGISel.cpp:1030) > ==8278== by 0xDA41E6: > llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) > (SelectionDAGISel.cpp:344) > ==8278== by 0xEBE6B6: > llvm::MachineFunctionPass::runOnFunction(llvm::Function&) > (MachineFunctionPass.cpp:27) > ==8278== by 0x11E2A5C: > llvm::FPPassManager::runOnFunction(llvm::Function&) > (PassManager.cpp:1350) > ==8278== by 0x11E2734: > llvm::FunctionPassManagerImpl::run(llvm::Function&) > (PassManager.cpp:1301) > ==8278== by 0x11E23E4: > llvm::FunctionPassManager::run(llvm::Function&) (PassManager.cpp:1231) > ==8278== > > Could you take a look? Sorry if you've already fixed this. > > On Wed, Mar 24, 2010 at 6:38 PM, Evan Cheng wrote: >> Author: evancheng >> Date: Wed Mar 24 20:38:16 2010 >> New Revision: 99469 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=99469&view=rev >> Log: >> Change how dbg_value sdnodes are converted into machine instructions. Their placement should be determined by the relative order of incoming llvm instructions. The scheduler will now use the SDNode ordering information to determine where to insert them. A dbg_value instruction is inserted after the instruction with the last highest source order and before the instruction with the next highest source order. It will optimize the placement by inserting right after the instruction that produces the value if they have consecutive order numbers. >> >> Here is a theoretical example that illustrates why the placement is important. >> >> tmp1 = >> store tmp1 -> x >> ... >> tmp2 = add ... >> ... >> call >> ... >> store tmp2 -> x >> >> Now mem2reg comes along: >> >> tmp1 = >> dbg_value (tmp1 -> x) >> ... >> tmp2 = add ... >> ... >> call >> ... >> dbg_value (tmp2 -> x) >> >> When the debugger examine the value of x after the add instruction but before the call, it should have the value of tmp1. >> >> Furthermore, for dbg_value's that reference constants, they should not be emitted at the beginning of the block (since they do not have "producers"). >> >> This patch also cleans up how SDISel manages DbgValue nodes. It allow a SDNode to be referenced by multiple SDDbgValue nodes. When a SDNode is deleted, it uses the information to find the SDDbgValues and invalidate them. They are not deleted until the corresponding SelectionDAG is destroyed. >> >> Modified: >> llvm/trunk/include/llvm/CodeGen/MachineOperand.h >> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >> llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >> llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >> >> Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) >> +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Wed Mar 24 20:38:16 2010 >> @@ -285,6 +285,11 @@ >> IsEarlyClobber = Val; >> } >> >> + void setIsDebug(bool Val = true) { >> + assert(isReg() && IsDef && "Wrong MachineOperand accessor"); >> + IsDebug = Val; >> + } >> + >> //===--------------------------------------------------------------------===// >> // Accessors for various operand types. >> //===--------------------------------------------------------------------===// >> >> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Mar 24 20:38:16 2010 >> @@ -60,42 +60,40 @@ >> >> /// SDDbgInfo - Keeps track of dbg_value information through SDISel. We do >> /// not build SDNodes for these so as not to perturb the generated code; >> -/// instead the info is kept off to the side in this structure. SDNodes may >> -/// have an associated dbg_value entry in DbgValMap. Debug info that is not >> -/// associated with any SDNode is held in DbgConstMap. It is possible for >> -/// optimizations to change a variable to a constant, in which case the >> -/// corresponding debug info is moved from the variable to the constant table >> -/// (NYI). >> +/// instead the info is kept off to the side in this structure. Each SDNode may >> +/// have one or more associated dbg_value entries. This information is kept in >> +/// DbgValMap. >> class SDDbgInfo { >> - DenseMap DbgVblMap; >> - SmallVector DbgConstMap; >> + SmallVector DbgValues; >> + DenseMap > DbgVblMap; >> >> void operator=(const SDDbgInfo&); // Do not implement. >> SDDbgInfo(const SDDbgInfo&); // Do not implement. >> public: >> SDDbgInfo() {} >> >> - void add(const SDNode *Node, SDDbgValue *V) { >> - DbgVblMap[Node] = V; >> + void add(SDDbgValue *V, const SDNode *Node = 0) { >> + if (Node) >> + DbgVblMap[Node].push_back(V); >> + DbgValues.push_back(V); >> } >> - void add(SDDbgValue *V) { DbgConstMap.push_back(V); } >> - void remove(const SDNode *Node) { >> - DenseMap::iterator Itr = >> - DbgVblMap.find(Node); >> - if (Itr != DbgVblMap.end()) >> - DbgVblMap.erase(Itr); >> - } >> - // No need to remove a constant. >> + >> void clear() { >> DbgVblMap.clear(); >> - DbgConstMap.clear(); >> + DbgValues.clear(); >> + } >> + >> + bool empty() const { >> + return DbgValues.empty(); >> } >> - SDDbgValue *getSDDbgValue(const SDNode *Node) { >> + >> + SmallVector &getSDDbgValues(const SDNode *Node) { >> return DbgVblMap[Node]; >> } >> - typedef SmallVector::iterator ConstDbgIterator; >> - ConstDbgIterator DbgConstBegin() { return DbgConstMap.begin(); } >> - ConstDbgIterator DbgConstEnd() { return DbgConstMap.end(); } >> + >> + typedef SmallVector::iterator DbgIterator; >> + DbgIterator DbgBegin() { return DbgValues.begin(); } >> + DbgIterator DbgEnd() { return DbgValues.end(); } >> }; >> >> enum CombineLevel { >> @@ -871,19 +869,21 @@ >> /// GetOrdering - Get the order for the SDNode. >> unsigned GetOrdering(const SDNode *SD) const; >> >> - /// AssignDbgInfo - Assign debug info to the SDNode. >> - void AssignDbgInfo(SDNode *SD, SDDbgValue *db); >> + /// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >> + /// value is produced by SD. >> + void AddDbgValue(SDDbgValue *DB, SDNode *SD = 0); >> >> - /// RememberDbgInfo - Remember debug info with no associated SDNode. >> - void RememberDbgInfo(SDDbgValue *db); >> + /// GetDbgValues - Get the debug values which reference the given SDNode. >> + SmallVector &GetDbgValues(const SDNode* SD) { >> + return DbgInfo->getSDDbgValues(SD); >> + } >> >> - /// GetDbgInfo - Get the debug info for the SDNode. >> - SDDbgValue *GetDbgInfo(const SDNode* SD); >> + /// hasDebugValues - Return true if there are any SDDbgValue nodes associated >> + /// with this SelectionDAG. >> + bool hasDebugValues() const { return !DbgInfo->empty(); } >> >> - SDDbgInfo::ConstDbgIterator DbgConstBegin() { >> - return DbgInfo->DbgConstBegin(); >> - } >> - SDDbgInfo::ConstDbgIterator DbgConstEnd() { return DbgInfo->DbgConstEnd(); } >> + SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } >> + SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); } >> >> void dump() const; >> >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Mar 24 20:38:16 2010 >> @@ -264,7 +264,8 @@ >> InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op, >> unsigned IIOpNum, >> const TargetInstrDesc *II, >> - DenseMap &VRBaseMap) { >> + DenseMap &VRBaseMap, >> + bool IsDebug) { >> assert(Op.getValueType() != MVT::Other && >> Op.getValueType() != MVT::Flag && >> "Chain and flag operands should occur at end of operand list!"); >> @@ -295,7 +296,11 @@ >> } >> } >> >> - MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef)); >> + MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef, >> + false/*isImp*/, false/*isKill*/, >> + false/*isDead*/, false/*isUndef*/, >> + false/*isEarlyClobber*/, >> + 0/*SubReg*/, IsDebug)); >> } >> >> /// AddOperand - Add the specified operand to the specified machine instr. II >> @@ -305,9 +310,10 @@ >> void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, >> unsigned IIOpNum, >> const TargetInstrDesc *II, >> - DenseMap &VRBaseMap) { >> + DenseMap &VRBaseMap, >> + bool IsDebug) { >> if (Op.isMachineOpcode()) { >> - AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >> + AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >> } else if (ConstantSDNode *C = dyn_cast(Op)) { >> MI->addOperand(MachineOperand::CreateImm(C->getSExtValue())); >> } else if (ConstantFPSDNode *F = dyn_cast(Op)) { >> @@ -356,7 +362,7 @@ >> assert(Op.getValueType() != MVT::Other && >> Op.getValueType() != MVT::Flag && >> "Chain and flag operands should occur at end of operand list!"); >> - AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >> + AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >> } >> } >> >> @@ -498,75 +504,48 @@ >> assert(isNew && "Node emitted out of order - early"); >> } >> >> -/// EmitDbgValue - Generate any debug info that refers to this Node. Constant >> -/// dbg_value is not handled here. >> -void >> -InstrEmitter::EmitDbgValue(SDNode *Node, >> - DenseMap &VRBaseMap, >> - SDDbgValue *sd) { >> - if (!Node->getHasDebugValue()) >> - return; >> - if (!sd) >> - return; >> - assert(sd->getKind() == SDDbgValue::SDNODE); >> - unsigned VReg = getVR(SDValue(sd->getSDNode(), sd->getResNo()), VRBaseMap); >> - const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >> - DebugLoc DL = sd->getDebugLoc(); >> - MachineInstr *MI; >> - if (VReg) { >> - MI = BuildMI(*MF, DL, II).addReg(VReg, RegState::Debug). >> - addImm(sd->getOffset()). >> - addMetadata(sd->getMDPtr()); >> - } else { >> - // Insert an Undef so we can see what we dropped. >> - MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()). >> - addMetadata(sd->getMDPtr()); >> - } >> - MBB->insert(InsertPos, MI); >> -} >> - >> -/// EmitDbgValue - Generate debug info that does not refer to a SDNode. >> -void >> -InstrEmitter::EmitDbgValue(SDDbgValue *sd, >> +/// EmitDbgValue - Generate machine instruction for a dbg_value node. >> +/// >> +MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD, >> + MachineBasicBlock *InsertBB, >> + DenseMap &VRBaseMap, >> DenseMap *EM) { >> - if (!sd) >> - return; >> + uint64_t Offset = SD->getOffset(); >> + MDNode* MDPtr = SD->getMDPtr(); >> + DebugLoc DL = SD->getDebugLoc(); >> + >> const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >> - uint64_t Offset = sd->getOffset(); >> - MDNode* mdPtr = sd->getMDPtr(); >> - SDDbgValue::DbgValueKind kind = sd->getKind(); >> - DebugLoc DL = sd->getDebugLoc(); >> - MachineInstr* MI; >> - if (kind == SDDbgValue::CONST) { >> - Value *V = sd->getConst(); >> + MachineInstrBuilder MIB = BuildMI(*MF, DL, II); >> + if (SD->getKind() == SDDbgValue::SDNODE) { >> + AddOperand(&*MIB, SDValue(SD->getSDNode(), SD->getResNo()), >> + (*MIB).getNumOperands(), &II, VRBaseMap, true /*IsDebug*/); >> + } else if (SD->getKind() == SDDbgValue::CONST) { >> + Value *V = SD->getConst(); >> if (ConstantInt *CI = dyn_cast(V)) { >> - MI = BuildMI(*MF, DL, II).addImm(CI->getZExtValue()). >> - addImm(Offset).addMetadata(mdPtr); >> + MIB.addImm(CI->getSExtValue()); >> } else if (ConstantFP *CF = dyn_cast(V)) { >> - MI = BuildMI(*MF, DL, II).addFPImm(CF). >> - addImm(Offset).addMetadata(mdPtr); >> + MIB.addFPImm(CF); >> } else { >> // Could be an Undef. In any case insert an Undef so we can see what we >> // dropped. >> - MI = BuildMI(*MF, DL, II).addReg(0U). >> - addImm(Offset).addMetadata(mdPtr); >> + MIB.addReg(0U); >> } >> - } else if (kind == SDDbgValue::FRAMEIX) { >> - unsigned FrameIx = sd->getFrameIx(); >> + } else if (SD->getKind() == SDDbgValue::FRAMEIX) { >> + unsigned FrameIx = SD->getFrameIx(); >> // Stack address; this needs to be lowered in target-dependent fashion. >> // FIXME test that the target supports this somehow; if not emit Undef. >> // Create a pseudo for EmitInstrWithCustomInserter's consumption. >> - MI = BuildMI(*MF, DL, II).addImm(FrameIx). >> - addImm(Offset).addMetadata(mdPtr); >> - MBB = TLI->EmitInstrWithCustomInserter(MI, MBB, EM); >> - InsertPos = MBB->end(); >> - return; >> + MIB.addImm(FrameIx).addImm(Offset).addMetadata(MDPtr); >> + abort(); >> + TLI->EmitInstrWithCustomInserter(&*MIB, InsertBB, EM); >> + return 0; >> } else { >> // Insert an Undef so we can see what we dropped. >> - MI = BuildMI(*MF, DL, II).addReg(0U). >> - addImm(Offset).addMetadata(mdPtr); >> + MIB.addReg(0U); >> } >> - MBB->insert(InsertPos, MI); >> + >> + MIB.addImm(Offset).addMetadata(MDPtr); >> + return &*MIB; >> } >> >> /// EmitNode - Generate machine code for a node and needed dependencies. >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Wed Mar 24 20:38:16 2010 >> @@ -64,7 +64,8 @@ >> void AddRegisterOperand(MachineInstr *MI, SDValue Op, >> unsigned IIOpNum, >> const TargetInstrDesc *II, >> - DenseMap &VRBaseMap); >> + DenseMap &VRBaseMap, >> + bool IsDebug = false); >> >> /// AddOperand - Add the specified operand to the specified machine instr. II >> /// specifies the instruction information for the node, and IIOpNum is the >> @@ -73,7 +74,8 @@ >> void AddOperand(MachineInstr *MI, SDValue Op, >> unsigned IIOpNum, >> const TargetInstrDesc *II, >> - DenseMap &VRBaseMap); >> + DenseMap &VRBaseMap, >> + bool IsDebug = false); >> >> /// EmitSubregNode - Generate machine code for subreg nodes. >> /// >> @@ -98,16 +100,12 @@ >> /// MachineInstr. >> static unsigned CountOperands(SDNode *Node); >> >> - /// EmitDbgValue - Generate any debug info that refers to this Node. Constant >> - /// dbg_value is not handled here. >> - void EmitDbgValue(SDNode *Node, >> - DenseMap &VRBaseMap, >> - SDDbgValue* sd); >> - >> - >> - /// EmitDbgValue - Generate a constant DBG_VALUE. No node is involved. >> - void EmitDbgValue(SDDbgValue* sd, >> - DenseMap *EM); >> + /// EmitDbgValue - Generate machine instruction for a dbg_value node. >> + /// >> + MachineInstr *EmitDbgValue(SDDbgValue *SD, >> + MachineBasicBlock *InsertBB, >> + DenseMap &VRBaseMap, >> + DenseMap *EM); >> >> /// EmitNode - Generate machine code for a node and needed dependencies. >> /// >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h Wed Mar 24 20:38:16 2010 >> @@ -47,10 +47,12 @@ >> uint64_t Offset; >> DebugLoc DL; >> unsigned Order; >> + bool Invalid; >> public: >> // Constructor for non-constants. >> SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, >> - unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { >> + unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O), >> + Invalid(false) { >> kind = SDNODE; >> u.s.Node = N; >> u.s.ResNo = R; >> @@ -97,6 +99,12 @@ >> // Returns the SDNodeOrder. This is the order of the preceding node in the >> // input. >> unsigned getOrder() { return Order; } >> + >> + // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" >> + // property. A SDDbgValue is invalid if the SDNode that produces the value is >> + // deleted. >> + void setIsInvalidated() { Invalid = true; } >> + bool isInvalidated() { return Invalid; } >> }; >> >> } // end llvm namespace >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Wed Mar 24 20:38:16 2010 >> @@ -23,6 +23,7 @@ >> #include "llvm/Target/TargetSubtarget.h" >> #include "llvm/ADT/DenseMap.h" >> #include "llvm/ADT/SmallPtrSet.h" >> +#include "llvm/ADT/SmallSet.h" >> #include "llvm/ADT/SmallVector.h" >> #include "llvm/ADT/Statistic.h" >> #include "llvm/Support/Debug.h" >> @@ -407,19 +408,67 @@ >> } >> } >> >> +namespace { >> + struct OrderSorter { >> + bool operator()(const std::pair &A, >> + const std::pair &B) { >> + return A.first < B.first; >> + } >> + }; >> +} >> + >> +// ProcessSourceNode - Process nodes with source order numbers. These are added >> +// to a vector which EmitSchedule use to determine how to insert dbg_value >> +// instructions in the right order. >> +static void ProcessSourceNode(SDNode *N, SelectionDAG *DAG, >> + InstrEmitter &Emitter, >> + DenseMap *EM, >> + DenseMap &VRBaseMap, >> + SmallVector, 32> &Orders, >> + SmallSet &Seen) { >> + unsigned Order = DAG->GetOrdering(N); >> + if (!Order || !Seen.insert(Order)) >> + return; >> + >> + MachineBasicBlock *BB = Emitter.getBlock(); >> + if (BB->empty() || BB->back().isPHI()) { >> + // Did not insert any instruction. >> + Orders.push_back(std::make_pair(Order, (MachineInstr*)0)); >> + return; >> + } >> + >> + Orders.push_back(std::make_pair(Order, &BB->back())); >> + if (!N->getHasDebugValue()) >> + return; >> + // Opportunistically insert immediate dbg_value uses, i.e. those with source >> + // order number right after the N. >> + MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos(); >> + SmallVector &DVs = DAG->GetDbgValues(N); >> + for (unsigned i = 0, e = DVs.size(); i != e; ++i) { >> + if (DVs[i]->isInvalidated()) >> + continue; >> + unsigned DVOrder = DVs[i]->getOrder(); >> + if (DVOrder == ++Order) { >> + // FIXME: If the source node with next higher order is scheduled before >> + // this could end up generating funky debug info. >> + MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], BB, VRBaseMap, EM); >> + Orders.push_back(std::make_pair(DVOrder, DbgMI)); >> + BB->insert(InsertPos, DbgMI); >> + DVs[i]->setIsInvalidated(); >> + } >> + } >> +} >> + >> + >> /// EmitSchedule - Emit the machine code in scheduled order. >> MachineBasicBlock *ScheduleDAGSDNodes:: >> EmitSchedule(DenseMap *EM) { >> InstrEmitter Emitter(BB, InsertPos); >> DenseMap VRBaseMap; >> DenseMap CopyVRBaseMap; >> - >> - // For now, any constant debug info nodes go at the beginning. >> - for (SDDbgInfo::ConstDbgIterator I = DAG->DbgConstBegin(), >> - E = DAG->DbgConstEnd(); I!=E; I++) { >> - Emitter.EmitDbgValue(*I, EM); >> - delete *I; >> - } >> + SmallVector, 32> Orders; >> + SmallSet Seen; >> + bool HasDbg = DAG->hasDebugValues(); >> >> for (unsigned i = 0, e = Sequence.size(); i != e; i++) { >> SUnit *SU = Sequence[i]; >> @@ -442,22 +491,72 @@ >> N = N->getFlaggedNode()) >> FlaggedNodes.push_back(N); >> while (!FlaggedNodes.empty()) { >> + SDNode *N = FlaggedNodes.back(); >> Emitter.EmitNode(FlaggedNodes.back(), SU->OrigNode != SU, SU->isCloned, >> VRBaseMap, EM); >> - if (FlaggedNodes.back()->getHasDebugValue()) >> - if (SDDbgValue *sd = DAG->GetDbgInfo(FlaggedNodes.back())) { >> - Emitter.EmitDbgValue(FlaggedNodes.back(), VRBaseMap, sd); >> - delete sd; >> - } >> + // Remember the the source order of the inserted instruction. >> + if (HasDbg) >> + ProcessSourceNode(N, DAG, Emitter, EM, VRBaseMap, Orders, Seen); >> FlaggedNodes.pop_back(); >> } >> Emitter.EmitNode(SU->getNode(), SU->OrigNode != SU, SU->isCloned, >> VRBaseMap, EM); >> - if (SU->getNode()->getHasDebugValue()) >> - if (SDDbgValue *sd = DAG->GetDbgInfo(SU->getNode())) { >> - Emitter.EmitDbgValue(SU->getNode(), VRBaseMap, sd); >> - delete sd; >> + // Remember the the source order of the inserted instruction. >> + if (HasDbg) >> + ProcessSourceNode(SU->getNode(), DAG, Emitter, EM, VRBaseMap, Orders, >> + Seen); >> + } >> + >> + // Insert all the dbg_value which have not already been inserted in source >> + // order sequence. >> + if (HasDbg) { >> + MachineBasicBlock::iterator BBBegin = BB->empty() ? BB->end() : BB->begin(); >> + while (BBBegin != BB->end() && BBBegin->isPHI()) >> + ++BBBegin; >> + >> + // Sort the source order instructions and use the order to insert debug >> + // values. >> + std::sort(Orders.begin(), Orders.end(), OrderSorter()); >> + >> + SDDbgInfo::DbgIterator DI = DAG->DbgBegin(); >> + SDDbgInfo::DbgIterator DE = DAG->DbgEnd(); >> + // Now emit the rest according to source order. >> + unsigned LastOrder = 0; >> + MachineInstr *LastMI = 0; >> + for (unsigned i = 0, e = Orders.size(); i != e && DI != DE; ++i) { >> + unsigned Order = Orders[i].first; >> + MachineInstr *MI = Orders[i].second; >> + // Insert all SDDbgValue's whose order(s) are before "Order". >> + if (!MI) >> + continue; >> + MachineBasicBlock *MIBB = MI->getParent(); >> + for (; DI != DE && >> + (*DI)->getOrder() >= LastOrder && (*DI)->getOrder() < Order; ++DI) { >> + if ((*DI)->isInvalidated()) >> + continue; >> + MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, MIBB, VRBaseMap, EM); >> + if (!LastOrder) >> + // Insert to start of the BB (after PHIs). >> + BB->insert(BBBegin, DbgMI); >> + else { >> + MachineBasicBlock::iterator Pos = MI; >> + MIBB->insert(llvm::next(Pos), DbgMI); >> + } >> } >> + LastOrder = Order; >> + LastMI = MI; >> + } >> + // Add trailing DbgValue's before the terminator. FIXME: May want to add >> + // some of them before one or more conditional branches? >> + while (DI != DE) { >> + MachineBasicBlock *InsertBB = Emitter.getBlock(); >> + MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator(); >> + if (!(*DI)->isInvalidated()) { >> + MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, InsertBB, VRBaseMap, EM); >> + InsertBB->insert(Pos, DbgMI); >> + } >> + ++DI; >> + } >> } >> >> BB = Emitter.getBlock(); >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 24 20:38:16 2010 >> @@ -598,8 +598,10 @@ >> // Remove the ordering of this node. >> Ordering->remove(N); >> >> - // And its entry in the debug info table, if any. >> - DbgInfo->remove(N); >> + // If any of the SDDbgValue nodes refer to this SDNode, invalidate them. >> + SmallVector &DbgVals = DbgInfo->getSDDbgValues(N); >> + for (unsigned i = 0, e = DbgVals.size(); i != e; ++i) >> + DbgVals[i]->setIsInvalidated(); >> } >> >> /// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that >> @@ -811,6 +813,7 @@ >> SelectionDAG::~SelectionDAG() { >> allnodes_clear(); >> delete Ordering; >> + DbgInfo->clear(); >> delete DbgInfo; >> } >> >> @@ -5241,24 +5244,12 @@ >> return Ordering->getOrder(SD); >> } >> >> -/// AssignDbgInfo - Assign debug info to the SDNode. >> -void SelectionDAG::AssignDbgInfo(SDNode* SD, SDDbgValue* db) { >> - assert(SD && "Trying to assign dbg info to a null node!"); >> - DbgInfo->add(SD, db); >> - SD->setHasDebugValue(true); >> -} >> - >> -/// RememberDbgInfo - Remember debug info which is not assigned to an SDNode. >> -void SelectionDAG::RememberDbgInfo(SDDbgValue* db) { >> - DbgInfo->add(db); >> -} >> - >> -/// GetDbgInfo - Get the debug info, if any, for the SDNode. >> -SDDbgValue* SelectionDAG::GetDbgInfo(const SDNode *SD) { >> - assert(SD && "Trying to get the order of a null node!"); >> - if (SD->getHasDebugValue()) >> - return DbgInfo->getSDDbgValue(SD); >> - return 0; >> +/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >> +/// value is produced by SD. >> +void SelectionDAG::AddDbgValue(SDDbgValue *DB, SDNode *SD) { >> + DbgInfo->add(DB, SD); >> + if (SD) >> + SD->setHasDebugValue(true); >> } >> >> //===----------------------------------------------------------------------===// >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99469&r1=99468&r2=99469&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Mar 24 20:38:16 2010 >> @@ -3825,20 +3825,20 @@ >> ++SDNodeOrder; >> if (isa(V) || isa(V)) { >> SDDbgValue* dv = new SDDbgValue(Variable, V, Offset, dl, SDNodeOrder); >> - DAG.RememberDbgInfo(dv); >> + DAG.AddDbgValue(dv); >> } else { >> SDValue &N = NodeMap[V]; >> if (N.getNode()) { >> SDDbgValue *dv = new SDDbgValue(Variable, N.getNode(), >> N.getResNo(), Offset, dl, SDNodeOrder); >> - DAG.AssignDbgInfo(N.getNode(), dv); >> + DAG.AddDbgValue(dv, N.getNode()); >> } else { >> // We may expand this to cover more cases. One case where we have no >> // data available is an unreferenced parameter; we need this fallback. >> SDDbgValue* dv = new SDDbgValue(Variable, >> UndefValue::get(V->getType()), >> Offset, dl, SDNodeOrder); >> - DAG.RememberDbgInfo(dv); >> + DAG.AddDbgValue(dv); >> } >> } >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From sabre at nondot.org Mon Mar 29 13:39:28 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 18:39:28 -0000 Subject: [llvm-commits] [llvm] r99825 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <20100329183928.BD9B92A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 13:39:28 2010 New Revision: 99825 URL: http://llvm.org/viewvc/llvm-project?rev=99825&view=rev Log: apparently llvm 2.7 now has great armv4 support, from John Tytgat Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=99825&r1=99824&r2=99825&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Mon Mar 29 13:39:28 2010 @@ -500,6 +500,9 @@ New LSR with full strength reduction mode The most awesome sext / zext optimization pass. ? +The ARM backend now has good support for ARMv4 backend (tested on StrongARM + hardware), previously only supported ARMv4T and newer. + CondProp pass removed (functionality merged into jump threading). From sabre at nondot.org Mon Mar 29 13:42:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 18:42:42 -0000 Subject: [llvm-commits] [llvm] r99826 - /llvm/trunk/docs/ReleaseNotes.html Message-ID: <20100329184242.D13B52A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 13:42:42 2010 New Revision: 99826 URL: http://llvm.org/viewvc/llvm-project?rev=99826&view=rev Log: some other notes. Modified: llvm/trunk/docs/ReleaseNotes.html Modified: llvm/trunk/docs/ReleaseNotes.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=99826&r1=99825&r2=99826&view=diff ============================================================================== --- llvm/trunk/docs/ReleaseNotes.html (original) +++ llvm/trunk/docs/ReleaseNotes.html Mon Mar 29 13:42:42 2010 @@ -483,7 +483,7 @@ Many subtle pointer invalidation bugs in Callgraph have been fixed and it now uses asserting value handles. MC Disassembler (with blog post), MCInstPrinter. Many X86 backend and AsmPrinter simplifications Various tools like llc and opt now read either .ll or .bc files as input. -Malloc and free instructions got removed. +Malloc and free instructions got removed, along with LowerAllocations pass. compiler-rt support for ARM. completely llvm-gcc NEON support. Can transcode from GAS to intel syntax with "llvm-mc foo.s -output-asm-variant=1" @@ -505,6 +505,7 @@ +Defaults to RTTI off, packagers should build with make REQUIRE_RTTI=1. CondProp pass removed (functionality merged into jump threading). AndersAA got removed (from 2.7 or mainline?) PredSimplify, LoopVR, GVNPRE got removed. From benny.kra at googlemail.com Mon Mar 29 14:07:58 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 29 Mar 2010 19:07:58 -0000 Subject: [llvm-commits] [llvm] r99827 - in /llvm/trunk/lib/Target/CellSPU: SPU.h SPUISelDAGToDAG.cpp SPUISelLowering.cpp SPURegisterInfo.cpp Message-ID: <20100329190758.3B47B2A6C12C@llvm.org> Author: d0k Date: Mon Mar 29 14:07:58 2010 New Revision: 99827 URL: http://llvm.org/viewvc/llvm-project?rev=99827&view=rev Log: Remove a bunch of integer width predicate functions in favor of MathExtras. Most of these were unused, some of them were wrong and unused (isS16Constant, isS10Constant). Modified: llvm/trunk/lib/Target/CellSPU/SPU.h llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Modified: llvm/trunk/lib/Target/CellSPU/SPU.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPU.h?rev=99827&r1=99826&r2=99827&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPU.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPU.h Mon Mar 29 14:07:58 2010 @@ -15,7 +15,6 @@ #ifndef LLVM_TARGET_IBMCELLSPU_H #define LLVM_TARGET_IBMCELLSPU_H -#include "llvm/System/DataTypes.h" #include "llvm/Target/TargetMachine.h" namespace llvm { @@ -25,134 +24,7 @@ FunctionPass *createSPUISelDag(SPUTargetMachine &TM); - /*--== Utility functions/predicates/etc used all over the place: --==*/ - //! Predicate test for a signed 10-bit value - /*! - \param Value The input value to be tested - - This predicate tests for a signed 10-bit value, returning the 10-bit value - as a short if true. - */ - template - inline bool isS10Constant(T Value); - - template<> - inline bool isS10Constant(short Value) { - int SExtValue = ((int) Value << (32 - 10)) >> (32 - 10); - return ((Value > 0 && Value <= (1 << 9) - 1) - || (Value < 0 && (short) SExtValue == Value)); - } - - template<> - inline bool isS10Constant(int Value) { - return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); - } - - template<> - inline bool isS10Constant(uint32_t Value) { - return (Value <= ((1 << 9) - 1)); - } - - template<> - inline bool isS10Constant(int64_t Value) { - return (Value >= -(1 << 9) && Value <= (1 << 9) - 1); - } - - template<> - inline bool isS10Constant(uint64_t Value) { - return (Value <= ((1 << 9) - 1)); - } - - //! Predicate test for an unsigned 10-bit value - /*! - \param Value The input value to be tested - */ - inline bool isU10Constant(short Value) { - return (Value == (Value & 0x3ff)); - } - - inline bool isU10Constant(int Value) { - return (Value == (Value & 0x3ff)); - } - - inline bool isU10Constant(uint32_t Value) { - return (Value == (Value & 0x3ff)); - } - - inline bool isU10Constant(int64_t Value) { - return (Value == (Value & 0x3ff)); - } - - inline bool isU10Constant(uint64_t Value) { - return (Value == (Value & 0x3ff)); - } - - //! Predicate test for a signed 14-bit value - /*! - \param Value The input value to be tested - */ - template - inline bool isS14Constant(T Value); - - template<> - inline bool isS14Constant(short Value) { - return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); - } - - template<> - inline bool isS14Constant(int Value) { - return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); - } - - template<> - inline bool isS14Constant(uint32_t Value) { - return (Value <= ((1 << 13) - 1)); - } - - template<> - inline bool isS14Constant(int64_t Value) { - return (Value >= -(1 << 13) && Value <= (1 << 13) - 1); - } - - template<> - inline bool isS14Constant(uint64_t Value) { - return (Value <= ((1 << 13) - 1)); - } - - //! Predicate test for a signed 16-bit value - /*! - \param Value The input value to be tested - */ - template - inline bool isS16Constant(T Value); - - template<> - inline bool isS16Constant(short Value) { - return true; - } - - template<> - inline bool isS16Constant(int Value) { - return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); - } - - template<> - inline bool isS16Constant(uint32_t Value) { - return (Value <= ((1 << 15) - 1)); - } - - template<> - inline bool isS16Constant(int64_t Value) { - return (Value >= -(1 << 15) && Value <= (1 << 15) - 1); - } - - template<> - inline bool isS16Constant(uint64_t Value) { - return (Value <= ((1 << 15) - 1)); - } - extern Target TheCellSPUTarget; - } // Defines symbolic names for the SPU instructions. Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=99827&r1=99826&r2=99827&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Mon Mar 29 14:07:58 2010 @@ -44,28 +44,28 @@ bool isI64IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSExtValue()); + return isInt<10>(CN->getSExtValue()); } //! ConstantSDNode predicate for i32 sign-extended, 10-bit immediates bool isI32IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSExtValue()); + return isInt<10>(CN->getSExtValue()); } //! ConstantSDNode predicate for i32 unsigned 10-bit immediate values bool isI32IntU10Immediate(ConstantSDNode *CN) { - return isU10Constant(CN->getSExtValue()); + return isUint<10>(CN->getSExtValue()); } //! ConstantSDNode predicate for i16 sign-extended, 10-bit immediate values bool isI16IntS10Immediate(ConstantSDNode *CN) { - return isS10Constant(CN->getSExtValue()); + return isInt<10>(CN->getSExtValue()); } //! SDNode predicate for i16 sign-extended, 10-bit immediate values @@ -80,7 +80,7 @@ bool isI16IntU10Immediate(ConstantSDNode *CN) { - return isU10Constant((short) CN->getZExtValue()); + return isUint<10>((short) CN->getZExtValue()); } //! SDNode predicate for i16 sign-extended, 10-bit immediate values Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=99827&r1=99826&r2=99827&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Mon Mar 29 14:07:58 2010 @@ -1492,7 +1492,7 @@ return SDValue(); Value = Value >> 32; } - if (isS10Constant(Value)) + if (isInt<10>(Value)) return DAG.getTargetConstant(Value, ValueType); } Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp?rev=99827&r1=99826&r2=99827&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Mon Mar 29 14:07:58 2010 @@ -371,8 +371,8 @@ // immediate, convert the instruction to X-form // if the instruction is not an AI (which takes a s10 immediate), assume // it is a load/store that can take a s14 immediate - if ( (MI.getOpcode() == SPU::AIr32 && !isS10Constant(Offset)) - || !isS14Constant(Offset) ) { + if ((MI.getOpcode() == SPU::AIr32 && !isInt<10>(Offset)) + || !isInt<14>(Offset)) { int newOpcode = convertDFormToXForm(MI.getOpcode()); unsigned tmpReg = findScratchRegister(II, RS, &SPU::R32CRegClass, SPAdj); BuildMI(MBB, II, dl, TII.get(SPU::ILr32), tmpReg ) @@ -482,14 +482,14 @@ // for the ABI BuildMI(MBB, MBBI, dl, TII.get(SPU::STQDr32), SPU::R0).addImm(16) .addReg(SPU::R1); - if (isS10Constant(FrameSize)) { + if (isInt<10>(FrameSize)) { // Spill $sp to adjusted $sp BuildMI(MBB, MBBI, dl, TII.get(SPU::STQDr32), SPU::R1).addImm(FrameSize) .addReg(SPU::R1); // Adjust $sp by required amout BuildMI(MBB, MBBI, dl, TII.get(SPU::AIr32), SPU::R1).addReg(SPU::R1) .addImm(FrameSize); - } else if (isS16Constant(FrameSize)) { + } else if (isInt<16>(FrameSize)) { // Frame size can be loaded into ILr32n, so temporarily spill $r2 and use // $r2 to adjust $sp: BuildMI(MBB, MBBI, dl, TII.get(SPU::STQDr128), SPU::R2) @@ -575,7 +575,7 @@ // the "empty" frame size is 16 - just the register scavenger spill slot if (FrameSize > 16 || MFI->hasCalls()) { FrameSize = FrameSize + SPUFrameInfo::minStackSize(); - if (isS10Constant(FrameSize + LinkSlotOffset)) { + if (isInt<10>(FrameSize + LinkSlotOffset)) { // Reload $lr, adjust $sp by required amount // Note: We do this to slightly improve dual issue -- not by much, but it // is an opportunity for dual issue. From sabre at nondot.org Mon Mar 29 15:35:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 20:35:01 -0000 Subject: [llvm-commits] [llvm] r99831 - /llvm/trunk/lib/Support/Timer.cpp Message-ID: <20100329203501.9CC302A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 15:35:01 2010 New Revision: 99831 URL: http://llvm.org/viewvc/llvm-project?rev=99831&view=rev Log: move code around and improve indentation, no functionality change. Modified: llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99831&r1=99830&r2=99831&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 15:35:01 2010 @@ -55,22 +55,26 @@ static TimerGroup *DefaultTimerGroup = 0; static TimerGroup *getDefaultTimerGroup() { - TimerGroup* tmp = DefaultTimerGroup; + TimerGroup *tmp = DefaultTimerGroup; sys::MemoryFence(); + if (tmp) return tmp; + + llvm_acquire_global_lock(); + tmp = DefaultTimerGroup; if (!tmp) { - llvm_acquire_global_lock(); - tmp = DefaultTimerGroup; - if (!tmp) { - tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); - sys::MemoryFence(); - DefaultTimerGroup = tmp; - } - llvm_release_global_lock(); + tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); + sys::MemoryFence(); + DefaultTimerGroup = tmp; } + llvm_release_global_lock(); return tmp; } +//===----------------------------------------------------------------------===// +// Timer Implementation +//===----------------------------------------------------------------------===// + Timer::Timer(const std::string &N) : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N), Started(false), TG(getDefaultTimerGroup()) { @@ -89,7 +93,6 @@ operator=(T); } - // Copy ctor, initialize with no TG member. Timer::Timer(bool, const Timer &T) { TG = T.TG; // Avoid assertion in operator= @@ -97,15 +100,14 @@ TG = 0; } - Timer::~Timer() { - if (TG) { - if (Started) { - Started = false; - TG->addTimerToPrint(*this); - } - TG->removeTimer(); + if (!TG) return; + + if (Started) { + Started = false; + TG->addTimerToPrint(*this); } + TG->removeTimer(); } static inline size_t getMemUsage() { @@ -129,17 +131,16 @@ ssize_t MemUsed = 0; if (Start) { MemUsed = getMemUsage(); - sys::Process::GetTimeUsage(now,user,sys); + sys::Process::GetTimeUsage(now, user, sys); } else { - sys::Process::GetTimeUsage(now,user,sys); + sys::Process::GetTimeUsage(now, user, sys); MemUsed = getMemUsage(); } - Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; - Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; - Result.MemUsed = MemUsed; - + Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; + Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; + Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.MemUsed = MemUsed; return Result; } @@ -196,19 +197,51 @@ (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); } + +static void printVal(double Val, double Total, raw_ostream &OS) { + if (Total < 1e-7) // Avoid dividing by zero... + OS << " ----- "; + else { + OS << " " << format("%7.4f", Val) << " ("; + OS << format("%5.1f", Val*100/Total) << "%)"; + } +} + +void Timer::print(const Timer &Total, raw_ostream &OS) { + sys::SmartScopedLock L(*TimerLock); + if (Total.UserTime) + printVal(UserTime, Total.UserTime, OS); + if (Total.SystemTime) + printVal(SystemTime, Total.SystemTime, OS); + if (Total.getProcessTime()) + printVal(getProcessTime(), Total.getProcessTime(), OS); + printVal(Elapsed, Total.Elapsed, OS); + + OS << " "; + + if (Total.MemUsed) { + OS << format("%9lld", (long long)MemUsed) << " "; + } + if (Total.PeakMem) { + if (PeakMem) { + OS << format("%9lld", (long long)PeakMem) << " "; + } else + OS << " "; + } + OS << Name << "\n"; + + Started = false; // Once printed, don't print again +} + + //===----------------------------------------------------------------------===// // NamedRegionTimer Implementation //===----------------------------------------------------------------------===// -namespace { - typedef std::map Name2Timer; typedef std::map > Name2Pair; -} - static ManagedStatic NamedTimers; - static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { @@ -252,42 +285,6 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// - -static void printVal(double Val, double Total, raw_ostream &OS) { - if (Total < 1e-7) // Avoid dividing by zero... - OS << " ----- "; - else { - OS << " " << format("%7.4f", Val) << " ("; - OS << format("%5.1f", Val*100/Total) << "%)"; - } -} - -void Timer::print(const Timer &Total, raw_ostream &OS) { - sys::SmartScopedLock L(*TimerLock); - if (Total.UserTime) - printVal(UserTime, Total.UserTime, OS); - if (Total.SystemTime) - printVal(SystemTime, Total.SystemTime, OS); - if (Total.getProcessTime()) - printVal(getProcessTime(), Total.getProcessTime(), OS); - printVal(Elapsed, Total.Elapsed, OS); - - OS << " "; - - if (Total.MemUsed) { - OS << format("%9lld", (long long)MemUsed) << " "; - } - if (Total.PeakMem) { - if (PeakMem) { - OS << format("%9lld", (long long)PeakMem) << " "; - } else - OS << " "; - } - OS << Name << "\n"; - - Started = false; // Once printed, don't print again -} - // GetLibSupportInfoOutputFile - Return a file stream to print our output on... raw_ostream * llvm::GetLibSupportInfoOutputFile() { @@ -313,70 +310,71 @@ void TimerGroup::removeTimer() { sys::SmartScopedLock L(*TimerLock); - if (--NumTimers == 0 && !TimersToPrint.empty()) { // Print timing report... - // Sort the timers in descending order by amount of time taken... - std::sort(TimersToPrint.begin(), TimersToPrint.end(), - std::greater()); - - // Figure out how many spaces to indent TimerGroup name... - unsigned Padding = (80-Name.length())/2; - if (Padding > 80) Padding = 0; // Don't allow "negative" numbers - - raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - - ++NumTimers; - { // Scope to contain Total timer... don't allow total timer to drop us to - // zero timers... - Timer Total("TOTAL"); - - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - Total.sum(TimersToPrint[i]); - - // Print out timing header... - *OutStream << "===" << std::string(73, '-') << "===\n" - << std::string(Padding, ' ') << Name << "\n" - << "===" << std::string(73, '-') - << "===\n"; - - // If this is not an collection of ungrouped times, print the total time. - // Ungrouped timers don't really make sense to add up. We still print the - // TOTAL line to make the percentages make sense. - if (this != DefaultTimerGroup) { - *OutStream << " Total Execution Time: "; - - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; - *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; - } - *OutStream << "\n"; - - if (Total.UserTime) - *OutStream << " ---User Time---"; - if (Total.SystemTime) - *OutStream << " --System Time--"; - if (Total.getProcessTime()) - *OutStream << " --User+System--"; - *OutStream << " ---Wall Time---"; - if (Total.getMemUsed()) - *OutStream << " ---Mem---"; - if (Total.getPeakMem()) - *OutStream << " -PeakMem-"; - *OutStream << " --- Name ---\n"; - - // Loop through all of the timing data, printing it out... - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - TimersToPrint[i].print(Total, *OutStream); - - Total.print(Total, *OutStream); - *OutStream << '\n'; - OutStream->flush(); - } - --NumTimers; + if (--NumTimers != 0 || TimersToPrint.empty()) + return; // Don't print timing report. + + // Sort the timers in descending order by amount of time taken. + std::sort(TimersToPrint.begin(), TimersToPrint.end(), + std::greater()); + + // Figure out how many spaces to indent TimerGroup name. + unsigned Padding = (80-Name.length())/2; + if (Padding > 80) Padding = 0; // Don't allow "negative" numbers - TimersToPrint.clear(); + raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - if (OutStream != &errs() && OutStream != &outs() && OutStream != &dbgs()) - delete OutStream; // Close the file... + ++NumTimers; + { // Scope to contain Total timer... don't allow total timer to drop us to + // zero timers... + Timer Total("TOTAL"); + + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + Total.sum(TimersToPrint[i]); + + // Print out timing header... + *OutStream << "===" << std::string(73, '-') << "===\n" + << std::string(Padding, ' ') << Name << "\n" + << "===" << std::string(73, '-') + << "===\n"; + + // If this is not an collection of ungrouped times, print the total time. + // Ungrouped timers don't really make sense to add up. We still print the + // TOTAL line to make the percentages make sense. + if (this != DefaultTimerGroup) { + *OutStream << " Total Execution Time: "; + + *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; + *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; + } + *OutStream << "\n"; + + if (Total.UserTime) + *OutStream << " ---User Time---"; + if (Total.SystemTime) + *OutStream << " --System Time--"; + if (Total.getProcessTime()) + *OutStream << " --User+System--"; + *OutStream << " ---Wall Time---"; + if (Total.getMemUsed()) + *OutStream << " ---Mem---"; + if (Total.getPeakMem()) + *OutStream << " -PeakMem-"; + *OutStream << " --- Name ---\n"; + + // Loop through all of the timing data, printing it out... + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + TimersToPrint[i].print(Total, *OutStream); + + Total.print(Total, *OutStream); + *OutStream << '\n'; + OutStream->flush(); } + --NumTimers; + + TimersToPrint.clear(); + + if (OutStream != &errs() && OutStream != &outs() && OutStream != &dbgs()) + delete OutStream; // Close the file... } void TimerGroup::addTimer() { From sabre at nondot.org Mon Mar 29 15:38:20 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 20:38:20 -0000 Subject: [llvm-commits] [llvm] r99832 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100329203820.8F90D2A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 15:38:20 2010 New Revision: 99832 URL: http://llvm.org/viewvc/llvm-project?rev=99832&view=rev Log: fix a variety of issues were we'd start DebugTimer but not stop it by using RAII. 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=99832&r1=99831&r2=99832&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 29 15:38:20 2010 @@ -1777,12 +1777,11 @@ void DwarfDebug::beginModule(Module *M, MachineModuleInfo *mmi) { this->M = M; - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - if (!MAI->doesSupportDebugInformation()) return; + TimeRegion Timer(DebugTimer); + DebugInfoFinder DbgFinder; DbgFinder.processModule(*M); @@ -1830,9 +1829,6 @@ // Emit initial sections emitInitial(); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); } /// endModule - Emit all Dwarf sections that should come after the content. @@ -1841,8 +1837,7 @@ if (!ModuleCU) return; - if (TimePassesIsEnabled) - DebugTimer->startTimer(); + TimeRegion Timer(DebugTimer); // Attach DW_AT_inline attribute with inlined subprogram DIEs. for (SmallPtrSet::iterator AI = InlinedSubprogramDIEs.begin(), @@ -1926,9 +1921,6 @@ delete ModuleCU; ModuleCU = NULL; // Reset for the next Module, if any. - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); } /// findAbstractVariable - Find abstract variable, if any, associated with Var. @@ -2229,12 +2221,10 @@ this->MF = MF; if (!ShouldEmitDwarfDebug()) return; - - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - if (!extractScopeInformation()) return; + + TimeRegion Timer(DebugTimer); collectVariableInfo(); @@ -2258,20 +2248,15 @@ recordSourceLine(Line, Col, DLT.getScope().getNode()); } - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); } /// endFunction - Gather and emit post-function debug information. /// void DwarfDebug::endFunction(const MachineFunction *MF) { if (!ShouldEmitDwarfDebug()) return; - - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - if (DbgScopeMap.empty()) - return; + if (DbgScopeMap.empty()) return; + + TimeRegion Timer(DebugTimer); if (CurrentFnDbgScope) { // Define end label for subprogram. @@ -2309,9 +2294,6 @@ AbstractScopesList.clear(); AbstractVariables.clear(); Lines.clear(); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); } /// recordSourceLine - Register a source line with debug info. Returns the @@ -2321,8 +2303,7 @@ if (!MMI) return 0; - if (TimePassesIsEnabled) - DebugTimer->startTimer(); + TimeRegion Timer(DebugTimer); StringRef Dir; StringRef Fn; @@ -2347,9 +2328,6 @@ MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Lines.push_back(SrcLineInfo(Line, Col, Src, Label)); - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - Asm->OutStreamer.EmitLabel(Label); return Label; } @@ -2361,15 +2339,8 @@ /// well. unsigned DwarfDebug::getOrCreateSourceID(const std::string &DirName, const std::string &FileName) { - if (TimePassesIsEnabled) - DebugTimer->startTimer(); - - unsigned SrcId = GetOrCreateSourceID(DirName.c_str(), FileName.c_str()); - - if (TimePassesIsEnabled) - DebugTimer->stopTimer(); - - return SrcId; + TimeRegion Timer(DebugTimer); + return GetOrCreateSourceID(DirName.c_str(), FileName.c_str()); } //===----------------------------------------------------------------------===// From sabre at nondot.org Mon Mar 29 15:39:38 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 20:39:38 -0000 Subject: [llvm-commits] [llvm] r99833 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <20100329203938.79A992A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 15:39:38 2010 New Revision: 99833 URL: http://llvm.org/viewvc/llvm-project?rev=99833&view=rev Log: use RAII for ExceptionTimer too Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=99833&r1=99832&r2=99833&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Mon Mar 29 15:39:38 2010 @@ -885,8 +885,7 @@ if (!shouldEmitMovesModule && !shouldEmitTableModule) return; - if (TimePassesIsEnabled) - ExceptionTimer->startTimer(); + TimeRegion Timer(ExceptionTimer); const std::vector Personalities = MMI->getPersonalities(); @@ -896,9 +895,6 @@ for (std::vector::iterator I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I) EmitFDE(*I); - - if (TimePassesIsEnabled) - ExceptionTimer->stopTimer(); } /// BeginFunction - Gather pre-function exception information. Assumes it's @@ -906,9 +902,7 @@ void DwarfException::BeginFunction(const MachineFunction *MF) { if (!MMI || !MAI->doesSupportExceptionHandling()) return; - if (TimePassesIsEnabled) - ExceptionTimer->startTimer(); - + TimeRegion Timer(ExceptionTimer); this->MF = MF; shouldEmitTable = shouldEmitMoves = false; @@ -924,9 +918,6 @@ shouldEmitTableModule |= shouldEmitTable; shouldEmitMovesModule |= shouldEmitMoves; - - if (TimePassesIsEnabled) - ExceptionTimer->stopTimer(); } /// EndFunction - Gather and emit post-function exception information. @@ -934,9 +925,7 @@ void DwarfException::EndFunction() { if (!shouldEmitMoves && !shouldEmitTable) return; - if (TimePassesIsEnabled) - ExceptionTimer->startTimer(); - + TimeRegion Timer(ExceptionTimer); Asm->OutStreamer.EmitLabel(getDWLabel("eh_func_end", SubprogramCount)); // Record if this personality index uses a landing pad. @@ -961,7 +950,4 @@ !MMI->getLandingPads().empty(), MMI->getFrameMoves(), MF->getFunction())); - - if (TimePassesIsEnabled) - ExceptionTimer->stopTimer(); } From sabre at nondot.org Mon Mar 29 15:40:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 20:40:19 -0000 Subject: [llvm-commits] [llvm] r99834 - /llvm/trunk/lib/Support/Timer.cpp Message-ID: <20100329204019.D4AFE2A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 15:40:19 2010 New Revision: 99834 URL: http://llvm.org/viewvc/llvm-project?rev=99834&view=rev Log: s/.../. Modified: llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99834&r1=99833&r2=99834&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 15:40:19 2010 @@ -199,7 +199,7 @@ static void printVal(double Val, double Total, raw_ostream &OS) { - if (Total < 1e-7) // Avoid dividing by zero... + if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; else { OS << " " << format("%7.4f", Val) << " ("; @@ -285,7 +285,7 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// -// GetLibSupportInfoOutputFile - Return a file stream to print our output on... +// GetLibSupportInfoOutputFile - Return a file stream to print our output on. raw_ostream * llvm::GetLibSupportInfoOutputFile() { std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); @@ -324,14 +324,14 @@ raw_ostream *OutStream = GetLibSupportInfoOutputFile(); ++NumTimers; - { // Scope to contain Total timer... don't allow total timer to drop us to - // zero timers... + { // Scope to contain Total timer: don't allow total timer to drop us to + // zero timers. Timer Total("TOTAL"); for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) Total.sum(TimersToPrint[i]); - // Print out timing header... + // Print out timing header. *OutStream << "===" << std::string(73, '-') << "===\n" << std::string(Padding, ' ') << Name << "\n" << "===" << std::string(73, '-') @@ -361,7 +361,7 @@ *OutStream << " -PeakMem-"; *OutStream << " --- Name ---\n"; - // Loop through all of the timing data, printing it out... + // Loop through all of the timing data, printing it out. for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) TimersToPrint[i].print(Total, *OutStream); @@ -374,7 +374,7 @@ TimersToPrint.clear(); if (OutStream != &errs() && OutStream != &outs() && OutStream != &dbgs()) - delete OutStream; // Close the file... + delete OutStream; // Close the file. } void TimerGroup::addTimer() { From echristo at apple.com Mon Mar 29 15:41:51 2010 From: echristo at apple.com (Eric Christopher) Date: Mon, 29 Mar 2010 20:41:51 -0000 Subject: [llvm-commits] [llvm] r99835 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100329204151.4DA412A6C12C@llvm.org> Author: echristo Date: Mon Mar 29 15:41:51 2010 New Revision: 99835 URL: http://llvm.org/viewvc/llvm-project?rev=99835&view=rev Log: We'll never match these as instructions, just as intrinsics so remove the SDNodes. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99835&r1=99834&r2=99835&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Mar 29 15:41:51 2010 @@ -69,12 +69,6 @@ def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>; def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>; -def X86aesimc : SDNode<"X86ISD::AESIMC", SDTIntBinOp>; -def X86aesenc : SDNode<"X86ISD::AESENC", SDTIntBinOp>; -def X86aesenclast : SDNode<"X86ISD::AESENCLAST", SDTIntBinOp>; -def X86aesdec : SDNode<"X86ISD::AESDEC", SDTIntBinOp>; -def X86aesdeclast : SDNode<"X86ISD::AESDECLAST", SDTIntBinOp>; - def SDTX86CmpPTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisVT<1, v4f32>, SDTCisVT<2, v4f32>]>; @@ -3841,25 +3835,25 @@ defm AESDECLAST : SS42I_binop_rm_int<0xDF, "aesdeclast", int_x86_sse42_aesdeclast>; -def : Pat<(v2i64 (X86aesimc VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, VR128:$src2)), (AESIMCrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (X86aesimc VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, (memop addr:$src2))), (AESIMCrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (X86aesenc VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, VR128:$src2)), (AESENCrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (X86aesenc VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, (memop addr:$src2))), (AESENCrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (X86aesenclast VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, VR128:$src2)), (AESENCLASTrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (X86aesenclast VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, (memop addr:$src2))), (AESENCLASTrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (X86aesdec VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, VR128:$src2)), (AESDECrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (X86aesdec VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, (memop addr:$src2))), (AESDECrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (X86aesdeclast VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, VR128:$src2)), (AESDECLASTrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (X86aesdeclast VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, (memop addr:$src2))), (AESDECLASTrm VR128:$src1, addr:$src2)>; def AESKEYGENASSIST128rr : SS42AI<0xDF, MRMSrcReg, (outs), From evan.cheng at apple.com Mon Mar 29 15:48:30 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 29 Mar 2010 20:48:30 -0000 Subject: [llvm-commits] [llvm] r99836 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Message-ID: <20100329204831.165F32A6C12C@llvm.org> Author: evancheng Date: Mon Mar 29 15:48:30 2010 New Revision: 99836 URL: http://llvm.org/viewvc/llvm-project?rev=99836&view=rev Log: Pool allocate SDDbgValue nodes. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99836&r1=99835&r2=99836&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Mon Mar 29 15:48:30 2010 @@ -34,6 +34,7 @@ class MachineConstantPoolValue; class MachineFunction; class MachineModuleInfo; +class MDNode; class SDNodeOrdering; class SDDbgValue; class TargetLowering; @@ -767,6 +768,15 @@ SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, const SDValue *Ops, unsigned NumOps); + /// getDbgValue - Creates a SDDbgValue node. + /// + SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off, + DebugLoc DL, unsigned O); + SDDbgValue *getDbgValue(MDNode *MDPtr, Value *C, uint64_t Off, + DebugLoc DL, unsigned O); + SDDbgValue *getDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off, + DebugLoc DL, unsigned O); + /// DAGUpdateListener - Clients of various APIs that cause global effects on /// the DAG can optionally implement this interface. This allows the clients /// to handle the various sorts of updates that happen. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99836&r1=99835&r2=99836&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Mar 29 15:48:30 2010 @@ -842,6 +842,7 @@ Root = getEntryNode(); delete Ordering; Ordering = new SDNodeOrdering(); + DbgInfo->clear(); delete DbgInfo; DbgInfo = new SDDbgInfo(); } @@ -4849,6 +4850,26 @@ return NULL; } +/// getDbgValue - Creates a SDDbgValue node. +/// +SDDbgValue * +SelectionDAG::getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R, uint64_t Off, + DebugLoc DL, unsigned O) { + return new (Allocator) SDDbgValue(MDPtr, N, R, Off, DL, O); +} + +SDDbgValue * +SelectionDAG::getDbgValue(MDNode *MDPtr, Value *C, uint64_t Off, + DebugLoc DL, unsigned O) { + return new (Allocator) SDDbgValue(MDPtr, C, Off, DL, O); +} + +SDDbgValue * +SelectionDAG::getDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off, + DebugLoc DL, unsigned O) { + return new (Allocator) SDDbgValue(MDPtr, FI, Off, DL, O); +} + namespace { /// RAUWUpdateListener - Helper for ReplaceAllUsesWith - When the node Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99836&r1=99835&r2=99836&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Mar 29 15:48:30 2010 @@ -3824,22 +3824,19 @@ // debug info exists. ++SDNodeOrder; if (isa(V) || isa(V)) { - SDDbgValue* dv = new SDDbgValue(Variable, V, Offset, dl, SDNodeOrder); - DAG.AddDbgValue(dv); + DAG.AddDbgValue(DAG.getDbgValue(Variable, V, Offset, dl, SDNodeOrder)); } else { SDValue &N = NodeMap[V]; - if (N.getNode()) { - SDDbgValue *dv = new SDDbgValue(Variable, N.getNode(), - N.getResNo(), Offset, dl, SDNodeOrder); - DAG.AddDbgValue(dv, N.getNode()); - } else { + if (N.getNode()) + DAG.AddDbgValue(DAG.getDbgValue(Variable, N.getNode(), + N.getResNo(), Offset, dl, SDNodeOrder), + N.getNode()); + else // We may expand this to cover more cases. One case where we have no // data available is an unreferenced parameter; we need this fallback. - SDDbgValue* dv = new SDDbgValue(Variable, + DAG.AddDbgValue(DAG.getDbgValue(Variable, UndefValue::get(V->getType()), - Offset, dl, SDNodeOrder); - DAG.AddDbgValue(dv); - } + Offset, dl, SDNodeOrder)); } // Build a debug info table entry. From evan.cheng at apple.com Mon Mar 29 15:49:23 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 29 Mar 2010 13:49:23 -0700 Subject: [llvm-commits] [llvm] r99469 - in /llvm/trunk: include/llvm/CodeGen/MachineOperand.h include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/InstrEmitter.cpp lib/CodeGen/SelectionDAG/InstrEmitter.h lib/CodeGen/SelectionDAG/SDNodeDbgValue.h l In-Reply-To: <37F7E1A8-9AB0-4736-9C59-7C304AA2BB3A@apple.com> References: <37F7E1A8-9AB0-4736-9C59-7C304AA2BB3A@apple.com> Message-ID: <51C8EEC7-AA24-4BCA-ADD3-80C8DF3C0A15@apple.com> Does 99836 fix it? Evan On Mar 29, 2010, at 11:38 AM, Evan Cheng wrote: > Looking. > > Evan > > On Mar 26, 2010, at 10:16 PM, Jeffrey Yasskin wrote: > >> Hey Evan, this change may have introduced the new memory leak in >> DebugInfo/2010-02-01-DbgValueCrash.ll >> (http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/7/steps/test-llvm/logs/stdio). >> The whole valgrind error (run at r99590) is: >> >> ==8278== 56 bytes in 1 blocks are definitely lost in loss record 130 of 135 >> ==8278== at 0x4C229C7: operator new(unsigned long) (vg_replace_malloc.c:220) >> ==8278== by 0xD809F6: >> llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst&, >> unsigned int) (SelectionDAGBuilder.cpp:3840) >> ==8278== by 0xD87327: >> llvm::SelectionDAGBuilder::visitCall(llvm::CallInst&) >> (SelectionDAGBuilder.cpp:4662) >> ==8278== by 0xD62E31: llvm::SelectionDAGBuilder::visit(unsigned >> int, llvm::User&) (Instruction.def:161) >> ==8278== by 0xD6293D: >> llvm::SelectionDAGBuilder::visit(llvm::Instruction&) >> (SelectionDAGBuilder.cpp:617) >> ==8278== by 0xDA455C: >> llvm::SelectionDAGISel::SelectBasicBlock(llvm::BasicBlock*, >> llvm::ilist_iterator, >> llvm::ilist_iterator, bool&) >> (SelectionDAGISel.cpp:407) >> ==8278== by 0xDA7952: >> llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function&, >> llvm::MachineFunction&, llvm::MachineModuleInfo*, llvm::DwarfWriter*, >> llvm::TargetInstrInfo const&) (SelectionDAGISel.cpp:1030) >> ==8278== by 0xDA41E6: >> llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) >> (SelectionDAGISel.cpp:344) >> ==8278== by 0xEBE6B6: >> llvm::MachineFunctionPass::runOnFunction(llvm::Function&) >> (MachineFunctionPass.cpp:27) >> ==8278== by 0x11E2A5C: >> llvm::FPPassManager::runOnFunction(llvm::Function&) >> (PassManager.cpp:1350) >> ==8278== by 0x11E2734: >> llvm::FunctionPassManagerImpl::run(llvm::Function&) >> (PassManager.cpp:1301) >> ==8278== by 0x11E23E4: >> llvm::FunctionPassManager::run(llvm::Function&) (PassManager.cpp:1231) >> ==8278== >> >> Could you take a look? Sorry if you've already fixed this. >> >> On Wed, Mar 24, 2010 at 6:38 PM, Evan Cheng wrote: >>> Author: evancheng >>> Date: Wed Mar 24 20:38:16 2010 >>> New Revision: 99469 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=99469&view=rev >>> Log: >>> Change how dbg_value sdnodes are converted into machine instructions. Their placement should be determined by the relative order of incoming llvm instructions. The scheduler will now use the SDNode ordering information to determine where to insert them. A dbg_value instruction is inserted after the instruction with the last highest source order and before the instruction with the next highest source order. It will optimize the placement by inserting right after the instruction that produces the value if they have consecutive order numbers. >>> >>> Here is a theoretical example that illustrates why the placement is important. >>> >>> tmp1 = >>> store tmp1 -> x >>> ... >>> tmp2 = add ... >>> ... >>> call >>> ... >>> store tmp2 -> x >>> >>> Now mem2reg comes along: >>> >>> tmp1 = >>> dbg_value (tmp1 -> x) >>> ... >>> tmp2 = add ... >>> ... >>> call >>> ... >>> dbg_value (tmp2 -> x) >>> >>> When the debugger examine the value of x after the add instruction but before the call, it should have the value of tmp1. >>> >>> Furthermore, for dbg_value's that reference constants, they should not be emitted at the beginning of the block (since they do not have "producers"). >>> >>> This patch also cleans up how SDISel manages DbgValue nodes. It allow a SDNode to be referenced by multiple SDDbgValue nodes. When a SDNode is deleted, it uses the information to find the SDDbgValues and invalidate them. They are not deleted until the corresponding SelectionDAG is destroyed. >>> >>> Modified: >>> llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>> llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>> llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>> llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>> >>> Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) >>> +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Wed Mar 24 20:38:16 2010 >>> @@ -285,6 +285,11 @@ >>> IsEarlyClobber = Val; >>> } >>> >>> + void setIsDebug(bool Val = true) { >>> + assert(isReg() && IsDef && "Wrong MachineOperand accessor"); >>> + IsDebug = Val; >>> + } >>> + >>> //===--------------------------------------------------------------------===// >>> // Accessors for various operand types. >>> //===--------------------------------------------------------------------===// >>> >>> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >>> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Mar 24 20:38:16 2010 >>> @@ -60,42 +60,40 @@ >>> >>> /// SDDbgInfo - Keeps track of dbg_value information through SDISel. We do >>> /// not build SDNodes for these so as not to perturb the generated code; >>> -/// instead the info is kept off to the side in this structure. SDNodes may >>> -/// have an associated dbg_value entry in DbgValMap. Debug info that is not >>> -/// associated with any SDNode is held in DbgConstMap. It is possible for >>> -/// optimizations to change a variable to a constant, in which case the >>> -/// corresponding debug info is moved from the variable to the constant table >>> -/// (NYI). >>> +/// instead the info is kept off to the side in this structure. Each SDNode may >>> +/// have one or more associated dbg_value entries. This information is kept in >>> +/// DbgValMap. >>> class SDDbgInfo { >>> - DenseMap DbgVblMap; >>> - SmallVector DbgConstMap; >>> + SmallVector DbgValues; >>> + DenseMap > DbgVblMap; >>> >>> void operator=(const SDDbgInfo&); // Do not implement. >>> SDDbgInfo(const SDDbgInfo&); // Do not implement. >>> public: >>> SDDbgInfo() {} >>> >>> - void add(const SDNode *Node, SDDbgValue *V) { >>> - DbgVblMap[Node] = V; >>> + void add(SDDbgValue *V, const SDNode *Node = 0) { >>> + if (Node) >>> + DbgVblMap[Node].push_back(V); >>> + DbgValues.push_back(V); >>> } >>> - void add(SDDbgValue *V) { DbgConstMap.push_back(V); } >>> - void remove(const SDNode *Node) { >>> - DenseMap::iterator Itr = >>> - DbgVblMap.find(Node); >>> - if (Itr != DbgVblMap.end()) >>> - DbgVblMap.erase(Itr); >>> - } >>> - // No need to remove a constant. >>> + >>> void clear() { >>> DbgVblMap.clear(); >>> - DbgConstMap.clear(); >>> + DbgValues.clear(); >>> + } >>> + >>> + bool empty() const { >>> + return DbgValues.empty(); >>> } >>> - SDDbgValue *getSDDbgValue(const SDNode *Node) { >>> + >>> + SmallVector &getSDDbgValues(const SDNode *Node) { >>> return DbgVblMap[Node]; >>> } >>> - typedef SmallVector::iterator ConstDbgIterator; >>> - ConstDbgIterator DbgConstBegin() { return DbgConstMap.begin(); } >>> - ConstDbgIterator DbgConstEnd() { return DbgConstMap.end(); } >>> + >>> + typedef SmallVector::iterator DbgIterator; >>> + DbgIterator DbgBegin() { return DbgValues.begin(); } >>> + DbgIterator DbgEnd() { return DbgValues.end(); } >>> }; >>> >>> enum CombineLevel { >>> @@ -871,19 +869,21 @@ >>> /// GetOrdering - Get the order for the SDNode. >>> unsigned GetOrdering(const SDNode *SD) const; >>> >>> - /// AssignDbgInfo - Assign debug info to the SDNode. >>> - void AssignDbgInfo(SDNode *SD, SDDbgValue *db); >>> + /// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>> + /// value is produced by SD. >>> + void AddDbgValue(SDDbgValue *DB, SDNode *SD = 0); >>> >>> - /// RememberDbgInfo - Remember debug info with no associated SDNode. >>> - void RememberDbgInfo(SDDbgValue *db); >>> + /// GetDbgValues - Get the debug values which reference the given SDNode. >>> + SmallVector &GetDbgValues(const SDNode* SD) { >>> + return DbgInfo->getSDDbgValues(SD); >>> + } >>> >>> - /// GetDbgInfo - Get the debug info for the SDNode. >>> - SDDbgValue *GetDbgInfo(const SDNode* SD); >>> + /// hasDebugValues - Return true if there are any SDDbgValue nodes associated >>> + /// with this SelectionDAG. >>> + bool hasDebugValues() const { return !DbgInfo->empty(); } >>> >>> - SDDbgInfo::ConstDbgIterator DbgConstBegin() { >>> - return DbgInfo->DbgConstBegin(); >>> - } >>> - SDDbgInfo::ConstDbgIterator DbgConstEnd() { return DbgInfo->DbgConstEnd(); } >>> + SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } >>> + SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); } >>> >>> void dump() const; >>> >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Mar 24 20:38:16 2010 >>> @@ -264,7 +264,8 @@ >>> InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op, >>> unsigned IIOpNum, >>> const TargetInstrDesc *II, >>> - DenseMap &VRBaseMap) { >>> + DenseMap &VRBaseMap, >>> + bool IsDebug) { >>> assert(Op.getValueType() != MVT::Other && >>> Op.getValueType() != MVT::Flag && >>> "Chain and flag operands should occur at end of operand list!"); >>> @@ -295,7 +296,11 @@ >>> } >>> } >>> >>> - MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef)); >>> + MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef, >>> + false/*isImp*/, false/*isKill*/, >>> + false/*isDead*/, false/*isUndef*/, >>> + false/*isEarlyClobber*/, >>> + 0/*SubReg*/, IsDebug)); >>> } >>> >>> /// AddOperand - Add the specified operand to the specified machine instr. II >>> @@ -305,9 +310,10 @@ >>> void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, >>> unsigned IIOpNum, >>> const TargetInstrDesc *II, >>> - DenseMap &VRBaseMap) { >>> + DenseMap &VRBaseMap, >>> + bool IsDebug) { >>> if (Op.isMachineOpcode()) { >>> - AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>> + AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>> } else if (ConstantSDNode *C = dyn_cast(Op)) { >>> MI->addOperand(MachineOperand::CreateImm(C->getSExtValue())); >>> } else if (ConstantFPSDNode *F = dyn_cast(Op)) { >>> @@ -356,7 +362,7 @@ >>> assert(Op.getValueType() != MVT::Other && >>> Op.getValueType() != MVT::Flag && >>> "Chain and flag operands should occur at end of operand list!"); >>> - AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>> + AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>> } >>> } >>> >>> @@ -498,75 +504,48 @@ >>> assert(isNew && "Node emitted out of order - early"); >>> } >>> >>> -/// EmitDbgValue - Generate any debug info that refers to this Node. Constant >>> -/// dbg_value is not handled here. >>> -void >>> -InstrEmitter::EmitDbgValue(SDNode *Node, >>> - DenseMap &VRBaseMap, >>> - SDDbgValue *sd) { >>> - if (!Node->getHasDebugValue()) >>> - return; >>> - if (!sd) >>> - return; >>> - assert(sd->getKind() == SDDbgValue::SDNODE); >>> - unsigned VReg = getVR(SDValue(sd->getSDNode(), sd->getResNo()), VRBaseMap); >>> - const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>> - DebugLoc DL = sd->getDebugLoc(); >>> - MachineInstr *MI; >>> - if (VReg) { >>> - MI = BuildMI(*MF, DL, II).addReg(VReg, RegState::Debug). >>> - addImm(sd->getOffset()). >>> - addMetadata(sd->getMDPtr()); >>> - } else { >>> - // Insert an Undef so we can see what we dropped. >>> - MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()). >>> - addMetadata(sd->getMDPtr()); >>> - } >>> - MBB->insert(InsertPos, MI); >>> -} >>> - >>> -/// EmitDbgValue - Generate debug info that does not refer to a SDNode. >>> -void >>> -InstrEmitter::EmitDbgValue(SDDbgValue *sd, >>> +/// EmitDbgValue - Generate machine instruction for a dbg_value node. >>> +/// >>> +MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD, >>> + MachineBasicBlock *InsertBB, >>> + DenseMap &VRBaseMap, >>> DenseMap *EM) { >>> - if (!sd) >>> - return; >>> + uint64_t Offset = SD->getOffset(); >>> + MDNode* MDPtr = SD->getMDPtr(); >>> + DebugLoc DL = SD->getDebugLoc(); >>> + >>> const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>> - uint64_t Offset = sd->getOffset(); >>> - MDNode* mdPtr = sd->getMDPtr(); >>> - SDDbgValue::DbgValueKind kind = sd->getKind(); >>> - DebugLoc DL = sd->getDebugLoc(); >>> - MachineInstr* MI; >>> - if (kind == SDDbgValue::CONST) { >>> - Value *V = sd->getConst(); >>> + MachineInstrBuilder MIB = BuildMI(*MF, DL, II); >>> + if (SD->getKind() == SDDbgValue::SDNODE) { >>> + AddOperand(&*MIB, SDValue(SD->getSDNode(), SD->getResNo()), >>> + (*MIB).getNumOperands(), &II, VRBaseMap, true /*IsDebug*/); >>> + } else if (SD->getKind() == SDDbgValue::CONST) { >>> + Value *V = SD->getConst(); >>> if (ConstantInt *CI = dyn_cast(V)) { >>> - MI = BuildMI(*MF, DL, II).addImm(CI->getZExtValue()). >>> - addImm(Offset).addMetadata(mdPtr); >>> + MIB.addImm(CI->getSExtValue()); >>> } else if (ConstantFP *CF = dyn_cast(V)) { >>> - MI = BuildMI(*MF, DL, II).addFPImm(CF). >>> - addImm(Offset).addMetadata(mdPtr); >>> + MIB.addFPImm(CF); >>> } else { >>> // Could be an Undef. In any case insert an Undef so we can see what we >>> // dropped. >>> - MI = BuildMI(*MF, DL, II).addReg(0U). >>> - addImm(Offset).addMetadata(mdPtr); >>> + MIB.addReg(0U); >>> } >>> - } else if (kind == SDDbgValue::FRAMEIX) { >>> - unsigned FrameIx = sd->getFrameIx(); >>> + } else if (SD->getKind() == SDDbgValue::FRAMEIX) { >>> + unsigned FrameIx = SD->getFrameIx(); >>> // Stack address; this needs to be lowered in target-dependent fashion. >>> // FIXME test that the target supports this somehow; if not emit Undef. >>> // Create a pseudo for EmitInstrWithCustomInserter's consumption. >>> - MI = BuildMI(*MF, DL, II).addImm(FrameIx). >>> - addImm(Offset).addMetadata(mdPtr); >>> - MBB = TLI->EmitInstrWithCustomInserter(MI, MBB, EM); >>> - InsertPos = MBB->end(); >>> - return; >>> + MIB.addImm(FrameIx).addImm(Offset).addMetadata(MDPtr); >>> + abort(); >>> + TLI->EmitInstrWithCustomInserter(&*MIB, InsertBB, EM); >>> + return 0; >>> } else { >>> // Insert an Undef so we can see what we dropped. >>> - MI = BuildMI(*MF, DL, II).addReg(0U). >>> - addImm(Offset).addMetadata(mdPtr); >>> + MIB.addReg(0U); >>> } >>> - MBB->insert(InsertPos, MI); >>> + >>> + MIB.addImm(Offset).addMetadata(MDPtr); >>> + return &*MIB; >>> } >>> >>> /// EmitNode - Generate machine code for a node and needed dependencies. >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Wed Mar 24 20:38:16 2010 >>> @@ -64,7 +64,8 @@ >>> void AddRegisterOperand(MachineInstr *MI, SDValue Op, >>> unsigned IIOpNum, >>> const TargetInstrDesc *II, >>> - DenseMap &VRBaseMap); >>> + DenseMap &VRBaseMap, >>> + bool IsDebug = false); >>> >>> /// AddOperand - Add the specified operand to the specified machine instr. II >>> /// specifies the instruction information for the node, and IIOpNum is the >>> @@ -73,7 +74,8 @@ >>> void AddOperand(MachineInstr *MI, SDValue Op, >>> unsigned IIOpNum, >>> const TargetInstrDesc *II, >>> - DenseMap &VRBaseMap); >>> + DenseMap &VRBaseMap, >>> + bool IsDebug = false); >>> >>> /// EmitSubregNode - Generate machine code for subreg nodes. >>> /// >>> @@ -98,16 +100,12 @@ >>> /// MachineInstr. >>> static unsigned CountOperands(SDNode *Node); >>> >>> - /// EmitDbgValue - Generate any debug info that refers to this Node. Constant >>> - /// dbg_value is not handled here. >>> - void EmitDbgValue(SDNode *Node, >>> - DenseMap &VRBaseMap, >>> - SDDbgValue* sd); >>> - >>> - >>> - /// EmitDbgValue - Generate a constant DBG_VALUE. No node is involved. >>> - void EmitDbgValue(SDDbgValue* sd, >>> - DenseMap *EM); >>> + /// EmitDbgValue - Generate machine instruction for a dbg_value node. >>> + /// >>> + MachineInstr *EmitDbgValue(SDDbgValue *SD, >>> + MachineBasicBlock *InsertBB, >>> + DenseMap &VRBaseMap, >>> + DenseMap *EM); >>> >>> /// EmitNode - Generate machine code for a node and needed dependencies. >>> /// >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h Wed Mar 24 20:38:16 2010 >>> @@ -47,10 +47,12 @@ >>> uint64_t Offset; >>> DebugLoc DL; >>> unsigned Order; >>> + bool Invalid; >>> public: >>> // Constructor for non-constants. >>> SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, >>> - unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { >>> + unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O), >>> + Invalid(false) { >>> kind = SDNODE; >>> u.s.Node = N; >>> u.s.ResNo = R; >>> @@ -97,6 +99,12 @@ >>> // Returns the SDNodeOrder. This is the order of the preceding node in the >>> // input. >>> unsigned getOrder() { return Order; } >>> + >>> + // setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" >>> + // property. A SDDbgValue is invalid if the SDNode that produces the value is >>> + // deleted. >>> + void setIsInvalidated() { Invalid = true; } >>> + bool isInvalidated() { return Invalid; } >>> }; >>> >>> } // end llvm namespace >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Wed Mar 24 20:38:16 2010 >>> @@ -23,6 +23,7 @@ >>> #include "llvm/Target/TargetSubtarget.h" >>> #include "llvm/ADT/DenseMap.h" >>> #include "llvm/ADT/SmallPtrSet.h" >>> +#include "llvm/ADT/SmallSet.h" >>> #include "llvm/ADT/SmallVector.h" >>> #include "llvm/ADT/Statistic.h" >>> #include "llvm/Support/Debug.h" >>> @@ -407,19 +408,67 @@ >>> } >>> } >>> >>> +namespace { >>> + struct OrderSorter { >>> + bool operator()(const std::pair &A, >>> + const std::pair &B) { >>> + return A.first < B.first; >>> + } >>> + }; >>> +} >>> + >>> +// ProcessSourceNode - Process nodes with source order numbers. These are added >>> +// to a vector which EmitSchedule use to determine how to insert dbg_value >>> +// instructions in the right order. >>> +static void ProcessSourceNode(SDNode *N, SelectionDAG *DAG, >>> + InstrEmitter &Emitter, >>> + DenseMap *EM, >>> + DenseMap &VRBaseMap, >>> + SmallVector, 32> &Orders, >>> + SmallSet &Seen) { >>> + unsigned Order = DAG->GetOrdering(N); >>> + if (!Order || !Seen.insert(Order)) >>> + return; >>> + >>> + MachineBasicBlock *BB = Emitter.getBlock(); >>> + if (BB->empty() || BB->back().isPHI()) { >>> + // Did not insert any instruction. >>> + Orders.push_back(std::make_pair(Order, (MachineInstr*)0)); >>> + return; >>> + } >>> + >>> + Orders.push_back(std::make_pair(Order, &BB->back())); >>> + if (!N->getHasDebugValue()) >>> + return; >>> + // Opportunistically insert immediate dbg_value uses, i.e. those with source >>> + // order number right after the N. >>> + MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos(); >>> + SmallVector &DVs = DAG->GetDbgValues(N); >>> + for (unsigned i = 0, e = DVs.size(); i != e; ++i) { >>> + if (DVs[i]->isInvalidated()) >>> + continue; >>> + unsigned DVOrder = DVs[i]->getOrder(); >>> + if (DVOrder == ++Order) { >>> + // FIXME: If the source node with next higher order is scheduled before >>> + // this could end up generating funky debug info. >>> + MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], BB, VRBaseMap, EM); >>> + Orders.push_back(std::make_pair(DVOrder, DbgMI)); >>> + BB->insert(InsertPos, DbgMI); >>> + DVs[i]->setIsInvalidated(); >>> + } >>> + } >>> +} >>> + >>> + >>> /// EmitSchedule - Emit the machine code in scheduled order. >>> MachineBasicBlock *ScheduleDAGSDNodes:: >>> EmitSchedule(DenseMap *EM) { >>> InstrEmitter Emitter(BB, InsertPos); >>> DenseMap VRBaseMap; >>> DenseMap CopyVRBaseMap; >>> - >>> - // For now, any constant debug info nodes go at the beginning. >>> - for (SDDbgInfo::ConstDbgIterator I = DAG->DbgConstBegin(), >>> - E = DAG->DbgConstEnd(); I!=E; I++) { >>> - Emitter.EmitDbgValue(*I, EM); >>> - delete *I; >>> - } >>> + SmallVector, 32> Orders; >>> + SmallSet Seen; >>> + bool HasDbg = DAG->hasDebugValues(); >>> >>> for (unsigned i = 0, e = Sequence.size(); i != e; i++) { >>> SUnit *SU = Sequence[i]; >>> @@ -442,22 +491,72 @@ >>> N = N->getFlaggedNode()) >>> FlaggedNodes.push_back(N); >>> while (!FlaggedNodes.empty()) { >>> + SDNode *N = FlaggedNodes.back(); >>> Emitter.EmitNode(FlaggedNodes.back(), SU->OrigNode != SU, SU->isCloned, >>> VRBaseMap, EM); >>> - if (FlaggedNodes.back()->getHasDebugValue()) >>> - if (SDDbgValue *sd = DAG->GetDbgInfo(FlaggedNodes.back())) { >>> - Emitter.EmitDbgValue(FlaggedNodes.back(), VRBaseMap, sd); >>> - delete sd; >>> - } >>> + // Remember the the source order of the inserted instruction. >>> + if (HasDbg) >>> + ProcessSourceNode(N, DAG, Emitter, EM, VRBaseMap, Orders, Seen); >>> FlaggedNodes.pop_back(); >>> } >>> Emitter.EmitNode(SU->getNode(), SU->OrigNode != SU, SU->isCloned, >>> VRBaseMap, EM); >>> - if (SU->getNode()->getHasDebugValue()) >>> - if (SDDbgValue *sd = DAG->GetDbgInfo(SU->getNode())) { >>> - Emitter.EmitDbgValue(SU->getNode(), VRBaseMap, sd); >>> - delete sd; >>> + // Remember the the source order of the inserted instruction. >>> + if (HasDbg) >>> + ProcessSourceNode(SU->getNode(), DAG, Emitter, EM, VRBaseMap, Orders, >>> + Seen); >>> + } >>> + >>> + // Insert all the dbg_value which have not already been inserted in source >>> + // order sequence. >>> + if (HasDbg) { >>> + MachineBasicBlock::iterator BBBegin = BB->empty() ? BB->end() : BB->begin(); >>> + while (BBBegin != BB->end() && BBBegin->isPHI()) >>> + ++BBBegin; >>> + >>> + // Sort the source order instructions and use the order to insert debug >>> + // values. >>> + std::sort(Orders.begin(), Orders.end(), OrderSorter()); >>> + >>> + SDDbgInfo::DbgIterator DI = DAG->DbgBegin(); >>> + SDDbgInfo::DbgIterator DE = DAG->DbgEnd(); >>> + // Now emit the rest according to source order. >>> + unsigned LastOrder = 0; >>> + MachineInstr *LastMI = 0; >>> + for (unsigned i = 0, e = Orders.size(); i != e && DI != DE; ++i) { >>> + unsigned Order = Orders[i].first; >>> + MachineInstr *MI = Orders[i].second; >>> + // Insert all SDDbgValue's whose order(s) are before "Order". >>> + if (!MI) >>> + continue; >>> + MachineBasicBlock *MIBB = MI->getParent(); >>> + for (; DI != DE && >>> + (*DI)->getOrder() >= LastOrder && (*DI)->getOrder() < Order; ++DI) { >>> + if ((*DI)->isInvalidated()) >>> + continue; >>> + MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, MIBB, VRBaseMap, EM); >>> + if (!LastOrder) >>> + // Insert to start of the BB (after PHIs). >>> + BB->insert(BBBegin, DbgMI); >>> + else { >>> + MachineBasicBlock::iterator Pos = MI; >>> + MIBB->insert(llvm::next(Pos), DbgMI); >>> + } >>> } >>> + LastOrder = Order; >>> + LastMI = MI; >>> + } >>> + // Add trailing DbgValue's before the terminator. FIXME: May want to add >>> + // some of them before one or more conditional branches? >>> + while (DI != DE) { >>> + MachineBasicBlock *InsertBB = Emitter.getBlock(); >>> + MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator(); >>> + if (!(*DI)->isInvalidated()) { >>> + MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, InsertBB, VRBaseMap, EM); >>> + InsertBB->insert(Pos, DbgMI); >>> + } >>> + ++DI; >>> + } >>> } >>> >>> BB = Emitter.getBlock(); >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 24 20:38:16 2010 >>> @@ -598,8 +598,10 @@ >>> // Remove the ordering of this node. >>> Ordering->remove(N); >>> >>> - // And its entry in the debug info table, if any. >>> - DbgInfo->remove(N); >>> + // If any of the SDDbgValue nodes refer to this SDNode, invalidate them. >>> + SmallVector &DbgVals = DbgInfo->getSDDbgValues(N); >>> + for (unsigned i = 0, e = DbgVals.size(); i != e; ++i) >>> + DbgVals[i]->setIsInvalidated(); >>> } >>> >>> /// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that >>> @@ -811,6 +813,7 @@ >>> SelectionDAG::~SelectionDAG() { >>> allnodes_clear(); >>> delete Ordering; >>> + DbgInfo->clear(); >>> delete DbgInfo; >>> } >>> >>> @@ -5241,24 +5244,12 @@ >>> return Ordering->getOrder(SD); >>> } >>> >>> -/// AssignDbgInfo - Assign debug info to the SDNode. >>> -void SelectionDAG::AssignDbgInfo(SDNode* SD, SDDbgValue* db) { >>> - assert(SD && "Trying to assign dbg info to a null node!"); >>> - DbgInfo->add(SD, db); >>> - SD->setHasDebugValue(true); >>> -} >>> - >>> -/// RememberDbgInfo - Remember debug info which is not assigned to an SDNode. >>> -void SelectionDAG::RememberDbgInfo(SDDbgValue* db) { >>> - DbgInfo->add(db); >>> -} >>> - >>> -/// GetDbgInfo - Get the debug info, if any, for the SDNode. >>> -SDDbgValue* SelectionDAG::GetDbgInfo(const SDNode *SD) { >>> - assert(SD && "Trying to get the order of a null node!"); >>> - if (SD->getHasDebugValue()) >>> - return DbgInfo->getSDDbgValue(SD); >>> - return 0; >>> +/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>> +/// value is produced by SD. >>> +void SelectionDAG::AddDbgValue(SDDbgValue *DB, SDNode *SD) { >>> + DbgInfo->add(DB, SD); >>> + if (SD) >>> + SD->setHasDebugValue(true); >>> } >>> >>> //===----------------------------------------------------------------------===// >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99469&r1=99468&r2=99469&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Mar 24 20:38:16 2010 >>> @@ -3825,20 +3825,20 @@ >>> ++SDNodeOrder; >>> if (isa(V) || isa(V)) { >>> SDDbgValue* dv = new SDDbgValue(Variable, V, Offset, dl, SDNodeOrder); >>> - DAG.RememberDbgInfo(dv); >>> + DAG.AddDbgValue(dv); >>> } else { >>> SDValue &N = NodeMap[V]; >>> if (N.getNode()) { >>> SDDbgValue *dv = new SDDbgValue(Variable, N.getNode(), >>> N.getResNo(), Offset, dl, SDNodeOrder); >>> - DAG.AssignDbgInfo(N.getNode(), dv); >>> + DAG.AddDbgValue(dv, N.getNode()); >>> } else { >>> // We may expand this to cover more cases. One case where we have no >>> // data available is an unreferenced parameter; we need this fallback. >>> SDDbgValue* dv = new SDDbgValue(Variable, >>> UndefValue::get(V->getType()), >>> Offset, dl, SDNodeOrder); >>> - DAG.RememberDbgInfo(dv); >>> + DAG.AddDbgValue(dv); >>> } >>> } >>> >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From jyasskin at google.com Mon Mar 29 15:53:47 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 29 Mar 2010 13:53:47 -0700 Subject: [llvm-commits] [llvm] r99469 - in /llvm/trunk: include/llvm/CodeGen/MachineOperand.h include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/InstrEmitter.cpp lib/CodeGen/SelectionDAG/InstrEmitter.h lib/CodeGen/SelectionDAG/SDNodeDbgValue.h l In-Reply-To: <51C8EEC7-AA24-4BCA-ADD3-80C8DF3C0A15@apple.com> References: <37F7E1A8-9AB0-4736-9C59-7C304AA2BB3A@apple.com> <51C8EEC7-AA24-4BCA-ADD3-80C8DF3C0A15@apple.com> Message-ID: I've started http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/11 to check. Thanks! On Mon, Mar 29, 2010 at 1:49 PM, Evan Cheng wrote: > Does 99836 fix it? > > Evan > On Mar 29, 2010, at 11:38 AM, Evan Cheng wrote: > >> Looking. >> >> Evan >> >> On Mar 26, 2010, at 10:16 PM, Jeffrey Yasskin wrote: >> >>> Hey Evan, this change may have introduced the new memory leak in >>> DebugInfo/2010-02-01-DbgValueCrash.ll >>> (http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/7/steps/test-llvm/logs/stdio). >>> The whole valgrind error (run at r99590) is: >>> >>> ==8278== 56 bytes in 1 blocks are definitely lost in loss record 130 of 135 >>> ==8278== ? ?at 0x4C229C7: operator new(unsigned long) (vg_replace_malloc.c:220) >>> ==8278== ? ?by 0xD809F6: >>> llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst&, >>> unsigned int) (SelectionDAGBuilder.cpp:3840) >>> ==8278== ? ?by 0xD87327: >>> llvm::SelectionDAGBuilder::visitCall(llvm::CallInst&) >>> (SelectionDAGBuilder.cpp:4662) >>> ==8278== ? ?by 0xD62E31: llvm::SelectionDAGBuilder::visit(unsigned >>> int, llvm::User&) (Instruction.def:161) >>> ==8278== ? ?by 0xD6293D: >>> llvm::SelectionDAGBuilder::visit(llvm::Instruction&) >>> (SelectionDAGBuilder.cpp:617) >>> ==8278== ? ?by 0xDA455C: >>> llvm::SelectionDAGISel::SelectBasicBlock(llvm::BasicBlock*, >>> llvm::ilist_iterator, >>> llvm::ilist_iterator, bool&) >>> (SelectionDAGISel.cpp:407) >>> ==8278== ? ?by 0xDA7952: >>> llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function&, >>> llvm::MachineFunction&, llvm::MachineModuleInfo*, llvm::DwarfWriter*, >>> llvm::TargetInstrInfo const&) (SelectionDAGISel.cpp:1030) >>> ==8278== ? ?by 0xDA41E6: >>> llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) >>> (SelectionDAGISel.cpp:344) >>> ==8278== ? ?by 0xEBE6B6: >>> llvm::MachineFunctionPass::runOnFunction(llvm::Function&) >>> (MachineFunctionPass.cpp:27) >>> ==8278== ? ?by 0x11E2A5C: >>> llvm::FPPassManager::runOnFunction(llvm::Function&) >>> (PassManager.cpp:1350) >>> ==8278== ? ?by 0x11E2734: >>> llvm::FunctionPassManagerImpl::run(llvm::Function&) >>> (PassManager.cpp:1301) >>> ==8278== ? ?by 0x11E23E4: >>> llvm::FunctionPassManager::run(llvm::Function&) (PassManager.cpp:1231) >>> ==8278== >>> >>> Could you take a look? Sorry if you've already fixed this. >>> >>> On Wed, Mar 24, 2010 at 6:38 PM, Evan Cheng wrote: >>>> Author: evancheng >>>> Date: Wed Mar 24 20:38:16 2010 >>>> New Revision: 99469 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=99469&view=rev >>>> Log: >>>> Change how dbg_value sdnodes are converted into machine instructions. Their placement should be determined by the relative order of incoming llvm instructions. The scheduler will now use the SDNode ordering information to determine where to insert them. A dbg_value instruction is inserted after the instruction with the last highest source order and before the instruction with the next highest source order. It will optimize the placement by inserting right after the instruction that produces the value if they have consecutive order numbers. >>>> >>>> Here is a theoretical example that illustrates why the placement is important. >>>> >>>> tmp1 = >>>> store tmp1 -> x >>>> ... >>>> tmp2 = add ... >>>> ... >>>> call >>>> ... >>>> store tmp2 -> x >>>> >>>> Now mem2reg comes along: >>>> >>>> tmp1 = >>>> dbg_value (tmp1 -> x) >>>> ... >>>> tmp2 = add ... >>>> ... >>>> call >>>> ... >>>> dbg_value (tmp2 -> x) >>>> >>>> When the debugger examine the value of x after the add instruction but before the call, it should have the value of tmp1. >>>> >>>> Furthermore, for dbg_value's that reference constants, they should not be emitted at the beginning of the block (since they do not have "producers"). >>>> >>>> This patch also cleans up how SDISel manages DbgValue nodes. It allow a SDNode to be referenced by multiple SDDbgValue nodes. When a SDNode is deleted, it uses the information to find the SDDbgValues and invalidate them. They are not deleted until the corresponding SelectionDAG is destroyed. >>>> >>>> Modified: >>>> ? llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>>> ? llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>>> >>>> Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) >>>> +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Wed Mar 24 20:38:16 2010 >>>> @@ -285,6 +285,11 @@ >>>> ? ?IsEarlyClobber = Val; >>>> ?} >>>> >>>> + ?void setIsDebug(bool Val = true) { >>>> + ? ?assert(isReg() && IsDef && "Wrong MachineOperand accessor"); >>>> + ? ?IsDebug = Val; >>>> + ?} >>>> + >>>> ?//===--------------------------------------------------------------------===// >>>> ?// Accessors for various operand types. >>>> ?//===--------------------------------------------------------------------===// >>>> >>>> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >>>> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Mar 24 20:38:16 2010 >>>> @@ -60,42 +60,40 @@ >>>> >>>> /// SDDbgInfo - Keeps track of dbg_value information through SDISel. ?We do >>>> /// not build SDNodes for these so as not to perturb the generated code; >>>> -/// instead the info is kept off to the side in this structure. ?SDNodes may >>>> -/// have an associated dbg_value entry in DbgValMap. ?Debug info that is not >>>> -/// associated with any SDNode is held in DbgConstMap. ?It is possible for >>>> -/// optimizations to change a variable to a constant, in which case the >>>> -/// corresponding debug info is moved from the variable to the constant table >>>> -/// (NYI). >>>> +/// instead the info is kept off to the side in this structure. Each SDNode may >>>> +/// have one or more associated dbg_value entries. This information is kept in >>>> +/// DbgValMap. >>>> class SDDbgInfo { >>>> - ?DenseMap DbgVblMap; >>>> - ?SmallVector DbgConstMap; >>>> + ?SmallVector DbgValues; >>>> + ?DenseMap > DbgVblMap; >>>> >>>> ?void operator=(const SDDbgInfo&); ? // Do not implement. >>>> ?SDDbgInfo(const SDDbgInfo&); ? // Do not implement. >>>> public: >>>> ?SDDbgInfo() {} >>>> >>>> - ?void add(const SDNode *Node, SDDbgValue *V) { >>>> - ? ?DbgVblMap[Node] = V; >>>> + ?void add(SDDbgValue *V, const SDNode *Node = 0) { >>>> + ? ?if (Node) >>>> + ? ? ?DbgVblMap[Node].push_back(V); >>>> + ? ?DbgValues.push_back(V); >>>> ?} >>>> - ?void add(SDDbgValue *V) { DbgConstMap.push_back(V); } >>>> - ?void remove(const SDNode *Node) { >>>> - ? ?DenseMap::iterator Itr = >>>> - ? ? ? ? ? ? ? ? ? ? ?DbgVblMap.find(Node); >>>> - ? ?if (Itr != DbgVblMap.end()) >>>> - ? ? ?DbgVblMap.erase(Itr); >>>> - ?} >>>> - ?// No need to remove a constant. >>>> + >>>> ?void clear() { >>>> ? ?DbgVblMap.clear(); >>>> - ? ?DbgConstMap.clear(); >>>> + ? ?DbgValues.clear(); >>>> + ?} >>>> + >>>> + ?bool empty() const { >>>> + ? ?return DbgValues.empty(); >>>> ?} >>>> - ?SDDbgValue *getSDDbgValue(const SDNode *Node) { >>>> + >>>> + ?SmallVector &getSDDbgValues(const SDNode *Node) { >>>> ? ?return DbgVblMap[Node]; >>>> ?} >>>> - ?typedef SmallVector::iterator ConstDbgIterator; >>>> - ?ConstDbgIterator DbgConstBegin() { return DbgConstMap.begin(); } >>>> - ?ConstDbgIterator DbgConstEnd() { return DbgConstMap.end(); } >>>> + >>>> + ?typedef SmallVector::iterator DbgIterator; >>>> + ?DbgIterator DbgBegin() { return DbgValues.begin(); } >>>> + ?DbgIterator DbgEnd() ? { return DbgValues.end(); } >>>> }; >>>> >>>> enum CombineLevel { >>>> @@ -871,19 +869,21 @@ >>>> ?/// GetOrdering - Get the order for the SDNode. >>>> ?unsigned GetOrdering(const SDNode *SD) const; >>>> >>>> - ?/// AssignDbgInfo - Assign debug info to the SDNode. >>>> - ?void AssignDbgInfo(SDNode *SD, SDDbgValue *db); >>>> + ?/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>>> + ?/// value is produced by SD. >>>> + ?void AddDbgValue(SDDbgValue *DB, SDNode *SD = 0); >>>> >>>> - ?/// RememberDbgInfo - Remember debug info with no associated SDNode. >>>> - ?void RememberDbgInfo(SDDbgValue *db); >>>> + ?/// GetDbgValues - Get the debug values which reference the given SDNode. >>>> + ?SmallVector &GetDbgValues(const SDNode* SD) { >>>> + ? ?return DbgInfo->getSDDbgValues(SD); >>>> + ?} >>>> >>>> - ?/// GetDbgInfo - Get the debug info for the SDNode. >>>> - ?SDDbgValue *GetDbgInfo(const SDNode* SD); >>>> + ?/// hasDebugValues - Return true if there are any SDDbgValue nodes associated >>>> + ?/// with this SelectionDAG. >>>> + ?bool hasDebugValues() const { return !DbgInfo->empty(); } >>>> >>>> - ?SDDbgInfo::ConstDbgIterator DbgConstBegin() { >>>> - ? ?return DbgInfo->DbgConstBegin(); >>>> - ?} >>>> - ?SDDbgInfo::ConstDbgIterator DbgConstEnd() { return DbgInfo->DbgConstEnd(); } >>>> + ?SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } >>>> + ?SDDbgInfo::DbgIterator DbgEnd() ? { return DbgInfo->DbgEnd(); } >>>> >>>> ?void dump() const; >>>> >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Mar 24 20:38:16 2010 >>>> @@ -264,7 +264,8 @@ >>>> InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned IIOpNum, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const TargetInstrDesc *II, >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap) { >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsDebug) { >>>> ?assert(Op.getValueType() != MVT::Other && >>>> ? ? ? ? Op.getValueType() != MVT::Flag && >>>> ? ? ? ? "Chain and flag operands should occur at end of operand list!"); >>>> @@ -295,7 +296,11 @@ >>>> ? ?} >>>> ?} >>>> >>>> - ?MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef)); >>>> + ?MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isImp*/, false/*isKill*/, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isDead*/, false/*isUndef*/, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isEarlyClobber*/, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0/*SubReg*/, IsDebug)); >>>> } >>>> >>>> /// AddOperand - Add the specified operand to the specified machine instr. ?II >>>> @@ -305,9 +310,10 @@ >>>> void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap) { >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool IsDebug) { >>>> ?if (Op.isMachineOpcode()) { >>>> - ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>>> + ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>>> ?} else if (ConstantSDNode *C = dyn_cast(Op)) { >>>> ? ?MI->addOperand(MachineOperand::CreateImm(C->getSExtValue())); >>>> ?} else if (ConstantFPSDNode *F = dyn_cast(Op)) { >>>> @@ -356,7 +362,7 @@ >>>> ? ?assert(Op.getValueType() != MVT::Other && >>>> ? ? ? ? ? Op.getValueType() != MVT::Flag && >>>> ? ? ? ? ? "Chain and flag operands should occur at end of operand list!"); >>>> - ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>>> + ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>>> ?} >>>> } >>>> >>>> @@ -498,75 +504,48 @@ >>>> ?assert(isNew && "Node emitted out of order - early"); >>>> } >>>> >>>> -/// EmitDbgValue - Generate any debug info that refers to this Node. ?Constant >>>> -/// dbg_value is not handled here. >>>> -void >>>> -InstrEmitter::EmitDbgValue(SDNode *Node, >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? SDDbgValue *sd) { >>>> - ?if (!Node->getHasDebugValue()) >>>> - ? ?return; >>>> - ?if (!sd) >>>> - ? ?return; >>>> - ?assert(sd->getKind() == SDDbgValue::SDNODE); >>>> - ?unsigned VReg = getVR(SDValue(sd->getSDNode(), sd->getResNo()), VRBaseMap); >>>> - ?const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>>> - ?DebugLoc DL = sd->getDebugLoc(); >>>> - ?MachineInstr *MI; >>>> - ?if (VReg) { >>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(VReg, RegState::Debug). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addImm(sd->getOffset()). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addMetadata(sd->getMDPtr()); >>>> - ?} else { >>>> - ? ?// Insert an Undef so we can see what we dropped. >>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addMetadata(sd->getMDPtr()); >>>> - ?} >>>> - ?MBB->insert(InsertPos, MI); >>>> -} >>>> - >>>> -/// EmitDbgValue - Generate debug info that does not refer to a SDNode. >>>> -void >>>> -InstrEmitter::EmitDbgValue(SDDbgValue *sd, >>>> +/// EmitDbgValue - Generate machine instruction for a dbg_value node. >>>> +/// >>>> +MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineBasicBlock *InsertBB, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>> ? ? ? ? ? ? ? ? ? ? ? ? DenseMap *EM) { >>>> - ?if (!sd) >>>> - ? ?return; >>>> + ?uint64_t Offset = SD->getOffset(); >>>> + ?MDNode* MDPtr = SD->getMDPtr(); >>>> + ?DebugLoc DL = SD->getDebugLoc(); >>>> + >>>> ?const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>>> - ?uint64_t Offset = sd->getOffset(); >>>> - ?MDNode* mdPtr = sd->getMDPtr(); >>>> - ?SDDbgValue::DbgValueKind kind = sd->getKind(); >>>> - ?DebugLoc DL = sd->getDebugLoc(); >>>> - ?MachineInstr* MI; >>>> - ?if (kind == SDDbgValue::CONST) { >>>> - ? ?Value *V = sd->getConst(); >>>> + ?MachineInstrBuilder MIB = BuildMI(*MF, DL, II); >>>> + ?if (SD->getKind() == SDDbgValue::SDNODE) { >>>> + ? ?AddOperand(&*MIB, SDValue(SD->getSDNode(), SD->getResNo()), >>>> + ? ? ? ? ? ? ? (*MIB).getNumOperands(), &II, VRBaseMap, true /*IsDebug*/); >>>> + ?} else if (SD->getKind() == SDDbgValue::CONST) { >>>> + ? ?Value *V = SD->getConst(); >>>> ? ?if (ConstantInt *CI = dyn_cast(V)) { >>>> - ? ? ?MI = BuildMI(*MF, DL, II).addImm(CI->getZExtValue()). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>> + ? ? ?MIB.addImm(CI->getSExtValue()); >>>> ? ?} else if (ConstantFP *CF = dyn_cast(V)) { >>>> - ? ? ?MI = BuildMI(*MF, DL, II).addFPImm(CF). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>> + ? ? ?MIB.addFPImm(CF); >>>> ? ?} else { >>>> ? ? ?// Could be an Undef. ?In any case insert an Undef so we can see what we >>>> ? ? ?// dropped. >>>> - ? ? ?MI = BuildMI(*MF, DL, II).addReg(0U). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>> + ? ? ?MIB.addReg(0U); >>>> ? ?} >>>> - ?} else if (kind == SDDbgValue::FRAMEIX) { >>>> - ? ?unsigned FrameIx = sd->getFrameIx(); >>>> + ?} else if (SD->getKind() == SDDbgValue::FRAMEIX) { >>>> + ? ?unsigned FrameIx = SD->getFrameIx(); >>>> ? ?// Stack address; this needs to be lowered in target-dependent fashion. >>>> ? ?// FIXME test that the target supports this somehow; if not emit Undef. >>>> ? ?// Create a pseudo for EmitInstrWithCustomInserter's consumption. >>>> - ? ?MI = BuildMI(*MF, DL, II).addImm(FrameIx). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>> - ? ?MBB = TLI->EmitInstrWithCustomInserter(MI, MBB, EM); >>>> - ? ?InsertPos = MBB->end(); >>>> - ? ?return; >>>> + ? ?MIB.addImm(FrameIx).addImm(Offset).addMetadata(MDPtr); >>>> + ? ?abort(); >>>> + ? ?TLI->EmitInstrWithCustomInserter(&*MIB, InsertBB, EM); >>>> + ? ?return 0; >>>> ?} else { >>>> ? ?// Insert an Undef so we can see what we dropped. >>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(0U). >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>> + ? ?MIB.addReg(0U); >>>> ?} >>>> - ?MBB->insert(InsertPos, MI); >>>> + >>>> + ?MIB.addImm(Offset).addMetadata(MDPtr); >>>> + ?return &*MIB; >>>> } >>>> >>>> /// EmitNode - Generate machine code for a node and needed dependencies. >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Wed Mar 24 20:38:16 2010 >>>> @@ -64,7 +64,8 @@ >>>> ?void AddRegisterOperand(MachineInstr *MI, SDValue Op, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>> - ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap); >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?bool IsDebug = false); >>>> >>>> ?/// AddOperand - Add the specified operand to the specified machine instr. ?II >>>> ?/// specifies the instruction information for the node, and IIOpNum is the >>>> @@ -73,7 +74,8 @@ >>>> ?void AddOperand(MachineInstr *MI, SDValue Op, >>>> ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>> ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>> - ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap); >>>> + ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ?bool IsDebug = false); >>>> >>>> ?/// EmitSubregNode - Generate machine code for subreg nodes. >>>> ?/// >>>> @@ -98,16 +100,12 @@ >>>> ?/// MachineInstr. >>>> ?static unsigned CountOperands(SDNode *Node); >>>> >>>> - ?/// EmitDbgValue - Generate any debug info that refers to this Node. ?Constant >>>> - ?/// dbg_value is not handled here. >>>> - ?void EmitDbgValue(SDNode *Node, >>>> - ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>> - ? ? ? ? ? ? ? ? ? ?SDDbgValue* sd); >>>> - >>>> - >>>> - ?/// EmitDbgValue - Generate a constant DBG_VALUE. ?No node is involved. >>>> - ?void EmitDbgValue(SDDbgValue* sd, >>>> - ? ? ? ? ? ? ? ?DenseMap *EM); >>>> + ?/// EmitDbgValue - Generate machine instruction for a dbg_value node. >>>> + ?/// >>>> + ?MachineInstr *EmitDbgValue(SDDbgValue *SD, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?MachineBasicBlock *InsertBB, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap *EM); >>>> >>>> ?/// EmitNode - Generate machine code for a node and needed dependencies. >>>> ?/// >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h Wed Mar 24 20:38:16 2010 >>>> @@ -47,10 +47,12 @@ >>>> ?uint64_t Offset; >>>> ?DebugLoc DL; >>>> ?unsigned Order; >>>> + ?bool Invalid; >>>> public: >>>> ?// Constructor for non-constants. >>>> ?SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, >>>> - ? ? ? ? ? ? unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { >>>> + ? ? ? ? ? ? unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O), >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? Invalid(false) { >>>> ? ?kind = SDNODE; >>>> ? ?u.s.Node = N; >>>> ? ?u.s.ResNo = R; >>>> @@ -97,6 +99,12 @@ >>>> ?// Returns the SDNodeOrder. ?This is the order of the preceding node in the >>>> ?// input. >>>> ?unsigned getOrder() { return Order; } >>>> + >>>> + ?// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" >>>> + ?// property. A SDDbgValue is invalid if the SDNode that produces the value is >>>> + ?// deleted. >>>> + ?void setIsInvalidated() { Invalid = true; } >>>> + ?bool isInvalidated() { return Invalid; } >>>> }; >>>> >>>> } // end llvm namespace >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Wed Mar 24 20:38:16 2010 >>>> @@ -23,6 +23,7 @@ >>>> #include "llvm/Target/TargetSubtarget.h" >>>> #include "llvm/ADT/DenseMap.h" >>>> #include "llvm/ADT/SmallPtrSet.h" >>>> +#include "llvm/ADT/SmallSet.h" >>>> #include "llvm/ADT/SmallVector.h" >>>> #include "llvm/ADT/Statistic.h" >>>> #include "llvm/Support/Debug.h" >>>> @@ -407,19 +408,67 @@ >>>> ?} >>>> } >>>> >>>> +namespace { >>>> + ?struct OrderSorter { >>>> + ? ?bool operator()(const std::pair &A, >>>> + ? ? ? ? ? ? ? ? ? ?const std::pair &B) { >>>> + ? ? ?return A.first < B.first; >>>> + ? ?} >>>> + ?}; >>>> +} >>>> + >>>> +// ProcessSourceNode - Process nodes with source order numbers. These are added >>>> +// to a vector which EmitSchedule use to determine how to insert dbg_value >>>> +// instructions in the right order. >>>> +static void ProcessSourceNode(SDNode *N, SelectionDAG *DAG, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? InstrEmitter &Emitter, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap *EM, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>> + ? ? ? ? ? ? ? ? ? ?SmallVector, 32> &Orders, >>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? SmallSet &Seen) { >>>> + ?unsigned Order = DAG->GetOrdering(N); >>>> + ?if (!Order || !Seen.insert(Order)) >>>> + ? ?return; >>>> + >>>> + ?MachineBasicBlock *BB = Emitter.getBlock(); >>>> + ?if (BB->empty() || BB->back().isPHI()) { >>>> + ? ?// Did not insert any instruction. >>>> + ? ?Orders.push_back(std::make_pair(Order, (MachineInstr*)0)); >>>> + ? ?return; >>>> + ?} >>>> + >>>> + ?Orders.push_back(std::make_pair(Order, &BB->back())); >>>> + ?if (!N->getHasDebugValue()) >>>> + ? ?return; >>>> + ?// Opportunistically insert immediate dbg_value uses, i.e. those with source >>>> + ?// order number right after the N. >>>> + ?MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos(); >>>> + ?SmallVector &DVs = DAG->GetDbgValues(N); >>>> + ?for (unsigned i = 0, e = DVs.size(); i != e; ++i) { >>>> + ? ?if (DVs[i]->isInvalidated()) >>>> + ? ? ?continue; >>>> + ? ?unsigned DVOrder = DVs[i]->getOrder(); >>>> + ? ?if (DVOrder == ++Order) { >>>> + ? ? ?// FIXME: If the source node with next higher order is scheduled before >>>> + ? ? ?// this could end up generating funky debug info. >>>> + ? ? ?MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], BB, VRBaseMap, EM); >>>> + ? ? ?Orders.push_back(std::make_pair(DVOrder, DbgMI)); >>>> + ? ? ?BB->insert(InsertPos, DbgMI); >>>> + ? ? ?DVs[i]->setIsInvalidated(); >>>> + ? ?} >>>> + ?} >>>> +} >>>> + >>>> + >>>> /// EmitSchedule - Emit the machine code in scheduled order. >>>> MachineBasicBlock *ScheduleDAGSDNodes:: >>>> EmitSchedule(DenseMap *EM) { >>>> ?InstrEmitter Emitter(BB, InsertPos); >>>> ?DenseMap VRBaseMap; >>>> ?DenseMap CopyVRBaseMap; >>>> - >>>> - ?// For now, any constant debug info nodes go at the beginning. >>>> - ?for (SDDbgInfo::ConstDbgIterator I = DAG->DbgConstBegin(), >>>> - ? ? ? E = DAG->DbgConstEnd(); I!=E; I++) { >>>> - ? ?Emitter.EmitDbgValue(*I, EM); >>>> - ? ?delete *I; >>>> - ?} >>>> + ?SmallVector, 32> Orders; >>>> + ?SmallSet Seen; >>>> + ?bool HasDbg = DAG->hasDebugValues(); >>>> >>>> ?for (unsigned i = 0, e = Sequence.size(); i != e; i++) { >>>> ? ?SUnit *SU = Sequence[i]; >>>> @@ -442,22 +491,72 @@ >>>> ? ? ? ? N = N->getFlaggedNode()) >>>> ? ? ?FlaggedNodes.push_back(N); >>>> ? ?while (!FlaggedNodes.empty()) { >>>> + ? ? ?SDNode *N = FlaggedNodes.back(); >>>> ? ? ?Emitter.EmitNode(FlaggedNodes.back(), SU->OrigNode != SU, SU->isCloned, >>>> ? ? ? ? ? ? ? ? ? ? ? VRBaseMap, EM); >>>> - ? ? ?if (FlaggedNodes.back()->getHasDebugValue()) >>>> - ? ? ? ?if (SDDbgValue *sd = DAG->GetDbgInfo(FlaggedNodes.back())) { >>>> - ? ? ? ? ?Emitter.EmitDbgValue(FlaggedNodes.back(), VRBaseMap, sd); >>>> - ? ? ? ? ?delete sd; >>>> - ? ? ? ?} >>>> + ? ? ?// Remember the the source order of the inserted instruction. >>>> + ? ? ?if (HasDbg) >>>> + ? ? ? ?ProcessSourceNode(N, DAG, Emitter, EM, VRBaseMap, Orders, Seen); >>>> ? ? ?FlaggedNodes.pop_back(); >>>> ? ?} >>>> ? ?Emitter.EmitNode(SU->getNode(), SU->OrigNode != SU, SU->isCloned, >>>> ? ? ? ? ? ? ? ? ? ? VRBaseMap, EM); >>>> - ? ?if (SU->getNode()->getHasDebugValue()) >>>> - ? ? ?if (SDDbgValue *sd = DAG->GetDbgInfo(SU->getNode())) { >>>> - ? ? ? ?Emitter.EmitDbgValue(SU->getNode(), VRBaseMap, sd); >>>> - ? ? ? ?delete sd; >>>> + ? ?// Remember the the source order of the inserted instruction. >>>> + ? ?if (HasDbg) >>>> + ? ? ?ProcessSourceNode(SU->getNode(), DAG, Emitter, EM, VRBaseMap, Orders, >>>> + ? ? ? ? ? ? ? ? ? ? ? ?Seen); >>>> + ?} >>>> + >>>> + ?// Insert all the dbg_value which have not already been inserted in source >>>> + ?// order sequence. >>>> + ?if (HasDbg) { >>>> + ? ?MachineBasicBlock::iterator BBBegin = BB->empty() ? BB->end() : BB->begin(); >>>> + ? ?while (BBBegin != BB->end() && BBBegin->isPHI()) >>>> + ? ? ?++BBBegin; >>>> + >>>> + ? ?// Sort the source order instructions and use the order to insert debug >>>> + ? ?// values. >>>> + ? ?std::sort(Orders.begin(), Orders.end(), OrderSorter()); >>>> + >>>> + ? ?SDDbgInfo::DbgIterator DI = DAG->DbgBegin(); >>>> + ? ?SDDbgInfo::DbgIterator DE = DAG->DbgEnd(); >>>> + ? ?// Now emit the rest according to source order. >>>> + ? ?unsigned LastOrder = 0; >>>> + ? ?MachineInstr *LastMI = 0; >>>> + ? ?for (unsigned i = 0, e = Orders.size(); i != e && DI != DE; ++i) { >>>> + ? ? ?unsigned Order = Orders[i].first; >>>> + ? ? ?MachineInstr *MI = Orders[i].second; >>>> + ? ? ?// Insert all SDDbgValue's whose order(s) are before "Order". >>>> + ? ? ?if (!MI) >>>> + ? ? ? ?continue; >>>> + ? ? ?MachineBasicBlock *MIBB = MI->getParent(); >>>> + ? ? ?for (; DI != DE && >>>> + ? ? ? ? ? ? (*DI)->getOrder() >= LastOrder && (*DI)->getOrder() < Order; ++DI) { >>>> + ? ? ? ?if ((*DI)->isInvalidated()) >>>> + ? ? ? ? ?continue; >>>> + ? ? ? ?MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, MIBB, VRBaseMap, EM); >>>> + ? ? ? ?if (!LastOrder) >>>> + ? ? ? ? ?// Insert to start of the BB (after PHIs). >>>> + ? ? ? ? ?BB->insert(BBBegin, DbgMI); >>>> + ? ? ? ?else { >>>> + ? ? ? ? ?MachineBasicBlock::iterator Pos = MI; >>>> + ? ? ? ? ?MIBB->insert(llvm::next(Pos), DbgMI); >>>> + ? ? ? ?} >>>> ? ? ?} >>>> + ? ? ?LastOrder = Order; >>>> + ? ? ?LastMI = MI; >>>> + ? ?} >>>> + ? ?// Add trailing DbgValue's before the terminator. FIXME: May want to add >>>> + ? ?// some of them before one or more conditional branches? >>>> + ? ?while (DI != DE) { >>>> + ? ? ?MachineBasicBlock *InsertBB = Emitter.getBlock(); >>>> + ? ? ?MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator(); >>>> + ? ? ?if (!(*DI)->isInvalidated()) { >>>> + ? ? ? ?MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, InsertBB, VRBaseMap, EM); >>>> + ? ? ? ?InsertBB->insert(Pos, DbgMI); >>>> + ? ? ?} >>>> + ? ? ?++DI; >>>> + ? ?} >>>> ?} >>>> >>>> ?BB = Emitter.getBlock(); >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 24 20:38:16 2010 >>>> @@ -598,8 +598,10 @@ >>>> ?// Remove the ordering of this node. >>>> ?Ordering->remove(N); >>>> >>>> - ?// And its entry in the debug info table, if any. >>>> - ?DbgInfo->remove(N); >>>> + ?// If any of the SDDbgValue nodes refer to this SDNode, invalidate them. >>>> + ?SmallVector &DbgVals = DbgInfo->getSDDbgValues(N); >>>> + ?for (unsigned i = 0, e = DbgVals.size(); i != e; ++i) >>>> + ? ?DbgVals[i]->setIsInvalidated(); >>>> } >>>> >>>> /// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that >>>> @@ -811,6 +813,7 @@ >>>> SelectionDAG::~SelectionDAG() { >>>> ?allnodes_clear(); >>>> ?delete Ordering; >>>> + ?DbgInfo->clear(); >>>> ?delete DbgInfo; >>>> } >>>> >>>> @@ -5241,24 +5244,12 @@ >>>> ?return Ordering->getOrder(SD); >>>> } >>>> >>>> -/// AssignDbgInfo - Assign debug info to the SDNode. >>>> -void SelectionDAG::AssignDbgInfo(SDNode* SD, SDDbgValue* db) { >>>> - ?assert(SD && "Trying to assign dbg info to a null node!"); >>>> - ?DbgInfo->add(SD, db); >>>> - ?SD->setHasDebugValue(true); >>>> -} >>>> - >>>> -/// RememberDbgInfo - Remember debug info which is not assigned to an SDNode. >>>> -void SelectionDAG::RememberDbgInfo(SDDbgValue* db) { >>>> - ?DbgInfo->add(db); >>>> -} >>>> - >>>> -/// GetDbgInfo - Get the debug info, if any, for the SDNode. >>>> -SDDbgValue* SelectionDAG::GetDbgInfo(const SDNode *SD) { >>>> - ?assert(SD && "Trying to get the order of a null node!"); >>>> - ?if (SD->getHasDebugValue()) >>>> - ? ?return DbgInfo->getSDDbgValue(SD); >>>> - ?return 0; >>>> +/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>>> +/// value is produced by SD. >>>> +void SelectionDAG::AddDbgValue(SDDbgValue *DB, SDNode *SD) { >>>> + ?DbgInfo->add(DB, SD); >>>> + ?if (SD) >>>> + ? ?SD->setHasDebugValue(true); >>>> } >>>> >>>> //===----------------------------------------------------------------------===// >>>> >>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>> ============================================================================== >>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Mar 24 20:38:16 2010 >>>> @@ -3825,20 +3825,20 @@ >>>> ? ?++SDNodeOrder; >>>> ? ?if (isa(V) || isa(V)) { >>>> ? ? ?SDDbgValue* dv = new SDDbgValue(Variable, V, Offset, dl, SDNodeOrder); >>>> - ? ? ?DAG.RememberDbgInfo(dv); >>>> + ? ? ?DAG.AddDbgValue(dv); >>>> ? ?} else { >>>> ? ? ?SDValue &N = NodeMap[V]; >>>> ? ? ?if (N.getNode()) { >>>> ? ? ? ?SDDbgValue *dv = new SDDbgValue(Variable, N.getNode(), >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?N.getResNo(), Offset, dl, SDNodeOrder); >>>> - ? ? ? ?DAG.AssignDbgInfo(N.getNode(), dv); >>>> + ? ? ? ?DAG.AddDbgValue(dv, N.getNode()); >>>> ? ? ?} else { >>>> ? ? ? ?// We may expand this to cover more cases. ?One case where we have no >>>> ? ? ? ?// data available is an unreferenced parameter; we need this fallback. >>>> ? ? ? ?SDDbgValue* dv = new SDDbgValue(Variable, >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?UndefValue::get(V->getType()), >>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Offset, dl, SDNodeOrder); >>>> - ? ? ? ?DAG.RememberDbgInfo(dv); >>>> + ? ? ? ?DAG.AddDbgValue(dv); >>>> ? ? ?} >>>> ? ?} >>>> >>>> >>>> >>>> _______________________________________________ >>>> llvm-commits mailing list >>>> llvm-commits at cs.uiuc.edu >>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From benny.kra at googlemail.com Mon Mar 29 16:13:41 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 29 Mar 2010 21:13:41 -0000 Subject: [llvm-commits] [llvm] r99838 - in /llvm/trunk: include/llvm/Support/MathExtras.h lib/Target/Blackfin/BlackfinInstrInfo.td lib/Target/Blackfin/BlackfinRegisterInfo.cpp lib/Target/CellSPU/SPUISelDAGToDAG.cpp lib/Target/MSIL/MSILWriter.cpp lib/Target/PowerPC/PPCBranchSelector.cpp lib/Target/PowerPC/PPCISelDAGToDAG.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/X86/X86FastISel.cpp lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100329211342.390E62A6C12C@llvm.org> Author: d0k Date: Mon Mar 29 16:13:41 2010 New Revision: 99838 URL: http://llvm.org/viewvc/llvm-project?rev=99838&view=rev Log: Make isInt?? and isUint?? template specializations of the generic versions. This makes calls a little bit more consistent and allows easy removal of the specializations in the future. Convert all callers to the templated functions. Modified: llvm/trunk/include/llvm/Support/MathExtras.h llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp llvm/trunk/lib/Target/MSIL/MSILWriter.cpp llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/include/llvm/Support/MathExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/MathExtras.h (original) +++ llvm/trunk/include/llvm/Support/MathExtras.h Mon Mar 29 16:13:41 2010 @@ -32,35 +32,43 @@ return static_cast(Value); } -/// is?Type - these functions produce optimal testing for integer data types. -inline bool isInt8 (int64_t Value) { - return static_cast(Value) == Value; -} -inline bool isUInt8 (int64_t Value) { - return static_cast(Value) == Value; -} -inline bool isInt16 (int64_t Value) { - return static_cast(Value) == Value; -} -inline bool isUInt16(int64_t Value) { - return static_cast(Value) == Value; -} -inline bool isInt32 (int64_t Value) { - return static_cast(Value) == Value; -} -inline bool isUInt32(int64_t Value) { - return static_cast(Value) == Value; -} - +/// isInt - Checks if an integer fits into the given bit width. template inline bool isInt(int64_t x) { return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1))); } +// Template specializations to get better code for common cases. +template<> +inline bool isInt<8>(int64_t x) { + return static_cast(x) == x; +} +template<> +inline bool isInt<16>(int64_t x) { + return static_cast(x) == x; +} +template<> +inline bool isInt<32>(int64_t x) { + return static_cast(x) == x; +} +/// isUInt - Checks if an unsigned integer fits into the given bit width. template -inline bool isUint(uint64_t x) { +inline bool isUInt(uint64_t x) { return N >= 64 || x < (UINT64_C(1)< +inline bool isUInt<8>(uint64_t x) { + return static_cast(x) == x; +} +template<> +inline bool isUInt<16>(uint64_t x) { + return static_cast(x) == x; +} +template<> +inline bool isUInt<32>(uint64_t x) { + return static_cast(x) == x; +} /// isMask_32 - This function returns true if the argument is a sequence of ones /// starting at the least significant bit with the remainder zero (32 bit Modified: llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinInstrInfo.td Mon Mar 29 16:13:41 2010 @@ -65,23 +65,23 @@ //===----------------------------------------------------------------------===// def imm3 : PatLeaf<(imm), [{return isInt<3>(N->getSExtValue());}]>; -def uimm3 : PatLeaf<(imm), [{return isUint<3>(N->getZExtValue());}]>; -def uimm4 : PatLeaf<(imm), [{return isUint<4>(N->getZExtValue());}]>; -def uimm5 : PatLeaf<(imm), [{return isUint<5>(N->getZExtValue());}]>; +def uimm3 : PatLeaf<(imm), [{return isUInt<3>(N->getZExtValue());}]>; +def uimm4 : PatLeaf<(imm), [{return isUInt<4>(N->getZExtValue());}]>; +def uimm5 : PatLeaf<(imm), [{return isUInt<5>(N->getZExtValue());}]>; def uimm5m2 : PatLeaf<(imm), [{ uint64_t value = N->getZExtValue(); - return value % 2 == 0 && isUint<5>(value); + return value % 2 == 0 && isUInt<5>(value); }]>; def uimm6m4 : PatLeaf<(imm), [{ uint64_t value = N->getZExtValue(); - return value % 4 == 0 && isUint<6>(value); + return value % 4 == 0 && isUInt<6>(value); }]>; def imm7 : PatLeaf<(imm), [{return isInt<7>(N->getSExtValue());}]>; def imm16 : PatLeaf<(imm), [{return isInt<16>(N->getSExtValue());}]>; -def uimm16 : PatLeaf<(imm), [{return isUint<16>(N->getZExtValue());}]>; +def uimm16 : PatLeaf<(imm), [{return isUInt<16>(N->getZExtValue());}]>; def ximm16 : PatLeaf<(imm), [{ int64_t value = N->getSExtValue(); Modified: llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinRegisterInfo.cpp Mon Mar 29 16:13:41 2010 @@ -164,7 +164,7 @@ return; } - if (isUint<16>(value)) { + if (isUInt<16>(value)) { BuildMI(MBB, I, DL, TII.get(BF::LOADuimm16), Reg).addImm(value); return; } @@ -255,13 +255,13 @@ assert(FIPos==1 && "Bad frame index operand"); MI.getOperand(FIPos).ChangeToRegister(BaseReg, false); MI.getOperand(FIPos+1).setImm(Offset); - if (isUint<6>(Offset)) { + if (isUInt<6>(Offset)) { MI.setDesc(TII.get(isStore ? BF::STORE32p_uimm6m4 : BF::LOAD32p_uimm6m4)); return 0; } - if (BaseReg == BF::FP && isUint<7>(-Offset)) { + if (BaseReg == BF::FP && isUInt<7>(-Offset)) { MI.setDesc(TII.get(isStore ? BF::STORE32fp_nimm7m4 : BF::LOAD32fp_nimm7m4)); Modified: llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelDAGToDAG.cpp Mon Mar 29 16:13:41 2010 @@ -58,7 +58,7 @@ bool isI32IntU10Immediate(ConstantSDNode *CN) { - return isUint<10>(CN->getSExtValue()); + return isUInt<10>(CN->getSExtValue()); } //! ConstantSDNode predicate for i16 sign-extended, 10-bit immediate values @@ -80,7 +80,7 @@ bool isI16IntU10Immediate(ConstantSDNode *CN) { - return isUint<10>((short) CN->getZExtValue()); + return isUInt<10>((short) CN->getZExtValue()); } //! SDNode predicate for i16 sign-extended, 10-bit immediate values Modified: llvm/trunk/lib/Target/MSIL/MSILWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSIL/MSILWriter.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSIL/MSILWriter.cpp (original) +++ llvm/trunk/lib/Target/MSIL/MSILWriter.cpp Mon Mar 29 16:13:41 2010 @@ -424,7 +424,7 @@ case Module::Pointer32: printSimpleInstruction("ldc.i4",utostr(N).c_str()); // FIXME: Need overflow test? - if (!isUInt32(N)) { + if (!isUInt<32>(N)) { errs() << "Value = " << utostr(N) << '\n'; llvm_unreachable("32-bit pointer overflowed"); } Modified: llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCBranchSelector.cpp Mon Mar 29 16:13:41 2010 @@ -130,7 +130,7 @@ } // If this branch is in range, ignore it. - if (isInt16(BranchSize)) { + if (isInt<16>(BranchSize)) { MBBStartOffset += 4; continue; } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelDAGToDAG.cpp Mon Mar 29 16:13:41 2010 @@ -470,11 +470,11 @@ if (CC == ISD::SETEQ || CC == ISD::SETNE) { if (isInt32Immediate(RHS, Imm)) { // SETEQ/SETNE comparison with 16-bit immediate, fold it. - if (isUInt16(Imm)) + if (isUInt<16>(Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPLWI, dl, MVT::i32, LHS, getI32Imm(Imm & 0xFFFF)), 0); // If this is a 16-bit signed immediate, fold it. - if (isInt16((int)Imm)) + if (isInt<16>((int)Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPWI, dl, MVT::i32, LHS, getI32Imm(Imm & 0xFFFF)), 0); @@ -494,7 +494,7 @@ } Opc = PPC::CMPLW; } else if (ISD::isUnsignedIntSetCC(CC)) { - if (isInt32Immediate(RHS, Imm) && isUInt16(Imm)) + if (isInt32Immediate(RHS, Imm) && isUInt<16>(Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPLWI, dl, MVT::i32, LHS, getI32Imm(Imm & 0xFFFF)), 0); Opc = PPC::CMPLW; @@ -511,11 +511,11 @@ if (CC == ISD::SETEQ || CC == ISD::SETNE) { if (isInt64Immediate(RHS.getNode(), Imm)) { // SETEQ/SETNE comparison with 16-bit immediate, fold it. - if (isUInt16(Imm)) + if (isUInt<16>(Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPLDI, dl, MVT::i64, LHS, getI32Imm(Imm & 0xFFFF)), 0); // If this is a 16-bit signed immediate, fold it. - if (isInt16(Imm)) + if (isInt<16>(Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPDI, dl, MVT::i64, LHS, getI32Imm(Imm & 0xFFFF)), 0); @@ -528,7 +528,7 @@ // xoris r0,r3,0x1234 // cmpldi cr0,r0,0x5678 // beq cr0,L6 - if (isUInt32(Imm)) { + if (isUInt<32>(Imm)) { SDValue Xor(CurDAG->getMachineNode(PPC::XORIS8, dl, MVT::i64, LHS, getI64Imm(Imm >> 16)), 0); return SDValue(CurDAG->getMachineNode(PPC::CMPLDI, dl, MVT::i64, Xor, @@ -537,7 +537,7 @@ } Opc = PPC::CMPLD; } else if (ISD::isUnsignedIntSetCC(CC)) { - if (isInt64Immediate(RHS.getNode(), Imm) && isUInt16(Imm)) + if (isInt64Immediate(RHS.getNode(), Imm) && isUInt<16>(Imm)) return SDValue(CurDAG->getMachineNode(PPC::CMPLDI, dl, MVT::i64, LHS, getI64Imm(Imm & 0xFFFF)), 0); Opc = PPC::CMPLD; @@ -761,12 +761,12 @@ unsigned Shift = 0; // If it can't be represented as a 32 bit value. - if (!isInt32(Imm)) { + if (!isInt<32>(Imm)) { Shift = CountTrailingZeros_64(Imm); int64_t ImmSh = static_cast(Imm) >> Shift; // If the shifted value fits 32 bits. - if (isInt32(ImmSh)) { + if (isInt<32>(ImmSh)) { // Go with the shifted value. Imm = ImmSh; } else { @@ -785,7 +785,7 @@ unsigned Hi = (Imm >> 16) & 0xFFFF; // Simple value. - if (isInt16(Imm)) { + if (isInt<16>(Imm)) { // Just the Lo bits. Result = CurDAG->getMachineNode(PPC::LI8, dl, MVT::i64, getI32Imm(Lo)); } else if (Lo) { Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Mon Mar 29 16:13:41 2010 @@ -512,7 +512,7 @@ MachineInstr *MI = I; DebugLoc dl = MI->getDebugLoc(); - if (isInt16(CalleeAmt)) { + if (isInt<16>(CalleeAmt)) { BuildMI(MBB, I, dl, TII.get(ADDIInstr), StackReg).addReg(StackReg). addImm(CalleeAmt); } else { @@ -596,7 +596,7 @@ else Reg = PPC::R0; - if (MaxAlign < TargetAlign && isInt16(FrameSize)) { + if (MaxAlign < TargetAlign && isInt<16>(FrameSize)) { BuildMI(MBB, II, dl, TII.get(PPC::ADDI), Reg) .addReg(PPC::R31) .addImm(FrameSize); @@ -798,7 +798,7 @@ // clear can be encoded. This is extremely uncommon, because normally you // only "std" to a stack slot that is at least 4-byte aligned, but it can // happen in invalid code. - if (isInt16(Offset) && (!isIXAddr || (Offset & 3) == 0)) { + if (isInt<16>(Offset) && (!isIXAddr || (Offset & 3) == 0)) { if (isIXAddr) Offset >>= 2; // The actual encoded value has the low two bits zero. MI.getOperand(OffsetOperandNo).ChangeToImmediate(Offset); @@ -1375,8 +1375,9 @@ if (!isPPC64) { // PPC32. if (ALIGN_STACK && MaxAlign > TargetAlign) { - assert(isPowerOf2_32(MaxAlign)&&isInt16(MaxAlign)&&"Invalid alignment!"); - assert(isInt16(NegFrameSize) && "Unhandled stack size and alignment!"); + assert(isPowerOf2_32(MaxAlign) && isInt<16>(MaxAlign) && + "Invalid alignment!"); + assert(isInt<16>(NegFrameSize) && "Unhandled stack size and alignment!"); BuildMI(MBB, MBBI, dl, TII.get(PPC::RLWINM), PPC::R0) .addReg(PPC::R1) @@ -1390,7 +1391,7 @@ .addReg(PPC::R1) .addReg(PPC::R1) .addReg(PPC::R0); - } else if (isInt16(NegFrameSize)) { + } else if (isInt<16>(NegFrameSize)) { BuildMI(MBB, MBBI, dl, TII.get(PPC::STWU), PPC::R1) .addReg(PPC::R1) .addImm(NegFrameSize) @@ -1408,8 +1409,9 @@ } } else { // PPC64. if (ALIGN_STACK && MaxAlign > TargetAlign) { - assert(isPowerOf2_32(MaxAlign)&&isInt16(MaxAlign)&&"Invalid alignment!"); - assert(isInt16(NegFrameSize) && "Unhandled stack size and alignment!"); + assert(isPowerOf2_32(MaxAlign) && isInt<16>(MaxAlign) && + "Invalid alignment!"); + assert(isInt<16>(NegFrameSize) && "Unhandled stack size and alignment!"); BuildMI(MBB, MBBI, dl, TII.get(PPC::RLDICL), PPC::X0) .addReg(PPC::X1) @@ -1422,7 +1424,7 @@ .addReg(PPC::X1) .addReg(PPC::X1) .addReg(PPC::X0); - } else if (isInt16(NegFrameSize)) { + } else if (isInt<16>(NegFrameSize)) { BuildMI(MBB, MBBI, dl, TII.get(PPC::STDU), PPC::X1) .addReg(PPC::X1) .addImm(NegFrameSize / 4) @@ -1591,7 +1593,7 @@ // enabled (=> hasFastCall()==true) the fastcc call might contain a tail // call which invalidates the stack pointer value in SP(0). So we use the // value of R31 in this case. - if (FI->hasFastCall() && isInt16(FrameSize)) { + if (FI->hasFastCall() && isInt<16>(FrameSize)) { assert(hasFP(MF) && "Expecting a valid the frame pointer."); BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI), PPC::R1) .addReg(PPC::R31).addImm(FrameSize); @@ -1605,7 +1607,7 @@ .addReg(PPC::R1) .addReg(PPC::R31) .addReg(PPC::R0); - } else if (isInt16(FrameSize) && + } else if (isInt<16>(FrameSize) && (!ALIGN_STACK || TargetAlign >= MaxAlign) && !MFI->hasVarSizedObjects()) { BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI), PPC::R1) @@ -1615,7 +1617,7 @@ .addImm(0).addReg(PPC::R1); } } else { - if (FI->hasFastCall() && isInt16(FrameSize)) { + if (FI->hasFastCall() && isInt<16>(FrameSize)) { assert(hasFP(MF) && "Expecting a valid the frame pointer."); BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI8), PPC::X1) .addReg(PPC::X31).addImm(FrameSize); @@ -1629,7 +1631,7 @@ .addReg(PPC::X1) .addReg(PPC::X31) .addReg(PPC::X0); - } else if (isInt16(FrameSize) && TargetAlign >= MaxAlign && + } else if (isInt<16>(FrameSize) && TargetAlign >= MaxAlign && !MFI->hasVarSizedObjects()) { BuildMI(MBB, MBBI, dl, TII.get(PPC::ADDI8), PPC::X1) .addReg(PPC::X1).addImm(FrameSize); @@ -1678,7 +1680,7 @@ unsigned LISInstr = isPPC64 ? PPC::LIS8 : PPC::LIS; unsigned ORIInstr = isPPC64 ? PPC::ORI8 : PPC::ORI; - if (CallerAllocatedAmt && isInt16(CallerAllocatedAmt)) { + if (CallerAllocatedAmt && isInt<16>(CallerAllocatedAmt)) { BuildMI(MBB, MBBI, dl, TII.get(ADDIInstr), StackReg) .addReg(StackReg).addImm(CallerAllocatedAmt); } else { Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Mar 29 16:13:41 2010 @@ -383,7 +383,7 @@ if (ConstantInt *CI = dyn_cast(U->getOperand(1))) { uint64_t Disp = (int32_t)AM.Disp + (uint64_t)CI->getSExtValue(); // They have to fit in the 32-bit signed displacement field though. - if (isInt32(Disp)) { + if (isInt<32>(Disp)) { AM.Disp = (uint32_t)Disp; return X86SelectAddress(U->getOperand(0), AM); } @@ -427,7 +427,7 @@ } } // Check for displacement overflow. - if (!isInt32(Disp)) + if (!isInt<32>(Disp)) break; // Ok, the GEP indices were covered by constant-offset and scaled-index // addressing. Update the address state and move on to examining the base. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99838&r1=99837&r2=99838&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Mar 29 16:13:41 2010 @@ -2424,7 +2424,7 @@ bool X86::isOffsetSuitableForCodeModel(int64_t Offset, CodeModel::Model M, bool hasSymbolicDisplacement) { // Offset should fit into 32 bit immediate field. - if (!isInt32(Offset)) + if (!isInt<32>(Offset)) return false; // If we don't have a symbolic displacement - we don't have any extra From sabre at nondot.org Mon Mar 29 16:24:52 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 21:24:52 -0000 Subject: [llvm-commits] [llvm] r99839 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100329212452.7FAD02A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 16:24:52 2010 New Revision: 99839 URL: http://llvm.org/viewvc/llvm-project?rev=99839&view=rev Log: various timer fixes: move operator= out of line, eliminate the per-timer lock (timers should be externally locked if needed), the info-output-stream can never be dbgs(), so drop the check. Make some stuff private. Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99839&r1=99838&r2=99839&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 16:24:52 2010 @@ -40,54 +40,27 @@ double SystemTime; // System time elapsed ssize_t MemUsed; // Memory allocated (in bytes) size_t PeakMem; // Peak memory used - size_t PeakMemBase; // Temporary for peak calculation... - std::string Name; // The name of this time variable + size_t PeakMemBase; // Temporary for peak memory calculation. + std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. - mutable sys::SmartMutex Lock; // Mutex for the contents of this Timer. public: explicit Timer(const std::string &N); Timer(const std::string &N, TimerGroup &tg); Timer(const Timer &T); ~Timer(); +private: double getProcessTime() const { return UserTime+SystemTime; } double getWallTime() const { return Elapsed; } ssize_t getMemUsed() const { return MemUsed; } size_t getPeakMem() const { return PeakMem; } +public: std::string getName() const { return Name; } - const Timer &operator=(const Timer &T) { - if (&T < this) { - T.Lock.acquire(); - Lock.acquire(); - } else { - Lock.acquire(); - T.Lock.acquire(); - } - - Elapsed = T.Elapsed; - UserTime = T.UserTime; - SystemTime = T.SystemTime; - MemUsed = T.MemUsed; - PeakMem = T.PeakMem; - PeakMemBase = T.PeakMemBase; - Name = T.Name; - Started = T.Started; - assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); - - if (&T < this) { - T.Lock.release(); - Lock.release(); - } else { - Lock.release(); - T.Lock.release(); - } - - return *this; - } - - // operator< - Allow sorting... + const Timer &operator=(const Timer &T); + + // operator< - Allow sorting. bool operator<(const Timer &T) const { // Sort by Wall Time elapsed, as it is the only thing really accurate return Elapsed < T.Elapsed; Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99839&r1=99838&r2=99839&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 16:24:52 2010 @@ -147,7 +147,6 @@ static ManagedStatic > ActiveTimers; void Timer::startTimer() { - sys::SmartScopedLock L(*TimerLock); Started = true; ActiveTimers->push_back(this); TimeRecord TR = getTimeRecord(true); @@ -159,7 +158,6 @@ } void Timer::stopTimer() { - sys::SmartScopedLock L(*TimerLock); TimeRecord TR = getTimeRecord(false); Elapsed += TR.Elapsed; UserTime += TR.UserTime; @@ -184,14 +182,26 @@ PeakMem += T.PeakMem; } +const Timer &Timer::operator=(const Timer &T) { + Elapsed = T.Elapsed; + UserTime = T.UserTime; + SystemTime = T.SystemTime; + MemUsed = T.MemUsed; + PeakMem = T.PeakMem; + PeakMemBase = T.PeakMemBase; + Name = T.Name; + Started = T.Started; + assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); + return *this; +} + + /// addPeakMemoryMeasurement - This method should be called whenever memory /// usage needs to be checked. It adds a peak memory measurement to the /// currently active timers, which will be printed when the timer group prints /// void Timer::addPeakMemoryMeasurement() { - sys::SmartScopedLock L(*TimerLock); size_t MemUsed = getMemUsage(); - for (std::vector::iterator I = ActiveTimers->begin(), E = ActiveTimers->end(); I != E; ++I) (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); @@ -208,7 +218,6 @@ } void Timer::print(const Timer &Total, raw_ostream &OS) { - sys::SmartScopedLock L(*TimerLock); if (Total.UserTime) printVal(UserTime, Total.UserTime, OS); if (Total.SystemTime) @@ -219,13 +228,13 @@ OS << " "; - if (Total.MemUsed) { + if (Total.MemUsed) OS << format("%9lld", (long long)MemUsed) << " "; - } + if (Total.PeakMem) { - if (PeakMem) { + if (PeakMem) OS << format("%9lld", (long long)PeakMem) << " "; - } else + else OS << " "; } OS << Name << "\n"; @@ -286,15 +295,13 @@ //===----------------------------------------------------------------------===// // GetLibSupportInfoOutputFile - Return a file stream to print our output on. -raw_ostream * -llvm::GetLibSupportInfoOutputFile() { +raw_ostream *llvm::GetLibSupportInfoOutputFile() { std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); if (LibSupportInfoOutputFilename.empty()) return &errs(); if (LibSupportInfoOutputFilename == "-") return &outs(); - std::string Error; raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), Error, raw_fd_ostream::F_Append); @@ -373,7 +380,7 @@ TimersToPrint.clear(); - if (OutStream != &errs() && OutStream != &outs() && OutStream != &dbgs()) + if (OutStream != &errs() && OutStream != &outs()) delete OutStream; // Close the file. } From evan.cheng at apple.com Mon Mar 29 16:27:30 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 29 Mar 2010 21:27:30 -0000 Subject: [llvm-commits] [llvm] r99840 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp test/CodeGen/Generic/2010-ZeroSizedArg.ll Message-ID: <20100329212730.C17452A6C12C@llvm.org> Author: evancheng Date: Mon Mar 29 16:27:30 2010 New Revision: 99840 URL: http://llvm.org/viewvc/llvm-project?rev=99840&view=rev Log: Fix PR4975. Avoid referencing empty vector. Added: llvm/trunk/test/CodeGen/Generic/2010-ZeroSizedArg.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99840&r1=99839&r2=99840&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Mar 29 16:27:30 2010 @@ -6051,8 +6051,10 @@ } if (!I->use_empty()) { - SDValue Res = DAG.getMergeValues(&ArgValues[0], NumValues, - SDB->getCurDebugLoc()); + 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 Added: llvm/trunk/test/CodeGen/Generic/2010-ZeroSizedArg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/2010-ZeroSizedArg.ll?rev=99840&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Generic/2010-ZeroSizedArg.ll (added) +++ llvm/trunk/test/CodeGen/Generic/2010-ZeroSizedArg.ll Mon Mar 29 16:27:30 2010 @@ -0,0 +1,17 @@ +; RUN: llc < %s +; PR4975 + +%0 = type <{ [0 x i32] }> +%union.T0 = type { } + + at .str = private constant [1 x i8] c" " + +define arm_apcscc void @t(%0) nounwind { +entry: + %arg0 = alloca %union.T0 + %1 = bitcast %union.T0* %arg0 to %0* + store %0 %0, %0* %1, align 1 + ret void +} + +declare arm_apcscc i32 @printf(i8*, ...) From sabre at nondot.org Mon Mar 29 16:28:41 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 21:28:41 -0000 Subject: [llvm-commits] [llvm] r99841 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100329212841.5A3AA2A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 16:28:41 2010 New Revision: 99841 URL: http://llvm.org/viewvc/llvm-project?rev=99841&view=rev Log: remove support for per-time peak memory tracking, this isn't used by anyone and is better exposed as a non-per-timer thing. Also, stop including System/Mutex.h in Timer.h Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99841&r1=99840&r2=99841&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 16:28:41 2010 @@ -16,7 +16,6 @@ #define LLVM_SUPPORT_TIMER_H #include "llvm/System/DataTypes.h" -#include "llvm/System/Mutex.h" #include #include #include @@ -39,8 +38,6 @@ double UserTime; // User time elapsed double SystemTime; // System time elapsed ssize_t MemUsed; // Memory allocated (in bytes) - size_t PeakMem; // Peak memory used - size_t PeakMemBase; // Temporary for peak memory calculation. std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. @@ -54,7 +51,6 @@ double getProcessTime() const { return UserTime+SystemTime; } double getWallTime() const { return Elapsed; } ssize_t getMemUsed() const { return MemUsed; } - size_t getPeakMem() const { return PeakMem; } public: std::string getName() const { return Name; } @@ -77,12 +73,6 @@ /// void stopTimer(); - /// addPeakMemoryMeasurement - This method should be called whenever memory - /// usage needs to be checked. It adds a peak memory measurement to the - /// currently active timers, which will be printed when the timer group prints - /// - static void addPeakMemoryMeasurement(); - /// print - Print the current timer to standard error, and reset the "Started" /// flag. void print(const Timer &Total, raw_ostream &OS); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99841&r1=99840&r2=99841&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 16:28:41 2010 @@ -11,15 +11,14 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Format.h" +#include "llvm/System/Mutex.h" #include "llvm/System/Process.h" -#include -#include #include using namespace llvm; @@ -76,13 +75,13 @@ //===----------------------------------------------------------------------===// Timer::Timer(const std::string &N) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N), + : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), Started(false), TG(getDefaultTimerGroup()) { TG->addTimer(); } Timer::Timer(const std::string &N, TimerGroup &tg) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), PeakMem(0), Name(N), + : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), Started(false), TG(&tg) { TG->addTimer(); } @@ -154,7 +153,6 @@ UserTime -= TR.UserTime; SystemTime -= TR.SystemTime; MemUsed -= TR.MemUsed; - PeakMemBase = TR.MemUsed; } void Timer::stopTimer() { @@ -179,7 +177,6 @@ UserTime += T.UserTime; SystemTime += T.SystemTime; MemUsed += T.MemUsed; - PeakMem += T.PeakMem; } const Timer &Timer::operator=(const Timer &T) { @@ -187,8 +184,6 @@ UserTime = T.UserTime; SystemTime = T.SystemTime; MemUsed = T.MemUsed; - PeakMem = T.PeakMem; - PeakMemBase = T.PeakMemBase; Name = T.Name; Started = T.Started; assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); @@ -196,18 +191,6 @@ } -/// addPeakMemoryMeasurement - This method should be called whenever memory -/// usage needs to be checked. It adds a peak memory measurement to the -/// currently active timers, which will be printed when the timer group prints -/// -void Timer::addPeakMemoryMeasurement() { - size_t MemUsed = getMemUsage(); - for (std::vector::iterator I = ActiveTimers->begin(), - E = ActiveTimers->end(); I != E; ++I) - (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); -} - - static void printVal(double Val, double Total, raw_ostream &OS) { if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; @@ -231,12 +214,6 @@ if (Total.MemUsed) OS << format("%9lld", (long long)MemUsed) << " "; - if (Total.PeakMem) { - if (PeakMem) - OS << format("%9lld", (long long)PeakMem) << " "; - else - OS << " "; - } OS << Name << "\n"; Started = false; // Once printed, don't print again @@ -364,8 +341,6 @@ *OutStream << " ---Wall Time---"; if (Total.getMemUsed()) *OutStream << " ---Mem---"; - if (Total.getPeakMem()) - *OutStream << " -PeakMem-"; *OutStream << " --- Name ---\n"; // Loop through all of the timing data, printing it out. From sabre at nondot.org Mon Mar 29 16:34:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Mon, 29 Mar 2010 21:34:06 -0000 Subject: [llvm-commits] [llvm] r99842 - /llvm/trunk/lib/Support/Timer.cpp Message-ID: <20100329213407.097512A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 16:34:06 2010 New Revision: 99842 URL: http://llvm.org/viewvc/llvm-project?rev=99842&view=rev Log: move a function into a more logical place in the file Modified: llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99842&r1=99841&r2=99842&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 16:34:06 2010 @@ -52,6 +52,27 @@ cl::Hidden, cl::location(getLibSupportInfoOutputFilename())); } +// GetLibSupportInfoOutputFile - Return a file stream to print our output on. +raw_ostream *llvm::GetLibSupportInfoOutputFile() { + std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); + if (LibSupportInfoOutputFilename.empty()) + return &errs(); + if (LibSupportInfoOutputFilename == "-") + return &outs(); + + std::string Error; + raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), + Error, raw_fd_ostream::F_Append); + if (Error.empty()) + return Result; + + errs() << "Error opening info-output-file '" + << LibSupportInfoOutputFilename << " for appending!\n"; + delete Result; + return &errs(); +} + + static TimerGroup *DefaultTimerGroup = 0; static TimerGroup *getDefaultTimerGroup() { TimerGroup *tmp = DefaultTimerGroup; @@ -271,27 +292,6 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// -// GetLibSupportInfoOutputFile - Return a file stream to print our output on. -raw_ostream *llvm::GetLibSupportInfoOutputFile() { - std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); - if (LibSupportInfoOutputFilename.empty()) - return &errs(); - if (LibSupportInfoOutputFilename == "-") - return &outs(); - - std::string Error; - raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), - Error, raw_fd_ostream::F_Append); - if (Error.empty()) - return Result; - - errs() << "Error opening info-output-file '" - << LibSupportInfoOutputFilename << " for appending!\n"; - delete Result; - return &errs(); -} - - void TimerGroup::removeTimer() { sys::SmartScopedLock L(*TimerLock); if (--NumTimers != 0 || TimersToPrint.empty()) @@ -326,7 +326,6 @@ // TOTAL line to make the percentages make sense. if (this != DefaultTimerGroup) { *OutStream << " Total Execution Time: "; - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; } From wangmp at apple.com Mon Mar 29 16:36:23 2010 From: wangmp at apple.com (Mon Ping Wang) Date: Mon, 29 Mar 2010 14:36:23 -0700 Subject: [llvm-commits] Patch: address space support for memcpy/memmove/memset In-Reply-To: <9E5E9EA6-0ECE-4678-A92B-083C78D8776B@apple.com> References: <89548B9C-55E6-40DF-8E7D-9B1C30162EA4@apple.com> <9E5E9EA6-0ECE-4678-A92B-083C78D8776B@apple.com> Message-ID: <73F57A9C-89C9-472A-8FF7-93F70C7E6AAF@apple.com> I don't think so. They are cases where we want to support copying data from one address space to another through a memcpy intrinsic. I'll add the isVolatile field to memcpy, memset, and memmove. Thanks, -- Mon Ping On Mar 26, 2010, at 4:44 PM, Chris Lattner wrote: > > On Mar 24, 2010, at 4:01 PM, Mon Ping Wang wrote: > >> >> This is a patch to add support for address spaces for memcpy, memmove, and memset. I have changed the signature of these functions to be overloaded based on the pointer type. I have included both the llvm changes and the llvm-gcc-4.2 changes need to support. Please let me know if I miss something. I'll check it in a few days. > > Should the source and destination pointers be required to be in the same address space? I can see it either way (f.e. on x86 a copy from DS -> GS segment address space makes sense), but it would be nice to reduce noisiness in the function name if a copy from one addr space to another isn't useful. > > Other than that, this patch looks great to me, but "while you're at it" can you add an "i1 isVolatile" parameter to llvm.memcpy and friends? > > -Chris From clattner at apple.com Mon Mar 29 17:22:21 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 29 Mar 2010 15:22:21 -0700 Subject: [llvm-commits] Patch: address space support for memcpy/memmove/memset In-Reply-To: <73F57A9C-89C9-472A-8FF7-93F70C7E6AAF@apple.com> References: <89548B9C-55E6-40DF-8E7D-9B1C30162EA4@apple.com> <9E5E9EA6-0ECE-4678-A92B-083C78D8776B@apple.com> <73F57A9C-89C9-472A-8FF7-93F70C7E6AAF@apple.com> Message-ID: On Mar 29, 2010, at 2:36 PM, Mon Ping Wang wrote: > > I don't think so. They are cases where we want to support copying data from one address space to another through a memcpy intrinsic. I'll add the isVolatile field to memcpy, memset, and memmove. Ok, awesome, thanks a lot! -Chris > > Thanks, > -- Mon Ping > > On Mar 26, 2010, at 4:44 PM, Chris Lattner wrote: > >> >> On Mar 24, 2010, at 4:01 PM, Mon Ping Wang wrote: >> >>> >>> This is a patch to add support for address spaces for memcpy, memmove, and memset. I have changed the signature of these functions to be overloaded based on the pointer type. I have included both the llvm changes and the llvm-gcc-4.2 changes need to support. Please let me know if I miss something. I'll check it in a few days. >> >> Should the source and destination pointers be required to be in the same address space? I can see it either way (f.e. on x86 a copy from DS -> GS segment address space makes sense), but it would be nice to reduce noisiness in the function name if a copy from one addr space to another isn't useful. >> >> Other than that, this patch looks great to me, but "while you're at it" can you add an "i1 isVolatile" parameter to llvm.memcpy and friends? >> >> -Chris > From dpatel at apple.com Mon Mar 29 17:59:58 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 29 Mar 2010 22:59:58 -0000 Subject: [llvm-commits] [llvm] r99845 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100329225958.E90FD2A6C12C@llvm.org> Author: dpatel Date: Mon Mar 29 17:59:58 2010 New Revision: 99845 URL: http://llvm.org/viewvc/llvm-project?rev=99845&view=rev Log: Encode start location of debug value, communicated through DBG_VALUE machine instruction, in a variable's DIE. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=99845&r1=99844&r2=99845&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 29 17:59:58 2010 @@ -149,20 +149,26 @@ DIVariable Var; // Variable Descriptor. unsigned FrameIndex; // Variable frame index. const MachineInstr *DbgValueMInsn; // DBG_VALUE + // DbgValueLabel - DBG_VALUE is effective from this label. + MCSymbol *DbgValueLabel; DbgVariable *const AbstractVar; // Abstract variable for this variable. DIE *TheDIE; public: // AbsVar may be NULL. DbgVariable(DIVariable V, unsigned I, DbgVariable *AbsVar) - : Var(V), FrameIndex(I), DbgValueMInsn(0), AbstractVar(AbsVar), TheDIE(0) {} + : Var(V), FrameIndex(I), DbgValueMInsn(0), + DbgValueLabel(0), AbstractVar(AbsVar), TheDIE(0) {} DbgVariable(DIVariable V, const MachineInstr *MI, DbgVariable *AbsVar) - : Var(V), FrameIndex(0), DbgValueMInsn(MI), AbstractVar(AbsVar), TheDIE(0) + : Var(V), FrameIndex(0), DbgValueMInsn(MI), DbgValueLabel(0), + AbstractVar(AbsVar), TheDIE(0) {} // Accessors. DIVariable getVariable() const { return Var; } unsigned getFrameIndex() const { return FrameIndex; } const MachineInstr *getDbgValue() const { return DbgValueMInsn; } + MCSymbol *getDbgValueLabel() const { return DbgValueLabel; } + void setDbgValueLabel(MCSymbol *L) { DbgValueLabel = L; } DbgVariable *getAbstractVariable() const { return AbstractVar; } void setDIE(DIE *D) { TheDIE = D; } DIE *getDIE() const { return TheDIE; } @@ -1367,7 +1373,7 @@ DIE *DwarfDebug::constructLexicalScopeDIE(DbgScope *Scope) { MCSymbol *Start = Scope->getStartLabel(); MCSymbol *End = Scope->getEndLabel(); - if (Start == 0) return 0; + if (Start == 0 || End == 0) return 0; assert(Start->isDefined() && "Invalid starting label for an inlined scope!"); assert(End->isDefined() && "Invalid end label for an inlined scope!"); @@ -1390,7 +1396,7 @@ DIE *DwarfDebug::constructInlinedScopeDIE(DbgScope *Scope) { MCSymbol *StartLabel = Scope->getStartLabel(); MCSymbol *EndLabel = Scope->getEndLabel(); - if (StartLabel == 0) return 0; + if (StartLabel == 0 || EndLabel == 0) return 0; assert(StartLabel->isDefined() && "Invalid starting label for an inlined scope!"); @@ -1498,12 +1504,18 @@ MachineLocation Location; Location.set(DbgValueInsn->getOperand(0).getReg()); addAddress(VariableDie, dwarf::DW_AT_location, Location); + if (MCSymbol *VS = DV->getDbgValueLabel()) + addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr, + VS); } else if (DbgValueInsn->getOperand(0).getType() == MachineOperand::MO_Immediate) { DIEBlock *Block = new DIEBlock(); unsigned Imm = DbgValueInsn->getOperand(0).getImm(); addUInt(Block, 0, dwarf::DW_FORM_udata, Imm); addBlock(VariableDie, dwarf::DW_AT_const_value, 0, Block); + if (MCSymbol *VS = DV->getDbgValueLabel()) + addLabel(VariableDie, dwarf::DW_AT_start_scope, dwarf::DW_FORM_addr, + VS); } else { //FIXME : Handle other operand types. delete VariableDie; @@ -1566,10 +1578,9 @@ else ScopeDIE = updateSubprogramScopeDIE(DS.getNode()); } - else { + else ScopeDIE = constructLexicalScopeDIE(Scope); - if (!ScopeDIE) return NULL; - } + if (!ScopeDIE) return NULL; // Add variables to scope. const SmallVector &Variables = Scope->getVariables(); @@ -1957,10 +1968,11 @@ if (!Scope) return NULL; - AbsDbgVariable = new DbgVariable(Var, MI, + AbsDbgVariable = new DbgVariable(Var, MI, NULL /* No more-abstract variable*/); Scope->addVariable(AbsDbgVariable); AbstractVariables[Var.getNode()] = AbsDbgVariable; + DbgValueStartMap[MI] = AbsDbgVariable; return AbsDbgVariable; } @@ -1998,6 +2010,7 @@ const MachineInstr *MInsn = II; if (MInsn->getOpcode() != TargetOpcode::DBG_VALUE) continue; + // FIXME : Lift this restriction. if (MInsn->getNumOperands() != 3) continue; @@ -2006,6 +2019,7 @@ // FIXME Handle inlined subroutine arguments. DbgVariable *ArgVar = new DbgVariable(DV, MInsn, NULL); CurrentFnDbgScope->addVariable(ArgVar); + DbgValueStartMap[MInsn] = ArgVar; continue; } @@ -2020,9 +2034,9 @@ if (!Scope) continue; - DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, - ScopeLoc); + DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, ScopeLoc); DbgVariable *RegVar = new DbgVariable(DV, MInsn, AbsDbgVariable); + DbgValueStartMap[MInsn] = RegVar; Scope->addVariable(RegVar); } } @@ -2030,10 +2044,6 @@ /// beginScope - Process beginning of a scope. void DwarfDebug::beginScope(const MachineInstr *MI) { - // Ignore DBG_VALUE instructions. - if (MI->getOpcode() == TargetOpcode::DBG_VALUE) - return; - // Check location. DebugLoc DL = MI->getDebugLoc(); if (DL.isUnknown()) @@ -2047,6 +2057,18 @@ return; PrevDILoc = DILoc.getNode(); + // DBG_VALUE instruction establishes new value. + if (MI->getOpcode() == TargetOpcode::DBG_VALUE) { + DenseMap::iterator DI + = DbgValueStartMap.find(MI); + if (DI != DbgValueStartMap.end()) { + MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), + DILoc.getColumnNumber(), + DILoc.getScope().getNode()); + DI->second->setDbgValueLabel(Label); + } + } + // Emit a label to indicate location change. This is used for line // table even if this instruction does start a new scope. MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), @@ -2062,7 +2084,6 @@ for (ScopeVector::iterator SDI = SD.begin(), SDE = SD.end(); SDI != SDE; ++SDI) (*SDI)->setStartLabel(Label); - } /// endScope - Process end of a scope. @@ -2289,6 +2310,7 @@ DeleteContainerSeconds(DbgScopeMap); DbgScopeBeginMap.clear(); DbgScopeEndMap.clear(); + DbgValueStartMap.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=99845&r1=99844&r2=99845&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 29 17:59:58 2010 @@ -150,6 +150,12 @@ /// DbgScopes in AbstractScopes. DenseMap AbstractVariables; + /// DbgValueStartMap - Tracks starting scope of variable DIEs. + /// If the scope of an object begins sometime after the low pc value for the + /// scope most closely enclosing the object, the object entry may have a + /// DW_AT_start_scope attribute. + DenseMap DbgValueStartMap; + /// InliendSubprogramDIEs - Collection of subprgram DIEs that are marked /// (at the end of the module) as DW_AT_inline. SmallPtrSet InlinedSubprogramDIEs; From isanbard at gmail.com Mon Mar 29 18:02:46 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 29 Mar 2010 23:02:46 -0000 Subject: [llvm-commits] [llvm] r99846 - /llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Message-ID: <20100329230246.58DC32A6C12C@llvm.org> Author: void Date: Mon Mar 29 18:02:46 2010 New Revision: 99846 URL: http://llvm.org/viewvc/llvm-project?rev=99846&view=rev Log: A more general (and simpler!) implementation of r99671. It performs a similar transform. I.e., if a clean-up eh.selector call dominates the invoke of an _Unwind_Resume_or_Rethrow, then we convert the eh.selector into a catch-all. This patch, however, uses the DominatorTree information, and doesn't go through the whole rigmarole of starting at the eh.exception call, finding the corresponding URoR and eh.selector calls, and trying to trace through any number of instruction types to get to them. Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=99846&r1=99845&r2=99846&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Mar 29 18:02:46 2010 @@ -88,6 +88,12 @@ /// initializer instead. bool CleanupSelectors(); + /// FindAllCleanupSelectors - Find all eh.selector calls that are clean-ups. + void FindAllCleanupSelectors(SmallPtrSet &Sels); + + /// FindAllURoRInvokes - Find all URoR invokes in the function. + void FindAllURoRInvokes(SmallPtrSet &URoRInvokes); + /// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow" /// calls. The "unwind" part of these invokes jump to a landing pad within /// the current function. This is a candidate to merge the selector @@ -95,57 +101,6 @@ /// pad. bool HandleURoRInvokes(); - /// FindSelectorAndURoR - Find the eh.selector call and URoR call associated - /// with the eh.exception call. This recursively looks past instructions - /// which don't change the EH pointer value, like casts or PHI nodes. - bool FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke, - SmallPtrSet &SelCalls); - - /// DoMem2RegPromotion - Take an alloca call and promote it from memory to a - /// register. - bool DoMem2RegPromotion(Value *V) { - AllocaInst *AI = dyn_cast(V); - if (!AI || !isAllocaPromotable(AI)) return false; - - // Turn the alloca into a register. - std::vector Allocas(1, AI); - PromoteMemToReg(Allocas, *DT, *DF); - return true; - } - - /// PromoteStoreInst - Perform Mem2Reg on a StoreInst. - bool PromoteStoreInst(StoreInst *SI) { - if (!SI || !DT || !DF) return false; - if (DoMem2RegPromotion(SI->getOperand(1))) - return true; - return false; - } - - /// PromoteEHPtrStore - Promote the storing of an EH pointer into a - /// register. This should get rid of the store and subsequent loads. - bool PromoteEHPtrStore(IntrinsicInst *II) { - if (!DT || !DF) return false; - - bool Changed = false; - StoreInst *SI; - - while (1) { - SI = 0; - for (Value::use_iterator - I = II->use_begin(), E = II->use_end(); I != E; ++I) { - SI = dyn_cast(I); - if (SI) break; - } - - if (!PromoteStoreInst(SI)) - break; - - Changed = true; - } - - return false; - } - public: static char ID; // Pass identification, replacement for typeid. DwarfEHPrepare(const TargetLowering *tli, bool fast) : @@ -178,49 +133,51 @@ return new DwarfEHPrepare(tli, fast); } -/// FindSelectorAndURoR - Find the eh.selector call associated with the -/// eh.exception call. And indicate if there is a URoR "invoke" associated with -/// the eh.exception call. This recursively looks past instructions which don't -/// change the EH pointer value, like casts or PHI nodes. -bool -DwarfEHPrepare::FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke, - SmallPtrSet &SelCalls) { - SmallPtrSet SeenPHIs; - bool Changed = false; - - restart: +/// FindAllCleanupSelectors - Find all eh.selector calls that are clean-ups. +void DwarfEHPrepare:: +FindAllCleanupSelectors(SmallPtrSet &Sels) { for (Value::use_iterator - I = Inst->use_begin(), E = Inst->use_end(); I != E; ++I) { - Instruction *II = dyn_cast(I); - if (!II || II->getParent()->getParent() != F) continue; - - if (IntrinsicInst *Sel = dyn_cast(II)) { - if (Sel->getIntrinsicID() == Intrinsic::eh_selector) - SelCalls.insert(Sel); - } else if (InvokeInst *Invoke = dyn_cast(II)) { - if (Invoke->getCalledFunction() == URoR) - URoRInvoke = true; - } else if (CastInst *CI = dyn_cast(II)) { - Changed |= FindSelectorAndURoR(CI, URoRInvoke, SelCalls); - } else if (StoreInst *SI = dyn_cast(II)) { - if (!PromoteStoreInst(SI)) continue; - Changed = true; - SeenPHIs.clear(); - goto restart; // Uses may have changed, restart loop. - } else if (PHINode *PN = dyn_cast(II)) { - if (SeenPHIs.insert(PN)) - // Don't process a PHI node more than once. - Changed |= FindSelectorAndURoR(PN, URoRInvoke, SelCalls); - } + I = SelectorIntrinsic->use_begin(), + E = SelectorIntrinsic->use_end(); I != E; ++I) { + IntrinsicInst *SI = cast(I); + if (!SI || SI->getParent()->getParent() != F) continue; + + unsigned NumOps = SI->getNumOperands(); + if (NumOps > 4) continue; + bool IsCleanUp = (NumOps == 3); + + if (!IsCleanUp) + if (ConstantInt *CI = dyn_cast(SI->getOperand(3))) + IsCleanUp = (CI->getZExtValue() == 0); + + if (IsCleanUp) + Sels.insert(SI); } +} - return Changed; +/// FindAllURoRInvokes - Find all URoR invokes in the function. +void DwarfEHPrepare:: +FindAllURoRInvokes(SmallPtrSet &URoRInvokes) { + for (Value::use_iterator + I = URoR->use_begin(), + E = URoR->use_end(); I != E; ++I) { + if (InvokeInst *II = dyn_cast(I)) + URoRInvokes.insert(II); + } } /// CleanupSelectors - Any remaining eh.selector intrinsic calls which still use /// the ".llvm.eh.catch.all.value" call need to convert to using it's /// initializer instead. bool DwarfEHPrepare::CleanupSelectors() { + if (!EHCatchAllValue) return false; + + if (!SelectorIntrinsic) { + SelectorIntrinsic = + Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_selector); + if (!SelectorIntrinsic) return false; + } + bool Changed = false; for (Value::use_iterator I = SelectorIntrinsic->use_begin(), @@ -244,6 +201,8 @@ /// function. This is a candidate to merge the selector associated with the URoR /// invoke with the one from the URoR's landing pad. bool DwarfEHPrepare::HandleURoRInvokes() { + if (!DT) return CleanupSelectors(); // We require DominatorTree information. + if (!EHCatchAllValue) { EHCatchAllValue = F->getParent()->getNamedGlobal(".llvm.eh.catch.all.value"); @@ -261,50 +220,28 @@ if (!URoR) return CleanupSelectors(); } - if (!ExceptionValueIntrinsic) { - ExceptionValueIntrinsic = - Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_exception); - if (!ExceptionValueIntrinsic) return CleanupSelectors(); - } + SmallPtrSet Sels; + SmallPtrSet URoRInvokes; + FindAllCleanupSelectors(Sels); + FindAllURoRInvokes(URoRInvokes); - bool Changed = false; SmallPtrSet SelsToConvert; - for (Value::use_iterator - I = ExceptionValueIntrinsic->use_begin(), - E = ExceptionValueIntrinsic->use_end(); I != E; ++I) { - IntrinsicInst *EHPtr = dyn_cast(I); - if (!EHPtr || EHPtr->getParent()->getParent() != F) continue; - - Changed |= PromoteEHPtrStore(EHPtr); - - bool URoRInvoke = false; - SmallPtrSet SelCalls; - Changed |= FindSelectorAndURoR(EHPtr, URoRInvoke, SelCalls); - - if (URoRInvoke) { - // This EH pointer is being used by an invoke of an URoR instruction and - // an eh.selector intrinsic call. If the eh.selector is a 'clean-up', we - // need to convert it to a 'catch-all'. - for (SmallPtrSet::iterator - SI = SelCalls.begin(), SE = SelCalls.end(); SI != SE; ++SI) { - IntrinsicInst *II = *SI; - unsigned NumOps = II->getNumOperands(); - - if (NumOps <= 4) { - bool IsCleanUp = (NumOps == 3); - - if (!IsCleanUp) - if (ConstantInt *CI = dyn_cast(II->getOperand(3))) - IsCleanUp = (CI->getZExtValue() == 0); - - if (IsCleanUp) - SelsToConvert.insert(II); - } + for (SmallPtrSet::iterator + SI = Sels.begin(), SE = Sels.end(); SI != SE; ++SI) { + const BasicBlock *SelBB = (*SI)->getParent(); + for (SmallPtrSet::iterator + UI = URoRInvokes.begin(), UE = URoRInvokes.end(); UI != UE; ++UI) { + const BasicBlock *URoRBB = (*UI)->getParent(); + if (SelBB == URoRBB || DT->dominates(SelBB, URoRBB)) { + SelsToConvert.insert(*SI); + break; } } } + bool Changed = false; + if (!SelsToConvert.empty()) { // Convert all clean-up eh.selectors, which are associated with "invokes" of // URoR calls, into catch-all eh.selectors. From stoklund at 2pi.dk Mon Mar 29 18:24:21 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 29 Mar 2010 23:24:21 -0000 Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86: SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h Message-ID: <20100329232421.B9E1B2A6C12C@llvm.org> Author: stoklund Date: Mon Mar 29 18:24:21 2010 New Revision: 99848 URL: http://llvm.org/viewvc/llvm-project?rev=99848&view=rev Log: Basic implementation of SSEDomainFix pass. Cross-block inference is primitive and wrong, but the pass is working otherwise. Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=99848&r1=99847&r2=99848&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original) +++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Mon Mar 29 18:24:21 2010 @@ -29,12 +29,108 @@ using namespace llvm; namespace { + +/// Allocate objects from a pool, allow objects to be recycled, and provide a +/// way of deleting everything. +template +class PoolAllocator { + std::vector Pages, Avail; +public: + ~PoolAllocator() { Clear(); } + + T* Alloc() { + if (Avail.empty()) { + T *p = new T[PageSize]; + Pages.push_back(p); + Avail.reserve(PageSize); + for (unsigned n = 0; n != PageSize; ++n) + Avail.push_back(p+n); + } + T *p = Avail.back(); + Avail.pop_back(); + return p; + } + + // Allow object to be reallocated. It won't be reconstructed. + void Recycle(T *p) { + p->clear(); + Avail.push_back(p); + } + + // Destroy all objects, make sure there are no external pointers to them. + void Clear() { + Avail.clear(); + while (!Pages.empty()) { + delete[] Pages.back(); + Pages.pop_back(); + } + } +}; + +/// A DomainValue is a bit like LiveIntervals' ValNo, but it laso keeps track +/// of execution domains. +/// +/// An open DomainValue represents a set of instructions that can still switch +/// execution domain. Multiple registers may refer to the same open +/// DomainValue - they will eventually be collapsed to the same execution +/// domain. +/// +/// A collapsed DomainValue represents a single register that has been forced +/// into one of more execution domains. There is a separate collapsed +/// DomainValue for each register, but it may contain multiple execution +/// domains. A register value is initially created in a single execution +/// domain, but if we were forced to pay the penalty of a domain crossing, we +/// keep track of the fact the the register is now available in multiple +/// domains. +struct DomainValue { + // Basic reference counting. + unsigned Refs; + + // Available domains. For an open DomainValue, it is the still possible + // domains for collapsing. For a collapsed DomainValue it is the domains where + // the register is available for free. + unsigned Mask; + + // Position of the last defining instruction. + unsigned Dist; + + // Twiddleable instructions using or defining these registers. + SmallVector Instrs; + + // Collapsed DomainValue have no instructions to twiddle - it simply keeps + // track of the domains where the registers are already available. + bool collapsed() const { return Instrs.empty(); } + + // Is any domain in mask available? + bool compat(unsigned mask) const { + return Mask & mask; + } + + // Mark domain as available + void add(unsigned domain) { + Mask |= 1u << domain; + } + + DomainValue() { clear(); } + + void clear() { + Refs = Mask = Dist = 0; + Instrs.clear(); + } +}; + class SSEDomainFixPass : public MachineFunctionPass { static char ID; - const X86InstrInfo *TII; + PoolAllocator Pool; MachineFunction *MF; + const X86InstrInfo *TII; + const TargetRegisterInfo *TRI; + MachineBasicBlock *MBB; + bool hasLiveRegs; + DomainValue *LiveRegs[16]; + public: SSEDomainFixPass() : MachineFunctionPass(&ID) {} @@ -50,47 +146,288 @@ } private: + // Register mapping. + int RegIndex(unsigned Reg); + + // LiveRegs manipulations. + void SetLiveReg(int rx, DomainValue *DV); + void Kill(int rx); + void Force(int rx, unsigned domain); + void Collapse(DomainValue *dv, unsigned domain); + bool Merge(DomainValue *A, DomainValue *B); + void enterBasicBlock(MachineBasicBlock *MBB); + void visitGenericInstr(MachineInstr*); + void visitSoftInstr(MachineInstr*, unsigned mask); + void visitHardInstr(MachineInstr*, unsigned domain); + }; } char SSEDomainFixPass::ID = 0; +/// Translate TRI register number to an index into our smaller tables of +/// interesting registers. Return -1 for boring registers. +int SSEDomainFixPass::RegIndex(unsigned reg) { + // Registers are sorted lexicographically. + // We just need them to be consecutive, ordering doesn't matter. + assert(X86::XMM9 == X86::XMM0+15 && "Unexpected sort"); + reg -= X86::XMM0; + return reg < 16 ? reg : -1; +} + +/// Set LiveRegs[rx] = dv, updating reference counts. +void SSEDomainFixPass::SetLiveReg(int rx, DomainValue *dv) { + if (LiveRegs[rx] == dv) + return; + if (LiveRegs[rx]) { + assert(LiveRegs[rx]->Refs && "Bad refcount"); + if (--LiveRegs[rx]->Refs == 0) Pool.Recycle(LiveRegs[rx]); + } + LiveRegs[rx] = dv; + if (dv) ++dv->Refs; +} + +// Kill register rx, recycle or collapse any DomainValue. +void SSEDomainFixPass::Kill(int rx) { + if (!LiveRegs[rx]) return; + + // Before killing the last reference to an open DomainValue, collapse it to + // the first available domain. + if (LiveRegs[rx]->Refs == 1 && !LiveRegs[rx]->collapsed()) + Collapse(LiveRegs[rx], CountTrailingZeros_32(LiveRegs[rx]->Mask)); + else + SetLiveReg(rx, 0); +} + +/// Force register rx into domain. +void SSEDomainFixPass::Force(int rx, unsigned domain) { + hasLiveRegs = true; + if (DomainValue *dv = LiveRegs[rx]) { + if (dv->collapsed()) + dv->add(domain); + else + Collapse(dv, domain); + } else { + // Set up basic collapsed DomainValue + DomainValue *dv = Pool.Alloc(); + dv->add(domain); + SetLiveReg(rx, dv); + } +} + +/// Collapse open DomainValue into given domain. If there are multiple +/// registers using dv, they each get a unique collapsed DomainValue. +void SSEDomainFixPass::Collapse(DomainValue *dv, unsigned domain) { + assert(dv->compat(1u << domain) && "Cannot collapse"); + + // Collapse all the instructions. + while (!dv->Instrs.empty()) { + MachineInstr *mi = dv->Instrs.back(); + TII->SetSSEDomain(mi, domain); + dv->Instrs.pop_back(); + } + dv->Mask = 1u << domain; + + // If there are multiple users, give them new, unique DomainValues. + if (dv->Refs > 1) { + for (unsigned rx=0, e = array_lengthof(LiveRegs); rx != e; ++rx) + if (LiveRegs[rx] == dv) { + DomainValue *dv2 = Pool.Alloc(); + dv2->add(domain); + SetLiveReg(rx, dv2); + } + Pool.Recycle(dv); + } +} + +/// Merge - All instructions and registers in B are moved to A, and B is +/// released. +bool SSEDomainFixPass::Merge(DomainValue *A, DomainValue *B) { + assert(!A->collapsed() && "Cannot merge into collapsed"); + assert(!B->collapsed() && "Cannot merge from collapsed"); + if (!A->compat(B->Mask)) + return false; + A->Mask &= B->Mask; + A->Dist = std::max(A->Dist, B->Dist); + A->Instrs.append(B->Instrs.begin(), B->Instrs.end()); + for (unsigned rx=0, e = array_lengthof(LiveRegs); rx != e; ++rx) + if (LiveRegs[rx] == B) + SetLiveReg(rx, A); + return true; +} + void SSEDomainFixPass::enterBasicBlock(MachineBasicBlock *mbb) { MBB = mbb; - DEBUG(dbgs() << "Entering MBB " << MBB->getName() << "\n"); +} + +// A hard instruction only works in one domain. All input registers will be +// forced into that domain. +void SSEDomainFixPass::visitHardInstr(MachineInstr *mi, unsigned domain) { + // Collapse all uses. + for (unsigned i = mi->getDesc().getNumDefs(), + e = mi->getDesc().getNumOperands(); i != e; ++i) { + MachineOperand &mo = mi->getOperand(i); + if (!mo.isReg()) continue; + int rx = RegIndex(mo.getReg()); + if (rx < 0) continue; + Force(rx, domain); + } + + // Kill all defs and force them. + for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) { + MachineOperand &mo = mi->getOperand(i); + if (!mo.isReg()) continue; + int rx = RegIndex(mo.getReg()); + if (rx < 0) continue; + Kill(rx); + Force(rx, domain); + } +} + +// A soft instruction can be changed to work in other domains given by mask. +void SSEDomainFixPass::visitSoftInstr(MachineInstr *mi, unsigned mask) { + // Scan the explicit use operands for incoming domains. + unsigned collmask = mask; + SmallVector used; + for (unsigned i = mi->getDesc().getNumDefs(), + e = mi->getDesc().getNumOperands(); i != e; ++i) { + MachineOperand &mo = mi->getOperand(i); + if (!mo.isReg()) continue; + int rx = RegIndex(mo.getReg()); + if (rx < 0) continue; + if (DomainValue *dv = LiveRegs[rx]) { + // Is it possible to use this collapsed register for free? + if (dv->collapsed()) { + if (unsigned m = collmask & dv->Mask) + collmask = m; + } else if (dv->compat(collmask)) + used.push_back(rx); + else + Kill(rx); + } + } + + // If the collapsed operands force a single domain, propagate the collapse. + if (isPowerOf2_32(collmask)) { + unsigned domain = CountTrailingZeros_32(collmask); + TII->SetSSEDomain(mi, domain); + visitHardInstr(mi, domain); + return; + } + + // Kill off any remaining uses that don't match collmask, and build a list of + // incoming DomainValue that we want to merge. + SmallVector doms; + for (SmallVector::iterator i=used.begin(), e=used.end(); i!=e; ++i) { + int rx = *i; + DomainValue *dv = LiveRegs[rx]; + // This useless DomainValue could have been missed above + if (!dv->compat(collmask)) { + Kill(*i); + continue; + } + // sorted, uniqued insert. + bool inserted = false; + for (SmallVector::iterator i = doms.begin(), e = doms.end(); + i != e && !inserted; ++i) { + if (dv == *i) + inserted = true; + else if (dv->Dist < (*i)->Dist) { + inserted = true; + doms.insert(i, dv); + } + } + if (!inserted) + doms.push_back(dv); + } + + // doms are now sorted in order of appearance. Try to merge them all, giving + // priority to the latest ones. + DomainValue *dv = 0; + while (!doms.empty()) { + if (!dv) + dv = doms.back(); + else if (!Merge(dv, doms.back())) + for (SmallVector::iterator i=used.begin(), e=used.end(); i!=e; ++i) + if (LiveRegs[*i] == doms.back()) + Kill(*i); + doms.pop_back(); + } + + // dv is the DomainValue we are going to use for this instruction. + if (!dv) + dv = Pool.Alloc(); + dv->Mask = collmask; + dv->Instrs.push_back(mi); + + // Finally set all defs and non-collapsed uses to dv. + for (unsigned i = 0, e = mi->getDesc().getNumOperands(); i != e; ++i) { + MachineOperand &mo = mi->getOperand(i); + if (!mo.isReg()) continue; + int rx = RegIndex(mo.getReg()); + if (rx < 0) continue; + if (!LiveRegs[rx] || (mo.isDef() && LiveRegs[rx]!=dv)) { + Kill(rx); + SetLiveReg(rx, dv); + } + } +} + +void SSEDomainFixPass::visitGenericInstr(MachineInstr *mi) { + // Process explicit defs, kill any XMM registers redefined + for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) { + MachineOperand &mo = mi->getOperand(i); + if (!mo.isReg()) continue; + int rx = RegIndex(mo.getReg()); + if (rx < 0) continue; + Kill(rx); + } } bool SSEDomainFixPass::runOnMachineFunction(MachineFunction &mf) { MF = &mf; TII = static_cast(MF->getTarget().getInstrInfo()); + TRI = MF->getTarget().getRegisterInfo(); + MBB = 0; + + hasLiveRegs = false; + for (unsigned i=0, e = array_lengthof(LiveRegs); i != e; ++i) + LiveRegs[i] = 0; // If no XMM registers are used in the function, we can skip it completely. - bool XMMIsUsed = false; + bool anyregs = false; for (TargetRegisterClass::const_iterator I = X86::VR128RegClass.begin(), E = X86::VR128RegClass.end(); I != E; ++I) if (MF->getRegInfo().isPhysRegUsed(*I)) { - XMMIsUsed = true; + anyregs = true; break; } - if (!XMMIsUsed) return false; + if (!anyregs) return false; MachineBasicBlock *Entry = MF->begin(); SmallPtrSet Visited; - for (df_ext_iterator > + for (df_ext_iterator > DFI = df_ext_begin(Entry, Visited), DFE = df_ext_end(Entry, Visited); - DFI != DFE; ++DFI) { + DFI != DFE; ++DFI) { enterBasicBlock(*DFI); for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { - MachineInstr *MI = I; - const unsigned *equiv = 0; - X86InstrInfo::SSEDomain domain = TII->GetSSEDomain(MI, equiv); - (void) domain; - DEBUG(dbgs() << "-isd"[domain] << (equiv ? "* " : " ") << *MI); + MachineInstr *mi = I; + if (mi->isDebugValue()) continue; + std::pair domp = TII->GetSSEDomain(mi); + if (domp.first) + if (domp.second) + visitSoftInstr(mi, domp.second); + else + visitHardInstr(mi, domp.first); + else if (hasLiveRegs) + visitGenericInstr(mi); } } + + Pool.Clear(); + return false; } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=99848&r1=99847&r2=99848&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Mon Mar 29 18:24:21 2010 @@ -3659,45 +3659,49 @@ return GlobalBaseReg; } -X86InstrInfo::SSEDomain X86InstrInfo::GetSSEDomain(const MachineInstr *MI, - const unsigned *&equiv) const { - // These are the replaceable SSE instructions. Some of these have Int variants - // that we don't include here. We don't want to replace instructions selected - // by intrinsics. - static const unsigned ReplaceableInstrs[][3] = { - //PackedInt PackedSingle PackedDouble - { X86::MOVDQAmr, X86::MOVAPSmr, X86::MOVAPDmr }, - { X86::MOVDQArm, X86::MOVAPSrm, X86::MOVAPDrm }, - { X86::MOVDQArr, X86::MOVAPSrr, X86::MOVAPDrr }, - { X86::MOVDQUmr, X86::MOVUPSmr, X86::MOVUPDmr }, - { X86::MOVDQUrm, X86::MOVUPSrm, X86::MOVUPDrm }, - { X86::MOVNTDQmr, X86::MOVNTPSmr, X86::MOVNTPDmr }, - { X86::PANDNrm, X86::ANDNPSrm, X86::ANDNPDrm }, - { X86::PANDNrr, X86::ANDNPSrr, X86::ANDNPDrr }, - { X86::PANDrm, X86::ANDPSrm, X86::ANDPDrm }, - { X86::PANDrr, X86::ANDPSrr, X86::ANDPDrr }, - { X86::PORrm, X86::ORPSrm, X86::ORPDrm }, - { X86::PORrr, X86::ORPSrr, X86::ORPDrr }, - { X86::PUNPCKHQDQrm, X86::UNPCKHPSrm, X86::UNPCKHPDrm }, - { X86::PUNPCKHQDQrr, X86::UNPCKHPSrr, X86::UNPCKHPDrr }, - { X86::PUNPCKLQDQrm, X86::UNPCKLPSrm, X86::UNPCKLPDrm }, - { X86::PUNPCKLQDQrr, X86::UNPCKLPSrr, X86::UNPCKLPDrr }, - { X86::PXORrm, X86::XORPSrm, X86::XORPDrm }, - { X86::PXORrr, X86::XORPSrr, X86::XORPDrr }, - }; +// These are the replaceable SSE instructions. Some of these have Int variants +// that we don't include here. We don't want to replace instructions selected +// by intrinsics. +static const unsigned ReplaceableInstrs[][3] = { + //PackedInt PackedSingle PackedDouble + { X86::MOVDQAmr, X86::MOVAPSmr, X86::MOVAPDmr }, + { X86::MOVDQArm, X86::MOVAPSrm, X86::MOVAPDrm }, + { X86::MOVDQArr, X86::MOVAPSrr, X86::MOVAPDrr }, + { X86::MOVDQUmr, X86::MOVUPSmr, X86::MOVUPDmr }, + { X86::MOVDQUrm, X86::MOVUPSrm, X86::MOVUPDrm }, + { X86::MOVNTDQmr, X86::MOVNTPSmr, X86::MOVNTPDmr }, + { X86::PANDNrm, X86::ANDNPSrm, X86::ANDNPDrm }, + { X86::PANDNrr, X86::ANDNPSrr, X86::ANDNPDrr }, + { X86::PANDrm, X86::ANDPSrm, X86::ANDPDrm }, + { X86::PANDrr, X86::ANDPSrr, X86::ANDPDrr }, + { X86::PORrm, X86::ORPSrm, X86::ORPDrm }, + { X86::PORrr, X86::ORPSrr, X86::ORPDrr }, + { X86::PXORrm, X86::XORPSrm, X86::XORPDrm }, + { X86::PXORrr, X86::XORPSrr, X86::XORPDrr }, +}; - const SSEDomain domain = - SSEDomain((MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3); - if (domain == NotSSEDomain) - return domain; +// FIXME: Some shuffle and unpack instructions have equivalents in different +// domains, but they require a bit more work than just switching opcodes. - // Linear search FTW! - const unsigned opc = MI->getOpcode(); +static const unsigned *lookup(unsigned opcode, unsigned domain) { for (unsigned i = 0, e = array_lengthof(ReplaceableInstrs); i != e; ++i) - if (ReplaceableInstrs[i][domain-1] == opc) { - equiv = ReplaceableInstrs[i]; - return domain; - } - equiv = 0; - return domain; + if (ReplaceableInstrs[i][domain-1] == opcode) + return ReplaceableInstrs[i]; + return 0; +} + +std::pair +X86InstrInfo::GetSSEDomain(const MachineInstr *MI) const { + uint16_t domain = (MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3; + return std::make_pair(domain, domain != NotSSEDomain && + lookup(MI->getOpcode(), domain) ? 0xe : 0); +} + +void X86InstrInfo::SetSSEDomain(MachineInstr *MI, unsigned Domain) const { + assert(Domain>0 && Domain<4 && "Invalid execution domain"); + uint16_t dom = (MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3; + assert(dom && "Not an SSE instruction"); + const unsigned *table = lookup(MI->getOpcode(), dom); + assert(table && "Cannot change domain"); + MI->setDesc(get(table[Domain-1])); } Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=99848&r1=99847&r2=99848&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Mon Mar 29 18:24:21 2010 @@ -722,11 +722,12 @@ /// Some SSE instructions come in variants for three domains. enum SSEDomain { NotSSEDomain, PackedInt, PackedSingle, PackedDouble }; - /// GetSSEDomain - Return the SSE execution domain of MI, or NotSSEDomain for - /// unknown instructions. If the instruction has equivalents for other - /// domains, equiv points to a list of opcodes for [PackedInt, PackedSingle, - /// PackedDouble]. - SSEDomain GetSSEDomain(const MachineInstr *MI, const unsigned *&equiv) const; + /// GetSSEDomain - Return the SSE execution domain of MI as the first element, + /// and a bitmask of possible arguments to SetSSEDomain ase the second. + std::pair GetSSEDomain(const MachineInstr *MI) const; + + /// SetSSEDomain - Set the SSEDomain of MI. + void SetSSEDomain(MachineInstr *MI, unsigned Domain) const; private: MachineInstr * convertToThreeAddressWithLEA(unsigned MIOpc, From isanbard at gmail.com Mon Mar 29 18:37:07 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 29 Mar 2010 23:37:07 -0000 Subject: [llvm-commits] [llvm] r99850 - /llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Message-ID: <20100329233707.505622A6C12C@llvm.org> Author: void Date: Mon Mar 29 18:37:07 2010 New Revision: 99850 URL: http://llvm.org/viewvc/llvm-project?rev=99850&view=rev Log: Re-add back in the slow way of determining of a clean-up should become a catch-all. The "dominates" way won't catch all of the selectors which must be changed. Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=99850&r1=99849&r2=99850&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Mar 29 18:37:07 2010 @@ -101,6 +101,57 @@ /// pad. bool HandleURoRInvokes(); + /// FindSelectorAndURoR - Find the eh.selector call and URoR call associated + /// with the eh.exception call. This recursively looks past instructions + /// which don't change the EH pointer value, like casts or PHI nodes. + bool FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke, + SmallPtrSet &SelCalls); + + /// DoMem2RegPromotion - Take an alloca call and promote it from memory to a + /// register. + bool DoMem2RegPromotion(Value *V) { + AllocaInst *AI = dyn_cast(V); + if (!AI || !isAllocaPromotable(AI)) return false; + + // Turn the alloca into a register. + std::vector Allocas(1, AI); + PromoteMemToReg(Allocas, *DT, *DF); + return true; + } + + /// PromoteStoreInst - Perform Mem2Reg on a StoreInst. + bool PromoteStoreInst(StoreInst *SI) { + if (!SI || !DT || !DF) return false; + if (DoMem2RegPromotion(SI->getOperand(1))) + return true; + return false; + } + + /// PromoteEHPtrStore - Promote the storing of an EH pointer into a + /// register. This should get rid of the store and subsequent loads. + bool PromoteEHPtrStore(IntrinsicInst *II) { + if (!DT || !DF) return false; + + bool Changed = false; + StoreInst *SI; + + while (1) { + SI = 0; + for (Value::use_iterator + I = II->use_begin(), E = II->use_end(); I != E; ++I) { + SI = dyn_cast(I); + if (SI) break; + } + + if (!PromoteStoreInst(SI)) + break; + + Changed = true; + } + + return false; + } + public: static char ID; // Pass identification, replacement for typeid. DwarfEHPrepare(const TargetLowering *tli, bool fast) : @@ -196,6 +247,45 @@ return Changed; } +/// FindSelectorAndURoR - Find the eh.selector call associated with the +/// eh.exception call. And indicate if there is a URoR "invoke" associated with +/// the eh.exception call. This recursively looks past instructions which don't +/// change the EH pointer value, like casts or PHI nodes. +bool +DwarfEHPrepare::FindSelectorAndURoR(Instruction *Inst, bool &URoRInvoke, + SmallPtrSet &SelCalls) { + SmallPtrSet SeenPHIs; + bool Changed = false; + + restart: + for (Value::use_iterator + I = Inst->use_begin(), E = Inst->use_end(); I != E; ++I) { + Instruction *II = dyn_cast(I); + if (!II || II->getParent()->getParent() != F) continue; + + if (IntrinsicInst *Sel = dyn_cast(II)) { + if (Sel->getIntrinsicID() == Intrinsic::eh_selector) + SelCalls.insert(Sel); + } else if (InvokeInst *Invoke = dyn_cast(II)) { + if (Invoke->getCalledFunction() == URoR) + URoRInvoke = true; + } else if (CastInst *CI = dyn_cast(II)) { + Changed |= FindSelectorAndURoR(CI, URoRInvoke, SelCalls); + } else if (StoreInst *SI = dyn_cast(II)) { + if (!PromoteStoreInst(SI)) continue; + Changed = true; + SeenPHIs.clear(); + goto restart; // Uses may have changed, restart loop. + } else if (PHINode *PN = dyn_cast(II)) { + if (SeenPHIs.insert(PN)) + // Don't process a PHI node more than once. + Changed |= FindSelectorAndURoR(PN, URoRInvoke, SelCalls); + } + } + + return Changed; +} + /// HandleURoRInvokes - Handle invokes of "_Unwind_Resume_or_Rethrow" calls. The /// "unwind" part of these invokes jump to a landing pad within the current /// function. This is a candidate to merge the selector associated with the URoR @@ -242,6 +332,51 @@ bool Changed = false; + if (Sels.size() != SelsToConvert.size()) { + // If we haven't been able to convert all of the clean-up selectors, then + // loop through the slow way to see if they still need to be converted. + if (!ExceptionValueIntrinsic) { + ExceptionValueIntrinsic = + Intrinsic::getDeclaration(F->getParent(), Intrinsic::eh_exception); + if (!ExceptionValueIntrinsic) return CleanupSelectors(); + } + + for (Value::use_iterator + I = ExceptionValueIntrinsic->use_begin(), + E = ExceptionValueIntrinsic->use_end(); I != E; ++I) { + IntrinsicInst *EHPtr = dyn_cast(I); + if (!EHPtr || EHPtr->getParent()->getParent() != F) continue; + + Changed |= PromoteEHPtrStore(EHPtr); + + bool URoRInvoke = false; + SmallPtrSet SelCalls; + Changed |= FindSelectorAndURoR(EHPtr, URoRInvoke, SelCalls); + + if (URoRInvoke) { + // This EH pointer is being used by an invoke of an URoR instruction and + // an eh.selector intrinsic call. If the eh.selector is a 'clean-up', we + // need to convert it to a 'catch-all'. + for (SmallPtrSet::iterator + SI = SelCalls.begin(), SE = SelCalls.end(); SI != SE; ++SI) { + IntrinsicInst *II = *SI; + unsigned NumOps = II->getNumOperands(); + + if (NumOps <= 4) { + bool IsCleanUp = (NumOps == 3); + + if (!IsCleanUp) + if (ConstantInt *CI = dyn_cast(II->getOperand(3))) + IsCleanUp = (CI->getZExtValue() == 0); + + if (IsCleanUp) + SelsToConvert.insert(II); + } + } + } + } + } + if (!SelsToConvert.empty()) { // Convert all clean-up eh.selectors, which are associated with "invokes" of // URoR calls, into catch-all eh.selectors. From dalej at apple.com Mon Mar 29 18:48:15 2010 From: dalej at apple.com (Dale Johannesen) Date: Mon, 29 Mar 2010 23:48:15 -0000 Subject: [llvm-commits] [test-suite] r99852 - /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Message-ID: <20100329234815.C653B2A6C12C@llvm.org> Author: johannes Date: Mon Mar 29 18:48:15 2010 New Revision: 99852 URL: http://llvm.org/viewvc/llvm-project?rev=99852&view=rev Log: Fix test; storage addressed by Altivec instructions must be 16-byte aligned. Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c?rev=99852&r1=99851&r2=99852&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c (original) +++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Mon Mar 29 18:48:15 2010 @@ -6,7 +6,9 @@ main() { /* Mac G-4 sdot for arbitrary N wpp 6/8/2002 */ - float x[N],y[N],tres,res,eps; + float x[N] __attribute__((aligned(16))); + float y[N] __attribute__((aligned(16))); + float tres,res,eps; int flag,i,k,ki,kl,n0,n; static float seed = 331.0; float sdot(int,float *,float *); From daniel at zuster.org Mon Mar 29 18:56:40 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 29 Mar 2010 23:56:40 -0000 Subject: [llvm-commits] [llvm] r99853 - in /llvm/trunk: lib/MC/MachObjectWriter.cpp test/MC/MachO/darwin-x86_64-reloc.s Message-ID: <20100329235640.630D42A6C12C@llvm.org> Author: ddunbar Date: Mon Mar 29 18:56:40 2010 New Revision: 99853 URL: http://llvm.org/viewvc/llvm-project?rev=99853&view=rev Log: MC/Mach-O/x86_64: Support @GOTPCREL on symbols, even for non-PCrel relocations! Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp llvm/trunk/test/MC/MachO/darwin-x86_64-reloc.s Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=99853&r1=99852&r2=99853&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Mar 29 18:56:40 2010 @@ -612,9 +612,16 @@ } } } else { - if (Modifier == MCSymbolRefExpr::VK_GOT) + if (Modifier == MCSymbolRefExpr::VK_GOT) { Type = RIT_X86_64_GOT; - else if (Modifier != MCSymbolRefExpr::VK_None) + } else if (Modifier == MCSymbolRefExpr::VK_GOTPCREL) { + // GOTPCREL is allowed as a modifier on non-PCrel instructions, in + // which case all we do is set the PCrel bit in the relocation entry; + // this is used with exception handling, for example. The source is + // required to include any necessary offset directly. + Type = RIT_X86_64_GOT; + IsPCRel = 1; + } else if (Modifier != MCSymbolRefExpr::VK_None) llvm_report_error("unsupported symbol modifier in relocation"); else Type = RIT_X86_64_Unsigned; Modified: llvm/trunk/test/MC/MachO/darwin-x86_64-reloc.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/darwin-x86_64-reloc.s?rev=99853&r1=99852&r2=99853&view=diff ============================================================================== --- llvm/trunk/test/MC/MachO/darwin-x86_64-reloc.s (original) +++ llvm/trunk/test/MC/MachO/darwin-x86_64-reloc.s Mon Mar 29 18:56:40 2010 @@ -38,25 +38,29 @@ L1: .quad L1 - _prev + .data +.long _foobar at GOTPCREL+4 +.long _foo at GOTPCREL+4 + // CHECK: ('cputype', 16777223) // CHECK: ('cpusubtype', 3) // CHECK: ('filetype', 1) // CHECK: ('num_load_commands', 1) -// CHECK: ('load_commands_size', 256) +// CHECK: ('load_commands_size', 336) // CHECK: ('flag', 0) // CHECK: ('reserved', 0) // CHECK: ('load_commands', [ // CHECK: # Load Command 0 // CHECK: (('command', 25) -// CHECK: ('size', 152) +// CHECK: ('size', 232) // CHECK: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') // CHECK: ('vm_addr', 0) -// CHECK: ('vm_size', 181) -// CHECK: ('file_offset', 288) -// CHECK: ('file_size', 181) +// CHECK: ('vm_size', 189) +// CHECK: ('file_offset', 368) +// CHECK: ('file_size', 189) // CHECK: ('maxprot', 7) // CHECK: ('initprot', 7) -// CHECK: ('num_sections', 1) +// CHECK: ('num_sections', 2) // CHECK: ('flags', 0) // CHECK: ('sections', [ // CHECK: # Section 0 @@ -64,9 +68,9 @@ // CHECK: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') // CHECK: ('address', 0) // CHECK: ('size', 181) -// CHECK: ('offset', 288) +// CHECK: ('offset', 368) // CHECK: ('alignment', 0) -// CHECK: ('reloc_offset', 472) +// CHECK: ('reloc_offset', 560) // CHECK: ('num_reloc', 27) // CHECK: ('flags', 0x80000400) // CHECK: ('reserved1', 0) @@ -157,19 +161,42 @@ // CHECK: ('word-1', 0x2d000000)), // CHECK: ]) // CHECK: ('_section_data', '\xc3\xe8\x00\x00\x00\x00\xe8\x04\x00\x00\x00H\x8b\x05\x00\x00\x00\x00\xff5\x00\x00\x00\x00\x8b\x05\x00\x00\x00\x00\x8b\x05\x04\x00\x00\x00\xc6\x05\xff\xff\xff\xff\x12\xc7\x05\xfc\xff\xff\xffxV4\x12\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00H\x8d\x05,\x00\x00\x00H\x8d\x05\x14\x00\x00\x00\x83\x05\x13\x00\x00\x00\x06f\x81\x05\x12\x00\x00\x00\xf4\x01\x81\x05\x10\x00\x00\x00\xf4\x01\x00\x00\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90,\x00\x00\x00\x00\x00\x00\x00\x14\x00\x00\x00\x00\x00\x00\x00\xe4\xff\xff\xff\xff\xff\xff\xff\xd4\xff\xff\xff\xff\xff\xff\xff,\x00\x00\x00\x00\x00\x00\x00') +// CHECK: # Section 1 +// CHECK: (('section_name', '__data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK: ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK: ('address', 181) +// CHECK: ('size', 8) +// CHECK: ('offset', 549) +// CHECK: ('alignment', 0) +// CHECK: ('reloc_offset', 776) +// CHECK: ('num_reloc', 2) +// CHECK: ('flags', 0x0) +// CHECK: ('reserved1', 0) +// CHECK: ('reserved2', 0) +// CHECK: ('reserved3', 0) +// CHECK: ), +// CHECK: ('_relocations', [ +// CHECK: # Relocation 0 +// CHECK: (('word-0', 0x4), +// CHECK: ('word-1', 0x4d000000)), +// CHECK: # Relocation 1 +// CHECK: (('word-0', 0x0), +// CHECK: ('word-1', 0x4d000004)), +// CHECK: ]) +// CHECK: ('_section_data', '\x04\x00\x00\x00\x04\x00\x00\x00') // CHECK: ]) // CHECK: ), // CHECK: # Load Command 1 // CHECK: (('command', 2) // CHECK: ('size', 24) -// CHECK: ('symoff', 688) -// CHECK: ('nsyms', 4) -// CHECK: ('stroff', 752) -// CHECK: ('strsize', 24) -// CHECK: ('_string_data', '\x00_foo\x00_baz\x00_bar\x00_prev\x00\x00\x00') +// CHECK: ('symoff', 792) +// CHECK: ('nsyms', 5) +// CHECK: ('stroff', 872) +// CHECK: ('strsize', 32) +// CHECK: ('_string_data', '\x00_foobar\x00_foo\x00_baz\x00_bar\x00_prev\x00\x00\x00') // CHECK: ('_symbols', [ // CHECK: # Symbol 0 -// CHECK: (('n_strx', 1) +// CHECK: (('n_strx', 9) // CHECK: ('n_type', 0xe) // CHECK: ('n_sect', 1) // CHECK: ('n_desc', 0) @@ -177,7 +204,7 @@ // CHECK: ('_string', '_foo') // CHECK: ), // CHECK: # Symbol 1 -// CHECK: (('n_strx', 6) +// CHECK: (('n_strx', 14) // CHECK: ('n_type', 0xe) // CHECK: ('n_sect', 1) // CHECK: ('n_desc', 0) @@ -185,7 +212,7 @@ // CHECK: ('_string', '_baz') // CHECK: ), // CHECK: # Symbol 2 -// CHECK: (('n_strx', 11) +// CHECK: (('n_strx', 19) // CHECK: ('n_type', 0xe) // CHECK: ('n_sect', 1) // CHECK: ('n_desc', 0) @@ -193,13 +220,21 @@ // CHECK: ('_string', '_bar') // CHECK: ), // CHECK: # Symbol 3 -// CHECK: (('n_strx', 16) +// CHECK: (('n_strx', 24) // CHECK: ('n_type', 0xe) // CHECK: ('n_sect', 1) // CHECK: ('n_desc', 0) // CHECK: ('n_value', 129) // CHECK: ('_string', '_prev') // CHECK: ), +// CHECK: # Symbol 4 +// CHECK: (('n_strx', 1) +// CHECK: ('n_type', 0x1) +// CHECK: ('n_sect', 0) +// CHECK: ('n_desc', 0) +// CHECK: ('n_value', 0) +// CHECK: ('_string', '_foobar') +// CHECK: ), // CHECK: ]) // CHECK: ), // CHECK: # Load Command 2 @@ -210,7 +245,7 @@ // CHECK: ('iextdefsym', 4) // CHECK: ('nextdefsym', 0) // CHECK: ('iundefsym', 4) -// CHECK: ('nundefsym', 0) +// CHECK: ('nundefsym', 1) // CHECK: ('tocoff', 0) // CHECK: ('ntoc', 0) // CHECK: ('modtaboff', 0) From stoklund at 2pi.dk Mon Mar 29 19:09:32 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 00:09:32 -0000 Subject: [llvm-commits] [llvm] r99855 - /llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Message-ID: <20100330000932.4B3482A6C12C@llvm.org> Author: stoklund Date: Mon Mar 29 19:09:32 2010 New Revision: 99855 URL: http://llvm.org/viewvc/llvm-project?rev=99855&view=rev Log: Be gentle to MSVC. C++ is hard, after all. Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=99855&r1=99854&r2=99855&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original) +++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Mon Mar 29 19:09:32 2010 @@ -203,14 +203,15 @@ /// Force register rx into domain. void SSEDomainFixPass::Force(int rx, unsigned domain) { hasLiveRegs = true; - if (DomainValue *dv = LiveRegs[rx]) { + DomainValue *dv; + if ((dv = LiveRegs[rx])) { if (dv->collapsed()) dv->add(domain); else Collapse(dv, domain); } else { // Set up basic collapsed DomainValue - DomainValue *dv = Pool.Alloc(); + dv = Pool.Alloc(); dv->add(domain); SetLiveReg(rx, dv); } From dalej at apple.com Mon Mar 29 19:23:28 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 30 Mar 2010 00:23:28 -0000 Subject: [llvm-commits] [test-suite] r99856 - /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Message-ID: <20100330002328.53D252A6C12C@llvm.org> Author: johannes Date: Mon Mar 29 19:23:28 2010 New Revision: 99856 URL: http://llvm.org/viewvc/llvm-project?rev=99856&view=rev Log: Fix more misaligned storage. (If this test ever worked, it was accidental; as far as I know it never did.) Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c?rev=99856&r1=99855&r2=99856&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c (original) +++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Mon Mar 29 19:23:28 2010 @@ -44,7 +44,7 @@ int i,ii,nres,nsegs; vector float V7 = (vector float)(0.0,0.0,0.0,0.0); vector float V0,V1; - float psum[4]; + float psum[4] __attribute__((aligned(16))); // n < NS done in scalar mode if(n < NS){ sum = x[0]*y[0]; From dalej at apple.com Mon Mar 29 19:58:32 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 30 Mar 2010 00:58:32 -0000 Subject: [llvm-commits] [test-suite] r99858 - in /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec: alti.expandfft.c alti.sdot.c alti.stepfft.c Message-ID: <20100330005832.8F0272A6C12C@llvm.org> Author: johannes Date: Mon Mar 29 19:58:32 2010 New Revision: 99858 URL: http://llvm.org/viewvc/llvm-project?rev=99858&view=rev Log: Fix more test bogosity: misaligned storage, falling off the end of main. Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c?rev=99858&r1=99857&r2=99858&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c (original) +++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.expandfft.c Mon Mar 29 19:58:32 2010 @@ -92,6 +92,7 @@ if((ln2%4)==0) nits /= 10; n *= 2; } + return 0; } void cfft2(unsigned int n,float x[][2],float y[][2],float w[][2], float sign) { @@ -103,7 +104,8 @@ */ int jb,jc,jd,jw,k,k2,k4,lj,m,j,mj,mj2,pass,tgle; - float rp,up,wr[4],wu[4]; + float rp,up,wr[4] __attribute((aligned(16))); + float wu[4] __attribute((aligned(16))); float *a,*b,*c,*d; const vector float vminus = (vector float)(-0.,0.,-0.,0.); const vector float vzero = (vector float)(0.,0.,0.,0.); Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c?rev=99858&r1=99857&r2=99858&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c (original) +++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c Mon Mar 29 19:58:32 2010 @@ -36,6 +36,7 @@ kl = 4; } if(flag == 0) printf(" All n tests passed\n"); + return 0; } #define NS 12 float sdot(int n, float *x, float *y) Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c?rev=99858&r1=99857&r2=99858&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c (original) +++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.stepfft.c Mon Mar 29 19:58:32 2010 @@ -70,6 +70,7 @@ } } } + return 0; } void cfft2(n,x,y,w,sign) int n; @@ -129,7 +130,7 @@ { int j,k,jc,jw,l,lj,mj2; float rp,up; - float wr[4], wu[4]; + float wr[4] __attribute((aligned(16))), wu[4] __attribute((aligned(16))); const vector float vminus = (vector float)(-0.,0.,-0.,0.); const vector float vzero = (vector float)(0.,0.,0.,0.); const vector unsigned char pv3201 = From echristo at apple.com Mon Mar 29 20:04:59 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 01:04:59 -0000 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100330010459.500622A6C12C@llvm.org> Author: echristo Date: Mon Mar 29 20:04:59 2010 New Revision: 99859 URL: http://llvm.org/viewvc/llvm-project?rev=99859&view=rev Log: Add FIXME for operand promotion. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99859&r1=99858&r2=99859&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Mar 29 20:04:59 2010 @@ -794,6 +794,9 @@ } // Promote v16i8, v8i16, v4i32 load, select, and, or, xor to v2i64. + // FIXME: This produces lots of inefficiencies in isel since + // we then need notice that most of our operands have been implicitly + // converted to v2i64. for (unsigned i = (unsigned)MVT::v16i8; i != (unsigned)MVT::v2i64; i++) { MVT::SimpleValueType SVT = (MVT::SimpleValueType)i; EVT VT = SVT; @@ -802,6 +805,7 @@ if (!VT.is128BitVector()) { continue; } + setOperationAction(ISD::AND, SVT, Promote); AddPromotedToType (ISD::AND, SVT, MVT::v2i64); setOperationAction(ISD::OR, SVT, Promote); From clattner at apple.com Mon Mar 29 21:06:34 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 29 Mar 2010 19:06:34 -0700 Subject: [llvm-commits] [test-suite] r99856 - /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/alti.sdot.c In-Reply-To: <20100330002328.53D252A6C12C@llvm.org> References: <20100330002328.53D252A6C12C@llvm.org> Message-ID: <78304CDD-846D-43BA-B285-9A4F4B6E9F87@apple.com> On Mar 29, 2010, at 5:23 PM, Dale Johannesen wrote: > Author: johannes > Date: Mon Mar 29 19:23:28 2010 > New Revision: 99856 > > URL: http://llvm.org/viewvc/llvm-project?rev=99856&view=rev > Log: > Fix more misaligned storage. (If this test ever > worked, it was accidental; as far as I know it > never did.) I think that GCC and, at one point llvm-gcc, round arrays on the stack up to its notion of a max align. -Chris From clattner at apple.com Mon Mar 29 21:07:13 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 29 Mar 2010 19:07:13 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <20100330010459.500622A6C12C@llvm.org> References: <20100330010459.500622A6C12C@llvm.org> Message-ID: On Mar 29, 2010, at 6:04 PM, Eric Christopher wrote: > Author: echristo > Date: Mon Mar 29 20:04:59 2010 > New Revision: 99859 > > URL: http://llvm.org/viewvc/llvm-project?rev=99859&view=rev > Log: > Add FIXME for operand promotion. What is this talking about? -Chris > > Modified: > llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99859&r1=99858&r2=99859&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Mar 29 20:04:59 2010 > @@ -794,6 +794,9 @@ > } > > // Promote v16i8, v8i16, v4i32 load, select, and, or, xor to v2i64. > + // FIXME: This produces lots of inefficiencies in isel since > + // we then need notice that most of our operands have been implicitly > + // converted to v2i64. > for (unsigned i = (unsigned)MVT::v16i8; i != (unsigned)MVT::v2i64; i++) { > MVT::SimpleValueType SVT = (MVT::SimpleValueType)i; > EVT VT = SVT; > @@ -802,6 +805,7 @@ > if (!VT.is128BitVector()) { > continue; > } > + > setOperationAction(ISD::AND, SVT, Promote); > AddPromotedToType (ISD::AND, SVT, MVT::v2i64); > setOperationAction(ISD::OR, SVT, Promote); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Mon Mar 29 21:38:19 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 02:38:19 -0000 Subject: [llvm-commits] [llvm] r99862 - in /llvm/trunk: include/llvm/PassManagers.h include/llvm/Support/Timer.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/Support/Timer.cpp lib/VMCore/PassManager.cpp Message-ID: <20100330023819.BDB612A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 21:38:19 2010 New Revision: 99862 URL: http://llvm.org/viewvc/llvm-project?rev=99862&view=rev Log: fairly major rewrite of various timing related stuff. Modified: llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/Support/Timer.cpp llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/include/llvm/PassManagers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassManagers.h (original) +++ llvm/trunk/include/llvm/PassManagers.h Mon Mar 29 21:38:19 2010 @@ -413,7 +413,6 @@ /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. - class FPPassManager : public ModulePass, public PMDataManager { public: static char ID; @@ -462,8 +461,7 @@ } }; -extern Timer *StartPassTimer(Pass *); -extern void StopPassTimer(Pass *, Timer *); +Timer *getPassTimer(Pass *); } Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 21:38:19 2010 @@ -16,15 +16,62 @@ #define LLVM_SUPPORT_TIMER_H #include "llvm/System/DataTypes.h" +#include #include #include -#include +#include namespace llvm { +class Timer; class TimerGroup; class raw_ostream; +class TimeRecord { + double WallTime; // Wall clock time elapsed in seconds + double UserTime; // User time elapsed + double SystemTime; // System time elapsed + ssize_t MemUsed; // Memory allocated (in bytes) +public: + TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {} + + /// getCurrentTime - Get the current time and memory usage. If Start is true + /// we get the memory usage before the time, otherwise we get time before + /// memory usage. This matters if the time to get the memory usage is + /// significant and shouldn't be counted as part of a duration. + static TimeRecord getCurrentTime(bool Start = true); + + double getProcessTime() const { return UserTime+SystemTime; } + double getUserTime() const { return UserTime; } + double getSystemTime() const { return SystemTime; } + double getWallTime() const { return WallTime; } + ssize_t getMemUsed() const { return MemUsed; } + + + // operator< - Allow sorting. + bool operator<(const TimeRecord &T) const { + // Sort by Wall Time elapsed, as it is the only thing really accurate + return WallTime < T.WallTime; + } + + void operator+=(const TimeRecord &RHS) { + WallTime += RHS.WallTime; + UserTime += RHS.UserTime; + SystemTime += RHS.SystemTime; + MemUsed += RHS.MemUsed; + } + void operator-=(const TimeRecord &RHS) { + WallTime -= RHS.WallTime; + UserTime -= RHS.UserTime; + SystemTime -= RHS.SystemTime; + MemUsed -= RHS.MemUsed; + } + + /// print - Print the current timer to standard error, and reset the "Started" + /// flag. + void print(const TimeRecord &Total, raw_ostream &OS) const; +}; + /// Timer - This class is used to track the amount of time spent between /// invocations of its startTimer()/stopTimer() methods. Given appropriate OS /// support it can also keep track of the RSS of the program at various points. @@ -34,35 +81,30 @@ /// if they are never started. /// class Timer { - double Elapsed; // Wall clock time elapsed in seconds - double UserTime; // User time elapsed - double SystemTime; // System time elapsed - ssize_t MemUsed; // Memory allocated (in bytes) + TimeRecord Time; std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. public: - explicit Timer(const std::string &N); - Timer(const std::string &N, TimerGroup &tg); - Timer(const Timer &T); + explicit Timer(const std::string &N) : TG(0) { init(N); } + Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); } + Timer(const Timer &RHS) : TG(0) { + assert(RHS.TG == 0 && "Can only copy uninitialized timers"); + } + const Timer &operator=(const Timer &T) { + assert(TG == 0 && T.TG == 0 && "Can only assign uninit timers"); + return *this; + } ~Timer(); -private: - double getProcessTime() const { return UserTime+SystemTime; } - double getWallTime() const { return Elapsed; } - ssize_t getMemUsed() const { return MemUsed; } -public: - std::string getName() const { return Name; } - - const Timer &operator=(const Timer &T); + // Create an uninitialized timer, client must use 'init'. + explicit Timer() : TG(0) {} + void init(const std::string &N); + void init(const std::string &N, TimerGroup &tg); + + const std::string &getName() const { return Name; } + bool isInitialized() const { return TG != 0; } - // operator< - Allow sorting. - bool operator<(const Timer &T) const { - // Sort by Wall Time elapsed, as it is the only thing really accurate - return Elapsed < T.Elapsed; - } - bool operator>(const Timer &T) const { return T.operator<(*this); } - /// startTimer - Start the timer running. Time between calls to /// startTimer/stopTimer is counted by the Timer class. Note that these calls /// must be correctly paired. @@ -73,19 +115,8 @@ /// void stopTimer(); - /// print - Print the current timer to standard error, and reset the "Started" - /// flag. - void print(const Timer &Total, raw_ostream &OS); - private: friend class TimerGroup; - - // Copy ctor, initialize with no TG member. - Timer(bool, const Timer &T); - - /// sum - Add the time accumulated in the specified timer into this timer. - /// - void sum(const Timer &T); }; @@ -132,9 +163,13 @@ class TimerGroup { std::string Name; unsigned NumTimers; - std::vector TimersToPrint; + std::vector > TimersToPrint; public: explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {} + explicit TimerGroup() : NumTimers(0) {} + + void setName(const std::string &name) { Name = name; } + ~TimerGroup() { assert(NumTimers == 0 && "TimerGroup destroyed before all contained timers!"); @@ -144,7 +179,7 @@ friend class Timer; void addTimer(); void removeTimer(); - void addTimerToPrint(const Timer &T); + void addTimerToPrint(const TimeRecord &T, const std::string &Name); }; } // End llvm namespace Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Mon Mar 29 21:38:19 2010 @@ -17,12 +17,13 @@ #define DEBUG_TYPE "cgscc-passmgr" #include "llvm/CallGraphSCCPass.h" +#include "llvm/IntrinsicInst.h" +#include "llvm/Function.h" +#include "llvm/PassManagers.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/ADT/SCCIterator.h" -#include "llvm/PassManagers.h" -#include "llvm/Function.h" #include "llvm/Support/Debug.h" -#include "llvm/IntrinsicInst.h" +#include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -102,9 +103,10 @@ CallGraphUpToDate = true; } - Timer *T = StartPassTimer(CGSP); - Changed = CGSP->runOnSCC(CurSCC); - StopPassTimer(CGSP, T); + { + TimeRegion PassTimer(getPassTimer(CGSP)); + Changed = CGSP->runOnSCC(CurSCC); + } // After the CGSCCPass is done, when assertions are enabled, use // RefreshCallGraph to verify that the callgraph was correctly updated. @@ -125,9 +127,8 @@ for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) { if (Function *F = CurSCC[i]->getFunction()) { dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName()); - Timer *T = StartPassTimer(FPP); + TimeRegion PassTimer(getPassTimer(FPP)); Changed |= FPP->runOnFunction(*F); - StopPassTimer(FPP, T); } } Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Mon Mar 29 21:38:19 2010 @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" +#include "llvm/Support/Timer.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -228,9 +229,9 @@ { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); - Timer *T = StartPassTimer(P); + TimeRegion PassTimer(getPassTimer(P)); + Changed |= P->runOnLoop(CurrentLoop, *this); - StopPassTimer(P, T); } if (Changed) @@ -245,9 +246,10 @@ // is a function pass and it's really expensive to verify every // loop in the function every time. That level of checking can be // enabled with the -verify-loop-info option. - Timer *T = StartPassTimer(LI); - CurrentLoop->verifyLoop(); - StopPassTimer(LI, T); + { + TimeRegion PassTimer(getPassTimer(LI)); + CurrentLoop->verifyLoop(); + } // Then call the regular verifyAnalysis functions. verifyPreservedAnalysis(P); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 21:38:19 2010 @@ -19,6 +19,7 @@ #include "llvm/Support/Format.h" #include "llvm/System/Mutex.h" #include "llvm/System/Process.h" +#include "llvm/ADT/StringMap.h" #include using namespace llvm; @@ -95,37 +96,28 @@ // Timer Implementation //===----------------------------------------------------------------------===// -Timer::Timer(const std::string &N) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), - Started(false), TG(getDefaultTimerGroup()) { +void Timer::init(const std::string &N) { + assert(TG == 0 && "Timer already initialized"); + Name = N; + Started = false; + TG = getDefaultTimerGroup(); TG->addTimer(); } -Timer::Timer(const std::string &N, TimerGroup &tg) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), - Started(false), TG(&tg) { +void Timer::init(const std::string &N, TimerGroup &tg) { + assert(TG == 0 && "Timer already initialized"); + Name = N; + Started = false; + TG = &tg; TG->addTimer(); } -Timer::Timer(const Timer &T) { - TG = T.TG; - if (TG) TG->addTimer(); - operator=(T); -} - -// Copy ctor, initialize with no TG member. -Timer::Timer(bool, const Timer &T) { - TG = T.TG; // Avoid assertion in operator= - operator=(T); // Copy contents - TG = 0; -} - Timer::~Timer() { - if (!TG) return; + if (!TG) return; // Never initialized. if (Started) { Started = false; - TG->addTimerToPrint(*this); + TG->addTimerToPrint(Time, Name); } TG->removeTimer(); } @@ -136,12 +128,7 @@ return 0; } -struct TimeRecord { - double Elapsed, UserTime, SystemTime; - ssize_t MemUsed; -}; - -static TimeRecord getTimeRecord(bool Start) { +TimeRecord TimeRecord::getCurrentTime(bool Start) { TimeRecord Result; sys::TimeValue now(0,0); @@ -157,9 +144,9 @@ MemUsed = getMemUsage(); } - Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; + Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; Result.MemUsed = MemUsed; return Result; } @@ -169,19 +156,11 @@ void Timer::startTimer() { Started = true; ActiveTimers->push_back(this); - TimeRecord TR = getTimeRecord(true); - Elapsed -= TR.Elapsed; - UserTime -= TR.UserTime; - SystemTime -= TR.SystemTime; - MemUsed -= TR.MemUsed; + Time -= TimeRecord::getCurrentTime(true); } void Timer::stopTimer() { - TimeRecord TR = getTimeRecord(false); - Elapsed += TR.Elapsed; - UserTime += TR.UserTime; - SystemTime += TR.SystemTime; - MemUsed += TR.MemUsed; + Time += TimeRecord::getCurrentTime(false); if (ActiveTimers->back() == this) { ActiveTimers->pop_back(); @@ -193,25 +172,6 @@ } } -void Timer::sum(const Timer &T) { - Elapsed += T.Elapsed; - UserTime += T.UserTime; - SystemTime += T.SystemTime; - MemUsed += T.MemUsed; -} - -const Timer &Timer::operator=(const Timer &T) { - Elapsed = T.Elapsed; - UserTime = T.UserTime; - SystemTime = T.SystemTime; - MemUsed = T.MemUsed; - Name = T.Name; - Started = T.Started; - assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); - return *this; -} - - static void printVal(double Val, double Total, raw_ostream &OS) { if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; @@ -221,23 +181,19 @@ } } -void Timer::print(const Timer &Total, raw_ostream &OS) { - if (Total.UserTime) - printVal(UserTime, Total.UserTime, OS); - if (Total.SystemTime) - printVal(SystemTime, Total.SystemTime, OS); +void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { + if (Total.getUserTime()) + printVal(getUserTime(), Total.getUserTime(), OS); + if (Total.getSystemTime()) + printVal(getSystemTime(), Total.getSystemTime(), OS); if (Total.getProcessTime()) printVal(getProcessTime(), Total.getProcessTime(), OS); - printVal(Elapsed, Total.Elapsed, OS); + printVal(getWallTime(), Total.getWallTime(), OS); OS << " "; - if (Total.MemUsed) - OS << format("%9lld", (long long)MemUsed) << " "; - - OS << Name << "\n"; - - Started = false; // Once printed, don't print again + if (Total.getMemUsed()) + OS << format("%9lld", (long long)getMemUsed()) << " "; } @@ -245,40 +201,35 @@ // NamedRegionTimer Implementation //===----------------------------------------------------------------------===// -typedef std::map Name2Timer; -typedef std::map > Name2Pair; +typedef StringMap Name2TimerMap; +typedef StringMap > Name2PairMap; -static ManagedStatic NamedTimers; -static ManagedStatic NamedGroupedTimers; +static ManagedStatic NamedTimers; +static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { sys::SmartScopedLock L(*TimerLock); - Name2Timer::iterator I = NamedTimers->find(Name); - if (I != NamedTimers->end()) - return I->second; - - return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second; + + Timer &T = (*NamedTimers)[Name]; + if (!T.isInitialized()) + T.init(Name); + return T; } static Timer &getNamedRegionTimer(const std::string &Name, const std::string &GroupName) { sys::SmartScopedLock L(*TimerLock); - Name2Pair::iterator I = NamedGroupedTimers->find(GroupName); - if (I == NamedGroupedTimers->end()) { - TimerGroup TG(GroupName); - std::pair Pair(TG, Name2Timer()); - I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair)); - } + std::pair &GroupEntry = + (*NamedGroupedTimers)[GroupName]; - Name2Timer::iterator J = I->second.second.find(Name); - if (J == I->second.second.end()) - J = I->second.second.insert(J, - std::make_pair(Name, - Timer(Name, - I->second.first))); + if (GroupEntry.second.empty()) + GroupEntry.first.setName(GroupName); - return J->second; + Timer &T = GroupEntry.second[Name]; + if (!T.isInitialized()) + T.init(Name); + return T; } NamedRegionTimer::NamedRegionTimer(const std::string &Name) @@ -298,8 +249,7 @@ return; // Don't print timing report. // Sort the timers in descending order by amount of time taken. - std::sort(TimersToPrint.begin(), TimersToPrint.end(), - std::greater()); + std::sort(TimersToPrint.begin(), TimersToPrint.end()); // Figure out how many spaces to indent TimerGroup name. unsigned Padding = (80-Name.length())/2; @@ -307,50 +257,46 @@ raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - ++NumTimers; - { // Scope to contain Total timer: don't allow total timer to drop us to - // zero timers. - Timer Total("TOTAL"); - - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - Total.sum(TimersToPrint[i]); - - // Print out timing header. - *OutStream << "===" << std::string(73, '-') << "===\n" - << std::string(Padding, ' ') << Name << "\n" - << "===" << std::string(73, '-') - << "===\n"; - - // If this is not an collection of ungrouped times, print the total time. - // Ungrouped timers don't really make sense to add up. We still print the - // TOTAL line to make the percentages make sense. - if (this != DefaultTimerGroup) { - *OutStream << " Total Execution Time: "; - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; - *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; - } - *OutStream << "\n"; - - if (Total.UserTime) - *OutStream << " ---User Time---"; - if (Total.SystemTime) - *OutStream << " --System Time--"; - if (Total.getProcessTime()) - *OutStream << " --User+System--"; - *OutStream << " ---Wall Time---"; - if (Total.getMemUsed()) - *OutStream << " ---Mem---"; - *OutStream << " --- Name ---\n"; - - // Loop through all of the timing data, printing it out. - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - TimersToPrint[i].print(Total, *OutStream); - - Total.print(Total, *OutStream); - *OutStream << '\n'; - OutStream->flush(); + TimeRecord Total; + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + Total += TimersToPrint[i].first; + + // Print out timing header. + *OutStream << "===" << std::string(73, '-') << "===\n"; + OutStream->indent(Padding) << Name << '\n'; + *OutStream << "===" << std::string(73, '-') << "===\n"; + + // If this is not an collection of ungrouped times, print the total time. + // Ungrouped timers don't really make sense to add up. We still print the + // TOTAL line to make the percentages make sense. + if (this != DefaultTimerGroup) { + *OutStream << " Total Execution Time: "; + *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; + *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; } - --NumTimers; + *OutStream << "\n"; + + if (Total.getUserTime()) + *OutStream << " ---User Time---"; + if (Total.getSystemTime()) + *OutStream << " --System Time--"; + if (Total.getProcessTime()) + *OutStream << " --User+System--"; + *OutStream << " ---Wall Time---"; + if (Total.getMemUsed()) + *OutStream << " ---Mem---"; + *OutStream << " --- Name ---\n"; + + // Loop through all of the timing data, printing it out. + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) { + const std::pair &Entry = TimersToPrint[e-i-1]; + Entry.first.print(Total, *OutStream); + *OutStream << Entry.second << '\n'; + } + + Total.print(Total, *OutStream); + *OutStream << "Total\n\n"; + OutStream->flush(); TimersToPrint.clear(); @@ -363,8 +309,8 @@ ++NumTimers; } -void TimerGroup::addTimerToPrint(const Timer &T) { +void TimerGroup::addTimerToPrint(const TimeRecord &T, const std::string &Name) { sys::SmartScopedLock L(*TimerLock); - TimersToPrint.push_back(Timer(true, T)); + TimersToPrint.push_back(std::make_pair(T, Name)); } Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=99862&r1=99861&r2=99862&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Mar 29 21:38:19 2010 @@ -378,7 +378,7 @@ static ManagedStatic > TimingInfoMutex; class TimingInfo { - std::map TimingData; + DenseMap TimingData; TimerGroup TG; public: @@ -397,19 +397,16 @@ // null. It may be called multiple times. static void createTheTimeInfo(); - /// passStarted - This method creates a timer for the given pass if it doesn't - /// already have one, and starts the timer. - Timer *passStarted(Pass *P) { + /// getPassTimer - Return the timer for the specified pass if it exists. + Timer *getPassTimer(Pass *P) { if (P->getAsPMDataManager()) return 0; sys::SmartScopedLock Lock(*TimingInfoMutex); - std::map::iterator I = TimingData.find(P); - if (I == TimingData.end()) - I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; - Timer *T = &I->second; - T->startTimer(); - return T; + Timer &T = TimingData[P]; + if (!T.isInitialized()) + T.init(P->getPassName(), TG); + return &T; } }; @@ -704,11 +701,8 @@ E = PreservedSet.end(); I != E; ++I) { AnalysisID AID = *I; if (Pass *AP = findAnalysisPass(AID, true)) { - - Timer *T = 0; - if (TheTimeInfo) T = TheTimeInfo->passStarted(AP); + TimeRegion PassTimer(getPassTimer(AP)); AP->verifyAnalysis(); - if (T) T->stopTimer(); } } } @@ -792,10 +786,9 @@ { // If the pass crashes releasing memory, remember this. PassManagerPrettyStackEntry X(P); - - Timer *T = StartPassTimer(P); + TimeRegion PassTimer(getPassTimer(P)); + P->releaseMemory(); - StopPassTimer(P, T); } if (const PassInfo *PI = P->getPassInfo()) { @@ -1128,10 +1121,9 @@ { // If the pass crashes, remember this. PassManagerPrettyStackEntry X(BP, *I); - - Timer *T = StartPassTimer(BP); + TimeRegion PassTimer(getPassTimer(BP)); + LocalChanged |= BP->runOnBasicBlock(*I); - StopPassTimer(BP, T); } Changed |= LocalChanged; @@ -1345,10 +1337,9 @@ { PassManagerPrettyStackEntry X(FP, F); + TimeRegion PassTimer(getPassTimer(FP)); - Timer *T = StartPassTimer(FP); LocalChanged |= FP->runOnFunction(F); - StopPassTimer(FP, T); } Changed |= LocalChanged; @@ -1420,9 +1411,9 @@ { PassManagerPrettyStackEntry X(MP, M); - Timer *T = StartPassTimer(MP); + TimeRegion PassTimer(getPassTimer(MP)); + LocalChanged |= MP->runOnModule(M); - StopPassTimer(MP, T); } Changed |= LocalChanged; @@ -1559,17 +1550,12 @@ } /// If TimingInfo is enabled then start pass timer. -Timer *llvm::StartPassTimer(Pass *P) { +Timer *llvm::getPassTimer(Pass *P) { if (TheTimeInfo) - return TheTimeInfo->passStarted(P); + return TheTimeInfo->getPassTimer(P); return 0; } -/// If TimingInfo is enabled then stop pass timer. -void llvm::StopPassTimer(Pass *P, Timer *T) { - if (T) T->stopTimer(); -} - //===----------------------------------------------------------------------===// // PMStack implementation // From jyasskin at google.com Mon Mar 29 21:49:45 2010 From: jyasskin at google.com (Jeffrey Yasskin) Date: Mon, 29 Mar 2010 19:49:45 -0700 Subject: [llvm-commits] [llvm] r99469 - in /llvm/trunk: include/llvm/CodeGen/MachineOperand.h include/llvm/CodeGen/SelectionDAG.h lib/CodeGen/SelectionDAG/InstrEmitter.cpp lib/CodeGen/SelectionDAG/InstrEmitter.h lib/CodeGen/SelectionDAG/SDNodeDbgValue.h l In-Reply-To: References: <37F7E1A8-9AB0-4736-9C59-7C304AA2BB3A@apple.com> <51C8EEC7-AA24-4BCA-ADD3-80C8DF3C0A15@apple.com> Message-ID: Yep, that fixed it: http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/11/steps/test-llvm/logs/stdio On Mon, Mar 29, 2010 at 1:53 PM, Jeffrey Yasskin wrote: > I've started http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/11 > to check. Thanks! > > On Mon, Mar 29, 2010 at 1:49 PM, Evan Cheng wrote: >> Does 99836 fix it? >> >> Evan >> On Mar 29, 2010, at 11:38 AM, Evan Cheng wrote: >> >>> Looking. >>> >>> Evan >>> >>> On Mar 26, 2010, at 10:16 PM, Jeffrey Yasskin wrote: >>> >>>> Hey Evan, this change may have introduced the new memory leak in >>>> DebugInfo/2010-02-01-DbgValueCrash.ll >>>> (http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/7/steps/test-llvm/logs/stdio). >>>> The whole valgrind error (run at r99590) is: >>>> >>>> ==8278== 56 bytes in 1 blocks are definitely lost in loss record 130 of 135 >>>> ==8278== ? ?at 0x4C229C7: operator new(unsigned long) (vg_replace_malloc.c:220) >>>> ==8278== ? ?by 0xD809F6: >>>> llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst&, >>>> unsigned int) (SelectionDAGBuilder.cpp:3840) >>>> ==8278== ? ?by 0xD87327: >>>> llvm::SelectionDAGBuilder::visitCall(llvm::CallInst&) >>>> (SelectionDAGBuilder.cpp:4662) >>>> ==8278== ? ?by 0xD62E31: llvm::SelectionDAGBuilder::visit(unsigned >>>> int, llvm::User&) (Instruction.def:161) >>>> ==8278== ? ?by 0xD6293D: >>>> llvm::SelectionDAGBuilder::visit(llvm::Instruction&) >>>> (SelectionDAGBuilder.cpp:617) >>>> ==8278== ? ?by 0xDA455C: >>>> llvm::SelectionDAGISel::SelectBasicBlock(llvm::BasicBlock*, >>>> llvm::ilist_iterator, >>>> llvm::ilist_iterator, bool&) >>>> (SelectionDAGISel.cpp:407) >>>> ==8278== ? ?by 0xDA7952: >>>> llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function&, >>>> llvm::MachineFunction&, llvm::MachineModuleInfo*, llvm::DwarfWriter*, >>>> llvm::TargetInstrInfo const&) (SelectionDAGISel.cpp:1030) >>>> ==8278== ? ?by 0xDA41E6: >>>> llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) >>>> (SelectionDAGISel.cpp:344) >>>> ==8278== ? ?by 0xEBE6B6: >>>> llvm::MachineFunctionPass::runOnFunction(llvm::Function&) >>>> (MachineFunctionPass.cpp:27) >>>> ==8278== ? ?by 0x11E2A5C: >>>> llvm::FPPassManager::runOnFunction(llvm::Function&) >>>> (PassManager.cpp:1350) >>>> ==8278== ? ?by 0x11E2734: >>>> llvm::FunctionPassManagerImpl::run(llvm::Function&) >>>> (PassManager.cpp:1301) >>>> ==8278== ? ?by 0x11E23E4: >>>> llvm::FunctionPassManager::run(llvm::Function&) (PassManager.cpp:1231) >>>> ==8278== >>>> >>>> Could you take a look? Sorry if you've already fixed this. >>>> >>>> On Wed, Mar 24, 2010 at 6:38 PM, Evan Cheng wrote: >>>>> Author: evancheng >>>>> Date: Wed Mar 24 20:38:16 2010 >>>>> New Revision: 99469 >>>>> >>>>> URL: http://llvm.org/viewvc/llvm-project?rev=99469&view=rev >>>>> Log: >>>>> Change how dbg_value sdnodes are converted into machine instructions. Their placement should be determined by the relative order of incoming llvm instructions. The scheduler will now use the SDNode ordering information to determine where to insert them. A dbg_value instruction is inserted after the instruction with the last highest source order and before the instruction with the next highest source order. It will optimize the placement by inserting right after the instruction that produces the value if they have consecutive order numbers. >>>>> >>>>> Here is a theoretical example that illustrates why the placement is important. >>>>> >>>>> tmp1 = >>>>> store tmp1 -> x >>>>> ... >>>>> tmp2 = add ... >>>>> ... >>>>> call >>>>> ... >>>>> store tmp2 -> x >>>>> >>>>> Now mem2reg comes along: >>>>> >>>>> tmp1 = >>>>> dbg_value (tmp1 -> x) >>>>> ... >>>>> tmp2 = add ... >>>>> ... >>>>> call >>>>> ... >>>>> dbg_value (tmp2 -> x) >>>>> >>>>> When the debugger examine the value of x after the add instruction but before the call, it should have the value of tmp1. >>>>> >>>>> Furthermore, for dbg_value's that reference constants, they should not be emitted at the beginning of the block (since they do not have "producers"). >>>>> >>>>> This patch also cleans up how SDISel manages DbgValue nodes. It allow a SDNode to be referenced by multiple SDDbgValue nodes. When a SDNode is deleted, it uses the information to find the SDDbgValues and invalidate them. They are not deleted until the corresponding SelectionDAG is destroyed. >>>>> >>>>> Modified: >>>>> ? llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>>>> ? llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>>>> ? llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>>>> >>>>> Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) >>>>> +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Wed Mar 24 20:38:16 2010 >>>>> @@ -285,6 +285,11 @@ >>>>> ? ?IsEarlyClobber = Val; >>>>> ?} >>>>> >>>>> + ?void setIsDebug(bool Val = true) { >>>>> + ? ?assert(isReg() && IsDef && "Wrong MachineOperand accessor"); >>>>> + ? ?IsDebug = Val; >>>>> + ?} >>>>> + >>>>> ?//===--------------------------------------------------------------------===// >>>>> ?// Accessors for various operand types. >>>>> ?//===--------------------------------------------------------------------===// >>>>> >>>>> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >>>>> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Wed Mar 24 20:38:16 2010 >>>>> @@ -60,42 +60,40 @@ >>>>> >>>>> /// SDDbgInfo - Keeps track of dbg_value information through SDISel. ?We do >>>>> /// not build SDNodes for these so as not to perturb the generated code; >>>>> -/// instead the info is kept off to the side in this structure. ?SDNodes may >>>>> -/// have an associated dbg_value entry in DbgValMap. ?Debug info that is not >>>>> -/// associated with any SDNode is held in DbgConstMap. ?It is possible for >>>>> -/// optimizations to change a variable to a constant, in which case the >>>>> -/// corresponding debug info is moved from the variable to the constant table >>>>> -/// (NYI). >>>>> +/// instead the info is kept off to the side in this structure. Each SDNode may >>>>> +/// have one or more associated dbg_value entries. This information is kept in >>>>> +/// DbgValMap. >>>>> class SDDbgInfo { >>>>> - ?DenseMap DbgVblMap; >>>>> - ?SmallVector DbgConstMap; >>>>> + ?SmallVector DbgValues; >>>>> + ?DenseMap > DbgVblMap; >>>>> >>>>> ?void operator=(const SDDbgInfo&); ? // Do not implement. >>>>> ?SDDbgInfo(const SDDbgInfo&); ? // Do not implement. >>>>> public: >>>>> ?SDDbgInfo() {} >>>>> >>>>> - ?void add(const SDNode *Node, SDDbgValue *V) { >>>>> - ? ?DbgVblMap[Node] = V; >>>>> + ?void add(SDDbgValue *V, const SDNode *Node = 0) { >>>>> + ? ?if (Node) >>>>> + ? ? ?DbgVblMap[Node].push_back(V); >>>>> + ? ?DbgValues.push_back(V); >>>>> ?} >>>>> - ?void add(SDDbgValue *V) { DbgConstMap.push_back(V); } >>>>> - ?void remove(const SDNode *Node) { >>>>> - ? ?DenseMap::iterator Itr = >>>>> - ? ? ? ? ? ? ? ? ? ? ?DbgVblMap.find(Node); >>>>> - ? ?if (Itr != DbgVblMap.end()) >>>>> - ? ? ?DbgVblMap.erase(Itr); >>>>> - ?} >>>>> - ?// No need to remove a constant. >>>>> + >>>>> ?void clear() { >>>>> ? ?DbgVblMap.clear(); >>>>> - ? ?DbgConstMap.clear(); >>>>> + ? ?DbgValues.clear(); >>>>> + ?} >>>>> + >>>>> + ?bool empty() const { >>>>> + ? ?return DbgValues.empty(); >>>>> ?} >>>>> - ?SDDbgValue *getSDDbgValue(const SDNode *Node) { >>>>> + >>>>> + ?SmallVector &getSDDbgValues(const SDNode *Node) { >>>>> ? ?return DbgVblMap[Node]; >>>>> ?} >>>>> - ?typedef SmallVector::iterator ConstDbgIterator; >>>>> - ?ConstDbgIterator DbgConstBegin() { return DbgConstMap.begin(); } >>>>> - ?ConstDbgIterator DbgConstEnd() { return DbgConstMap.end(); } >>>>> + >>>>> + ?typedef SmallVector::iterator DbgIterator; >>>>> + ?DbgIterator DbgBegin() { return DbgValues.begin(); } >>>>> + ?DbgIterator DbgEnd() ? { return DbgValues.end(); } >>>>> }; >>>>> >>>>> enum CombineLevel { >>>>> @@ -871,19 +869,21 @@ >>>>> ?/// GetOrdering - Get the order for the SDNode. >>>>> ?unsigned GetOrdering(const SDNode *SD) const; >>>>> >>>>> - ?/// AssignDbgInfo - Assign debug info to the SDNode. >>>>> - ?void AssignDbgInfo(SDNode *SD, SDDbgValue *db); >>>>> + ?/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>>>> + ?/// value is produced by SD. >>>>> + ?void AddDbgValue(SDDbgValue *DB, SDNode *SD = 0); >>>>> >>>>> - ?/// RememberDbgInfo - Remember debug info with no associated SDNode. >>>>> - ?void RememberDbgInfo(SDDbgValue *db); >>>>> + ?/// GetDbgValues - Get the debug values which reference the given SDNode. >>>>> + ?SmallVector &GetDbgValues(const SDNode* SD) { >>>>> + ? ?return DbgInfo->getSDDbgValues(SD); >>>>> + ?} >>>>> >>>>> - ?/// GetDbgInfo - Get the debug info for the SDNode. >>>>> - ?SDDbgValue *GetDbgInfo(const SDNode* SD); >>>>> + ?/// hasDebugValues - Return true if there are any SDDbgValue nodes associated >>>>> + ?/// with this SelectionDAG. >>>>> + ?bool hasDebugValues() const { return !DbgInfo->empty(); } >>>>> >>>>> - ?SDDbgInfo::ConstDbgIterator DbgConstBegin() { >>>>> - ? ?return DbgInfo->DbgConstBegin(); >>>>> - ?} >>>>> - ?SDDbgInfo::ConstDbgIterator DbgConstEnd() { return DbgInfo->DbgConstEnd(); } >>>>> + ?SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); } >>>>> + ?SDDbgInfo::DbgIterator DbgEnd() ? { return DbgInfo->DbgEnd(); } >>>>> >>>>> ?void dump() const; >>>>> >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Mar 24 20:38:16 2010 >>>>> @@ -264,7 +264,8 @@ >>>>> InstrEmitter::AddRegisterOperand(MachineInstr *MI, SDValue Op, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned IIOpNum, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const TargetInstrDesc *II, >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap) { >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsDebug) { >>>>> ?assert(Op.getValueType() != MVT::Other && >>>>> ? ? ? ? Op.getValueType() != MVT::Flag && >>>>> ? ? ? ? "Chain and flag operands should occur at end of operand list!"); >>>>> @@ -295,7 +296,11 @@ >>>>> ? ?} >>>>> ?} >>>>> >>>>> - ?MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef)); >>>>> + ?MI->addOperand(MachineOperand::CreateReg(VReg, isOptDef, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isImp*/, false/*isKill*/, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isDead*/, false/*isUndef*/, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false/*isEarlyClobber*/, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0/*SubReg*/, IsDebug)); >>>>> } >>>>> >>>>> /// AddOperand - Add the specified operand to the specified machine instr. ?II >>>>> @@ -305,9 +310,10 @@ >>>>> void InstrEmitter::AddOperand(MachineInstr *MI, SDValue Op, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap) { >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool IsDebug) { >>>>> ?if (Op.isMachineOpcode()) { >>>>> - ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>>>> + ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>>>> ?} else if (ConstantSDNode *C = dyn_cast(Op)) { >>>>> ? ?MI->addOperand(MachineOperand::CreateImm(C->getSExtValue())); >>>>> ?} else if (ConstantFPSDNode *F = dyn_cast(Op)) { >>>>> @@ -356,7 +362,7 @@ >>>>> ? ?assert(Op.getValueType() != MVT::Other && >>>>> ? ? ? ? ? Op.getValueType() != MVT::Flag && >>>>> ? ? ? ? ? "Chain and flag operands should occur at end of operand list!"); >>>>> - ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap); >>>>> + ? ?AddRegisterOperand(MI, Op, IIOpNum, II, VRBaseMap, IsDebug); >>>>> ?} >>>>> } >>>>> >>>>> @@ -498,75 +504,48 @@ >>>>> ?assert(isNew && "Node emitted out of order - early"); >>>>> } >>>>> >>>>> -/// EmitDbgValue - Generate any debug info that refers to this Node. ?Constant >>>>> -/// dbg_value is not handled here. >>>>> -void >>>>> -InstrEmitter::EmitDbgValue(SDNode *Node, >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? SDDbgValue *sd) { >>>>> - ?if (!Node->getHasDebugValue()) >>>>> - ? ?return; >>>>> - ?if (!sd) >>>>> - ? ?return; >>>>> - ?assert(sd->getKind() == SDDbgValue::SDNODE); >>>>> - ?unsigned VReg = getVR(SDValue(sd->getSDNode(), sd->getResNo()), VRBaseMap); >>>>> - ?const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>>>> - ?DebugLoc DL = sd->getDebugLoc(); >>>>> - ?MachineInstr *MI; >>>>> - ?if (VReg) { >>>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(VReg, RegState::Debug). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addImm(sd->getOffset()). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addMetadata(sd->getMDPtr()); >>>>> - ?} else { >>>>> - ? ?// Insert an Undef so we can see what we dropped. >>>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?addMetadata(sd->getMDPtr()); >>>>> - ?} >>>>> - ?MBB->insert(InsertPos, MI); >>>>> -} >>>>> - >>>>> -/// EmitDbgValue - Generate debug info that does not refer to a SDNode. >>>>> -void >>>>> -InstrEmitter::EmitDbgValue(SDDbgValue *sd, >>>>> +/// EmitDbgValue - Generate machine instruction for a dbg_value node. >>>>> +/// >>>>> +MachineInstr *InstrEmitter::EmitDbgValue(SDDbgValue *SD, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineBasicBlock *InsertBB, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? DenseMap *EM) { >>>>> - ?if (!sd) >>>>> - ? ?return; >>>>> + ?uint64_t Offset = SD->getOffset(); >>>>> + ?MDNode* MDPtr = SD->getMDPtr(); >>>>> + ?DebugLoc DL = SD->getDebugLoc(); >>>>> + >>>>> ?const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE); >>>>> - ?uint64_t Offset = sd->getOffset(); >>>>> - ?MDNode* mdPtr = sd->getMDPtr(); >>>>> - ?SDDbgValue::DbgValueKind kind = sd->getKind(); >>>>> - ?DebugLoc DL = sd->getDebugLoc(); >>>>> - ?MachineInstr* MI; >>>>> - ?if (kind == SDDbgValue::CONST) { >>>>> - ? ?Value *V = sd->getConst(); >>>>> + ?MachineInstrBuilder MIB = BuildMI(*MF, DL, II); >>>>> + ?if (SD->getKind() == SDDbgValue::SDNODE) { >>>>> + ? ?AddOperand(&*MIB, SDValue(SD->getSDNode(), SD->getResNo()), >>>>> + ? ? ? ? ? ? ? (*MIB).getNumOperands(), &II, VRBaseMap, true /*IsDebug*/); >>>>> + ?} else if (SD->getKind() == SDDbgValue::CONST) { >>>>> + ? ?Value *V = SD->getConst(); >>>>> ? ?if (ConstantInt *CI = dyn_cast(V)) { >>>>> - ? ? ?MI = BuildMI(*MF, DL, II).addImm(CI->getZExtValue()). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>>> + ? ? ?MIB.addImm(CI->getSExtValue()); >>>>> ? ?} else if (ConstantFP *CF = dyn_cast(V)) { >>>>> - ? ? ?MI = BuildMI(*MF, DL, II).addFPImm(CF). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>>> + ? ? ?MIB.addFPImm(CF); >>>>> ? ?} else { >>>>> ? ? ?// Could be an Undef. ?In any case insert an Undef so we can see what we >>>>> ? ? ?// dropped. >>>>> - ? ? ?MI = BuildMI(*MF, DL, II).addReg(0U). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>>> + ? ? ?MIB.addReg(0U); >>>>> ? ?} >>>>> - ?} else if (kind == SDDbgValue::FRAMEIX) { >>>>> - ? ?unsigned FrameIx = sd->getFrameIx(); >>>>> + ?} else if (SD->getKind() == SDDbgValue::FRAMEIX) { >>>>> + ? ?unsigned FrameIx = SD->getFrameIx(); >>>>> ? ?// Stack address; this needs to be lowered in target-dependent fashion. >>>>> ? ?// FIXME test that the target supports this somehow; if not emit Undef. >>>>> ? ?// Create a pseudo for EmitInstrWithCustomInserter's consumption. >>>>> - ? ?MI = BuildMI(*MF, DL, II).addImm(FrameIx). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>>> - ? ?MBB = TLI->EmitInstrWithCustomInserter(MI, MBB, EM); >>>>> - ? ?InsertPos = MBB->end(); >>>>> - ? ?return; >>>>> + ? ?MIB.addImm(FrameIx).addImm(Offset).addMetadata(MDPtr); >>>>> + ? ?abort(); >>>>> + ? ?TLI->EmitInstrWithCustomInserter(&*MIB, InsertBB, EM); >>>>> + ? ?return 0; >>>>> ?} else { >>>>> ? ?// Insert an Undef so we can see what we dropped. >>>>> - ? ?MI = BuildMI(*MF, DL, II).addReg(0U). >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? addImm(Offset).addMetadata(mdPtr); >>>>> + ? ?MIB.addReg(0U); >>>>> ?} >>>>> - ?MBB->insert(InsertPos, MI); >>>>> + >>>>> + ?MIB.addImm(Offset).addMetadata(MDPtr); >>>>> + ?return &*MIB; >>>>> } >>>>> >>>>> /// EmitNode - Generate machine code for a node and needed dependencies. >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Wed Mar 24 20:38:16 2010 >>>>> @@ -64,7 +64,8 @@ >>>>> ?void AddRegisterOperand(MachineInstr *MI, SDValue Op, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>>> - ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap); >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?bool IsDebug = false); >>>>> >>>>> ?/// AddOperand - Add the specified operand to the specified machine instr. ?II >>>>> ?/// specifies the instruction information for the node, and IIOpNum is the >>>>> @@ -73,7 +74,8 @@ >>>>> ?void AddOperand(MachineInstr *MI, SDValue Op, >>>>> ? ? ? ? ? ? ? ? ?unsigned IIOpNum, >>>>> ? ? ? ? ? ? ? ? ?const TargetInstrDesc *II, >>>>> - ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap); >>>>> + ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ?bool IsDebug = false); >>>>> >>>>> ?/// EmitSubregNode - Generate machine code for subreg nodes. >>>>> ?/// >>>>> @@ -98,16 +100,12 @@ >>>>> ?/// MachineInstr. >>>>> ?static unsigned CountOperands(SDNode *Node); >>>>> >>>>> - ?/// EmitDbgValue - Generate any debug info that refers to this Node. ?Constant >>>>> - ?/// dbg_value is not handled here. >>>>> - ?void EmitDbgValue(SDNode *Node, >>>>> - ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>>> - ? ? ? ? ? ? ? ? ? ?SDDbgValue* sd); >>>>> - >>>>> - >>>>> - ?/// EmitDbgValue - Generate a constant DBG_VALUE. ?No node is involved. >>>>> - ?void EmitDbgValue(SDDbgValue* sd, >>>>> - ? ? ? ? ? ? ? ?DenseMap *EM); >>>>> + ?/// EmitDbgValue - Generate machine instruction for a dbg_value node. >>>>> + ?/// >>>>> + ?MachineInstr *EmitDbgValue(SDDbgValue *SD, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?MachineBasicBlock *InsertBB, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ?DenseMap *EM); >>>>> >>>>> ?/// EmitNode - Generate machine code for a node and needed dependencies. >>>>> ?/// >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SDNodeDbgValue.h Wed Mar 24 20:38:16 2010 >>>>> @@ -47,10 +47,12 @@ >>>>> ?uint64_t Offset; >>>>> ?DebugLoc DL; >>>>> ?unsigned Order; >>>>> + ?bool Invalid; >>>>> public: >>>>> ?// Constructor for non-constants. >>>>> ?SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl, >>>>> - ? ? ? ? ? ? unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O) { >>>>> + ? ? ? ? ? ? unsigned O) : mdPtr(mdP), Offset(off), DL(dl), Order(O), >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? Invalid(false) { >>>>> ? ?kind = SDNODE; >>>>> ? ?u.s.Node = N; >>>>> ? ?u.s.ResNo = R; >>>>> @@ -97,6 +99,12 @@ >>>>> ?// Returns the SDNodeOrder. ?This is the order of the preceding node in the >>>>> ?// input. >>>>> ?unsigned getOrder() { return Order; } >>>>> + >>>>> + ?// setIsInvalidated / isInvalidated - Setter / getter of the "Invalidated" >>>>> + ?// property. A SDDbgValue is invalid if the SDNode that produces the value is >>>>> + ?// deleted. >>>>> + ?void setIsInvalidated() { Invalid = true; } >>>>> + ?bool isInvalidated() { return Invalid; } >>>>> }; >>>>> >>>>> } // end llvm namespace >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Wed Mar 24 20:38:16 2010 >>>>> @@ -23,6 +23,7 @@ >>>>> #include "llvm/Target/TargetSubtarget.h" >>>>> #include "llvm/ADT/DenseMap.h" >>>>> #include "llvm/ADT/SmallPtrSet.h" >>>>> +#include "llvm/ADT/SmallSet.h" >>>>> #include "llvm/ADT/SmallVector.h" >>>>> #include "llvm/ADT/Statistic.h" >>>>> #include "llvm/Support/Debug.h" >>>>> @@ -407,19 +408,67 @@ >>>>> ?} >>>>> } >>>>> >>>>> +namespace { >>>>> + ?struct OrderSorter { >>>>> + ? ?bool operator()(const std::pair &A, >>>>> + ? ? ? ? ? ? ? ? ? ?const std::pair &B) { >>>>> + ? ? ?return A.first < B.first; >>>>> + ? ?} >>>>> + ?}; >>>>> +} >>>>> + >>>>> +// ProcessSourceNode - Process nodes with source order numbers. These are added >>>>> +// to a vector which EmitSchedule use to determine how to insert dbg_value >>>>> +// instructions in the right order. >>>>> +static void ProcessSourceNode(SDNode *N, SelectionDAG *DAG, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? InstrEmitter &Emitter, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap *EM, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? DenseMap &VRBaseMap, >>>>> + ? ? ? ? ? ? ? ? ? ?SmallVector, 32> &Orders, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ? ? SmallSet &Seen) { >>>>> + ?unsigned Order = DAG->GetOrdering(N); >>>>> + ?if (!Order || !Seen.insert(Order)) >>>>> + ? ?return; >>>>> + >>>>> + ?MachineBasicBlock *BB = Emitter.getBlock(); >>>>> + ?if (BB->empty() || BB->back().isPHI()) { >>>>> + ? ?// Did not insert any instruction. >>>>> + ? ?Orders.push_back(std::make_pair(Order, (MachineInstr*)0)); >>>>> + ? ?return; >>>>> + ?} >>>>> + >>>>> + ?Orders.push_back(std::make_pair(Order, &BB->back())); >>>>> + ?if (!N->getHasDebugValue()) >>>>> + ? ?return; >>>>> + ?// Opportunistically insert immediate dbg_value uses, i.e. those with source >>>>> + ?// order number right after the N. >>>>> + ?MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos(); >>>>> + ?SmallVector &DVs = DAG->GetDbgValues(N); >>>>> + ?for (unsigned i = 0, e = DVs.size(); i != e; ++i) { >>>>> + ? ?if (DVs[i]->isInvalidated()) >>>>> + ? ? ?continue; >>>>> + ? ?unsigned DVOrder = DVs[i]->getOrder(); >>>>> + ? ?if (DVOrder == ++Order) { >>>>> + ? ? ?// FIXME: If the source node with next higher order is scheduled before >>>>> + ? ? ?// this could end up generating funky debug info. >>>>> + ? ? ?MachineInstr *DbgMI = Emitter.EmitDbgValue(DVs[i], BB, VRBaseMap, EM); >>>>> + ? ? ?Orders.push_back(std::make_pair(DVOrder, DbgMI)); >>>>> + ? ? ?BB->insert(InsertPos, DbgMI); >>>>> + ? ? ?DVs[i]->setIsInvalidated(); >>>>> + ? ?} >>>>> + ?} >>>>> +} >>>>> + >>>>> + >>>>> /// EmitSchedule - Emit the machine code in scheduled order. >>>>> MachineBasicBlock *ScheduleDAGSDNodes:: >>>>> EmitSchedule(DenseMap *EM) { >>>>> ?InstrEmitter Emitter(BB, InsertPos); >>>>> ?DenseMap VRBaseMap; >>>>> ?DenseMap CopyVRBaseMap; >>>>> - >>>>> - ?// For now, any constant debug info nodes go at the beginning. >>>>> - ?for (SDDbgInfo::ConstDbgIterator I = DAG->DbgConstBegin(), >>>>> - ? ? ? E = DAG->DbgConstEnd(); I!=E; I++) { >>>>> - ? ?Emitter.EmitDbgValue(*I, EM); >>>>> - ? ?delete *I; >>>>> - ?} >>>>> + ?SmallVector, 32> Orders; >>>>> + ?SmallSet Seen; >>>>> + ?bool HasDbg = DAG->hasDebugValues(); >>>>> >>>>> ?for (unsigned i = 0, e = Sequence.size(); i != e; i++) { >>>>> ? ?SUnit *SU = Sequence[i]; >>>>> @@ -442,22 +491,72 @@ >>>>> ? ? ? ? N = N->getFlaggedNode()) >>>>> ? ? ?FlaggedNodes.push_back(N); >>>>> ? ?while (!FlaggedNodes.empty()) { >>>>> + ? ? ?SDNode *N = FlaggedNodes.back(); >>>>> ? ? ?Emitter.EmitNode(FlaggedNodes.back(), SU->OrigNode != SU, SU->isCloned, >>>>> ? ? ? ? ? ? ? ? ? ? ? VRBaseMap, EM); >>>>> - ? ? ?if (FlaggedNodes.back()->getHasDebugValue()) >>>>> - ? ? ? ?if (SDDbgValue *sd = DAG->GetDbgInfo(FlaggedNodes.back())) { >>>>> - ? ? ? ? ?Emitter.EmitDbgValue(FlaggedNodes.back(), VRBaseMap, sd); >>>>> - ? ? ? ? ?delete sd; >>>>> - ? ? ? ?} >>>>> + ? ? ?// Remember the the source order of the inserted instruction. >>>>> + ? ? ?if (HasDbg) >>>>> + ? ? ? ?ProcessSourceNode(N, DAG, Emitter, EM, VRBaseMap, Orders, Seen); >>>>> ? ? ?FlaggedNodes.pop_back(); >>>>> ? ?} >>>>> ? ?Emitter.EmitNode(SU->getNode(), SU->OrigNode != SU, SU->isCloned, >>>>> ? ? ? ? ? ? ? ? ? ? VRBaseMap, EM); >>>>> - ? ?if (SU->getNode()->getHasDebugValue()) >>>>> - ? ? ?if (SDDbgValue *sd = DAG->GetDbgInfo(SU->getNode())) { >>>>> - ? ? ? ?Emitter.EmitDbgValue(SU->getNode(), VRBaseMap, sd); >>>>> - ? ? ? ?delete sd; >>>>> + ? ?// Remember the the source order of the inserted instruction. >>>>> + ? ?if (HasDbg) >>>>> + ? ? ?ProcessSourceNode(SU->getNode(), DAG, Emitter, EM, VRBaseMap, Orders, >>>>> + ? ? ? ? ? ? ? ? ? ? ? ?Seen); >>>>> + ?} >>>>> + >>>>> + ?// Insert all the dbg_value which have not already been inserted in source >>>>> + ?// order sequence. >>>>> + ?if (HasDbg) { >>>>> + ? ?MachineBasicBlock::iterator BBBegin = BB->empty() ? BB->end() : BB->begin(); >>>>> + ? ?while (BBBegin != BB->end() && BBBegin->isPHI()) >>>>> + ? ? ?++BBBegin; >>>>> + >>>>> + ? ?// Sort the source order instructions and use the order to insert debug >>>>> + ? ?// values. >>>>> + ? ?std::sort(Orders.begin(), Orders.end(), OrderSorter()); >>>>> + >>>>> + ? ?SDDbgInfo::DbgIterator DI = DAG->DbgBegin(); >>>>> + ? ?SDDbgInfo::DbgIterator DE = DAG->DbgEnd(); >>>>> + ? ?// Now emit the rest according to source order. >>>>> + ? ?unsigned LastOrder = 0; >>>>> + ? ?MachineInstr *LastMI = 0; >>>>> + ? ?for (unsigned i = 0, e = Orders.size(); i != e && DI != DE; ++i) { >>>>> + ? ? ?unsigned Order = Orders[i].first; >>>>> + ? ? ?MachineInstr *MI = Orders[i].second; >>>>> + ? ? ?// Insert all SDDbgValue's whose order(s) are before "Order". >>>>> + ? ? ?if (!MI) >>>>> + ? ? ? ?continue; >>>>> + ? ? ?MachineBasicBlock *MIBB = MI->getParent(); >>>>> + ? ? ?for (; DI != DE && >>>>> + ? ? ? ? ? ? (*DI)->getOrder() >= LastOrder && (*DI)->getOrder() < Order; ++DI) { >>>>> + ? ? ? ?if ((*DI)->isInvalidated()) >>>>> + ? ? ? ? ?continue; >>>>> + ? ? ? ?MachineInstr *DbgMI = Emitter.EmitDbgValue(*DI, MIBB, VRBaseMap, EM); >>>>> + ? ? ? ?if (!LastOrder) >>>>> + ? ? ? ? ?// Insert to start of the BB (after PHIs). >>>>> + ? ? ? ? ?BB->insert(BBBegin, DbgMI); >>>>> + ? ? ? ?else { >>>>> + ? ? ? ? ?MachineBasicBlock::iterator Pos = MI; >>>>> + ? ? ? ? ?MIBB->insert(llvm::next(Pos), DbgMI); >>>>> + ? ? ? ?} >>>>> ? ? ?} >>>>> + ? ? ?LastOrder = Order; >>>>> + ? ? ?LastMI = MI; >>>>> + ? ?} >>>>> + ? ?// Add trailing DbgValue's before the terminator. FIXME: May want to add >>>>> + ? ?// some of them before one or more conditional branches? >>>>> + ? ?while (DI != DE) { >>>>> + ? ? ?MachineBasicBlock *InsertBB = Emitter.getBlock(); >>>>> + ? ? ?MachineBasicBlock::iterator Pos= Emitter.getBlock()->getFirstTerminator(); >>>>> + ? ? ?if (!(*DI)->isInvalidated()) { >>>>> + ? ? ? ?MachineInstr *DbgMI= Emitter.EmitDbgValue(*DI, InsertBB, VRBaseMap, EM); >>>>> + ? ? ? ?InsertBB->insert(Pos, DbgMI); >>>>> + ? ? ?} >>>>> + ? ? ?++DI; >>>>> + ? ?} >>>>> ?} >>>>> >>>>> ?BB = Emitter.getBlock(); >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed Mar 24 20:38:16 2010 >>>>> @@ -598,8 +598,10 @@ >>>>> ?// Remove the ordering of this node. >>>>> ?Ordering->remove(N); >>>>> >>>>> - ?// And its entry in the debug info table, if any. >>>>> - ?DbgInfo->remove(N); >>>>> + ?// If any of the SDDbgValue nodes refer to this SDNode, invalidate them. >>>>> + ?SmallVector &DbgVals = DbgInfo->getSDDbgValues(N); >>>>> + ?for (unsigned i = 0, e = DbgVals.size(); i != e; ++i) >>>>> + ? ?DbgVals[i]->setIsInvalidated(); >>>>> } >>>>> >>>>> /// RemoveNodeFromCSEMaps - Take the specified node out of the CSE map that >>>>> @@ -811,6 +813,7 @@ >>>>> SelectionDAG::~SelectionDAG() { >>>>> ?allnodes_clear(); >>>>> ?delete Ordering; >>>>> + ?DbgInfo->clear(); >>>>> ?delete DbgInfo; >>>>> } >>>>> >>>>> @@ -5241,24 +5244,12 @@ >>>>> ?return Ordering->getOrder(SD); >>>>> } >>>>> >>>>> -/// AssignDbgInfo - Assign debug info to the SDNode. >>>>> -void SelectionDAG::AssignDbgInfo(SDNode* SD, SDDbgValue* db) { >>>>> - ?assert(SD && "Trying to assign dbg info to a null node!"); >>>>> - ?DbgInfo->add(SD, db); >>>>> - ?SD->setHasDebugValue(true); >>>>> -} >>>>> - >>>>> -/// RememberDbgInfo - Remember debug info which is not assigned to an SDNode. >>>>> -void SelectionDAG::RememberDbgInfo(SDDbgValue* db) { >>>>> - ?DbgInfo->add(db); >>>>> -} >>>>> - >>>>> -/// GetDbgInfo - Get the debug info, if any, for the SDNode. >>>>> -SDDbgValue* SelectionDAG::GetDbgInfo(const SDNode *SD) { >>>>> - ?assert(SD && "Trying to get the order of a null node!"); >>>>> - ?if (SD->getHasDebugValue()) >>>>> - ? ?return DbgInfo->getSDDbgValue(SD); >>>>> - ?return 0; >>>>> +/// AddDbgValue - Add a dbg_value SDNode. If SD is non-null that means the >>>>> +/// value is produced by SD. >>>>> +void SelectionDAG::AddDbgValue(SDDbgValue *DB, SDNode *SD) { >>>>> + ?DbgInfo->add(DB, SD); >>>>> + ?if (SD) >>>>> + ? ?SD->setHasDebugValue(true); >>>>> } >>>>> >>>>> //===----------------------------------------------------------------------===// >>>>> >>>>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99469&r1=99468&r2=99469&view=diff >>>>> ============================================================================== >>>>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >>>>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Mar 24 20:38:16 2010 >>>>> @@ -3825,20 +3825,20 @@ >>>>> ? ?++SDNodeOrder; >>>>> ? ?if (isa(V) || isa(V)) { >>>>> ? ? ?SDDbgValue* dv = new SDDbgValue(Variable, V, Offset, dl, SDNodeOrder); >>>>> - ? ? ?DAG.RememberDbgInfo(dv); >>>>> + ? ? ?DAG.AddDbgValue(dv); >>>>> ? ?} else { >>>>> ? ? ?SDValue &N = NodeMap[V]; >>>>> ? ? ?if (N.getNode()) { >>>>> ? ? ? ?SDDbgValue *dv = new SDDbgValue(Variable, N.getNode(), >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?N.getResNo(), Offset, dl, SDNodeOrder); >>>>> - ? ? ? ?DAG.AssignDbgInfo(N.getNode(), dv); >>>>> + ? ? ? ?DAG.AddDbgValue(dv, N.getNode()); >>>>> ? ? ?} else { >>>>> ? ? ? ?// We may expand this to cover more cases. ?One case where we have no >>>>> ? ? ? ?// data available is an unreferenced parameter; we need this fallback. >>>>> ? ? ? ?SDDbgValue* dv = new SDDbgValue(Variable, >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?UndefValue::get(V->getType()), >>>>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Offset, dl, SDNodeOrder); >>>>> - ? ? ? ?DAG.RememberDbgInfo(dv); >>>>> + ? ? ? ?DAG.AddDbgValue(dv); >>>>> ? ? ?} >>>>> ? ?} >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> llvm-commits mailing list >>>>> llvm-commits at cs.uiuc.edu >>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>>>> >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> > From sabre at nondot.org Mon Mar 29 22:57:00 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 03:57:00 -0000 Subject: [llvm-commits] [llvm] r99870 - in /llvm/trunk: include/llvm/PassManagers.h include/llvm/Support/Timer.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/Support/Timer.cpp lib/VMCore/PassManager.cpp Message-ID: <20100330035700.7584A2A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 22:57:00 2010 New Revision: 99870 URL: http://llvm.org/viewvc/llvm-project?rev=99870&view=rev Log: revert r99862 which is causing FNT failures. Modified: llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/Support/Timer.cpp llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/include/llvm/PassManagers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassManagers.h (original) +++ llvm/trunk/include/llvm/PassManagers.h Mon Mar 29 22:57:00 2010 @@ -413,6 +413,7 @@ /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. + class FPPassManager : public ModulePass, public PMDataManager { public: static char ID; @@ -461,7 +462,8 @@ } }; -Timer *getPassTimer(Pass *); +extern Timer *StartPassTimer(Pass *); +extern void StopPassTimer(Pass *, Timer *); } Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 22:57:00 2010 @@ -16,62 +16,15 @@ #define LLVM_SUPPORT_TIMER_H #include "llvm/System/DataTypes.h" -#include #include #include -#include +#include namespace llvm { -class Timer; class TimerGroup; class raw_ostream; -class TimeRecord { - double WallTime; // Wall clock time elapsed in seconds - double UserTime; // User time elapsed - double SystemTime; // System time elapsed - ssize_t MemUsed; // Memory allocated (in bytes) -public: - TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {} - - /// getCurrentTime - Get the current time and memory usage. If Start is true - /// we get the memory usage before the time, otherwise we get time before - /// memory usage. This matters if the time to get the memory usage is - /// significant and shouldn't be counted as part of a duration. - static TimeRecord getCurrentTime(bool Start = true); - - double getProcessTime() const { return UserTime+SystemTime; } - double getUserTime() const { return UserTime; } - double getSystemTime() const { return SystemTime; } - double getWallTime() const { return WallTime; } - ssize_t getMemUsed() const { return MemUsed; } - - - // operator< - Allow sorting. - bool operator<(const TimeRecord &T) const { - // Sort by Wall Time elapsed, as it is the only thing really accurate - return WallTime < T.WallTime; - } - - void operator+=(const TimeRecord &RHS) { - WallTime += RHS.WallTime; - UserTime += RHS.UserTime; - SystemTime += RHS.SystemTime; - MemUsed += RHS.MemUsed; - } - void operator-=(const TimeRecord &RHS) { - WallTime -= RHS.WallTime; - UserTime -= RHS.UserTime; - SystemTime -= RHS.SystemTime; - MemUsed -= RHS.MemUsed; - } - - /// print - Print the current timer to standard error, and reset the "Started" - /// flag. - void print(const TimeRecord &Total, raw_ostream &OS) const; -}; - /// Timer - This class is used to track the amount of time spent between /// invocations of its startTimer()/stopTimer() methods. Given appropriate OS /// support it can also keep track of the RSS of the program at various points. @@ -81,30 +34,35 @@ /// if they are never started. /// class Timer { - TimeRecord Time; + double Elapsed; // Wall clock time elapsed in seconds + double UserTime; // User time elapsed + double SystemTime; // System time elapsed + ssize_t MemUsed; // Memory allocated (in bytes) std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. public: - explicit Timer(const std::string &N) : TG(0) { init(N); } - Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); } - Timer(const Timer &RHS) : TG(0) { - assert(RHS.TG == 0 && "Can only copy uninitialized timers"); - } - const Timer &operator=(const Timer &T) { - assert(TG == 0 && T.TG == 0 && "Can only assign uninit timers"); - return *this; - } + explicit Timer(const std::string &N); + Timer(const std::string &N, TimerGroup &tg); + Timer(const Timer &T); ~Timer(); - // Create an uninitialized timer, client must use 'init'. - explicit Timer() : TG(0) {} - void init(const std::string &N); - void init(const std::string &N, TimerGroup &tg); - - const std::string &getName() const { return Name; } - bool isInitialized() const { return TG != 0; } +private: + double getProcessTime() const { return UserTime+SystemTime; } + double getWallTime() const { return Elapsed; } + ssize_t getMemUsed() const { return MemUsed; } +public: + std::string getName() const { return Name; } + + const Timer &operator=(const Timer &T); + // operator< - Allow sorting. + bool operator<(const Timer &T) const { + // Sort by Wall Time elapsed, as it is the only thing really accurate + return Elapsed < T.Elapsed; + } + bool operator>(const Timer &T) const { return T.operator<(*this); } + /// startTimer - Start the timer running. Time between calls to /// startTimer/stopTimer is counted by the Timer class. Note that these calls /// must be correctly paired. @@ -115,8 +73,19 @@ /// void stopTimer(); + /// print - Print the current timer to standard error, and reset the "Started" + /// flag. + void print(const Timer &Total, raw_ostream &OS); + private: friend class TimerGroup; + + // Copy ctor, initialize with no TG member. + Timer(bool, const Timer &T); + + /// sum - Add the time accumulated in the specified timer into this timer. + /// + void sum(const Timer &T); }; @@ -163,13 +132,9 @@ class TimerGroup { std::string Name; unsigned NumTimers; - std::vector > TimersToPrint; + std::vector TimersToPrint; public: explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {} - explicit TimerGroup() : NumTimers(0) {} - - void setName(const std::string &name) { Name = name; } - ~TimerGroup() { assert(NumTimers == 0 && "TimerGroup destroyed before all contained timers!"); @@ -179,7 +144,7 @@ friend class Timer; void addTimer(); void removeTimer(); - void addTimerToPrint(const TimeRecord &T, const std::string &Name); + void addTimerToPrint(const Timer &T); }; } // End llvm namespace Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Mon Mar 29 22:57:00 2010 @@ -17,13 +17,12 @@ #define DEBUG_TYPE "cgscc-passmgr" #include "llvm/CallGraphSCCPass.h" -#include "llvm/IntrinsicInst.h" -#include "llvm/Function.h" -#include "llvm/PassManagers.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/ADT/SCCIterator.h" +#include "llvm/PassManagers.h" +#include "llvm/Function.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Timer.h" +#include "llvm/IntrinsicInst.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -103,10 +102,9 @@ CallGraphUpToDate = true; } - { - TimeRegion PassTimer(getPassTimer(CGSP)); - Changed = CGSP->runOnSCC(CurSCC); - } + Timer *T = StartPassTimer(CGSP); + Changed = CGSP->runOnSCC(CurSCC); + StopPassTimer(CGSP, T); // After the CGSCCPass is done, when assertions are enabled, use // RefreshCallGraph to verify that the callgraph was correctly updated. @@ -127,8 +125,9 @@ for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) { if (Function *F = CurSCC[i]->getFunction()) { dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName()); - TimeRegion PassTimer(getPassTimer(FPP)); + Timer *T = StartPassTimer(FPP); Changed |= FPP->runOnFunction(*F); + StopPassTimer(FPP, T); } } Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Mon Mar 29 22:57:00 2010 @@ -14,7 +14,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" -#include "llvm/Support/Timer.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -229,9 +228,9 @@ { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); - TimeRegion PassTimer(getPassTimer(P)); - + Timer *T = StartPassTimer(P); Changed |= P->runOnLoop(CurrentLoop, *this); + StopPassTimer(P, T); } if (Changed) @@ -246,10 +245,9 @@ // is a function pass and it's really expensive to verify every // loop in the function every time. That level of checking can be // enabled with the -verify-loop-info option. - { - TimeRegion PassTimer(getPassTimer(LI)); - CurrentLoop->verifyLoop(); - } + Timer *T = StartPassTimer(LI); + CurrentLoop->verifyLoop(); + StopPassTimer(LI, T); // Then call the regular verifyAnalysis functions. verifyPreservedAnalysis(P); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 22:57:00 2010 @@ -19,7 +19,6 @@ #include "llvm/Support/Format.h" #include "llvm/System/Mutex.h" #include "llvm/System/Process.h" -#include "llvm/ADT/StringMap.h" #include using namespace llvm; @@ -96,28 +95,37 @@ // Timer Implementation //===----------------------------------------------------------------------===// -void Timer::init(const std::string &N) { - assert(TG == 0 && "Timer already initialized"); - Name = N; - Started = false; - TG = getDefaultTimerGroup(); +Timer::Timer(const std::string &N) + : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), + Started(false), TG(getDefaultTimerGroup()) { TG->addTimer(); } -void Timer::init(const std::string &N, TimerGroup &tg) { - assert(TG == 0 && "Timer already initialized"); - Name = N; - Started = false; - TG = &tg; +Timer::Timer(const std::string &N, TimerGroup &tg) + : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), + Started(false), TG(&tg) { TG->addTimer(); } +Timer::Timer(const Timer &T) { + TG = T.TG; + if (TG) TG->addTimer(); + operator=(T); +} + +// Copy ctor, initialize with no TG member. +Timer::Timer(bool, const Timer &T) { + TG = T.TG; // Avoid assertion in operator= + operator=(T); // Copy contents + TG = 0; +} + Timer::~Timer() { - if (!TG) return; // Never initialized. + if (!TG) return; if (Started) { Started = false; - TG->addTimerToPrint(Time, Name); + TG->addTimerToPrint(*this); } TG->removeTimer(); } @@ -128,7 +136,12 @@ return 0; } -TimeRecord TimeRecord::getCurrentTime(bool Start) { +struct TimeRecord { + double Elapsed, UserTime, SystemTime; + ssize_t MemUsed; +}; + +static TimeRecord getTimeRecord(bool Start) { TimeRecord Result; sys::TimeValue now(0,0); @@ -144,9 +157,9 @@ MemUsed = getMemUsage(); } - Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; + Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; Result.MemUsed = MemUsed; return Result; } @@ -156,11 +169,19 @@ void Timer::startTimer() { Started = true; ActiveTimers->push_back(this); - Time -= TimeRecord::getCurrentTime(true); + TimeRecord TR = getTimeRecord(true); + Elapsed -= TR.Elapsed; + UserTime -= TR.UserTime; + SystemTime -= TR.SystemTime; + MemUsed -= TR.MemUsed; } void Timer::stopTimer() { - Time += TimeRecord::getCurrentTime(false); + TimeRecord TR = getTimeRecord(false); + Elapsed += TR.Elapsed; + UserTime += TR.UserTime; + SystemTime += TR.SystemTime; + MemUsed += TR.MemUsed; if (ActiveTimers->back() == this) { ActiveTimers->pop_back(); @@ -172,6 +193,25 @@ } } +void Timer::sum(const Timer &T) { + Elapsed += T.Elapsed; + UserTime += T.UserTime; + SystemTime += T.SystemTime; + MemUsed += T.MemUsed; +} + +const Timer &Timer::operator=(const Timer &T) { + Elapsed = T.Elapsed; + UserTime = T.UserTime; + SystemTime = T.SystemTime; + MemUsed = T.MemUsed; + Name = T.Name; + Started = T.Started; + assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); + return *this; +} + + static void printVal(double Val, double Total, raw_ostream &OS) { if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; @@ -181,19 +221,23 @@ } } -void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { - if (Total.getUserTime()) - printVal(getUserTime(), Total.getUserTime(), OS); - if (Total.getSystemTime()) - printVal(getSystemTime(), Total.getSystemTime(), OS); +void Timer::print(const Timer &Total, raw_ostream &OS) { + if (Total.UserTime) + printVal(UserTime, Total.UserTime, OS); + if (Total.SystemTime) + printVal(SystemTime, Total.SystemTime, OS); if (Total.getProcessTime()) printVal(getProcessTime(), Total.getProcessTime(), OS); - printVal(getWallTime(), Total.getWallTime(), OS); + printVal(Elapsed, Total.Elapsed, OS); OS << " "; - if (Total.getMemUsed()) - OS << format("%9lld", (long long)getMemUsed()) << " "; + if (Total.MemUsed) + OS << format("%9lld", (long long)MemUsed) << " "; + + OS << Name << "\n"; + + Started = false; // Once printed, don't print again } @@ -201,35 +245,40 @@ // NamedRegionTimer Implementation //===----------------------------------------------------------------------===// -typedef StringMap Name2TimerMap; -typedef StringMap > Name2PairMap; +typedef std::map Name2Timer; +typedef std::map > Name2Pair; -static ManagedStatic NamedTimers; -static ManagedStatic NamedGroupedTimers; +static ManagedStatic NamedTimers; +static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { sys::SmartScopedLock L(*TimerLock); - - Timer &T = (*NamedTimers)[Name]; - if (!T.isInitialized()) - T.init(Name); - return T; + Name2Timer::iterator I = NamedTimers->find(Name); + if (I != NamedTimers->end()) + return I->second; + + return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second; } static Timer &getNamedRegionTimer(const std::string &Name, const std::string &GroupName) { sys::SmartScopedLock L(*TimerLock); - std::pair &GroupEntry = - (*NamedGroupedTimers)[GroupName]; + Name2Pair::iterator I = NamedGroupedTimers->find(GroupName); + if (I == NamedGroupedTimers->end()) { + TimerGroup TG(GroupName); + std::pair Pair(TG, Name2Timer()); + I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair)); + } - if (GroupEntry.second.empty()) - GroupEntry.first.setName(GroupName); + Name2Timer::iterator J = I->second.second.find(Name); + if (J == I->second.second.end()) + J = I->second.second.insert(J, + std::make_pair(Name, + Timer(Name, + I->second.first))); - Timer &T = GroupEntry.second[Name]; - if (!T.isInitialized()) - T.init(Name); - return T; + return J->second; } NamedRegionTimer::NamedRegionTimer(const std::string &Name) @@ -249,7 +298,8 @@ return; // Don't print timing report. // Sort the timers in descending order by amount of time taken. - std::sort(TimersToPrint.begin(), TimersToPrint.end()); + std::sort(TimersToPrint.begin(), TimersToPrint.end(), + std::greater()); // Figure out how many spaces to indent TimerGroup name. unsigned Padding = (80-Name.length())/2; @@ -257,46 +307,50 @@ raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - TimeRecord Total; - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - Total += TimersToPrint[i].first; - - // Print out timing header. - *OutStream << "===" << std::string(73, '-') << "===\n"; - OutStream->indent(Padding) << Name << '\n'; - *OutStream << "===" << std::string(73, '-') << "===\n"; - - // If this is not an collection of ungrouped times, print the total time. - // Ungrouped timers don't really make sense to add up. We still print the - // TOTAL line to make the percentages make sense. - if (this != DefaultTimerGroup) { - *OutStream << " Total Execution Time: "; - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; - *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; - } - *OutStream << "\n"; - - if (Total.getUserTime()) - *OutStream << " ---User Time---"; - if (Total.getSystemTime()) - *OutStream << " --System Time--"; - if (Total.getProcessTime()) - *OutStream << " --User+System--"; - *OutStream << " ---Wall Time---"; - if (Total.getMemUsed()) - *OutStream << " ---Mem---"; - *OutStream << " --- Name ---\n"; - - // Loop through all of the timing data, printing it out. - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) { - const std::pair &Entry = TimersToPrint[e-i-1]; - Entry.first.print(Total, *OutStream); - *OutStream << Entry.second << '\n'; + ++NumTimers; + { // Scope to contain Total timer: don't allow total timer to drop us to + // zero timers. + Timer Total("TOTAL"); + + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + Total.sum(TimersToPrint[i]); + + // Print out timing header. + *OutStream << "===" << std::string(73, '-') << "===\n" + << std::string(Padding, ' ') << Name << "\n" + << "===" << std::string(73, '-') + << "===\n"; + + // If this is not an collection of ungrouped times, print the total time. + // Ungrouped timers don't really make sense to add up. We still print the + // TOTAL line to make the percentages make sense. + if (this != DefaultTimerGroup) { + *OutStream << " Total Execution Time: "; + *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; + *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; + } + *OutStream << "\n"; + + if (Total.UserTime) + *OutStream << " ---User Time---"; + if (Total.SystemTime) + *OutStream << " --System Time--"; + if (Total.getProcessTime()) + *OutStream << " --User+System--"; + *OutStream << " ---Wall Time---"; + if (Total.getMemUsed()) + *OutStream << " ---Mem---"; + *OutStream << " --- Name ---\n"; + + // Loop through all of the timing data, printing it out. + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + TimersToPrint[i].print(Total, *OutStream); + + Total.print(Total, *OutStream); + *OutStream << '\n'; + OutStream->flush(); } - - Total.print(Total, *OutStream); - *OutStream << "Total\n\n"; - OutStream->flush(); + --NumTimers; TimersToPrint.clear(); @@ -309,8 +363,8 @@ ++NumTimers; } -void TimerGroup::addTimerToPrint(const TimeRecord &T, const std::string &Name) { +void TimerGroup::addTimerToPrint(const Timer &T) { sys::SmartScopedLock L(*TimerLock); - TimersToPrint.push_back(std::make_pair(T, Name)); + TimersToPrint.push_back(Timer(true, T)); } Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=99870&r1=99869&r2=99870&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Mar 29 22:57:00 2010 @@ -378,7 +378,7 @@ static ManagedStatic > TimingInfoMutex; class TimingInfo { - DenseMap TimingData; + std::map TimingData; TimerGroup TG; public: @@ -397,16 +397,19 @@ // null. It may be called multiple times. static void createTheTimeInfo(); - /// getPassTimer - Return the timer for the specified pass if it exists. - Timer *getPassTimer(Pass *P) { + /// passStarted - This method creates a timer for the given pass if it doesn't + /// already have one, and starts the timer. + Timer *passStarted(Pass *P) { if (P->getAsPMDataManager()) return 0; sys::SmartScopedLock Lock(*TimingInfoMutex); - Timer &T = TimingData[P]; - if (!T.isInitialized()) - T.init(P->getPassName(), TG); - return &T; + std::map::iterator I = TimingData.find(P); + if (I == TimingData.end()) + I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; + Timer *T = &I->second; + T->startTimer(); + return T; } }; @@ -701,8 +704,11 @@ E = PreservedSet.end(); I != E; ++I) { AnalysisID AID = *I; if (Pass *AP = findAnalysisPass(AID, true)) { - TimeRegion PassTimer(getPassTimer(AP)); + + Timer *T = 0; + if (TheTimeInfo) T = TheTimeInfo->passStarted(AP); AP->verifyAnalysis(); + if (T) T->stopTimer(); } } } @@ -786,9 +792,10 @@ { // If the pass crashes releasing memory, remember this. PassManagerPrettyStackEntry X(P); - TimeRegion PassTimer(getPassTimer(P)); - + + Timer *T = StartPassTimer(P); P->releaseMemory(); + StopPassTimer(P, T); } if (const PassInfo *PI = P->getPassInfo()) { @@ -1121,9 +1128,10 @@ { // If the pass crashes, remember this. PassManagerPrettyStackEntry X(BP, *I); - TimeRegion PassTimer(getPassTimer(BP)); - + + Timer *T = StartPassTimer(BP); LocalChanged |= BP->runOnBasicBlock(*I); + StopPassTimer(BP, T); } Changed |= LocalChanged; @@ -1337,9 +1345,10 @@ { PassManagerPrettyStackEntry X(FP, F); - TimeRegion PassTimer(getPassTimer(FP)); + Timer *T = StartPassTimer(FP); LocalChanged |= FP->runOnFunction(F); + StopPassTimer(FP, T); } Changed |= LocalChanged; @@ -1411,9 +1420,9 @@ { PassManagerPrettyStackEntry X(MP, M); - TimeRegion PassTimer(getPassTimer(MP)); - + Timer *T = StartPassTimer(MP); LocalChanged |= MP->runOnModule(M); + StopPassTimer(MP, T); } Changed |= LocalChanged; @@ -1550,12 +1559,17 @@ } /// If TimingInfo is enabled then start pass timer. -Timer *llvm::getPassTimer(Pass *P) { +Timer *llvm::StartPassTimer(Pass *P) { if (TheTimeInfo) - return TheTimeInfo->getPassTimer(P); + return TheTimeInfo->passStarted(P); return 0; } +/// If TimingInfo is enabled then stop pass timer. +void llvm::StopPassTimer(Pass *P, Timer *T) { + if (T) T->stopTimer(); +} + //===----------------------------------------------------------------------===// // PMStack implementation // From sabre at nondot.org Mon Mar 29 23:03:22 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 04:03:22 -0000 Subject: [llvm-commits] [llvm] r99871 - in /llvm/trunk: include/llvm/PassManagers.h include/llvm/Support/Timer.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/Support/Timer.cpp lib/VMCore/PassManager.cpp Message-ID: <20100330040322.7F7B32A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 23:03:22 2010 New Revision: 99871 URL: http://llvm.org/viewvc/llvm-project?rev=99871&view=rev Log: reapply my timer rewrite with a change for PassManager to store timers by pointer instead of by-value. Modified: llvm/trunk/include/llvm/PassManagers.h llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/Support/Timer.cpp llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/include/llvm/PassManagers.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/PassManagers.h?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/include/llvm/PassManagers.h (original) +++ llvm/trunk/include/llvm/PassManagers.h Mon Mar 29 23:03:22 2010 @@ -413,7 +413,6 @@ /// It batches all function passes and basic block pass managers together and /// sequence them to process one function at a time before processing next /// function. - class FPPassManager : public ModulePass, public PMDataManager { public: static char ID; @@ -462,8 +461,7 @@ } }; -extern Timer *StartPassTimer(Pass *); -extern void StopPassTimer(Pass *, Timer *); +Timer *getPassTimer(Pass *); } Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 23:03:22 2010 @@ -16,15 +16,62 @@ #define LLVM_SUPPORT_TIMER_H #include "llvm/System/DataTypes.h" +#include #include #include -#include +#include namespace llvm { +class Timer; class TimerGroup; class raw_ostream; +class TimeRecord { + double WallTime; // Wall clock time elapsed in seconds + double UserTime; // User time elapsed + double SystemTime; // System time elapsed + ssize_t MemUsed; // Memory allocated (in bytes) +public: + TimeRecord() : WallTime(0), UserTime(0), SystemTime(0), MemUsed(0) {} + + /// getCurrentTime - Get the current time and memory usage. If Start is true + /// we get the memory usage before the time, otherwise we get time before + /// memory usage. This matters if the time to get the memory usage is + /// significant and shouldn't be counted as part of a duration. + static TimeRecord getCurrentTime(bool Start = true); + + double getProcessTime() const { return UserTime+SystemTime; } + double getUserTime() const { return UserTime; } + double getSystemTime() const { return SystemTime; } + double getWallTime() const { return WallTime; } + ssize_t getMemUsed() const { return MemUsed; } + + + // operator< - Allow sorting. + bool operator<(const TimeRecord &T) const { + // Sort by Wall Time elapsed, as it is the only thing really accurate + return WallTime < T.WallTime; + } + + void operator+=(const TimeRecord &RHS) { + WallTime += RHS.WallTime; + UserTime += RHS.UserTime; + SystemTime += RHS.SystemTime; + MemUsed += RHS.MemUsed; + } + void operator-=(const TimeRecord &RHS) { + WallTime -= RHS.WallTime; + UserTime -= RHS.UserTime; + SystemTime -= RHS.SystemTime; + MemUsed -= RHS.MemUsed; + } + + /// print - Print the current timer to standard error, and reset the "Started" + /// flag. + void print(const TimeRecord &Total, raw_ostream &OS) const; +}; + /// Timer - This class is used to track the amount of time spent between /// invocations of its startTimer()/stopTimer() methods. Given appropriate OS /// support it can also keep track of the RSS of the program at various points. @@ -34,35 +81,30 @@ /// if they are never started. /// class Timer { - double Elapsed; // Wall clock time elapsed in seconds - double UserTime; // User time elapsed - double SystemTime; // System time elapsed - ssize_t MemUsed; // Memory allocated (in bytes) + TimeRecord Time; std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. public: - explicit Timer(const std::string &N); - Timer(const std::string &N, TimerGroup &tg); - Timer(const Timer &T); + explicit Timer(const std::string &N) : TG(0) { init(N); } + Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); } + Timer(const Timer &RHS) : TG(0) { + assert(RHS.TG == 0 && "Can only copy uninitialized timers"); + } + const Timer &operator=(const Timer &T) { + assert(TG == 0 && T.TG == 0 && "Can only assign uninit timers"); + return *this; + } ~Timer(); -private: - double getProcessTime() const { return UserTime+SystemTime; } - double getWallTime() const { return Elapsed; } - ssize_t getMemUsed() const { return MemUsed; } -public: - std::string getName() const { return Name; } - - const Timer &operator=(const Timer &T); + // Create an uninitialized timer, client must use 'init'. + explicit Timer() : TG(0) {} + void init(const std::string &N); + void init(const std::string &N, TimerGroup &tg); + + const std::string &getName() const { return Name; } + bool isInitialized() const { return TG != 0; } - // operator< - Allow sorting. - bool operator<(const Timer &T) const { - // Sort by Wall Time elapsed, as it is the only thing really accurate - return Elapsed < T.Elapsed; - } - bool operator>(const Timer &T) const { return T.operator<(*this); } - /// startTimer - Start the timer running. Time between calls to /// startTimer/stopTimer is counted by the Timer class. Note that these calls /// must be correctly paired. @@ -73,19 +115,8 @@ /// void stopTimer(); - /// print - Print the current timer to standard error, and reset the "Started" - /// flag. - void print(const Timer &Total, raw_ostream &OS); - private: friend class TimerGroup; - - // Copy ctor, initialize with no TG member. - Timer(bool, const Timer &T); - - /// sum - Add the time accumulated in the specified timer into this timer. - /// - void sum(const Timer &T); }; @@ -132,9 +163,13 @@ class TimerGroup { std::string Name; unsigned NumTimers; - std::vector TimersToPrint; + std::vector > TimersToPrint; public: explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {} + explicit TimerGroup() : NumTimers(0) {} + + void setName(const std::string &name) { Name = name; } + ~TimerGroup() { assert(NumTimers == 0 && "TimerGroup destroyed before all contained timers!"); @@ -144,7 +179,7 @@ friend class Timer; void addTimer(); void removeTimer(); - void addTimerToPrint(const Timer &T); + void addTimerToPrint(const TimeRecord &T, const std::string &Name); }; } // End llvm namespace Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Mon Mar 29 23:03:22 2010 @@ -17,12 +17,13 @@ #define DEBUG_TYPE "cgscc-passmgr" #include "llvm/CallGraphSCCPass.h" +#include "llvm/IntrinsicInst.h" +#include "llvm/Function.h" +#include "llvm/PassManagers.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/ADT/SCCIterator.h" -#include "llvm/PassManagers.h" -#include "llvm/Function.h" #include "llvm/Support/Debug.h" -#include "llvm/IntrinsicInst.h" +#include "llvm/Support/Timer.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -102,9 +103,10 @@ CallGraphUpToDate = true; } - Timer *T = StartPassTimer(CGSP); - Changed = CGSP->runOnSCC(CurSCC); - StopPassTimer(CGSP, T); + { + TimeRegion PassTimer(getPassTimer(CGSP)); + Changed = CGSP->runOnSCC(CurSCC); + } // After the CGSCCPass is done, when assertions are enabled, use // RefreshCallGraph to verify that the callgraph was correctly updated. @@ -125,9 +127,8 @@ for (unsigned i = 0, e = CurSCC.size(); i != e; ++i) { if (Function *F = CurSCC[i]->getFunction()) { dumpPassInfo(P, EXECUTION_MSG, ON_FUNCTION_MSG, F->getName()); - Timer *T = StartPassTimer(FPP); + TimeRegion PassTimer(getPassTimer(FPP)); Changed |= FPP->runOnFunction(*F); - StopPassTimer(FPP, T); } } Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Mon Mar 29 23:03:22 2010 @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" +#include "llvm/Support/Timer.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -228,9 +229,9 @@ { PassManagerPrettyStackEntry X(P, *CurrentLoop->getHeader()); - Timer *T = StartPassTimer(P); + TimeRegion PassTimer(getPassTimer(P)); + Changed |= P->runOnLoop(CurrentLoop, *this); - StopPassTimer(P, T); } if (Changed) @@ -245,9 +246,10 @@ // is a function pass and it's really expensive to verify every // loop in the function every time. That level of checking can be // enabled with the -verify-loop-info option. - Timer *T = StartPassTimer(LI); - CurrentLoop->verifyLoop(); - StopPassTimer(LI, T); + { + TimeRegion PassTimer(getPassTimer(LI)); + CurrentLoop->verifyLoop(); + } // Then call the regular verifyAnalysis functions. verifyPreservedAnalysis(P); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 23:03:22 2010 @@ -19,6 +19,7 @@ #include "llvm/Support/Format.h" #include "llvm/System/Mutex.h" #include "llvm/System/Process.h" +#include "llvm/ADT/StringMap.h" #include using namespace llvm; @@ -95,37 +96,28 @@ // Timer Implementation //===----------------------------------------------------------------------===// -Timer::Timer(const std::string &N) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), - Started(false), TG(getDefaultTimerGroup()) { +void Timer::init(const std::string &N) { + assert(TG == 0 && "Timer already initialized"); + Name = N; + Started = false; + TG = getDefaultTimerGroup(); TG->addTimer(); } -Timer::Timer(const std::string &N, TimerGroup &tg) - : Elapsed(0), UserTime(0), SystemTime(0), MemUsed(0), Name(N), - Started(false), TG(&tg) { +void Timer::init(const std::string &N, TimerGroup &tg) { + assert(TG == 0 && "Timer already initialized"); + Name = N; + Started = false; + TG = &tg; TG->addTimer(); } -Timer::Timer(const Timer &T) { - TG = T.TG; - if (TG) TG->addTimer(); - operator=(T); -} - -// Copy ctor, initialize with no TG member. -Timer::Timer(bool, const Timer &T) { - TG = T.TG; // Avoid assertion in operator= - operator=(T); // Copy contents - TG = 0; -} - Timer::~Timer() { - if (!TG) return; + if (!TG) return; // Never initialized. if (Started) { Started = false; - TG->addTimerToPrint(*this); + TG->addTimerToPrint(Time, Name); } TG->removeTimer(); } @@ -136,12 +128,7 @@ return 0; } -struct TimeRecord { - double Elapsed, UserTime, SystemTime; - ssize_t MemUsed; -}; - -static TimeRecord getTimeRecord(bool Start) { +TimeRecord TimeRecord::getCurrentTime(bool Start) { TimeRecord Result; sys::TimeValue now(0,0); @@ -157,9 +144,9 @@ MemUsed = getMemUsage(); } - Result.Elapsed = now.seconds() + now.microseconds() / 1000000.0; + Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; - Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; + Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; Result.MemUsed = MemUsed; return Result; } @@ -169,19 +156,11 @@ void Timer::startTimer() { Started = true; ActiveTimers->push_back(this); - TimeRecord TR = getTimeRecord(true); - Elapsed -= TR.Elapsed; - UserTime -= TR.UserTime; - SystemTime -= TR.SystemTime; - MemUsed -= TR.MemUsed; + Time -= TimeRecord::getCurrentTime(true); } void Timer::stopTimer() { - TimeRecord TR = getTimeRecord(false); - Elapsed += TR.Elapsed; - UserTime += TR.UserTime; - SystemTime += TR.SystemTime; - MemUsed += TR.MemUsed; + Time += TimeRecord::getCurrentTime(false); if (ActiveTimers->back() == this) { ActiveTimers->pop_back(); @@ -193,25 +172,6 @@ } } -void Timer::sum(const Timer &T) { - Elapsed += T.Elapsed; - UserTime += T.UserTime; - SystemTime += T.SystemTime; - MemUsed += T.MemUsed; -} - -const Timer &Timer::operator=(const Timer &T) { - Elapsed = T.Elapsed; - UserTime = T.UserTime; - SystemTime = T.SystemTime; - MemUsed = T.MemUsed; - Name = T.Name; - Started = T.Started; - assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); - return *this; -} - - static void printVal(double Val, double Total, raw_ostream &OS) { if (Total < 1e-7) // Avoid dividing by zero. OS << " ----- "; @@ -221,23 +181,19 @@ } } -void Timer::print(const Timer &Total, raw_ostream &OS) { - if (Total.UserTime) - printVal(UserTime, Total.UserTime, OS); - if (Total.SystemTime) - printVal(SystemTime, Total.SystemTime, OS); +void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { + if (Total.getUserTime()) + printVal(getUserTime(), Total.getUserTime(), OS); + if (Total.getSystemTime()) + printVal(getSystemTime(), Total.getSystemTime(), OS); if (Total.getProcessTime()) printVal(getProcessTime(), Total.getProcessTime(), OS); - printVal(Elapsed, Total.Elapsed, OS); + printVal(getWallTime(), Total.getWallTime(), OS); OS << " "; - if (Total.MemUsed) - OS << format("%9lld", (long long)MemUsed) << " "; - - OS << Name << "\n"; - - Started = false; // Once printed, don't print again + if (Total.getMemUsed()) + OS << format("%9lld", (long long)getMemUsed()) << " "; } @@ -245,40 +201,35 @@ // NamedRegionTimer Implementation //===----------------------------------------------------------------------===// -typedef std::map Name2Timer; -typedef std::map > Name2Pair; +typedef StringMap Name2TimerMap; +typedef StringMap > Name2PairMap; -static ManagedStatic NamedTimers; -static ManagedStatic NamedGroupedTimers; +static ManagedStatic NamedTimers; +static ManagedStatic NamedGroupedTimers; static Timer &getNamedRegionTimer(const std::string &Name) { sys::SmartScopedLock L(*TimerLock); - Name2Timer::iterator I = NamedTimers->find(Name); - if (I != NamedTimers->end()) - return I->second; - - return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second; + + Timer &T = (*NamedTimers)[Name]; + if (!T.isInitialized()) + T.init(Name); + return T; } static Timer &getNamedRegionTimer(const std::string &Name, const std::string &GroupName) { sys::SmartScopedLock L(*TimerLock); - Name2Pair::iterator I = NamedGroupedTimers->find(GroupName); - if (I == NamedGroupedTimers->end()) { - TimerGroup TG(GroupName); - std::pair Pair(TG, Name2Timer()); - I = NamedGroupedTimers->insert(I, std::make_pair(GroupName, Pair)); - } + std::pair &GroupEntry = + (*NamedGroupedTimers)[GroupName]; - Name2Timer::iterator J = I->second.second.find(Name); - if (J == I->second.second.end()) - J = I->second.second.insert(J, - std::make_pair(Name, - Timer(Name, - I->second.first))); + if (GroupEntry.second.empty()) + GroupEntry.first.setName(GroupName); - return J->second; + Timer &T = GroupEntry.second[Name]; + if (!T.isInitialized()) + T.init(Name); + return T; } NamedRegionTimer::NamedRegionTimer(const std::string &Name) @@ -298,8 +249,7 @@ return; // Don't print timing report. // Sort the timers in descending order by amount of time taken. - std::sort(TimersToPrint.begin(), TimersToPrint.end(), - std::greater()); + std::sort(TimersToPrint.begin(), TimersToPrint.end()); // Figure out how many spaces to indent TimerGroup name. unsigned Padding = (80-Name.length())/2; @@ -307,50 +257,46 @@ raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - ++NumTimers; - { // Scope to contain Total timer: don't allow total timer to drop us to - // zero timers. - Timer Total("TOTAL"); - - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - Total.sum(TimersToPrint[i]); - - // Print out timing header. - *OutStream << "===" << std::string(73, '-') << "===\n" - << std::string(Padding, ' ') << Name << "\n" - << "===" << std::string(73, '-') - << "===\n"; - - // If this is not an collection of ungrouped times, print the total time. - // Ungrouped timers don't really make sense to add up. We still print the - // TOTAL line to make the percentages make sense. - if (this != DefaultTimerGroup) { - *OutStream << " Total Execution Time: "; - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; - *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; - } - *OutStream << "\n"; - - if (Total.UserTime) - *OutStream << " ---User Time---"; - if (Total.SystemTime) - *OutStream << " --System Time--"; - if (Total.getProcessTime()) - *OutStream << " --User+System--"; - *OutStream << " ---Wall Time---"; - if (Total.getMemUsed()) - *OutStream << " ---Mem---"; - *OutStream << " --- Name ---\n"; - - // Loop through all of the timing data, printing it out. - for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) - TimersToPrint[i].print(Total, *OutStream); - - Total.print(Total, *OutStream); - *OutStream << '\n'; - OutStream->flush(); + TimeRecord Total; + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) + Total += TimersToPrint[i].first; + + // Print out timing header. + *OutStream << "===" << std::string(73, '-') << "===\n"; + OutStream->indent(Padding) << Name << '\n'; + *OutStream << "===" << std::string(73, '-') << "===\n"; + + // If this is not an collection of ungrouped times, print the total time. + // Ungrouped timers don't really make sense to add up. We still print the + // TOTAL line to make the percentages make sense. + if (this != DefaultTimerGroup) { + *OutStream << " Total Execution Time: "; + *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; + *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; } - --NumTimers; + *OutStream << "\n"; + + if (Total.getUserTime()) + *OutStream << " ---User Time---"; + if (Total.getSystemTime()) + *OutStream << " --System Time--"; + if (Total.getProcessTime()) + *OutStream << " --User+System--"; + *OutStream << " ---Wall Time---"; + if (Total.getMemUsed()) + *OutStream << " ---Mem---"; + *OutStream << " --- Name ---\n"; + + // Loop through all of the timing data, printing it out. + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) { + const std::pair &Entry = TimersToPrint[e-i-1]; + Entry.first.print(Total, *OutStream); + *OutStream << Entry.second << '\n'; + } + + Total.print(Total, *OutStream); + *OutStream << "Total\n\n"; + OutStream->flush(); TimersToPrint.clear(); @@ -363,8 +309,8 @@ ++NumTimers; } -void TimerGroup::addTimerToPrint(const Timer &T) { +void TimerGroup::addTimerToPrint(const TimeRecord &T, const std::string &Name) { sys::SmartScopedLock L(*TimerLock); - TimersToPrint.push_back(Timer(true, T)); + TimersToPrint.push_back(std::make_pair(T, Name)); } Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=99871&r1=99870&r2=99871&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Mon Mar 29 23:03:22 2010 @@ -378,17 +378,19 @@ static ManagedStatic > TimingInfoMutex; class TimingInfo { - std::map TimingData; + DenseMap TimingData; TimerGroup TG; - public: // Use 'create' member to get this. TimingInfo() : TG("... Pass execution timing report ...") {} // TimingDtor - Print out information about timing information ~TimingInfo() { - // Delete all of the timers... - TimingData.clear(); + // Delete all of the timers, which accumulate their info into the + // TimerGroup. + for (DenseMap::iterator I = TimingData.begin(), + E = TimingData.end(); I != E; ++I) + delete I->second; // TimerGroup is deleted next, printing the report. } @@ -397,18 +399,15 @@ // null. It may be called multiple times. static void createTheTimeInfo(); - /// passStarted - This method creates a timer for the given pass if it doesn't - /// already have one, and starts the timer. - Timer *passStarted(Pass *P) { + /// getPassTimer - Return the timer for the specified pass if it exists. + Timer *getPassTimer(Pass *P) { if (P->getAsPMDataManager()) return 0; sys::SmartScopedLock Lock(*TimingInfoMutex); - std::map::iterator I = TimingData.find(P); - if (I == TimingData.end()) - I=TimingData.insert(std::make_pair(P, Timer(P->getPassName(), TG))).first; - Timer *T = &I->second; - T->startTimer(); + Timer *&T = TimingData[P]; + if (T == 0) + T = new Timer(P->getPassName(), TG); return T; } }; @@ -704,11 +703,8 @@ E = PreservedSet.end(); I != E; ++I) { AnalysisID AID = *I; if (Pass *AP = findAnalysisPass(AID, true)) { - - Timer *T = 0; - if (TheTimeInfo) T = TheTimeInfo->passStarted(AP); + TimeRegion PassTimer(getPassTimer(AP)); AP->verifyAnalysis(); - if (T) T->stopTimer(); } } } @@ -792,10 +788,9 @@ { // If the pass crashes releasing memory, remember this. PassManagerPrettyStackEntry X(P); - - Timer *T = StartPassTimer(P); + TimeRegion PassTimer(getPassTimer(P)); + P->releaseMemory(); - StopPassTimer(P, T); } if (const PassInfo *PI = P->getPassInfo()) { @@ -1128,10 +1123,9 @@ { // If the pass crashes, remember this. PassManagerPrettyStackEntry X(BP, *I); - - Timer *T = StartPassTimer(BP); + TimeRegion PassTimer(getPassTimer(BP)); + LocalChanged |= BP->runOnBasicBlock(*I); - StopPassTimer(BP, T); } Changed |= LocalChanged; @@ -1345,10 +1339,9 @@ { PassManagerPrettyStackEntry X(FP, F); + TimeRegion PassTimer(getPassTimer(FP)); - Timer *T = StartPassTimer(FP); LocalChanged |= FP->runOnFunction(F); - StopPassTimer(FP, T); } Changed |= LocalChanged; @@ -1420,9 +1413,9 @@ { PassManagerPrettyStackEntry X(MP, M); - Timer *T = StartPassTimer(MP); + TimeRegion PassTimer(getPassTimer(MP)); + LocalChanged |= MP->runOnModule(M); - StopPassTimer(MP, T); } Changed |= LocalChanged; @@ -1559,17 +1552,12 @@ } /// If TimingInfo is enabled then start pass timer. -Timer *llvm::StartPassTimer(Pass *P) { +Timer *llvm::getPassTimer(Pass *P) { if (TheTimeInfo) - return TheTimeInfo->passStarted(P); + return TheTimeInfo->getPassTimer(P); return 0; } -/// If TimingInfo is enabled then stop pass timer. -void llvm::StopPassTimer(Pass *P, Timer *T) { - if (T) T->stopTimer(); -} - //===----------------------------------------------------------------------===// // PMStack implementation // From sabre at nondot.org Mon Mar 29 23:40:01 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 04:40:01 -0000 Subject: [llvm-commits] [llvm] r99872 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100330044001.C62D72A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 23:40:01 2010 New Revision: 99872 URL: http://llvm.org/viewvc/llvm-project?rev=99872&view=rev Log: change TimerGroup to keep a linked list of active timers instead of just a count of them, and refactor the guts of report printing out of removeTimer into its own method. Refactor addTimerToPrint away. Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99872&r1=99871&r2=99872&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 23:40:01 2010 @@ -85,6 +85,8 @@ std::string Name; // The name of this time variable. bool Started; // Has this time variable ever been started? TimerGroup *TG; // The TimerGroup this Timer is in. + + Timer **Prev, *Next; // Doubly linked list of timers in the group. public: explicit Timer(const std::string &N) : TG(0) { init(N); } Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); } @@ -133,12 +135,10 @@ T->startTimer(); } explicit TimeRegion(Timer *t) : T(t) { - if (T) - T->startTimer(); + if (T) T->startTimer(); } ~TimeRegion() { - if (T) - T->stopTimer(); + if (T) T->stopTimer(); } }; @@ -162,24 +162,36 @@ /// class TimerGroup { std::string Name; - unsigned NumTimers; + Timer *FirstTimer; // First timer in the group. std::vector > TimersToPrint; public: - explicit TimerGroup(const std::string &name) : Name(name), NumTimers(0) {} - explicit TimerGroup() : NumTimers(0) {} + explicit TimerGroup(const std::string &name) : Name(name), FirstTimer(0) {} + explicit TimerGroup() : FirstTimer(0) {} + + explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) { + operator=(TG); + } + + void operator=(const TimerGroup &TG) { + assert(TG.FirstTimer == 0 && FirstTimer == 0 && + "Cannot assign group with timers"); + Name = TG.Name; + } + void setName(const std::string &name) { Name = name; } ~TimerGroup() { - assert(NumTimers == 0 && + assert(FirstTimer == 0 && "TimerGroup destroyed before all contained timers!"); } + void PrintQueuedTimers(raw_ostream &OS); + private: friend class Timer; - void addTimer(); - void removeTimer(); - void addTimerToPrint(const TimeRecord &T, const std::string &Name); + void addTimer(Timer &T); + void removeTimer(Timer &T); }; } // End llvm namespace Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99872&r1=99871&r2=99872&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 23:40:01 2010 @@ -20,7 +20,6 @@ #include "llvm/System/Mutex.h" #include "llvm/System/Process.h" #include "llvm/ADT/StringMap.h" -#include using namespace llvm; // GetLibSupportInfoOutputFile - Return a file stream to print our output on. @@ -101,7 +100,7 @@ Name = N; Started = false; TG = getDefaultTimerGroup(); - TG->addTimer(); + TG->addTimer(*this); } void Timer::init(const std::string &N, TimerGroup &tg) { @@ -109,17 +108,12 @@ Name = N; Started = false; TG = &tg; - TG->addTimer(); + TG->addTimer(*this); } Timer::~Timer() { if (!TG) return; // Never initialized. - - if (Started) { - Started = false; - TG->addTimerToPrint(Time, Name); - } - TG->removeTimer(); + TG->removeTimer(*this); } static inline size_t getMemUsage() { @@ -243,74 +237,92 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// -void TimerGroup::removeTimer() { +void TimerGroup::removeTimer(Timer &T) { sys::SmartScopedLock L(*TimerLock); - if (--NumTimers != 0 || TimersToPrint.empty()) - return; // Don't print timing report. - // Sort the timers in descending order by amount of time taken. - std::sort(TimersToPrint.begin(), TimersToPrint.end()); + // If the timer was started, move its data to TimersToPrint. + if (T.Started) { + T.Started = false; + TimersToPrint.push_back(std::make_pair(T.Time, T.Name)); + } + + // Unlink the timer from our list. + *T.Prev = T.Next; + if (T.Next) + T.Next->Prev = T.Prev; + + // Print the report when all timers in this group are destroyed if some of + // them were started. + if (FirstTimer != 0 || TimersToPrint.empty()) + return; + + raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - // Figure out how many spaces to indent TimerGroup name. - unsigned Padding = (80-Name.length())/2; - if (Padding > 80) Padding = 0; // Don't allow "negative" numbers + PrintQueuedTimers(*OutStream); - raw_ostream *OutStream = GetLibSupportInfoOutputFile(); + if (OutStream != &errs() && OutStream != &outs()) + delete OutStream; // Close the file. +} + +void TimerGroup::addTimer(Timer &T) { + sys::SmartScopedLock L(*TimerLock); + + // Add the timer to our list. + if (FirstTimer) + FirstTimer->Prev = &T.Next; + T.Next = FirstTimer; + T.Prev = &FirstTimer; + FirstTimer = &T; +} +void TimerGroup::PrintQueuedTimers(raw_ostream &OS) { + // Sort the timers in descending order by amount of time taken. + std::sort(TimersToPrint.begin(), TimersToPrint.end()); + TimeRecord Total; for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) Total += TimersToPrint[i].first; - + // Print out timing header. - *OutStream << "===" << std::string(73, '-') << "===\n"; - OutStream->indent(Padding) << Name << '\n'; - *OutStream << "===" << std::string(73, '-') << "===\n"; - + OS << "===" << std::string(73, '-') << "===\n"; + // Figure out how many spaces to indent TimerGroup name. + unsigned Padding = (80-Name.length())/2; + if (Padding > 80) Padding = 0; // Don't allow "negative" numbers + OS.indent(Padding) << Name << '\n'; + OS << "===" << std::string(73, '-') << "===\n"; + // If this is not an collection of ungrouped times, print the total time. // Ungrouped timers don't really make sense to add up. We still print the // TOTAL line to make the percentages make sense. if (this != DefaultTimerGroup) { - *OutStream << " Total Execution Time: "; - *OutStream << format("%5.4f", Total.getProcessTime()) << " seconds ("; - *OutStream << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; + OS << " Total Execution Time: "; + OS << format("%5.4f", Total.getProcessTime()) << " seconds ("; + OS << format("%5.4f", Total.getWallTime()) << " wall clock)\n"; } - *OutStream << "\n"; - + OS << '\n'; + if (Total.getUserTime()) - *OutStream << " ---User Time---"; + OS << " ---User Time---"; if (Total.getSystemTime()) - *OutStream << " --System Time--"; + OS << " --System Time--"; if (Total.getProcessTime()) - *OutStream << " --User+System--"; - *OutStream << " ---Wall Time---"; + OS << " --User+System--"; + OS << " ---Wall Time---"; if (Total.getMemUsed()) - *OutStream << " ---Mem---"; - *OutStream << " --- Name ---\n"; - + OS << " ---Mem---"; + OS << " --- Name ---\n"; + // Loop through all of the timing data, printing it out. for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) { const std::pair &Entry = TimersToPrint[e-i-1]; - Entry.first.print(Total, *OutStream); - *OutStream << Entry.second << '\n'; + Entry.first.print(Total, OS); + OS << Entry.second << '\n'; } - - Total.print(Total, *OutStream); - *OutStream << "Total\n\n"; - OutStream->flush(); - + + Total.print(Total, OS); + OS << "Total\n\n"; + OS.flush(); + TimersToPrint.clear(); - - if (OutStream != &errs() && OutStream != &outs()) - delete OutStream; // Close the file. -} - -void TimerGroup::addTimer() { - sys::SmartScopedLock L(*TimerLock); - ++NumTimers; -} - -void TimerGroup::addTimerToPrint(const TimeRecord &T, const std::string &Name) { - sys::SmartScopedLock L(*TimerLock); - TimersToPrint.push_back(std::make_pair(T, Name)); } From sabre at nondot.org Mon Mar 29 23:58:26 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 04:58:26 -0000 Subject: [llvm-commits] [llvm] r99873 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Statistic.cpp lib/Support/Timer.cpp Message-ID: <20100330045826.427272A6C12C@llvm.org> Author: lattner Date: Mon Mar 29 23:58:26 2010 New Revision: 99873 URL: http://llvm.org/viewvc/llvm-project?rev=99873&view=rev Log: if a timergroup is destroyed before its timers, print times. Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Statistic.cpp llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99873&r1=99872&r2=99873&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Mon Mar 29 23:58:26 2010 @@ -171,6 +171,7 @@ explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) { operator=(TG); } + ~TimerGroup(); void operator=(const TimerGroup &TG) { assert(TG.FirstTimer == 0 && FirstTimer == 0 && @@ -181,11 +182,6 @@ void setName(const std::string &name) { Name = name; } - ~TimerGroup() { - assert(FirstTimer == 0 && - "TimerGroup destroyed before all contained timers!"); - } - void PrintQueuedTimers(raw_ostream &OS); private: Modified: llvm/trunk/lib/Support/Statistic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=99873&r1=99872&r2=99873&view=diff ============================================================================== --- llvm/trunk/lib/Support/Statistic.cpp (original) +++ llvm/trunk/lib/Support/Statistic.cpp Mon Mar 29 23:58:26 2010 @@ -128,6 +128,6 @@ OutStream << '\n'; // Flush the output stream... OutStream.flush(); - if (&OutStream != &outs() && &OutStream != &errs() && &OutStream != &dbgs()) + if (&OutStream != &outs() && &OutStream != &errs()) delete &OutStream; // Close the file. } Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99873&r1=99872&r2=99873&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Mon Mar 29 23:58:26 2010 @@ -237,14 +237,22 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// +TimerGroup::~TimerGroup() { + // If the timer group is destroyed before the timers it owns, accumulate and + // print the timing data. + while (FirstTimer != 0) + removeTimer(*FirstTimer); +} + + void TimerGroup::removeTimer(Timer &T) { sys::SmartScopedLock L(*TimerLock); // If the timer was started, move its data to TimersToPrint. - if (T.Started) { - T.Started = false; + if (T.Started) TimersToPrint.push_back(std::make_pair(T.Time, T.Name)); - } + + T.TG = 0; // Unlink the timer from our list. *T.Prev = T.Next; @@ -257,9 +265,9 @@ return; raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - + PrintQueuedTimers(*OutStream); - + if (OutStream != &errs() && OutStream != &outs()) delete OutStream; // Close the file. } From sabre at nondot.org Tue Mar 30 00:01:08 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 05:01:08 -0000 Subject: [llvm-commits] [llvm] r99874 - in /llvm/trunk/lib/Support: Statistic.cpp Timer.cpp Message-ID: <20100330050108.81E5A2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 00:01:08 2010 New Revision: 99874 URL: http://llvm.org/viewvc/llvm-project?rev=99874&view=rev Log: rename GetLibSupportInfoOutputFile -> CreateInfoOutputFile and have it always return a new stream to simplify clients. Modified: llvm/trunk/lib/Support/Statistic.cpp llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/lib/Support/Statistic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=99874&r1=99873&r2=99874&view=diff ============================================================================== --- llvm/trunk/lib/Support/Statistic.cpp (original) +++ llvm/trunk/lib/Support/Statistic.cpp Tue Mar 30 00:01:08 2010 @@ -32,8 +32,8 @@ #include using namespace llvm; -// GetLibSupportInfoOutputFile - Return a file stream to print our output on. -namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); } +// CreateInfoOutputFile - Return a file stream to print our output on. +namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } /// -stats - Command line option to cause transformations to emit stats about /// what they did. @@ -96,7 +96,7 @@ if (Stats.empty()) return; // Get the stream to write to. - raw_ostream &OutStream = *GetLibSupportInfoOutputFile(); + raw_ostream &OutStream = *CreateInfoOutputFile(); // Figure out how long the biggest Value and Name fields are. unsigned MaxNameLen = 0, MaxValLen = 0; @@ -125,9 +125,8 @@ } - OutStream << '\n'; // Flush the output stream... + OutStream << '\n'; // Flush the output stream. OutStream.flush(); - if (&OutStream != &outs() && &OutStream != &errs()) - delete &OutStream; // Close the file. + delete &OutStream; // Close the file. } Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99874&r1=99873&r2=99874&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Tue Mar 30 00:01:08 2010 @@ -22,8 +22,8 @@ #include "llvm/ADT/StringMap.h" using namespace llvm; -// GetLibSupportInfoOutputFile - Return a file stream to print our output on. -namespace llvm { extern raw_ostream *GetLibSupportInfoOutputFile(); } +// CreateInfoOutputFile - Return a file stream to print our output on. +namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy // of constructor/destructor ordering being unspecified by C++. Basically the @@ -52,13 +52,13 @@ cl::Hidden, cl::location(getLibSupportInfoOutputFilename())); } -// GetLibSupportInfoOutputFile - Return a file stream to print our output on. -raw_ostream *llvm::GetLibSupportInfoOutputFile() { +// CreateInfoOutputFile - Return a file stream to print our output on. +raw_ostream *llvm::CreateInfoOutputFile() { std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); if (LibSupportInfoOutputFilename.empty()) - return &errs(); + return new raw_fd_ostream(2, false); // stderr. if (LibSupportInfoOutputFilename == "-") - return &outs(); + return new raw_fd_ostream(1, false); // stdout. std::string Error; raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), @@ -69,7 +69,7 @@ errs() << "Error opening info-output-file '" << LibSupportInfoOutputFilename << " for appending!\n"; delete Result; - return &errs(); + return new raw_fd_ostream(2, false); // stderr. } @@ -264,12 +264,9 @@ if (FirstTimer != 0 || TimersToPrint.empty()) return; - raw_ostream *OutStream = GetLibSupportInfoOutputFile(); - + raw_ostream *OutStream = CreateInfoOutputFile(); PrintQueuedTimers(*OutStream); - - if (OutStream != &errs() && OutStream != &outs()) - delete OutStream; // Close the file. + delete OutStream; // Close the file. } void TimerGroup::addTimer(Timer &T) { From sabre at nondot.org Tue Mar 30 00:20:02 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 05:20:02 -0000 Subject: [llvm-commits] [llvm] r99875 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100330052002.562B92A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 00:20:02 2010 New Revision: 99875 URL: http://llvm.org/viewvc/llvm-project?rev=99875&view=rev Log: add a new TimerGroup::print method, and refactor away the bogus TimerGroup copy ctor and assignment operator. Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99875&r1=99874&r2=99875&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Tue Mar 30 00:20:02 2010 @@ -164,30 +164,24 @@ std::string Name; Timer *FirstTimer; // First timer in the group. std::vector > TimersToPrint; + TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT + void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT public: - explicit TimerGroup(const std::string &name) : Name(name), FirstTimer(0) {} - explicit TimerGroup() : FirstTimer(0) {} + explicit TimerGroup(const std::string &name = "") + : Name(name), FirstTimer(0) {} - explicit TimerGroup(const TimerGroup &TG) : FirstTimer(0) { - operator=(TG); - } ~TimerGroup(); - void operator=(const TimerGroup &TG) { - assert(TG.FirstTimer == 0 && FirstTimer == 0 && - "Cannot assign group with timers"); - Name = TG.Name; - } - - void setName(const std::string &name) { Name = name; } - - void PrintQueuedTimers(raw_ostream &OS); + + /// print - Print any started timers in this group and zero them. + void print(raw_ostream &OS); private: friend class Timer; void addTimer(Timer &T); void removeTimer(Timer &T); + void PrintQueuedTimers(raw_ostream &OS); }; } // End llvm namespace Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99875&r1=99874&r2=99875&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Tue Mar 30 00:20:02 2010 @@ -19,6 +19,7 @@ #include "llvm/Support/Format.h" #include "llvm/System/Mutex.h" #include "llvm/System/Process.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" using namespace llvm; @@ -112,36 +113,30 @@ } Timer::~Timer() { - if (!TG) return; // Never initialized. + if (!TG) return; // Never initialized, or already cleared. TG->removeTimer(*this); } static inline size_t getMemUsage() { - if (TrackSpace) - return sys::Process::GetMallocUsage(); - return 0; + if (!TrackSpace) return 0; + return sys::Process::GetMallocUsage(); } TimeRecord TimeRecord::getCurrentTime(bool Start) { TimeRecord Result; - - sys::TimeValue now(0,0); - sys::TimeValue user(0,0); - sys::TimeValue sys(0,0); - - ssize_t MemUsed = 0; + sys::TimeValue now(0,0), user(0,0), sys(0,0); + if (Start) { - MemUsed = getMemUsage(); + Result.MemUsed = getMemUsage(); sys::Process::GetTimeUsage(now, user, sys); } else { sys::Process::GetTimeUsage(now, user, sys); - MemUsed = getMemUsage(); + Result.MemUsed = getMemUsage(); } Result.WallTime = now.seconds() + now.microseconds() / 1000000.0; Result.UserTime = user.seconds() + user.microseconds() / 1000000.0; Result.SystemTime = sys.seconds() + sys.microseconds() / 1000000.0; - Result.MemUsed = MemUsed; return Result; } @@ -196,7 +191,30 @@ //===----------------------------------------------------------------------===// typedef StringMap Name2TimerMap; -typedef StringMap > Name2PairMap; + +class Name2PairMap { + StringMap > Map; +public: + ~Name2PairMap() { + for (StringMap >::iterator + I = Map.begin(), E = Map.end(); I != E; ++I) + delete I->second.first; + } + + Timer &get(const std::string &Name, const std::string &GroupName) { + sys::SmartScopedLock L(*TimerLock); + + std::pair &GroupEntry = Map[GroupName]; + + if (!GroupEntry.first) + GroupEntry.first = new TimerGroup(GroupName); + + Timer &T = GroupEntry.second[Name]; + if (!T.isInitialized()) + T.init(Name, *GroupEntry.first); + return T; + } +}; static ManagedStatic NamedTimers; static ManagedStatic NamedGroupedTimers; @@ -210,28 +228,12 @@ return T; } -static Timer &getNamedRegionTimer(const std::string &Name, - const std::string &GroupName) { - sys::SmartScopedLock L(*TimerLock); - - std::pair &GroupEntry = - (*NamedGroupedTimers)[GroupName]; - - if (GroupEntry.second.empty()) - GroupEntry.first.setName(GroupName); - - Timer &T = GroupEntry.second[Name]; - if (!T.isInitialized()) - T.init(Name); - return T; -} - NamedRegionTimer::NamedRegionTimer(const std::string &Name) : TimeRegion(getNamedRegionTimer(Name)) {} NamedRegionTimer::NamedRegionTimer(const std::string &Name, const std::string &GroupName) - : TimeRegion(getNamedRegionTimer(Name, GroupName)) {} + : TimeRegion(NamedGroupedTimers->get(Name, GroupName)) {} //===----------------------------------------------------------------------===// // TimerGroup Implementation @@ -331,3 +333,22 @@ TimersToPrint.clear(); } +/// print - Print any started timers in this group and zero them. +void TimerGroup::print(raw_ostream &OS) { + sys::SmartScopedLock L(*TimerLock); + + // See if any of our timers were started, if so add them to TimersToPrint and + // reset them. + for (Timer *T = FirstTimer; T; T = T->Next) { + if (!T->Started) continue; + TimersToPrint.push_back(std::make_pair(T->Time, T->Name)); + + // Clear out the time. + T->Started = 0; + T->Time = TimeRecord(); + } + + // If any timers were started, print the group. + if (!TimersToPrint.empty()) + PrintQueuedTimers(OS); +} From sabre at nondot.org Tue Mar 30 00:27:59 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 05:27:59 -0000 Subject: [llvm-commits] [llvm] r99876 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100330052759.13FA12A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 00:27:58 2010 New Revision: 99876 URL: http://llvm.org/viewvc/llvm-project?rev=99876&view=rev Log: finally, maintain a global list of timer groups, allowing us to implement TimerGroup::printAll, which prints and resets all active timers. Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99876&r1=99875&r2=99876&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Tue Mar 30 00:27:58 2010 @@ -164,12 +164,12 @@ std::string Name; Timer *FirstTimer; // First timer in the group. std::vector > TimersToPrint; + + TimerGroup **Prev, *Next; // Doubly linked list of TimerGroup's. TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT public: - explicit TimerGroup(const std::string &name = "") - : Name(name), FirstTimer(0) {} - + explicit TimerGroup(const std::string &name); ~TimerGroup(); void setName(const std::string &name) { Name = name; } @@ -177,6 +177,9 @@ /// print - Print any started timers in this group and zero them. void print(raw_ostream &OS); + /// printAll - This static method prints all timers and clears them all out. + static void printAll(raw_ostream &OS); + private: friend class Timer; void addTimer(Timer &T); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99876&r1=99875&r2=99876&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Tue Mar 30 00:27:58 2010 @@ -239,11 +239,33 @@ // TimerGroup Implementation //===----------------------------------------------------------------------===// +/// TimerGroupList - This is the global list of TimerGroups, maintained by the +/// TimerGroup ctor/dtor and is protected by the TimerLock lock. +static TimerGroup *TimerGroupList = 0; + +TimerGroup::TimerGroup(const std::string &name) + : Name(name), FirstTimer(0) { + + // Add the group to TimerGroupList. + sys::SmartScopedLock L(*TimerLock); + if (TimerGroupList) + TimerGroupList->Prev = &Next; + Next = TimerGroupList; + Prev = &TimerGroupList; + TimerGroupList = this; +} + TimerGroup::~TimerGroup() { // If the timer group is destroyed before the timers it owns, accumulate and // print the timing data. while (FirstTimer != 0) removeTimer(*FirstTimer); + + // Remove the group from the TimerGroupList. + sys::SmartScopedLock L(*TimerLock); + *Prev = Next; + if (Next) + Next->Prev = Prev; } @@ -352,3 +374,11 @@ if (!TimersToPrint.empty()) PrintQueuedTimers(OS); } + +/// printAll - This static method prints all timers and clears them all out. +void TimerGroup::printAll(raw_ostream &OS) { + sys::SmartScopedLock L(*TimerLock); + + for (TimerGroup *TG = TimerGroupList; TG; TG = TG->Next) + TG->print(OS); +} From sabre at nondot.org Tue Mar 30 00:34:03 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 05:34:03 -0000 Subject: [llvm-commits] [llvm] r99877 - in /llvm/trunk: include/llvm/Support/Timer.h lib/Support/Timer.cpp Message-ID: <20100330053403.23BD62A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 00:34:02 2010 New Revision: 99877 URL: http://llvm.org/viewvc/llvm-project?rev=99877&view=rev Log: stringref'ize Timer apis Modified: llvm/trunk/include/llvm/Support/Timer.h llvm/trunk/lib/Support/Timer.cpp Modified: llvm/trunk/include/llvm/Support/Timer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Timer.h?rev=99877&r1=99876&r2=99877&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Timer.h (original) +++ llvm/trunk/include/llvm/Support/Timer.h Tue Mar 30 00:34:02 2010 @@ -16,6 +16,7 @@ #define LLVM_SUPPORT_TIMER_H #include "llvm/System/DataTypes.h" +#include "llvm/ADT/StringRef.h" #include #include #include @@ -88,8 +89,8 @@ Timer **Prev, *Next; // Doubly linked list of timers in the group. public: - explicit Timer(const std::string &N) : TG(0) { init(N); } - Timer(const std::string &N, TimerGroup &tg) : TG(0) { init(N, tg); } + explicit Timer(StringRef N) : TG(0) { init(N); } + Timer(StringRef N, TimerGroup &tg) : TG(0) { init(N, tg); } Timer(const Timer &RHS) : TG(0) { assert(RHS.TG == 0 && "Can only copy uninitialized timers"); } @@ -101,8 +102,8 @@ // Create an uninitialized timer, client must use 'init'. explicit Timer() : TG(0) {} - void init(const std::string &N); - void init(const std::string &N, TimerGroup &tg); + void init(StringRef N); + void init(StringRef N, TimerGroup &tg); const std::string &getName() const { return Name; } bool isInitialized() const { return TG != 0; } @@ -149,9 +150,8 @@ /// is primarily used for debugging and for hunting performance problems. /// struct NamedRegionTimer : public TimeRegion { - explicit NamedRegionTimer(const std::string &Name); - explicit NamedRegionTimer(const std::string &Name, - const std::string &GroupName); + explicit NamedRegionTimer(StringRef Name); + explicit NamedRegionTimer(StringRef Name, StringRef GroupName); }; @@ -169,10 +169,10 @@ TimerGroup(const TimerGroup &TG); // DO NOT IMPLEMENT void operator=(const TimerGroup &TG); // DO NOT IMPLEMENT public: - explicit TimerGroup(const std::string &name); + explicit TimerGroup(StringRef name); ~TimerGroup(); - void setName(const std::string &name) { Name = name; } + void setName(StringRef name) { Name.assign(name.begin(), name.end()); } /// print - Print any started timers in this group and zero them. void print(raw_ostream &OS); Modified: llvm/trunk/lib/Support/Timer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Timer.cpp?rev=99877&r1=99876&r2=99877&view=diff ============================================================================== --- llvm/trunk/lib/Support/Timer.cpp (original) +++ llvm/trunk/lib/Support/Timer.cpp Tue Mar 30 00:34:02 2010 @@ -55,20 +55,20 @@ // CreateInfoOutputFile - Return a file stream to print our output on. raw_ostream *llvm::CreateInfoOutputFile() { - std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); - if (LibSupportInfoOutputFilename.empty()) + const std::string &OutputFilename = getLibSupportInfoOutputFilename(); + if (OutputFilename.empty()) return new raw_fd_ostream(2, false); // stderr. - if (LibSupportInfoOutputFilename == "-") + if (OutputFilename == "-") return new raw_fd_ostream(1, false); // stdout. std::string Error; - raw_ostream *Result = new raw_fd_ostream(LibSupportInfoOutputFilename.c_str(), + raw_ostream *Result = new raw_fd_ostream(OutputFilename.c_str(), Error, raw_fd_ostream::F_Append); if (Error.empty()) return Result; errs() << "Error opening info-output-file '" - << LibSupportInfoOutputFilename << " for appending!\n"; + << OutputFilename << " for appending!\n"; delete Result; return new raw_fd_ostream(2, false); // stderr. } @@ -96,17 +96,17 @@ // Timer Implementation //===----------------------------------------------------------------------===// -void Timer::init(const std::string &N) { +void Timer::init(StringRef N) { assert(TG == 0 && "Timer already initialized"); - Name = N; + Name.assign(N.begin(), N.end()); Started = false; TG = getDefaultTimerGroup(); TG->addTimer(*this); } -void Timer::init(const std::string &N, TimerGroup &tg) { +void Timer::init(StringRef N, TimerGroup &tg) { assert(TG == 0 && "Timer already initialized"); - Name = N; + Name.assign(N.begin(), N.end()); Started = false; TG = &tg; TG->addTimer(*this); @@ -201,7 +201,7 @@ delete I->second.first; } - Timer &get(const std::string &Name, const std::string &GroupName) { + Timer &get(StringRef Name, StringRef GroupName) { sys::SmartScopedLock L(*TimerLock); std::pair &GroupEntry = Map[GroupName]; @@ -219,7 +219,7 @@ static ManagedStatic NamedTimers; static ManagedStatic NamedGroupedTimers; -static Timer &getNamedRegionTimer(const std::string &Name) { +static Timer &getNamedRegionTimer(StringRef Name) { sys::SmartScopedLock L(*TimerLock); Timer &T = (*NamedTimers)[Name]; @@ -228,11 +228,10 @@ return T; } -NamedRegionTimer::NamedRegionTimer(const std::string &Name) +NamedRegionTimer::NamedRegionTimer(StringRef Name) : TimeRegion(getNamedRegionTimer(Name)) {} -NamedRegionTimer::NamedRegionTimer(const std::string &Name, - const std::string &GroupName) +NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName) : TimeRegion(NamedGroupedTimers->get(Name, GroupName)) {} //===----------------------------------------------------------------------===// @@ -243,8 +242,8 @@ /// TimerGroup ctor/dtor and is protected by the TimerLock lock. static TimerGroup *TimerGroupList = 0; -TimerGroup::TimerGroup(const std::string &name) - : Name(name), FirstTimer(0) { +TimerGroup::TimerGroup(StringRef name) + : Name(name.begin(), name.end()), FirstTimer(0) { // Add the group to TimerGroupList. sys::SmartScopedLock L(*TimerLock); From evan.cheng at apple.com Tue Mar 30 00:49:07 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 30 Mar 2010 05:49:07 -0000 Subject: [llvm-commits] [llvm] r99879 - in /llvm/trunk/lib/CodeGen: LiveIntervalAnalysis.cpp VirtRegRewriter.cpp Message-ID: <20100330054907.7828E2A6C12C@llvm.org> Author: evancheng Date: Tue Mar 30 00:49:07 2010 New Revision: 99879 URL: http://llvm.org/viewvc/llvm-project?rev=99879&view=rev Log: Avoid being influenced by the presence of dbg_value instructions. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99879&r1=99878&r2=99879&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 00:49:07 2010 @@ -819,8 +819,9 @@ unsigned ImpUse = getReMatImplicitUse(li, MI); if (ImpUse) { const LiveInterval &ImpLi = getInterval(ImpUse); - for (MachineRegisterInfo::use_iterator ri = mri_->use_begin(li.reg), - re = mri_->use_end(); ri != re; ++ri) { + for (MachineRegisterInfo::use_nodbg_iterator + ri = mri_->use_nodbg_begin(li.reg), re = mri_->use_nodbg_end(); + ri != re; ++ri) { MachineInstr *UseMI = &*ri; SlotIndex UseIdx = getInstructionIndex(UseMI); if (li.FindLiveRangeContaining(UseIdx)->valno != ValNo) @@ -1052,7 +1053,7 @@ // all of its uses are rematerialized, simply delete it. if (MI == ReMatOrigDefMI && CanDelete) { DEBUG(dbgs() << "\t\t\t\tErasing re-materializable def: " - << MI << '\n'); + << *MI << '\n'); RemoveMachineInstrFromMaps(MI); vrm.RemoveMachineInstrFromMaps(MI); MI->eraseFromParent(); @@ -1520,6 +1521,12 @@ MachineOperand &O = ri.getOperand(); MachineInstr *MI = &*ri; ++ri; + if (MI->isDebugValue()) { + // Remove debug info for now. + O.setReg(0U); + DEBUG(dbgs() << "Removing debug info due to spill:" << "\t" << *MI); + continue; + } if (O.isDef()) { assert(MI->isImplicitDef() && "Register def was not rewritten?"); @@ -2012,6 +2019,8 @@ E = mri_->reg_end(); I != E; ++I) { MachineOperand &O = I.getOperand(); MachineInstr *MI = O.getParent(); + if (MI->isDebugValue()) + continue; SlotIndex Index = getInstructionIndex(MI); if (pli.liveAt(Index)) ++NumConflicts; @@ -2052,7 +2061,7 @@ E = mri_->reg_end(); I != E; ++I) { MachineOperand &O = I.getOperand(); MachineInstr *MI = O.getParent(); - if (SeenMIs.count(MI)) + if (MI->isDebugValue() || SeenMIs.count(MI)) continue; SeenMIs.insert(MI); SlotIndex Index = getInstructionIndex(MI); Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=99879&r1=99878&r2=99879&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Tue Mar 30 00:49:07 2010 @@ -990,10 +990,17 @@ SmallVector Kills; // Take a look at 2 instructions at most. - for (unsigned Count = 0; Count < 2; ++Count) { + unsigned Count = 0; + while (Count < 2) { if (MII == MBB.begin()) break; MachineInstr *PrevMI = prior(MII); + MII = PrevMI; + + if (PrevMI->isDebugValue()) + continue; // Skip over dbg_value instructions. + ++Count; + for (unsigned i = 0, e = PrevMI->getNumOperands(); i != e; ++i) { MachineOperand &MO = PrevMI->getOperand(i); if (!MO.isReg() || MO.getReg() == 0) @@ -1022,8 +1029,6 @@ for (const unsigned *AS = TRI->getAliasSet(Reg); *AS; ++AS) Uses.set(*AS); } - - MII = PrevMI; } return 0; @@ -1213,6 +1218,9 @@ std::vector &KillOps) { MachineBasicBlock::iterator NextMII = llvm::next(MII); + // Skip over dbg_value instructions. + while (NextMII != MBB->end() && NextMII->isDebugValue()) + NextMII = llvm::next(NextMII); if (NextMII == MBB->end()) return false; @@ -1277,6 +1285,9 @@ VRM->RemoveMachineInstrFromMaps(&NextMI); MBB->erase(&NextMI); ++NumModRefUnfold; + // Skip over dbg_value instructions. + while (NextMII != MBB->end() && NextMII->isDebugValue()) + NextMII = llvm::next(NextMII); if (NextMII == MBB->end()) break; } while (FoldsStackSlotModRef(*NextMII, SS, PhysReg, TII, TRI, *VRM)); @@ -1622,7 +1633,7 @@ for (MachineRegisterInfo::reg_iterator RI = MRI->reg_begin(Reg), RE = MRI->reg_end(); RI != RE; ++RI) { MachineInstr *UDMI = &*RI; - if (UDMI->getParent() != MBB) + if (UDMI->isDebugValue() || UDMI->getParent() != MBB) continue; DenseMap::iterator DI = DistanceMap.find(UDMI); if (DI == DistanceMap.end()) From baldrick at free.fr Tue Mar 30 01:37:12 2010 From: baldrick at free.fr (Duncan Sands) Date: Tue, 30 Mar 2010 08:37:12 +0200 Subject: [llvm-commits] [llvm] r99832 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: <20100329203820.8F90D2A6C12C@llvm.org> References: <20100329203820.8F90D2A6C12C@llvm.org> Message-ID: <4BB19C18.50305@free.fr> Hi Chris, > fix a variety of issues were we'd start DebugTimer but > not stop it by using RAII. is there any real reason for the dwarf debug and dwarf exception writers to have their own special timers? They are the only passes that do: ===-------------------------------------------------------------------------=== Miscellaneous Ungrouped Timers ===-------------------------------------------------------------------------=== ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- ----- ----- ----- ----- DWARF Exception Writer ----- ----- ----- ----- Dwarf Debug Writer ----- ----- ----- ----- TOTAL Ciao, Duncan. From gabor at mac.com Tue Mar 30 04:34:53 2010 From: gabor at mac.com (Gabor Greif) Date: Tue, 30 Mar 2010 11:34:53 +0200 Subject: [llvm-commits] [PATCH] Configurable CallSiteBase Message-ID: <4BB1C5BD.7090204@mac.com> Hi all, I'd like to put this patch to review. It pulls out some functionality from CallSite into a template baseclass CallSiteBase. CallSiteBase is highly customizable in the type of the inputs and outputs (types), especially constness variants. CallSite then chooses the fully non-const configuration. CallSiteBase<> with all-default parameters implements the fully const configuration. This is the preferred configuration for analyses and predicates, because it prevents accidental mutation. It is not yet settled how I should arrange the order of CallSiteBase template parameters. Logically, those that are frequently customized should go to the front, but I have no data points yet, since all we use now is an all-or-nothing regarding constness. Some predicates of analyses already have been converted to full-constness to demonstrate the concept. More to follow. There is potential for pulling more methods into the base class, I plan to do this as soon as need arises. Notable omissions: - ProgrammersManual: document CallSiteBase - should we define a class ConstCallSite? (I see no gain ATM.) CallSiteBase now provides three convenience features (some of them are inherited by CallSite too) : - operator bool: this conversion allows to check whether we have a proper call site. Allows to eliminate an indentation level of "if" statements. - operator ->: gives back the payload as an instruction (InstrTy*) - constructor from ValueTy: this may supplant the static "get" method in the future (ATM it is implementer in terms of "get"). Anyway, this constructor can be used in "if" statements to get rid of a free-standing wide-scope local binding. Comments, suggestions welcome. I plan to commit this in 2-3 days. Cheers, Gabor -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: CallSiteBase.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100330/84ce3c6f/attachment.pl From edwintorok at gmail.com Tue Mar 30 04:54:15 2010 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 30 Mar 2010 12:54:15 +0300 Subject: [llvm-commits] [llvm] r99400 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/Generic/2010-03-24-liveintervalleak.ll In-Reply-To: References: <20100324135036.CB2412A6C12C@llvm.org> <2004E368-7E33-4932-8135-48B6F6F610A8@2pi.dk> <0BB4DEE1-61E1-4B17-AA3E-2AA9255990F0@2pi.dk> <02E03C07-91C5-42C0-9A14-BCAAF154F997@apple.com> Message-ID: <4BB1CA47.8000009@gmail.com> On 03/26/2010 02:29 AM, Jakob Stoklund Olesen wrote: > On Mar 25, 2010, at 4:48 PM, Evan Cheng wrote: > >> On Mar 25, 2010, at 4:39 PM, Jakob Stoklund Olesen wrote: >> >>> On Mar 25, 2010, at 4:32 PM, Evan Cheng wrote: >>> >>>> On Mar 25, 2010, at 4:30 PM, Jakob Stoklund Olesen wrote: >>>> >>>>> On Mar 24, 2010, at 6:50 AM, Torok Edwin wrote: >>>>> >>>>>> Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp >>>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99400&r1=99399&r2=99400&view=diff >>>>>> ============================================================================== >>>>>> --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) >>>>>> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Mar 24 08:50:36 2010 >>>>>> @@ -85,8 +85,10 @@ >>>>>> void LiveIntervals::releaseMemory() { >>>>>> // Free the live intervals themselves. >>>>>> for (DenseMap::iterator I = r2iMap_.begin(), >>>>>> - E = r2iMap_.end(); I != E; ++I) >>>>>> + E = r2iMap_.end(); I != E; ++I) { >>>>>> + I->second->clear(); >>>>>> delete I->second; >>>>>> + } >>>>>> >>>>>> r2iMap_.clear(); >>>>> I think LiveInterval::clear is broken. I calls VNI->~VNInfo(), but those VNIs can be referenced from multiple intervals. >>>> Really? Multiple liveinterval's or liverange's? >>> LiveIntervals. >>> >>> Is a VNI supposed to belong to only one LiveInterval? I don't know any concrete examples where that is not the case, but a lot of funny stuff is going on when coalescing. >> I don't think VNI should be shared between liveinterval's. It may be shared temporarily during coalescing though. > > Let's call it a bug. In that case, clear() is fine, but a VNI is accidentally shared somewhere. > >> Either way, VNI are all bump allocated so the dtor should not be called? > > Yeah, but they contain a SmallVector that leaks if it is not destroyed. Adding more clear()s doesn't fix the leaks though, and sometimes I get double-frees. I don't really understand what happens with VNInfos after liveintervals are joined. So instead of using clear() I tought BumpPtrAllocator to iterate over all the allocated slabs, and call a destructor function. In our case all the objects we allocate are of same size, so by simply iterating on the slabs with that size (and alignment) we find the pointers to all the VNInfos we allocated, and call their destructor. The valnos list doesn't seem to be reliable for that purpose. I'm testing the attached patch now. Best regards, --Edwin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100330/68bf4bc0/attachment.pl From edwintorok at gmail.com Tue Mar 30 05:08:27 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 10:08:27 -0000 Subject: [llvm-commits] [llvm] r99881 - in /llvm/trunk: include/llvm/Support/Allocator.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp Message-ID: <20100330100827.265FF2A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 05:08:26 2010 New Revision: 99881 URL: http://llvm.org/viewvc/llvm-project?rev=99881&view=rev Log: Introduce another Reset() method in BumpPtrAllocator that calls a destructor on all objects it has allocated, if they are all of the same size and alignment. Use this to destruct all VNInfos allocated in LiveIntervalAnalysis (PR6653). valnos is not reliable for this purpose, as seen in r99400 (which still leaked, and sometimes caused double frees). Modified: llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99881&r1=99880&r2=99881&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 05:08:26 2010 @@ -134,6 +134,7 @@ static MallocSlabAllocator DefaultSlabAllocator; public: + typedef void (*DTorFunction)(void*); BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, SlabAllocator &allocator = DefaultSlabAllocator); ~BumpPtrAllocator(); @@ -142,6 +143,11 @@ /// to the beginning of it, freeing all memory allocated so far. void Reset(); + /// Reset - like Reset(), but call DTorFunction for each allocated + /// object. This assumes that all objects allocated with this allocator + /// had the same size and alignment specified here. + void Reset(size_t Size, size_t Alignment, DTorFunction DTor); + /// Allocate - Allocate space at the specified alignment. /// void *Allocate(size_t Size, size_t Alignment); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99881&r1=99880&r2=99881&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 05:08:26 2010 @@ -82,6 +82,11 @@ MachineFunctionPass::getAnalysisUsage(AU); } +static void VNInfoDTor(void* Ptr) +{ + reinterpret_cast(Ptr)->~VNInfo(); +} + void LiveIntervals::releaseMemory() { // Free the live intervals themselves. for (DenseMap::iterator I = r2iMap_.begin(), @@ -91,7 +96,7 @@ r2iMap_.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset(); + VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); while (!CloneMIs.empty()) { MachineInstr *MI = CloneMIs.back(); CloneMIs.pop_back(); Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99881&r1=99880&r2=99881&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 05:08:26 2010 @@ -78,6 +78,21 @@ End = ((char*)CurSlab) + CurSlab->Size; } +void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { + if (Alignment == 0) Alignment = 1; + MemSlab *Slab = CurSlab; + while (Slab) { + char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; + for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { + Ptr = AlignPtr(Ptr, Alignment); + if (Ptr + Size <= End) + DTor(Ptr); + } + Slab = Slab->NextPtr; + } + Reset(); +} + /// Allocate - Allocate space at the specified alignment. /// void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { From edwintorok at gmail.com Tue Mar 30 05:25:09 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 10:25:09 -0000 Subject: [llvm-commits] [llvm] r99882 - in /llvm/trunk: include/llvm/Support/Allocator.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp Message-ID: <20100330102509.232752A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 05:25:08 2010 New Revision: 99882 URL: http://llvm.org/viewvc/llvm-project?rev=99882&view=rev Log: Revert 99881, it brooke smooshlab's llvm-gcc-i386-darwin9. Modified: llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99882&r1=99881&r2=99882&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 05:25:08 2010 @@ -134,7 +134,6 @@ static MallocSlabAllocator DefaultSlabAllocator; public: - typedef void (*DTorFunction)(void*); BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, SlabAllocator &allocator = DefaultSlabAllocator); ~BumpPtrAllocator(); @@ -143,11 +142,6 @@ /// to the beginning of it, freeing all memory allocated so far. void Reset(); - /// Reset - like Reset(), but call DTorFunction for each allocated - /// object. This assumes that all objects allocated with this allocator - /// had the same size and alignment specified here. - void Reset(size_t Size, size_t Alignment, DTorFunction DTor); - /// Allocate - Allocate space at the specified alignment. /// void *Allocate(size_t Size, size_t Alignment); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99882&r1=99881&r2=99882&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 05:25:08 2010 @@ -82,11 +82,6 @@ MachineFunctionPass::getAnalysisUsage(AU); } -static void VNInfoDTor(void* Ptr) -{ - reinterpret_cast(Ptr)->~VNInfo(); -} - void LiveIntervals::releaseMemory() { // Free the live intervals themselves. for (DenseMap::iterator I = r2iMap_.begin(), @@ -96,7 +91,7 @@ r2iMap_.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); + VNInfoAllocator.Reset(); while (!CloneMIs.empty()) { MachineInstr *MI = CloneMIs.back(); CloneMIs.pop_back(); Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99882&r1=99881&r2=99882&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 05:25:08 2010 @@ -78,21 +78,6 @@ End = ((char*)CurSlab) + CurSlab->Size; } -void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { - if (Alignment == 0) Alignment = 1; - MemSlab *Slab = CurSlab; - while (Slab) { - char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; - for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { - Ptr = AlignPtr(Ptr, Alignment); - if (Ptr + Size <= End) - DTor(Ptr); - } - Slab = Slab->NextPtr; - } - Reset(); -} - /// Allocate - Allocate space at the specified alignment. /// void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { From edwintorok at gmail.com Tue Mar 30 06:17:48 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 11:17:48 -0000 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp Message-ID: <20100330111748.9148F2A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 06:17:48 2010 New Revision: 99883 URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev Log: Reapply r99881 with some fixes: only call destructor in releaseMemory! Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=99883&r1=99882&r2=99883&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Mar 30 06:17:48 2010 @@ -330,12 +330,7 @@ } void clear() { - while (!valnos.empty()) { - VNInfo *VNI = valnos.back(); - valnos.pop_back(); - VNI->~VNInfo(); - } - + valnos.clear(); ranges.clear(); } Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99883&r1=99882&r2=99883&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 06:17:48 2010 @@ -134,6 +134,7 @@ static MallocSlabAllocator DefaultSlabAllocator; public: + typedef void (*DTorFunction)(void*); BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, SlabAllocator &allocator = DefaultSlabAllocator); ~BumpPtrAllocator(); @@ -142,6 +143,11 @@ /// to the beginning of it, freeing all memory allocated so far. void Reset(); + /// Reset - like Reset(), but call DTorFunction for each allocated + /// object. This assumes that all objects allocated with this allocator + /// had the same size and alignment specified here. + void Reset(size_t Size, size_t Alignment, DTorFunction DTor); + /// Allocate - Allocate space at the specified alignment. /// void *Allocate(size_t Size, size_t Alignment); Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99883&r1=99882&r2=99883&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 06:17:48 2010 @@ -305,7 +305,6 @@ do { VNInfo *VNI = valnos.back(); valnos.pop_back(); - VNI->~VNInfo(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { ValNo->setIsUnused(true); @@ -353,7 +352,6 @@ do { VNInfo *VNI = valnos.back(); valnos.pop_back(); - VNI->~VNInfo(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { ValNo->setIsUnused(true); @@ -581,7 +579,6 @@ do { VNInfo *VNI = valnos.back(); valnos.pop_back(); - VNI->~VNInfo(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { V1->setIsUnused(true); @@ -658,7 +655,6 @@ if (UnusedValNo) { // Delete the last unused val#. valnos.pop_back(); - UnusedValNo->~VNInfo(); } } @@ -751,7 +747,6 @@ do { VNInfo *VNI = valnos.back(); valnos.pop_back(); - VNI->~VNInfo(); } while (valnos.back()->isUnused()); } else { V1->setIsUnused(true); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99883&r1=99882&r2=99883&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 06:17:48 2010 @@ -82,6 +82,11 @@ MachineFunctionPass::getAnalysisUsage(AU); } +static void VNInfoDTor(void* Ptr) +{ + reinterpret_cast(Ptr)->~VNInfo(); +} + void LiveIntervals::releaseMemory() { // Free the live intervals themselves. for (DenseMap::iterator I = r2iMap_.begin(), @@ -91,7 +96,7 @@ r2iMap_.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset(); + VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); while (!CloneMIs.empty()) { MachineInstr *MI = CloneMIs.back(); CloneMIs.pop_back(); Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99883&r1=99882&r2=99883&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 06:17:48 2010 @@ -78,6 +78,21 @@ End = ((char*)CurSlab) + CurSlab->Size; } +void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { + if (Alignment == 0) Alignment = 1; + MemSlab *Slab = CurSlab; + while (Slab) { + char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; + for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { + Ptr = AlignPtr(Ptr, Alignment); + if (Ptr + Size <= End) + DTor(Ptr); + } + Slab = Slab->NextPtr; + } + Reset(); +} + /// Allocate - Allocate space at the specified alignment. /// void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { From edwintorok at gmail.com Tue Mar 30 07:31:58 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 12:31:58 -0000 Subject: [llvm-commits] [llvm] r99885 - /llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Message-ID: <20100330123158.C66242A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 07:31:58 2010 New Revision: 99885 URL: http://llvm.org/viewvc/llvm-project?rev=99885&view=rev Log: Honour addGlobalMapping() in the interpreter, if it was used to add mappings for external Functions (the JIT does honour this). Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99885&r1=99884&r2=99885&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Mar 30 07:31:58 2010 @@ -265,6 +265,7 @@ if (RF == RawFunctions->end()) { RawFn = (RawFunc)(intptr_t) sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName()); + RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F); if (RawFn != 0) RawFunctions->insert(std::make_pair(F, RawFn)); // Cache for later } else { From edwintorok at gmail.com Tue Mar 30 07:52:03 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 12:52:03 -0000 Subject: [llvm-commits] [llvm] r99886 - /llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Message-ID: <20100330125204.040E72A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 07:52:03 2010 New Revision: 99886 URL: http://llvm.org/viewvc/llvm-project?rev=99886&view=rev Log: Don't overwrite previous value, if it succeeded. Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99886&r1=99885&r2=99886&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Mar 30 07:52:03 2010 @@ -265,7 +265,8 @@ if (RF == RawFunctions->end()) { RawFn = (RawFunc)(intptr_t) sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName()); - RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F); + if (!RawnFn) + RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F); if (RawFn != 0) RawFunctions->insert(std::make_pair(F, RawFn)); // Cache for later } else { From benny.kra at googlemail.com Tue Mar 30 08:28:42 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 30 Mar 2010 13:28:42 -0000 Subject: [llvm-commits] [llvm] r99887 - in /llvm/trunk/lib/Target/PIC16: PIC16Section.cpp PIC16Section.h Message-ID: <20100330132842.C2BF12A6C12C@llvm.org> Author: d0k Date: Tue Mar 30 08:28:42 2010 New Revision: 99887 URL: http://llvm.org/viewvc/llvm-project?rev=99887&view=rev Log: PIC16: Plug a leak in PIC16Section by allocating name & address strings in the MCContext. There is still one leak left in PIC16Section (the Items vector). Modified: llvm/trunk/lib/Target/PIC16/PIC16Section.cpp llvm/trunk/lib/Target/PIC16/PIC16Section.h Modified: llvm/trunk/lib/Target/PIC16/PIC16Section.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.cpp?rev=99887&r1=99886&r2=99887&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.cpp Tue Mar 30 08:28:42 2010 @@ -17,10 +17,9 @@ // This is the only way to create a PIC16Section. Sections created here // do not need to be explicitly deleted as they are managed by auto_ptrs. -PIC16Section *PIC16Section::Create(const StringRef &Name, - PIC16SectionType Ty, - const std::string &Address, - int Color, MCContext &Ctx) { +PIC16Section *PIC16Section::Create(StringRef Name, PIC16SectionType Ty, + StringRef Address, int Color, + MCContext &Ctx) { /// Determine the internal SectionKind info. /// Users of PIC16Section class should not need to know the internal @@ -59,8 +58,17 @@ } + // Copy strings into context allocated memory so they get free'd when the + // context is destroyed. + char *NameCopy = static_cast(Ctx.Allocate(Name.size(), 1)); + memcpy(NameCopy, Name.data(), Name.size()); + char *AddressCopy = static_cast(Ctx.Allocate(Address.size(), 1)); + memcpy(AddressCopy, Address.data(), Address.size()); + // Create the Section. - PIC16Section *S = new (Ctx) PIC16Section(Name, K, Address, Color); + PIC16Section *S = + new (Ctx) PIC16Section(StringRef(NameCopy, Name.size()), K, + StringRef(AddressCopy, Address.size()), Color); S->T = Ty; return S; } Modified: llvm/trunk/lib/Target/PIC16/PIC16Section.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.h?rev=99887&r1=99886&r2=99887&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.h Tue Mar 30 08:28:42 2010 @@ -30,11 +30,11 @@ PIC16SectionType T; /// Name of the section to uniquely identify it. - std::string Name; + StringRef Name; /// User can specify an address at which a section should be placed. /// Negative value here means user hasn't specified any. - std::string Address; + StringRef Address; /// Overlay information - Sections with same color can be overlaid on /// one another. @@ -43,17 +43,16 @@ /// Total size of all data objects contained here. unsigned Size; - PIC16Section(const StringRef &name, SectionKind K, const std::string &addr, - int color) + PIC16Section(StringRef name, SectionKind K, StringRef addr, int color) : MCSection(K), Name(name), Address(addr), Color(color), Size(0) { } public: /// Return the name of the section. - const std::string &getName() const { return Name; } + StringRef getName() const { return Name; } /// Return the Address of the section. - const std::string &getAddress() const { return Address; } + StringRef getAddress() const { return Address; } /// Return the Color of the section. int getColor() const { return Color; } @@ -77,8 +76,8 @@ PIC16SectionType getType() const { return T; } /// This would be the only way to create a section. - static PIC16Section *Create(const StringRef &Name, PIC16SectionType Ty, - const std::string &Address, int Color, + static PIC16Section *Create(StringRef Name, PIC16SectionType Ty, + StringRef Address, int Color, MCContext &Ctx); /// Override this as PIC16 has its own way of printing switching From edwintorok at gmail.com Tue Mar 30 09:01:41 2010 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 30 Mar 2010 17:01:41 +0300 Subject: [llvm-commits] [llvm] r99400 - in /llvm/trunk: lib/CodeGen/LiveIntervalAnalysis.cpp test/CodeGen/Generic/2010-03-24-liveintervalleak.ll In-Reply-To: <4BB1CA47.8000009@gmail.com> References: <20100324135036.CB2412A6C12C@llvm.org> <2004E368-7E33-4932-8135-48B6F6F610A8@2pi.dk> <0BB4DEE1-61E1-4B17-AA3E-2AA9255990F0@2pi.dk> <02E03C07-91C5-42C0-9A14-BCAAF154F997@apple.com> <4BB1CA47.8000009@gmail.com> Message-ID: <4BB20445.5040208@gmail.com> On 03/30/2010 12:54 PM, T?r?k Edwin wrote: > On 03/26/2010 02:29 AM, Jakob Stoklund Olesen wrote: >> On Mar 25, 2010, at 4:48 PM, Evan Cheng wrote: >> >>> On Mar 25, 2010, at 4:39 PM, Jakob Stoklund Olesen wrote: >>> >>>> On Mar 25, 2010, at 4:32 PM, Evan Cheng wrote: >>>> >>>>> On Mar 25, 2010, at 4:30 PM, Jakob Stoklund Olesen wrote: >>>>> >>>>>> On Mar 24, 2010, at 6:50 AM, Torok Edwin wrote: >>>>>> >>>>>>> Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp >>>>>>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99400&r1=99399&r2=99400&view=diff >>>>>>> ============================================================================== >>>>>>> --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) >>>>>>> +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Mar 24 08:50:36 2010 >>>>>>> @@ -85,8 +85,10 @@ >>>>>>> void LiveIntervals::releaseMemory() { >>>>>>> // Free the live intervals themselves. >>>>>>> for (DenseMap::iterator I = r2iMap_.begin(), >>>>>>> - E = r2iMap_.end(); I != E; ++I) >>>>>>> + E = r2iMap_.end(); I != E; ++I) { >>>>>>> + I->second->clear(); >>>>>>> delete I->second; >>>>>>> + } >>>>>>> >>>>>>> r2iMap_.clear(); >>>>>> I think LiveInterval::clear is broken. I calls VNI->~VNInfo(), but those VNIs can be referenced from multiple intervals. >>>>> Really? Multiple liveinterval's or liverange's? >>>> LiveIntervals. >>>> >>>> Is a VNI supposed to belong to only one LiveInterval? I don't know any concrete examples where that is not the case, but a lot of funny stuff is going on when coalescing. >>> I don't think VNI should be shared between liveinterval's. It may be shared temporarily during coalescing though. >> Let's call it a bug. In that case, clear() is fine, but a VNI is accidentally shared somewhere. >> >>> Either way, VNI are all bump allocated so the dtor should not be called? >> Yeah, but they contain a SmallVector that leaks if it is not destroyed. > > Adding more clear()s doesn't fix the leaks though, and sometimes I get > double-frees. > I don't really understand what happens with VNInfos after liveintervals > are joined. > > So instead of using clear() I tought BumpPtrAllocator to iterate over > all the allocated slabs, and call a destructor function. > In our case all the objects we allocate are of same size, so by simply > iterating on the slabs with that size (and alignment) we find the > pointers to all the VNInfos we allocated, and call their destructor. > > The valnos list doesn't seem to be reliable for that purpose. > > I'm testing the attached patch now. I've committed it in r99883. Let me know if it causes any problems (the initial version I committed in 99881 broke the buildbots). Best regards, --Edwin From benny.kra at googlemail.com Tue Mar 30 09:34:13 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 30 Mar 2010 14:34:13 -0000 Subject: [llvm-commits] [llvm] r99888 - in /llvm/trunk: lib/Target/PIC16/PIC16Section.h test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll test/CodeGen/PIC16/2009-11-20-NewNode.ll test/CodeGen/PIC16/C16-15.ll test/CodeGen/PIC16/global-in-user-section.ll test/CodeGen/PIC16/globals.ll test/CodeGen/PIC16/sext.ll Message-ID: <20100330143413.5CA222A6C12C@llvm.org> Author: d0k Date: Tue Mar 30 09:34:13 2010 New Revision: 99888 URL: http://llvm.org/viewvc/llvm-project?rev=99888&view=rev Log: XFAIL some PIC16 tests when running under valgrind-leaks. I don't expect these to be fixed any time soon. Modified: llvm/trunk/lib/Target/PIC16/PIC16Section.h llvm/trunk/test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll llvm/trunk/test/CodeGen/PIC16/2009-11-20-NewNode.ll llvm/trunk/test/CodeGen/PIC16/C16-15.ll llvm/trunk/test/CodeGen/PIC16/global-in-user-section.ll llvm/trunk/test/CodeGen/PIC16/globals.ll llvm/trunk/test/CodeGen/PIC16/sext.ll Modified: llvm/trunk/lib/Target/PIC16/PIC16Section.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Section.h?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16Section.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16Section.h Tue Mar 30 09:34:13 2010 @@ -63,6 +63,8 @@ void setSize(unsigned size) { Size = size; } /// Conatined data objects. + // FIXME: This vector is leaked because sections are allocated with a + // BumpPtrAllocator. std::vectorItems; /// Check section type. Modified: llvm/trunk/test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/2009-07-17-PR4566-pic16.ll Tue Mar 30 09:34:13 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=pic16 | FileCheck %s +; XFAIL: vg_leak target datalayout = "e-p:16:8:8-i8:8:8-i16:8:8-i32:8:8-f32:32:32" target triple = "pic16-" Modified: llvm/trunk/test/CodeGen/PIC16/2009-11-20-NewNode.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/2009-11-20-NewNode.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/2009-11-20-NewNode.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/2009-11-20-NewNode.ll Tue Mar 30 09:34:13 2010 @@ -1,5 +1,6 @@ ; RUN: llc -march=pic16 < %s ; PR5558 +; XFAIL: vg_leak define i64 @_strtoll_r(i16 %base) nounwind { entry: Modified: llvm/trunk/test/CodeGen/PIC16/C16-15.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/C16-15.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/C16-15.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/C16-15.ll Tue Mar 30 09:34:13 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=pic16 | grep "extern" | grep "@.lib.unordered.f32" | count 3 +; XFAIL: vg_leak @pc = global i8* inttoptr (i64 160 to i8*), align 1 ; [#uses=2] @aa = common global i16 0, align 1 ; [#uses=0] Modified: llvm/trunk/test/CodeGen/PIC16/global-in-user-section.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/global-in-user-section.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/global-in-user-section.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/global-in-user-section.ll Tue Mar 30 09:34:13 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=pic16 | FileCheck %s +; XFAIL: vg_leak @G1 = common global i16 0, section "usersection", align 1 ; CHECK: usersection UDATA Modified: llvm/trunk/test/CodeGen/PIC16/globals.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/globals.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/globals.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/globals.ll Tue Mar 30 09:34:13 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=pic16 | FileCheck %s +; XFAIL: vg_leak @G1 = global i32 4712, section "Address=412" ; CHECK: @G1.412..user_section.# IDATA 412 Modified: llvm/trunk/test/CodeGen/PIC16/sext.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PIC16/sext.ll?rev=99888&r1=99887&r2=99888&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PIC16/sext.ll (original) +++ llvm/trunk/test/CodeGen/PIC16/sext.ll Tue Mar 30 09:34:13 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -march=pic16 +; XFAIL: vg_leak @main.auto.c = internal global i8 0 ; [#uses=1] From criswell at uiuc.edu Tue Mar 30 10:53:05 2010 From: criswell at uiuc.edu (John Criswell) Date: Tue, 30 Mar 2010 15:53:05 -0000 Subject: [llvm-commits] [poolalloc] r99890 - /poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp Message-ID: <20100330155305.428902A6C12C@llvm.org> Author: criswell Date: Tue Mar 30 10:53:05 2010 New Revision: 99890 URL: http://llvm.org/viewvc/llvm-project?rev=99890&view=rev Log: Corrected the size of SAFECode pools (they are now 92 bytes in size). Like the PoolAllocate pass, enable SAFECode options by default. Modified: poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp Modified: poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp?rev=99890&r1=99889&r2=99890&view=diff ============================================================================== --- poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp (original) +++ poolalloc/branches/release_26/lib/PoolAllocate/PoolOptimize.cpp Tue Mar 30 10:53:05 2010 @@ -32,7 +32,7 @@ static char ID; bool SAFECodeEnabled; - PoolOptimize(bool SAFECode = false) : ModulePass((intptr_t)&ID) { + PoolOptimize(bool SAFECode = true) : ModulePass((intptr_t)&ID) { SAFECodeEnabled = SAFECode; } bool runOnModule(Module &M); @@ -72,7 +72,7 @@ const Type *VoidPtrTy = PointerType::getUnqual(Int8Type); const Type *PoolDescPtrTy; if (SAFECodeEnabled) - PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 50)); + PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 92)); else PoolDescPtrTy = PointerType::getUnqual(ArrayType::get(VoidPtrTy, 16)); From kremenek at apple.com Tue Mar 30 11:20:04 2010 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 30 Mar 2010 16:20:04 -0000 Subject: [llvm-commits] [llvm] r99892 - /llvm/trunk/include/llvm/ADT/PointerUnion.h Message-ID: <20100330162004.0BC082A6C12C@llvm.org> Author: kremenek Date: Tue Mar 30 11:20:03 2010 New Revision: 99892 URL: http://llvm.org/viewvc/llvm-project?rev=99892&view=rev Log: Change PointerUnionX::getFromOpaqueValue() to be declared 'static inline' instead of 'static'. Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h Modified: llvm/trunk/include/llvm/ADT/PointerUnion.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/PointerUnion.h?rev=99892&r1=99891&r2=99892&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/PointerUnion.h (original) +++ llvm/trunk/include/llvm/ADT/PointerUnion.h Tue Mar 30 11:20:03 2010 @@ -124,7 +124,7 @@ } void *getOpaqueValue() const { return Val.getOpaqueValue(); } - static PointerUnion getFromOpaqueValue(void *VP) { + static inline PointerUnion getFromOpaqueValue(void *VP) { PointerUnion V; V.Val = ValTy::getFromOpaqueValue(VP); return V; @@ -227,7 +227,7 @@ } void *getOpaqueValue() const { return Val.getOpaqueValue(); } - static PointerUnion3 getFromOpaqueValue(void *VP) { + static inline PointerUnion3 getFromOpaqueValue(void *VP) { PointerUnion3 V; V.Val = ValTy::getFromOpaqueValue(VP); return V; @@ -338,7 +338,7 @@ } void *getOpaqueValue() const { return Val.getOpaqueValue(); } - static PointerUnion4 getFromOpaqueValue(void *VP) { + static inline PointerUnion4 getFromOpaqueValue(void *VP) { PointerUnion4 V; V.Val = ValTy::getFromOpaqueValue(VP); return V; From stoklund at 2pi.dk Tue Mar 30 11:32:49 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 09:32:49 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: <20100330111748.9148F2A6C12C@llvm.org> References: <20100330111748.9148F2A6C12C@llvm.org> Message-ID: On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote: > Author: edwin > Date: Tue Mar 30 06:17:48 2010 > New Revision: 99883 > > URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev > Log: > Reapply r99881 with some fixes: only call destructor in releaseMemory! > > Modified: > llvm/trunk/include/llvm/CodeGen/LiveInterval.h > llvm/trunk/include/llvm/Support/Allocator.h > llvm/trunk/lib/CodeGen/LiveInterval.cpp > llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > llvm/trunk/lib/Support/Allocator.cpp Hi T?r?k, It is OK to defer destruction of VNInfos, and I think it is a good idea with a BumpPtrAllocator that can destroy all elements, but the current implementation seems unsafe. It only works correctly if everything allocated is of the same type and size. Given the operator new() at the bottom of Allocator.h, that seems like a risky assertion. A template class that is only capable of allocating one type would be safer. /jakob From edwintorok at gmail.com Tue Mar 30 11:49:15 2010 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Tue, 30 Mar 2010 19:49:15 +0300 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: References: <20100330111748.9148F2A6C12C@llvm.org> Message-ID: <4BB22B8B.7010002@gmail.com> On 03/30/2010 07:32 PM, Jakob Stoklund Olesen wrote: > On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote: > >> Author: edwin >> Date: Tue Mar 30 06:17:48 2010 >> New Revision: 99883 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev >> Log: >> Reapply r99881 with some fixes: only call destructor in releaseMemory! >> >> Modified: >> llvm/trunk/include/llvm/CodeGen/LiveInterval.h >> llvm/trunk/include/llvm/Support/Allocator.h >> llvm/trunk/lib/CodeGen/LiveInterval.cpp >> llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp >> llvm/trunk/lib/Support/Allocator.cpp > > Hi T?r?k, > > It is OK to defer destruction of VNInfos, and I think it is a good idea with a BumpPtrAllocator that can destroy all elements, but the current implementation seems unsafe. It only works correctly if everything allocated is of the same type and size. Hi, I think it is safe in the VNInfo case, but a more general solution is better of course. > > Given the operator new() at the bottom of Allocator.h, that seems like a risky assertion. That wasn't there on the 2.7 branch. > > A template class that is only capable of allocating one type would be safer. Sounds good, the template could automatically call the destructor when Reset() is called, without the need for the special Reset() method. I won't have time to work on this for the next days, so if you want to make these changes please do. Best regards, --Edwin From stoklund at 2pi.dk Tue Mar 30 12:00:12 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 10:00:12 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: <4BB22B8B.7010002@gmail.com> References: <20100330111748.9148F2A6C12C@llvm.org> <4BB22B8B.7010002@gmail.com> Message-ID: <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> On Mar 30, 2010, at 9:49 AM, T?r?k Edwin wrote: > On 03/30/2010 07:32 PM, Jakob Stoklund Olesen wrote: >> A template class that is only capable of allocating one type would be safer. > > Sounds good, the template could automatically call the destructor when > Reset() is called, without the need for the special Reset() method. > > I won't have time to work on this for the next days, so if you want to > make these changes please do. Please take a look when you get the time. Thanks, /jakob From echristo at apple.com Tue Mar 30 12:23:10 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 10:23:10 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <20100330010459.500622A6C12C@llvm.org> Message-ID: <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> On Mar 29, 2010, at 7:07 PM, Chris Lattner wrote: > > On Mar 29, 2010, at 6:04 PM, Eric Christopher wrote: > >> Author: echristo >> Date: Mon Mar 29 20:04:59 2010 >> New Revision: 99859 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=99859&view=rev >> Log: >> Add FIXME for operand promotion. > > What is this talking about? Basic idea is that loop is canonicalizing all loads (etc) to v2i64. This means that to match we've got some weird casts around that wouldn't need to be there if we just left them as whatever type they were. This is why we see, for example, the bc_v4i32 cast used all over the place in X86InstrSSE.td for things not sse2 to get them to match. -eric From dgregor at apple.com Tue Mar 30 12:32:08 2010 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 30 Mar 2010 17:32:08 -0000 Subject: [llvm-commits] [llvm] r99893 - in /llvm/trunk: include/llvm/ADT/Statistic.h lib/Support/Statistic.cpp Message-ID: <20100330173208.3419B2A6C12C@llvm.org> Author: dgregor Date: Tue Mar 30 12:32:08 2010 New Revision: 99893 URL: http://llvm.org/viewvc/llvm-project?rev=99893&view=rev Log: Introduce namespace-scope functions to enable LLVM statistics without passing the command-line parameter "-stats" and to print the resulting statistics without calling llvm_shutdown(). Modified: llvm/trunk/include/llvm/ADT/Statistic.h llvm/trunk/lib/Support/Statistic.cpp Modified: llvm/trunk/include/llvm/ADT/Statistic.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Statistic.h?rev=99893&r1=99892&r2=99893&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Statistic.h (original) +++ llvm/trunk/include/llvm/ADT/Statistic.h Tue Mar 30 12:32:08 2010 @@ -29,6 +29,7 @@ #include "llvm/System/Atomic.h" namespace llvm { +class raw_ostream; class Statistic { public: @@ -113,6 +114,15 @@ #define STATISTIC(VARNAME, DESC) \ static llvm::Statistic VARNAME = { DEBUG_TYPE, DESC, 0, 0 } +/// \brief Enable the collection and printing of statistics. +void EnableStatistics(); + +/// \brief Print statistics to the file returned by CreateInfoOutputFile(). +void PrintStatistics(); + +/// \brief Print statistics to the given output stream. +void PrintStatistics(raw_ostream &OS); + } // End llvm namespace #endif Modified: llvm/trunk/lib/Support/Statistic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=99893&r1=99892&r2=99893&view=diff ============================================================================== --- llvm/trunk/lib/Support/Statistic.cpp (original) +++ llvm/trunk/lib/Support/Statistic.cpp Tue Mar 30 12:32:08 2010 @@ -48,6 +48,8 @@ /// llvm_shutdown is called. We print statistics from the destructor. class StatisticInfo { std::vector Stats; + friend void llvm::PrintStatistics(); + friend void llvm::PrintStatistics(raw_ostream &OS); public: ~StatisticInfo(); @@ -92,41 +94,55 @@ // Print information when destroyed, iff command line option is specified. StatisticInfo::~StatisticInfo() { - // Statistics not enabled? - if (Stats.empty()) return; + llvm::PrintStatistics(); +} - // Get the stream to write to. - raw_ostream &OutStream = *CreateInfoOutputFile(); +void llvm::EnableStatistics() { + Enabled.setValue(true); +} + +void llvm::PrintStatistics(raw_ostream &OS) { + StatisticInfo &Stats = *StatInfo; // Figure out how long the biggest Value and Name fields are. unsigned MaxNameLen = 0, MaxValLen = 0; - for (size_t i = 0, e = Stats.size(); i != e; ++i) { + for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) { MaxValLen = std::max(MaxValLen, - (unsigned)utostr(Stats[i]->getValue()).size()); + (unsigned)utostr(Stats.Stats[i]->getValue()).size()); MaxNameLen = std::max(MaxNameLen, - (unsigned)std::strlen(Stats[i]->getName())); + (unsigned)std::strlen(Stats.Stats[i]->getName())); } // Sort the fields by name. - std::stable_sort(Stats.begin(), Stats.end(), NameCompare()); + std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(), NameCompare()); // Print out the statistics header... - OutStream << "===" << std::string(73, '-') << "===\n" - << " ... Statistics Collected ...\n" - << "===" << std::string(73, '-') << "===\n\n"; + OS << "===" << std::string(73, '-') << "===\n" + << " ... Statistics Collected ...\n" + << "===" << std::string(73, '-') << "===\n\n"; // Print all of the statistics. - for (size_t i = 0, e = Stats.size(); i != e; ++i) { - std::string CountStr = utostr(Stats[i]->getValue()); - OutStream << std::string(MaxValLen-CountStr.size(), ' ') - << CountStr << " " << Stats[i]->getName() - << std::string(MaxNameLen-std::strlen(Stats[i]->getName()), ' ') - << " - " << Stats[i]->getDesc() << "\n"; - + for (size_t i = 0, e = Stats.Stats.size(); i != e; ++i) { + std::string CountStr = utostr(Stats.Stats[i]->getValue()); + OS << std::string(MaxValLen-CountStr.size(), ' ') + << CountStr << " " << Stats.Stats[i]->getName() + << std::string(MaxNameLen-std::strlen(Stats.Stats[i]->getName()), ' ') + << " - " << Stats.Stats[i]->getDesc() << "\n"; } - OutStream << '\n'; // Flush the output stream. - OutStream.flush(); - + OS << '\n'; // Flush the output stream. + OS.flush(); + +} + +void llvm::PrintStatistics() { + StatisticInfo &Stats = *StatInfo; + + // Statistics not enabled? + if (Stats.Stats.empty()) return; + + // Get the stream to write to. + raw_ostream &OutStream = *CreateInfoOutputFile(); + PrintStatistics(OutStream); delete &OutStream; // Close the file. } From kremenek at apple.com Tue Mar 30 12:49:36 2010 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 30 Mar 2010 10:49:36 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: <20100330111748.9148F2A6C12C@llvm.org> References: <20100330111748.9148F2A6C12C@llvm.org> Message-ID: <09A2327E-E0FB-42A3-BF96-C1456D636699@apple.com> Hi Edwin, I'm now getting an "unused variable 'VNI'" warning, which is breaking my -Werror builds. Can the declaration of 'VNI' be removed? Ted On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote: > Author: edwin > Date: Tue Mar 30 06:17:48 2010 > New Revision: 99883 > > URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev > Log: > Reapply r99881 with some fixes: only call destructor in releaseMemory! > > Modified: > llvm/trunk/include/llvm/CodeGen/LiveInterval.h > llvm/trunk/include/llvm/Support/Allocator.h > llvm/trunk/lib/CodeGen/LiveInterval.cpp > llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > llvm/trunk/lib/Support/Allocator.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) > +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Mar 30 06:17:48 2010 > @@ -330,12 +330,7 @@ > } > > void clear() { > - while (!valnos.empty()) { > - VNInfo *VNI = valnos.back(); > - valnos.pop_back(); > - VNI->~VNInfo(); > - } > - > + valnos.clear(); > ranges.clear(); > } > > > Modified: llvm/trunk/include/llvm/Support/Allocator.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/Allocator.h (original) > +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 06:17:48 2010 > @@ -134,6 +134,7 @@ > static MallocSlabAllocator DefaultSlabAllocator; > > public: > + typedef void (*DTorFunction)(void*); > BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, > SlabAllocator &allocator = DefaultSlabAllocator); > ~BumpPtrAllocator(); > @@ -142,6 +143,11 @@ > /// to the beginning of it, freeing all memory allocated so far. > void Reset(); > > + /// Reset - like Reset(), but call DTorFunction for each allocated > + /// object. This assumes that all objects allocated with this allocator > + /// had the same size and alignment specified here. > + void Reset(size_t Size, size_t Alignment, DTorFunction DTor); > + > /// Allocate - Allocate space at the specified alignment. > /// > void *Allocate(size_t Size, size_t Alignment); > > Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 06:17:48 2010 > @@ -305,7 +305,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > ValNo->setIsUnused(true); > @@ -353,7 +352,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > ValNo->setIsUnused(true); > @@ -581,7 +579,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > V1->setIsUnused(true); > @@ -658,7 +655,6 @@ > if (UnusedValNo) { > // Delete the last unused val#. > valnos.pop_back(); > - UnusedValNo->~VNInfo(); > } > } > > @@ -751,7 +747,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (valnos.back()->isUnused()); > } else { > V1->setIsUnused(true); > > Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 06:17:48 2010 > @@ -82,6 +82,11 @@ > MachineFunctionPass::getAnalysisUsage(AU); > } > > +static void VNInfoDTor(void* Ptr) > +{ > + reinterpret_cast(Ptr)->~VNInfo(); > +} > + > void LiveIntervals::releaseMemory() { > // Free the live intervals themselves. > for (DenseMap::iterator I = r2iMap_.begin(), > @@ -91,7 +96,7 @@ > r2iMap_.clear(); > > // Release VNInfo memroy regions after all VNInfo objects are dtor'd. > - VNInfoAllocator.Reset(); > + VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); > while (!CloneMIs.empty()) { > MachineInstr *MI = CloneMIs.back(); > CloneMIs.pop_back(); > > Modified: llvm/trunk/lib/Support/Allocator.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/Support/Allocator.cpp (original) > +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 06:17:48 2010 > @@ -78,6 +78,21 @@ > End = ((char*)CurSlab) + CurSlab->Size; > } > > +void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { > + if (Alignment == 0) Alignment = 1; > + MemSlab *Slab = CurSlab; > + while (Slab) { > + char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; > + for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { > + Ptr = AlignPtr(Ptr, Alignment); > + if (Ptr + Size <= End) > + DTor(Ptr); > + } > + Slab = Slab->NextPtr; > + } > + Reset(); > +} > + > /// Allocate - Allocate space at the specified alignment. > /// > void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Tue Mar 30 12:57:42 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 30 Mar 2010 17:57:42 -0000 Subject: [llvm-commits] [llvm] r99895 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp Message-ID: <20100330175742.5E9282A6C12C@llvm.org> Author: ddunbar Date: Tue Mar 30 12:57:42 2010 New Revision: 99895 URL: http://llvm.org/viewvc/llvm-project?rev=99895&view=rev Log: Fix -Asserts warning. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99895&r1=99894&r2=99895&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 12:57:42 2010 @@ -303,7 +303,6 @@ // otherwise mark it as ~1U so it can be nuked later. if (ValNo->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -350,7 +349,6 @@ // otherwise mark it as ~1U so it can be nuked later. if (ValNo->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -577,7 +575,6 @@ // mark it as ~1U so it can be nuked later. if (V1->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (!valnos.empty() && valnos.back()->isUnused()); } else { @@ -745,7 +742,6 @@ // ~1U so it can be nuked later. if (V1->id == getNumValNums()-1) { do { - VNInfo *VNI = valnos.back(); valnos.pop_back(); } while (valnos.back()->isUnused()); } else { From daniel at zuster.org Tue Mar 30 13:02:37 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 30 Mar 2010 18:02:37 -0000 Subject: [llvm-commits] [test-suite] r99897 - in /test-suite/trunk/External: Makefile SPEC/CFP2006/Makefile SPEC/CINT2000/Makefile SPEC/CINT2006/Makefile Message-ID: <20100330180237.D81662A6C12C@llvm.org> Author: ddunbar Date: Tue Mar 30 13:02:37 2010 New Revision: 99897 URL: http://llvm.org/viewvc/llvm-project?rev=99897&view=rev Log: Remove stray executable bit on some External Makefiles. Modified: test-suite/trunk/External/Makefile (contents, props changed) test-suite/trunk/External/SPEC/CFP2006/Makefile (contents, props changed) test-suite/trunk/External/SPEC/CINT2000/Makefile (contents, props changed) test-suite/trunk/External/SPEC/CINT2006/Makefile (contents, props changed) Modified: test-suite/trunk/External/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/Makefile?rev=99897&r1=99896&r2=99897&view=diff ============================================================================== (empty) Propchange: test-suite/trunk/External/Makefile ------------------------------------------------------------------------------ --- svn:executable (original) +++ svn:executable (removed) @@ -1 +0,0 @@ -* Modified: test-suite/trunk/External/SPEC/CFP2006/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/SPEC/CFP2006/Makefile?rev=99897&r1=99896&r2=99897&view=diff ============================================================================== (empty) Propchange: test-suite/trunk/External/SPEC/CFP2006/Makefile ------------------------------------------------------------------------------ --- svn:executable (original) +++ svn:executable (removed) @@ -1 +0,0 @@ -* Modified: test-suite/trunk/External/SPEC/CINT2000/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/SPEC/CINT2000/Makefile?rev=99897&r1=99896&r2=99897&view=diff ============================================================================== (empty) Propchange: test-suite/trunk/External/SPEC/CINT2000/Makefile ------------------------------------------------------------------------------ --- svn:executable (original) +++ svn:executable (removed) @@ -1 +0,0 @@ -* Modified: test-suite/trunk/External/SPEC/CINT2006/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/External/SPEC/CINT2006/Makefile?rev=99897&r1=99896&r2=99897&view=diff ============================================================================== (empty) Propchange: test-suite/trunk/External/SPEC/CINT2006/Makefile ------------------------------------------------------------------------------ --- svn:executable (original) +++ svn:executable (removed) @@ -1 +0,0 @@ -* From dgregor at apple.com Tue Mar 30 13:05:52 2010 From: dgregor at apple.com (Douglas Gregor) Date: Tue, 30 Mar 2010 18:05:52 -0000 Subject: [llvm-commits] [llvm] r99898 - in /llvm/trunk/include/llvm: Support/Casting.h Type.h Value.h Message-ID: <20100330180552.AB5692A6C12C@llvm.org> Author: dgregor Date: Tue Mar 30 13:05:52 2010 New Revision: 99898 URL: http://llvm.org/viewvc/llvm-project?rev=99898&view=rev Log: Switch isa_impl from a function template to a class template with a static inline member function doit(). This enables the use of partial specialization to override the last stage of the "isa" check. Modified: llvm/trunk/include/llvm/Support/Casting.h llvm/trunk/include/llvm/Type.h llvm/trunk/include/llvm/Value.h Modified: llvm/trunk/include/llvm/Support/Casting.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Casting.h?rev=99898&r1=99897&r2=99898&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Casting.h (original) +++ llvm/trunk/include/llvm/Support/Casting.h Tue Mar 30 13:05:52 2010 @@ -50,9 +50,11 @@ // if (isa(myVal)) { ... } // template -inline bool isa_impl(const From &Val) { - return To::classof(&Val); -} +struct isa_impl { + static inline bool doit(const From &Val) { + return To::classof(&Val); + } +}; template struct isa_impl_wrap { @@ -68,7 +70,7 @@ struct isa_impl_wrap { // When From == SimpleType, we are as simple as we are going to get. static bool doit(const FromTy &Val) { - return isa_impl(Val); + return isa_impl::doit(Val); } }; @@ -251,10 +253,12 @@ }*/ }; -template <> inline bool isa_impl(const bar &Val) { - dbgs() << "Classof: " << &Val << "\n"; - return true; -} +template <> struct isa_impl { + static inline bool doit(const bar &Val) { + dbgs() << "Classof: " << &Val << "\n"; + return true; + } +}; bar *fub(); Modified: llvm/trunk/include/llvm/Type.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Type.h?rev=99898&r1=99897&r2=99898&view=diff ============================================================================== --- llvm/trunk/include/llvm/Type.h (original) +++ llvm/trunk/include/llvm/Type.h Tue Mar 30 13:05:52 2010 @@ -548,9 +548,11 @@ } }; -template <> inline bool isa_impl(const Type &Ty) { - return Ty.getTypeID() == Type::PointerTyID; -} +template <> struct isa_impl { + static inline bool doit(const Type &Ty) { + return Ty.getTypeID() == Type::PointerTyID; + } +}; raw_ostream &operator<<(raw_ostream &OS, const Type &T); Modified: llvm/trunk/include/llvm/Value.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Value.h?rev=99898&r1=99897&r2=99898&view=diff ============================================================================== --- llvm/trunk/include/llvm/Value.h (original) +++ llvm/trunk/include/llvm/Value.h Tue Mar 30 13:05:52 2010 @@ -324,39 +324,67 @@ // isa - Provide some specializations of isa so that we don't have to include // the subtype header files to test to see if the value is a subclass... // -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() >= Value::ConstantFirstVal && - Val.getValueID() <= Value::ConstantLastVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::ArgumentVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::InlineAsmVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() >= Value::InstructionVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::BasicBlockVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::FunctionVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::GlobalVariableVal; -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::GlobalAliasVal; -} -template <> inline bool isa_impl(const Value &Val) { - return isa(Val) || isa(Val) || - isa(Val); -} -template <> inline bool isa_impl(const Value &Val) { - return Val.getValueID() == Value::MDNodeVal; -} - +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() >= Value::ConstantFirstVal && + Val.getValueID() <= Value::ConstantLastVal; + } +}; + +template <> struct isa_impl { + static inline bool doit (const Value &Val) { + return Val.getValueID() == Value::ArgumentVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::InlineAsmVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() >= Value::InstructionVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::BasicBlockVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::FunctionVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::GlobalVariableVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::GlobalAliasVal; + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return isa(Val) || isa(Val) || + isa(Val); + } +}; + +template <> struct isa_impl { + static inline bool doit(const Value &Val) { + return Val.getValueID() == Value::MDNodeVal; + } +}; // Value* is only 4-byte aligned. template<> From dpatel at apple.com Tue Mar 30 13:07:00 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 30 Mar 2010 18:07:00 -0000 Subject: [llvm-commits] [llvm] r99899 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100330180700.9EC462A6C12C@llvm.org> Author: dpatel Date: Tue Mar 30 13:07:00 2010 New Revision: 99899 URL: http://llvm.org/viewvc/llvm-project?rev=99899&view=rev Log: There is no need to fall through after processing DBG_VALUE machine instruction. 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=99899&r1=99898&r2=99899&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 30 13:07:00 2010 @@ -2067,6 +2067,7 @@ DILoc.getScope().getNode()); DI->second->setDbgValueLabel(Label); } + return; } // Emit a label to indicate location change. This is used for line From evan.cheng at apple.com Tue Mar 30 13:08:53 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 30 Mar 2010 18:08:53 -0000 Subject: [llvm-commits] [llvm] r99901 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <20100330180854.02A112A6C12C@llvm.org> Author: evancheng Date: Tue Mar 30 13:08:53 2010 New Revision: 99901 URL: http://llvm.org/viewvc/llvm-project?rev=99901&view=rev Log: Funky indentation. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99901&r1=99900&r2=99901&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Mar 30 13:08:53 2010 @@ -3273,11 +3273,11 @@ } static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, - SDValue Chain, SDValue Dst, - SDValue Src, uint64_t Size, - unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstSVOff, - const Value *SrcSV, uint64_t SrcSVOff){ + SDValue Chain, SDValue Dst, + SDValue Src, uint64_t Size, + unsigned Align, bool AlwaysInline, + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Expand memcpy to a series of load and store ops if the size operand falls From sabre at nondot.org Tue Mar 30 13:10:53 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 18:10:53 -0000 Subject: [llvm-commits] [llvm] r99902 - in /llvm/trunk: include/llvm/MC/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/MC/ lib/MC/MCParser/ lib/Target/ lib/Target/ARM/AsmPrinter/ lib/Target/MSP430/AsmPrinter/ lib/Target/PowerPC/AsmPrinter/ lib/Target/X86/ lib/Target/X86/AsmPrinter/ Message-ID: <20100330181053.B08C82A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 13:10:53 2010 New Revision: 99902 URL: http://llvm.org/viewvc/llvm-project?rev=99902&view=rev Log: Rip out the 'is temporary' nonsense from the MCContext interface to create symbols. It is extremely error prone and a source of a lot of the remaining integrated assembler bugs on x86-64. This fixes rdar://7807601. Modified: llvm/trunk/include/llvm/MC/MCContext.h llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/MC/MCContext.cpp llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/MC/MCParser/AsmParser.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp llvm/trunk/lib/Target/Mangler.cpp llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/include/llvm/MC/MCContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCContext.h (original) +++ llvm/trunk/include/llvm/MC/MCContext.h Tue Mar 30 13:10:53 2010 @@ -65,19 +65,8 @@ /// reference and return it. /// /// @param Name - The symbol name, which must be unique across all symbols. - MCSymbol *GetOrCreateSymbol(StringRef Name, bool isTemporary = false); - MCSymbol *GetOrCreateSymbol(const Twine &Name, bool isTemporary = false); - - /// GetOrCreateTemporarySymbol - Create a new assembler temporary symbol - /// with the specified @p Name if it doesn't exist or return the existing - /// one if it does. - /// - /// @param Name - The symbol name, for debugging purposes only, temporary - /// symbols do not surive assembly. - MCSymbol *GetOrCreateTemporarySymbol(StringRef Name) { - return GetOrCreateSymbol(Name, true); - } - MCSymbol *GetOrCreateTemporarySymbol(const Twine &Name); + MCSymbol *GetOrCreateSymbol(StringRef Name); + MCSymbol *GetOrCreateSymbol(const Twine &Name); /// LookupSymbol - Get the symbol for \p Name, or null. MCSymbol *LookupSymbol(StringRef Name) const; Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Tue Mar 30 13:10:53 2010 @@ -160,11 +160,6 @@ static const MCSymbolRefExpr *Create(StringRef Name, VariantKind Kind, MCContext &Ctx); - /// CreateTemp - Create a reference to an assembler temporary label with the - /// specified name. - static const MCSymbolRefExpr *CreateTemp(StringRef Name, VariantKind Kind, - MCContext &Ctx); - /// @} /// @name Accessors /// @{ Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Mar 30 13:10:53 2010 @@ -922,8 +922,8 @@ // Otherwise, emit with .set (aka assignment). MCSymbol *SetLabel = - OutContext.GetOrCreateTemporarySymbol(Twine(MAI->getPrivateGlobalPrefix()) + - "set" + Twine(SetCounter++)); + OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + + "set" + Twine(SetCounter++)); OutStreamer.EmitAssignment(SetLabel, Diff); OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/); } @@ -1599,7 +1599,7 @@ /// GetCPISymbol - Return the symbol for the specified constant pool entry. MCSymbol *AsmPrinter::GetCPISymbol(unsigned CPID) const { - return OutContext.GetOrCreateTemporarySymbol + return OutContext.GetOrCreateSymbol (Twine(MAI->getPrivateGlobalPrefix()) + "CPI" + Twine(getFunctionNumber()) + "_" + Twine(CPID)); } @@ -1612,7 +1612,7 @@ /// GetJTSetSymbol - Return the symbol for the specified jump table .set /// FIXME: privatize to AsmPrinter. MCSymbol *AsmPrinter::GetJTSetSymbol(unsigned UID, unsigned MBBID) const { - return OutContext.GetOrCreateTemporarySymbol + return OutContext.GetOrCreateSymbol (Twine(MAI->getPrivateGlobalPrefix()) + Twine(getFunctionNumber()) + "_" + Twine(UID) + "_set_" + Twine(MBBID)); } @@ -1626,9 +1626,7 @@ SmallString<60> NameStr; Mang->getNameWithPrefix(NameStr, GV, ForcePrivate); NameStr.append(Suffix.begin(), Suffix.end()); - if (!GV->hasPrivateLinkage() && !ForcePrivate) - return OutContext.GetOrCreateSymbol(NameStr.str()); - return OutContext.GetOrCreateTemporarySymbol(NameStr.str()); + return OutContext.GetOrCreateSymbol(NameStr.str()); } /// GetExternalSymbolSymbol - Return the MCSymbol for the specified Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp Tue Mar 30 13:10:53 2010 @@ -45,14 +45,14 @@ //assert(ID && "Should use getTempLabel if no ID"); if (ID == 0) return getTempLabel(Name); - return Asm->OutContext.GetOrCreateTemporarySymbol + return Asm->OutContext.GetOrCreateSymbol (Twine(MAI->getPrivateGlobalPrefix()) + Twine(Name) + Twine(ID)); } /// getTempLabel - Return the MCSymbol corresponding to the assembler temporary /// label with the specified name. MCSymbol *DwarfPrinter::getTempLabel(const char *Name) const { - return Asm->OutContext.GetOrCreateTemporarySymbol + return Asm->OutContext.GetOrCreateSymbol (Twine(MAI->getPrivateGlobalPrefix()) + Name); } Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Mar 30 13:10:53 2010 @@ -45,9 +45,9 @@ const MachineFunction *MF = getParent(); MCContext &Ctx = MF->getContext(); const char *Prefix = Ctx.getAsmInfo().getPrivateGlobalPrefix(); - return Ctx.GetOrCreateTemporarySymbol(Twine(Prefix) + "BB" + - Twine(MF->getFunctionNumber()) + "_" + - Twine(getNumber())); + return Ctx.GetOrCreateSymbol(Twine(Prefix) + "BB" + + Twine(MF->getFunctionNumber()) + "_" + + Twine(getNumber())); } Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Tue Mar 30 13:10:53 2010 @@ -460,9 +460,7 @@ SmallString<60> Name; raw_svector_ostream(Name) << Prefix << "JTI" << getFunctionNumber() << '_' << JTI; - if (isLinkerPrivate) - return Ctx.GetOrCreateSymbol(Name.str()); - return Ctx.GetOrCreateTemporarySymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Tue Mar 30 13:10:53 2010 @@ -406,7 +406,7 @@ // Add information about the stub reference to ELFMMI so that the stub // gets emitted by the asmprinter. - MCSymbol *SSym = getContext().GetOrCreateTemporarySymbol(Name.str()); + MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str()); MachineModuleInfoImpl::StubValueTy &StubSym = ELFMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { MCSymbol *Sym = Mang->getSymbol(GV); @@ -759,7 +759,7 @@ // Add information about the stub reference to MachOMMI so that the stub // gets emitted by the asmprinter. - MCSymbol *SSym = getContext().GetOrCreateTemporarySymbol(Name.str()); + MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str()); MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); if (StubSym.getPointer() == 0) { MCSymbol *Sym = Mang->getSymbol(GV); Modified: llvm/trunk/lib/MC/MCContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCContext.cpp (original) +++ llvm/trunk/lib/MC/MCContext.cpp Tue Mar 30 13:10:53 2010 @@ -23,9 +23,12 @@ // we don't need to free them here. } -MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name, bool isTemporary) { +MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) { assert(!Name.empty() && "Normal symbols cannot be unnamed!"); + // Determine whether this is an assembler temporary or normal label. + bool isTemporary = Name.startswith(MAI.getPrivateGlobalPrefix()); + // Do the lookup and get the entire StringMapEntry. We want access to the // key if we are creating the entry. StringMapEntry &Entry = Symbols.GetOrCreateValue(Name); @@ -38,24 +41,17 @@ return Result; } -MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name, bool isTemporary) { +MCSymbol *MCContext::GetOrCreateSymbol(const Twine &Name) { SmallString<128> NameSV; Name.toVector(NameSV); - return GetOrCreateSymbol(NameSV.str(), isTemporary); + return GetOrCreateSymbol(NameSV.str()); } MCSymbol *MCContext::CreateTempSymbol() { - return GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix()) + - "tmp" + Twine(NextUniqueID++)); -} - -MCSymbol *MCContext::GetOrCreateTemporarySymbol(const Twine &Name) { - SmallString<128> NameSV; - Name.toVector(NameSV); - return GetOrCreateTemporarySymbol(NameSV.str()); + return GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix()) + + "tmp" + Twine(NextUniqueID++)); } - MCSymbol *MCContext::LookupSymbol(StringRef Name) const { return Symbols.lookup(Name); } Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Tue Mar 30 13:10:53 2010 @@ -154,12 +154,6 @@ return Create(Ctx.GetOrCreateSymbol(Name), Kind, Ctx); } -const MCSymbolRefExpr *MCSymbolRefExpr::CreateTemp(StringRef Name, - VariantKind Kind, - MCContext &Ctx) { - return Create(Ctx.GetOrCreateTemporarySymbol(Name), Kind, Ctx); -} - StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) { switch (Kind) { default: Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Mar 30 13:10:53 2010 @@ -238,9 +238,7 @@ } MCSymbol *AsmParser::CreateSymbol(StringRef Name) { - // If the label starts with L it is an assembler temporary label. - if (Name.startswith("L")) - return Ctx.GetOrCreateTemporarySymbol(Name); + // FIXME: Inline into callers. return Ctx.GetOrCreateSymbol(Name); } Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Tue Mar 30 13:10:53 2010 @@ -841,7 +841,7 @@ raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << getFunctionNumber() << '_' << uid << '_' << uid2 << "_set_" << MBB->getNumber(); - return OutContext.GetOrCreateTemporarySymbol(Name.str()); + return OutContext.GetOrCreateSymbol(Name.str()); } MCSymbol *ARMAsmPrinter:: @@ -849,7 +849,7 @@ SmallString<60> Name; raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_' << uid << '_' << uid2; - return OutContext.GetOrCreateTemporarySymbol(Name.str()); + return OutContext.GetOrCreateSymbol(Name.str()); } void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNum) { @@ -1186,7 +1186,7 @@ // FIXME: MOVE TO SHARED PLACE. unsigned Id = (unsigned)MI->getOperand(2).getImm(); const char *Prefix = MAI->getPrivateGlobalPrefix(); - MCSymbol *Label =OutContext.GetOrCreateTemporarySymbol(Twine(Prefix) + MCSymbol *Label =OutContext.GetOrCreateSymbol(Twine(Prefix) + "PC" + Twine(getFunctionNumber()) + "_" + Twine(Id)); OutStreamer.EmitLabel(Label); Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMMCInstLower.cpp Tue Mar 30 13:10:53 2010 @@ -75,7 +75,7 @@ #endif // Create a symbol for the name. - return Ctx.GetOrCreateTemporarySymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } MCSymbol *ARMMCInstLower:: @@ -91,7 +91,7 @@ #endif // Create a symbol for the name. - return Ctx.GetOrCreateTemporarySymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } MCOperand ARMMCInstLower:: Modified: llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/MSP430/AsmPrinter/MSP430MCInstLower.cpp Tue Mar 30 13:10:53 2010 @@ -59,7 +59,7 @@ } // Create a symbol for the name. - return Ctx.GetOrCreateTemporarySymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } MCSymbol *MSP430MCInstLower:: @@ -75,7 +75,7 @@ } // Create a symbol for the name. - return Ctx.GetOrCreateTemporarySymbol(Name.str()); + return Ctx.GetOrCreateSymbol(Name.str()); } MCOperand MSP430MCInstLower:: Modified: llvm/trunk/lib/Target/Mangler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mangler.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mangler.cpp (original) +++ llvm/trunk/lib/Target/Mangler.cpp Tue Mar 30 13:10:53 2010 @@ -235,10 +235,7 @@ MCSymbol *Mangler::getSymbol(const GlobalValue *GV) { SmallString<60> NameStr; getNameWithPrefix(NameStr, GV, false); - if (!GV->hasPrivateLinkage()) - return Context.GetOrCreateSymbol(NameStr.str()); - - return Context.GetOrCreateTemporarySymbol(NameStr.str()); + return Context.GetOrCreateSymbol(NameStr.str()); } Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Tue Mar 30 13:10:53 2010 @@ -309,8 +309,8 @@ const MCSymbol *&TOCEntry = TOC[Sym]; if (TOCEntry == 0) TOCEntry = OutContext. - GetOrCreateTemporarySymbol(StringRef(MAI->getPrivateGlobalPrefix()) + - "C" + Twine(LabelID++)); + GetOrCreateSymbol(StringRef(MAI->getPrivateGlobalPrefix()) + + "C" + Twine(LabelID++)); O << *TOCEntry << "@toc"; } @@ -674,14 +674,14 @@ // Remove $stub suffix, add $lazy_ptr. SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end()-5); TmpStr += "$lazy_ptr"; - return Ctx.GetOrCreateTemporarySymbol(TmpStr.str()); + return Ctx.GetOrCreateSymbol(TmpStr.str()); } static const MCSymbol *GetAnonSym(const MCSymbol *Sym, MCContext &Ctx) { // Add $tmp suffix to $stub, yielding $stub$tmp. SmallString<128> TmpStr(Sym->getName().begin(), Sym->getName().end()); TmpStr += "$tmp"; - return Ctx.GetOrCreateTemporarySymbol(TmpStr.str()); + return Ctx.GetOrCreateSymbol(TmpStr.str()); } void PPCDarwinAsmPrinter:: Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Tue Mar 30 13:10:53 2010 @@ -83,7 +83,7 @@ case X86II::MO_DARWIN_NONLAZY: case X86II::MO_DARWIN_NONLAZY_PIC_BASE: { Name += "$non_lazy_ptr"; - MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str()); + MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); MachineModuleInfoImpl::StubValueTy &StubSym = getMachOMMI().getGVStubEntry(Sym); @@ -98,7 +98,7 @@ } case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE: { Name += "$non_lazy_ptr"; - MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str()); + MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); MachineModuleInfoImpl::StubValueTy &StubSym = getMachOMMI().getHiddenGVStubEntry(Sym); if (StubSym.getPointer() == 0) { @@ -112,7 +112,7 @@ } case X86II::MO_DARWIN_STUB: { Name += "$stub"; - MCSymbol *Sym = Ctx.GetOrCreateTemporarySymbol(Name.str()); + MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name.str()); MachineModuleInfoImpl::StubValueTy &StubSym = getMachOMMI().getFnStubEntry(Sym); if (StubSym.getPointer()) @@ -127,7 +127,7 @@ Name.erase(Name.end()-5, Name.end()); StubSym = MachineModuleInfoImpl:: - StubValueTy(Ctx.GetOrCreateTemporarySymbol(Name.str()), false); + StubValueTy(Ctx.GetOrCreateSymbol(Name.str()), false); } return Sym; } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99902&r1=99901&r2=99902&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Mar 30 13:10:53 2010 @@ -1112,8 +1112,8 @@ X86TargetLowering::getPICBaseSymbol(const MachineFunction *MF, MCContext &Ctx) const { const MCAsmInfo &MAI = *getTargetMachine().getMCAsmInfo(); - return Ctx.GetOrCreateTemporarySymbol(Twine(MAI.getPrivateGlobalPrefix())+ - Twine(MF->getFunctionNumber())+"$pb"); + return Ctx.GetOrCreateSymbol(Twine(MAI.getPrivateGlobalPrefix())+ + Twine(MF->getFunctionNumber())+"$pb"); } From clattner at apple.com Tue Mar 30 13:25:23 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 11:25:23 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> References: <20100330010459.500622A6C12C@llvm.org> <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> Message-ID: On Mar 30, 2010, at 10:23 AM, Eric Christopher wrote: > > On Mar 29, 2010, at 7:07 PM, Chris Lattner wrote: > >> >> On Mar 29, 2010, at 6:04 PM, Eric Christopher wrote: >> >>> Author: echristo >>> Date: Mon Mar 29 20:04:59 2010 >>> New Revision: 99859 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=99859&view=rev >>> Log: >>> Add FIXME for operand promotion. >> >> What is this talking about? > > Basic idea is that loop is canonicalizing all loads (etc) to v2i64. This means that to match we've got some weird casts around that wouldn't need to be there if we just left them as whatever type they were. > > This is why we see, for example, the bc_v4i32 cast used all over the place in X86InstrSSE.td for things not sse2 to get them to match. But we do this for a really good reason. Canonicalization is important because without it, we have to write all patterns for all possible load types. -Chris From daniel at zuster.org Tue Mar 30 13:25:30 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 30 Mar 2010 18:25:30 -0000 Subject: [llvm-commits] [zorg] r99905 - in /zorg/trunk/lnt/lnt: formats/JSONFormat.py testing/__init__.py viewer/zview/zviewui.ptl Message-ID: <20100330182530.34B302A6C12C@llvm.org> Author: ddunbar Date: Tue Mar 30 13:25:30 2010 New Revision: 99905 URL: http://llvm.org/viewvc/llvm-project?rev=99905&view=rev Log: LNT: Support use with simplejson, for 2.5 compatibility. Modified: zorg/trunk/lnt/lnt/formats/JSONFormat.py zorg/trunk/lnt/lnt/testing/__init__.py zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl Modified: zorg/trunk/lnt/lnt/formats/JSONFormat.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/formats/JSONFormat.py?rev=99905&r1=99904&r2=99905&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/formats/JSONFormat.py (original) +++ zorg/trunk/lnt/lnt/formats/JSONFormat.py Tue Mar 30 13:25:30 2010 @@ -1,4 +1,7 @@ -import json +try: + import json +except ImportError: + import simplejson as json def _matches_format(path_or_file): if isinstance(path_or_file, str): Modified: zorg/trunk/lnt/lnt/testing/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/__init__.py?rev=99905&r1=99904&r2=99905&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/testing/__init__.py (original) +++ zorg/trunk/lnt/lnt/testing/__init__.py Tue Mar 30 13:25:30 2010 @@ -8,7 +8,11 @@ import time import datetime -import json + +try: + import json +except ImportError: + import simplejson as json def normalize_time(t): if isinstance(t,float): Modified: zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl?rev=99905&r1=99904&r2=99905&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl Tue Mar 30 13:25:30 2010 @@ -12,7 +12,10 @@ from sqlalchemy import func -import json +try: + import json +except ImportError: + import simplejson as json class ZViewUI(Directory): _q_exports = ["", "get_machines", "get_tests", "get_test_data", From echristo at apple.com Tue Mar 30 13:29:10 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 11:29:10 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <20100330010459.500622A6C12C@llvm.org> <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> Message-ID: >> >> Basic idea is that loop is canonicalizing all loads (etc) to v2i64. This means that to match we've got some weird casts around that wouldn't need to be there if we just left them as whatever type they were. >> >> This is why we see, for example, the bc_v4i32 cast used all over the place in X86InstrSSE.td for things not sse2 to get them to match. > > But we do this for a really good reason. Canonicalization is important because without it, we have to write all patterns for all possible load types. or assume that the casts are relatively free I guess. Maybe we can rewrite the memopvXXX patterns to autoload from v2i64 and bc to what we want instead of needing to explicitly bc. Guess it was largely a note of "think of how to do this better". -eric From clattner at apple.com Tue Mar 30 13:32:08 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 11:32:08 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: References: <20100330010459.500622A6C12C@llvm.org> <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> Message-ID: <716C0DE8-2EAD-4B87-B0DE-9E1E449140B1@apple.com> On Mar 30, 2010, at 11:29 AM, Eric Christopher wrote: >>> >>> Basic idea is that loop is canonicalizing all loads (etc) to v2i64. This means that to match we've got some weird casts around that wouldn't need to be there if we just left them as whatever type they were. >>> >>> This is why we see, for example, the bc_v4i32 cast used all over the place in X86InstrSSE.td for things not sse2 to get them to match. >> >> But we do this for a really good reason. Canonicalization is important because without it, we have to write all patterns for all possible load types. > > or assume that the casts are relatively free I guess. Maybe we can rewrite the memopvXXX patterns to autoload from v2i64 and bc to what we want instead of needing to explicitly bc. > > Guess it was largely a note of "think of how to do this better". I recently made tblgen ignore noop bitcasts in .td files. This means that the .td file could write the sse load as a patfrag like this: (bitconvert (v2i64 (load ...))) when used in a context that is already v2i64, the bitconvert would go away. -Chris From clattner at apple.com Tue Mar 30 13:33:22 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 11:33:22 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: <20100330111748.9148F2A6C12C@llvm.org> References: <20100330111748.9148F2A6C12C@llvm.org> Message-ID: <3197F787-B0C0-464A-B2DB-12B0D7972B21@apple.com> On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote: > Author: edwin > Date: Tue Mar 30 06:17:48 2010 > New Revision: 99883 > > URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev > Log: > Reapply r99881 with some fixes: only call destructor in releaseMemory! Edwin, this patch isn't safe at all. What if you allocate different types in one bump pointer? Please revert it. -Chris > > Modified: > llvm/trunk/include/llvm/CodeGen/LiveInterval.h > llvm/trunk/include/llvm/Support/Allocator.h > llvm/trunk/lib/CodeGen/LiveInterval.cpp > llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > llvm/trunk/lib/Support/Allocator.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) > +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Mar 30 06:17:48 2010 > @@ -330,12 +330,7 @@ > } > > void clear() { > - while (!valnos.empty()) { > - VNInfo *VNI = valnos.back(); > - valnos.pop_back(); > - VNI->~VNInfo(); > - } > - > + valnos.clear(); > ranges.clear(); > } > > > Modified: llvm/trunk/include/llvm/Support/Allocator.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/Allocator.h (original) > +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 06:17:48 2010 > @@ -134,6 +134,7 @@ > static MallocSlabAllocator DefaultSlabAllocator; > > public: > + typedef void (*DTorFunction)(void*); > BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, > SlabAllocator &allocator = DefaultSlabAllocator); > ~BumpPtrAllocator(); > @@ -142,6 +143,11 @@ > /// to the beginning of it, freeing all memory allocated so far. > void Reset(); > > + /// Reset - like Reset(), but call DTorFunction for each allocated > + /// object. This assumes that all objects allocated with this allocator > + /// had the same size and alignment specified here. > + void Reset(size_t Size, size_t Alignment, DTorFunction DTor); > + > /// Allocate - Allocate space at the specified alignment. > /// > void *Allocate(size_t Size, size_t Alignment); > > Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 06:17:48 2010 > @@ -305,7 +305,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > ValNo->setIsUnused(true); > @@ -353,7 +352,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > ValNo->setIsUnused(true); > @@ -581,7 +579,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (!valnos.empty() && valnos.back()->isUnused()); > } else { > V1->setIsUnused(true); > @@ -658,7 +655,6 @@ > if (UnusedValNo) { > // Delete the last unused val#. > valnos.pop_back(); > - UnusedValNo->~VNInfo(); > } > } > > @@ -751,7 +747,6 @@ > do { > VNInfo *VNI = valnos.back(); > valnos.pop_back(); > - VNI->~VNInfo(); > } while (valnos.back()->isUnused()); > } else { > V1->setIsUnused(true); > > Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 06:17:48 2010 > @@ -82,6 +82,11 @@ > MachineFunctionPass::getAnalysisUsage(AU); > } > > +static void VNInfoDTor(void* Ptr) > +{ > + reinterpret_cast(Ptr)->~VNInfo(); > +} > + > void LiveIntervals::releaseMemory() { > // Free the live intervals themselves. > for (DenseMap::iterator I = r2iMap_.begin(), > @@ -91,7 +96,7 @@ > r2iMap_.clear(); > > // Release VNInfo memroy regions after all VNInfo objects are dtor'd. > - VNInfoAllocator.Reset(); > + VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); > while (!CloneMIs.empty()) { > MachineInstr *MI = CloneMIs.back(); > CloneMIs.pop_back(); > > Modified: llvm/trunk/lib/Support/Allocator.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99883&r1=99882&r2=99883&view=diff > ============================================================================== > --- llvm/trunk/lib/Support/Allocator.cpp (original) > +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 06:17:48 2010 > @@ -78,6 +78,21 @@ > End = ((char*)CurSlab) + CurSlab->Size; > } > > +void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { > + if (Alignment == 0) Alignment = 1; > + MemSlab *Slab = CurSlab; > + while (Slab) { > + char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; > + for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { > + Ptr = AlignPtr(Ptr, Alignment); > + if (Ptr + Size <= End) > + DTor(Ptr); > + } > + Slab = Slab->NextPtr; > + } > + Reset(); > +} > + > /// Allocate - Allocate space at the specified alignment. > /// > void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From echristo at apple.com Tue Mar 30 13:37:45 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 11:37:45 -0700 Subject: [llvm-commits] [llvm] r99859 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp In-Reply-To: <716C0DE8-2EAD-4B87-B0DE-9E1E449140B1@apple.com> References: <20100330010459.500622A6C12C@llvm.org> <2FEB4591-EA2E-4D3E-BC34-9820CC90B663@apple.com> <716C0DE8-2EAD-4B87-B0DE-9E1E449140B1@apple.com> Message-ID: <8EFE88BB-BB51-4FA2-830A-475B7B32E9A2@apple.com> On Mar 30, 2010, at 11:32 AM, Chris Lattner wrote: > > On Mar 30, 2010, at 11:29 AM, Eric Christopher wrote: > >>>> >>>> Basic idea is that loop is canonicalizing all loads (etc) to v2i64. This means that to match we've got some weird casts around that wouldn't need to be there if we just left them as whatever type they were. >>>> >>>> This is why we see, for example, the bc_v4i32 cast used all over the place in X86InstrSSE.td for things not sse2 to get them to match. >>> >>> But we do this for a really good reason. Canonicalization is important because without it, we have to write all patterns for all possible load types. >> >> or assume that the casts are relatively free I guess. Maybe we can rewrite the memopvXXX patterns to autoload from v2i64 and bc to what we want instead of needing to explicitly bc. >> >> Guess it was largely a note of "think of how to do this better". > > I recently made tblgen ignore noop bitcasts in .td files. This means that the .td file could write the sse load as a patfrag like this: > > (bitconvert (v2i64 (load ...))) > > when used in a context that is already v2i64, the bitconvert would go away. Cool. I think that fixes a comment I saw in the td file. The problem I'm seeing is something like (memopv4i32 addr:$src) actually needs to be (bc_v4i32 (memopv2i64 addr:$src) in order for the magic to work. So I'm currently thinking that rewriting "memopv4i32" to be the latter and just expand out might be a better way of going about it. -eric From dalej at apple.com Tue Mar 30 13:41:12 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 30 Mar 2010 18:41:12 -0000 Subject: [llvm-commits] [test-suite] r99909 - /test-suite/trunk/TEST.m2regllcdbg.Makefile Message-ID: <20100330184112.7FA4D2A6C12C@llvm.org> Author: johannes Date: Tue Mar 30 13:41:12 2010 New Revision: 99909 URL: http://llvm.org/viewvc/llvm-project?rev=99909&view=rev Log: Strip out another comment that's started appearing in Dwarf debug info tables. Modified: test-suite/trunk/TEST.m2regllcdbg.Makefile Modified: test-suite/trunk/TEST.m2regllcdbg.Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.m2regllcdbg.Makefile?rev=99909&r1=99908&r2=99909&view=diff ============================================================================== --- test-suite/trunk/TEST.m2regllcdbg.Makefile (original) +++ test-suite/trunk/TEST.m2regllcdbg.Makefile Tue Mar 30 13:41:12 2010 @@ -32,7 +32,7 @@ $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC) - grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ + grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT) $(LOPT) -strip-nondebug $< -f -o $@ @@ -44,7 +44,7 @@ $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ Output/%.second.s: Output/%.t2c.s Output/.dir - grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ + grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ Output/%.diff: Output/%.first.s Output/%.second.s @-if diff $^ > $@; then \ From echristo at apple.com Tue Mar 30 13:49:01 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 18:49:01 -0000 Subject: [llvm-commits] [llvm] r99910 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp test/Bitcode/sse41_pmulld.ll test/Bitcode/sse41_pmulld.ll.bc test/CodeGen/X86/pmul.ll test/CodeGen/X86/pmulld.ll Message-ID: <20100330184901.9CCA82A6C12C@llvm.org> Author: echristo Date: Tue Mar 30 13:49:01 2010 New Revision: 99910 URL: http://llvm.org/viewvc/llvm-project?rev=99910&view=rev Log: Remove the pmulld intrinsic and autoupdate it as a vector multiply. Rewrite the pmulld patterns, and make sure that they fold in loads of arguments into the instruction. Added: llvm/trunk/test/Bitcode/sse41_pmulld.ll llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc (with props) llvm/trunk/test/CodeGen/X86/pmulld.ll Modified: llvm/trunk/include/llvm/IntrinsicsX86.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/CodeGen/X86/pmul.ll Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=99910&r1=99909&r2=99910&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Mar 30 13:49:01 2010 @@ -810,9 +810,6 @@ def int_x86_sse41_pmuldq : GCCBuiltin<"__builtin_ia32_pmuldq128">, Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem, Commutative]>; - def int_x86_sse41_pmulld : GCCBuiltin<"__builtin_ia32_pmulld128">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], - [IntrNoMem, Commutative]>; } // Vector extract Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=99910&r1=99909&r2=99910&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Mar 30 13:49:01 2010 @@ -597,7 +597,6 @@ { X86::PMULHUWrr, X86::PMULHUWrm, 16 }, { X86::PMULHWrr, X86::PMULHWrm, 16 }, { X86::PMULLDrr, X86::PMULLDrm, 16 }, - { X86::PMULLDrr_int, X86::PMULLDrm_int, 16 }, { X86::PMULLWrr, X86::PMULLWrm, 16 }, { X86::PMULUDQrr, X86::PMULUDQrm, 16 }, { X86::PORrr, X86::PORrm, 16 }, Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99910&r1=99909&r2=99910&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Mar 30 13:49:01 2010 @@ -3448,8 +3448,28 @@ OpSize; } } -defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul, - int_x86_sse41_pmulld, 1>; + +/// SS48I_binop_rm - Simple SSE41 binary operator. +let Constraints = "$src1 = $dst" in { +multiclass SS48I_binop_rm opc, string OpcodeStr, SDNode OpNode, + ValueType OpVT, bit Commutable = 0> { + def rr : SS48I, + OpSize { + let isCommutable = Commutable; + } + def rm : SS48I, + OpSize; +} +} + +defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32, 1>; /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate let Constraints = "$src1 = $dst" in { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=99910&r1=99909&r2=99910&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Mar 30 13:49:01 2010 @@ -225,7 +225,12 @@ // Calls to these intrinsics are transformed into ShuffleVector's. NewFn = 0; return true; + } else if (Name.compare(5, 16, "x86.sse41.pmulld", 16) == 0) { + // Calls to these intrinsics are transformed into vector multiplies. + NewFn = 0; + return true; } + break; } @@ -355,6 +360,18 @@ // Clean up the old call now that it has been completely upgraded. CI->eraseFromParent(); + } else if (F->getName() == "llvm.x86.sse41.pmulld") { + // Upgrade this set of intrinsics into vector multiplies. + Instruction *Mul = BinaryOperator::CreateMul(CI->getOperand(1), + CI->getOperand(2), + CI->getName(), + CI); + // Fix up all the uses with our new multiply. + if (!CI->use_empty()) + CI->replaceAllUsesWith(Mul); + + // Remove upgraded multiply. + CI->eraseFromParent(); } else { llvm_unreachable("Unknown function for CallInst upgrade."); } Added: llvm/trunk/test/Bitcode/sse41_pmulld.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse41_pmulld.ll?rev=99910&view=auto ============================================================================== --- llvm/trunk/test/Bitcode/sse41_pmulld.ll (added) +++ llvm/trunk/test/Bitcode/sse41_pmulld.ll Tue Mar 30 13:49:01 2010 @@ -0,0 +1,2 @@ +; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.pmulld} +; RUN: llvm-dis < %s.bc | grep mul \ No newline at end of file Added: llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc?rev=99910&view=auto ============================================================================== Binary file - no diff available. Propchange: llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: llvm/trunk/test/CodeGen/X86/pmul.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pmul.ll?rev=99910&r1=99909&r2=99910&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pmul.ll (original) +++ llvm/trunk/test/CodeGen/X86/pmul.ll Tue Mar 30 13:49:01 2010 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=x86 -mattr=sse41 -stack-alignment=16 > %t ; RUN: grep pmul %t | count 12 -; RUN: grep mov %t | count 12 +; RUN: grep mov %t | count 11 define <4 x i32> @a(<4 x i32> %i) nounwind { %A = mul <4 x i32> %i, < i32 117, i32 117, i32 117, i32 117 > Added: llvm/trunk/test/CodeGen/X86/pmulld.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pmulld.ll?rev=99910&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/pmulld.ll (added) +++ llvm/trunk/test/CodeGen/X86/pmulld.ll Tue Mar 30 13:49:01 2010 @@ -0,0 +1,16 @@ +; RUN: llc < %s -march=x86-64 -mattr=+sse41 -asm-verbose=0 | FileCheck %s + +define <4 x i32> @test1(<4 x i32> %A, <4 x i32> %B) nounwind { +; CHECK: test1: +; CHECK-NEXT: pmulld + %C = mul <4 x i32> %A, %B + ret <4 x i32> %C +} + +define <4 x i32> @test1a(<4 x i32> %A, <4 x i32> *%Bp) nounwind { +; CHECK: test1a: +; CHECK-NEXT: pmulld + %B = load <4 x i32>* %Bp + %C = mul <4 x i32> %A, %B + ret <4 x i32> %C +} From benny.kra at googlemail.com Tue Mar 30 14:17:05 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 30 Mar 2010 21:17:05 +0200 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> References: <20100330111748.9148F2A6C12C@llvm.org> <4BB22B8B.7010002@gmail.com> <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> Message-ID: On 30.03.2010, at 19:00, Jakob Stoklund Olesen wrote: > > On Mar 30, 2010, at 9:49 AM, T?r?k Edwin wrote: > >> On 03/30/2010 07:32 PM, Jakob Stoklund Olesen wrote: > >>> A template class that is only capable of allocating one type would be safer. >> >> Sounds good, the template could automatically call the destructor when >> Reset() is called, without the need for the special Reset() method. I quickly put together a patch that adds a templated BumpPtrAllocator and allocates all VNInfos through it. -------------- next part -------------- A non-text attachment was scrubbed... Name: specificbumpallocator.patch Type: application/octet-stream Size: 11149 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100330/63fdcdce/attachment.obj From ggreif at gmail.com Tue Mar 30 14:20:54 2010 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 30 Mar 2010 19:20:54 -0000 Subject: [llvm-commits] [llvm] r99914 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <20100330192054.23C2E2A6C12C@llvm.org> Author: ggreif Date: Tue Mar 30 14:20:53 2010 New Revision: 99914 URL: http://llvm.org/viewvc/llvm-project?rev=99914&view=rev Log: fix two cases where the arguments were extracted from the wrong range out of the InvokeInst spotted by baldrick -- thanks\! Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=99914&r1=99913&r2=99914&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Mar 30 14:20:53 2010 @@ -1768,7 +1768,7 @@ Pred->getInstList().remove(II); // Take out of symbol table // Insert the call now. - SmallVector Args(II->op_begin()+3, II->op_end()); + SmallVector Args(II->op_begin(), II->op_end()-3); CallInst *CI = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), II->getName(), BI); @@ -1970,13 +1970,13 @@ II->removeFromParent(); // Take out of symbol table // Insert the call now... - SmallVector Args(II->op_begin()+3, II->op_end()); + SmallVector Args(II->op_begin(), II->op_end()-3); CallInst *CI = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), II->getName(), BI); CI->setCallingConv(II->getCallingConv()); CI->setAttributes(II->getAttributes()); - // If the invoke produced a value, the Call does now instead. + // If the invoke produced a value, the call does now instead. II->replaceAllUsesWith(CI); delete II; Changed = true; From gohman at apple.com Tue Mar 30 14:44:22 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 30 Mar 2010 12:44:22 -0700 Subject: [llvm-commits] [PATCH] Configurable CallSiteBase In-Reply-To: <4BB1C5BD.7090204@mac.com> References: <4BB1C5BD.7090204@mac.com> Message-ID: <45FDEBC5-75A2-49F9-A1DE-72F8BD198F98@apple.com> On Mar 30, 2010, at 2:34 AM, Gabor Greif wrote: > Hi all, > > I'd like to put this patch to review. It pulls out some > functionality from CallSite into a template baseclass > CallSiteBase. CallSiteBase is highly customizable in the > type of the inputs and outputs (types), especially constness > variants. CallSite then chooses the fully non-const configuration. Hi Gabor, this looks interesting. I have a few comments. > CallSiteBase<> with all-default parameters implements the fully > const configuration. This is the preferred configuration for > analyses and predicates, because it prevents accidental mutation. Did you find any accidental mutations? > It is not yet settled how I should arrange the order of > CallSiteBase template parameters. Logically, those that are > frequently customized should go to the front, but I have no > data points yet, since all we use now is an all-or-nothing > regarding constness. I don't think there aren't any interesting customizations besides flipping constness. > > Some predicates of analyses already have been converted to > full-constness to demonstrate the concept. More to follow. > > There is potential for pulling more methods into the base class, > I plan to do this as soon as need arises. > > Notable omissions: > - ProgrammersManual: document CallSiteBase > - should we define a class ConstCallSite? (I see no gain ATM.) Yes -- a class, or perhaps a typedef. 7-ary templates are fearsome, even when fully defaulted. Since there's little need for general customization, presenting the two main use cases as regular types makes it easier to understand the API. > > CallSiteBase now provides three convenience features (some of > them are inherited by CallSite too) : > - operator bool: this conversion allows to check whether we have > a proper call site. Allows to eliminate an indentation level of > "if" statements. > - operator ->: gives back the payload as an instruction (InstrTy*) > - constructor from ValueTy: this may supplant the static "get" > method in the future (ATM it is implementer in terms of "get"). > Anyway, this constructor can be used in "if" statements to > get rid of a free-standing wide-scope local binding. Another way to provide this functionality would be to redo the CallSite abstraction as a pseudo-class, following the IntrinsicInst.h example. That way, it could use dyn_cast like everything else instead of its own syntax. For example, something like this: class CallSite : public User { CallSite(); // DO NOT IMPLEMENT CallSite(const CallSite &); // DO NOT IMPLEMENT void operator=(const CallSite &); // DO NOT IMPLEMENT public: // ... // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const CallSite *) { return true; } static inline bool classof(const CallInst *I) { return true; } static inline bool classof(const InvokeInst *I) { return true; } static inline bool classof(const Value *V) { return isa(V) || isa(V); } }; I don't have a strong opinion about this though. Dan From stoklund at 2pi.dk Tue Mar 30 14:46:43 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 12:46:43 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: References: <20100330111748.9148F2A6C12C@llvm.org> <4BB22B8B.7010002@gmail.com> <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> Message-ID: On Mar 30, 2010, at 12:17 PM, Benjamin Kramer wrote: > > On 30.03.2010, at 19:00, Jakob Stoklund Olesen wrote: > >> >> On Mar 30, 2010, at 9:49 AM, T?r?k Edwin wrote: >> >>> On 03/30/2010 07:32 PM, Jakob Stoklund Olesen wrote: >> >>>> A template class that is only capable of allocating one type would be safer. >>> >>> Sounds good, the template could automatically call the destructor when >>> Reset() is called, without the need for the special Reset() method. > > I quickly put together a patch that adds a templated BumpPtrAllocator and allocates all VNInfos through it. > > Looks good to me, thanks! I would rename Reset() to something more ominous, like DestroyAll(). + void Deallocate(const T *Ptr) { + Ptr->~T(); + } Is that one necessary? If you are going to destroy single elements, you should not be using this class in the first place. /jakob From gohman at apple.com Tue Mar 30 14:56:41 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 30 Mar 2010 19:56:41 -0000 Subject: [llvm-commits] [llvm] r99915 - in /llvm/trunk: include/llvm/Support/FileUtilities.h tools/llvm-ld/llvm-ld.cpp Message-ID: <20100330195641.E9EBD2A6C12C@llvm.org> Author: djg Date: Tue Mar 30 14:56:41 2010 New Revision: 99915 URL: http://llvm.org/viewvc/llvm-project?rev=99915&view=rev Log: Fix llvm-ld to clean up its output files in case of an error. Modified: llvm/trunk/include/llvm/Support/FileUtilities.h llvm/trunk/tools/llvm-ld/llvm-ld.cpp Modified: llvm/trunk/include/llvm/Support/FileUtilities.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileUtilities.h?rev=99915&r1=99914&r2=99915&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/FileUtilities.h (original) +++ llvm/trunk/include/llvm/Support/FileUtilities.h Tue Mar 30 14:56:41 2010 @@ -52,6 +52,17 @@ } } + /// setFile - Give ownership of the file to the FileRemover so it will + /// be removed when the object is destroyed. If the FileRemover already + /// had ownership of a file, remove it first. + void setFile(const sys::Path &filename, bool deleteIt = true) { + if (DeleteIt) + Filename.eraseFromDisk(); + + Filename = filename; + DeleteIt = deleteIt; + } + /// releaseFile - Take ownership of the file away from the FileRemover so it /// will not be removed when the object is destroyed. void releaseFile() { DeleteIt = false; } Modified: llvm/trunk/tools/llvm-ld/llvm-ld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ld/llvm-ld.cpp?rev=99915&r1=99914&r2=99915&view=diff ============================================================================== --- llvm/trunk/tools/llvm-ld/llvm-ld.cpp (original) +++ llvm/trunk/tools/llvm-ld/llvm-ld.cpp Tue Mar 30 14:56:41 2010 @@ -30,6 +30,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" @@ -124,6 +125,10 @@ /// everywhere. static std::string progname; +/// FileRemover objects to clean up output files in the event of an error. +static FileRemover OutputRemover; +static FileRemover BitcodeOutputRemover; + /// PrintAndExit - Prints a message to standard error and exits with error code /// /// Inputs: @@ -236,10 +241,6 @@ if (!ErrorInfo.empty()) PrintAndExit(ErrorInfo, M); - // Ensure that the bitcode file gets removed from the disk if we get a - // terminating signal. - sys::RemoveFileOnSignal(sys::Path(FileName)); - // Write it out WriteBitcodeToFile(M, Out); } @@ -517,6 +518,39 @@ // Parse the command line options cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); +#if defined(_WIN32) || defined(__CYGWIN__) + if (!LinkAsLibrary) { + // Default to "a.exe" instead of "a.out". + if (OutputFilename.getNumOccurrences() == 0) + OutputFilename = "a.exe"; + + // If there is no suffix add an "exe" one. + sys::Path ExeFile( OutputFilename ); + if (ExeFile.getSuffix() == "") { + ExeFile.appendSuffix("exe"); + OutputFilename = ExeFile.str(); + } + } +#endif + + // Generate the bitcode for the optimized module. + // If -b wasn't specified, use the name specified + // with -o to construct BitcodeOutputFilename. + if (BitcodeOutputFilename.empty()) { + BitcodeOutputFilename = OutputFilename; + if (!LinkAsLibrary) BitcodeOutputFilename += ".bc"; + } + + // Arrange for the bitcode output file to be deleted on any errors. + BitcodeOutputRemover.setFile(sys::Path(BitcodeOutputFilename)); + sys::RemoveFileOnSignal(sys::Path(BitcodeOutputFilename)); + + // Arrange for the output file to be deleted on any errors. + if (!LinkAsLibrary) { + OutputRemover.setFile(sys::Path(OutputFilename)); + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + } + // Construct a Linker (now that Verbose is set) Linker TheLinker(progname, OutputFilename, Context, Verbose); @@ -559,29 +593,7 @@ // Optimize the module Optimize(Composite.get()); -#if defined(_WIN32) || defined(__CYGWIN__) - if (!LinkAsLibrary) { - // Default to "a.exe" instead of "a.out". - if (OutputFilename.getNumOccurrences() == 0) - OutputFilename = "a.exe"; - - // If there is no suffix add an "exe" one. - sys::Path ExeFile( OutputFilename ); - if (ExeFile.getSuffix() == "") { - ExeFile.appendSuffix("exe"); - OutputFilename = ExeFile.str(); - } - } -#endif - - // Generate the bitcode for the optimized module. - // If -b wasn't specified, use the name specified - // with -o to construct BitcodeOutputFilename. - if (BitcodeOutputFilename.empty()) { - BitcodeOutputFilename = OutputFilename; - if (!LinkAsLibrary) BitcodeOutputFilename += ".bc"; - } - + // Generate the bitcode output. GenerateBitcode(Composite.get(), BitcodeOutputFilename); // If we are not linking a library, generate either a native executable @@ -634,9 +646,9 @@ sys::Path AssemblyFile ( OutputFilename); AssemblyFile.appendSuffix("s"); - // Mark the output files for removal if we get an interrupt. + // Mark the output files for removal. + FileRemover AssemblyFileRemover(AssemblyFile); sys::RemoveFileOnSignal(AssemblyFile); - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); // Determine the locations of the llc and gcc programs. sys::Path llc = FindExecutable("llc", argv[0], @@ -657,16 +669,13 @@ if (0 != GenerateNative(OutputFilename, AssemblyFile.str(), NativeLinkItems, gcc, envp, ErrMsg)) PrintAndExit(ErrMsg, Composite.get()); - - // Remove the assembly language file. - AssemblyFile.eraseFromDisk(); } else if (NativeCBE) { sys::Path CFile (OutputFilename); CFile.appendSuffix("cbe.c"); - // Mark the output files for removal if we get an interrupt. + // Mark the output files for removal. + FileRemover CFileRemover(CFile); sys::RemoveFileOnSignal(CFile); - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); // Determine the locations of the llc and gcc programs. sys::Path llc = FindExecutable("llc", argv[0], @@ -686,10 +695,6 @@ if (GenerateNative(OutputFilename, CFile.str(), NativeLinkItems, gcc, envp, ErrMsg)) PrintAndExit(ErrMsg, Composite.get()); - - // Remove the assembly language file. - CFile.eraseFromDisk(); - } else { EmitShellScript(argv, Composite.get()); } @@ -707,6 +712,11 @@ PrintAndExit(ErrMsg, Composite.get()); } + // Operations which may fail are now complete. + BitcodeOutputRemover.releaseFile(); + if (!LinkAsLibrary) + OutputRemover.releaseFile(); + // Graceful exit return 0; } From stoklund at 2pi.dk Tue Mar 30 15:04:01 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 20:04:01 -0000 Subject: [llvm-commits] [llvm] r99916 - /llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Message-ID: <20100330200401.6723F2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 15:04:01 2010 New Revision: 99916 URL: http://llvm.org/viewvc/llvm-project?rev=99916&view=rev Log: Add cross-block inference to SSEDomainFix. Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=99916&r1=99915&r2=99916&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original) +++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Tue Mar 30 15:04:01 2010 @@ -106,11 +106,16 @@ return Mask & mask; } - // Mark domain as available + // Mark domain as available. void add(unsigned domain) { Mask |= 1u << domain; } + // First domain available in mask. + unsigned firstDomain() const { + return CountTrailingZeros_32(Mask); + } + DomainValue() { clear(); } void clear() { @@ -119,6 +124,8 @@ } }; +static const unsigned NumRegs = 16; + class SSEDomainFixPass : public MachineFunctionPass { static char ID; PoolAllocator Pool; @@ -126,10 +133,11 @@ MachineFunction *MF; const X86InstrInfo *TII; const TargetRegisterInfo *TRI; - MachineBasicBlock *MBB; - bool hasLiveRegs; - DomainValue *LiveRegs[16]; + DomainValue **LiveRegs; + typedef DenseMap LiveOutMap; + LiveOutMap LiveOuts; + unsigned Distance; public: SSEDomainFixPass() : MachineFunctionPass(&ID) {} @@ -156,7 +164,7 @@ void Collapse(DomainValue *dv, unsigned domain); bool Merge(DomainValue *A, DomainValue *B); - void enterBasicBlock(MachineBasicBlock *MBB); + void enterBasicBlock(); void visitGenericInstr(MachineInstr*); void visitSoftInstr(MachineInstr*, unsigned mask); void visitHardInstr(MachineInstr*, unsigned domain); @@ -171,13 +179,17 @@ int SSEDomainFixPass::RegIndex(unsigned reg) { // Registers are sorted lexicographically. // We just need them to be consecutive, ordering doesn't matter. - assert(X86::XMM9 == X86::XMM0+15 && "Unexpected sort"); + assert(X86::XMM9 == X86::XMM0+NumRegs-1 && "Unexpected sort"); reg -= X86::XMM0; - return reg < 16 ? reg : -1; + return reg < NumRegs ? reg : -1; } /// Set LiveRegs[rx] = dv, updating reference counts. void SSEDomainFixPass::SetLiveReg(int rx, DomainValue *dv) { + assert(unsigned(rx) < NumRegs && "Invalid index"); + if (!LiveRegs) + LiveRegs = (DomainValue**)calloc(sizeof(DomainValue*), NumRegs); + if (LiveRegs[rx] == dv) return; if (LiveRegs[rx]) { @@ -190,28 +202,30 @@ // Kill register rx, recycle or collapse any DomainValue. void SSEDomainFixPass::Kill(int rx) { - if (!LiveRegs[rx]) return; + assert(unsigned(rx) < NumRegs && "Invalid index"); + if (!LiveRegs || !LiveRegs[rx]) return; // Before killing the last reference to an open DomainValue, collapse it to // the first available domain. if (LiveRegs[rx]->Refs == 1 && !LiveRegs[rx]->collapsed()) - Collapse(LiveRegs[rx], CountTrailingZeros_32(LiveRegs[rx]->Mask)); + Collapse(LiveRegs[rx], LiveRegs[rx]->firstDomain()); else SetLiveReg(rx, 0); } /// Force register rx into domain. void SSEDomainFixPass::Force(int rx, unsigned domain) { - hasLiveRegs = true; + assert(unsigned(rx) < NumRegs && "Invalid index"); DomainValue *dv; - if ((dv = LiveRegs[rx])) { + if (LiveRegs && (dv = LiveRegs[rx])) { if (dv->collapsed()) dv->add(domain); else Collapse(dv, domain); } else { - // Set up basic collapsed DomainValue + // Set up basic collapsed DomainValue. dv = Pool.Alloc(); + dv->Dist = Distance; dv->add(domain); SetLiveReg(rx, dv); } @@ -231,14 +245,14 @@ dv->Mask = 1u << domain; // If there are multiple users, give them new, unique DomainValues. - if (dv->Refs > 1) { - for (unsigned rx=0, e = array_lengthof(LiveRegs); rx != e; ++rx) + if (LiveRegs && dv->Refs > 1) { + for (unsigned rx = 0; rx != NumRegs; ++rx) if (LiveRegs[rx] == dv) { DomainValue *dv2 = Pool.Alloc(); + dv2->Dist = Distance; dv2->add(domain); SetLiveReg(rx, dv2); } - Pool.Recycle(dv); } } @@ -252,14 +266,42 @@ A->Mask &= B->Mask; A->Dist = std::max(A->Dist, B->Dist); A->Instrs.append(B->Instrs.begin(), B->Instrs.end()); - for (unsigned rx=0, e = array_lengthof(LiveRegs); rx != e; ++rx) + for (unsigned rx = 0; rx != NumRegs; ++rx) if (LiveRegs[rx] == B) SetLiveReg(rx, A); return true; } -void SSEDomainFixPass::enterBasicBlock(MachineBasicBlock *mbb) { - MBB = mbb; +void SSEDomainFixPass::enterBasicBlock() { + // Try to coalesce live-out registers from predecessors. + for (MachineBasicBlock::const_livein_iterator i = MBB->livein_begin(), + e = MBB->livein_end(); i != e; ++i) { + int rx = RegIndex(*i); + if (rx < 0) continue; + for (MachineBasicBlock::const_pred_iterator pi = MBB->pred_begin(), + pe = MBB->pred_end(); pi != pe; ++pi) { + LiveOutMap::const_iterator fi = LiveOuts.find(*pe); + if (fi == LiveOuts.end()) continue; + DomainValue *pdv = fi->second[rx]; + if (!pdv) continue; + if (!LiveRegs || !LiveRegs[rx]) + SetLiveReg(rx, pdv); + else { + // We have a live DomainValue from more than one predecessor. + if (LiveRegs[rx]->collapsed()) { + // We are already collapsed, but predecessor is not. Force him. + if (!pdv->collapsed()) + Collapse(pdv, LiveRegs[rx]->firstDomain()); + } else { + // Currently open, merge in predecessor. + if (!pdv->collapsed()) + Merge(LiveRegs[rx], pdv); + else + Collapse(LiveRegs[rx], pdv->firstDomain()); + } + } + } + } } // A hard instruction only works in one domain. All input registers will be @@ -291,8 +333,9 @@ // Scan the explicit use operands for incoming domains. unsigned collmask = mask; SmallVector used; - for (unsigned i = mi->getDesc().getNumDefs(), - e = mi->getDesc().getNumOperands(); i != e; ++i) { + if (LiveRegs) + for (unsigned i = mi->getDesc().getNumDefs(), + e = mi->getDesc().getNumOperands(); i != e; ++i) { MachineOperand &mo = mi->getOperand(i); if (!mo.isReg()) continue; int rx = RegIndex(mo.getReg()); @@ -323,7 +366,7 @@ for (SmallVector::iterator i=used.begin(), e=used.end(); i!=e; ++i) { int rx = *i; DomainValue *dv = LiveRegs[rx]; - // This useless DomainValue could have been missed above + // This useless DomainValue could have been missed above. if (!dv->compat(collmask)) { Kill(*i); continue; @@ -359,6 +402,7 @@ // dv is the DomainValue we are going to use for this instruction. if (!dv) dv = Pool.Alloc(); + dv->Dist = Distance; dv->Mask = collmask; dv->Instrs.push_back(mi); @@ -368,7 +412,7 @@ if (!mo.isReg()) continue; int rx = RegIndex(mo.getReg()); if (rx < 0) continue; - if (!LiveRegs[rx] || (mo.isDef() && LiveRegs[rx]!=dv)) { + if (!LiveRegs || !LiveRegs[rx] || (mo.isDef() && LiveRegs[rx]!=dv)) { Kill(rx); SetLiveReg(rx, dv); } @@ -376,7 +420,7 @@ } void SSEDomainFixPass::visitGenericInstr(MachineInstr *mi) { - // Process explicit defs, kill any XMM registers redefined + // Process explicit defs, kill any XMM registers redefined. for (unsigned i = 0, e = mi->getDesc().getNumDefs(); i != e; ++i) { MachineOperand &mo = mi->getOperand(i); if (!mo.isReg()) continue; @@ -391,10 +435,9 @@ TII = static_cast(MF->getTarget().getInstrInfo()); TRI = MF->getTarget().getRegisterInfo(); MBB = 0; - - hasLiveRegs = false; - for (unsigned i=0, e = array_lengthof(LiveRegs); i != e; ++i) - LiveRegs[i] = 0; + LiveRegs = 0; + Distance = 0; + assert(NumRegs == X86::VR128RegClass.getNumRegs() && "Bad regclass"); // If no XMM registers are used in the function, we can skip it completely. bool anyregs = false; @@ -411,22 +454,35 @@ for (df_ext_iterator > DFI = df_ext_begin(Entry, Visited), DFE = df_ext_end(Entry, Visited); DFI != DFE; ++DFI) { - enterBasicBlock(*DFI); + MBB = *DFI; + enterBasicBlock(); for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; ++I) { MachineInstr *mi = I; if (mi->isDebugValue()) continue; + ++Distance; std::pair domp = TII->GetSSEDomain(mi); if (domp.first) if (domp.second) visitSoftInstr(mi, domp.second); else visitHardInstr(mi, domp.first); - else if (hasLiveRegs) + else if (LiveRegs) visitGenericInstr(mi); } + + // Save live registers at end of MBB - used by enterBasicBlock(). + if (LiveRegs) + LiveOuts.insert(std::make_pair(MBB, LiveRegs)); + LiveRegs = 0; } + // Clear the LiveOuts vectors. Should we also collapse any remaining + // DomainValues? + for (LiveOutMap::const_iterator i = LiveOuts.begin(), e = LiveOuts.end(); + i != e; ++i) + free(i->second); + LiveOuts.clear(); Pool.Clear(); return false; From gohman at apple.com Tue Mar 30 15:04:57 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 30 Mar 2010 20:04:57 -0000 Subject: [llvm-commits] [llvm] r99917 - in /llvm/trunk: docs/ProgrammersManual.html lib/Archive/ArchiveWriter.cpp lib/System/Unix/Path.inc lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <20100330200458.2EEFA2A6C12C@llvm.org> Author: djg Date: Tue Mar 30 15:04:57 2010 New Revision: 99917 URL: http://llvm.org/viewvc/llvm-project?rev=99917&view=rev Log: Fix a grammaro. Modified: llvm/trunk/docs/ProgrammersManual.html llvm/trunk/lib/Archive/ArchiveWriter.cpp llvm/trunk/lib/System/Unix/Path.inc llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=99917&r1=99916&r2=99917&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Tue Mar 30 15:04:57 2010 @@ -3080,7 +3080,7 @@
FunctionType
Subclass of DerivedTypes for function types.
    -
  • bool isVarArg() const: Returns true if its a vararg +
  • bool isVarArg() const: Returns true if it's a vararg function
  • const Type * getReturnType() const: Returns the return type of the function.
  • Modified: llvm/trunk/lib/Archive/ArchiveWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Archive/ArchiveWriter.cpp?rev=99917&r1=99916&r2=99917&view=diff ============================================================================== --- llvm/trunk/lib/Archive/ArchiveWriter.cpp (original) +++ llvm/trunk/lib/Archive/ArchiveWriter.cpp Tue Mar 30 15:04:57 2010 @@ -220,7 +220,7 @@ } // Now that we have the data in memory, update the - // symbol table if its a bitcode file. + // symbol table if it's a bitcode file. if (CreateSymbolTable && member.isBitcode()) { std::vector symbols; std::string FullMemberName = archPath.str() + "(" + member.getPath().str() Modified: llvm/trunk/lib/System/Unix/Path.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Path.inc?rev=99917&r1=99916&r2=99917&view=diff ============================================================================== --- llvm/trunk/lib/System/Unix/Path.inc (original) +++ llvm/trunk/lib/System/Unix/Path.inc Tue Mar 30 15:04:57 2010 @@ -454,7 +454,7 @@ bool Path::isRegularFile() const { - // Get the status so we can determine if its a file or directory + // Get the status so we can determine if it's a file or directory struct stat buf; if (0 != stat(path.c_str(), &buf)) @@ -736,7 +736,7 @@ bool Path::eraseFromDisk(bool remove_contents, std::string *ErrStr) const { - // Get the status so we can determine if its a file or directory + // Get the status so we can determine if it's a file or directory. struct stat buf; if (0 != stat(path.c_str(), &buf)) { MakeErrMsg(ErrStr, path + ": can't get status of file"); Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=99917&r1=99916&r2=99917&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Mar 30 15:04:57 2010 @@ -224,7 +224,7 @@ if (BI->isUnconditional() && BI->getSuccessor(0) == BB) { if (!AggressiveInsts) return false; // Okay, it looks like the instruction IS in the "condition". Check to - // see if its a cheap instruction to unconditionally compute, and if it + // see if it's a cheap instruction to unconditionally compute, and if it // only uses stuff defined outside of the condition. If so, hoist it out. if (!I->isSafeToSpeculativelyExecute()) return false; From edwintorok at gmail.com Tue Mar 30 15:15:13 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Tue, 30 Mar 2010 20:15:13 -0000 Subject: [llvm-commits] [llvm] r99918 - /llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Message-ID: <20100330201513.32B8B2A6C12C@llvm.org> Author: edwin Date: Tue Mar 30 15:15:13 2010 New Revision: 99918 URL: http://llvm.org/viewvc/llvm-project?rev=99918&view=rev Log: Typo noticed by Duncan. Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99918&r1=99917&r2=99918&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Mar 30 15:15:13 2010 @@ -265,7 +265,7 @@ if (RF == RawFunctions->end()) { RawFn = (RawFunc)(intptr_t) sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName()); - if (!RawnFn) + if (!RawFn) RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F); if (RawFn != 0) RawFunctions->insert(std::make_pair(F, RawFn)); // Cache for later From benny.kra at googlemail.com Tue Mar 30 15:16:45 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 30 Mar 2010 20:16:45 -0000 Subject: [llvm-commits] [llvm] r99919 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/CodeGen/LiveIntervalAnalysis.h include/llvm/CodeGen/LiveStackAnalysis.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/LiveStackAnalysis.cpp lib/CodeGen/PreAllocSplitting.cpp lib/Support/Allocator.cpp Message-ID: <20100330201645.945CF2A6C12C@llvm.org> Author: d0k Date: Tue Mar 30 15:16:45 2010 New Revision: 99919 URL: http://llvm.org/viewvc/llvm-project?rev=99919&view=rev Log: Introduce SpecificBumpPtrAllocator, a wrapper for BumpPtrAllocator which allows only a single type of object to be allocated. Use it to make VNInfo destruction typesafe. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h llvm/trunk/include/llvm/Support/Allocator.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp llvm/trunk/lib/Support/Allocator.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Tue Mar 30 15:16:45 2010 @@ -67,7 +67,7 @@ } cr; public: - + typedef SpecificBumpPtrAllocator Allocator; typedef SmallVector KillSet; /// The ID number of this value. @@ -365,10 +365,8 @@ /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. VNInfo *getNextValue(SlotIndex def, MachineInstr *CopyMI, - bool isDefAccurate, BumpPtrAllocator &VNInfoAllocator){ - VNInfo *VNI = - static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), - alignof())); + bool isDefAccurate, VNInfo::Allocator &VNInfoAllocator) { + VNInfo *VNI = VNInfoAllocator.Allocate(); new (VNI) VNInfo((unsigned)valnos.size(), def, CopyMI); VNI->setIsDefAccurate(isDefAccurate); valnos.push_back(VNI); @@ -378,11 +376,8 @@ /// Create a copy of the given value. The new value will be identical except /// for the Value number. VNInfo *createValueCopy(const VNInfo *orig, - BumpPtrAllocator &VNInfoAllocator) { - VNInfo *VNI = - static_cast(VNInfoAllocator.Allocate((unsigned)sizeof(VNInfo), - alignof())); - + VNInfo::Allocator &VNInfoAllocator) { + VNInfo *VNI = VNInfoAllocator.Allocate(); new (VNI) VNInfo((unsigned)valnos.size(), *orig); valnos.push_back(VNI); return VNI; @@ -422,14 +417,14 @@ /// VNInfoAllocator since it will create a new val#. void MergeInClobberRanges(LiveIntervals &li_, const LiveInterval &Clobbers, - BumpPtrAllocator &VNInfoAllocator); + VNInfo::Allocator &VNInfoAllocator); /// MergeInClobberRange - Same as MergeInClobberRanges except it merge in a /// single LiveRange only. void MergeInClobberRange(LiveIntervals &li_, SlotIndex Start, SlotIndex End, - BumpPtrAllocator &VNInfoAllocator); + VNInfo::Allocator &VNInfoAllocator); /// MergeValueInAsValue - Merge all of the live ranges of a specific val# /// in RHS into this live interval as the specified value number. @@ -449,7 +444,7 @@ /// Copy - Copy the specified live interval. This copies all the fields /// except for the register of the interval. void Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI, - BumpPtrAllocator &VNInfoAllocator); + VNInfo::Allocator &VNInfoAllocator); bool empty() const { return ranges.empty(); } Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Tue Mar 30 15:16:45 2010 @@ -55,7 +55,7 @@ /// Special pool allocator for VNInfo's (LiveInterval val#). /// - BumpPtrAllocator VNInfoAllocator; + VNInfo::Allocator VNInfoAllocator; typedef DenseMap Reg2IntervalMap; Reg2IntervalMap r2iMap_; @@ -221,7 +221,7 @@ indexes_->renumberIndexes(); } - BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; } + VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; } /// getVNInfoSourceReg - Helper function that parses the specified VNInfo /// copy field and returns the source register that defines it. Modified: llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveStackAnalysis.h Tue Mar 30 15:16:45 2010 @@ -27,7 +27,7 @@ class LiveStacks : public MachineFunctionPass { /// Special pool allocator for VNInfo's (LiveInterval val#). /// - BumpPtrAllocator VNInfoAllocator; + VNInfo::Allocator VNInfoAllocator; /// S2IMap - Stack slot indices to live interval mapping. /// @@ -91,7 +91,7 @@ return I->second; } - BumpPtrAllocator& getVNInfoAllocator() { return VNInfoAllocator; } + VNInfo::Allocator& getVNInfoAllocator() { return VNInfoAllocator; } virtual void getAnalysisUsage(AnalysisUsage &AU) const; virtual void releaseMemory(); Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Tue Mar 30 15:16:45 2010 @@ -133,8 +133,8 @@ static MallocSlabAllocator DefaultSlabAllocator; + template friend class SpecificBumpPtrAllocator; public: - typedef void (*DTorFunction)(void*); BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, SlabAllocator &allocator = DefaultSlabAllocator); ~BumpPtrAllocator(); @@ -143,11 +143,6 @@ /// to the beginning of it, freeing all memory allocated so far. void Reset(); - /// Reset - like Reset(), but call DTorFunction for each allocated - /// object. This assumes that all objects allocated with this allocator - /// had the same size and alignment specified here. - void Reset(size_t Size, size_t Alignment, DTorFunction DTor); - /// Allocate - Allocate space at the specified alignment. /// void *Allocate(size_t Size, size_t Alignment); @@ -182,6 +177,45 @@ void PrintStats() const; }; +/// SpecificBumpPtrAllocator - Same as BumpPtrAllocator but allows only +/// elements of one type to be allocated. This allows calling the destructor +/// in DestroyAll() and when the allocator is destroyed. +template +class SpecificBumpPtrAllocator { + BumpPtrAllocator Allocator; +public: + SpecificBumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, + SlabAllocator &allocator = BumpPtrAllocator::DefaultSlabAllocator) + : Allocator(size, threshold, allocator) {} + + ~SpecificBumpPtrAllocator() { + DestroyAll(); + } + + /// Call the destructor of each allocated object and deallocate all but the + /// current slab and reset the current pointer to the beginning of it, freeing + /// all memory allocated so far. + void DestroyAll() { + MemSlab *Slab = Allocator.CurSlab; + while (Slab) { + char *End = Slab == Allocator.CurSlab ? Allocator.CurPtr : + (char *)Slab + Slab->Size; + for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += sizeof(T)) { + Ptr = Allocator.AlignPtr(Ptr, alignof()); + if (Ptr + sizeof(T) <= End) + reinterpret_cast(Ptr)->~T(); + } + Slab = Slab->NextPtr; + } + Allocator.Reset(); + } + + /// Allocate space for a specific count of elements. + T *Allocate(size_t num = 1) { + return Allocator.Allocate(num); + } +}; + } // end namespace llvm inline void *operator new(size_t Size, llvm::BumpPtrAllocator &Allocator) { Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 15:16:45 2010 @@ -591,7 +591,7 @@ /// used with an unknown definition value. void LiveInterval::MergeInClobberRanges(LiveIntervals &li_, const LiveInterval &Clobbers, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { if (Clobbers.empty()) return; DenseMap ValNoMaps; @@ -658,7 +658,7 @@ void LiveInterval::MergeInClobberRange(LiveIntervals &li_, SlotIndex Start, SlotIndex End, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { // Find a value # to use for the clobber ranges. If there is already a value# // for unknown values, use it. VNInfo *ClobberValNo = @@ -753,7 +753,7 @@ void LiveInterval::Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI, - BumpPtrAllocator &VNInfoAllocator) { + VNInfo::Allocator &VNInfoAllocator) { ranges.clear(); valnos.clear(); std::pair Hint = MRI->getRegAllocationHint(RHS.reg); Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Mar 30 15:16:45 2010 @@ -82,11 +82,6 @@ MachineFunctionPass::getAnalysisUsage(AU); } -static void VNInfoDTor(void* Ptr) -{ - reinterpret_cast(Ptr)->~VNInfo(); -} - void LiveIntervals::releaseMemory() { // Free the live intervals themselves. for (DenseMap::iterator I = r2iMap_.begin(), @@ -96,7 +91,7 @@ r2iMap_.clear(); // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset((unsigned)sizeof(VNInfo), alignof(), VNInfoDTor); + VNInfoAllocator.DestroyAll(); while (!CloneMIs.empty()) { MachineInstr *MI = CloneMIs.back(); CloneMIs.pop_back(); Modified: llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveStackAnalysis.cpp Tue Mar 30 15:16:45 2010 @@ -36,7 +36,7 @@ void LiveStacks::releaseMemory() { // Release VNInfo memroy regions after all VNInfo objects are dtor'd. - VNInfoAllocator.Reset(); + VNInfoAllocator.DestroyAll(); S2IMap.clear(); S2RCMap.clear(); } Modified: llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp (original) +++ llvm/trunk/lib/CodeGen/PreAllocSplitting.cpp Tue Mar 30 15:16:45 2010 @@ -665,7 +665,7 @@ /// ReconstructLiveInterval - Recompute a live interval from scratch. void PreAllocSplitting::ReconstructLiveInterval(LiveInterval* LI) { - BumpPtrAllocator& Alloc = LIs->getVNInfoAllocator(); + VNInfo::Allocator& Alloc = LIs->getVNInfoAllocator(); // Clear the old ranges and valnos; LI->clear(); Modified: llvm/trunk/lib/Support/Allocator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Allocator.cpp?rev=99919&r1=99918&r2=99919&view=diff ============================================================================== --- llvm/trunk/lib/Support/Allocator.cpp (original) +++ llvm/trunk/lib/Support/Allocator.cpp Tue Mar 30 15:16:45 2010 @@ -78,21 +78,6 @@ End = ((char*)CurSlab) + CurSlab->Size; } -void BumpPtrAllocator::Reset(size_t Size, size_t Alignment, DTorFunction DTor) { - if (Alignment == 0) Alignment = 1; - MemSlab *Slab = CurSlab; - while (Slab) { - char *End = Slab == CurSlab ? CurPtr : (char*)Slab + Slab->Size; - for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += Size) { - Ptr = AlignPtr(Ptr, Alignment); - if (Ptr + Size <= End) - DTor(Ptr); - } - Slab = Slab->NextPtr; - } - Reset(); -} - /// Allocate - Allocate space at the specified alignment. /// void *BumpPtrAllocator::Allocate(size_t Size, size_t Alignment) { From benny.kra at googlemail.com Tue Mar 30 15:17:57 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 30 Mar 2010 22:17:57 +0200 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: References: <20100330111748.9148F2A6C12C@llvm.org> <4BB22B8B.7010002@gmail.com> <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> Message-ID: On 30.03.2010, at 21:46, Jakob Stoklund Olesen wrote: > > On Mar 30, 2010, at 12:17 PM, Benjamin Kramer wrote: > >> >> On 30.03.2010, at 19:00, Jakob Stoklund Olesen wrote: >> >>> >>> On Mar 30, 2010, at 9:49 AM, T?r?k Edwin wrote: >>> >>>> On 03/30/2010 07:32 PM, Jakob Stoklund Olesen wrote: >>> >>>>> A template class that is only capable of allocating one type would be safer. >>>> >>>> Sounds good, the template could automatically call the destructor when >>>> Reset() is called, without the need for the special Reset() method. >> >> I quickly put together a patch that adds a templated BumpPtrAllocator and allocates all VNInfos through it. >> >> > > Looks good to me, thanks! > > I would rename Reset() to something more ominous, like DestroyAll(). > > + void Deallocate(const T *Ptr) { > + Ptr->~T(); > + } > > Is that one necessary? If you are going to destroy single elements, you should not be using this class in the first place. Fixed & Committed revision 99919. From stoklund at 2pi.dk Tue Mar 30 15:20:29 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 13:20:29 -0700 Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp In-Reply-To: References: <20100330111748.9148F2A6C12C@llvm.org> <4BB22B8B.7010002@gmail.com> <756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk> Message-ID: <326FDA8E-4F4A-47AB-8B0F-50D1E3C988AF@2pi.dk> On Mar 30, 2010, at 1:17 PM, Benjamin Kramer wrote: > Fixed & Committed revision 99919. Awesome, thanks! From dalej at apple.com Tue Mar 30 15:39:52 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 30 Mar 2010 20:39:52 -0000 Subject: [llvm-commits] [test-suite] r99924 - /test-suite/trunk/TEST.m2regllcdbg.Makefile Message-ID: <20100330203952.486162A6C12C@llvm.org> Author: johannes Date: Tue Mar 30 15:39:52 2010 New Revision: 99924 URL: http://llvm.org/viewvc/llvm-project?rev=99924&view=rev Log: Remove Ltmp labels from comparison. Dwarf generator makes these and they won't be the same in debug and non-debug versions. Modified: test-suite/trunk/TEST.m2regllcdbg.Makefile Modified: test-suite/trunk/TEST.m2regllcdbg.Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.m2regllcdbg.Makefile?rev=99924&r1=99923&r2=99924&view=diff ============================================================================== --- test-suite/trunk/TEST.m2regllcdbg.Makefile (original) +++ test-suite/trunk/TEST.m2regllcdbg.Makefile Tue Mar 30 15:39:52 2010 @@ -32,7 +32,7 @@ $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC) - grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ + grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT) $(LOPT) -strip-nondebug $< -f -o $@ @@ -44,7 +44,7 @@ $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ Output/%.second.s: Output/%.t2c.s Output/.dir - grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ + grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ Output/%.diff: Output/%.first.s Output/%.second.s @-if diff $^ > $@; then \ From clattner at apple.com Tue Mar 30 15:48:28 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 13:48:28 -0700 Subject: [llvm-commits] [test-suite] r99924 - /test-suite/trunk/TEST.m2regllcdbg.Makefile In-Reply-To: <20100330203952.486162A6C12C@llvm.org> References: <20100330203952.486162A6C12C@llvm.org> Message-ID: <77E2920C-60A4-4299-B3A7-BAC87552DE44@apple.com> On Mar 30, 2010, at 1:39 PM, Dale Johannesen wrote: > Author: johannes > Date: Tue Mar 30 15:39:52 2010 > New Revision: 99924 > > URL: http://llvm.org/viewvc/llvm-project?rev=99924&view=rev > Log: > Remove Ltmp labels from comparison. Dwarf generator > makes these and they won't be the same in debug and non-debug > versions. Right, these get stripped by the assembler so they won't make it to the .o file. -Chris > > > Modified: > test-suite/trunk/TEST.m2regllcdbg.Makefile > > Modified: test-suite/trunk/TEST.m2regllcdbg.Makefile > URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.m2regllcdbg.Makefile?rev=99924&r1=99923&r2=99924&view=diff > ============================================================================== > --- test-suite/trunk/TEST.m2regllcdbg.Makefile (original) > +++ test-suite/trunk/TEST.m2regllcdbg.Makefile Tue Mar 30 15:39:52 2010 > @@ -32,7 +32,7 @@ > $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ > > Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC) > - grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ > + grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ > > Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT) > $(LOPT) -strip-nondebug $< -f -o $@ > @@ -44,7 +44,7 @@ > $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ > > Output/%.second.s: Output/%.t2c.s Output/.dir > - grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ > + grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ > > Output/%.diff: Output/%.first.s Output/%.second.s > @-if diff $^ > $@; then \ > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From sabre at nondot.org Tue Mar 30 15:48:48 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 20:48:48 -0000 Subject: [llvm-commits] [llvm] r99927 - in /llvm/trunk/lib/VMCore: Constants.cpp LLVMContext.cpp Metadata.cpp Message-ID: <20100330204848.B135E2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 15:48:48 2010 New Revision: 99927 URL: http://llvm.org/viewvc/llvm-project?rev=99927&view=rev Log: move some method definitions to files that make sense. Modified: llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/LLVMContext.cpp llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=99927&r1=99926&r2=99927&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Mar 30 15:48:48 2010 @@ -1947,6 +1947,20 @@ return Instruction::getOpcodeName(getOpcode()); } + + +GetElementPtrConstantExpr:: +GetElementPtrConstantExpr(Constant *C, const std::vector &IdxList, + const Type *DestTy) + : ConstantExpr(DestTy, Instruction::GetElementPtr, + OperandTraits::op_end(this) + - (IdxList.size()+1), IdxList.size()+1) { + OperandList[0] = C; + for (unsigned i = 0, E = IdxList.size(); i != E; ++i) + OperandList[i+1] = IdxList[i]; +} + + //===----------------------------------------------------------------------===// // replaceUsesOfWithOnConstant implementations Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=99927&r1=99926&r2=99927&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContext.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Mar 30 15:48:48 2010 @@ -29,16 +29,45 @@ LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { } LLVMContext::~LLVMContext() { delete pImpl; } -GetElementPtrConstantExpr::GetElementPtrConstantExpr - (Constant *C, - const std::vector &IdxList, - const Type *DestTy) - : ConstantExpr(DestTy, Instruction::GetElementPtr, - OperandTraits::op_end(this) - - (IdxList.size()+1), - IdxList.size()+1) { - OperandList[0] = C; - for (unsigned i = 0, E = IdxList.size(); i != E; ++i) - OperandList[i+1] = IdxList[i]; + +#ifndef NDEBUG +/// isValidName - Return true if Name is a valid custom metadata handler name. +static bool isValidName(StringRef MDName) { + if (MDName.empty()) + return false; + + if (!isalpha(MDName[0])) + return false; + + for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E; + ++I) { + if (!isalnum(*I) && *I != '_' && *I != '-' && *I != '.') + return false; + } + return true; +} +#endif + +/// getMDKindID - Return a unique non-zero ID for the specified metadata kind. +unsigned LLVMContext::getMDKindID(StringRef Name) const { + assert(isValidName(Name) && "Invalid MDNode name"); + + unsigned &Entry = pImpl->CustomMDKindNames[Name]; + + // If this is new, assign it its ID. + if (Entry == 0) Entry = pImpl->CustomMDKindNames.size(); + return Entry; } +/// getHandlerNames - Populate client supplied smallvector using custome +/// metadata name and ID. +void LLVMContext::getMDKindNames(SmallVectorImpl &Names) const { + Names.resize(pImpl->CustomMDKindNames.size()+1); + Names[0] = ""; + for (StringMap::const_iterator I = pImpl->CustomMDKindNames.begin(), + E = pImpl->CustomMDKindNames.end(); I != E; ++I) + // MD Handlers are numbered from 1. + Names[I->second] = I->first(); +} + + Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=99927&r1=99926&r2=99927&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Mar 30 15:48:48 2010 @@ -412,50 +412,6 @@ } //===----------------------------------------------------------------------===// -// LLVMContext MDKind naming implementation. -// - -#ifndef NDEBUG -/// isValidName - Return true if Name is a valid custom metadata handler name. -static bool isValidName(StringRef MDName) { - if (MDName.empty()) - return false; - - if (!isalpha(MDName[0])) - return false; - - for (StringRef::iterator I = MDName.begin() + 1, E = MDName.end(); I != E; - ++I) { - if (!isalnum(*I) && *I != '_' && *I != '-' && *I != '.') - return false; - } - return true; -} -#endif - -/// getMDKindID - Return a unique non-zero ID for the specified metadata kind. -unsigned LLVMContext::getMDKindID(StringRef Name) const { - assert(isValidName(Name) && "Invalid MDNode name"); - - unsigned &Entry = pImpl->CustomMDKindNames[Name]; - - // If this is new, assign it its ID. - if (Entry == 0) Entry = pImpl->CustomMDKindNames.size(); - return Entry; -} - -/// getHandlerNames - Populate client supplied smallvector using custome -/// metadata name and ID. -void LLVMContext::getMDKindNames(SmallVectorImpl &Names) const { - Names.resize(pImpl->CustomMDKindNames.size()+1); - Names[0] = ""; - for (StringMap::const_iterator I = pImpl->CustomMDKindNames.begin(), - E = pImpl->CustomMDKindNames.end(); I != E; ++I) - // MD Handlers are numbered from 1. - Names[I->second] = I->first(); -} - -//===----------------------------------------------------------------------===// // Instruction Metadata method implementations. // From wangmp at apple.com Tue Mar 30 15:55:57 2010 From: wangmp at apple.com (Mon P Wang) Date: Tue, 30 Mar 2010 20:55:57 -0000 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ Message-ID: <20100330205557.B1D5A2A6C12C@llvm.org> Author: wangmp Date: Tue Mar 30 15:55:56 2010 New Revision: 99928 URL: http://llvm.org/viewvc/llvm-project?rev=99928&view=rev Log: Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset, e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) A update of langref will occur in a subsequent checkin. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/Analysis/BasicAA/modref.ll llvm/trunk/test/Transforms/InstCombine/memset_chk.ll llvm/trunk/test/Transforms/InstCombine/objsize.ll llvm/trunk/test/Transforms/MemCpyOpt/align.ll llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Tue Mar 30 15:55:56 2010 @@ -534,17 +534,17 @@ SDValue getStackArgumentTokenFactor(SDValue Chain); SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool AlwaysInline, + SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, + SDValue Size, unsigned Align, bool isVol, const Value *DstSV, uint64_t DstOSVff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, + SDValue Size, unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff); /// getSetCC - Helper function to make it easier to build SetCC's if you just Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Tue Mar 30 15:55:56 2010 @@ -133,6 +133,13 @@ return getAlignmentCst()->getZExtValue(); } + ConstantInt *getVolatileCst() const { + return cast(const_cast(getOperand(5))); + } + bool isVolatile() const { + return getVolatileCst()->getZExtValue() != 0; + } + /// getDest - This is just like getRawDest, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. @@ -155,7 +162,11 @@ void setAlignment(Constant* A) { setOperand(4, A); } - + + void setVolatile(Constant* V) { + setOperand(5, V); + } + const Type *getAlignmentType() const { return getOperand(4)->getType(); } Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Tue Mar 30 15:55:56 2010 @@ -224,16 +224,16 @@ // def int_memcpy : Intrinsic<[], - [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memmove : Intrinsic<[], - [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memset : Intrinsic<[], - [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>]>; // These functions do not actually read memory, but they are sensitive to the Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Mar 30 15:55:56 2010 @@ -909,6 +909,11 @@ Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; return Insert(CallInst::Create(Callee, Args, Args+4), Name); } + CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, + Value *Arg4, Value *Arg5, const Twine &Name = "") { + Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; + return Insert(CallInst::Create(Callee, Args, Args+5), Name); + } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Mar 30 15:55:56 2010 @@ -1184,7 +1184,7 @@ EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { @@ -1201,7 +1201,7 @@ EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { return SDValue(); @@ -1217,7 +1217,7 @@ EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, const Value *DstSV, uint64_t DstOff) { return SDValue(); } Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Tue Mar 30 15:55:56 2010 @@ -46,8 +46,8 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD); /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src @@ -57,8 +57,8 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD); /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. @@ -70,8 +70,8 @@ const TargetData *TD); /// EmitMemSet - Emit a call to the memset function - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, - const TargetData *TD); + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, + IRBuilder<> &B, const TargetData *TD); /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' /// (e.g. 'floor'). This function is known to take a single of type matching Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Mar 30 15:55:56 2010 @@ -3275,7 +3275,8 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool AlwaysInline, + unsigned Align, bool isVol, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3312,7 +3313,7 @@ Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, DstAlign); + DstSV, DstSVOff + DstOff, isVol, false, DstAlign); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3323,10 +3324,10 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); + SrcSV, SrcSVOff + SrcOff, VT, isVol, false, Align); Store = DAG.getTruncStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, VT, false, false, + DstSV, DstSVOff + DstOff, VT, isVol, false, DstAlign); } OutChains.push_back(Store); @@ -3341,7 +3342,8 @@ static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool AlwaysInline, + unsigned Align, bool isVol, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3372,7 +3374,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, false, false, Align); + SrcSV, SrcSVOff + SrcOff, isVol, false, Align); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3387,7 +3389,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, DstAlign); + DstSV, DstSVOff + DstOff, isVol, false, DstAlign); OutChains.push_back(Store); DstOff += VTSize; } @@ -3399,7 +3401,7 @@ static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3422,7 +3424,7 @@ SDValue Value = getMemsetValue(Src, VT, DAG, dl); SDValue Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, 0); + DstSV, DstSVOff + DstOff, isVol, false, 0); OutChains.push_back(Store); DstOff += VTSize; } @@ -3433,7 +3435,7 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool AlwaysInline, + unsigned Align, bool isVol, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3447,8 +3449,8 @@ SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, isVol, + false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3457,7 +3459,7 @@ // code. If the target chooses to do this, this is the next best. SDValue Result = TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, - AlwaysInline, + isVol, AlwaysInline, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; @@ -3467,11 +3469,12 @@ if (AlwaysInline) { assert(ConstantSize && "AlwaysInline requires a constant size!"); return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, true, - DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, isVol, + true, DstSV, DstSVOff, SrcSV, SrcSVOff); } // Emit a library call. + assert(!isVol && "library memcpy does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3492,7 +3495,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3506,8 +3509,8 @@ SDValue Result = getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, isVol, + false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3515,12 +3518,13 @@ // Then check to see if we should lower the memmove with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; // Emit a library call. + assert(!isVol && "library memmove does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3541,7 +3545,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff) { // Check to see if we should lower the memset to stores first. @@ -3554,7 +3558,7 @@ SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), - Align, DstSV, DstSVOff); + Align, isVol, DstSV, DstSVOff); if (Result.getNode()) return Result; } @@ -3562,12 +3566,13 @@ // Then check to see if we should lower the memset with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, DstSV, DstSVOff); if (Result.getNode()) return Result; // Emit a library call. + assert(!isVol && "library memset does not support volatile"); const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Mar 30 15:55:56 2010 @@ -3731,28 +3731,50 @@ case Intrinsic::longjmp: return "_longjmp"+!TLI.usesUnderscoreLongJmp(); case Intrinsic::memcpy: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + cast(I.getOperand(2)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, + bool isVol = cast(I.getOperand(5))->getZExtValue(); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } case Intrinsic::memset: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, + bool isVol = cast(I.getOperand(5))->getZExtValue(); + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, I.getOperand(1), 0)); return 0; } case Intrinsic::memmove: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + cast(I.getOperand(2)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); + bool isVol = cast(I.getOperand(5))->getZExtValue(); // If the source and destination are known to not be aliases, we can // lower memmove as memcpy. @@ -3761,12 +3783,12 @@ Size = C->getZExtValue(); if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == AliasAnalysis::NoAlias) { - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, - I.getOperand(1), 0, I.getOperand(2), 0)); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Mar 30 15:55:56 2010 @@ -861,7 +861,8 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*AlwaysInline=*/false, NULL, 0, NULL, 0); + /*isVolatile=*/false, /*AlwaysInline=*/false, + NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack. @@ -2053,7 +2054,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ // Do repeated 4-byte loads and stores. To be improved. @@ -2089,7 +2090,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff, false, false, 0); + SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -2100,7 +2101,7 @@ TFOps[i] = DAG.getStore(Chain, dl, Loads[i], DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff, false, false, 0); + DstSV, DstSVOff + DstOff, isVolatile, false, 0); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Mar 30 15:55:56 2010 @@ -305,7 +305,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue LowerCallResult(SDValue Chain, SDValue InFlag, Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Mar 30 15:55:56 2010 @@ -2392,7 +2392,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - false, NULL, 0, NULL, 0); + false, false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Mar 30 15:55:56 2010 @@ -1422,7 +1422,8 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*AlwaysInline=*/true, NULL, 0, NULL, 0); + /*isVolatile*/false, /*AlwaysInline=*/true, + NULL, 0, NULL, 0); } /// IsTailCallConvention - Return true if the calling convention is one that @@ -6539,6 +6540,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, + bool isVolatile, const Value *DstSV, uint64_t DstSVOff) { ConstantSDNode *ConstantSize = dyn_cast(Size); @@ -6667,7 +6669,7 @@ DAG.getConstant(Offset, AddrVT)), Src, DAG.getConstant(BytesLeft, SizeVT), - Align, DstSV, DstSVOff + Offset); + Align, isVolatile, DstSV, DstSVOff + Offset); } // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. @@ -6678,7 +6680,7 @@ X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { // This requires the copy size to be a constant, preferrably @@ -6737,7 +6739,7 @@ DAG.getNode(ISD::ADD, dl, SrcVT, Src, DAG.getConstant(Offset, SrcVT)), DAG.getConstant(BytesLeft, SizeVT), - Align, AlwaysInline, + Align, isVolatile, AlwaysInline, DstSV, DstSVOff + Offset, SrcSV, SrcSVOff + Offset)); } @@ -6820,8 +6822,8 @@ DebugLoc dl = Op.getDebugLoc(); return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, - DAG.getIntPtrConstant(24), 8, false, - DstSV, 0, SrcSV, 0); + DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, + false, DstSV, 0, SrcSV, 0); } SDValue Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Mar 30 15:55:56 2010 @@ -737,12 +737,13 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, + bool isVolatile, const Value *DstSV, uint64_t DstSVOff); SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); @@ -752,7 +753,7 @@ /// block, the number of args, and whether or not the second arg is /// in memory or not. MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, - unsigned argNum, bool inMem) const; + unsigned argNum, bool inMem) const; /// Utility function to emit atomic bitwise operations (and, or, xor). /// It takes the bitwise instruction to expand, the associated machine basic Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Tue Mar 30 15:55:56 2010 @@ -1443,7 +1443,7 @@ return DAG.getMemmove(Chain, dl, ST->getBasePtr(), LD->getBasePtr(), DAG.getConstant(StoreBits/8, MVT::i32), - Alignment, ST->getSrcValue(), + Alignment, false, ST->getSrcValue(), ST->getSrcValueOffset(), LD->getSrcValue(), LD->getSrcValueOffset()); } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Mar 30 15:55:56 2010 @@ -136,8 +136,14 @@ return 0; // If not 1/2/4/8 bytes, exit. // Use an integer load+store unless we can find something better. - Type *NewPtrTy = - PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); + unsigned SrcAddrSp = + cast(MI->getOperand(2)->getType())->getAddressSpace(); + unsigned DstAddrSp = + cast(MI->getOperand(1)->getType())->getAddressSpace(); + + const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); + Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); + Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); // Memcpy forces the use of i8* for the source and destination. That means // that if you're using memcpy to move one double around, you'll get a cast @@ -167,8 +173,10 @@ break; } - if (SrcETy->isSingleValueType()) - NewPtrTy = PointerType::getUnqual(SrcETy); + if (SrcETy->isSingleValueType()) { + NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); + NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); + } } } @@ -178,11 +186,12 @@ SrcAlign = std::max(SrcAlign, CopyAlign); DstAlign = std::max(DstAlign, CopyAlign); - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); - Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); + Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); InsertNewInstBefore(L, *MI); - InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); + InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), + *MI); // Set the size of the copy to 0, it will be deleted on the next iteration. MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); @@ -275,10 +284,11 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - const Type *Tys[1]; - Tys[0] = CI.getOperand(3)->getType(); + const Type *Tys[3] = { CI.getOperand(1)->getType(), + CI.getOperand(2)->getType(), + CI.getOperand(3)->getType() }; CI.setOperand(0, - Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); + Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); Changed = true; } } Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Mar 30 15:55:56 2010 @@ -413,7 +413,6 @@ // interesting as a small compile-time optimization. Ranges.addStore(0, SI); - Function *MemSetF = 0; // Now that we have full information about ranges, loop over the ranges and // emit memset's for anything big enough to be worthwhile. @@ -433,29 +432,40 @@ // memset block. This ensure that the memset is dominated by any addressing // instruction needed by the start of the block. BasicBlock::iterator InsertPt = BI; - - if (MemSetF == 0) { - const Type *Ty = Type::getInt64Ty(Context); - MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); - } - + // Get the starting pointer of the block. StartPtr = Range.StartPtr; - + + // Determine alignment + unsigned Alignment = Range.Alignment; + if (Alignment == 0) { + const Type *EltType = + cast(StartPtr->getType())->getElementType(); + Alignment = TD->getABITypeAlignment(EltType); + } + // Cast the start ptr to be i8* as memset requires. - const Type *i8Ptr = Type::getInt8PtrTy(Context); - if (StartPtr->getType() != i8Ptr) + const PointerType* StartPTy = cast(StartPtr->getType()); + const PointerType *i8Ptr = Type::getInt8PtrTy(Context, + StartPTy->getAddressSpace()); + if (StartPTy!= i8Ptr) StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), InsertPt); - + Value *Ops[] = { StartPtr, ByteVal, // Start, value // size ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), // align - ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) + ConstantInt::get(Type::getInt32Ty(Context), Alignment), + // volatile + ConstantInt::get(Type::getInt1Ty(Context), 0), }; - Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); + const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; + + Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); + + Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); DEBUG(dbgs() << "Replace stores:\n"; for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) dbgs() << *Range.TheStores[i]; @@ -680,16 +690,19 @@ return false; // If all checks passed, then we can transform these memcpy's - const Type *Ty = M->getLength()->getType(); + const Type *ArgTys[3] = { M->getRawDest()->getType(), + MDep->getRawSource()->getType(), + M->getLength()->getType() }; Function *MemCpyFun = Intrinsic::getDeclaration( M->getParent()->getParent()->getParent(), - M->getIntrinsicID(), &Ty, 1); + M->getIntrinsicID(), ArgTys, 3); - Value *Args[4] = { - M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() + Value *Args[5] = { + M->getRawDest(), MDep->getRawSource(), M->getLength(), + M->getAlignmentCst(), M->getVolatileCst() }; - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); // If C and M don't interfere, then this is a valid transformation. If they @@ -728,8 +741,10 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - const Type *Ty = M->getLength()->getType(); - M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); + const Type *ArgTys[3] = { M->getDest()->getType(), M->getSource()->getType(), + M->getLength()->getType() }; + M->setOperand(0, + Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); // MemDep may have over conservative information about this instruction, just // conservatively flush it from the cache. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Mar 30 15:55:56 2010 @@ -858,8 +858,17 @@ EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); // Cast the other pointer (if we have one) to BytePtrTy. - if (OtherElt && OtherElt->getType() != BytePtrTy) - OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); + if (OtherElt && OtherElt->getType() != BytePtrTy) { + // Preserve address space of OtherElt + const PointerType* OtherPTy = cast(OtherElt->getType()); + const PointerType* PTy = cast(BytePtrTy); + if (OtherPTy->getElementType() != PTy->getElementType()) { + Type *NewOtherPTy = PointerType::get(PTy->getElementType(), + OtherPTy->getAddressSpace()); + OtherElt = new BitCastInst(OtherElt, NewOtherPTy, + OtherElt->getNameStr(), MI); + } + } unsigned EltSize = TD->getTypeAllocSize(EltTy); @@ -870,17 +879,28 @@ SROADest ? OtherElt : EltPtr, // Src ptr ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size // Align - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), + MI->getVolatileCst() }; - CallInst::Create(TheFn, Ops, Ops + 4, "", MI); + // In case we fold the address space overloaded memcpy of A to B + // with memcpy of B to C, change the function to be a memcpy of A to C. + const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), + Ops[2]->getType() }; + Module *M = MI->getParent()->getParent()->getParent(); + TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); + CallInst::Create(TheFn, Ops, Ops + 5, "", MI); } else { assert(isa(MI)); Value *Ops[] = { EltPtr, MI->getOperand(2), // Dest, Value, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size - Zero // Align + Zero, // Align + ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile }; - CallInst::Create(TheFn, Ops, Ops + 4, "", MI); + const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; + Module *M = MI->getParent()->getParent()->getParent(); + TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); + CallInst::Create(TheFn, Ops, Ops + 5, "", MI); } } DeadInsts.push_back(MI); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Tue Mar 30 15:55:56 2010 @@ -142,7 +142,8 @@ // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. EmitMemCpy(CpyDst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), + 1, false, B, TD); } }; @@ -383,7 +384,8 @@ CI->getOperand(3), B, TD); else EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), + 1, false, B, TD); return Dst; } }; @@ -411,8 +413,8 @@ if (SrcLen == 0) { // strncpy(x, "", y) -> memset(x, '\0', y, 1) - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, - B, TD); + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), + LenOp, false, B, TD); return Dst; } @@ -432,7 +434,8 @@ // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), + 1, false, B, TD); return Dst; } @@ -593,7 +596,7 @@ // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, B, TD); + CI->getOperand(3), 1, false, B, TD); return CI->getOperand(1); } }; @@ -615,7 +618,7 @@ // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) EmitMemMove(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, B, TD); + CI->getOperand(3), 1, false, B, TD); return CI->getOperand(1); } }; @@ -637,8 +640,8 @@ // memset(p, v, n) -> llvm.memset(p, v, n, 1) Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), - false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); + false); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); return CI->getOperand(1); } }; @@ -999,7 +1002,7 @@ // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. ConstantInt::get(TD->getIntPtrType(*Context), - FormatStr.size()+1), 1, B, TD); + FormatStr.size()+1), 1, false, B, TD); return ConstantInt::get(CI->getType(), FormatStr.size()); } @@ -1013,11 +1016,11 @@ // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), - Type::getInt8Ty(*Context), "char"); + Type::getInt8Ty(*Context), "char"); Value *Ptr = CastToCStr(CI->getOperand(1), B); B.CreateStore(V, Ptr); Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), - "nul"); + "nul"); B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); return ConstantInt::get(CI->getType(), 1); @@ -1034,7 +1037,7 @@ Value *IncLen = B.CreateAdd(Len, ConstantInt::get(Len->getType(), 1), "leninc"); - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); // The sprintf result is the unincremented number of bytes in the string. return B.CreateIntCast(Len, CI->getType(), false); Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Tue Mar 30 15:55:56 2010 @@ -109,15 +109,16 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always /// expects that Len has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); - const Type *Ty = Len->getType(); - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); + const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); - return B.CreateCall4(MemCpy, Dst, Src, Len, - ConstantInt::get(B.getInt32Ty(), Align)); + return B.CreateCall5(MemCpy, Dst, Src, Len, + ConstantInt::get(B.getInt32Ty(), Align), + ConstantInt::get(B.getInt1Ty(), isVolatile)); } /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. @@ -146,16 +147,18 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); LLVMContext &Context = B.GetInsertBlock()->getContext(); - const Type *Ty = TD->getIntPtrType(Context); - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); + const Type *ArgTys[3] = { Dst->getType(), Src->getType(), + TD->getIntPtrType(Context) }; + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); Value *A = ConstantInt::get(B.getInt32Ty(), Align); - return B.CreateCall4(MemMove, Dst, Src, Len, A); + Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); + return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); } /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is @@ -206,15 +209,15 @@ } /// EmitMemSet - Emit a call to the memset function -Value *llvm::EmitMemSet(Value *Dst, Value *Val, - Value *Len, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, + IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Intrinsic::ID IID = Intrinsic::memset; - const Type *Tys[1]; - Tys[0] = Len->getType(); - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); + const Type *Tys[2] = { Dst->getType(), Len->getType() }; + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); Value *Align = ConstantInt::get(B.getInt32Ty(), 1); - return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); + Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); + return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); } /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. @@ -381,7 +384,7 @@ if (Name == "__memcpy_chk") { if (isFoldable(4, 3, false)) { EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, B, TD); + 1, false, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -396,7 +399,7 @@ if (Name == "__memmove_chk") { if (isFoldable(4, 3, false)) { EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, B, TD); + 1, false, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -407,7 +410,7 @@ if (isFoldable(4, 3, false)) { Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); replaceCall(CI->getOperand(1)); return true; } Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Mar 30 15:55:56 2010 @@ -297,10 +297,10 @@ I->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - const Type *Tys[] = { Type::getInt64Ty(Context) }; + const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, - Tys, 1); + Tys, 3); Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); @@ -309,17 +309,18 @@ Size = ConstantExpr::getSizeOf(AggTy); else Size = ConstantInt::get(Type::getInt64Ty(Context), - TD->getTypeStoreSize(AggTy)); + TD->getTypeStoreSize(AggTy)); // Always generate a memcpy of alignment 1 here because we don't know // the alignment of the src pointer. Other optimizations can infer // better alignment. Value *CallArgs[] = { DestCast, SrcCast, Size, - ConstantInt::get(Type::getInt32Ty(Context), 1) + ConstantInt::get(Type::getInt32Ty(Context), 1), + ConstantInt::get(Type::getInt1Ty(Context), 0) }; CallInst *TheMemCpy = - CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); + CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); // If we have a call graph, update it. if (CG) { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Mar 30 15:55:56 2010 @@ -145,6 +145,54 @@ } break; + case 'm': { + // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the + // new format that allows overloading the pointer for different address + // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) + const char* NewFnName = NULL; + if (Name.compare(5,8,"memcpy.i",8) == 0) { + if (Name[13] == '8') + NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; + else if (Name.compare(13,2,"16") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; + else if (Name.compare(13,2,"32") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; + else if (Name.compare(13,2,"64") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; + } else if (Name.compare(5,9,"memmove.i",9) == 0) { + if (Name[14] == '8') + NewFnName = "llvm.memmove.p0i8.p0i8.i8"; + else if (Name.compare(14,2,"16") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i16"; + else if (Name.compare(14,2,"32") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i32"; + else if (Name.compare(14,2,"64") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i64"; + } + else if (Name.compare(5,8,"memset.i",8) == 0) { + if (Name[13] == '8') + NewFnName = "llvm.memset.p0i8.i8"; + else if (Name.compare(13,2,"16") == 0) + NewFnName = "llvm.memset.p0i8.i16"; + else if (Name.compare(13,2,"32") == 0) + NewFnName = "llvm.memset.p0i8.i32"; + else if (Name.compare(13,2,"64") == 0) + NewFnName = "llvm.memset.p0i8.i64"; + } + if (NewFnName) { + const FunctionType *FTy = F->getFunctionType(); + NewFn = cast(M->getOrInsertFunction(NewFnName, + FTy->getReturnType(), + FTy->getParamType(0), + FTy->getParamType(1), + FTy->getParamType(2), + FTy->getParamType(3), + Type::getInt1Ty(F->getContext()), + (Type *)0)); + return true; + } + break; + } case 'p': // This upgrades the llvm.part.select overloaded intrinsic names to only // use one type specifier in the name. We only care about the old format @@ -472,6 +520,28 @@ CI->eraseFromParent(); } break; + case Intrinsic::memcpy: + case Intrinsic::memmove: + case Intrinsic::memset: { + // Add isVolatile + const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); + Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), + CI->getOperand(3), CI->getOperand(4), + llvm::ConstantInt::get(I1Ty, 0) }; + CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, + CI->getName(), CI); + NewCI->setTailCall(CI->isTailCall()); + NewCI->setCallingConv(CI->getCallingConv()); + // Handle any uses of the old CallInst. + if (!CI->use_empty()) + // Replace all uses of the old call with the new cast which has the + // correct type. + CI->replaceAllUsesWith(NewCI); + + // Clean up the old call now that it has been completely upgraded. + CI->eraseFromParent(); + break; + } } } Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Tue Mar 30 15:55:56 2010 @@ -103,7 +103,7 @@ ret i32 %sub ; CHECK: @test4 ; CHECK: load i32* @G -; CHECK: memset.i32 +; CHECK: memset.p0i8.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } @@ -118,7 +118,7 @@ ret i32 %sub ; CHECK: @test5 ; CHECK: load i32* @G -; CHECK: memcpy.i32 +; CHECK: memcpy.p0i8.p0i8.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Tue Mar 30 15:55:56 2010 @@ -7,7 +7,7 @@ define i32 @t() nounwind ssp { ; CHECK: @t -; CHECK: @llvm.memset.i64 +; CHECK: @llvm.memset.p0i8.i64 entry: %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Tue Mar 30 15:55:56 2010 @@ -113,7 +113,7 @@ %1 = bitcast %struct.data* %0 to i8* %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) +; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind ret i32 0 } @@ -128,7 +128,7 @@ %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) %2 = load i8** @s, align 8 ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) +; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind ret void } Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Tue Mar 30 15:55:56 2010 @@ -4,7 +4,7 @@ ; The resulting memset is only 4-byte aligned, despite containing ; a 16-byte alignmed store in the middle. -; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) +; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) define void @foo(i32* %p) { %a0 = getelementptr i32* %p, i64 0 Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Tue Mar 30 15:55:56 2010 @@ -21,7 +21,7 @@ %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) -; CHECK: @llvm.memcpy.i32 +; CHECK: @llvm.memcpy.p0i8.p0i8.i32 ret i32 0 } Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=99928&r1=99927&r2=99928&view=diff ============================================================================== --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Tue Mar 30 15:55:56 2010 @@ -1,7 +1,7 @@ ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} ; PR1047 -define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { +define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { entry: ret void } From wangmp at apple.com Tue Mar 30 15:58:23 2010 From: wangmp at apple.com (Mon P Wang) Date: Tue, 30 Mar 2010 20:58:23 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r99929 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100330205823.825C82A6C12C@llvm.org> Author: wangmp Date: Tue Mar 30 15:58:23 2010 New Revision: 99929 URL: http://llvm.org/viewvc/llvm-project?rev=99929&view=rev Log: Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=99929&r1=99928&r2=99929&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Mar 30 15:58:23 2010 @@ -1559,15 +1559,17 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 3), Ops, Ops+5); return Ops[0]; } @@ -1575,15 +1577,17 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 3), Ops, Ops+5); return Ops[0]; } @@ -1591,15 +1595,16 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; - + const Type *ArgTypes[2] = {SBP, IntPtr}; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 2), Ops, Ops+5); return Ops[0]; } From stoklund at 2pi.dk Tue Mar 30 16:09:31 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 21:09:31 -0000 Subject: [llvm-commits] [llvm] r99931 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Message-ID: <20100330210932.01E602A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 16:09:31 2010 New Revision: 99931 URL: http://llvm.org/viewvc/llvm-project?rev=99931&view=rev Log: Enable -sse-domain-fix by default. What could possibly go wrong? Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=99931&r1=99930&r2=99931&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Mar 30 16:09:31 2010 @@ -23,11 +23,6 @@ #include "llvm/Target/TargetRegistry.h" using namespace llvm; -static cl::opt -SSEDomainFix("sse-domain-fix", - cl::desc("Enable fixing of SSE execution domain"), - cl::init(false), cl::Hidden); - static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { @@ -177,7 +172,7 @@ bool X86TargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (SSEDomainFix && OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { + if (OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { PM.add(createSSEDomainFixPass()); return true; } From stoklund at 2pi.dk Tue Mar 30 16:36:32 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 21:36:32 -0000 Subject: [llvm-commits] [llvm] r99933 - /llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Message-ID: <20100330213632.5058E2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 16:36:32 2010 New Revision: 99933 URL: http://llvm.org/viewvc/llvm-project?rev=99933&view=rev Log: Revert "Enable -sse-domain-fix by default. What could possibly go wrong?" Not running 'make check-all' before committing is a bad idea. Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=99933&r1=99932&r2=99933&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Mar 30 16:36:32 2010 @@ -23,6 +23,11 @@ #include "llvm/Target/TargetRegistry.h" using namespace llvm; +static cl::opt +SSEDomainFix("sse-domain-fix", + cl::desc("Enable fixing of SSE execution domain"), + cl::init(false), cl::Hidden); + static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { @@ -172,7 +177,7 @@ bool X86TargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { + if (SSEDomainFix && OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { PM.add(createSSEDomainFixPass()); return true; } From dpatel at apple.com Tue Mar 30 17:09:52 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 30 Mar 2010 22:09:52 -0000 Subject: [llvm-commits] [llvm] r99938 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll Message-ID: <20100330220952.3B5042A6C12D@llvm.org> Author: dpatel Date: Tue Mar 30 17:09:52 2010 New Revision: 99938 URL: http://llvm.org/viewvc/llvm-project?rev=99938&view=rev Log: Ignore invalid metadata. Added: llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=99938&r1=99937&r2=99938&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 30 17:09:52 2010 @@ -2163,6 +2163,7 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); + if (!DLTScope.getNode()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. @@ -2184,6 +2185,7 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); + if (!DLTScope.getNode()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. Added: llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll?rev=99938&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll (added) +++ llvm/trunk/test/DebugInfo/2010-03-30-InvalidDbgInfoCrash.ll Tue Mar 30 17:09:52 2010 @@ -0,0 +1,30 @@ +; RUN: llc < %s -o /dev/null + +define void @baz(i32 %i) nounwind ssp { +entry: + call void @llvm.dbg.declare(metadata !0, metadata !1), !dbg !0 + ret void, !dbg !0 +} + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +!0 = metadata !{{ [0 x i8] }** undef} +!1 = metadata !{i32 524544, metadata !2, metadata !"x", metadata !4, i32 11, metadata !9} ; [ DW_TAG_auto_variable ] +!2 = metadata !{i32 524299, metadata !3, i32 8, i32 0} ; [ DW_TAG_lexical_block ] +!3 = metadata !{i32 524334, i32 0, metadata !4, metadata !"baz", metadata !"baz", metadata !"baz", metadata !4, i32 8, metadata !6, i1 true, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ] +!4 = metadata !{i32 524329, metadata !"2007-12-VarArrayDebug.c", metadata !"/Users/sabre/llvm/test/FrontendC/", metadata !5} ; [ DW_TAG_file_type ] +!5 = metadata !{i32 524305, i32 0, i32 1, metadata !"2007-12-VarArrayDebug.c", metadata !"/Users/sabre/llvm/test/FrontendC/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!6 = metadata !{i32 524309, metadata !4, metadata !"", metadata !4, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !7, i32 0, null} ; [ DW_TAG_subroutine_type ] +!7 = metadata !{null, metadata !8} +!8 = metadata !{i32 524324, metadata !4, metadata !"int", metadata !4, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!9 = metadata !{i32 524303, metadata !4, metadata !"", metadata !4, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !10} ; [ DW_TAG_pointer_type ] +!10 = metadata !{i32 524307, metadata !3, metadata !"", metadata !4, i32 11, i64 8, i64 8, i64 0, i32 0, null, metadata !11, i32 0, null} ; [ DW_TAG_structure_type ] +!11 = metadata !{metadata !12} +!12 = metadata !{i32 524301, metadata !10, metadata !"b", metadata !4, i32 11, i64 8, i64 8, i64 0, i32 0, metadata !13} ; [ DW_TAG_member ] +!13 = metadata !{i32 524310, metadata !3, metadata !"A", metadata !4, i32 11, i64 0, i64 0, i64 0, i32 0, metadata !14} ; [ DW_TAG_typedef ] +!14 = metadata !{i32 524289, metadata !4, metadata !"", metadata !4, i32 0, i64 8, i64 8, i64 0, i32 0, metadata !15, metadata !16, i32 0, null} ; [ DW_TAG_array_type ] +!15 = metadata !{i32 524324, metadata !4, metadata !"char", metadata !4, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ] +!16 = metadata !{metadata !17} +!17 = metadata !{i32 524321, i64 0, i64 0} ; [ DW_TAG_subrange_type ] +!18 = metadata !{metadata !"llvm.mdnode.fwdref.19"} +!19 = metadata !{metadata !"llvm.mdnode.fwdref.23"} From echristo at apple.com Tue Mar 30 17:12:29 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 30 Mar 2010 15:12:29 -0700 Subject: [llvm-commits] Patch: address space support for memcpy/memmove/memset In-Reply-To: <89548B9C-55E6-40DF-8E7D-9B1C30162EA4@apple.com> References: <89548B9C-55E6-40DF-8E7D-9B1C30162EA4@apple.com> Message-ID: <2757EFD3-4A6B-4F49-9329-35B2BE1679EF@apple.com> On Mar 24, 2010, at 4:01 PM, Mon Ping Wang wrote: > Please let me know if I miss something. Could you also please add a testcase for the AutoUpgrade parts you added? Thanks. -eric From isanbard at gmail.com Tue Mar 30 17:18:30 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 30 Mar 2010 22:18:30 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r99941 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/eh1.C Message-ID: <20100330221830.70E542A6C12C@llvm.org> Author: void Date: Tue Mar 30 17:18:30 2010 New Revision: 99941 URL: http://llvm.org/viewvc/llvm-project?rev=99941&view=rev Log: We now generate LSDAs into the TEXT section. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/eh1.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/eh1.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/eh1.C?rev=99941&r1=99940&r2=99941&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/eh1.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/eh1.C Tue Mar 30 17:18:30 2010 @@ -1,6 +1,6 @@ /* APPLE LOCAL file EH __DATA __gcc_except_tab 5819051 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-final { scan-assembler "__DATA,__gcc_except_tab" } } */ +/* { dg-final { scan-assembler "__TEXT,__gcc_except_tab" } } */ /* Radar 5819051 */ #include From bob.wilson at apple.com Tue Mar 30 17:27:04 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 30 Mar 2010 22:27:04 -0000 Subject: [llvm-commits] [llvm] r99948 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ Message-ID: <20100330222705.22A9D2A6C12C@llvm.org> Author: bwilson Date: Tue Mar 30 17:27:04 2010 New Revision: 99948 URL: http://llvm.org/viewvc/llvm-project?rev=99948&view=rev Log: Revert Mon Ping's change 99928, since it broke all the llvm-gcc buildbots. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/Analysis/BasicAA/modref.ll llvm/trunk/test/Transforms/InstCombine/memset_chk.ll llvm/trunk/test/Transforms/InstCombine/objsize.ll llvm/trunk/test/Transforms/MemCpyOpt/align.ll llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Tue Mar 30 17:27:04 2010 @@ -534,17 +534,17 @@ SDValue getStackArgumentTokenFactor(SDValue Chain); SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, + SDValue Size, unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, + SDValue Size, unsigned Align, const Value *DstSV, uint64_t DstOSVff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, + SDValue Size, unsigned Align, const Value *DstSV, uint64_t DstSVOff); /// getSetCC - Helper function to make it easier to build SetCC's if you just Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Tue Mar 30 17:27:04 2010 @@ -133,13 +133,6 @@ return getAlignmentCst()->getZExtValue(); } - ConstantInt *getVolatileCst() const { - return cast(const_cast(getOperand(5))); - } - bool isVolatile() const { - return getVolatileCst()->getZExtValue() != 0; - } - /// getDest - This is just like getRawDest, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. @@ -162,11 +155,7 @@ void setAlignment(Constant* A) { setOperand(4, A); } - - void setVolatile(Constant* V) { - setOperand(5, V); - } - + const Type *getAlignmentType() const { return getOperand(4)->getType(); } Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Tue Mar 30 17:27:04 2010 @@ -224,16 +224,16 @@ // def int_memcpy : Intrinsic<[], - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memmove : Intrinsic<[], - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memset : Intrinsic<[], - [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>]>; // These functions do not actually read memory, but they are sensitive to the Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Mar 30 17:27:04 2010 @@ -909,11 +909,6 @@ Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; return Insert(CallInst::Create(Callee, Args, Args+4), Name); } - CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, - Value *Arg4, Value *Arg5, const Twine &Name = "") { - Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; - return Insert(CallInst::Create(Callee, Args, Args+5), Name); - } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Mar 30 17:27:04 2010 @@ -1184,7 +1184,7 @@ EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { @@ -1201,7 +1201,7 @@ EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { return SDValue(); @@ -1217,7 +1217,7 @@ EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, const Value *DstSV, uint64_t DstOff) { return SDValue(); } Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Tue Mar 30 17:27:04 2010 @@ -46,8 +46,8 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD); /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src @@ -57,8 +57,8 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD); /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. @@ -70,8 +70,8 @@ const TargetData *TD); /// EmitMemSet - Emit a call to the memset function - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, - IRBuilder<> &B, const TargetData *TD); + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, + const TargetData *TD); /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' /// (e.g. 'floor'). This function is known to take a single of type matching Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Mar 30 17:27:04 2010 @@ -3275,8 +3275,7 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, - bool AlwaysInline, + unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3313,7 +3312,7 @@ Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, DstAlign); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3324,10 +3323,10 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, isVol, false, Align); + SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); Store = DAG.getTruncStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, VT, isVol, false, + DstSV, DstSVOff + DstOff, VT, false, false, DstAlign); } OutChains.push_back(Store); @@ -3342,8 +3341,7 @@ static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, - bool AlwaysInline, + unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3374,7 +3372,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, isVol, false, Align); + SrcSV, SrcSVOff + SrcOff, false, false, Align); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3389,7 +3387,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, DstAlign); OutChains.push_back(Store); DstOff += VTSize; } @@ -3401,7 +3399,7 @@ static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3424,7 +3422,7 @@ SDValue Value = getMemsetValue(Src, VT, DAG, dl); SDValue Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, 0); + DstSV, DstSVOff + DstOff, false, false, 0); OutChains.push_back(Store); DstOff += VTSize; } @@ -3435,7 +3433,7 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, bool AlwaysInline, + unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3449,8 +3447,8 @@ SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, isVol, - false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3459,7 +3457,7 @@ // code. If the target chooses to do this, this is the next best. SDValue Result = TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, - isVol, AlwaysInline, + AlwaysInline, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; @@ -3469,12 +3467,11 @@ if (AlwaysInline) { assert(ConstantSize && "AlwaysInline requires a constant size!"); return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, isVol, - true, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, true, + DstSV, DstSVOff, SrcSV, SrcSVOff); } // Emit a library call. - assert(!isVol && "library memcpy does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3495,7 +3492,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3509,8 +3506,8 @@ SDValue Result = getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, isVol, - false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3518,13 +3515,12 @@ // Then check to see if we should lower the memmove with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; // Emit a library call. - assert(!isVol && "library memmove does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3545,7 +3541,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff) { // Check to see if we should lower the memset to stores first. @@ -3558,7 +3554,7 @@ SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), - Align, isVol, DstSV, DstSVOff); + Align, DstSV, DstSVOff); if (Result.getNode()) return Result; } @@ -3566,13 +3562,12 @@ // Then check to see if we should lower the memset with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, DstSV, DstSVOff); if (Result.getNode()) return Result; // Emit a library call. - assert(!isVol && "library memset does not support volatile"); const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Mar 30 17:27:04 2010 @@ -3731,50 +3731,28 @@ case Intrinsic::longjmp: return "_longjmp"+!TLI.usesUnderscoreLongJmp(); case Intrinsic::memcpy: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - cast(I.getOperand(2)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } case Intrinsic::memset: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, I.getOperand(1), 0)); return 0; } case Intrinsic::memmove: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - cast(I.getOperand(2)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); // If the source and destination are known to not be aliases, we can // lower memmove as memcpy. @@ -3783,12 +3761,12 @@ Size = C->getZExtValue(); if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == AliasAnalysis::NoAlias) { - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, - false, I.getOperand(1), 0, I.getOperand(2), 0)); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, + I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Mar 30 17:27:04 2010 @@ -861,8 +861,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*isVolatile=*/false, /*AlwaysInline=*/false, - NULL, 0, NULL, 0); + /*AlwaysInline=*/false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack. @@ -2054,7 +2053,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ // Do repeated 4-byte loads and stores. To be improved. @@ -2090,7 +2089,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); + SrcSV, SrcSVOff + SrcOff, false, false, 0); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -2101,7 +2100,7 @@ TFOps[i] = DAG.getStore(Chain, dl, Loads[i], DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff, isVolatile, false, 0); + DstSV, DstSVOff + DstOff, false, false, 0); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Mar 30 17:27:04 2010 @@ -305,7 +305,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue LowerCallResult(SDValue Chain, SDValue InFlag, Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Mar 30 17:27:04 2010 @@ -2392,7 +2392,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - false, false, NULL, 0, NULL, 0); + false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Mar 30 17:27:04 2010 @@ -1422,8 +1422,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*isVolatile*/false, /*AlwaysInline=*/true, - NULL, 0, NULL, 0); + /*AlwaysInline=*/true, NULL, 0, NULL, 0); } /// IsTailCallConvention - Return true if the calling convention is one that @@ -6540,7 +6539,6 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, const Value *DstSV, uint64_t DstSVOff) { ConstantSDNode *ConstantSize = dyn_cast(Size); @@ -6669,7 +6667,7 @@ DAG.getConstant(Offset, AddrVT)), Src, DAG.getConstant(BytesLeft, SizeVT), - Align, isVolatile, DstSV, DstSVOff + Offset); + Align, DstSV, DstSVOff + Offset); } // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. @@ -6680,7 +6678,7 @@ X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { // This requires the copy size to be a constant, preferrably @@ -6739,7 +6737,7 @@ DAG.getNode(ISD::ADD, dl, SrcVT, Src, DAG.getConstant(Offset, SrcVT)), DAG.getConstant(BytesLeft, SizeVT), - Align, isVolatile, AlwaysInline, + Align, AlwaysInline, DstSV, DstSVOff + Offset, SrcSV, SrcSVOff + Offset)); } @@ -6822,8 +6820,8 @@ DebugLoc dl = Op.getDebugLoc(); return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, - DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, - false, DstSV, 0, SrcSV, 0); + DAG.getIntPtrConstant(24), 8, false, + DstSV, 0, SrcSV, 0); } SDValue Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Mar 30 17:27:04 2010 @@ -737,13 +737,12 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, const Value *DstSV, uint64_t DstSVOff); SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); @@ -753,7 +752,7 @@ /// block, the number of args, and whether or not the second arg is /// in memory or not. MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, - unsigned argNum, bool inMem) const; + unsigned argNum, bool inMem) const; /// Utility function to emit atomic bitwise operations (and, or, xor). /// It takes the bitwise instruction to expand, the associated machine basic Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Tue Mar 30 17:27:04 2010 @@ -1443,7 +1443,7 @@ return DAG.getMemmove(Chain, dl, ST->getBasePtr(), LD->getBasePtr(), DAG.getConstant(StoreBits/8, MVT::i32), - Alignment, false, ST->getSrcValue(), + Alignment, ST->getSrcValue(), ST->getSrcValueOffset(), LD->getSrcValue(), LD->getSrcValueOffset()); } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Mar 30 17:27:04 2010 @@ -136,14 +136,8 @@ return 0; // If not 1/2/4/8 bytes, exit. // Use an integer load+store unless we can find something better. - unsigned SrcAddrSp = - cast(MI->getOperand(2)->getType())->getAddressSpace(); - unsigned DstAddrSp = - cast(MI->getOperand(1)->getType())->getAddressSpace(); - - const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); - Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); - Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); + Type *NewPtrTy = + PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); // Memcpy forces the use of i8* for the source and destination. That means // that if you're using memcpy to move one double around, you'll get a cast @@ -173,10 +167,8 @@ break; } - if (SrcETy->isSingleValueType()) { - NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); - NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); - } + if (SrcETy->isSingleValueType()) + NewPtrTy = PointerType::getUnqual(SrcETy); } } @@ -186,12 +178,11 @@ SrcAlign = std::max(SrcAlign, CopyAlign); DstAlign = std::max(DstAlign, CopyAlign); - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); - Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); + Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); InsertNewInstBefore(L, *MI); - InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), - *MI); + InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); // Set the size of the copy to 0, it will be deleted on the next iteration. MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); @@ -284,11 +275,10 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - const Type *Tys[3] = { CI.getOperand(1)->getType(), - CI.getOperand(2)->getType(), - CI.getOperand(3)->getType() }; + const Type *Tys[1]; + Tys[0] = CI.getOperand(3)->getType(); CI.setOperand(0, - Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); + Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); Changed = true; } } Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Mar 30 17:27:04 2010 @@ -413,6 +413,7 @@ // interesting as a small compile-time optimization. Ranges.addStore(0, SI); + Function *MemSetF = 0; // Now that we have full information about ranges, loop over the ranges and // emit memset's for anything big enough to be worthwhile. @@ -432,40 +433,29 @@ // memset block. This ensure that the memset is dominated by any addressing // instruction needed by the start of the block. BasicBlock::iterator InsertPt = BI; - + + if (MemSetF == 0) { + const Type *Ty = Type::getInt64Ty(Context); + MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); + } + // Get the starting pointer of the block. StartPtr = Range.StartPtr; - - // Determine alignment - unsigned Alignment = Range.Alignment; - if (Alignment == 0) { - const Type *EltType = - cast(StartPtr->getType())->getElementType(); - Alignment = TD->getABITypeAlignment(EltType); - } - + // Cast the start ptr to be i8* as memset requires. - const PointerType* StartPTy = cast(StartPtr->getType()); - const PointerType *i8Ptr = Type::getInt8PtrTy(Context, - StartPTy->getAddressSpace()); - if (StartPTy!= i8Ptr) + const Type *i8Ptr = Type::getInt8PtrTy(Context); + if (StartPtr->getType() != i8Ptr) StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), InsertPt); - + Value *Ops[] = { StartPtr, ByteVal, // Start, value // size ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), // align - ConstantInt::get(Type::getInt32Ty(Context), Alignment), - // volatile - ConstantInt::get(Type::getInt1Ty(Context), 0), + ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) }; - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; - - Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); - - Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); DEBUG(dbgs() << "Replace stores:\n"; for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) dbgs() << *Range.TheStores[i]; @@ -690,19 +680,16 @@ return false; // If all checks passed, then we can transform these memcpy's - const Type *ArgTys[3] = { M->getRawDest()->getType(), - MDep->getRawSource()->getType(), - M->getLength()->getType() }; + const Type *Ty = M->getLength()->getType(); Function *MemCpyFun = Intrinsic::getDeclaration( M->getParent()->getParent()->getParent(), - M->getIntrinsicID(), ArgTys, 3); + M->getIntrinsicID(), &Ty, 1); - Value *Args[5] = { - M->getRawDest(), MDep->getRawSource(), M->getLength(), - M->getAlignmentCst(), M->getVolatileCst() + Value *Args[4] = { + M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() }; - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); // If C and M don't interfere, then this is a valid transformation. If they @@ -741,10 +728,8 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - const Type *ArgTys[3] = { M->getDest()->getType(), M->getSource()->getType(), - M->getLength()->getType() }; - M->setOperand(0, - Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); + const Type *Ty = M->getLength()->getType(); + M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); // MemDep may have over conservative information about this instruction, just // conservatively flush it from the cache. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Mar 30 17:27:04 2010 @@ -858,17 +858,8 @@ EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); // Cast the other pointer (if we have one) to BytePtrTy. - if (OtherElt && OtherElt->getType() != BytePtrTy) { - // Preserve address space of OtherElt - const PointerType* OtherPTy = cast(OtherElt->getType()); - const PointerType* PTy = cast(BytePtrTy); - if (OtherPTy->getElementType() != PTy->getElementType()) { - Type *NewOtherPTy = PointerType::get(PTy->getElementType(), - OtherPTy->getAddressSpace()); - OtherElt = new BitCastInst(OtherElt, NewOtherPTy, - OtherElt->getNameStr(), MI); - } - } + if (OtherElt && OtherElt->getType() != BytePtrTy) + OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); unsigned EltSize = TD->getTypeAllocSize(EltTy); @@ -879,28 +870,17 @@ SROADest ? OtherElt : EltPtr, // Src ptr ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size // Align - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), - MI->getVolatileCst() + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) }; - // In case we fold the address space overloaded memcpy of A to B - // with memcpy of B to C, change the function to be a memcpy of A to C. - const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), - Ops[2]->getType() }; - Module *M = MI->getParent()->getParent()->getParent(); - TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } else { assert(isa(MI)); Value *Ops[] = { EltPtr, MI->getOperand(2), // Dest, Value, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size - Zero, // Align - ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile + Zero // Align }; - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; - Module *M = MI->getParent()->getParent()->getParent(); - TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } } DeadInsts.push_back(MI); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Tue Mar 30 17:27:04 2010 @@ -142,8 +142,7 @@ // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. EmitMemCpy(CpyDst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); } }; @@ -384,8 +383,7 @@ CI->getOperand(3), B, TD); else EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); return Dst; } }; @@ -413,8 +411,8 @@ if (SrcLen == 0) { // strncpy(x, "", y) -> memset(x, '\0', y, 1) - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), - LenOp, false, B, TD); + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, + B, TD); return Dst; } @@ -434,8 +432,7 @@ // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); return Dst; } @@ -596,7 +593,7 @@ // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, false, B, TD); + CI->getOperand(3), 1, B, TD); return CI->getOperand(1); } }; @@ -618,7 +615,7 @@ // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) EmitMemMove(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, false, B, TD); + CI->getOperand(3), 1, B, TD); return CI->getOperand(1); } }; @@ -640,8 +637,8 @@ // memset(p, v, n) -> llvm.memset(p, v, n, 1) Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), - false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); + false); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); return CI->getOperand(1); } }; @@ -1002,7 +999,7 @@ // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. ConstantInt::get(TD->getIntPtrType(*Context), - FormatStr.size()+1), 1, false, B, TD); + FormatStr.size()+1), 1, B, TD); return ConstantInt::get(CI->getType(), FormatStr.size()); } @@ -1016,11 +1013,11 @@ // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), - Type::getInt8Ty(*Context), "char"); + Type::getInt8Ty(*Context), "char"); Value *Ptr = CastToCStr(CI->getOperand(1), B); B.CreateStore(V, Ptr); Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), - "nul"); + "nul"); B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); return ConstantInt::get(CI->getType(), 1); @@ -1037,7 +1034,7 @@ Value *IncLen = B.CreateAdd(Len, ConstantInt::get(Len->getType(), 1), "leninc"); - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); // The sprintf result is the unincremented number of bytes in the string. return B.CreateIntCast(Len, CI->getType(), false); Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Tue Mar 30 17:27:04 2010 @@ -109,16 +109,15 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always /// expects that Len has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); + const Type *Ty = Len->getType(); + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); - return B.CreateCall5(MemCpy, Dst, Src, Len, - ConstantInt::get(B.getInt32Ty(), Align), - ConstantInt::get(B.getInt1Ty(), isVolatile)); + return B.CreateCall4(MemCpy, Dst, Src, Len, + ConstantInt::get(B.getInt32Ty(), Align)); } /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. @@ -147,18 +146,16 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); LLVMContext &Context = B.GetInsertBlock()->getContext(); - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), - TD->getIntPtrType(Context) }; - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); + const Type *Ty = TD->getIntPtrType(Context); + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); Value *A = ConstantInt::get(B.getInt32Ty(), Align); - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); - return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); + return B.CreateCall4(MemMove, Dst, Src, Len, A); } /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is @@ -209,15 +206,15 @@ } /// EmitMemSet - Emit a call to the memset function -Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, - IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemSet(Value *Dst, Value *Val, + Value *Len, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Intrinsic::ID IID = Intrinsic::memset; - const Type *Tys[2] = { Dst->getType(), Len->getType() }; - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); + const Type *Tys[1]; + Tys[0] = Len->getType(); + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); Value *Align = ConstantInt::get(B.getInt32Ty(), 1); - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); - return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); + return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); } /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. @@ -384,7 +381,7 @@ if (Name == "__memcpy_chk") { if (isFoldable(4, 3, false)) { EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, false, B, TD); + 1, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -399,7 +396,7 @@ if (Name == "__memmove_chk") { if (isFoldable(4, 3, false)) { EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, false, B, TD); + 1, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -410,7 +407,7 @@ if (isFoldable(4, 3, false)) { Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); replaceCall(CI->getOperand(1)); return true; } Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Mar 30 17:27:04 2010 @@ -297,10 +297,10 @@ I->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; + const Type *Tys[] = { Type::getInt64Ty(Context) }; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, - Tys, 3); + Tys, 1); Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); @@ -309,18 +309,17 @@ Size = ConstantExpr::getSizeOf(AggTy); else Size = ConstantInt::get(Type::getInt64Ty(Context), - TD->getTypeStoreSize(AggTy)); + TD->getTypeStoreSize(AggTy)); // Always generate a memcpy of alignment 1 here because we don't know // the alignment of the src pointer. Other optimizations can infer // better alignment. Value *CallArgs[] = { DestCast, SrcCast, Size, - ConstantInt::get(Type::getInt32Ty(Context), 1), - ConstantInt::get(Type::getInt1Ty(Context), 0) + ConstantInt::get(Type::getInt32Ty(Context), 1) }; CallInst *TheMemCpy = - CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); + CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); // If we have a call graph, update it. if (CG) { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Mar 30 17:27:04 2010 @@ -145,54 +145,6 @@ } break; - case 'm': { - // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the - // new format that allows overloading the pointer for different address - // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) - const char* NewFnName = NULL; - if (Name.compare(5,8,"memcpy.i",8) == 0) { - if (Name[13] == '8') - NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; - else if (Name.compare(13,2,"16") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; - else if (Name.compare(13,2,"32") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; - else if (Name.compare(13,2,"64") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; - } else if (Name.compare(5,9,"memmove.i",9) == 0) { - if (Name[14] == '8') - NewFnName = "llvm.memmove.p0i8.p0i8.i8"; - else if (Name.compare(14,2,"16") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i16"; - else if (Name.compare(14,2,"32") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i32"; - else if (Name.compare(14,2,"64") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i64"; - } - else if (Name.compare(5,8,"memset.i",8) == 0) { - if (Name[13] == '8') - NewFnName = "llvm.memset.p0i8.i8"; - else if (Name.compare(13,2,"16") == 0) - NewFnName = "llvm.memset.p0i8.i16"; - else if (Name.compare(13,2,"32") == 0) - NewFnName = "llvm.memset.p0i8.i32"; - else if (Name.compare(13,2,"64") == 0) - NewFnName = "llvm.memset.p0i8.i64"; - } - if (NewFnName) { - const FunctionType *FTy = F->getFunctionType(); - NewFn = cast(M->getOrInsertFunction(NewFnName, - FTy->getReturnType(), - FTy->getParamType(0), - FTy->getParamType(1), - FTy->getParamType(2), - FTy->getParamType(3), - Type::getInt1Ty(F->getContext()), - (Type *)0)); - return true; - } - break; - } case 'p': // This upgrades the llvm.part.select overloaded intrinsic names to only // use one type specifier in the name. We only care about the old format @@ -520,28 +472,6 @@ CI->eraseFromParent(); } break; - case Intrinsic::memcpy: - case Intrinsic::memmove: - case Intrinsic::memset: { - // Add isVolatile - const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); - Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), CI->getOperand(4), - llvm::ConstantInt::get(I1Ty, 0) }; - CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, - CI->getName(), CI); - NewCI->setTailCall(CI->isTailCall()); - NewCI->setCallingConv(CI->getCallingConv()); - // Handle any uses of the old CallInst. - if (!CI->use_empty()) - // Replace all uses of the old call with the new cast which has the - // correct type. - CI->replaceAllUsesWith(NewCI); - - // Clean up the old call now that it has been completely upgraded. - CI->eraseFromParent(); - break; - } } } Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Tue Mar 30 17:27:04 2010 @@ -103,7 +103,7 @@ ret i32 %sub ; CHECK: @test4 ; CHECK: load i32* @G -; CHECK: memset.p0i8.i32 +; CHECK: memset.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } @@ -118,7 +118,7 @@ ret i32 %sub ; CHECK: @test5 ; CHECK: load i32* @G -; CHECK: memcpy.p0i8.p0i8.i32 +; CHECK: memcpy.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Tue Mar 30 17:27:04 2010 @@ -7,7 +7,7 @@ define i32 @t() nounwind ssp { ; CHECK: @t -; CHECK: @llvm.memset.p0i8.i64 +; CHECK: @llvm.memset.i64 entry: %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Tue Mar 30 17:27:04 2010 @@ -113,7 +113,7 @@ %1 = bitcast %struct.data* %0 to i8* %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) +; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind ret i32 0 } @@ -128,7 +128,7 @@ %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) %2 = load i8** @s, align 8 ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) +; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind ret void } Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Tue Mar 30 17:27:04 2010 @@ -4,7 +4,7 @@ ; The resulting memset is only 4-byte aligned, despite containing ; a 16-byte alignmed store in the middle. -; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) +; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) define void @foo(i32* %p) { %a0 = getelementptr i32* %p, i64 0 Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Tue Mar 30 17:27:04 2010 @@ -21,7 +21,7 @@ %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) -; CHECK: @llvm.memcpy.p0i8.p0i8.i32 +; CHECK: @llvm.memcpy.i32 ret i32 0 } Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=99948&r1=99947&r2=99948&view=diff ============================================================================== --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Tue Mar 30 17:27:04 2010 @@ -1,7 +1,7 @@ ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} ; PR1047 -define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { +define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { entry: ret void } From bob.wilson at apple.com Tue Mar 30 17:29:06 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 30 Mar 2010 22:29:06 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r99950 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100330222906.DB7DD2A6C12C@llvm.org> Author: bwilson Date: Tue Mar 30 17:29:06 2010 New Revision: 99950 URL: http://llvm.org/viewvc/llvm-project?rev=99950&view=rev Log: Revert Mon Ping's 99929 due to broken llvm-gcc buildbots. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=99950&r1=99949&r2=99950&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Mar 30 17:29:06 2010 @@ -1559,17 +1559,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, - ArgTypes, 3), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } @@ -1577,17 +1575,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, - ArgTypes, 3), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } @@ -1595,16 +1591,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[2] = {SBP, IntPtr}; + Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, - ArgTypes, 2), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } From stoklund at 2pi.dk Tue Mar 30 17:46:53 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 22:46:53 -0000 Subject: [llvm-commits] [llvm] r99952 - in /llvm/trunk/lib/Target/X86: X86InstrFormats.td X86InstrInfo.cpp X86InstrInfo.h Message-ID: <20100330224653.7A7732A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 17:46:53 2010 New Revision: 99952 URL: http://llvm.org/viewvc/llvm-project?rev=99952&view=rev Log: Renumber SSE execution domains for better code size. SSEDomainFix will collapse to the domain with the lower number when it has a choice. The SSEPackedSingle domain often has smaller instructions, so prefer that. Modified: llvm/trunk/lib/Target/X86/X86InstrFormats.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.h Modified: llvm/trunk/lib/Target/X86/X86InstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFormats.td?rev=99952&r1=99951&r2=99952&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFormats.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFormats.td Tue Mar 30 17:46:53 2010 @@ -69,14 +69,14 @@ def SpecialFP : FPFormat<7>; // Class specifying the SSE execution domain, used by the SSEDomainFix pass. -// Instruction execution domain. +// Keep in sync with tables in X86InstrInfo.cpp. class Domain val> { bits<2> Value = val; } def GenericDomain : Domain<0>; -def SSEPackedInt : Domain<1>; -def SSEPackedSingle : Domain<2>; -def SSEPackedDouble : Domain<3>; +def SSEPackedSingle : Domain<1>; +def SSEPackedDouble : Domain<2>; +def SSEPackedInt : Domain<3>; // Prefix byte classes which are used to indicate to the ad-hoc machine code // emitter that various prefix bytes are required. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=99952&r1=99951&r2=99952&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Mar 30 17:46:53 2010 @@ -3663,20 +3663,20 @@ // by intrinsics. static const unsigned ReplaceableInstrs[][3] = { //PackedInt PackedSingle PackedDouble - { X86::MOVDQAmr, X86::MOVAPSmr, X86::MOVAPDmr }, - { X86::MOVDQArm, X86::MOVAPSrm, X86::MOVAPDrm }, - { X86::MOVDQArr, X86::MOVAPSrr, X86::MOVAPDrr }, - { X86::MOVDQUmr, X86::MOVUPSmr, X86::MOVUPDmr }, - { X86::MOVDQUrm, X86::MOVUPSrm, X86::MOVUPDrm }, - { X86::MOVNTDQmr, X86::MOVNTPSmr, X86::MOVNTPDmr }, - { X86::PANDNrm, X86::ANDNPSrm, X86::ANDNPDrm }, - { X86::PANDNrr, X86::ANDNPSrr, X86::ANDNPDrr }, - { X86::PANDrm, X86::ANDPSrm, X86::ANDPDrm }, - { X86::PANDrr, X86::ANDPSrr, X86::ANDPDrr }, - { X86::PORrm, X86::ORPSrm, X86::ORPDrm }, - { X86::PORrr, X86::ORPSrr, X86::ORPDrr }, - { X86::PXORrm, X86::XORPSrm, X86::XORPDrm }, - { X86::PXORrr, X86::XORPSrr, X86::XORPDrr }, + { X86::MOVAPSmr, X86::MOVAPDmr, X86::MOVDQAmr }, + { X86::MOVAPSrm, X86::MOVAPDrm, X86::MOVDQArm }, + { X86::MOVAPSrr, X86::MOVAPDrr, X86::MOVDQArr }, + { X86::MOVUPSmr, X86::MOVUPDmr, X86::MOVDQUmr }, + { X86::MOVUPSrm, X86::MOVUPDrm, X86::MOVDQUrm }, + { X86::MOVNTPSmr, X86::MOVNTPDmr, X86::MOVNTDQmr }, + { X86::ANDNPSrm, X86::ANDNPDrm, X86::PANDNrm }, + { X86::ANDNPSrr, X86::ANDNPDrr, X86::PANDNrr }, + { X86::ANDPSrm, X86::ANDPDrm, X86::PANDrm }, + { X86::ANDPSrr, X86::ANDPDrr, X86::PANDrr }, + { X86::ORPSrm, X86::ORPDrm, X86::PORrm }, + { X86::ORPSrr, X86::ORPDrr, X86::PORrr }, + { X86::XORPSrm, X86::XORPDrm, X86::PXORrm }, + { X86::XORPSrr, X86::XORPDrr, X86::PXORrr }, }; // FIXME: Some shuffle and unpack instructions have equivalents in different @@ -3692,8 +3692,8 @@ std::pair X86InstrInfo::GetSSEDomain(const MachineInstr *MI) const { uint16_t domain = (MI->getDesc().TSFlags >> X86II::SSEDomainShift) & 3; - return std::make_pair(domain, domain != NotSSEDomain && - lookup(MI->getOpcode(), domain) ? 0xe : 0); + return std::make_pair(domain, + domain && lookup(MI->getOpcode(), domain) ? 0xe : 0); } void X86InstrInfo::SetSSEDomain(MachineInstr *MI, unsigned Domain) const { Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.h?rev=99952&r1=99951&r2=99952&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.h Tue Mar 30 17:46:53 2010 @@ -399,7 +399,7 @@ GS = 2 << SegOvrShift, // Execution domain for SSE instructions in bits 22, 23. - // 0 in bits 22-23 means normal, non-SSE instruction. See SSEDomain below. + // 0 in bits 22-23 means normal, non-SSE instruction. SSEDomainShift = 22, OpcodeShift = 24, @@ -719,9 +719,6 @@ /// unsigned getGlobalBaseReg(MachineFunction *MF) const; - /// Some SSE instructions come in variants for three domains. - enum SSEDomain { NotSSEDomain, PackedInt, PackedSingle, PackedDouble }; - /// GetSSEDomain - Return the SSE execution domain of MI as the first element, /// and a bitmask of possible arguments to SetSSEDomain ase the second. std::pair GetSSEDomain(const MachineInstr *MI) const; From stoklund at 2pi.dk Tue Mar 30 17:46:55 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 22:46:55 -0000 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100330224656.01CC02A6C12D@llvm.org> Author: stoklund Date: Tue Mar 30 17:46:55 2010 New Revision: 99953 URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev Log: V_SETALLONES is an integer instruction. Since it is just a pxor in disguise, we should probably expand it to a full polymorphic triple. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99953&r1=99952&r2=99953&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Mar 30 17:46:55 2010 @@ -2424,7 +2424,7 @@ // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-ones value if folding it would be beneficial. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isCodeGenOnly = 1 in + isCodeGenOnly = 1, ExeDomain = SSEPackedInt in // FIXME: Change encoding to pseudo. def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "", [(set VR128:$dst, (v4i32 immAllOnesV))]>; From stoklund at 2pi.dk Tue Mar 30 17:47:00 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 22:47:00 -0000 Subject: [llvm-commits] [llvm] r99954 - in /llvm/trunk: lib/Target/X86/X86TargetMachine.cpp test/CodeGen/X86/2009-02-05-CoalescerBug.ll test/CodeGen/X86/dagcombine-buildvector.ll test/CodeGen/X86/gather-addresses.ll test/CodeGen/X86/sse-align-12.ll test/CodeGen/X86/sse-align-6.ll test/CodeGen/X86/sse3.ll test/CodeGen/X86/vec_compare.ll test/CodeGen/X86/widen_cast-2.ll test/CodeGen/X86/widen_load-2.ll Message-ID: <20100330224700.B6E752A6C12E@llvm.org> Author: stoklund Date: Tue Mar 30 17:47:00 2010 New Revision: 99954 URL: http://llvm.org/viewvc/llvm-project?rev=99954&view=rev Log: Enable -sse-domain-fix by default. Now with tests! Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp llvm/trunk/test/CodeGen/X86/2009-02-05-CoalescerBug.ll llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll llvm/trunk/test/CodeGen/X86/gather-addresses.ll llvm/trunk/test/CodeGen/X86/sse-align-12.ll llvm/trunk/test/CodeGen/X86/sse-align-6.ll llvm/trunk/test/CodeGen/X86/sse3.ll llvm/trunk/test/CodeGen/X86/vec_compare.ll llvm/trunk/test/CodeGen/X86/widen_cast-2.ll llvm/trunk/test/CodeGen/X86/widen_load-2.ll Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Tue Mar 30 17:47:00 2010 @@ -23,11 +23,6 @@ #include "llvm/Target/TargetRegistry.h" using namespace llvm; -static cl::opt -SSEDomainFix("sse-domain-fix", - cl::desc("Enable fixing of SSE execution domain"), - cl::init(false), cl::Hidden); - static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { @@ -177,7 +172,7 @@ bool X86TargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (SSEDomainFix && OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { + if (OptLevel != CodeGenOpt::None && Subtarget.hasSSE2()) { PM.add(createSSEDomainFixPass()); return true; } Modified: llvm/trunk/test/CodeGen/X86/2009-02-05-CoalescerBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-02-05-CoalescerBug.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-02-05-CoalescerBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-02-05-CoalescerBug.ll Tue Mar 30 17:47:00 2010 @@ -1,5 +1,7 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2,-sse41 | grep movss | count 2 -; RUN: llc < %s -march=x86 -mattr=+sse2,-sse41 | grep movaps | count 4 +; RUN: llc < %s -march=x86 -mattr=+sse2,-sse41 -o %t +; RUN: grep movss %t | count 2 +; RUN: grep movaps %t | count 2 +; RUN: grep movdqa %t | count 2 define i1 @t([2 x float]* %y, [2 x float]* %w, i32, [2 x float]* %x.pn59, i32 %smax190, i32 %j.1180, <4 x float> %wu.2179, <4 x float> %wr.2178, <4 x float>* %tmp89.out, <4 x float>* %tmp107.out, i32* %indvar.next218.out) nounwind { newFuncRoot: Modified: llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll (original) +++ llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll Tue Mar 30 17:47:00 2010 @@ -1,11 +1,11 @@ -; RUN: llc < %s -march=x86 -mcpu=penryn -disable-mmx -o %t -; RUN: grep unpcklpd %t | count 1 -; RUN: grep movapd %t | count 1 -; RUN: grep movaps %t | count 1 +; RUN: llc < %s -march=x86 -mcpu=penryn -disable-mmx | FileCheck %s ; Shows a dag combine bug that will generate an illegal build vector ; with v2i64 build_vector i32, i32. +; CHECK: _test: +; CHECK: unpcklpd +; CHECK: movapd define void @test(<2 x double>* %dst, <4 x double> %src) nounwind { entry: %tmp7.i = shufflevector <4 x double> %src, <4 x double> undef, <2 x i32> < i32 0, i32 2 > @@ -13,6 +13,8 @@ ret void } +; CHECK: _test2: +; CHECK: movdqa define void @test2(<4 x i16>* %src, <4 x i32>* %dest) nounwind { entry: %tmp1 = load <4 x i16>* %src Modified: llvm/trunk/test/CodeGen/X86/gather-addresses.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/gather-addresses.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/gather-addresses.ll (original) +++ llvm/trunk/test/CodeGen/X86/gather-addresses.ll Tue Mar 30 17:47:00 2010 @@ -5,7 +5,7 @@ ; bounce the vector off of cache rather than shuffling each individual ; element out of the index vector. -; CHECK: pand (%rdx), %xmm0 +; CHECK: andps (%rdx), %xmm0 ; CHECK: movaps %xmm0, -24(%rsp) ; CHECK: movslq -24(%rsp), %rax ; CHECK: movsd (%rdi,%rax,8), %xmm0 Modified: llvm/trunk/test/CodeGen/X86/sse-align-12.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-align-12.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse-align-12.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse-align-12.ll Tue Mar 30 17:47:00 2010 @@ -1,10 +1,8 @@ -; RUN: llc < %s -march=x86-64 > %t -; RUN: grep unpck %t | count 2 -; RUN: grep shuf %t | count 2 -; RUN: grep ps %t | count 4 -; RUN: grep pd %t | count 4 -; RUN: grep movup %t | count 4 +; RUN: llc < %s -march=x86-64 | FileCheck %s +; CHECK: _a: +; CHECK: movdqu +; CHECK: pshufd define <4 x float> @a(<4 x float>* %y) nounwind { %x = load <4 x float>* %y, align 4 %a = extractelement <4 x float> %x, i32 0 @@ -17,6 +15,10 @@ %s = insertelement <4 x float> %r, float %a, i32 3 ret <4 x float> %s } + +; CHECK: _b: +; CHECK: movups +; CHECK: unpckhps define <4 x float> @b(<4 x float>* %y, <4 x float> %z) nounwind { %x = load <4 x float>* %y, align 4 %a = extractelement <4 x float> %x, i32 2 @@ -29,6 +31,10 @@ %s = insertelement <4 x float> %r, float %b, i32 3 ret <4 x float> %s } + +; CHECK: _c: +; CHECK: movupd +; CHECK: shufpd define <2 x double> @c(<2 x double>* %y) nounwind { %x = load <2 x double>* %y, align 8 %a = extractelement <2 x double> %x, i32 0 @@ -37,6 +43,10 @@ %r = insertelement <2 x double> %p, double %a, i32 1 ret <2 x double> %r } + +; CHECK: _d: +; CHECK: movupd +; CHECK: unpckhpd define <2 x double> @d(<2 x double>* %y, <2 x double> %z) nounwind { %x = load <2 x double>* %y, align 8 %a = extractelement <2 x double> %x, i32 1 Modified: llvm/trunk/test/CodeGen/X86/sse-align-6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-align-6.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse-align-6.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse-align-6.ll Tue Mar 30 17:47:00 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86-64 | grep movups | count 1 +; RUN: llc < %s -march=x86-64 | grep movdqu | count 1 define <2 x i64> @bar(<2 x i64>* %p, <2 x i64> %x) nounwind { %t = load <2 x i64>* %p, align 8 Modified: llvm/trunk/test/CodeGen/X86/sse3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse3.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse3.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse3.ll Tue Mar 30 17:47:00 2010 @@ -20,7 +20,7 @@ ; X64: pshuflw $0, %xmm0, %xmm0 ; X64: xorl %eax, %eax ; X64: pinsrw $0, %eax, %xmm0 -; X64: movaps %xmm0, (%rdi) +; X64: movdqa %xmm0, (%rdi) ; X64: ret } @@ -32,7 +32,7 @@ ; X64: t1: ; X64: movl (%rsi), %eax -; X64: movaps (%rdi), %xmm0 +; X64: movdqa (%rdi), %xmm0 ; X64: pinsrw $0, %eax, %xmm0 ; X64: ret } @@ -66,7 +66,7 @@ ; X64: pshufhw $100, %xmm0, %xmm2 ; X64: pinsrw $1, %eax, %xmm2 ; X64: pextrw $1, %xmm0, %eax -; X64: movaps %xmm2, %xmm0 +; X64: movdqa %xmm2, %xmm0 ; X64: pinsrw $4, %eax, %xmm0 ; X64: ret } @@ -122,7 +122,7 @@ ; X64: t8: ; X64: pshuflw $-58, (%rsi), %xmm0 ; X64: pshufhw $-58, %xmm0, %xmm0 -; X64: movaps %xmm0, (%rdi) +; X64: movdqa %xmm0, (%rdi) ; X64: ret } Modified: llvm/trunk/test/CodeGen/X86/vec_compare.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_compare.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_compare.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_compare.ll Tue Mar 30 17:47:00 2010 @@ -15,7 +15,7 @@ ; CHECK: test2: ; CHECK: pcmp ; CHECK: pcmp -; CHECK: xorps +; CHECK: pxor ; CHECK: ret %C = icmp sge <4 x i32> %A, %B %D = sext <4 x i1> %C to <4 x i32> @@ -25,7 +25,7 @@ define <4 x i32> @test3(<4 x i32> %A, <4 x i32> %B) nounwind { ; CHECK: test3: ; CHECK: pcmpgtd -; CHECK: movaps +; CHECK: movdqa ; CHECK: ret %C = icmp slt <4 x i32> %A, %B %D = sext <4 x i1> %C to <4 x i32> @@ -34,7 +34,7 @@ define <4 x i32> @test4(<4 x i32> %A, <4 x i32> %B) nounwind { ; CHECK: test4: -; CHECK: movaps +; CHECK: movdqa ; CHECK: pcmpgtd ; CHECK: ret %C = icmp ugt <4 x i32> %A, %B Modified: llvm/trunk/test/CodeGen/X86/widen_cast-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_cast-2.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_cast-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_cast-2.ll Tue Mar 30 17:47:00 2010 @@ -2,7 +2,7 @@ ; CHECK: pextrd ; CHECK: pextrd ; CHECK: movd -; CHECK: movaps +; CHECK: movdqa ; bitcast v14i16 to v7i32 Modified: llvm/trunk/test/CodeGen/X86/widen_load-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_load-2.ll?rev=99954&r1=99953&r2=99954&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_load-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_load-2.ll Tue Mar 30 17:47:00 2010 @@ -5,7 +5,7 @@ %i32vec3 = type <3 x i32> define void @add3i32(%i32vec3* sret %ret, %i32vec3* %ap, %i32vec3* %bp) { -; CHECK: movaps +; CHECK: movdqa ; CHECK: paddd ; CHECK: pextrd ; CHECK: movq @@ -33,13 +33,13 @@ %i32vec7 = type <7 x i32> define void @add7i32(%i32vec7* sret %ret, %i32vec7* %ap, %i32vec7* %bp) { -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa ; CHECK: paddd ; CHECK: paddd ; CHECK: pextrd ; CHECK: movq -; CHECK: movaps +; CHECK: movdqa %a = load %i32vec7* %ap, align 16 %b = load %i32vec7* %bp, align 16 %x = add %i32vec7 %a, %b @@ -49,15 +49,15 @@ %i32vec12 = type <12 x i32> define void @add12i32(%i32vec12* sret %ret, %i32vec12* %ap, %i32vec12* %bp) { -; CHECK: movaps -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa +; CHECK: movdqa ; CHECK: paddd ; CHECK: paddd ; CHECK: paddd -; CHECK: movaps -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa +; CHECK: movdqa %a = load %i32vec12* %ap, align 16 %b = load %i32vec12* %bp, align 16 %x = add %i32vec12 %a, %b @@ -68,7 +68,7 @@ %i16vec3 = type <3 x i16> define void @add3i16(%i16vec3* nocapture sret %ret, %i16vec3* %ap, %i16vec3* %bp) nounwind { -; CHECK: movaps +; CHECK: movdqa ; CHECK: paddw ; CHECK: movd ; CHECK: pextrw @@ -81,7 +81,7 @@ %i16vec4 = type <4 x i16> define void @add4i16(%i16vec4* nocapture sret %ret, %i16vec4* %ap, %i16vec4* %bp) nounwind { -; CHECK: movaps +; CHECK: movdqa ; CHECK: paddw ; CHECK: movq %a = load %i16vec4* %ap, align 16 @@ -93,12 +93,12 @@ %i16vec12 = type <12 x i16> define void @add12i16(%i16vec12* nocapture sret %ret, %i16vec12* %ap, %i16vec12* %bp) nounwind { -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa ; CHECK: paddw ; CHECK: paddw ; CHECK: movq -; CHECK: movaps +; CHECK: movdqa %a = load %i16vec12* %ap, align 16 %b = load %i16vec12* %bp, align 16 %x = add %i16vec12 %a, %b @@ -108,15 +108,15 @@ %i16vec18 = type <18 x i16> define void @add18i16(%i16vec18* nocapture sret %ret, %i16vec18* %ap, %i16vec18* %bp) nounwind { -; CHECK: movaps -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa +; CHECK: movdqa ; CHECK: paddw ; CHECK: paddw ; CHECK: paddw ; CHECK: movd -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa %a = load %i16vec18* %ap, align 16 %b = load %i16vec18* %bp, align 16 %x = add %i16vec18 %a, %b @@ -127,7 +127,7 @@ %i8vec3 = type <3 x i8> define void @add3i8(%i8vec3* nocapture sret %ret, %i8vec3* %ap, %i8vec3* %bp) nounwind { -; CHECK: movaps +; CHECK: movdqa ; CHECK: paddb ; CHECK: pextrb ; CHECK: movb @@ -140,8 +140,8 @@ %i8vec31 = type <31 x i8> define void @add31i8(%i8vec31* nocapture sret %ret, %i8vec31* %ap, %i8vec31* %bp) nounwind { -; CHECK: movaps -; CHECK: movaps +; CHECK: movdqa +; CHECK: movdqa ; CHECK: paddb ; CHECK: paddb ; CHECK: movq From gabor at mac.com Tue Mar 30 17:49:39 2010 From: gabor at mac.com (Gabor Greif) Date: Wed, 31 Mar 2010 00:49:39 +0200 Subject: [llvm-commits] [PATCH] Configurable CallSiteBase In-Reply-To: <45FDEBC5-75A2-49F9-A1DE-72F8BD198F98@apple.com> References: <4BB1C5BD.7090204@mac.com> <45FDEBC5-75A2-49F9-A1DE-72F8BD198F98@apple.com> Message-ID: <47B9B926-8241-4C18-8F5C-FD2B2DCD56DA@mac.com> Am 30.03.2010 um 21:44 schrieb Dan Gohman: > > On Mar 30, 2010, at 2:34 AM, Gabor Greif wrote: > >> Hi all, >> >> I'd like to put this patch to review. It pulls out some >> functionality from CallSite into a template baseclass >> CallSiteBase. CallSiteBase is highly customizable in the >> type of the inputs and outputs (types), especially constness >> variants. CallSite then chooses the fully non-const configuration. > > Hi Gabor, this looks interesting. I have a few comments. > >> CallSiteBase<> with all-default parameters implements the fully >> const configuration. This is the preferred configuration for >> analyses and predicates, because it prevents accidental mutation. > > Did you find any accidental mutations? Not so far, but I have only const-ized a bunch of occurrences. I was able to remove several non-const --> non-const casts that were necessitated by the CallSite class, however. > >> It is not yet settled how I should arrange the order of >> CallSiteBase template parameters. Logically, those that are >> frequently customized should go to the front, but I have no >> data points yet, since all we use now is an all-or-nothing >> regarding constness. > > I don't think there aren't any interesting customizations > besides flipping constness. Yeah. But I am not done yet. Other use-cases may lurk there. > >> >> Some predicates of analyses already have been converted to >> full-constness to demonstrate the concept. More to follow. >> >> There is potential for pulling more methods into the base class, >> I plan to do this as soon as need arises. >> >> Notable omissions: >> - ProgrammersManual: document CallSiteBase >> - should we define a class ConstCallSite? (I see no gain ATM.) > > Yes -- a class, or perhaps a typedef. 7-ary templates are fearsome, > even > when fully defaulted. Since there's little need for general > customization, > presenting the two main use cases as regular types makes it easier to > understand the API. Okay, I'll drop "ImmutableCallSite" in the mix. > >> >> CallSiteBase now provides three convenience features (some of >> them are inherited by CallSite too) : >> - operator bool: this conversion allows to check whether we have >> a proper call site. Allows to eliminate an indentation level of >> "if" statements. >> - operator ->: gives back the payload as an instruction (InstrTy*) >> - constructor from ValueTy: this may supplant the static "get" >> method in the future (ATM it is implementer in terms of "get"). >> Anyway, this constructor can be used in "if" statements to >> get rid of a free-standing wide-scope local binding. > > Another way to provide this functionality would be to redo the > CallSite > abstraction as a pseudo-class, following the IntrinsicInst.h example. > That way, it could use dyn_cast like everything else instead of its > own syntax. > > For example, something like this: > > class CallSite : public User { > CallSite(); // DO NOT IMPLEMENT > CallSite(const CallSite &); // DO NOT IMPLEMENT > void operator=(const CallSite &); // DO NOT IMPLEMENT > public: > // ... > > // Methods for support type inquiry through isa, cast, and > dyn_cast: > static inline bool classof(const CallSite *) { return true; } > static inline bool classof(const CallInst *I) { return true; } > static inline bool classof(const InvokeInst *I) { return true; } > static inline bool classof(const Value *V) { > return isa(V) || isa(V); > } > }; Hmmm, CallSite is supposed to have the weight of a pointer, and the above is rather heavy, certainly not "value semantics". I do not like the idea. Cheers, Gabor > > I don't have a strong opinion about this though. > > Dan > From clattner at apple.com Tue Mar 30 17:50:47 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 15:50:47 -0700 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td In-Reply-To: <20100330224656.01CC02A6C12D@llvm.org> References: <20100330224656.01CC02A6C12D@llvm.org> Message-ID: <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> On Mar 30, 2010, at 3:46 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Tue Mar 30 17:46:55 2010 > New Revision: 99953 > > URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev > Log: > V_SETALLONES is an integer instruction. > > Since it is just a pxor in disguise, we should probably expand it to a full > polymorphic triple. Couldn't V_SETALLONES be implementated in all domains to avoid a domain crossing? -Chris > > Modified: > llvm/trunk/lib/Target/X86/X86InstrSSE.td > > Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99953&r1=99952&r2=99953&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) > +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Mar 30 17:46:55 2010 > @@ -2424,7 +2424,7 @@ > // We set canFoldAsLoad because this can be converted to a constant-pool > // load of an all-ones value if folding it would be beneficial. > let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, > - isCodeGenOnly = 1 in > + isCodeGenOnly = 1, ExeDomain = SSEPackedInt in > // FIXME: Change encoding to pseudo. > def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "", > [(set VR128:$dst, (v4i32 immAllOnesV))]>; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ggreif at gmail.com Tue Mar 30 17:53:16 2010 From: ggreif at gmail.com (Gabor Greif) Date: Tue, 30 Mar 2010 15:53:16 -0700 (PDT) Subject: [llvm-commits] [PATCH] Configurable CallSiteBase In-Reply-To: <47B9B926-8241-4C18-8F5C-FD2B2DCD56DA@mac.com> References: <4BB1C5BD.7090204@mac.com> <45FDEBC5-75A2-49F9-A1DE-72F8BD198F98@apple.com> <47B9B926-8241-4C18-8F5C-FD2B2DCD56DA@mac.com> Message-ID: <8ed6e324-9c79-41e7-ba9e-ec76afad855f@10g2000yqq.googlegroups.com> On 31 Mrz., 00:49, Gabor Greif wrote: > I was able to remove several non-const --> non-const casts Err, I mean *const --> non-const casts* Gabor From stoklund at 2pi.dk Tue Mar 30 17:57:41 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 15:57:41 -0700 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td In-Reply-To: <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> References: <20100330224656.01CC02A6C12D@llvm.org> <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> Message-ID: On Mar 30, 2010, at 3:50 PM, Chris Lattner wrote: > > On Mar 30, 2010, at 3:46 PM, Jakob Stoklund Olesen wrote: > >> Author: stoklund >> Date: Tue Mar 30 17:46:55 2010 >> New Revision: 99953 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev >> Log: >> V_SETALLONES is an integer instruction. >> >> Since it is just a pxor in disguise, we should probably expand it to a full >> polymorphic triple. > > Couldn't V_SETALLONES be implementated in all domains to avoid a domain crossing? Yes, and so can V_SET0. Coming up. From sabre at nondot.org Tue Mar 30 18:03:27 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 30 Mar 2010 23:03:27 -0000 Subject: [llvm-commits] [llvm] r99957 - in /llvm/trunk: include/llvm/Instruction.h include/llvm/LLVMContext.h include/llvm/Support/ValueHandle.h lib/VMCore/Instruction.cpp lib/VMCore/LLVMContext.cpp lib/VMCore/Metadata.cpp Message-ID: <20100330230327.5051D2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 18:03:27 2010 New Revision: 99957 URL: http://llvm.org/viewvc/llvm-project?rev=99957&view=rev Log: Fix a major source of compile-time slowness at -O0 -g by optimizing the storage of !dbg metadata kinds in the instruction themselves. The on-the-side hash table works great for metadata that not-all instructions get, or for metadata that only exists when optimizing. But when compile-time is everything, it isn't great. I'm not super thrilled with the fact that this plops a TrackingVH in Instruction, because it grows it by 3 words. I'm investigating alternatives, but this should be a step in the right direction in any case. Modified: llvm/trunk/include/llvm/Instruction.h llvm/trunk/include/llvm/LLVMContext.h llvm/trunk/include/llvm/Support/ValueHandle.h llvm/trunk/lib/VMCore/Instruction.cpp llvm/trunk/lib/VMCore/LLVMContext.cpp llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Tue Mar 30 18:03:27 2010 @@ -17,6 +17,7 @@ #include "llvm/User.h" #include "llvm/ADT/ilist_node.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { @@ -31,6 +32,7 @@ Instruction(const Instruction &); // Do not implement BasicBlock *Parent; + TrackingVH DbgInfo; // 'dbg' Metadata cache. enum { /// HasMetadataBit - This is a bit stored in the SubClassData field which @@ -123,7 +125,7 @@ /// hasMetadata() - Return true if this instruction has any metadata attached /// to it. bool hasMetadata() const { - return (getSubclassDataFromValue() & HasMetadataBit) != 0; + return DbgInfo != 0 || hasMetadataHashEntry(); } /// getMetadata - Get the metadata of given kind attached to this Instruction. @@ -155,6 +157,12 @@ void setMetadata(const char *Kind, MDNode *Node); private: + /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side + /// metadata hash. + bool hasMetadataHashEntry() const { + return (getSubclassDataFromValue() & HasMetadataBit) != 0; + } + // These are all implemented in Metadata.cpp. MDNode *getMetadataImpl(unsigned KindID) const; MDNode *getMetadataImpl(const char *Kind) const; @@ -315,7 +323,7 @@ return Value::getSubclassDataFromValue(); } - void setHasMetadata(bool V) { + void setHasMetadataHashEntry(bool V) { setValueSubclassData((getSubclassDataFromValue() & ~HasMetadataBit) | (V ? HasMetadataBit : 0)); } Modified: llvm/trunk/include/llvm/LLVMContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LLVMContext.h?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/include/llvm/LLVMContext.h (original) +++ llvm/trunk/include/llvm/LLVMContext.h Tue Mar 30 18:03:27 2010 @@ -36,6 +36,12 @@ LLVMContext(); ~LLVMContext(); + // Pinned metadata names, which always have the same value. This is a + // compile-time performance optimization, not a correctness optimization. + enum { + MD_dbg = 1 // "dbg" -> 1. + }; + /// getMDKindID - Return a unique non-zero ID for the specified metadata kind. /// This ID is uniqued across modules in the current LLVMContext. unsigned getMDKindID(StringRef Name) const; Modified: llvm/trunk/include/llvm/Support/ValueHandle.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ValueHandle.h?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ValueHandle.h (original) +++ llvm/trunk/include/llvm/Support/ValueHandle.h Tue Mar 30 18:03:27 2010 @@ -302,7 +302,7 @@ ValueTy *getValPtr() const { CheckValidity(); - return static_cast(ValueHandleBase::getValPtr()); + return (ValueTy*)ValueHandleBase::getValPtr(); } void setValPtr(ValueTy *P) { CheckValidity(); Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Tue Mar 30 18:03:27 2010 @@ -22,7 +22,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, Instruction *InsertBefore) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -36,7 +36,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContext.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContext.cpp Tue Mar 30 18:03:27 2010 @@ -26,7 +26,11 @@ return *GlobalContext; } -LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { } +LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { + // Create the first metadata kind, which is always 'dbg'. + unsigned DbgID = getMDKindID("dbg"); + assert(DbgID == MD_dbg && "dbg kind id drifted"); (void)DbgID; +} LLVMContext::~LLVMContext() { delete pImpl; } Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=99957&r1=99956&r2=99957&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Mar 30 18:03:27 2010 @@ -430,12 +430,19 @@ void Instruction::setMetadata(unsigned KindID, MDNode *Node) { if (Node == 0 && !hasMetadata()) return; + // Handle 'dbg' as a special case since it is not stored in the hash table. + if (KindID == LLVMContext::MD_dbg) { + DbgInfo = Node; + return; + } + // Handle the case when we're adding/updating metadata on an instruction. if (Node) { LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this]; - assert(!Info.empty() == hasMetadata() && "HasMetadata bit is wonked"); + assert(!Info.empty() == hasMetadataHashEntry() && + "HasMetadata bit is wonked"); if (Info.empty()) { - setHasMetadata(true); + setHasMetadataHashEntry(true); } else { // Handle replacement of an existing value. for (unsigned i = 0, e = Info.size(); i != e; ++i) @@ -451,18 +458,19 @@ } // Otherwise, we're removing metadata from an instruction. - assert(hasMetadata() && getContext().pImpl->MetadataStore.count(this) && + assert(hasMetadataHashEntry() && + getContext().pImpl->MetadataStore.count(this) && "HasMetadata bit out of date!"); LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this]; // Common case is removing the only entry. if (Info.size() == 1 && Info[0].first == KindID) { getContext().pImpl->MetadataStore.erase(this); - setHasMetadata(false); + setHasMetadataHashEntry(false); return; } - // Handle replacement of an existing value. + // Handle removal of an existing value. for (unsigned i = 0, e = Info.size(); i != e; ++i) if (Info[i].first == KindID) { Info[i] = Info.back(); @@ -474,8 +482,14 @@ } MDNode *Instruction::getMetadataImpl(unsigned KindID) const { + // Handle 'dbg' as a special case since it is not stored in the hash table. + if (KindID == LLVMContext::MD_dbg) + return DbgInfo; + + if (!hasMetadataHashEntry()) return 0; + LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this]; - assert(hasMetadata() && !Info.empty() && "Shouldn't have called this"); + assert(!Info.empty() && "bit out of sync with hash table"); for (LLVMContextImpl::MDMapTy::iterator I = Info.begin(), E = Info.end(); I != E; ++I) @@ -485,14 +499,22 @@ } void Instruction::getAllMetadataImpl(SmallVectorImpl > &Result)const { - assert(hasMetadata() && getContext().pImpl->MetadataStore.count(this) && + MDNode*> > &Result) const { + Result.clear(); + + // Handle 'dbg' as a special case since it is not stored in the hash table. + if (DbgInfo) { + Result.push_back(std::make_pair((unsigned)LLVMContext::MD_dbg, DbgInfo)); + if (!hasMetadataHashEntry()) return; + } + + assert(hasMetadataHashEntry() && + getContext().pImpl->MetadataStore.count(this) && "Shouldn't have called this"); const LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore.find(this)->second; assert(!Info.empty() && "Shouldn't have called this"); - Result.clear(); Result.append(Info.begin(), Info.end()); // Sort the resulting array so it is stable. @@ -503,7 +525,10 @@ /// removeAllMetadata - Remove all metadata from this instruction. void Instruction::removeAllMetadata() { assert(hasMetadata() && "Caller should check"); - getContext().pImpl->MetadataStore.erase(this); - setHasMetadata(false); + DbgInfo = 0; + if (hasMetadataHashEntry()) { + getContext().pImpl->MetadataStore.erase(this); + setHasMetadataHashEntry(false); + } } From clattner at apple.com Tue Mar 30 18:06:21 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 16:06:21 -0700 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td In-Reply-To: References: <20100330224656.01CC02A6C12D@llvm.org> <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> Message-ID: <0E649214-0B06-460D-90F5-E4CF3D8AC6D0@apple.com> On Mar 30, 2010, at 3:57 PM, Jakob Stoklund Olesen wrote: > > On Mar 30, 2010, at 3:50 PM, Chris Lattner wrote: > >> >> On Mar 30, 2010, at 3:46 PM, Jakob Stoklund Olesen wrote: >> >>> Author: stoklund >>> Date: Tue Mar 30 17:46:55 2010 >>> New Revision: 99953 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev >>> Log: >>> V_SETALLONES is an integer instruction. >>> >>> Since it is just a pxor in disguise, we should probably expand it to a full >>> polymorphic triple. >> >> Couldn't V_SETALLONES be implementated in all domains to avoid a domain crossing? > > Yes, and so can V_SET0. > > Coming up. Spiffy, thanks :) -Chris From daniel at zuster.org Tue Mar 30 18:06:33 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 30 Mar 2010 16:06:33 -0700 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/ Message-ID: Hi Mon Ping, On Tue, Mar 30, 2010 at 1:55 PM, Mon P Wang wrote: > Author: wangmp > Date: Tue Mar 30 15:55:56 2010 > New Revision: 99928 > > URL: http://llvm.org/viewvc/llvm-project?rev=99928&view=rev > Log: > Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset, > e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) > A update of langref will occur in a subsequent checkin. This patch could have been staged better. In particular, bringing in API changes like CreateCall5 you intend to use in separate projects in a separate, earlier commit is general goodness. - Daniel > Modified: > ? ?llvm/trunk/include/llvm/CodeGen/SelectionDAG.h > ? ?llvm/trunk/include/llvm/IntrinsicInst.h > ? ?llvm/trunk/include/llvm/Intrinsics.td > ? ?llvm/trunk/include/llvm/Support/IRBuilder.h > ? ?llvm/trunk/include/llvm/Target/TargetLowering.h > ? ?llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h > ? ?llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > ? ?llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > ? ?llvm/trunk/lib/Target/ARM/ARMISelLowering.h > ? ?llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > ? ?llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > ? ?llvm/trunk/lib/Target/X86/X86ISelLowering.h > ? ?llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > ? ?llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp > ? ?llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > ? ?llvm/trunk/lib/VMCore/AutoUpgrade.cpp > ? ?llvm/trunk/test/Analysis/BasicAA/modref.ll > ? ?llvm/trunk/test/Transforms/InstCombine/memset_chk.ll > ? ?llvm/trunk/test/Transforms/InstCombine/objsize.ll > ? ?llvm/trunk/test/Transforms/MemCpyOpt/align.ll > ? ?llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll > ? ?llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll > > Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) > +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Tue Mar 30 15:55:56 2010 > @@ -534,17 +534,17 @@ > ? SDValue getStackArgumentTokenFactor(SDValue Chain); > > ? SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff); > > ? SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, bool isVol, > ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstOSVff, > ? ? ? ? ? ? ? ? ? ? ?const Value *SrcSV, uint64_t SrcSVOff); > > ? SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, > + ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, bool isVol, > ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff); > > ? /// getSetCC - Helper function to make it easier to build SetCC's if you just > > Modified: llvm/trunk/include/llvm/IntrinsicInst.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/IntrinsicInst.h (original) > +++ llvm/trunk/include/llvm/IntrinsicInst.h Tue Mar 30 15:55:56 2010 > @@ -133,6 +133,13 @@ > ? ? ? return getAlignmentCst()->getZExtValue(); > ? ? } > > + ? ?ConstantInt *getVolatileCst() const { > + ? ? ?return cast(const_cast(getOperand(5))); > + ? ?} > + ? ?bool isVolatile() const { > + ? ? ?return getVolatileCst()->getZExtValue() != 0; > + ? ?} > + > ? ? /// getDest - This is just like getRawDest, but it strips off any cast > ? ? /// instructions that feed it, giving the original input. ?The returned > ? ? /// value is guaranteed to be a pointer. > @@ -155,7 +162,11 @@ > ? ? void setAlignment(Constant* A) { > ? ? ? setOperand(4, A); > ? ? } > - > + > + ? ?void setVolatile(Constant* V) { > + ? ? ?setOperand(5, V); > + ? ?} > + > ? ? const Type *getAlignmentType() const { > ? ? ? return getOperand(4)->getType(); > ? ? } > > Modified: llvm/trunk/include/llvm/Intrinsics.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Intrinsics.td (original) > +++ llvm/trunk/include/llvm/Intrinsics.td Tue Mar 30 15:55:56 2010 > @@ -224,16 +224,16 @@ > ?// > > ?def int_memcpy ?: Intrinsic<[], > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?llvm_i32_ty], > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?llvm_i32_ty, llvm_i1_ty], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; > ?def int_memmove : Intrinsic<[], > - ? ? ? ? ? ? ? ? ? ? ? ? ? ?[llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? llvm_i32_ty], > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?[llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? llvm_i32_ty, llvm_i1_ty], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; > ?def int_memset ?: Intrinsic<[], > - ? ? ? ? ? ? ? ? ? ? ? ? ? ?[llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? llvm_i32_ty], > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?[llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? llvm_i32_ty, llvm_i1_ty], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? [IntrWriteArgMem, NoCapture<0>]>; > > ?// These functions do not actually read memory, but they are sensitive to the > > Modified: llvm/trunk/include/llvm/Support/IRBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Mar 30 15:55:56 2010 > @@ -909,6 +909,11 @@ > ? ? Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; > ? ? return Insert(CallInst::Create(Callee, Args, Args+4), Name); > ? } > + ?CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, > + ? ? ? ? ? ? ? ? ? ? ? ?Value *Arg4, Value *Arg5, const Twine &Name = "") { > + ? ?Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; > + ? ?return Insert(CallInst::Create(Callee, Args, Args+5), Name); > + ?} > > ? template > ? CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, > > Modified: llvm/trunk/include/llvm/Target/TargetLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) > +++ llvm/trunk/include/llvm/Target/TargetLowering.h Tue Mar 30 15:55:56 2010 > @@ -1184,7 +1184,7 @@ > ? EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Op1, SDValue Op2, > - ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Op3, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Op3, unsigned Align, bool isVolatile, > ? ? ? ? ? ? ? ? ? ? ? ? ? bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcOff) { > @@ -1201,7 +1201,7 @@ > ? EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Op1, SDValue Op2, > - ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Op3, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Op3, unsigned Align, bool isVolatile, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *SrcSV, uint64_t SrcOff) { > ? ? return SDValue(); > @@ -1217,7 +1217,7 @@ > ? EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Op1, SDValue Op2, > - ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Op3, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Op3, unsigned Align, bool isVolatile, > ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstOff) { > ? ? return SDValue(); > ? } > > Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Tue Mar 30 15:55:56 2010 > @@ -46,8 +46,8 @@ > > ? /// EmitMemCpy - Emit a call to the memcpy function to the builder. ?This > ? /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > - ?Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, > - ? ? ? ? ? ? ? ? ? ?unsigned Align, IRBuilder<> &B, const TargetData *TD); > + ?Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, > + ? ? ? ? ? ? ? ? ? ?bool isVolatile, IRBuilder<> &B, const TargetData *TD); > > ? /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. > ? /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src > @@ -57,8 +57,8 @@ > > ? /// EmitMemMove - Emit a call to the memmove function to the builder. ?This > ? /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > - ?Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, IRBuilder<> &B, const TargetData *TD); > + ?Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? bool isVolatile, IRBuilder<> &B, const TargetData *TD); > > ? /// EmitMemChr - Emit a call to the memchr function. ?This assumes that Ptr is > ? /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. > @@ -70,8 +70,8 @@ > ? ? ? ? ? ? ? ? ? ? const TargetData *TD); > > ? /// EmitMemSet - Emit a call to the memset function > - ?Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, > - ? ? ? ? ? ? ? ? ? ?const TargetData *TD); > + ?Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, > + ? ? ? ? ? ? ? ? ? ?IRBuilder<> &B, const TargetData *TD); > > ? /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' > ? /// (e.g. ?'floor'). ?This function is known to take a single of type matching > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Mar 30 15:55:56 2010 > @@ -3275,7 +3275,8 @@ > ?static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Chain, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Src, uint64_t Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, bool isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *SrcSV, uint64_t SrcSVOff) { > ? const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > @@ -3312,7 +3313,7 @@ > ? ? ? Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); > ? ? ? Store = DAG.getStore(Chain, dl, Value, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?getMemBasePlusOffset(Dst, DstOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, false, false, DstAlign); > + ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, isVol, false, DstAlign); > ? ? } else { > ? ? ? // The type might not be legal for the target. ?This should only happen > ? ? ? // if the type is smaller than a legal type, as on PPC, so the right > @@ -3323,10 +3324,10 @@ > ? ? ? assert(NVT.bitsGE(VT)); > ? ? ? Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getMemBasePlusOffset(Src, SrcOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? SrcSV, SrcSVOff + SrcOff, VT, isVol, false, Align); > ? ? ? Store = DAG.getTruncStore(Chain, dl, Value, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? getMemBasePlusOffset(Dst, DstOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DstSV, DstSVOff + DstOff, VT, false, false, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DstSV, DstSVOff + DstOff, VT, isVol, false, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstAlign); > ? ? } > ? ? OutChains.push_back(Store); > @@ -3341,7 +3342,8 @@ > ?static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Src, uint64_t Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, bool isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff){ > ? const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > @@ -3372,7 +3374,7 @@ > > ? ? Value = DAG.getLoad(VT, dl, Chain, > ? ? ? ? ? ? ? ? ? ? ? ? getMemBasePlusOffset(Src, SrcOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ?SrcSV, SrcSVOff + SrcOff, false, false, Align); > + ? ? ? ? ? ? ? ? ? ? ? ?SrcSV, SrcSVOff + SrcOff, isVol, false, Align); > ? ? LoadValues.push_back(Value); > ? ? LoadChains.push_back(Value.getValue(1)); > ? ? SrcOff += VTSize; > @@ -3387,7 +3389,7 @@ > > ? ? Store = DAG.getStore(Chain, dl, LoadValues[i], > ? ? ? ? ? ? ? ? ? ? ? ? ?getMemBasePlusOffset(Dst, DstOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, false, false, DstAlign); > + ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, isVol, false, DstAlign); > ? ? OutChains.push_back(Store); > ? ? DstOff += VTSize; > ? } > @@ -3399,7 +3401,7 @@ > ?static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Chain, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Src, uint64_t Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, bool isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstSVOff) { > ? const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > > @@ -3422,7 +3424,7 @@ > ? ? SDValue Value = getMemsetValue(Src, VT, DAG, dl); > ? ? SDValue Store = DAG.getStore(Chain, dl, Value, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?getMemBasePlusOffset(Dst, DstOff, DAG), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, false, false, 0); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + DstOff, isVol, false, 0); > ? ? OutChains.push_back(Store); > ? ? DstOff += VTSize; > ? } > @@ -3433,7 +3435,7 @@ > > ?SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Src, SDValue Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, bool isVol, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff) { > > @@ -3447,8 +3449,8 @@ > > ? ? SDValue Result = > ? ? ? getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ConstantSize->getZExtValue(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ConstantSize->getZExtValue(), ?Align, isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? false, DstSV, DstSVOff, SrcSV, SrcSVOff); > ? ? if (Result.getNode()) > ? ? ? return Result; > ? } > @@ -3457,7 +3459,7 @@ > ? // code. If the target chooses to do this, this is the next best. > ? SDValue Result = > ? ? TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?isVol, AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff, SrcSV, SrcSVOff); > ? if (Result.getNode()) > ? ? return Result; > @@ -3467,11 +3469,12 @@ > ? if (AlwaysInline) { > ? ? assert(ConstantSize && "AlwaysInline requires a constant size!"); > ? ? return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ConstantSize->getZExtValue(), Align, true, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff, SrcSV, SrcSVOff); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ConstantSize->getZExtValue(), Align, isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? true, DstSV, DstSVOff, SrcSV, SrcSVOff); > ? } > > ? // Emit a library call. > + ?assert(!isVol && "library memcpy does not support volatile"); > ? TargetLowering::ArgListTy Args; > ? TargetLowering::ArgListEntry Entry; > ? Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); > @@ -3492,7 +3495,7 @@ > > ?SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Src, SDValue Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, bool isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *SrcSV, uint64_t SrcSVOff) { > > @@ -3506,8 +3509,8 @@ > > ? ? SDValue Result = > ? ? ? getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ConstantSize->getZExtValue(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ConstantSize->getZExtValue(), Align, isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false, DstSV, DstSVOff, SrcSV, SrcSVOff); > ? ? if (Result.getNode()) > ? ? ? return Result; > ? } > @@ -3515,12 +3518,13 @@ > ? // Then check to see if we should lower the memmove with target-specific > ? // code. If the target chooses to do this, this is the next best. > ? SDValue Result = > - ? ?TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, > + ? ?TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DstSV, DstSVOff, SrcSV, SrcSVOff); > ? if (Result.getNode()) > ? ? return Result; > > ? // Emit a library call. > + ?assert(!isVol && "library memmove does not support volatile"); > ? TargetLowering::ArgListTy Args; > ? TargetLowering::ArgListEntry Entry; > ? Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); > @@ -3541,7 +3545,7 @@ > > ?SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Src, SDValue Size, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, bool isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff) { > > ? // Check to see if we should lower the memset to stores first. > @@ -3554,7 +3558,7 @@ > > ? ? SDValue Result = > ? ? ? getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), > - ? ? ? ? ? ? ? ? ? ? ?Align, DstSV, DstSVOff); > + ? ? ? ? ? ? ? ? ? ? ?Align, isVol, DstSV, DstSVOff); > ? ? if (Result.getNode()) > ? ? ? return Result; > ? } > @@ -3562,12 +3566,13 @@ > ? // Then check to see if we should lower the memset with target-specific > ? // code. If the target chooses to do this, this is the next best. > ? SDValue Result = > - ? ?TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, > + ? ?TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff); > ? if (Result.getNode()) > ? ? return Result; > > ? // Emit a library call. > + ?assert(!isVol && "library memset does not support volatile"); > ? const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); > ? TargetLowering::ArgListTy Args; > ? TargetLowering::ArgListEntry Entry; > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Mar 30 15:55:56 2010 > @@ -3731,28 +3731,50 @@ > ? case Intrinsic::longjmp: > ? ? return "_longjmp"+!TLI.usesUnderscoreLongJmp(); > ? case Intrinsic::memcpy: { > + ? ?// Assert for address < 256 since we support only user defined address > + ? ?// spaces. > + ? ?assert(cast(I.getOperand(1)->getType())->getAddressSpace() > + ? ? ? ? ? < 256 && > + ? ? ? ? ? cast(I.getOperand(2)->getType())->getAddressSpace() > + ? ? ? ? ? < 256 && > + ? ? ? ? ? "Unknown address space"); > ? ? SDValue Op1 = getValue(I.getOperand(1)); > ? ? SDValue Op2 = getValue(I.getOperand(2)); > ? ? SDValue Op3 = getValue(I.getOperand(3)); > ? ? unsigned Align = cast(I.getOperand(4))->getZExtValue(); > - ? ?DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, > + ? ?bool isVol = cast(I.getOperand(5))->getZExtValue(); > + ? ?DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? I.getOperand(1), 0, I.getOperand(2), 0)); > ? ? return 0; > ? } > ? case Intrinsic::memset: { > + ? ?// Assert for address < 256 since we support only user defined address > + ? ?// spaces. > + ? ?assert(cast(I.getOperand(1)->getType())->getAddressSpace() > + ? ? ? ? ? < 256 && > + ? ? ? ? ? "Unknown address space"); > ? ? SDValue Op1 = getValue(I.getOperand(1)); > ? ? SDValue Op2 = getValue(I.getOperand(2)); > ? ? SDValue Op3 = getValue(I.getOperand(3)); > ? ? unsigned Align = cast(I.getOperand(4))->getZExtValue(); > - ? ?DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, > + ? ?bool isVol = cast(I.getOperand(5))->getZExtValue(); > + ? ?DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? I.getOperand(1), 0)); > ? ? return 0; > ? } > ? case Intrinsic::memmove: { > + ? ?// Assert for address < 256 since we support only user defined address > + ? ?// spaces. > + ? ?assert(cast(I.getOperand(1)->getType())->getAddressSpace() > + ? ? ? ? ? < 256 && > + ? ? ? ? ? cast(I.getOperand(2)->getType())->getAddressSpace() > + ? ? ? ? ? < 256 && > + ? ? ? ? ? "Unknown address space"); > ? ? SDValue Op1 = getValue(I.getOperand(1)); > ? ? SDValue Op2 = getValue(I.getOperand(2)); > ? ? SDValue Op3 = getValue(I.getOperand(3)); > ? ? unsigned Align = cast(I.getOperand(4))->getZExtValue(); > + ? ?bool isVol = cast(I.getOperand(5))->getZExtValue(); > > ? ? // If the source and destination are known to not be aliases, we can > ? ? // lower memmove as memcpy. > @@ -3761,12 +3783,12 @@ > ? ? ? Size = C->getZExtValue(); > ? ? if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == > ? ? ? ? AliasAnalysis::NoAlias) { > - ? ? ?DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?I.getOperand(1), 0, I.getOperand(2), 0)); > + ? ? ?DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false, I.getOperand(1), 0, I.getOperand(2), 0)); > ? ? ? return 0; > ? ? } > > - ? ?DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, > + ? ?DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?I.getOperand(1), 0, I.getOperand(2), 0)); > ? ? return 0; > ? } > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Mar 30 15:55:56 2010 > @@ -861,7 +861,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? DebugLoc dl) { > ? SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); > ? return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - ? ? ? ? ? ? ? ? ? ? ? /*AlwaysInline=*/false, NULL, 0, NULL, 0); > + ? ? ? ? ? ? ? ? ? ? ? /*isVolatile=*/false, /*AlwaysInline=*/false, > + ? ? ? ? ? ? ? ? ? ? ? NULL, 0, NULL, 0); > ?} > > ?/// LowerMemOpCallTo - Store the argument to the stack. > @@ -2053,7 +2054,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool isVolatile, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *SrcSV, uint64_t SrcSVOff){ > ? // Do repeated 4-byte loads and stores. To be improved. > @@ -2089,7 +2090,7 @@ > ? ? ? Loads[i] = DAG.getLoad(VT, dl, Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DAG.getNode(ISD::ADD, dl, MVT::i32, Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DAG.getConstant(SrcOff, MVT::i32)), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? SrcSV, SrcSVOff + SrcOff, false, false, 0); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); > ? ? ? TFOps[i] = Loads[i].getValue(1); > ? ? ? SrcOff += VTSize; > ? ? } > @@ -2100,7 +2101,7 @@ > ? ? ? TFOps[i] = DAG.getStore(Chain, dl, Loads[i], > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(DstOff, MVT::i32)), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DstSV, DstSVOff + DstOff, false, false, 0); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?DstSV, DstSVOff + DstOff, isVolatile, false, 0); > ? ? ? DstOff += VTSize; > ? ? } > ? ? Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Mar 30 15:55:56 2010 > @@ -305,7 +305,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool isVolatile, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff); > ? ? SDValue LowerCallResult(SDValue Chain, SDValue InFlag, > > Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Mar 30 15:55:56 2010 > @@ -2392,7 +2392,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? DebugLoc dl) { > ? SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); > ? return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - ? ? ? ? ? ? ? ? ? ? ? false, NULL, 0, NULL, 0); > + ? ? ? ? ? ? ? ? ? ? ? false, false, NULL, 0, NULL, 0); > ?} > > ?/// LowerMemOpCallTo - Store the argument to the stack or remember it in case of > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Mar 30 15:55:56 2010 > @@ -1422,7 +1422,8 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? DebugLoc dl) { > ? SDValue SizeNode ? ? = DAG.getConstant(Flags.getByValSize(), MVT::i32); > ? return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - ? ? ? ? ? ? ? ? ? ? ? /*AlwaysInline=*/true, NULL, 0, NULL, 0); > + ? ? ? ? ? ? ? ? ? ? ? /*isVolatile*/false, /*AlwaysInline=*/true, > + ? ? ? ? ? ? ? ? ? ? ? NULL, 0, NULL, 0); > ?} > > ?/// IsTailCallConvention - Return true if the calling convention is one that > @@ -6539,6 +6540,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SDValue Size, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool isVolatile, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Value *DstSV, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t DstSVOff) { > ? ConstantSDNode *ConstantSize = dyn_cast(Size); > @@ -6667,7 +6669,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(Offset, AddrVT)), > ? ? ? ? ? ? ? ? ? ? ? ? ? Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(BytesLeft, SizeVT), > - ? ? ? ? ? ? ? ? ? ? ? ? ?Align, DstSV, DstSVOff + Offset); > + ? ? ? ? ? ? ? ? ? ? ? ? ?Align, isVolatile, DstSV, DstSVOff + Offset); > ? } > > ? // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. > @@ -6678,7 +6680,7 @@ > ?X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool isVolatile, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff) { > ? // This requires the copy size to be a constant, preferrably > @@ -6737,7 +6739,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getNode(ISD::ADD, dl, SrcVT, Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(Offset, SrcVT)), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(BytesLeft, SizeVT), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Align, AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Align, isVolatile, AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DstSV, DstSVOff + Offset, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SrcSV, SrcSVOff + Offset)); > ? } > @@ -6820,8 +6822,8 @@ > ? DebugLoc dl = Op.getDebugLoc(); > > ? return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, > - ? ? ? ? ? ? ? ? ? ? ? DAG.getIntPtrConstant(24), 8, false, > - ? ? ? ? ? ? ? ? ? ? ? DstSV, 0, SrcSV, 0); > + ? ? ? ? ? ? ? ? ? ? ? DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, > + ? ? ? ? ? ? ? ? ? ? ? false, DstSV, 0, SrcSV, 0); > ?} > > ?SDValue > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Mar 30 15:55:56 2010 > @@ -737,12 +737,13 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool isVolatile, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff); > ? ? SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Chain, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Dst, SDValue Src, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SDValue Size, unsigned Align, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool AlwaysInline, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool isVolatile, bool AlwaysInline, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *DstSV, uint64_t DstSVOff, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? const Value *SrcSV, uint64_t SrcSVOff); > > @@ -752,7 +753,7 @@ > ? ? /// block, the number of args, and whether or not the second arg is > ? ? /// in memory or not. > ? ? MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned argNum, bool inMem) const; > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned argNum, bool inMem) const; > > ? ? /// Utility function to emit atomic bitwise operations (and, or, xor). > ? ? /// It takes the bitwise instruction to expand, the associated machine basic > > Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Tue Mar 30 15:55:56 2010 > @@ -1443,7 +1443,7 @@ > ? ? ? ? return DAG.getMemmove(Chain, dl, ST->getBasePtr(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? LD->getBasePtr(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(StoreBits/8, MVT::i32), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Alignment, ST->getSrcValue(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Alignment, false, ST->getSrcValue(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ST->getSrcValueOffset(), LD->getSrcValue(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? LD->getSrcValueOffset()); > ? ? ? } > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue Mar 30 15:55:56 2010 > @@ -136,8 +136,14 @@ > ? ? return 0; ?// If not 1/2/4/8 bytes, exit. > > ? // Use an integer load+store unless we can find something better. > - ?Type *NewPtrTy = > - ? ? ? ? ? ?PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); > + ?unsigned SrcAddrSp = > + ? ?cast(MI->getOperand(2)->getType())->getAddressSpace(); > + ?unsigned DstAddrSp = > + ? ?cast(MI->getOperand(1)->getType())->getAddressSpace(); > + > + ?const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); > + ?Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); > + ?Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); > > ? // Memcpy forces the use of i8* for the source and destination. ?That means > ? // that if you're using memcpy to move one double around, you'll get a cast > @@ -167,8 +173,10 @@ > ? ? ? ? ? break; > ? ? ? } > > - ? ? ?if (SrcETy->isSingleValueType()) > - ? ? ? ?NewPtrTy = PointerType::getUnqual(SrcETy); > + ? ? ?if (SrcETy->isSingleValueType()) { > + ? ? ? ?NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); > + ? ? ? ?NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); > + ? ? ?} > ? ? } > ? } > > @@ -178,11 +186,12 @@ > ? SrcAlign = std::max(SrcAlign, CopyAlign); > ? DstAlign = std::max(DstAlign, CopyAlign); > > - ?Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); > - ?Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); > - ?Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); > + ?Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); > + ?Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); > + ?Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); > ? InsertNewInstBefore(L, *MI); > - ?InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); > + ?InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), > + ? ? ? ? ? ? ? ? ? ? ?*MI); > > ? // Set the size of the copy to 0, it will be deleted on the next iteration. > ? MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); > @@ -275,10 +284,11 @@ > ? ? ? ? if (GVSrc->isConstant()) { > ? ? ? ? ? Module *M = CI.getParent()->getParent()->getParent(); > ? ? ? ? ? Intrinsic::ID MemCpyID = Intrinsic::memcpy; > - ? ? ? ? ?const Type *Tys[1]; > - ? ? ? ? ?Tys[0] = CI.getOperand(3)->getType(); > + ? ? ? ? ?const Type *Tys[3] = { CI.getOperand(1)->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getOperand(2)->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getOperand(3)->getType() }; > ? ? ? ? ? CI.setOperand(0, > - ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); > + ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); > ? ? ? ? ? Changed = true; > ? ? ? ? } > ? ? } > > Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Tue Mar 30 15:55:56 2010 > @@ -413,7 +413,6 @@ > ? // interesting as a small compile-time optimization. > ? Ranges.addStore(0, SI); > > - ?Function *MemSetF = 0; > > ? // Now that we have full information about ranges, loop over the ranges and > ? // emit memset's for anything big enough to be worthwhile. > @@ -433,29 +432,40 @@ > ? ? // memset block. ?This ensure that the memset is dominated by any addressing > ? ? // instruction needed by the start of the block. > ? ? BasicBlock::iterator InsertPt = BI; > - > - ? ?if (MemSetF == 0) { > - ? ? ?const Type *Ty = Type::getInt64Ty(Context); > - ? ? ?MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); > - ? ?} > - > + > ? ? // Get the starting pointer of the block. > ? ? StartPtr = Range.StartPtr; > - > + > + ? ?// Determine alignment > + ? ?unsigned Alignment = Range.Alignment; > + ? ?if (Alignment == 0) { > + ? ? ?const Type *EltType = > + ? ? ? ? cast(StartPtr->getType())->getElementType(); > + ? ? ?Alignment = TD->getABITypeAlignment(EltType); > + ? ?} > + > ? ? // Cast the start ptr to be i8* as memset requires. > - ? ?const Type *i8Ptr = Type::getInt8PtrTy(Context); > - ? ?if (StartPtr->getType() != i8Ptr) > + ? ?const PointerType* StartPTy = cast(StartPtr->getType()); > + ? ?const PointerType *i8Ptr = Type::getInt8PtrTy(Context, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?StartPTy->getAddressSpace()); > + ? ?if (StartPTy!= i8Ptr) > ? ? ? StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?InsertPt); > - > + > ? ? Value *Ops[] = { > ? ? ? StartPtr, ByteVal, ? // Start, value > ? ? ? // size > ? ? ? ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), > ? ? ? // align > - ? ? ?ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) > + ? ? ?ConstantInt::get(Type::getInt32Ty(Context), Alignment), > + ? ? ?// volatile > + ? ? ?ConstantInt::get(Type::getInt1Ty(Context), 0), > ? ? }; > - ? ?Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); > + ? ?const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; > + > + ? ?Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > + > + ? ?Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); > ? ? DEBUG(dbgs() << "Replace stores:\n"; > ? ? ? ? ? for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) > ? ? ? ? ? ? dbgs() << *Range.TheStores[i]; > @@ -680,16 +690,19 @@ > ? ? return false; > > ? // If all checks passed, then we can transform these memcpy's > - ?const Type *Ty = M->getLength()->getType(); > + ?const Type *ArgTys[3] = { M->getRawDest()->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?MDep->getRawSource()->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; > ? Function *MemCpyFun = Intrinsic::getDeclaration( > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getParent()->getParent()->getParent(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? M->getIntrinsicID(), &Ty, 1); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? M->getIntrinsicID(), ArgTys, 3); > > - ?Value *Args[4] = { > - ? ?M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() > + ?Value *Args[5] = { > + ? ?M->getRawDest(), MDep->getRawSource(), M->getLength(), > + ? ?M->getAlignmentCst(), M->getVolatileCst() > ? }; > > - ?CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); > + ?CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); > > > ? // If C and M don't interfere, then this is a valid transformation. ?If they > @@ -728,8 +741,10 @@ > > ? // If not, then we know we can transform this. > ? Module *Mod = M->getParent()->getParent()->getParent(); > - ?const Type *Ty = M->getLength()->getType(); > - ?M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); > + ?const Type *ArgTys[3] = { M->getDest()->getType(), M->getSource()->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; > + ?M->setOperand(0, > + ? ? ? ? ? ? ? ?Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); > > ? // MemDep may have over conservative information about this instruction, just > ? // conservatively flush it from the cache. > > Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Mar 30 15:55:56 2010 > @@ -858,8 +858,17 @@ > ? ? ? EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); > > ? ? // Cast the other pointer (if we have one) to BytePtrTy. > - ? ?if (OtherElt && OtherElt->getType() != BytePtrTy) > - ? ? ?OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); > + ? ?if (OtherElt && OtherElt->getType() != BytePtrTy) { > + ? ? ?// Preserve address space of OtherElt > + ? ? ?const PointerType* OtherPTy = cast(OtherElt->getType()); > + ? ? ?const PointerType* PTy = cast(BytePtrTy); > + ? ? ?if (OtherPTy->getElementType() != PTy->getElementType()) { > + ? ? ? ?Type *NewOtherPTy = PointerType::get(PTy->getElementType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OtherPTy->getAddressSpace()); > + ? ? ? ?OtherElt = new BitCastInst(OtherElt, NewOtherPTy, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? OtherElt->getNameStr(), MI); > + ? ? ?} > + ? ?} > > ? ? unsigned EltSize = TD->getTypeAllocSize(EltTy); > > @@ -870,17 +879,28 @@ > ? ? ? ? SROADest ? OtherElt : EltPtr, ?// Src ptr > ? ? ? ? ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size > ? ? ? ? // Align > - ? ? ? ?ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) > + ? ? ? ?ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), > + ? ? ? ?MI->getVolatileCst() > ? ? ? }; > - ? ? ?CallInst::Create(TheFn, Ops, Ops + 4, "", MI); > + ? ? ?// In case we fold the address space overloaded memcpy of A to B > + ? ? ?// with memcpy of B to C, change the function to be a memcpy of A to C. > + ? ? ?const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?Ops[2]->getType() }; > + ? ? ?Module *M = MI->getParent()->getParent()->getParent(); > + ? ? ?TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); > + ? ? ?CallInst::Create(TheFn, Ops, Ops + 5, "", MI); > ? ? } else { > ? ? ? assert(isa(MI)); > ? ? ? Value *Ops[] = { > ? ? ? ? EltPtr, MI->getOperand(2), ?// Dest, Value, > ? ? ? ? ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size > - ? ? ? ?Zero ?// Align > + ? ? ? ?Zero, ?// Align > + ? ? ? ?ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile > ? ? ? }; > - ? ? ?CallInst::Create(TheFn, Ops, Ops + 4, "", MI); > + ? ? ?const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; > + ? ? ?Module *M = MI->getParent()->getParent()->getParent(); > + ? ? ?TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > + ? ? ?CallInst::Create(TheFn, Ops, Ops + 5, "", MI); > ? ? } > ? } > ? DeadInsts.push_back(MI); > > Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Tue Mar 30 15:55:56 2010 > @@ -142,7 +142,8 @@ > ? ? // We have enough information to now generate the memcpy call to do the > ? ? // concatenation for us. ?Make a memcpy to copy the nul byte with align = 1. > ? ? EmitMemCpy(CpyDst, Src, > - ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); > + ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len+1), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1, false, B, TD); > ? } > ?}; > > @@ -383,7 +384,8 @@ > ? ? ? ? ? ? ? ? ? ? CI->getOperand(3), B, TD); > ? ? else > ? ? ? EmitMemCpy(Dst, Src, > - ? ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); > + ? ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1, false, B, TD); > ? ? return Dst; > ? } > ?}; > @@ -411,8 +413,8 @@ > > ? ? if (SrcLen == 0) { > ? ? ? // strncpy(x, "", y) -> memset(x, '\0', y, 1) > - ? ? ?EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ?B, TD); > + ? ? ?EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), > + ? ? ? ? ? ? ? ? LenOp, false, B, TD); > ? ? ? return Dst; > ? ? } > > @@ -432,7 +434,8 @@ > > ? ? // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] > ? ? EmitMemCpy(Dst, Src, > - ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); > + ? ? ? ? ? ? ? ConstantInt::get(TD->getIntPtrType(*Context), Len), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1, false, B, TD); > > ? ? return Dst; > ? } > @@ -593,7 +596,7 @@ > > ? ? // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) > ? ? EmitMemCpy(CI->getOperand(1), CI->getOperand(2), > - ? ? ? ? ? ? ? CI->getOperand(3), 1, B, TD); > + ? ? ? ? ? ? ? CI->getOperand(3), 1, false, B, TD); > ? ? return CI->getOperand(1); > ? } > ?}; > @@ -615,7 +618,7 @@ > > ? ? // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) > ? ? EmitMemMove(CI->getOperand(1), CI->getOperand(2), > - ? ? ? ? ? ? ? ?CI->getOperand(3), 1, B, TD); > + ? ? ? ? ? ? ? ?CI->getOperand(3), 1, false, B, TD); > ? ? return CI->getOperand(1); > ? } > ?}; > @@ -637,8 +640,8 @@ > > ? ? // memset(p, v, n) -> llvm.memset(p, v, n, 1) > ? ? Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false); > - ? ?EmitMemSet(CI->getOperand(1), Val, ?CI->getOperand(3), B, TD); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? false); > + ? ?EmitMemSet(CI->getOperand(1), Val, ?CI->getOperand(3), false, B, TD); > ? ? return CI->getOperand(1); > ? } > ?}; > @@ -999,7 +1002,7 @@ > ? ? ? // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) > ? ? ? EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. > ? ? ? ? ? ? ? ? ?ConstantInt::get(TD->getIntPtrType(*Context), > - ? ? ? ? ? ? ? ? FormatStr.size()+1), 1, B, TD); > + ? ? ? ? ? ? ? ? FormatStr.size()+1), 1, false, B, TD); > ? ? ? return ConstantInt::get(CI->getType(), FormatStr.size()); > ? ? } > > @@ -1013,11 +1016,11 @@ > ? ? ? // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 > ? ? ? if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; > ? ? ? Value *V = B.CreateTrunc(CI->getOperand(3), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt8Ty(*Context), "char"); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Type::getInt8Ty(*Context), "char"); > ? ? ? Value *Ptr = CastToCStr(CI->getOperand(1), B); > ? ? ? B.CreateStore(V, Ptr); > ? ? ? Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), > - ? ? ? ? ? ? ? ? ? ? ? "nul"); > + ? ? ? ? ? ? ? ? ? ? ? ?"nul"); > ? ? ? B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); > > ? ? ? return ConstantInt::get(CI->getType(), 1); > @@ -1034,7 +1037,7 @@ > ? ? ? Value *IncLen = B.CreateAdd(Len, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ConstantInt::get(Len->getType(), 1), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "leninc"); > - ? ? ?EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); > + ? ? ?EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); > > ? ? ? // The sprintf result is the unincremented number of bytes in the string. > ? ? ? return B.CreateIntCast(Len, CI->getType(), false); > > Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Tue Mar 30 15:55:56 2010 > @@ -109,15 +109,16 @@ > > ?/// EmitMemCpy - Emit a call to the memcpy function to the builder. ?This always > ?/// expects that Len has type 'intptr_t' and Dst/Src are pointers. > -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, > - ? ? ? ? ? ? ? ? ? ? ? ?unsigned Align, IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ?bool isVolatile, IRBuilder<> &B, const TargetData *TD) { > ? Module *M = B.GetInsertBlock()->getParent()->getParent(); > - ?const Type *Ty = Len->getType(); > - ?Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); > + ?const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; > + ?Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); > ? Dst = CastToCStr(Dst, B); > ? Src = CastToCStr(Src, B); > - ?return B.CreateCall4(MemCpy, Dst, Src, Len, > - ? ? ? ? ? ? ? ? ? ? ? ConstantInt::get(B.getInt32Ty(), Align)); > + ?return B.CreateCall5(MemCpy, Dst, Src, Len, > + ? ? ? ? ? ? ? ? ? ? ? ConstantInt::get(B.getInt32Ty(), Align), > + ? ? ? ? ? ? ? ? ? ? ? ConstantInt::get(B.getInt1Ty(), isVolatile)); > ?} > > ?/// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. > @@ -146,16 +147,18 @@ > > ?/// EmitMemMove - Emit a call to the memmove function to the builder. ?This > ?/// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, > - ? ? ? ? ? ? ? ? ? ? ? ? unsigned Align, IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, > + ? ? ? ? ? ? ? ? ? ? ? ? bool isVolatile, IRBuilder<> &B, const TargetData *TD) { > ? Module *M = B.GetInsertBlock()->getParent()->getParent(); > ? LLVMContext &Context = B.GetInsertBlock()->getContext(); > - ?const Type *Ty = TD->getIntPtrType(Context); > - ?Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); > + ?const Type *ArgTys[3] = { Dst->getType(), Src->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ?TD->getIntPtrType(Context) }; > + ?Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); > ? Dst = CastToCStr(Dst, B); > ? Src = CastToCStr(Src, B); > ? Value *A = ConstantInt::get(B.getInt32Ty(), Align); > - ?return B.CreateCall4(MemMove, Dst, Src, Len, A); > + ?Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); > + ?return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); > ?} > > ?/// EmitMemChr - Emit a call to the memchr function. ?This assumes that Ptr is > @@ -206,15 +209,15 @@ > ?} > > ?/// EmitMemSet - Emit a call to the memset function > -Value *llvm::EmitMemSet(Value *Dst, Value *Val, > - ? ? ? ? ? ? ? ? ? ? ? ?Value *Len, IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, > + ? ? ? ? ? ? ? ? ? ? ? ?IRBuilder<> &B, const TargetData *TD) { > ?Module *M = B.GetInsertBlock()->getParent()->getParent(); > ?Intrinsic::ID IID = Intrinsic::memset; > - const Type *Tys[1]; > - Tys[0] = Len->getType(); > - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); > + const Type *Tys[2] = { Dst->getType(), Len->getType() }; > + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); > ?Value *Align = ConstantInt::get(B.getInt32Ty(), 1); > - return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); > + Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); > + return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); > ?} > > ?/// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. > @@ -381,7 +384,7 @@ > ? if (Name == "__memcpy_chk") { > ? ? if (isFoldable(4, 3, false)) { > ? ? ? EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), > - ? ? ? ? ? ? ? ? 1, B, TD); > + ? ? ? ? ? ? ? ? 1, false, B, TD); > ? ? ? replaceCall(CI->getOperand(1)); > ? ? ? return true; > ? ? } > @@ -396,7 +399,7 @@ > ? if (Name == "__memmove_chk") { > ? ? if (isFoldable(4, 3, false)) { > ? ? ? EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), > - ? ? ? ? ? ? ? ? ?1, B, TD); > + ? ? ? ? ? ? ? ? ?1, false, B, TD); > ? ? ? replaceCall(CI->getOperand(1)); > ? ? ? return true; > ? ? } > @@ -407,7 +410,7 @@ > ? ? if (isFoldable(4, 3, false)) { > ? ? ? Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?false); > - ? ? ?EmitMemSet(CI->getOperand(1), Val, ?CI->getOperand(3), B, TD); > + ? ? ?EmitMemSet(CI->getOperand(1), Val, ?CI->getOperand(3), false, B, TD); > ? ? ? replaceCall(CI->getOperand(1)); > ? ? ? return true; > ? ? } > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Tue Mar 30 15:55:56 2010 > @@ -297,10 +297,10 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? I->getName(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &*Caller->begin()->begin()); > ? ? ? ? // Emit a memcpy. > - ? ? ? ?const Type *Tys[] = { Type::getInt64Ty(Context) }; > + ? ? ? ?const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > ? ? ? ? Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::memcpy, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Tys, 1); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Tys, 3); > ? ? ? ? Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); > ? ? ? ? Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); > > @@ -309,17 +309,18 @@ > ? ? ? ? ? Size = ConstantExpr::getSizeOf(AggTy); > ? ? ? ? else > ? ? ? ? ? Size = ConstantInt::get(Type::getInt64Ty(Context), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TD->getTypeStoreSize(AggTy)); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?TD->getTypeStoreSize(AggTy)); > > ? ? ? ? // Always generate a memcpy of alignment 1 here because we don't know > ? ? ? ? // the alignment of the src pointer. ?Other optimizations can infer > ? ? ? ? // better alignment. > ? ? ? ? Value *CallArgs[] = { > ? ? ? ? ? DestCast, SrcCast, Size, > - ? ? ? ? ?ConstantInt::get(Type::getInt32Ty(Context), 1) > + ? ? ? ? ?ConstantInt::get(Type::getInt32Ty(Context), 1), > + ? ? ? ? ?ConstantInt::get(Type::getInt1Ty(Context), 0) > ? ? ? ? }; > ? ? ? ? CallInst *TheMemCpy = > - ? ? ? ? ?CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); > + ? ? ? ? ?CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); > > ? ? ? ? // If we have a call graph, update it. > ? ? ? ? if (CG) { > > Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) > +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Mar 30 15:55:56 2010 > @@ -145,6 +145,54 @@ > ? ? } > ? ? break; > > + ?case 'm': { > + ? ?// This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the > + ? ?// new format that allows overloading the pointer for different address > + ? ?// space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) > + ? ?const char* NewFnName = NULL; > + ? ?if (Name.compare(5,8,"memcpy.i",8) == 0) { > + ? ? ?if (Name[13] == '8') > + ? ? ? ?NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; > + ? ? ?else if (Name.compare(13,2,"16") == 0) > + ? ? ? ?NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; > + ? ? ?else if (Name.compare(13,2,"32") == 0) > + ? ? ? ?NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; > + ? ? ?else if (Name.compare(13,2,"64") == 0) > + ? ? ? ?NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; > + ? ?} else if (Name.compare(5,9,"memmove.i",9) == 0) { > + ? ? ?if (Name[14] == '8') > + ? ? ? ?NewFnName = "llvm.memmove.p0i8.p0i8.i8"; > + ? ? ?else if (Name.compare(14,2,"16") == 0) > + ? ? ? ?NewFnName = "llvm.memmove.p0i8.p0i8.i16"; > + ? ? ?else if (Name.compare(14,2,"32") == 0) > + ? ? ? ?NewFnName = "llvm.memmove.p0i8.p0i8.i32"; > + ? ? ?else if (Name.compare(14,2,"64") == 0) > + ? ? ? ?NewFnName = "llvm.memmove.p0i8.p0i8.i64"; > + ? ?} > + ? ?else if (Name.compare(5,8,"memset.i",8) == 0) { > + ? ? ?if (Name[13] == '8') > + ? ? ? ?NewFnName = "llvm.memset.p0i8.i8"; > + ? ? ?else if (Name.compare(13,2,"16") == 0) > + ? ? ? ?NewFnName = "llvm.memset.p0i8.i16"; > + ? ? ?else if (Name.compare(13,2,"32") == 0) > + ? ? ? ?NewFnName = "llvm.memset.p0i8.i32"; > + ? ? ?else if (Name.compare(13,2,"64") == 0) > + ? ? ? ?NewFnName = "llvm.memset.p0i8.i64"; > + ? ?} > + ? ?if (NewFnName) { > + ? ? ?const FunctionType *FTy = F->getFunctionType(); > + ? ? ?NewFn = cast(M->getOrInsertFunction(NewFnName, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FTy->getReturnType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FTy->getParamType(0), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FTy->getParamType(1), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FTy->getParamType(2), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?FTy->getParamType(3), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt1Ty(F->getContext()), > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(Type *)0)); > + ? ? ?return true; > + ? ?} > + ? ?break; > + ?} > ? case 'p': > ? ? // ?This upgrades the llvm.part.select overloaded intrinsic names to only > ? ? // ?use one type specifier in the name. We only care about the old format > @@ -472,6 +520,28 @@ > ? ? CI->eraseFromParent(); > ? } > ? break; > + ?case Intrinsic::memcpy: > + ?case Intrinsic::memmove: > + ?case Intrinsic::memset: { > + ? ?// Add isVolatile > + ? ?const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); > + ? ?Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), > + ? ? ? ? ? ? ? ? ? ? ? ? ? CI->getOperand(3), CI->getOperand(4), > + ? ? ? ? ? ? ? ? ? ? ? ? ? llvm::ConstantInt::get(I1Ty, 0) }; > + ? ?CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI->getName(), CI); > + ? ?NewCI->setTailCall(CI->isTailCall()); > + ? ?NewCI->setCallingConv(CI->getCallingConv()); > + ? ?// ?Handle any uses of the old CallInst. > + ? ?if (!CI->use_empty()) > + ? ? ?// ?Replace all uses of the old call with the new cast which has the > + ? ? ?// ?correct type. > + ? ? ?CI->replaceAllUsesWith(NewCI); > + > + ? ?// ?Clean up the old call now that it has been completely upgraded. > + ? ?CI->eraseFromParent(); > + ? ?break; > + ?} > ? } > ?} > > > Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) > +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Tue Mar 30 15:55:56 2010 > @@ -103,7 +103,7 @@ > ? ret i32 %sub > ?; CHECK: @test4 > ?; CHECK: load i32* @G > -; CHECK: memset.i32 > +; CHECK: memset.p0i8.i32 > ?; CHECK-NOT: load > ?; CHECK: sub i32 %tmp, %tmp > ?} > @@ -118,7 +118,7 @@ > ? ret i32 %sub > ?; CHECK: @test5 > ?; CHECK: load i32* @G > -; CHECK: memcpy.i32 > +; CHECK: memcpy.p0i8.p0i8.i32 > ?; CHECK-NOT: load > ?; CHECK: sub i32 %tmp, %tmp > ?} > > Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Tue Mar 30 15:55:56 2010 > @@ -7,7 +7,7 @@ > > ?define i32 @t() nounwind ssp { > ?; CHECK: @t > -; CHECK: @llvm.memset.i64 > +; CHECK: @llvm.memset.p0i8.i64 > ?entry: > ? %0 = alloca %struct.data, align 8 ? ? ? ? ? ? ? ; <%struct.data*> [#uses=1] > ? %1 = bitcast %struct.data* %0 to i8* ? ? ? ? ? ?; [#uses=1] > > Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Tue Mar 30 15:55:56 2010 > @@ -113,7 +113,7 @@ > ? %1 = bitcast %struct.data* %0 to i8* > ? %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind > ?; CHECK-NOT: @llvm.objectsize > -; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) > +; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) > ? %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind > ? ret i32 0 > ?} > @@ -128,7 +128,7 @@ > ? %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) > ? %2 = load i8** @s, align 8 > ?; CHECK-NOT: @llvm.objectsize > -; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) > +; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) > ? %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind > ? ret void > ?} > > Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) > +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Tue Mar 30 15:55:56 2010 > @@ -4,7 +4,7 @@ > ?; The resulting memset is only 4-byte aligned, despite containing > ?; a 16-byte alignmed store in the middle. > > -; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) > +; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) > > ?define void @foo(i32* %p) { > ? %a0 = getelementptr i32* %p, i64 0 > > Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) > +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Tue Mar 30 15:55:56 2010 > @@ -21,7 +21,7 @@ > ? %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 > ? %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 > ? %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) > -; CHECK: @llvm.memcpy.i32 > +; CHECK: @llvm.memcpy.p0i8.p0i8.i32 > ? ret i32 0 > ?} > > > Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=99928&r1=99927&r2=99928&view=diff > ============================================================================== > --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) > +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Tue Mar 30 15:55:56 2010 > @@ -1,7 +1,7 @@ > ?; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} > ?; PR1047 > > -define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { > +define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { > ?entry: > ? ? ? ?ret void > ?} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stoklund at 2pi.dk Tue Mar 30 18:12:48 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 23:12:48 -0000 Subject: [llvm-commits] [llvm] r99959 - in /llvm/trunk/test/CodeGen/X86: dagcombine-buildvector.ll sse-align-12.ll Message-ID: <20100330231248.357E62A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 18:12:48 2010 New Revision: 99959 URL: http://llvm.org/viewvc/llvm-project?rev=99959&view=rev Log: Not all platforms start symbols with _ Modified: llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll llvm/trunk/test/CodeGen/X86/sse-align-12.ll Modified: llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll?rev=99959&r1=99958&r2=99959&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll (original) +++ llvm/trunk/test/CodeGen/X86/dagcombine-buildvector.ll Tue Mar 30 18:12:48 2010 @@ -3,7 +3,7 @@ ; Shows a dag combine bug that will generate an illegal build vector ; with v2i64 build_vector i32, i32. -; CHECK: _test: +; CHECK: test: ; CHECK: unpcklpd ; CHECK: movapd define void @test(<2 x double>* %dst, <4 x double> %src) nounwind { @@ -13,7 +13,7 @@ ret void } -; CHECK: _test2: +; CHECK: test2: ; CHECK: movdqa define void @test2(<4 x i16>* %src, <4 x i32>* %dest) nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/sse-align-12.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sse-align-12.ll?rev=99959&r1=99958&r2=99959&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sse-align-12.ll (original) +++ llvm/trunk/test/CodeGen/X86/sse-align-12.ll Tue Mar 30 18:12:48 2010 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=x86-64 | FileCheck %s -; CHECK: _a: +; CHECK: a: ; CHECK: movdqu ; CHECK: pshufd define <4 x float> @a(<4 x float>* %y) nounwind { @@ -16,7 +16,7 @@ ret <4 x float> %s } -; CHECK: _b: +; CHECK: b: ; CHECK: movups ; CHECK: unpckhps define <4 x float> @b(<4 x float>* %y, <4 x float> %z) nounwind { @@ -32,7 +32,7 @@ ret <4 x float> %s } -; CHECK: _c: +; CHECK: c: ; CHECK: movupd ; CHECK: shufpd define <2 x double> @c(<2 x double>* %y) nounwind { @@ -44,7 +44,7 @@ ret <2 x double> %r } -; CHECK: _d: +; CHECK: d: ; CHECK: movupd ; CHECK: unpckhpd define <2 x double> @d(<2 x double>* %y, <2 x double> %z) nounwind { From stoklund at 2pi.dk Tue Mar 30 18:16:34 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 16:16:34 -0700 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td In-Reply-To: References: <20100330224656.01CC02A6C12D@llvm.org> <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> Message-ID: On Mar 30, 2010, at 3:57 PM, Jakob Stoklund Olesen wrote: > > On Mar 30, 2010, at 3:50 PM, Chris Lattner wrote: > >> >> On Mar 30, 2010, at 3:46 PM, Jakob Stoklund Olesen wrote: >> >>> Author: stoklund >>> Date: Tue Mar 30 17:46:55 2010 >>> New Revision: 99953 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev >>> Log: >>> V_SETALLONES is an integer instruction. >>> >>> Since it is just a pxor in disguise, we should probably expand it to a full >>> polymorphic triple. >> >> Couldn't V_SETALLONES be implementated in all domains to avoid a domain crossing? > > Yes, and so can V_SET0. On second thought, no it can't. V_SETALLONES is implemented as pcmpeqd, and the corresponding floating-point operation would be cmpeqps/cmpeqpd. But that does not produce all ones if the register happens to contain a NaN! I don't think that V_SETALLONES is useful for floating-point anyway? V_SET0 is easy to do. It is implemented with xorps. From gohman at apple.com Tue Mar 30 18:46:29 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 30 Mar 2010 16:46:29 -0700 Subject: [llvm-commits] [PATCH] Configurable CallSiteBase In-Reply-To: <47B9B926-8241-4C18-8F5C-FD2B2DCD56DA@mac.com> References: <4BB1C5BD.7090204@mac.com> <45FDEBC5-75A2-49F9-A1DE-72F8BD198F98@apple.com> <47B9B926-8241-4C18-8F5C-FD2B2DCD56DA@mac.com> Message-ID: <44367D71-431A-4DB8-BA7C-2710EC55BE9E@apple.com> On Mar 30, 2010, at 3:49 PM, Gabor Greif wrote: > Am 30.03.2010 um 21:44 schrieb Dan Gohman: > >> >> On Mar 30, 2010, at 2:34 AM, Gabor Greif wrote: >>> >>> CallSiteBase now provides three convenience features (some of >>> them are inherited by CallSite too) : >>> - operator bool: this conversion allows to check whether we have >>> a proper call site. Allows to eliminate an indentation level of >>> "if" statements. >>> - operator ->: gives back the payload as an instruction (InstrTy*) >>> - constructor from ValueTy: this may supplant the static "get" >>> method in the future (ATM it is implementer in terms of "get"). >>> Anyway, this constructor can be used in "if" statements to >>> get rid of a free-standing wide-scope local binding. >> >> Another way to provide this functionality would be to redo the CallSite >> abstraction as a pseudo-class, following the IntrinsicInst.h example. >> That way, it could use dyn_cast like everything else instead of its >> own syntax. >> >> For example, something like this: >> >> class CallSite : public User { >> CallSite(); // DO NOT IMPLEMENT >> CallSite(const CallSite &); // DO NOT IMPLEMENT >> void operator=(const CallSite &); // DO NOT IMPLEMENT >> public: >> // ... >> >> // Methods for support type inquiry through isa, cast, and dyn_cast: >> static inline bool classof(const CallSite *) { return true; } >> static inline bool classof(const CallInst *I) { return true; } >> static inline bool classof(const InvokeInst *I) { return true; } >> static inline bool classof(const Value *V) { >> return isa(V) || isa(V); >> } >> }; > > Hmmm, CallSite is supposed to have the weight of a pointer, and the above > is rather heavy, certainly not "value semantics". I do not like the idea. It isn't actually heavy. This kind of CallSite would be passed around by pointer rather than by value, so it would still have the weight of a pointer. Typical use would be like this: if (CallSite *CS = dyn_cast(V)) { doStuffWith(CS); } Dan From dalej at apple.com Tue Mar 30 18:53:28 2010 From: dalej at apple.com (Dale Johannesen) Date: Tue, 30 Mar 2010 23:53:28 -0000 Subject: [llvm-commits] [test-suite] r99961 - /test-suite/trunk/TEST.optllcdbg.Makefile Message-ID: <20100330235328.3A0022A6C12C@llvm.org> Author: johannes Date: Tue Mar 30 18:53:28 2010 New Revision: 99961 URL: http://llvm.org/viewvc/llvm-project?rev=99961&view=rev Log: Next phase of testing optimization + debug info. opt is run with -std-compile-opts and llc with -O3, modulo user overrides. Full speed ahead! Added: test-suite/trunk/TEST.optllcdbg.Makefile Added: test-suite/trunk/TEST.optllcdbg.Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.optllcdbg.Makefile?rev=99961&view=auto ============================================================================== --- test-suite/trunk/TEST.optllcdbg.Makefile (added) +++ test-suite/trunk/TEST.optllcdbg.Makefile Tue Mar 30 18:53:28 2010 @@ -0,0 +1,55 @@ +##===- TEST.llcdbg.Makefile --------------------------------*- Makefile -*-===## +# +# This test checks whether presence of debug declarations influences +# the code generator or not. +# +# If input.bc includes llvm.dbg intrinsics and llvm.dbg variables then +# the code in first.s and second.s should match. Otherwise debugging information +# is influencing the code generator. The Dwarf info in first.s and second.s is +# normally quite different, so the data directives that appear in Dwarf are +# stripped out before comparison. +# +# This has only been used on Darwin; the data directives to strip and grep magic +# might be different elsewhere. +# +##===----------------------------------------------------------------------===## + +TESTNAME = $* +TARGET_FLAGS = -g -O0 +LLC_DEBUG_FLAGS = -O3 +OPT_FLAGS = -std-compile-opts +.PRECIOUS: Output/%.first.s Output/%.second.s Output/%.t2c.s Output/%.t1c.s Output/%.t2b.bc Output/%.t1b.bc + +$(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ +test.$(TEST).%: Output/%.diff + +Output/%.t1a.bc: Output/%.linked.rbc Output/.dir $(LOPT) + $(LOPT) -strip-debug-declare -strip-nondebug $< -f -o $@ + +Output/%.t1b.bc: Output/%.t1a.bc Output/.dir $(LOPT) + $(LOPT) $(OPT_FLAGS) $< -f -o $@ + +Output/%.t1c.s: Output/%.t1b.bc Output/.dir $(LLC) + $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ + +Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC) + grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@ + +Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT) + $(LOPT) -strip-nondebug $< -f -o $@ + +Output/%.t2b.bc: Output/%.t2a.bc Output/.dir $(LOPT) + $(LOPT) $(OPT_FLAGS) $< -f -o $@ + +Output/%.t2c.s: Output/%.t2b.bc Output/.dir $(LLC) + $(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@ + +Output/%.second.s: Output/%.t2c.s Output/.dir + grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@ + +Output/%.diff: Output/%.first.s Output/%.second.s + @-if diff $^ > $@; then \ + echo "--------- TEST-PASS: $*"; \ + else \ + echo "--------- TEST-FAIL: $*"; \ + fi From sherpya at netfarm.it Tue Mar 30 16:07:32 2010 From: sherpya at netfarm.it (Gianluigi Tiesi) Date: Tue, 30 Mar 2010 23:07:32 +0200 Subject: [llvm-commits] [patch] win32 - fix deadlock on ctrl + c handler when sys::AddSignalHandler is invoked Message-ID: <4BB26814.90101@netfarm.it> Hi, signal handling on win32 has a problem, the function sys::AddSignalHandler calls RegisterHandler() but then does not releases the critical section as stated in the function. So if the program calls the function and the user press ctrl c, the program will not able to exit Regards -- Gianluigi Tiesi EDP Project Leader Netfarm S.r.l. - http://www.netfarm.it/ Free Software: http://oss.netfarm.it/ -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ctrl_c_handler.diff Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100330/31d85b47/attachment.pl From stoklund at 2pi.dk Tue Mar 30 19:40:13 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 31 Mar 2010 00:40:13 -0000 Subject: [llvm-commits] [llvm] r99975 - in /llvm/trunk: lib/Target/X86/AsmPrinter/X86MCInstLower.cpp lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/vec_return.ll test/CodeGen/X86/vec_shuffle-7.ll test/CodeGen/X86/vec_shuffle-9.ll test/CodeGen/X86/vec_zero.ll test/CodeGen/X86/vec_zero_cse.ll test/CodeGen/X86/xor.ll Message-ID: <20100331004013.A36FD2A6C12D@llvm.org> Author: stoklund Date: Tue Mar 30 19:40:13 2010 New Revision: 99975 URL: http://llvm.org/viewvc/llvm-project?rev=99975&view=rev Log: Replace V_SET0 with variants for each SSE execution domain. Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/CodeGen/X86/vec_return.ll llvm/trunk/test/CodeGen/X86/vec_shuffle-7.ll llvm/trunk/test/CodeGen/X86/vec_shuffle-9.ll llvm/trunk/test/CodeGen/X86/vec_zero.ll llvm/trunk/test/CodeGen/X86/vec_zero_cse.ll llvm/trunk/test/CodeGen/X86/xor.ll Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Tue Mar 30 19:40:13 2010 @@ -287,7 +287,9 @@ LowerUnaryToTwoAddr(OutMI, X86::MMX_PCMPEQDrr); break; case X86::FsFLD0SS: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; case X86::FsFLD0SD: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; - case X86::V_SET0: LowerUnaryToTwoAddr(OutMI, X86::XORPSrr); break; + case X86::V_SET0PS: LowerUnaryToTwoAddr(OutMI, X86::XORPSrr); break; + case X86::V_SET0PD: LowerUnaryToTwoAddr(OutMI, X86::XORPDrr); break; + case X86::V_SET0PI: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; case X86::V_SETALLONES: LowerUnaryToTwoAddr(OutMI, X86::PCMPEQDrr); break; case X86::MOV16r0: Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Mar 30 19:40:13 2010 @@ -2514,7 +2514,9 @@ Alignment = (*LoadMI->memoperands_begin())->getAlignment(); else switch (LoadMI->getOpcode()) { - case X86::V_SET0: + case X86::V_SET0PS: + case X86::V_SET0PD: + case X86::V_SET0PI: case X86::V_SETALLONES: Alignment = 16; break; @@ -2544,11 +2546,13 @@ SmallVector MOs; switch (LoadMI->getOpcode()) { - case X86::V_SET0: + case X86::V_SET0PS: + case X86::V_SET0PD: + case X86::V_SET0PI: case X86::V_SETALLONES: case X86::FsFLD0SD: case X86::FsFLD0SS: { - // Folding a V_SET0 or V_SETALLONES as a load, to ease register pressure. + // Folding a V_SET0P? or V_SETALLONES as a load, to ease register pressure. // Create a constant-pool entry and operands to load from it. // Medium and large mode can't fold loads this way. @@ -3675,6 +3679,7 @@ { X86::ANDPSrr, X86::ANDPDrr, X86::PANDrr }, { X86::ORPSrm, X86::ORPDrm, X86::PORrm }, { X86::ORPSrr, X86::ORPDrr, X86::PORrr }, + { X86::V_SET0PS, X86::V_SET0PD, X86::V_SET0PI }, { X86::XORPSrm, X86::XORPDrm, X86::PXORrm }, { X86::XORPSrr, X86::XORPDrr, X86::PXORrr }, }; Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Mar 30 19:40:13 2010 @@ -1115,15 +1115,19 @@ // load of an all-zeros value if folding it would be beneficial. // FIXME: Change encoding to pseudo! let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isCodeGenOnly = 1 in -def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + isCodeGenOnly = 1 in { +def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>; +def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>; +let ExeDomain = SSEPackedInt in +def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", [(set VR128:$dst, (v4i32 immAllZerosV))]>; +} -def : Pat<(v2i64 immAllZerosV), (V_SET0)>; -def : Pat<(v8i16 immAllZerosV), (V_SET0)>; -def : Pat<(v16i8 immAllZerosV), (V_SET0)>; -def : Pat<(v2f64 immAllZerosV), (V_SET0)>; -def : Pat<(v4f32 immAllZerosV), (V_SET0)>; +def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>; +def : Pat<(v8i16 immAllZerosV), (V_SET0PI)>; +def : Pat<(v16i8 immAllZerosV), (V_SET0PI)>; def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))), (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss))>; @@ -3026,14 +3030,14 @@ let AddedComplexity = 15 in { // Zeroing a VR128 then do a MOVS{S|D} to the lower bits. def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))), - (MOVSDrr (v2f64 (V_SET0)), FR64:$src)>; + (MOVSDrr (v2f64 (V_SET0PS)), FR64:$src)>; def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))), - (MOVSSrr (v4f32 (V_SET0)), FR32:$src)>; + (MOVSSrr (v4f32 (V_SET0PS)), FR32:$src)>; def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))), - (MOVSSrr (v4f32 (V_SET0)), + (MOVSSrr (v4f32 (V_SET0PS)), (f32 (EXTRACT_SUBREG (v4f32 VR128:$src), x86_subreg_ss)))>; def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))), - (MOVSSrr (v4i32 (V_SET0)), + (MOVSSrr (v4i32 (V_SET0PI)), (EXTRACT_SUBREG (v4i32 VR128:$src), x86_subreg_ss))>; } Modified: llvm/trunk/test/CodeGen/X86/vec_return.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_return.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_return.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_return.ll Tue Mar 30 19:40:13 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 > %t -; RUN: grep xorps %t | count 1 +; RUN: grep pxor %t | count 1 ; RUN: grep movaps %t | count 1 ; RUN: not grep shuf %t Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-7.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-7.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-7.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-7.ll Tue Mar 30 19:40:13 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 -o %t -; RUN: grep xorps %t | count 1 +; RUN: grep pxor %t | count 1 ; RUN: not grep shufps %t define void @test() { Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-9.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-9.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-9.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-9.ll Tue Mar 30 19:40:13 2010 @@ -1,7 +1,7 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s define <4 x i32> @test(i8** %ptr) { -; CHECK: xorps +; CHECK: pxor ; CHECK: punpcklbw ; CHECK: punpcklwd Modified: llvm/trunk/test/CodeGen/X86/vec_zero.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_zero.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_zero.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_zero.ll Tue Mar 30 19:40:13 2010 @@ -1,5 +1,6 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2 | grep xorps | count 2 +; RUN: llc < %s -march=x86 -mattr=+sse2 | FileCheck %s +; CHECK: xorps define void @foo(<4 x float>* %P) { %T = load <4 x float>* %P ; <<4 x float>> [#uses=1] %S = fadd <4 x float> zeroinitializer, %T ; <<4 x float>> [#uses=1] @@ -7,6 +8,7 @@ ret void } +; CHECK: pxor define void @bar(<4 x i32>* %P) { %T = load <4 x i32>* %P ; <<4 x i32>> [#uses=1] %S = add <4 x i32> zeroinitializer, %T ; <<4 x i32>> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/vec_zero_cse.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_zero_cse.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_zero_cse.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_zero_cse.ll Tue Mar 30 19:40:13 2010 @@ -1,5 +1,4 @@ -; RUN: llc < %s -relocation-model=static -march=x86 -mcpu=yonah | grep pxor | count 1 -; RUN: llc < %s -relocation-model=static -march=x86 -mcpu=yonah | grep xorps | count 1 +; RUN: llc < %s -relocation-model=static -march=x86 -mcpu=yonah | grep pxor | count 2 ; RUN: llc < %s -relocation-model=static -march=x86 -mcpu=yonah | grep pcmpeqd | count 2 @M1 = external global <1 x i64> Modified: llvm/trunk/test/CodeGen/X86/xor.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor.ll?rev=99975&r1=99974&r2=99975&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/xor.ll (original) +++ llvm/trunk/test/CodeGen/X86/xor.ll Tue Mar 30 19:40:13 2010 @@ -7,7 +7,7 @@ ret <4 x i32> %tmp ; X32: test1: -; X32: xorps %xmm0, %xmm0 +; X32: pxor %xmm0, %xmm0 ; X32: ret } From stoklund at 2pi.dk Tue Mar 30 19:40:08 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 31 Mar 2010 00:40:08 -0000 Subject: [llvm-commits] [llvm] r99974 - in /llvm/trunk: lib/Target/X86/SSEDomainFix.cpp test/CodeGen/X86/widen_arith-5.ll Message-ID: <20100331004008.5EDDF2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 30 19:40:08 2010 New Revision: 99974 URL: http://llvm.org/viewvc/llvm-project?rev=99974&view=rev Log: Fix typo. Thank you, valgrind. Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp llvm/trunk/test/CodeGen/X86/widen_arith-5.ll Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=99974&r1=99973&r2=99974&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original) +++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Tue Mar 30 19:40:08 2010 @@ -280,7 +280,7 @@ if (rx < 0) continue; for (MachineBasicBlock::const_pred_iterator pi = MBB->pred_begin(), pe = MBB->pred_end(); pi != pe; ++pi) { - LiveOutMap::const_iterator fi = LiveOuts.find(*pe); + LiveOutMap::const_iterator fi = LiveOuts.find(*pi); if (fi == LiveOuts.end()) continue; DomainValue *pdv = fi->second[rx]; if (!pdv) continue; Modified: llvm/trunk/test/CodeGen/X86/widen_arith-5.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/widen_arith-5.ll?rev=99974&r1=99973&r2=99974&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/widen_arith-5.ll (original) +++ llvm/trunk/test/CodeGen/X86/widen_arith-5.ll Tue Mar 30 19:40:08 2010 @@ -1,5 +1,5 @@ ; RUN: llc < %s -march=x86-64 -mattr=+sse42 -disable-mmx | FileCheck %s -; CHECK: movaps +; CHECK: movdqa ; CHECK: pmulld ; CHECK: psubd From daniel at zuster.org Tue Mar 30 19:57:26 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 30 Mar 2010 17:57:26 -0700 Subject: [llvm-commits] [llvm] r99895 - /llvm/trunk/lib/CodeGen/LiveInterval.cpp In-Reply-To: <20100330175742.5E9282A6C12C@llvm.org> References: <20100330175742.5E9282A6C12C@llvm.org> Message-ID: Hey Lang, Not sure if you are still poking at this code, but each of these edits is in four copies of the same code -- shouldn't it be factored out? - Daniel On Tue, Mar 30, 2010 at 10:57 AM, Daniel Dunbar wrote: > Author: ddunbar > Date: Tue Mar 30 12:57:42 2010 > New Revision: 99895 > > URL: http://llvm.org/viewvc/llvm-project?rev=99895&view=rev > Log: > Fix -Asserts warning. > > Modified: > ? ?llvm/trunk/lib/CodeGen/LiveInterval.cpp > > Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=99895&r1=99894&r2=99895&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) > +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Tue Mar 30 12:57:42 2010 > @@ -303,7 +303,6 @@ > ? ? ? ? ? // otherwise mark it as ~1U so it can be nuked later. > ? ? ? ? ? if (ValNo->id == getNumValNums()-1) { > ? ? ? ? ? ? do { > - ? ? ? ? ? ? ?VNInfo *VNI = valnos.back(); > ? ? ? ? ? ? ? valnos.pop_back(); > ? ? ? ? ? ? } while (!valnos.empty() && valnos.back()->isUnused()); > ? ? ? ? ? } else { > @@ -350,7 +349,6 @@ > ? // otherwise mark it as ~1U so it can be nuked later. > ? if (ValNo->id == getNumValNums()-1) { > ? ? do { > - ? ? ?VNInfo *VNI = valnos.back(); > ? ? ? valnos.pop_back(); > ? ? } while (!valnos.empty() && valnos.back()->isUnused()); > ? } else { > @@ -577,7 +575,6 @@ > ? ? ? ? // mark it as ~1U so it can be nuked later. > ? ? ? ? if (V1->id == getNumValNums()-1) { > ? ? ? ? ? do { > - ? ? ? ? ? ?VNInfo *VNI = valnos.back(); > ? ? ? ? ? ? valnos.pop_back(); > ? ? ? ? ? } while (!valnos.empty() && valnos.back()->isUnused()); > ? ? ? ? } else { > @@ -745,7 +742,6 @@ > ? // ~1U so it can be nuked later. > ? if (V1->id == getNumValNums()-1) { > ? ? do { > - ? ? ?VNInfo *VNI = valnos.back(); > ? ? ? valnos.pop_back(); > ? ? } while (valnos.back()->isUnused()); > ? } else { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From sabre at nondot.org Tue Mar 30 22:34:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 03:34:40 -0000 Subject: [llvm-commits] [llvm] r99982 - in /llvm/trunk: include/llvm/Instruction.h include/llvm/Support/ValueHandle.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/SelectionDAG/FastISel.cpp lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/VMCore/Metadata.cpp Message-ID: <20100331033440.5D44B2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 22:34:40 2010 New Revision: 99982 URL: http://llvm.org/viewvc/llvm-project?rev=99982&view=rev Log: add new apis for getting/setting !dbg metadata on instructions. In addition to being a convenience, they are faster than the old apis, particularly when not going from an MDKindID like people should be doing. Modified: llvm/trunk/include/llvm/Instruction.h llvm/trunk/include/llvm/Support/ValueHandle.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Tue Mar 30 22:34:40 2010 @@ -156,6 +156,16 @@ void setMetadata(unsigned KindID, MDNode *Node); void setMetadata(const char *Kind, MDNode *Node); + /// setDbgMetadata - This is just an optimized helper function that is + /// equivalent to setMetadata("dbg", Node); + void setDbgMetadata(MDNode *Node); + + /// getDbgMetadata - This is just an optimized helper function that is + /// equivalent to calling getMetadata("dbg"). + MDNode *getDbgMetadata() const { + return DbgInfo; + } + private: /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side /// metadata hash. Modified: llvm/trunk/include/llvm/Support/ValueHandle.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ValueHandle.h?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ValueHandle.h (original) +++ llvm/trunk/include/llvm/Support/ValueHandle.h Tue Mar 30 22:34:40 2010 @@ -284,8 +284,7 @@ Value *VP = ValueHandleBase::getValPtr(); // Null is always ok. - if (!VP) - return; + if (!VP) return; // Check that this value is valid (i.e., it hasn't been deleted). We // explicitly delay this check until access to avoid requiring clients to be Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 30 22:34:40 2010 @@ -2014,7 +2014,8 @@ // FIXME : Lift this restriction. if (MInsn->getNumOperands() != 3) continue; - DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata())); + DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands() + - 1).getMetadata())); if (DV.getTag() == dwarf::DW_TAG_arg_variable) { // FIXME Handle inlined subroutine arguments. DbgVariable *ArgVar = new DbgVariable(DV, MInsn, NULL); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Mar 30 22:34:40 2010 @@ -340,10 +340,9 @@ StaticAllocaMap.find(AI); if (SI == StaticAllocaMap.end()) break; // VLAs. int FI = SI->second; - if (MMI) { - if (MDNode *Dbg = DI->getMetadata("dbg")) - MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); - } + if (MDNode *Dbg = DI->getDbgMetadata()) + MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); + // Building the map above is target independent. Generating DBG_VALUE // inline is target dependent; do this now. (void)TargetSelectInstruction(cast(I)); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Mar 30 22:34:40 2010 @@ -3800,7 +3800,7 @@ int FI = SI->second; if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getMetadata("dbg")) + if (MDNode *Dbg = DI.getDbgMetadata()) MMI->setVariableDbgInfo(Variable, FI, Dbg); return 0; } @@ -3852,7 +3852,7 @@ return 0; // VLAs. int FI = SI->second; if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getMetadata("dbg")) + if (MDNode *Dbg = DI.getDbgMetadata()) MMI->setVariableDbgInfo(Variable, FI, Dbg); return 0; } Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=99982&r1=99981&r2=99982&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Tue Mar 30 22:34:40 2010 @@ -424,6 +424,10 @@ return getMetadataImpl(getContext().getMDKindID(Kind)); } +void Instruction::setDbgMetadata(MDNode *Node) { + DbgInfo = Node; +} + /// setMetadata - Set the metadata of of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. From clattner at apple.com Tue Mar 30 22:56:40 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 20:56:40 -0700 Subject: [llvm-commits] [llvm] r99953 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td In-Reply-To: References: <20100330224656.01CC02A6C12D@llvm.org> <51C096DF-1DCF-492E-8608-1DBA61EECA5C@apple.com> Message-ID: <2BD8CDE7-6DDC-48EC-B306-EED3BD3EA0FB@apple.com> On Mar 30, 2010, at 4:16 PM, Jakob Stoklund Olesen wrote: > > On Mar 30, 2010, at 3:57 PM, Jakob Stoklund Olesen wrote: > >> >> On Mar 30, 2010, at 3:50 PM, Chris Lattner wrote: >> >>> >>> On Mar 30, 2010, at 3:46 PM, Jakob Stoklund Olesen wrote: >>> >>>> Author: stoklund >>>> Date: Tue Mar 30 17:46:55 2010 >>>> New Revision: 99953 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=99953&view=rev >>>> Log: >>>> V_SETALLONES is an integer instruction. >>>> >>>> Since it is just a pxor in disguise, we should probably expand it to a full >>>> polymorphic triple. >>> >>> Couldn't V_SETALLONES be implementated in all domains to avoid a domain crossing? >> >> Yes, and so can V_SET0. > > On second thought, no it can't. > > V_SETALLONES is implemented as pcmpeqd, and the corresponding floating-point operation would be cmpeqps/cmpeqpd. But that does not produce all ones if the register happens to contain a NaN! > > I don't think that V_SETALLONES is useful for floating-point anyway? > > V_SET0 is easy to do. It is implemented with xorps. Right, I was thinking more of the zero case than the all-ones case, thanks. -Chris From sabre at nondot.org Tue Mar 30 23:09:11 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 04:09:11 -0000 Subject: [llvm-commits] [llvm] r99984 - in /llvm/trunk: include/llvm/Support/IRBuilder.h lib/VMCore/IRBuilder.cpp Message-ID: <20100331040911.915942A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 23:09:11 2010 New Revision: 99984 URL: http://llvm.org/viewvc/llvm-project?rev=99984&view=rev Log: make irbuilder use the new optimized debug info accessors. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/VMCore/IRBuilder.cpp Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=99984&r1=99983&r2=99984&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Tue Mar 30 23:09:11 2010 @@ -40,7 +40,6 @@ /// IRBuilderBase - Common base class shared among various IRBuilders. class IRBuilderBase { - unsigned DbgMDKind; MDNode *CurDbgLocation; protected: BasicBlock *BB; @@ -49,7 +48,7 @@ public: IRBuilderBase(LLVMContext &context) - : DbgMDKind(0), CurDbgLocation(0), Context(context) { + : CurDbgLocation(0), Context(context) { ClearInsertionPoint(); } @@ -82,12 +81,20 @@ /// SetCurrentDebugLocation - Set location information used by debugging /// information. - void SetCurrentDebugLocation(MDNode *L); + void SetCurrentDebugLocation(MDNode *L) { + CurDbgLocation = L; + } + + /// SetCurrentDebugLocation - Set location information used by debugging + /// information. MDNode *getCurrentDebugLocation() const { return CurDbgLocation; } /// SetInstDebugLocation - If this builder has a current debug location, set /// it on the specified instruction. - void SetInstDebugLocation(Instruction *I) const; + void SetInstDebugLocation(Instruction *I) const { + if (CurDbgLocation) + I->setDbgMetadata(CurDbgLocation); + } //===--------------------------------------------------------------------===// // Miscellaneous creation methods. Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=99984&r1=99983&r2=99984&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Tue Mar 30 23:09:11 2010 @@ -32,19 +32,6 @@ return GV; } -/// SetCurrentDebugLocation - Set location information used by debugging -/// information. -void IRBuilderBase::SetCurrentDebugLocation(MDNode *L) { - if (DbgMDKind == 0) - DbgMDKind = Context.getMDKindID("dbg"); - CurDbgLocation = L; -} - -void IRBuilderBase::SetInstDebugLocation(Instruction *I) const { - if (CurDbgLocation) - I->setMetadata(DbgMDKind, CurDbgLocation); -} - const Type *IRBuilderBase::getCurrentFunctionReturnType() const { assert(BB && BB->getParent() && "No current function!"); return BB->getParent()->getReturnType(); From sabre at nondot.org Tue Mar 30 23:21:31 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 04:21:31 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r99985 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <20100331042131.5766A2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 23:21:31 2010 New Revision: 99985 URL: http://llvm.org/viewvc/llvm-project?rev=99985&view=rev Log: llvm-gcc deserves some love too. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=99985&r1=99984&r2=99985&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Tue Mar 30 23:21:31 2010 @@ -475,7 +475,7 @@ llvm::DILocation DL = DebugFactory.CreateLocation(CurLineNo, 0 /* column */, VarScope, DO); - Call->setMetadata("dbg", DL.getNode()); + Call->setDbgMetadata(DL.getNode()); } From sabre at nondot.org Tue Mar 30 23:24:50 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 04:24:50 -0000 Subject: [llvm-commits] [llvm] r99986 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <20100331042450.8731F2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 23:24:50 2010 New Revision: 99986 URL: http://llvm.org/viewvc/llvm-project?rev=99986&view=rev Log: use the optimized debug info apis in sdisel. 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=99986&r1=99985&r2=99986&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Mar 30 23:24:50 2010 @@ -366,23 +366,23 @@ /// SetDebugLoc - Update MF's and SDB's DebugLocs if debug information is /// attached with this instruction. -static void SetDebugLoc(unsigned MDDbgKind, Instruction *I, - SelectionDAGBuilder *SDB, +static void SetDebugLoc(Instruction *I, SelectionDAGBuilder *SDB, FastISel *FastIS, MachineFunction *MF) { - if (MDNode *Dbg = I->getMetadata(MDDbgKind)) { - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); - - SDB->setCurDebugLoc(Loc); - - if (FastIS) - FastIS->setCurDebugLoc(Loc); - - // If the function doesn't have a default debug location yet, set - // it. This is kind of a hack. - if (MF->getDefaultDebugLoc().isUnknown()) - MF->setDefaultDebugLoc(Loc); - } + MDNode *Dbg = I->getDbgMetadata(); + if (Dbg == 0) return; + + DILocation DILoc(Dbg); + DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); + + SDB->setCurDebugLoc(Loc); + + if (FastIS) + FastIS->setCurDebugLoc(Loc); + + // If the function doesn't have a default debug location yet, set + // it. This is kind of a hack. + if (MF->getDefaultDebugLoc().isUnknown()) + MF->setDefaultDebugLoc(Loc); } /// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown. @@ -397,12 +397,11 @@ BasicBlock::iterator End, bool &HadTailCall) { SDB->setCurrentBasicBlock(BB); - unsigned MDDbgKind = LLVMBB->getContext().getMDKindID("dbg"); // Lower all of the non-terminator instructions. If a call is emitted // as a tail call, cease emitting nodes for this block. for (BasicBlock::iterator I = Begin; I != End && !SDB->HasTailCall; ++I) { - SetDebugLoc(MDDbgKind, I, SDB, 0, MF); + SetDebugLoc(I, SDB, 0, MF); if (!isa(I)) { SDB->visit(*I); @@ -425,7 +424,7 @@ HandlePHINodesInSuccessorBlocks(LLVMBB); // Lower the terminator after the copies are emitted. - SetDebugLoc(MDDbgKind, LLVMBB->getTerminator(), SDB, 0, MF); + SetDebugLoc(LLVMBB->getTerminator(), SDB, 0, MF); SDB->visit(*LLVMBB->getTerminator()); ResetDebugLoc(SDB, 0); } @@ -863,8 +862,6 @@ #endif ); - unsigned MDDbgKind = Fn.getContext().getMDKindID("dbg"); - // Iterate over all basic blocks in the function. for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I) { BasicBlock *LLVMBB = &*I; @@ -962,7 +959,7 @@ break; } - SetDebugLoc(MDDbgKind, BI, SDB, FastIS, &MF); + SetDebugLoc(BI, SDB, FastIS, &MF); // Try to select the instruction with FastISel. if (FastIS->SelectInstruction(BI)) { From sabre at nondot.org Tue Mar 30 23:26:23 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 04:26:23 -0000 Subject: [llvm-commits] [llvm] r99987 - /llvm/trunk/include/llvm/Support/DebugLoc.h Message-ID: <20100331042623.F04282A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 23:26:23 2010 New Revision: 99987 URL: http://llvm.org/viewvc/llvm-project?rev=99987&view=rev Log: fix file header. Modified: llvm/trunk/include/llvm/Support/DebugLoc.h Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=99987&r1=99986&r2=99987&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Tue Mar 30 23:26:23 2010 @@ -1,4 +1,4 @@ -//===---- llvm/DebugLoc.h - Debug Location Information ----------*- C++ -*-===// +//===---- llvm/Support/DebugLoc.h - Debug Location Information --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -25,7 +25,6 @@ /// to index into a vector of unique debug location tuples. class DebugLoc { unsigned Idx; - public: DebugLoc() : Idx(~0U) {} // Defaults to invalid. From sabre at nondot.org Tue Mar 30 23:39:37 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 04:39:37 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r99988 - /llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Message-ID: <20100331043937.2127C2A6C12C@llvm.org> Author: lattner Date: Tue Mar 30 23:39:36 2010 New Revision: 99988 URL: http://llvm.org/viewvc/llvm-project?rev=99988&view=rev Log: force irbuilder.cpp to be pulled into the llvm-gcc dylib when built "apple style". Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp?rev=99988&r1=99987&r2=99988&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-linker-hack.cpp Tue Mar 30 23:39:36 2010 @@ -33,6 +33,7 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/IRBuilder.h" #include "llvm/Support/raw_os_ostream.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetRegistry.h" @@ -97,6 +98,9 @@ llvm::DIFactory(*static_cast(0)); std::string Err; llvm::TargetRegistry::lookupTarget("", Err); + + llvm::IRBuilder<> * volatile X; + X->getCurrentFunctionReturnType(); } /* LLVM LOCAL end (ENTIRE FILE!) */ From baldrick at free.fr Wed Mar 31 00:11:28 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 31 Mar 2010 07:11:28 +0200 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <20100330205557.B1D5A2A6C12C@llvm.org> References: <20100330205557.B1D5A2A6C12C@llvm.org> Message-ID: <4BB2D980.4010309@free.fr> Hi Mon Ping, > Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset, > e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) > A update of langref will occur in a subsequent checkin. I'm trying to imagine situations in which a volatile mem* call is useful, but I didn't come up with anything very convincing yet. Can you please explain what you have in mind. Ciao, Duncan. PS: It looks like you forgot to document the new intrinsics. From sabre at nondot.org Wed Mar 31 00:15:23 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 05:15:23 -0000 Subject: [llvm-commits] [llvm] r99989 - /llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Message-ID: <20100331051523.2D20E2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 00:15:22 2010 New Revision: 99989 URL: http://llvm.org/viewvc/llvm-project?rev=99989&view=rev Log: reduce indentation, fit in 80 cols and various other cosmetic cleanups. Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLocal.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLocal.cpp?rev=99989&r1=99988&r2=99989&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLocal.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLocal.cpp Wed Mar 31 00:15:22 2010 @@ -118,8 +118,8 @@ bool isVirtRegModified(unsigned Reg) const { assert(TargetRegisterInfo::isVirtualRegister(Reg) && "Illegal VirtReg!"); - assert(Reg - TargetRegisterInfo::FirstVirtualRegister < VirtRegModified.size() - && "Illegal virtual register!"); + assert(Reg - TargetRegisterInfo::FirstVirtualRegister < + VirtRegModified.size() && "Illegal virtual register!"); return VirtRegModified[Reg - TargetRegisterInfo::FirstVirtualRegister]; } @@ -135,15 +135,16 @@ if (PhysRegsUseOrder.empty() || PhysRegsUseOrder.back() == Reg) return; // Already most recently used - for (unsigned i = PhysRegsUseOrder.size(); i != 0; --i) - if (areRegsEqual(Reg, PhysRegsUseOrder[i-1])) { - unsigned RegMatch = PhysRegsUseOrder[i-1]; // remove from middle - PhysRegsUseOrder.erase(PhysRegsUseOrder.begin()+i-1); - // Add it to the end of the list - PhysRegsUseOrder.push_back(RegMatch); - if (RegMatch == Reg) - return; // Found an exact match, exit early - } + for (unsigned i = PhysRegsUseOrder.size(); i != 0; --i) { + unsigned RegMatch = PhysRegsUseOrder[i-1]; // remove from middle + if (!areRegsEqual(Reg, RegMatch)) continue; + + PhysRegsUseOrder.erase(PhysRegsUseOrder.begin()+i-1); + // Add it to the end of the list + PhysRegsUseOrder.push_back(RegMatch); + if (RegMatch == Reg) + return; // Found an exact match, exit early + } } public: @@ -267,7 +268,7 @@ int FrameIdx = MF->getFrameInfo()->CreateSpillStackObject(RC->getSize(), RC->getAlignment()); - // Assign the slot... + // Assign the slot. StackSlotForVirtReg[VirtReg] = FrameIdx; return FrameIdx; } @@ -337,15 +338,19 @@ assert(PhysRegsUsed[PhysReg] != -2 && "Non allocable reg used!"); if (PhysRegsUsed[PhysReg] || !OnlyVirtRegs) spillVirtReg(MBB, I, PhysRegsUsed[PhysReg], PhysReg); - } else { - // If the selected register aliases any other registers, we must make - // sure that one of the aliases isn't alive. - for (const unsigned *AliasSet = TRI->getAliasSet(PhysReg); - *AliasSet; ++AliasSet) - if (PhysRegsUsed[*AliasSet] != -1 && // Spill aliased register. - PhysRegsUsed[*AliasSet] != -2) // If allocatable. - if (PhysRegsUsed[*AliasSet]) - spillVirtReg(MBB, I, PhysRegsUsed[*AliasSet], *AliasSet); + return; + } + + // If the selected register aliases any other registers, we must make + // sure that one of the aliases isn't alive. + for (const unsigned *AliasSet = TRI->getAliasSet(PhysReg); + *AliasSet; ++AliasSet) { + if (PhysRegsUsed[*AliasSet] == -1 || // Spill aliased register. + PhysRegsUsed[*AliasSet] == -2) // If allocatable. + continue; + + if (PhysRegsUsed[*AliasSet]) + spillVirtReg(MBB, I, PhysRegsUsed[*AliasSet], *AliasSet); } } @@ -410,58 +415,63 @@ // First check to see if we have a free register of the requested type... unsigned PhysReg = NoFree ? 0 : getFreeReg(RC); + if (PhysReg != 0) { + // Assign the register. + assignVirtToPhysReg(VirtReg, PhysReg); + return PhysReg; + } + // If we didn't find an unused register, scavenge one now! - if (PhysReg == 0) { - assert(!PhysRegsUseOrder.empty() && "No allocated registers??"); + assert(!PhysRegsUseOrder.empty() && "No allocated registers??"); - // Loop over all of the preallocated registers from the least recently used - // to the most recently used. When we find one that is capable of holding - // our register, use it. - for (unsigned i = 0; PhysReg == 0; ++i) { - assert(i != PhysRegsUseOrder.size() && - "Couldn't find a register of the appropriate class!"); - - unsigned R = PhysRegsUseOrder[i]; - - // We can only use this register if it holds a virtual register (ie, it - // can be spilled). Do not use it if it is an explicitly allocated - // physical register! - assert(PhysRegsUsed[R] != -1 && - "PhysReg in PhysRegsUseOrder, but is not allocated?"); - if (PhysRegsUsed[R] && PhysRegsUsed[R] != -2) { - // If the current register is compatible, use it. - if (RC->contains(R)) { - PhysReg = R; - break; - } else { - // If one of the registers aliased to the current register is - // compatible, use it. - for (const unsigned *AliasIt = TRI->getAliasSet(R); - *AliasIt; ++AliasIt) { - if (RC->contains(*AliasIt) && - // If this is pinned down for some reason, don't use it. For - // example, if CL is pinned, and we run across CH, don't use - // CH as justification for using scavenging ECX (which will - // fail). - PhysRegsUsed[*AliasIt] != 0 && - - // Make sure the register is allocatable. Don't allocate SIL on - // x86-32. - PhysRegsUsed[*AliasIt] != -2) { - PhysReg = *AliasIt; // Take an aliased register - break; - } - } - } + // Loop over all of the preallocated registers from the least recently used + // to the most recently used. When we find one that is capable of holding + // our register, use it. + for (unsigned i = 0; PhysReg == 0; ++i) { + assert(i != PhysRegsUseOrder.size() && + "Couldn't find a register of the appropriate class!"); + + unsigned R = PhysRegsUseOrder[i]; + + // We can only use this register if it holds a virtual register (ie, it + // can be spilled). Do not use it if it is an explicitly allocated + // physical register! + assert(PhysRegsUsed[R] != -1 && + "PhysReg in PhysRegsUseOrder, but is not allocated?"); + if (PhysRegsUsed[R] && PhysRegsUsed[R] != -2) { + // If the current register is compatible, use it. + if (RC->contains(R)) { + PhysReg = R; + break; + } + + // If one of the registers aliased to the current register is + // compatible, use it. + for (const unsigned *AliasIt = TRI->getAliasSet(R); + *AliasIt; ++AliasIt) { + if (!RC->contains(*AliasIt)) continue; + + // If this is pinned down for some reason, don't use it. For + // example, if CL is pinned, and we run across CH, don't use + // CH as justification for using scavenging ECX (which will + // fail). + if (PhysRegsUsed[*AliasIt] == 0) continue; + + // Make sure the register is allocatable. Don't allocate SIL on + // x86-32. + if (PhysRegsUsed[*AliasIt] == -2) continue; + + PhysReg = *AliasIt; // Take an aliased register + break; } } + } - assert(PhysReg && "Physical register not assigned!?!?"); + assert(PhysReg && "Physical register not assigned!?!?"); - // At this point PhysRegsUseOrder[i] is the least recently used register of - // compatible register class. Spill it to memory and reap its remains. - spillPhysReg(MBB, I, PhysReg); - } + // At this point PhysRegsUseOrder[i] is the least recently used register of + // compatible register class. Spill it to memory and reap its remains. + spillPhysReg(MBB, I, PhysReg); // Now that we know which register we need to assign this to, do it now! assignVirtToPhysReg(VirtReg, PhysReg); @@ -543,17 +553,17 @@ } for (const unsigned *SubRegs = TRI->getSubRegisters(PhysReg); *SubRegs; ++SubRegs) { - if (!ReloadedRegs.insert(*SubRegs)) { - std::string msg; - raw_string_ostream Msg(msg); - Msg << "Ran out of registers during register allocation!"; - if (MI->isInlineAsm()) { - Msg << "\nPlease check your inline asm statement for invalid " - << "constraints:\n"; - MI->print(Msg, TM); - } - llvm_report_error(Msg.str()); + if (ReloadedRegs.insert(*SubRegs)) continue; + + std::string msg; + raw_string_ostream Msg(msg); + Msg << "Ran out of registers during register allocation!"; + if (MI->isInlineAsm()) { + Msg << "\nPlease check your inline asm statement for invalid " + << "constraints:\n"; + MI->print(Msg, TM); } + llvm_report_error(Msg.str()); } return MI; @@ -563,7 +573,7 @@ /// read/mod/write register, i.e. update partial register. static bool isReadModWriteImplicitKill(MachineInstr *MI, unsigned Reg) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); + MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.getReg() == Reg && MO.isImplicit() && MO.isDef() && !MO.isDead()) return true; @@ -575,7 +585,7 @@ /// read/mod/write register, i.e. update partial register. static bool isReadModWriteImplicitDef(MachineInstr *MI, unsigned Reg) { for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); + MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.getReg() == Reg && MO.isImplicit() && !MO.isDef() && MO.isKill()) return true; @@ -606,7 +616,7 @@ /// ComputeLocalLiveness - Computes liveness of registers within a basic /// block, setting the killed/dead flags as appropriate. void RALocal::ComputeLocalLiveness(MachineBasicBlock& MBB) { - MachineRegisterInfo& MRI = MBB.getParent()->getRegInfo(); + MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo(); // Keep track of the most recently seen previous use or def of each reg, // so that we can update them with dead/kill markers. DenseMap > LastUseDef; @@ -614,58 +624,60 @@ I != E; ++I) { if (I->isDebugValue()) continue; + for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - MachineOperand& MO = I->getOperand(i); + MachineOperand &MO = I->getOperand(i); // Uses don't trigger any flags, but we need to save // them for later. Also, we have to process these // _before_ processing the defs, since an instr // uses regs before it defs them. - if (MO.isReg() && MO.getReg() && MO.isUse()) { - LastUseDef[MO.getReg()] = std::make_pair(I, i); - + if (!MO.isReg() || !MO.getReg() || !MO.isUse()) + continue; + + LastUseDef[MO.getReg()] = std::make_pair(I, i); + + if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) continue; + + const unsigned *Aliases = TRI->getAliasSet(MO.getReg()); + if (Aliases == 0) + continue; + + while (*Aliases) { + DenseMap >::iterator + alias = LastUseDef.find(*Aliases); - if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) continue; + if (alias != LastUseDef.end() && alias->second.first != I) + LastUseDef[*Aliases] = std::make_pair(I, i); - const unsigned* Aliases = TRI->getAliasSet(MO.getReg()); - if (Aliases) { - while (*Aliases) { - DenseMap >::iterator - alias = LastUseDef.find(*Aliases); - - if (alias != LastUseDef.end() && alias->second.first != I) - LastUseDef[*Aliases] = std::make_pair(I, i); - - ++Aliases; - } - } + ++Aliases; } } for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - MachineOperand& MO = I->getOperand(i); + MachineOperand &MO = I->getOperand(i); // Defs others than 2-addr redefs _do_ trigger flag changes: // - A def followed by a def is dead // - A use followed by a def is a kill - if (MO.isReg() && MO.getReg() && MO.isDef()) { - DenseMap >::iterator - last = LastUseDef.find(MO.getReg()); - if (last != LastUseDef.end()) { - // Check if this is a two address instruction. If so, then - // the def does not kill the use. - if (last->second.first == I && - I->isRegTiedToUseOperand(i)) - continue; - - MachineOperand& lastUD = - last->second.first->getOperand(last->second.second); - if (lastUD.isDef()) - lastUD.setIsDead(true); - else - lastUD.setIsKill(true); - } + if (!MO.isReg() || !MO.getReg() || !MO.isDef()) continue; + + DenseMap >::iterator + last = LastUseDef.find(MO.getReg()); + if (last != LastUseDef.end()) { + // Check if this is a two address instruction. If so, then + // the def does not kill the use. + if (last->second.first == I && + I->isRegTiedToUseOperand(i)) + continue; - LastUseDef[MO.getReg()] = std::make_pair(I, i); + MachineOperand &lastUD = + last->second.first->getOperand(last->second.second); + if (lastUD.isDef()) + lastUD.setIsDead(true); + else + lastUD.setIsKill(true); } + + LastUseDef[MO.getReg()] = std::make_pair(I, i); } } @@ -687,9 +699,9 @@ // in the block and determine if it is dead. for (DenseMap >::iterator I = LastUseDef.begin(), E = LastUseDef.end(); I != E; ++I) { - MachineInstr* MI = I->second.first; + MachineInstr *MI = I->second.first; unsigned idx = I->second.second; - MachineOperand& MO = MI->getOperand(idx); + MachineOperand &MO = MI->getOperand(idx); bool isPhysReg = TargetRegisterInfo::isPhysicalRegister(MO.getReg()); @@ -712,20 +724,21 @@ // Two cases: // - used in another block // - used in the same block before it is defined (loop) - if (UI->getParent() != &MBB || - (MO.isDef() && UI.getOperand().isUse() && precedes(&*UI, MI))) { - if (UI->isDebugValue()) { - UsedByDebugValueOnly = true; - continue; - } - - // A non-DBG_VALUE use means we can leave DBG_VALUE uses alone. - UsedInMultipleBlocks.set(MO.getReg() - - TargetRegisterInfo::FirstVirtualRegister); - usedOutsideBlock = true; - UsedByDebugValueOnly = false; - break; + if (UI->getParent() == &MBB && + !(MO.isDef() && UI.getOperand().isUse() && precedes(&*UI, MI))) + continue; + + if (UI->isDebugValue()) { + UsedByDebugValueOnly = true; + continue; } + + // A non-DBG_VALUE use means we can leave DBG_VALUE uses alone. + UsedInMultipleBlocks.set(MO.getReg() - + TargetRegisterInfo::FirstVirtualRegister); + usedOutsideBlock = true; + UsedByDebugValueOnly = false; + break; } if (UsedByDebugValueOnly) @@ -770,11 +783,11 @@ AddToPhysRegsUseOrder(Reg); for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); *SubRegs; ++SubRegs) { - if (PhysRegsUsed[*SubRegs] != -2) { - AddToPhysRegsUseOrder(*SubRegs); - PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now - MF->getRegInfo().setPhysRegUsed(*SubRegs); - } + if (PhysRegsUsed[*SubRegs] == -2) continue; + + AddToPhysRegsUseOrder(*SubRegs); + PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now + MF->getRegInfo().setPhysRegUsed(*SubRegs); } } @@ -813,16 +826,16 @@ SmallVector Kills; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); - if (MO.isReg() && MO.isKill()) { - if (!MO.isImplicit()) - Kills.push_back(MO.getReg()); - else if (!isReadModWriteImplicitKill(MI, MO.getReg())) - // These are extra physical register kills when a sub-register - // is defined (def of a sub-register is a read/mod/write of the - // larger registers). Ignore. - Kills.push_back(MO.getReg()); - } + MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isKill()) continue; + + if (!MO.isImplicit()) + Kills.push_back(MO.getReg()); + else if (!isReadModWriteImplicitKill(MI, MO.getReg())) + // These are extra physical register kills when a sub-register + // is defined (def of a sub-register is a read/mod/write of the + // larger registers). Ignore. + Kills.push_back(MO.getReg()); } // If any physical regs are earlyclobber, spill any value they might @@ -830,45 +843,45 @@ // If any virtual regs are earlyclobber, allocate them now (before // freeing inputs that are killed). if (MI->isInlineAsm()) { - for (unsigned i = 0; i != MI->getNumOperands(); ++i) { - MachineOperand& MO = MI->getOperand(i); - if (MO.isReg() && MO.isDef() && MO.isEarlyClobber() && - MO.getReg()) { - if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) { - unsigned DestVirtReg = MO.getReg(); - unsigned DestPhysReg; - - // If DestVirtReg already has a value, use it. - if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg))) - DestPhysReg = getReg(MBB, MI, DestVirtReg); - MF->getRegInfo().setPhysRegUsed(DestPhysReg); - markVirtRegModified(DestVirtReg); - getVirtRegLastUse(DestVirtReg) = - std::make_pair((MachineInstr*)0, 0); - DEBUG(dbgs() << " Assigning " << TRI->getName(DestPhysReg) - << " to %reg" << DestVirtReg << "\n"); - MO.setReg(DestPhysReg); // Assign the earlyclobber register - } else { - unsigned Reg = MO.getReg(); - if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. - // These are extra physical register defs when a sub-register - // is defined (def of a sub-register is a read/mod/write of the - // larger registers). Ignore. - if (isReadModWriteImplicitDef(MI, MO.getReg())) continue; - - MF->getRegInfo().setPhysRegUsed(Reg); - spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg - PhysRegsUsed[Reg] = 0; // It is free and reserved now - AddToPhysRegsUseOrder(Reg); - - for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); - *SubRegs; ++SubRegs) { - if (PhysRegsUsed[*SubRegs] != -2) { - MF->getRegInfo().setPhysRegUsed(*SubRegs); - PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now - AddToPhysRegsUseOrder(*SubRegs); - } - } + for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef() || !MO.isEarlyClobber() || + !MO.getReg()) + continue; + + if (TargetRegisterInfo::isVirtualRegister(MO.getReg())) { + unsigned DestVirtReg = MO.getReg(); + unsigned DestPhysReg; + + // If DestVirtReg already has a value, use it. + if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg))) + DestPhysReg = getReg(MBB, MI, DestVirtReg); + MF->getRegInfo().setPhysRegUsed(DestPhysReg); + markVirtRegModified(DestVirtReg); + getVirtRegLastUse(DestVirtReg) = + std::make_pair((MachineInstr*)0, 0); + DEBUG(dbgs() << " Assigning " << TRI->getName(DestPhysReg) + << " to %reg" << DestVirtReg << "\n"); + MO.setReg(DestPhysReg); // Assign the earlyclobber register + } else { + unsigned Reg = MO.getReg(); + if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. + // These are extra physical register defs when a sub-register + // is defined (def of a sub-register is a read/mod/write of the + // larger registers). Ignore. + if (isReadModWriteImplicitDef(MI, MO.getReg())) continue; + + MF->getRegInfo().setPhysRegUsed(Reg); + spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg + PhysRegsUsed[Reg] = 0; // It is free and reserved now + AddToPhysRegsUseOrder(Reg); + + for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); + *SubRegs; ++SubRegs) { + if (PhysRegsUsed[*SubRegs] == -2) continue; + MF->getRegInfo().setPhysRegUsed(*SubRegs); + PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now + AddToPhysRegsUseOrder(*SubRegs); } } } @@ -894,7 +907,7 @@ // SmallSet ReloadedRegs; for (unsigned i = 0; i != MI->getNumOperands(); ++i) { - MachineOperand& MO = MI->getOperand(i); + MachineOperand &MO = MI->getOperand(i); // here we are looking for only used operands (never def&use) if (MO.isReg() && !MO.isDef() && MO.getReg() && !MO.isImplicit() && TargetRegisterInfo::isVirtualRegister(MO.getReg())) @@ -923,18 +936,18 @@ "Silently clearing a virtual register?"); } - if (PhysReg) { - DEBUG(dbgs() << " Last use of " << TRI->getName(PhysReg) - << "[%reg" << VirtReg <<"], removing it from live set\n"); - removePhysReg(PhysReg); - for (const unsigned *SubRegs = TRI->getSubRegisters(PhysReg); - *SubRegs; ++SubRegs) { - if (PhysRegsUsed[*SubRegs] != -2) { - DEBUG(dbgs() << " Last use of " - << TRI->getName(*SubRegs) << "[%reg" << VirtReg - <<"], removing it from live set\n"); - removePhysReg(*SubRegs); - } + if (!PhysReg) continue; + + DEBUG(dbgs() << " Last use of " << TRI->getName(PhysReg) + << "[%reg" << VirtReg <<"], removing it from live set\n"); + removePhysReg(PhysReg); + for (const unsigned *SubRegs = TRI->getSubRegisters(PhysReg); + *SubRegs; ++SubRegs) { + if (PhysRegsUsed[*SubRegs] != -2) { + DEBUG(dbgs() << " Last use of " + << TRI->getName(*SubRegs) << "[%reg" << VirtReg + <<"], removing it from live set\n"); + removePhysReg(*SubRegs); } } } @@ -942,30 +955,31 @@ // Loop over all of the operands of the instruction, spilling registers that // are defined, and marking explicit destinations in the PhysRegsUsed map. for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); - if (MO.isReg() && MO.isDef() && !MO.isImplicit() && MO.getReg() && - !MO.isEarlyClobber() && - TargetRegisterInfo::isPhysicalRegister(MO.getReg())) { - unsigned Reg = MO.getReg(); - if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. - // These are extra physical register defs when a sub-register - // is defined (def of a sub-register is a read/mod/write of the - // larger registers). Ignore. - if (isReadModWriteImplicitDef(MI, MO.getReg())) continue; - - MF->getRegInfo().setPhysRegUsed(Reg); - spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg - PhysRegsUsed[Reg] = 0; // It is free and reserved now - AddToPhysRegsUseOrder(Reg); - - for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); - *SubRegs; ++SubRegs) { - if (PhysRegsUsed[*SubRegs] != -2) { - MF->getRegInfo().setPhysRegUsed(*SubRegs); - PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now - AddToPhysRegsUseOrder(*SubRegs); - } - } + MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef() || MO.isImplicit() || !MO.getReg() || + MO.isEarlyClobber() || + !TargetRegisterInfo::isPhysicalRegister(MO.getReg())) + continue; + + unsigned Reg = MO.getReg(); + if (PhysRegsUsed[Reg] == -2) continue; // Something like ESP. + // These are extra physical register defs when a sub-register + // is defined (def of a sub-register is a read/mod/write of the + // larger registers). Ignore. + if (isReadModWriteImplicitDef(MI, MO.getReg())) continue; + + MF->getRegInfo().setPhysRegUsed(Reg); + spillPhysReg(MBB, MI, Reg, true); // Spill any existing value in reg + PhysRegsUsed[Reg] = 0; // It is free and reserved now + AddToPhysRegsUseOrder(Reg); + + for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); + *SubRegs; ++SubRegs) { + if (PhysRegsUsed[*SubRegs] == -2) continue; + + MF->getRegInfo().setPhysRegUsed(*SubRegs); + PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now + AddToPhysRegsUseOrder(*SubRegs); } } @@ -982,18 +996,18 @@ MF->getRegInfo().setPhysRegUsed(Reg); for (const unsigned *SubRegs = TRI->getSubRegisters(Reg); *SubRegs; ++SubRegs) { - if (PhysRegsUsed[*SubRegs] != -2) { - AddToPhysRegsUseOrder(*SubRegs); - PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now - MF->getRegInfo().setPhysRegUsed(*SubRegs); - } + if (PhysRegsUsed[*SubRegs] == -2) continue; + + AddToPhysRegsUseOrder(*SubRegs); + PhysRegsUsed[*SubRegs] = 0; // It is free and reserved now + MF->getRegInfo().setPhysRegUsed(*SubRegs); } } } SmallVector DeadDefs; for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); + MachineOperand &MO = MI->getOperand(i); if (MO.isReg() && MO.isDead()) DeadDefs.push_back(MO.getReg()); } @@ -1004,45 +1018,46 @@ // we need to scavenge a register. // for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { - MachineOperand& MO = MI->getOperand(i); - if (MO.isReg() && MO.isDef() && MO.getReg() && - !MO.isEarlyClobber() && - TargetRegisterInfo::isVirtualRegister(MO.getReg())) { - unsigned DestVirtReg = MO.getReg(); - unsigned DestPhysReg; - - // If DestVirtReg already has a value, use it. - if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg))) { - // If this is a copy try to reuse the input as the output; - // that will make the copy go away. - // If this is a copy, the source reg is a phys reg, and - // that reg is available, use that phys reg for DestPhysReg. - // If this is a copy, the source reg is a virtual reg, and - // the phys reg that was assigned to that virtual reg is now - // available, use that phys reg for DestPhysReg. (If it's now - // available that means this was the last use of the source.) - if (isCopy && - TargetRegisterInfo::isPhysicalRegister(SrcCopyReg) && - isPhysRegAvailable(SrcCopyReg)) { - DestPhysReg = SrcCopyReg; - assignVirtToPhysReg(DestVirtReg, DestPhysReg); - } else if (isCopy && - TargetRegisterInfo::isVirtualRegister(SrcCopyReg) && - SrcCopyPhysReg && isPhysRegAvailable(SrcCopyPhysReg) && - MF->getRegInfo().getRegClass(DestVirtReg)-> - contains(SrcCopyPhysReg)) { - DestPhysReg = SrcCopyPhysReg; - assignVirtToPhysReg(DestVirtReg, DestPhysReg); - } else - DestPhysReg = getReg(MBB, MI, DestVirtReg); - } - MF->getRegInfo().setPhysRegUsed(DestPhysReg); - markVirtRegModified(DestVirtReg); - getVirtRegLastUse(DestVirtReg) = std::make_pair((MachineInstr*)0, 0); - DEBUG(dbgs() << " Assigning " << TRI->getName(DestPhysReg) - << " to %reg" << DestVirtReg << "\n"); - MO.setReg(DestPhysReg); // Assign the output register + MachineOperand &MO = MI->getOperand(i); + if (!MO.isReg() || !MO.isDef() || !MO.getReg() || + MO.isEarlyClobber() || + !TargetRegisterInfo::isVirtualRegister(MO.getReg())) + continue; + + unsigned DestVirtReg = MO.getReg(); + unsigned DestPhysReg; + + // If DestVirtReg already has a value, use it. + if (!(DestPhysReg = getVirt2PhysRegMapSlot(DestVirtReg))) { + // If this is a copy try to reuse the input as the output; + // that will make the copy go away. + // If this is a copy, the source reg is a phys reg, and + // that reg is available, use that phys reg for DestPhysReg. + // If this is a copy, the source reg is a virtual reg, and + // the phys reg that was assigned to that virtual reg is now + // available, use that phys reg for DestPhysReg. (If it's now + // available that means this was the last use of the source.) + if (isCopy && + TargetRegisterInfo::isPhysicalRegister(SrcCopyReg) && + isPhysRegAvailable(SrcCopyReg)) { + DestPhysReg = SrcCopyReg; + assignVirtToPhysReg(DestVirtReg, DestPhysReg); + } else if (isCopy && + TargetRegisterInfo::isVirtualRegister(SrcCopyReg) && + SrcCopyPhysReg && isPhysRegAvailable(SrcCopyPhysReg) && + MF->getRegInfo().getRegClass(DestVirtReg)-> + contains(SrcCopyPhysReg)) { + DestPhysReg = SrcCopyPhysReg; + assignVirtToPhysReg(DestVirtReg, DestPhysReg); + } else + DestPhysReg = getReg(MBB, MI, DestVirtReg); } + MF->getRegInfo().setPhysRegUsed(DestPhysReg); + markVirtRegModified(DestVirtReg); + getVirtRegLastUse(DestVirtReg) = std::make_pair((MachineInstr*)0, 0); + DEBUG(dbgs() << " Assigning " << TRI->getName(DestPhysReg) + << " to %reg" << DestVirtReg << "\n"); + MO.setReg(DestPhysReg); // Assign the output register } // If this instruction defines any registers that are immediately dead, @@ -1059,21 +1074,20 @@ } else if (PhysRegsUsed[PhysReg] == -2) { // Unallocatable register dead, ignore. continue; - } - - if (PhysReg) { - DEBUG(dbgs() << " Register " << TRI->getName(PhysReg) - << " [%reg" << VirtReg - << "] is never used, removing it from live set\n"); - removePhysReg(PhysReg); - for (const unsigned *AliasSet = TRI->getAliasSet(PhysReg); - *AliasSet; ++AliasSet) { - if (PhysRegsUsed[*AliasSet] != -2) { - DEBUG(dbgs() << " Register " << TRI->getName(*AliasSet) - << " [%reg" << *AliasSet - << "] is never used, removing it from live set\n"); - removePhysReg(*AliasSet); - } + } else if (!PhysReg) + continue; + + DEBUG(dbgs() << " Register " << TRI->getName(PhysReg) + << " [%reg" << VirtReg + << "] is never used, removing it from live set\n"); + removePhysReg(PhysReg); + for (const unsigned *AliasSet = TRI->getAliasSet(PhysReg); + *AliasSet; ++AliasSet) { + if (PhysRegsUsed[*AliasSet] != -2) { + DEBUG(dbgs() << " Register " << TRI->getName(*AliasSet) + << " [%reg" << *AliasSet + << "] is never used, removing it from live set\n"); + removePhysReg(*AliasSet); } } } @@ -1143,8 +1157,10 @@ StackSlotForVirtReg.grow(LastVirtReg); Virt2PhysRegMap.grow(LastVirtReg); Virt2LastUseMap.grow(LastVirtReg); - VirtRegModified.resize(LastVirtReg+1-TargetRegisterInfo::FirstVirtualRegister); - UsedInMultipleBlocks.resize(LastVirtReg+1-TargetRegisterInfo::FirstVirtualRegister); + VirtRegModified.resize(LastVirtReg+1 - + TargetRegisterInfo::FirstVirtualRegister); + UsedInMultipleBlocks.resize(LastVirtReg+1 - + TargetRegisterInfo::FirstVirtualRegister); // Loop over all of the basic blocks, eliminating virtual register references for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end(); From clattner at apple.com Wed Mar 31 00:22:47 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 22:22:47 -0700 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <4BB2D980.4010309@free.fr> References: <20100330205557.B1D5A2A6C12C@llvm.org> <4BB2D980.4010309@free.fr> Message-ID: <3ED1D34B-674B-47E4-93EA-DFB5E2CC7319@apple.com> On Mar 30, 2010, at 10:11 PM, Duncan Sands wrote: > Hi Mon Ping, > >> Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset, >> e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) >> A update of langref will occur in a subsequent checkin. > > I'm trying to imagine situations in which a volatile mem* call is useful, but I > didn't come up with anything very convincing yet. Can you please explain what > you have in mind. volatile struct foo X, Y; X = Y; Should lower to a 'volatile memcpy'. Knowing that a memcpy is volatile allows the optimizer (e.g. memcpyopt) to avoid touching them. -Chris From baldrick at free.fr Wed Mar 31 00:27:33 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 31 Mar 2010 05:27:33 -0000 Subject: [llvm-commits] [llvm] r99991 - /llvm/trunk/include/llvm/Support/IRBuilder.h Message-ID: <20100331052733.EDF972A6C12C@llvm.org> Author: baldrick Date: Wed Mar 31 00:27:33 2010 New Revision: 99991 URL: http://llvm.org/viewvc/llvm-project?rev=99991&view=rev Log: Correct comment. 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=99991&r1=99990&r2=99991&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Mar 31 00:27:33 2010 @@ -85,7 +85,7 @@ CurDbgLocation = L; } - /// SetCurrentDebugLocation - Set location information used by debugging + /// getCurrentDebugLocation - Get location information used by debugging /// information. MDNode *getCurrentDebugLocation() const { return CurDbgLocation; } From baldrick at free.fr Wed Mar 31 00:33:07 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 31 Mar 2010 07:33:07 +0200 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <3ED1D34B-674B-47E4-93EA-DFB5E2CC7319@apple.com> References: <20100330205557.B1D5A2A6C12C@llvm.org> <4BB2D980.4010309@free.fr> <3ED1D34B-674B-47E4-93EA-DFB5E2CC7319@apple.com> Message-ID: <4BB2DE93.5070607@free.fr> Hi Chris, >> I'm trying to imagine situations in which a volatile mem* call is useful, but I >> didn't come up with anything very convincing yet. Can you please explain what >> you have in mind. > > volatile struct foo X, Y; > > X = Y; > > Should lower to a 'volatile memcpy'. shouldn't it load to a series of field by field volatile copies? Ciao, Duncan. From sabre at nondot.org Wed Mar 31 00:36:29 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 05:36:29 -0000 Subject: [llvm-commits] [llvm] r99992 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100331053629.3617C2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 00:36:29 2010 New Revision: 99992 URL: http://llvm.org/viewvc/llvm-project?rev=99992&view=rev Log: assert is a function-like macro, not a control flow operator. 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=99992&r1=99991&r2=99992&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 00:36:29 2010 @@ -230,14 +230,14 @@ void fixInstructionMarkers(DenseMap &MIIndexMap) { - assert (getFirstInsn() && "First instruction is missing!"); + assert(getFirstInsn() && "First instruction is missing!"); // Use the end of last child scope as end of this scope. const SmallVector &Scopes = getScopes(); const MachineInstr *LastInsn = getFirstInsn(); unsigned LIndex = 0; if (Scopes.empty()) { - assert (getLastInsn() && "Inner most scope does not have last insn!"); + assert(getLastInsn() && "Inner most scope does not have last insn!"); return; } for (SmallVector::const_iterator SI = Scopes.begin(), @@ -1243,9 +1243,9 @@ /// getUpdatedDbgScope - Find or create DbgScope assicated with the instruction. /// Initialize scope and update scope hierarchy. DbgScope *DwarfDebug::getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, - MDNode *InlinedAt) { - assert (N && "Invalid Scope encoding!"); - assert (MI && "Missing machine instruction!"); + MDNode *InlinedAt) { + assert(N && "Invalid Scope encoding!"); + assert(MI && "Missing machine instruction!"); bool GetConcreteScope = (MI && InlinedAt); DbgScope *NScope = NULL; @@ -1254,7 +1254,7 @@ NScope = DbgScopeMap.lookup(InlinedAt); else NScope = DbgScopeMap.lookup(N); - assert (NScope && "Unable to find working scope!"); + assert(NScope && "Unable to find working scope!"); if (NScope->getFirstInsn()) return NScope; @@ -1264,7 +1264,7 @@ DILocation IL(InlinedAt); Parent = getUpdatedDbgScope(IL.getScope().getNode(), MI, IL.getOrigLocation().getNode()); - assert (Parent && "Unable to find Parent scope!"); + assert(Parent && "Unable to find Parent scope!"); NScope->setParent(Parent); Parent->addScope(NScope); } else if (DIDescriptor(N).isLexicalBlock()) { @@ -1291,7 +1291,7 @@ } DbgScope *DwarfDebug::getOrCreateAbstractScope(MDNode *N) { - assert (N && "Invalid Scope encoding!"); + assert(N && "Invalid Scope encoding!"); DbgScope *AScope = AbstractScopes.lookup(N); if (AScope) @@ -1409,7 +1409,7 @@ DISubprogram InlinedSP = getDISubprogram(DS.getNode()); DIE *OriginDIE = ModuleCU->getDIE(InlinedSP.getNode()); - assert (OriginDIE && "Unable to find Origin DIE!"); + assert(OriginDIE && "Unable to find Origin DIE!"); addDIEEntry(ScopeDIE, dwarf::DW_AT_abstract_origin, dwarf::DW_FORM_ref4, OriginDIE); @@ -1473,9 +1473,9 @@ DISubprogram InlinedSP = getDISubprogram(DS.getNode()); DIE *OriginSPDIE = ModuleCU->getDIE(InlinedSP.getNode()); (void) OriginSPDIE; - assert (OriginSPDIE && "Unable to find Origin DIE for the SP!"); + assert(OriginSPDIE && "Unable to find Origin DIE for the SP!"); DIE *AbsDIE = DV->getAbstractVariable()->getDIE(); - assert (AbsDIE && "Unable to find Origin DIE for the Variable!"); + assert(AbsDIE && "Unable to find Origin DIE for the Variable!"); addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin, dwarf::DW_FORM_ref4, AbsDIE); } @@ -1750,7 +1750,7 @@ DIType GTy = DI_GV.getType(); if (GTy.isCompositeType() && !GTy.getName().empty()) { DIEEntry *Entry = ModuleCU->getDIEEntry(GTy.getNode()); - assert (Entry && "Missing global type!"); + assert(Entry && "Missing global type!"); ModuleCU->addGlobalType(GTy.getName(), Entry->getEntry()); } return; @@ -2220,7 +2220,7 @@ if (S->isAbstractScope()) continue; const MachineInstr *MI = S->getFirstInsn(); - assert (MI && "DbgScope does not have first instruction!"); + assert(MI && "DbgScope does not have first instruction!"); InsnToDbgScopeMapTy::iterator IDI = DbgScopeBeginMap.find(MI); if (IDI != DbgScopeBeginMap.end()) @@ -2229,7 +2229,7 @@ DbgScopeBeginMap[MI].push_back(S); MI = S->getLastInsn(); - assert (MI && "DbgScope does not have last instruction!"); + assert(MI && "DbgScope does not have last instruction!"); IDI = DbgScopeEndMap.find(MI); if (IDI != DbgScopeEndMap.end()) IDI->second.push_back(S); From sabre at nondot.org Wed Mar 31 00:39:57 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 05:39:57 -0000 Subject: [llvm-commits] [llvm] r99993 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100331053957.A509D2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 00:39:57 2010 New Revision: 99993 URL: http://llvm.org/viewvc/llvm-project?rev=99993&view=rev Log: use the isDebugValue() predicate and pop_back_val() 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=99993&r1=99992&r2=99993&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 00:39:57 2010 @@ -2008,7 +2008,7 @@ for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); II != IE; ++II) { const MachineInstr *MInsn = II; - if (MInsn->getOpcode() != TargetOpcode::DBG_VALUE) + if (!MInsn->isDebugValue()) continue; // FIXME : Lift this restriction. @@ -2059,7 +2059,7 @@ PrevDILoc = DILoc.getNode(); // DBG_VALUE instruction establishes new value. - if (MI->getOpcode() == TargetOpcode::DBG_VALUE) { + if (MI->isDebugValue()) { DenseMap::iterator DI = DbgValueStartMap.find(MI); if (DI != DbgValueStartMap.end()) { @@ -2091,7 +2091,7 @@ /// endScope - Process end of a scope. void DwarfDebug::endScope(const MachineInstr *MI) { // Ignore DBG_VALUE instruction. - if (MI->getOpcode() == TargetOpcode::DBG_VALUE) + if (MI->isDebugValue()) return; // Check location. @@ -2142,7 +2142,7 @@ } /// extractScopeInformation - Scan machine instructions in this function -/// and collect DbgScopes. Return true, if atleast one scope was found. +/// and collect DbgScopes. Return true, if at least one scope was found. bool DwarfDebug::extractScopeInformation() { // If scope information was extracted using .dbg intrinsics then there is not // any need to extract these information by scanning each instruction. @@ -2158,7 +2158,7 @@ II != IE; ++II) { const MachineInstr *MInsn = II; // FIXME : Remove DBG_VALUE check. - if (MInsn->getOpcode() == TargetOpcode::DBG_VALUE) continue; + if (MInsn->isDebugValue()) continue; MIIndexMap[MInsn] = MIIndex++; DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; @@ -2181,7 +2181,7 @@ II != IE; ++II) { const MachineInstr *MInsn = II; // FIXME : Remove DBG_VALUE check. - if (MInsn->getOpcode() == TargetOpcode::DBG_VALUE) continue; + if (MInsn->isDebugValue()) continue; DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); @@ -2209,7 +2209,7 @@ SmallVector WorkList; WorkList.push_back(CurrentFnDbgScope); while (!WorkList.empty()) { - DbgScope *S = WorkList.back(); WorkList.pop_back(); + DbgScope *S = WorkList.pop_back_val(); const SmallVector &Children = S->getScopes(); if (!Children.empty()) From baldrick at free.fr Wed Mar 31 00:41:36 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 31 Mar 2010 05:41:36 -0000 Subject: [llvm-commits] [dragonegg] r99994 - /dragonegg/trunk/gcc_revision_tested_with Message-ID: <20100331054136.96D132A6C12C@llvm.org> Author: baldrick Date: Wed Mar 31 00:41:36 2010 New Revision: 99994 URL: http://llvm.org/viewvc/llvm-project?rev=99994&view=rev Log: Bump the GCC revision to one for which the except.h header is available to plugins. Modified: dragonegg/trunk/gcc_revision_tested_with Modified: dragonegg/trunk/gcc_revision_tested_with URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/gcc_revision_tested_with?rev=99994&r1=99993&r2=99994&view=diff ============================================================================== --- dragonegg/trunk/gcc_revision_tested_with (original) +++ dragonegg/trunk/gcc_revision_tested_with Wed Mar 31 00:41:36 2010 @@ -1 +1 @@ -157558 +157849 From sabre at nondot.org Wed Mar 31 00:42:48 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 05:42:48 -0000 Subject: [llvm-commits] [llvm] r99995 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100331054248.96D5B2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 00:42:48 2010 New Revision: 99995 URL: http://llvm.org/viewvc/llvm-project?rev=99995&view=rev Log: MI != 0 is checked in the assert right above this. 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=99995&r1=99994&r2=99995&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 00:42:48 2010 @@ -1246,7 +1246,7 @@ MDNode *InlinedAt) { assert(N && "Invalid Scope encoding!"); assert(MI && "Missing machine instruction!"); - bool GetConcreteScope = (MI && InlinedAt); + bool GetConcreteScope = InlinedAt != 0; DbgScope *NScope = NULL; From baldrick at free.fr Wed Mar 31 00:50:37 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 31 Mar 2010 05:50:37 -0000 Subject: [llvm-commits] [dragonegg] r99996 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <20100331055037.18D882A6C12C@llvm.org> Author: baldrick Date: Wed Mar 31 00:50:36 2010 New Revision: 99996 URL: http://llvm.org/viewvc/llvm-project?rev=99996&view=rev Log: Generate invokes for calls in exception handling regions. The trick here is in getting phi nodes right: the GCC landing pad may contain phi nodes, and in theory the landing pad may be shared amongst several exception handling regions (each of which can have its own notion of exception pointer), or even be the target of a normal edge. On the other hand, we (may) need to have invokes branch to a basic block which sets up the exception pointer and selector before branching to the GCC landing pad. If the GCC landing pad is shared by several exception handling regions then we have to create many such basic blocks. The result is that any phi nodes in the GCC landing pad need to be factorized through all these extra basic blocks. To do this, first all invokes are initially set to unwind to the GCC landing pad. Then GCC phi nodes are converted to LLVM phi nodes. Finally, any additional basic blocks are introduced, invoke destinations are changed to point to them, and phi nodes are factorized. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=99996&r1=99995&r2=99996&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Wed Mar 31 00:50:36 2010 @@ -76,6 +76,7 @@ #include "tree-pass.h" #include "rtl.h" #include "langhooks.h" +#include "except.h" extern int get_pointer_alignment (tree exp, unsigned int max_align); extern enum machine_mode reg_raw_mode[FIRST_PSEUDO_REGISTER]; @@ -987,15 +988,14 @@ Builder.CreateAggregateRet(RetVals.data(), RetVals.size()); } - // Emit pending exception handling code. - EmitLandingPads(); - EmitPostPads(); - EmitUnwindBlock(); - // Populate phi nodes with their operands now that all ssa names have been // defined and all basic blocks output. PopulatePhiNodes(); + // Now that phi nodes have been output, emit pending exception handling code. + EmitLandingPads(); + EmitUnwindBlock(); + #ifndef NDEBUG if (!errorcount && !sorrycount) for (DenseMap >::const_iterator I = SSANames.begin(), @@ -1849,40 +1849,17 @@ Intrinsic::eh_typeid_for); } -/// getLandingPad - Return the landing pad for the given exception handling -/// region, creating it if necessary. -BasicBlock *TreeToLLVM::getLandingPad(unsigned RegionNo) { - LandingPads.grow(RegionNo); - BasicBlock *&LandingPad = LandingPads[RegionNo]; - - if (!LandingPad) - LandingPad = BasicBlock::Create(Context, "lpad"); - - return LandingPad; -} - - -/// getPostPad - Return the post landing pad for the given exception handling -/// region, creating it if necessary. -BasicBlock *TreeToLLVM::getPostPad(unsigned RegionNo) { - PostPads.grow(RegionNo); - BasicBlock *&PostPad = PostPads[RegionNo]; - - if (!PostPad) - PostPad = BasicBlock::Create(Context, "ppad"); - - return PostPad; -} - /// getExceptionPtr - Return the local holding the exception pointer for the /// given exception handling region, creating it if necessary. AllocaInst *TreeToLLVM::getExceptionPtr(unsigned RegionNo) { - ExceptionPtrs.grow(RegionNo); + if (RegionNo >= ExceptionPtrs.size()) + ExceptionPtrs.resize(RegionNo + 1, 0); + AllocaInst *&ExceptionPtr = ExceptionPtrs[RegionNo]; if (!ExceptionPtr) { ExceptionPtr = CreateTemporary(Type::getInt8PtrTy(Context)); - ExceptionPtr->setName("exc_ptr"); + ExceptionPtr->setName("exc_tmp"); } return ExceptionPtr; @@ -1896,28 +1873,109 @@ /// EmitLandingPads - Emit EH landing pads. void TreeToLLVM::EmitLandingPads() { - std::vector Args; -//FIXME std::vector Handlers; + // If a GCC landing pad is shared by several exception handling regions, or if + // there is a normal edge to it, then create an LLVM landing pad for each eh + // region. Calls to eh.exception and eh.selector will be placed in the LLVM + // landing pad, which branches to the GCC landing pad. + for (unsigned RegionNo = 1; RegionNo < Invokes.size(); ++RegionNo){ + // Get the list of invokes for this exception handling region. + SmallVector &InvokesForRegion = Invokes[RegionNo]; + + if (InvokesForRegion.empty()) + continue; - for (unsigned i = 1; i < LandingPads.size(); ++i) { - BasicBlock *LandingPad = LandingPads[i]; + // All of the invokes unwind to the same basic block: the GCC landing pad. + BasicBlock *OldDest = InvokesForRegion[0]->getUnwindDest(); - if (!LandingPad) + // If the number of invokes is equal to the number of predecessors of the + // landing pad then it follows that no other exception handing region has + // invokes that unwind to this GCC landing pad, and also that there are no + // normal edges to the landing pad. In this common case there is no need + // to create an LLVM specific landing pad. + if ((unsigned)std::distance(pred_begin(OldDest), pred_end(OldDest)) == + InvokesForRegion.size()) + continue; + + // Create the LLVM landing pad right before the GCC landing pad. + BasicBlock *NewDest = BasicBlock::Create(Context, "lpad", Fn, OldDest); + + // Redirect invoke unwind edges from the GCC landing pad to NewDest. + for (unsigned i = 0, e = InvokesForRegion.size(); i < e; ++i) + InvokesForRegion[i]->setSuccessor(1, NewDest); + + // If there are any PHI nodes in OldDest, we need to update them to merge + // incoming values from NewDest instead. + pred_iterator PB = pred_begin(NewDest), PE = pred_end(NewDest); + for (BasicBlock::iterator II = OldDest->begin(); isa(II);) { + PHINode *PN = cast(II++); + + // Check to see if all of the values coming in via invoke unwind edges are + // the same. If so, we don't need to create a new PHI node. + Value *InVal = PN->getIncomingValueForBlock(*PB); + for (pred_iterator PI = PB; PI != PE; ++PI) { + if (PI != PB && InVal != PN->getIncomingValueForBlock(*PI)) { + InVal = 0; + break; + } + } + + if (InVal == 0) { + // Different unwind edges have different values. Create a new PHI node + // in NewDest. + PHINode *NewPN = PHINode::Create(PN->getType(), PN->getName()+".lpad", + NewDest); + // Add an entry for each unwind edge, using the value from the old PHI. + for (pred_iterator PI = PB; PI != PE; ++PI) + NewPN->addIncoming(PN->getIncomingValueForBlock(*PI), *PI); + + // Now use this new PHI as the common incoming value for NewDest in PN. + InVal = NewPN; + } + + // Revector exactly one entry in the PHI node to come from NewDest and + // delete the entries that came from the invoke unwind edges. + for (pred_iterator PI = PB; PI != PE; ++PI) + PN->removeIncomingValue(*PI); + PN->addIncoming(InVal, NewDest); + } + + // Add a fallthrough from NewDest to the original landing pad. + BranchInst::Create(OldDest, NewDest); + } + + // Initialize the exception pointer and selector value for each exception + // handling region at the start of the corresponding landing pad. At this + // point each exception handling region has its own landing pad, which is + // only reachable via the unwind edges of the region's invokes. +//FIXME std::vector Args; +//FIXME std::vector Handlers; + for (unsigned RegionNo = 1; RegionNo < Invokes.size(); ++RegionNo){ + // Get the list of invokes for this exception handling region. + SmallVector &InvokesForRegion = Invokes[RegionNo]; + + if (InvokesForRegion.empty()) continue; CreateExceptionValues(); - BeginBlock(LandingPad); + // All of the invokes unwind to the same basic block: the landing pad. + BasicBlock *LPad = InvokesForRegion[0]->getUnwindDest(); - // Fetch and store the exception. + // Insert instructions at the start of the landing pad, but after any phis. + Builder.SetInsertPoint(LPad, LPad->getFirstNonPHI()); + + // Fetch the exception pointer. Value *ExcPtr = Builder.CreateCall(FuncEHException, "exc_ptr"); - Builder.CreateStore(ExcPtr, getExceptionPtr(i)); - // Fetch and store the exception selector. + // Store it if made use of elsewhere. + if (RegionNo < ExceptionPtrs.size() && ExceptionPtrs[RegionNo]) + Builder.CreateStore(ExcPtr, ExceptionPtrs[RegionNo]); - // The exception and the personality function. - Args.push_back(ExcPtr); -abort();//FIXME +//FIXME // Fetch and store the exception selector. +//FIXME +//FIXME // The exception and the personality function. +//FIXME Args.push_back(ExcPtr); +//FIXME //FIXME assert(llvm_eh_personality_libfunc //FIXME && "no exception handling personality function!"); //FIXME Args.push_back(Builder.CreateBitCast(DECL_LOCAL(llvm_eh_personality_libfunc), @@ -1992,30 +2050,29 @@ //FIXME Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(), //FIXME "eh_select"); //FIXME Builder.CreateStore(Select, ExceptionSelectorValue); -//FIXME // Branch to the post landing pad for the first reachable handler. -//FIXME assert(!Handlers.empty() && "Landing pad but no handler?"); -//FIXME Builder.CreateBr(getPostPad(get_eh_region_number(*Handlers.begin()))); -//FIXME + //FIXME Handlers.clear(); //FIXME Args.clear(); } + + Invokes.clear(); } -/// EmitPostPads - Emit EH post landing pads. -void TreeToLLVM::EmitPostPads() { +//FIXME/// EmitPostPads - Emit EH post landing pads. +//FIXMEvoid TreeToLLVM::EmitPostPads() { //FIXME std::vector Handlers; - - for (unsigned i = 1; i < PostPads.size(); ++i) { - BasicBlock *PostPad = PostPads[i]; - - if (!PostPad) - continue; - - CreateExceptionValues(); - - BeginBlock(PostPad); - -abort();//FIXME +//FIXME +//FIXME for (unsigned i = 1; i < PostPads.size(); ++i) { +//FIXME BasicBlock *PostPad = PostPads[i]; +//FIXME +//FIXME if (!PostPad) +//FIXME continue; +//FIXME +//FIXME CreateExceptionValues(); +//FIXME +//FIXME BeginBlock(PostPad); +//FIXMEBuilder.CreateUnreachable(); +//FIXME //FIXME eh_region region = get_eh_region(i); //FIXME BasicBlock *Dest = getLabelDeclBlock(get_eh_region_tree_label(region)); //FIXME @@ -2111,10 +2168,10 @@ //FIXME UnwindBB = BasicBlock::Create(Context, "Unwind"); //FIXME Builder.CreateBr(UnwindBB); //FIXME } - +//FIXME //FIXME Handlers.clear(); - } -} +//FIXME } +//FIXME} /// EmitUnwindBlock - Emit the lazily created EH unwind block. void TreeToLLVM::EmitUnwindBlock() { @@ -2628,6 +2685,7 @@ Value *TreeToLLVM::EmitCallOf(Value *Callee, gimple stmt, const MemRef *DestLoc, const AttrListPtr &InPAL) { BasicBlock *LandingPad = 0; // Non-zero indicates an invoke. + int RegionNo = 0; // Non-zero if contained in an exception handling region. AttrListPtr PAL = InPAL; if (PAL.isEmpty() && isa(Callee)) @@ -2641,18 +2699,18 @@ if (!PAL.paramHasAttr(~0, Attribute::NoUnwind)) { // This call may throw. Determine if we need to generate // an invoke rather than a simple call. -//FIXME int RegionNo = lookup_stmt_eh_region(stmt); -//FIXME -//FIXME // Is the call contained in an exception handling region? -//FIXME if (RegionNo > 0) { -//FIXME // Are there any exception handlers for this region? -//FIXME if (can_throw_internal_1(RegionNo, false, false)) -//FIXME // There are - turn the call into an invoke. -//FIXME LandingPad = getLandingPad(RegionNo); -//FIXME else -//FIXME assert(can_throw_external_1(RegionNo, false, false) && -//FIXME "Must-not-throw region handled by runtime?"); -//FIXME } + RegionNo = lookup_stmt_eh_lp(stmt); + + // Is the call in an exception handling region with a landing pad? + if (RegionNo > 0) { + // Generate an invoke, with the GCC landing pad as the unwind destination. + // The destination may change to an LLVM only landing pad, which precedes + // the GCC one, after phi nodes have been populated (doing things this way + // simplifies the generation of phi nodes). + eh_landing_pad lp = get_eh_landing_pad_from_number(RegionNo); + assert(lp && "Post landing pad not found!"); + LandingPad = getLabelDeclBlock(lp->post_landing_pad); + } } tree fndecl = gimple_call_fndecl(stmt); @@ -2768,6 +2826,16 @@ CallOperands.begin(), CallOperands.end()); cast(Call)->setCallingConv(CallingConvention); cast(Call)->setAttributes(PAL); + + // The invoke's destination may change to an LLVM only landing pad, which + // precedes the GCC one, after phi nodes have been populated (doing things + // this way simplifies the generation of phi nodes). Record the invoke as + // well as the GCC exception handling region. + assert(RegionNo > 0 && "Invoke but no GCC landing pad?"); + if ((unsigned)RegionNo >= Invokes.size()) + Invokes.resize(RegionNo + 1); + Invokes[RegionNo].push_back(cast(Call)); + BeginBlock(NextBlock); } Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=99996&r1=99995&r2=99996&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Wed Mar 31 00:50:36 2010 @@ -424,14 +424,11 @@ //===---------------------- Exception Handling --------------------------===// - /// LandingPads - The landing pad for a given EH region. - IndexedMap LandingPads; - - /// PostPads - The post landing pad for a given EH region. - IndexedMap PostPads; + /// Invokes - The list of invoke instructions for a given EH region. + SmallVector, 16> Invokes; /// ExceptionPtrs - The local holding the exception pointer for a EH region. - IndexedMap ExceptionPtrs; + SmallVector ExceptionPtrs; /// FuncEHException - Function used to receive the exception. Function *FuncEHException; @@ -554,9 +551,6 @@ /// EmitLandingPads - Emit EH landing pads. void EmitLandingPads(); - /// EmitPostPads - Emit EH post landing pads. - void EmitPostPads(); - /// EmitUnwindBlock - Emit the lazily created EH unwind block. void EmitUnwindBlock(); @@ -574,10 +568,6 @@ /// region, creating it if necessary. BasicBlock *getLandingPad(unsigned RegionNo); - /// getPostPad - Return the post landing pad for the given exception handling - /// region, creating it if necessary. - BasicBlock *getPostPad(unsigned RegionNo); - /// getExceptionPtr - Return the local holding the exception pointer for the /// given exception handling region, creating it if necessary. AllocaInst *getExceptionPtr(unsigned RegionNo); From sabre at nondot.org Wed Mar 31 00:53:47 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 05:53:47 -0000 Subject: [llvm-commits] [llvm] r99997 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <20100331055347.90BDF2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 00:53:47 2010 New Revision: 99997 URL: http://llvm.org/viewvc/llvm-project?rev=99997&view=rev Log: microoptimize this hot method, also making it more consistent with other similar ones. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=99997&r1=99996&r2=99997&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Mar 31 00:53:47 2010 @@ -96,9 +96,8 @@ if (DbgNode == 0) return DIDescriptor(); - if (Elt < DbgNode->getNumOperands() && DbgNode->getOperand(Elt)) - return DIDescriptor(dyn_cast(DbgNode->getOperand(Elt))); - + if (Elt < DbgNode->getNumOperands()) + return DIDescriptor(dyn_cast_or_null(DbgNode->getOperand(Elt))); return DIDescriptor(); } From sabre at nondot.org Wed Mar 31 01:06:37 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 06:06:37 -0000 Subject: [llvm-commits] [llvm] r99998 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100331060637.7D60D2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 01:06:37 2010 New Revision: 99998 URL: http://llvm.org/viewvc/llvm-project?rev=99998&view=rev Log: tidy up 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=99998&r1=99997&r2=99998&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 01:06:37 2010 @@ -692,9 +692,9 @@ } // Get the offsets for the forwarding field and the variable field. - unsigned int forwardingFieldOffset = + unsigned forwardingFieldOffset = DIDerivedType(forwardingField.getNode()).getOffsetInBits() >> 3; - unsigned int varFieldOffset = + unsigned varFieldOffset = DIDerivedType(varField.getNode()).getOffsetInBits() >> 3; // Decode the original location, and use that as the start of the byref @@ -1525,7 +1525,8 @@ } else { MachineLocation Location; unsigned FrameReg; - int Offset = RI->getFrameIndexReference(*MF, DV->getFrameIndex(), FrameReg); + int Offset = RI->getFrameIndexReference(*MF, DV->getFrameIndex(), + FrameReg); Location.set(FrameReg, Offset); if (VD.hasComplexAddress()) @@ -1609,7 +1610,7 @@ /// source file names. If none currently exists, create a new id and insert it /// in the SourceIds map. This can update DirectoryNames and SourceFileNames /// maps as well. -unsigned DwarfDebug::GetOrCreateSourceID(StringRef DirName, StringRef FileName) { +unsigned DwarfDebug::GetOrCreateSourceID(StringRef DirName, StringRef FileName){ unsigned DId; StringMap::iterator DI = DirectoryIdMap.find(DirName); if (DI != DirectoryIdMap.end()) { @@ -1722,8 +1723,8 @@ DIDescriptor GVContext = DI_GV.getContext(); // Do not create specification DIE if context is either compile unit // or a subprogram. - if (DI_GV.isDefinition() && !GVContext.isCompileUnit() - && !GVContext.isFile() && !GVContext.isSubprogram()) { + if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && + !GVContext.isFile() && !GVContext.isSubprogram()) { // Create specification DIE. DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, @@ -1871,7 +1872,7 @@ if (!NDie) continue; addDIEEntry(SPDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); // FIXME - This is not the correct approach. - // addDIEEntry(NDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie); + //addDIEEntry(NDie, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, NDie } // Standard sections final addresses. From sabre at nondot.org Wed Mar 31 01:09:04 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 06:09:04 -0000 Subject: [llvm-commits] [llvm] r99999 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Message-ID: <20100331060904.CD95B2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 01:09:04 2010 New Revision: 99999 URL: http://llvm.org/viewvc/llvm-project?rev=99999&view=rev Log: reduce indentation Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=99999&r1=99998&r2=99999&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Wed Mar 31 01:09:04 2010 @@ -419,23 +419,24 @@ for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) { const MachineOperand &MO = MI->getOperand(I); - if (MO.isGlobal()) { - if (Function *F = dyn_cast(MO.getGlobal())) { - if (SawFunc) { - // Be conservative. If we have more than one function operand for this - // call, then we can't make the assumption that it's the callee and - // not a parameter to the call. - // - // FIXME: Determine if there's a way to say that `F' is the callee or - // parameter. - MarkedNoUnwind = false; - break; - } - - MarkedNoUnwind = F->doesNotThrow(); - SawFunc = true; - } + if (!MO.isGlobal()) continue; + + Function *F = dyn_cast(MO.getGlobal()); + if (F == 0) continue; + + if (SawFunc) { + // Be conservative. If we have more than one function operand for this + // call, then we can't make the assumption that it's the callee and + // not a parameter to the call. + // + // FIXME: Determine if there's a way to say that `F' is the callee or + // parameter. + MarkedNoUnwind = false; + break; } + + MarkedNoUnwind = F->doesNotThrow(); + SawFunc = true; } return MarkedNoUnwind; @@ -504,7 +505,10 @@ LastLabel = LandingPad->EndLabels[P.RangeIndex]; assert(BeginLabel && LastLabel && "Invalid landing pad!"); - if (LandingPad->LandingPadLabel) { + if (!LandingPad->LandingPadLabel) { + // Create a gap. + PreviousIsInvoke = false; + } else { // This try-range is for an invoke. CallSiteEntry Site = { BeginLabel, @@ -536,9 +540,6 @@ CallSites[SiteNo - 1] = Site; } PreviousIsInvoke = true; - } else { - // Create a gap. - PreviousIsInvoke = false; } } } From sabre at nondot.org Wed Mar 31 01:09:32 2010 From: sabre at nondot.org (Chris Lattner) Date: Wed, 31 Mar 2010 06:09:32 -0000 Subject: [llvm-commits] [www] r100000 - /www/trunk/index.html Message-ID: <20100331060932.A0F2A2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 01:09:32 2010 New Revision: 100000 URL: http://llvm.org/viewvc/llvm-project?rev=100000&view=rev Log: r100000, patch by coppro on irc. Modified: www/trunk/index.html Modified: www/trunk/index.html URL: http://llvm.org/viewvc/llvm-project/www/trunk/index.html?rev=100000&r1=99999&r2=100000&view=diff ============================================================================== --- www/trunk/index.html (original) +++ www/trunk/index.html Wed Mar 31 01:09:32 2010 @@ -137,6 +137,17 @@
    +
    LLVM Reaches 100,000 Revisions!
    + +
    +

    The 100,000th revision was committed to the + repository on March + 30, 2010. There was much rejoicing.

    +
    + +
    + +
From clattner at apple.com Wed Mar 31 01:11:55 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 30 Mar 2010 23:11:55 -0700 Subject: [llvm-commits] [llvm] r99928 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <4BB2DE93.5070607@free.fr> References: <20100330205557.B1D5A2A6C12C@llvm.org> <4BB2D980.4010309@free.fr> <3ED1D34B-674B-47E4-93EA-DFB5E2CC7319@apple.com> <4BB2DE93.5070607@free.fr> Message-ID: On Mar 30, 2010, at 10:33 PM, Duncan Sands wrote: > Hi Chris, > >>> I'm trying to imagine situations in which a volatile mem* call is useful, but I >>> didn't come up with anything very convincing yet. Can you please explain what >>> you have in mind. >> >> volatile struct foo X, Y; >> >> X = Y; >> >> Should lower to a 'volatile memcpy'. > > shouldn't it load to a series of field by field volatile copies? Not if it is large. C doesn't specify what to do here. -Chris From stoklund at 2pi.dk Wed Mar 31 01:34:35 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 30 Mar 2010 23:34:35 -0700 Subject: [llvm-commits] [www] r100000 - /www/trunk/index.html In-Reply-To: <20100331060932.A0F2A2A6C12C@llvm.org> References: <20100331060932.A0F2A2A6C12C@llvm.org> Message-ID: <13DC7737-6E4B-4393-AB77-3750630FA273@2pi.dk> Happy odometer event! Sent from my iPod On Mar 30, 2010, at 11:09 PM, Chris Lattner wrote: > Author: lattner > Date: Wed Mar 31 01:09:32 2010 > New Revision: 100000 > > URL: http://llvm.org/viewvc/llvm-project?rev=100000&view=rev > Log: > r100000, patch by coppro on irc. > > > Modified: > www/trunk/index.html > > Modified: www/trunk/index.html > URL: http://llvm.org/viewvc/llvm-project/www/trunk/index.html?rev=100000&r1=99999&r2=100000&view=diff > === > === > === > ===================================================================== > --- www/trunk/index.html (original) > +++ www/trunk/index.html Wed Mar 31 01:09:32 2010 > @@ -137,6 +137,17 @@ > >
> > +
LLVM Reaches 100,000 Revisions!
> + > +
> +

The 100,000th revision was committed to the > + repository > on March > + 30, 2010. There was much rejoicing.

> +
> + > +
> + > + > > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Wed Mar 31 02:50:17 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 31 Mar 2010 07:50:17 -0000 Subject: [llvm-commits] [llvm] r100001 - /llvm/trunk/docs/SourceLevelDebugging.html Message-ID: <20100331075018.0105B2A6C12D@llvm.org> Author: nicholas Date: Wed Mar 31 02:50:17 2010 New Revision: 100001 URL: http://llvm.org/viewvc/llvm-project?rev=100001&view=rev Log: Small fixes to this documentation. Remove mention of uint/int type, fix typo in 'number'. Modified: llvm/trunk/docs/SourceLevelDebugging.html Modified: llvm/trunk/docs/SourceLevelDebugging.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/SourceLevelDebugging.html?rev=100001&r1=100000&r2=100001&view=diff ============================================================================== --- llvm/trunk/docs/SourceLevelDebugging.html (original) +++ llvm/trunk/docs/SourceLevelDebugging.html Wed Mar 31 02:50:17 2010 @@ -289,26 +289,25 @@ 0x1000.)

The fields of debug descriptors used internally by LLVM - are restricted to only the simple data types int, uint, - bool, float, double, mdstring and - mdnode.

+ are restricted to only the simple data types i32, i1, + float, double, mdstring and mdnode.

 !1 = metadata !{
-  uint,   ;; A tag
+  i32,   ;; A tag
   ...
 }
 

The first field of a descriptor is always an - uint containing a tag value identifying the content of the + i32 containing a tag value identifying the content of the descriptor. The remaining fields are specific to the descriptor. The values of tags are loosely bound to the tag values of DWARF information entries. However, that does not restrict the use of the information supplied to DWARF targets. To facilitate versioning of debug information, the tag is augmented - with the current debug version (LLVMDebugVersion = 8 << 16 or 0x80000 or + with the current debug version (LLVMDebugVersion = 8 << 16 or 0x80000 or 524288.)

The details of the various descriptors follow.

@@ -829,8 +828,8 @@ rules.

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

+ llvm instructions to encode line number and scoping information. Consider + the following C fragment, for example:





From nicholas at mxc.ca  Wed Mar 31 03:11:39 2010
From: nicholas at mxc.ca (Nick Lewycky)
Date: Wed, 31 Mar 2010 01:11:39 -0700
Subject: [llvm-commits] [llvm] r99885 -
	/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
In-Reply-To: <20100330123158.C66242A6C12C@llvm.org>
References: <20100330123158.C66242A6C12C@llvm.org>
Message-ID: <4BB303BB.5050402@mxc.ca>

Torok Edwin wrote:
> Author: edwin
> Date: Tue Mar 30 07:31:58 2010
> New Revision: 99885
>
> URL: http://llvm.org/viewvc/llvm-project?rev=99885&view=rev
> Log:
> Honour addGlobalMapping() in the interpreter, if it was used to add mappings for
> external Functions (the JIT does honour this).
>
> Modified:
>      llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99885&r1=99884&r2=99885&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Mar 30 07:31:58 2010
> @@ -265,6 +265,7 @@
>     if (RF == RawFunctions->end()) {
>       RawFn = (RawFunc)(intptr_t)
>         sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
> +    RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);

What? Surely you meant:

   [...]
   RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);
   if (RawFn == 0)
     RawFn = (RawFunc)(intptr_t)
              sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
   [...]

right?

Nick

>       if (RawFn != 0)
>         RawFunctions->insert(std::make_pair(F, RawFn));  // Cache for later
>     } else {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



From nicholas at mxc.ca  Wed Mar 31 03:12:39 2010
From: nicholas at mxc.ca (Nick Lewycky)
Date: Wed, 31 Mar 2010 01:12:39 -0700
Subject: [llvm-commits] [llvm] r99886 -
	/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
In-Reply-To: <20100330125204.040E72A6C12C@llvm.org>
References: <20100330125204.040E72A6C12C@llvm.org>
Message-ID: <4BB303F7.4010106@mxc.ca>

Torok Edwin wrote:
> Author: edwin
> Date: Tue Mar 30 07:52:03 2010
> New Revision: 99886
>
> URL: http://llvm.org/viewvc/llvm-project?rev=99886&view=rev
> Log:
> Don't overwrite previous value, if it succeeded.
>
> Modified:
>      llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>
> Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99886&r1=99885&r2=99886&view=diff
> ==============================================================================
> --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original)
> +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Tue Mar 30 07:52:03 2010
> @@ -265,7 +265,8 @@
>     if (RF == RawFunctions->end()) {
>       RawFn = (RawFunc)(intptr_t)
>         sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
> -    RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);
> +    if (!RawnFn)
> +	RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);

Oh, I didn't see this commit before my last email :)

So, if I assign a value through addGlobalMapping, I really expect it to 
take precedence over calling dlsym.

Nick

>       if (RawFn != 0)
>         RawFunctions->insert(std::make_pair(F, RawFn));  // Cache for later
>     } else {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



From edwintorok at gmail.com  Wed Mar 31 07:05:15 2010
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Wed, 31 Mar 2010 15:05:15 +0300
Subject: [llvm-commits] [llvm] r99886 -
	/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
In-Reply-To: <4BB303F7.4010106@mxc.ca>
References: <20100330125204.040E72A6C12C@llvm.org> <4BB303F7.4010106@mxc.ca>
Message-ID: <4BB33A7B.6010000@gmail.com>

On 03/31/2010 11:12 AM, Nick Lewycky wrote:
> Torok Edwin wrote:
>> Author: edwin
>> Date: Tue Mar 30 07:52:03 2010
>> New Revision: 99886
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=99886&view=rev
>> Log:
>> Don't overwrite previous value, if it succeeded.
>>
>> Modified:
>>      llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>>
>> Modified:
>> llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=99886&r1=99885&r2=99886&view=diff
>>
>> ==============================================================================
>>
>> --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>> (original)
>> +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
>> Tue Mar 30 07:52:03 2010
>> @@ -265,7 +265,8 @@
>>     if (RF == RawFunctions->end()) {
>>       RawFn = (RawFunc)(intptr_t)
>>         sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
>> -    RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);
>> +    if (!RawnFn)
>> +    RawFn = (RawFunc)(intptr_t)getPointerToGlobalIfAvailable(F);
> 
> Oh, I didn't see this commit before my last email :)
> 
> So, if I assign a value through addGlobalMapping, I really expect it to
> take precedence over calling dlsym.

Right, I'll fix that soon.

Best regards,
--Edwin


From edwintorok at gmail.com  Wed Mar 31 07:07:16 2010
From: edwintorok at gmail.com (Torok Edwin)
Date: Wed, 31 Mar 2010 12:07:16 -0000
Subject: [llvm-commits] [llvm] r100003 -
	/llvm/trunk/lib/System/Win32/Signals.inc
Message-ID: <20100331120716.A9CE22A6C12C@llvm.org>

Author: edwin
Date: Wed Mar 31 07:07:16 2010
New Revision: 100003

URL: http://llvm.org/viewvc/llvm-project?rev=100003&view=rev
Log:
AddSignalHandler was not releasing the critical section on win32.
Patch from Gianluigi Tiesi!

Modified:
    llvm/trunk/lib/System/Win32/Signals.inc

Modified: llvm/trunk/lib/System/Win32/Signals.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/Signals.inc?rev=100003&r1=100002&r2=100003&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/Signals.inc (original)
+++ llvm/trunk/lib/System/Win32/Signals.inc Wed Mar 31 07:07:16 2010
@@ -163,6 +163,7 @@
     CallBacksToRun = new std::vector >();
   CallBacksToRun->push_back(std::make_pair(FnPtr, Cookie));
   RegisterHandler();
+  LeaveCriticalSection(&CriticalSection);
 }
 }
 




From edwintorok at gmail.com  Wed Mar 31 07:11:23 2010
From: edwintorok at gmail.com (=?UTF-8?B?VMO2csO2ayBFZHdpbg==?=)
Date: Wed, 31 Mar 2010 15:11:23 +0300
Subject: [llvm-commits] [patch] win32 - fix deadlock on ctrl + c handler
 when sys::AddSignalHandler is invoked
In-Reply-To: <4BB26814.90101@netfarm.it>
References: <4BB26814.90101@netfarm.it>
Message-ID: <4BB33BEB.4020507@gmail.com>

On 03/31/2010 12:07 AM, Gianluigi Tiesi wrote:
> Hi,
> 
> signal handling on win32 has a problem,
> the function sys::AddSignalHandler
> 
> calls RegisterHandler()
> 
> but then does not releases the critical section
> as stated in the function.
> 
> So if the program calls the function and the user
> press ctrl c, the program will not able to exit

Thanks, I applied your patch to both LLVM and ClamAV.

Best regards,
--Edwin


From edwintorok at gmail.com  Wed Mar 31 07:13:56 2010
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Wed, 31 Mar 2010 15:13:56 +0300
Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk:
 include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h
 lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp
 lib/Support/Allocator.cpp
In-Reply-To: <3197F787-B0C0-464A-B2DB-12B0D7972B21@apple.com>
References: <20100330111748.9148F2A6C12C@llvm.org>
	<3197F787-B0C0-464A-B2DB-12B0D7972B21@apple.com>
Message-ID: <4BB33C84.8020607@gmail.com>

On 03/30/2010 09:33 PM, Chris Lattner wrote:
> On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote:
> 
>> Author: edwin
>> Date: Tue Mar 30 06:17:48 2010
>> New Revision: 99883
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev
>> Log:
>> Reapply r99881 with some fixes: only call destructor in releaseMemory!
> 
> Edwin, this patch isn't safe at all.  What if you allocate different types in one bump pointer? 

Jakob and Benjamin have addressed that issue in r99919, I'll have a look
at that commit shortly.

> Please revert it.

Is r99919 unsafe too? I can revert both then.

Best regards,
--Edwin


From edwintorok at gmail.com  Wed Mar 31 07:15:08 2010
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Wed, 31 Mar 2010 15:15:08 +0300
Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk:
 include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h
 lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp
 lib/Support/Allocator.cpp
In-Reply-To: <09A2327E-E0FB-42A3-BF96-C1456D636699@apple.com>
References: <20100330111748.9148F2A6C12C@llvm.org>
	<09A2327E-E0FB-42A3-BF96-C1456D636699@apple.com>
Message-ID: <4BB33CCC.5090404@gmail.com>

On 03/30/2010 08:49 PM, Ted Kremenek wrote:
> Hi Edwin,
> 
> I'm now getting an "unused variable 'VNI'" warning, which is breaking my -Werror builds.  Can the declaration of 'VNI' be removed?

There were some more changes in r99919, I'll update my tree soon and see
where the warning is and fix it.

Best regards,
--Edwin


From edwintorok at gmail.com  Wed Mar 31 09:31:25 2010
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Wed, 31 Mar 2010 17:31:25 +0300
Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk:
 include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h
 lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp
 lib/Support/Allocator.cpp
In-Reply-To: <326FDA8E-4F4A-47AB-8B0F-50D1E3C988AF@2pi.dk>
References: <20100330111748.9148F2A6C12C@llvm.org>
	
	<4BB22B8B.7010002@gmail.com>
	<756DB20B-2E30-4EED-AF0F-3BA03743B535@2pi.dk>
	
	
	
	<326FDA8E-4F4A-47AB-8B0F-50D1E3C988AF@2pi.dk>
Message-ID: <4BB35CBD.8010706@gmail.com>

On 03/30/2010 11:20 PM, Jakob Stoklund Olesen wrote:
> On Mar 30, 2010, at 1:17 PM, Benjamin Kramer wrote:
> 
>> Fixed & Committed revision 99919.
> 
> Awesome, thanks!

Looks very nice, thanks!

Best regards,
--Edwin


From daniel at zuster.org  Wed Mar 31 10:52:07 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 15:52:07 -0000
Subject: [llvm-commits] [zorg] r100009 -
	/zorg/trunk/lnt/lnt/viewer/js/View2D.js
Message-ID: <20100331155207.8011C2A6C12C@llvm.org>

Author: ddunbar
Date: Wed Mar 31 10:52:07 2010
New Revision: 100009

URL: http://llvm.org/viewvc/llvm-project?rev=100009&view=rev
Log:
Tweak Y axis width.


Modified:
    zorg/trunk/lnt/lnt/viewer/js/View2D.js

Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/js/View2D.js?rev=100009&r1=100008&r2=100009&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/viewer/js/View2D.js (original)
+++ zorg/trunk/lnt/lnt/viewer/js/View2D.js Wed Mar 31 10:52:07 2010
@@ -782,7 +782,7 @@
         var gi = new Graph2D_GraphInfo();
 
         gi.xAxisH = 40;
-        gi.yAxisW = 40;
+        gi.yAxisW = 60;
 
         var min = null, max = null;
         for (var i = 0, e = this.plots.length; i != e; ++i) {




From benny.kra at googlemail.com  Wed Mar 31 11:04:26 2010
From: benny.kra at googlemail.com (Benjamin Kramer)
Date: Wed, 31 Mar 2010 16:04:26 -0000
Subject: [llvm-commits] [llvm] r100010 -
	/llvm/trunk/lib/VMCore/ValueSymbolTable.cpp
Message-ID: <20100331160426.C42AF2A6C12C@llvm.org>

Author: d0k
Date: Wed Mar 31 11:04:26 2010
New Revision: 100010

URL: http://llvm.org/viewvc/llvm-project?rev=100010&view=rev
Log:
Bump SmallString size a bit to avoid malloc trashing.

Modified:
    llvm/trunk/lib/VMCore/ValueSymbolTable.cpp

Modified: llvm/trunk/lib/VMCore/ValueSymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ValueSymbolTable.cpp?rev=100010&r1=100009&r2=100010&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ValueSymbolTable.cpp (original)
+++ llvm/trunk/lib/VMCore/ValueSymbolTable.cpp Wed Mar 31 11:04:26 2010
@@ -55,9 +55,7 @@
     raw_svector_ostream(UniqueName) << ++LastUnique;
 
     // Try insert the vmap entry with this suffix.
-    ValueName &NewName =
-      vmap.GetOrCreateValue(StringRef(UniqueName.data(),
-                                      UniqueName.size()));
+    ValueName &NewName = vmap.GetOrCreateValue(UniqueName);
     if (NewName.getValue() == 0) {
       // Newly inserted name.  Success!
       NewName.setValue(V);
@@ -88,7 +86,7 @@
   }
   
   // Otherwise, there is a naming conflict.  Rename this value.
-  SmallString<128> UniqueName(Name.begin(), Name.end());
+  SmallString<256> UniqueName(Name.begin(), Name.end());
   
   while (1) {
     // Trim any suffix off and append the next number.
@@ -96,9 +94,7 @@
     raw_svector_ostream(UniqueName) << ++LastUnique;
     
     // Try insert the vmap entry with this suffix.
-    ValueName &NewName =
-      vmap.GetOrCreateValue(StringRef(UniqueName.data(),
-                                      UniqueName.size()));
+    ValueName &NewName = vmap.GetOrCreateValue(UniqueName);
     if (NewName.getValue() == 0) {
       // Newly inserted name.  Success!
       NewName.setValue(V);




From benny.kra at googlemail.com  Wed Mar 31 11:06:22 2010
From: benny.kra at googlemail.com (Benjamin Kramer)
Date: Wed, 31 Mar 2010 16:06:22 -0000
Subject: [llvm-commits] [llvm] r100011 -
	/llvm/trunk/lib/Analysis/LoopPass.cpp
Message-ID: <20100331160622.B4EF32A6C12C@llvm.org>

Author: d0k
Date: Wed Mar 31 11:06:22 2010
New Revision: 100011

URL: http://llvm.org/viewvc/llvm-project?rev=100011&view=rev
Log:
s/getNameStr/getName/

Modified:
    llvm/trunk/lib/Analysis/LoopPass.cpp

Modified: llvm/trunk/lib/Analysis/LoopPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100011&r1=100010&r2=100011&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopPass.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopPass.cpp Wed Mar 31 11:06:22 2010
@@ -222,7 +222,7 @@
       LoopPass *P = (LoopPass*)getContainedPass(Index);
 
       dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG,
-                   CurrentLoop->getHeader()->getNameStr());
+                   CurrentLoop->getHeader()->getName());
       dumpRequiredSet(P);
 
       initializeAnalysisImpl(P);
@@ -237,7 +237,7 @@
       if (Changed)
         dumpPassInfo(P, MODIFICATION_MSG, ON_LOOP_MSG,
                      skipThisLoop ? "" :
-                                    CurrentLoop->getHeader()->getNameStr());
+                                    CurrentLoop->getHeader()->getName());
       dumpPreservedSet(P);
 
       if (!skipThisLoop) {
@@ -259,7 +259,7 @@
       recordAvailableAnalysis(P);
       removeDeadPasses(P,
                        skipThisLoop ? "" :
-                                      CurrentLoop->getHeader()->getNameStr(),
+                                      CurrentLoop->getHeader()->getName(),
                        ON_LOOP_MSG);
 
       if (skipThisLoop)




From daniel at zuster.org  Wed Mar 31 12:00:45 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 17:00:45 -0000
Subject: [llvm-commits] [compiler-rt] r100014 - in /compiler-rt/trunk/lib:
 absvdi2.c absvsi2.c absvti2.c addvdi3.c addvsi3.c addvti3.c clear_cache.c
 eprintf.c gcc_personality_v0.c int_lib.h mulvdi3.c mulvsi3.c mulvti3.c
 negvdi2.c negvsi2.c negvti2.c subvdi3.c subvsi3.c subvti3.c
 trampoline_setup.c
Message-ID: <20100331170045.A18AF2A6C12C@llvm.org>

Author: ddunbar
Date: Wed Mar 31 12:00:45 2010
New Revision: 100014

URL: http://llvm.org/viewvc/llvm-project?rev=100014&view=rev
Log:
Use a private compilerrt_abort() define instead of calling abort directly.
 - Fiddling with abort directly is annoying given the way we use system includes, although it would be nice to fix this so we could make sure calling abort directly is verboten.

Modified:
    compiler-rt/trunk/lib/absvdi2.c
    compiler-rt/trunk/lib/absvsi2.c
    compiler-rt/trunk/lib/absvti2.c
    compiler-rt/trunk/lib/addvdi3.c
    compiler-rt/trunk/lib/addvsi3.c
    compiler-rt/trunk/lib/addvti3.c
    compiler-rt/trunk/lib/clear_cache.c
    compiler-rt/trunk/lib/eprintf.c
    compiler-rt/trunk/lib/gcc_personality_v0.c
    compiler-rt/trunk/lib/int_lib.h
    compiler-rt/trunk/lib/mulvdi3.c
    compiler-rt/trunk/lib/mulvsi3.c
    compiler-rt/trunk/lib/mulvti3.c
    compiler-rt/trunk/lib/negvdi2.c
    compiler-rt/trunk/lib/negvsi2.c
    compiler-rt/trunk/lib/negvti2.c
    compiler-rt/trunk/lib/subvdi3.c
    compiler-rt/trunk/lib/subvsi3.c
    compiler-rt/trunk/lib/subvti3.c
    compiler-rt/trunk/lib/trampoline_setup.c

Modified: compiler-rt/trunk/lib/absvdi2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/absvdi2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/absvdi2.c (original)
+++ compiler-rt/trunk/lib/absvdi2.c Wed Mar 31 12:00:45 2010
@@ -24,7 +24,7 @@
 {
     const int N = (int)(sizeof(di_int) * CHAR_BIT);
     if (a == ((di_int)1 << (N-1)))
-        abort();
+        compilerrt_abort();
     const di_int t = a >> (N - 1);
     return (a ^ t) - t;
 }

Modified: compiler-rt/trunk/lib/absvsi2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/absvsi2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/absvsi2.c (original)
+++ compiler-rt/trunk/lib/absvsi2.c Wed Mar 31 12:00:45 2010
@@ -24,7 +24,7 @@
 {
     const int N = (int)(sizeof(si_int) * CHAR_BIT);
     if (a == (1 << (N-1)))
-        abort();
+        compilerrt_abort();
     const si_int t = a >> (N - 1);
     return (a ^ t) - t;
 }

Modified: compiler-rt/trunk/lib/absvti2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/absvti2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/absvti2.c (original)
+++ compiler-rt/trunk/lib/absvti2.c Wed Mar 31 12:00:45 2010
@@ -26,7 +26,7 @@
 {
     const int N = (int)(sizeof(ti_int) * CHAR_BIT);
     if (a == ((ti_int)1 << (N-1)))
-        abort();
+        compilerrt_abort();
     const ti_int s = a >> (N - 1);
     return (a ^ s) - s;
 }

Modified: compiler-rt/trunk/lib/addvdi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/addvdi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/addvdi3.c (original)
+++ compiler-rt/trunk/lib/addvdi3.c Wed Mar 31 12:00:45 2010
@@ -26,12 +26,12 @@
     if (b >= 0)
     {
         if (s < a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s >= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/addvsi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/addvsi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/addvsi3.c (original)
+++ compiler-rt/trunk/lib/addvsi3.c Wed Mar 31 12:00:45 2010
@@ -26,12 +26,12 @@
     if (b >= 0)
     {
         if (s < a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s >= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/addvti3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/addvti3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/addvti3.c (original)
+++ compiler-rt/trunk/lib/addvti3.c Wed Mar 31 12:00:45 2010
@@ -28,12 +28,12 @@
     if (b >= 0)
     {
         if (s < a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s >= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/clear_cache.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/clear_cache.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/clear_cache.c (original)
+++ compiler-rt/trunk/lib/clear_cache.c Wed Mar 31 12:00:45 2010
@@ -33,7 +33,7 @@
         /* On Darwin, sys_icache_invalidate() provides this functionality */
         sys_icache_invalidate(start, end-start);
     #else
-        abort();
+        compilerrt_abort();
     #endif
 #endif
 }

Modified: compiler-rt/trunk/lib/eprintf.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eprintf.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/eprintf.c (original)
+++ compiler-rt/trunk/lib/eprintf.c Wed Mar 31 12:00:45 2010
@@ -10,6 +10,7 @@
 
 
 
+#include "int_lib.h"
 #include 
 #include 
 
@@ -28,5 +29,5 @@
 {
 	fprintf(stderr, format, assertion_expression, line, file);
 	fflush(stderr);
-	abort();
+	compilerrt_abort();
 }

Modified: compiler-rt/trunk/lib/gcc_personality_v0.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gcc_personality_v0.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/gcc_personality_v0.c (original)
+++ compiler-rt/trunk/lib/gcc_personality_v0.c Wed Mar 31 12:00:45 2010
@@ -142,7 +142,7 @@
         case DW_EH_PE_sleb128:
         default:
             /* not supported */
-            abort();
+            compilerrt_abort();
             break;
     }
 
@@ -160,7 +160,7 @@
         case DW_EH_PE_aligned:
         default:
             /* not supported */
-            abort();
+            compilerrt_abort();
             break;
     }
 

Modified: compiler-rt/trunk/lib/int_lib.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_lib.h?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/int_lib.h (original)
+++ compiler-rt/trunk/lib/int_lib.h Wed Mar 31 12:00:45 2010
@@ -23,6 +23,8 @@
 #include "endianness.h"
 #include 
 
+#define compilerrt_abort() abort()
+
 #if !defined(INFINITY) && defined(HUGE_VAL)
 #define INFINITY HUGE_VAL
 #endif /* INFINITY */

Modified: compiler-rt/trunk/lib/mulvdi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulvdi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/mulvdi3.c (original)
+++ compiler-rt/trunk/lib/mulvdi3.c Wed Mar 31 12:00:45 2010
@@ -29,13 +29,13 @@
     {
         if (b == 0 || b == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     if (b == MIN)
     {
         if (a == 0 || a == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     di_int sa = a >> (N - 1);
     di_int abs_a = (a ^ sa) - sa;
@@ -46,12 +46,12 @@
     if (sa == sb)
     {
         if (abs_a > MAX / abs_b)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (abs_a > MIN / -abs_b)
-            abort();
+            compilerrt_abort();
     }
     return a * b;
 }

Modified: compiler-rt/trunk/lib/mulvsi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulvsi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/mulvsi3.c (original)
+++ compiler-rt/trunk/lib/mulvsi3.c Wed Mar 31 12:00:45 2010
@@ -29,13 +29,13 @@
     {
         if (b == 0 || b == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     if (b == MIN)
     {
         if (a == 0 || a == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     si_int sa = a >> (N - 1);
     si_int abs_a = (a ^ sa) - sa;
@@ -46,12 +46,12 @@
     if (sa == sb)
     {
         if (abs_a > MAX / abs_b)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (abs_a > MIN / -abs_b)
-            abort();
+            compilerrt_abort();
     }
     return a * b;
 }

Modified: compiler-rt/trunk/lib/mulvti3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/mulvti3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/mulvti3.c (original)
+++ compiler-rt/trunk/lib/mulvti3.c Wed Mar 31 12:00:45 2010
@@ -31,13 +31,13 @@
     {
         if (b == 0 || b == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     if (b == MIN)
     {
         if (a == 0 || a == 1)
             return a * b;
-        abort();
+        compilerrt_abort();
     }
     ti_int sa = a >> (N - 1);
     ti_int abs_a = (a ^ sa) - sa;
@@ -48,12 +48,12 @@
     if (sa == sb)
     {
         if (abs_a > MAX / abs_b)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (abs_a > MIN / -abs_b)
-            abort();
+            compilerrt_abort();
     }
     return a * b;
 }

Modified: compiler-rt/trunk/lib/negvdi2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/negvdi2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/negvdi2.c (original)
+++ compiler-rt/trunk/lib/negvdi2.c Wed Mar 31 12:00:45 2010
@@ -24,6 +24,6 @@
 {
     const di_int MIN = (di_int)1 << ((int)(sizeof(di_int) * CHAR_BIT)-1);
     if (a == MIN)
-        abort();
+        compilerrt_abort();
     return -a;
 }

Modified: compiler-rt/trunk/lib/negvsi2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/negvsi2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/negvsi2.c (original)
+++ compiler-rt/trunk/lib/negvsi2.c Wed Mar 31 12:00:45 2010
@@ -24,6 +24,6 @@
 {
     const si_int MIN = (si_int)1 << ((int)(sizeof(si_int) * CHAR_BIT)-1);
     if (a == MIN)
-        abort();
+        compilerrt_abort();
     return -a;
 }

Modified: compiler-rt/trunk/lib/negvti2.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/negvti2.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/negvti2.c (original)
+++ compiler-rt/trunk/lib/negvti2.c Wed Mar 31 12:00:45 2010
@@ -26,7 +26,7 @@
 {
     const ti_int MIN = (ti_int)1 << ((int)(sizeof(ti_int) * CHAR_BIT)-1);
     if (a == MIN)
-        abort();
+        compilerrt_abort();
     return -a;
 }
 

Modified: compiler-rt/trunk/lib/subvdi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/subvdi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/subvdi3.c (original)
+++ compiler-rt/trunk/lib/subvdi3.c Wed Mar 31 12:00:45 2010
@@ -26,12 +26,12 @@
     if (b >= 0)
     {
         if (s > a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s <= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/subvsi3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/subvsi3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/subvsi3.c (original)
+++ compiler-rt/trunk/lib/subvsi3.c Wed Mar 31 12:00:45 2010
@@ -26,12 +26,12 @@
     if (b >= 0)
     {
         if (s > a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s <= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/subvti3.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/subvti3.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/subvti3.c (original)
+++ compiler-rt/trunk/lib/subvti3.c Wed Mar 31 12:00:45 2010
@@ -28,12 +28,12 @@
     if (b >= 0)
     {
         if (s > a)
-            abort();
+            compilerrt_abort();
     }
     else
     {
         if (s <= a)
-            abort();
+            compilerrt_abort();
     }
     return s;
 }

Modified: compiler-rt/trunk/lib/trampoline_setup.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/trampoline_setup.c?rev=100014&r1=100013&r2=100014&view=diff
==============================================================================
--- compiler-rt/trunk/lib/trampoline_setup.c (original)
+++ compiler-rt/trunk/lib/trampoline_setup.c Wed Mar 31 12:00:45 2010
@@ -28,7 +28,7 @@
     /* should never happen, but if compiler did not allocate */
     /* enough space on stack for the trampoline, abort */
     if ( trampSizeAllocated < 40 )
-        abort();
+        compilerrt_abort();
     
     /* create trampoline */
     trampOnStack[0] = 0x7c0802a6;    /* mflr r0 */




From daniel at zuster.org  Wed Mar 31 12:00:49 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 17:00:49 -0000
Subject: [llvm-commits] [compiler-rt] r100015 - in /compiler-rt/trunk:
 Makefile lib/int_lib.h make/lib_info.mk make/platform/clang_darwin.mk
Message-ID: <20100331170049.2BFA82A6C12D@llvm.org>

Author: ddunbar
Date: Wed Mar 31 12:00:48 2010
New Revision: 100015

URL: http://llvm.org/viewvc/llvm-project?rev=100015&view=rev
Log:
Add new build option KERNEL_USE, which compiles with -mkernel and gets propogated to CFLAGS. Use this to call panic() instead of abort() when enabled.

Modified:
    compiler-rt/trunk/Makefile
    compiler-rt/trunk/lib/int_lib.h
    compiler-rt/trunk/make/lib_info.mk
    compiler-rt/trunk/make/platform/clang_darwin.mk

Modified: compiler-rt/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=100015&r1=100014&r2=100015&view=diff
==============================================================================
--- compiler-rt/trunk/Makefile (original)
+++ compiler-rt/trunk/Makefile Wed Mar 31 12:00:48 2010
@@ -206,10 +206,16 @@
 $(call Set,Tmp.Dependencies,$($(Tmp.SubDirKey).Dependencies))
 $(call Set,Tmp.CC,$(strip \
   $(call GetCNAVar,CC,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
+$(call Set,Tmp.KERNEL_USE,$(strip \
+  $(call GetCNAVar,KERNEL_USE,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
+$(call Set,Tmp.VISIBILITY_HIDDEN,$(strip \
+  $(call GetCNAVar,VISIBILITY_HIDDEN,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
 $(call Set,Tmp.CFLAGS,$(strip \
   $(if $(call IsDefined,$(Tmp.Key).UniversalArchs),-arch $(Tmp.Arch),)\
-  $(if $(call streq,$($(Tmp.Key).VISIBILITY_HIDDEN),1),\
+  $(if $(call streq,$(Tmp.VISIBILITY_HIDDEN),1),\
        -fvisibility=hidden -DVISIBILITY_HIDDEN,)\
+  $(if $(call streq,$(Tmp.KERNEL_USE),1),\
+       -mkernel -DKERNEL_USE,)\
   $(call GetCNAVar,CFLAGS,$(Tmp.Key),$(Tmp.Config),$(Tmp.Arch))))
 
 $(Tmp.ObjPath)/%.o: $(Tmp.SrcPath)/%.s $(Tmp.Dependencies) $(Tmp.ObjPath)/.dir

Modified: compiler-rt/trunk/lib/int_lib.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/int_lib.h?rev=100015&r1=100014&r2=100015&view=diff
==============================================================================
--- compiler-rt/trunk/lib/int_lib.h (original)
+++ compiler-rt/trunk/lib/int_lib.h Wed Mar 31 12:00:48 2010
@@ -23,7 +23,14 @@
 #include "endianness.h"
 #include 
 
+/* If compiling for kernel use, call panic() instead of abort(). */
+#ifdef KERNEL_USE
+extern void panic (const char *, ...);
+#define compilerrt_abort() \
+  panic("%s:%d: abort in %s", __FILE__, __LINE__, __FUNCTION__)
+#else
 #define compilerrt_abort() abort()
+#endif
 
 #if !defined(INFINITY) && defined(HUGE_VAL)
 #define INFINITY HUGE_VAL

Modified: compiler-rt/trunk/make/lib_info.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_info.mk?rev=100015&r1=100014&r2=100015&view=diff
==============================================================================
--- compiler-rt/trunk/make/lib_info.mk (original)
+++ compiler-rt/trunk/make/lib_info.mk Wed Mar 31 12:00:48 2010
@@ -47,4 +47,5 @@
 AvailableOptions := AR ARFLAGS \
                     CC CFLAGS FUNCTIONS OPTIMIZED \
                     RANLIB RANLIBFLAGS \
-                    VISIBILITY_HIDDEN
+                    VISIBILITY_HIDDEN \
+                    KERNEL_USE

Modified: compiler-rt/trunk/make/platform/clang_darwin.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=100015&r1=100014&r2=100015&view=diff
==============================================================================
--- compiler-rt/trunk/make/platform/clang_darwin.mk (original)
+++ compiler-rt/trunk/make/platform/clang_darwin.mk Wed Mar 31 12:00:48 2010
@@ -242,4 +242,6 @@
 FUNCTIONS.cc_kext.x86_64 := \
 	$(filter-out $(CCKEXT_MISSING_FUNCTIONS),$(FUNCTIONS.cc_kext.x86_64))
 
+KERNEL_USE.cc_kext := 1
+
 VISIBILITY_HIDDEN := 1




From stoklund at 2pi.dk  Wed Mar 31 12:13:16 2010
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Wed, 31 Mar 2010 17:13:16 -0000
Subject: [llvm-commits] [llvm] r100016 -
	/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
Message-ID: <20100331171316.73F042A6C12C@llvm.org>

Author: stoklund
Date: Wed Mar 31 12:13:16 2010
New Revision: 100016

URL: http://llvm.org/viewvc/llvm-project?rev=100016&view=rev
Log:
Fix PR6750. Don't try to merge a DomainValue with itself.

Modified:
    llvm/trunk/lib/Target/X86/SSEDomainFix.cpp

Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=100016&r1=100015&r2=100016&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original)
+++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Wed Mar 31 12:13:16 2010
@@ -261,6 +261,8 @@
 bool SSEDomainFixPass::Merge(DomainValue *A, DomainValue *B) {
   assert(!A->collapsed() && "Cannot merge into collapsed");
   assert(!B->collapsed() && "Cannot merge from collapsed");
+	if (A == B)
+    return true;
   if (!A->compat(B->Mask))
     return false;
   A->Mask &= B->Mask;




From edwintorok at gmail.com  Wed Mar 31 12:23:53 2010
From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=)
Date: Wed, 31 Mar 2010 20:23:53 +0300
Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk:
 include/llvm/CodeGen/LiveInterval.h include/llvm/Support/Allocator.h
 lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp
 lib/Support/Allocator.cpp
In-Reply-To: <4BB33CCC.5090404@gmail.com>
References: <20100330111748.9148F2A6C12C@llvm.org>
	<09A2327E-E0FB-42A3-BF96-C1456D636699@apple.com>
	<4BB33CCC.5090404@gmail.com>
Message-ID: <4BB38529.5080606@gmail.com>

On 03/31/2010 03:15 PM, T?r?k Edwin wrote:
> On 03/30/2010 08:49 PM, Ted Kremenek wrote:
>> Hi Edwin,
>>
>> I'm now getting an "unused variable 'VNI'" warning, which is breaking my -Werror builds.  Can the declaration of 'VNI' be removed?
> 
> There were some more changes in r99919, I'll update my tree soon and see
> where the warning is and fix it.

Hi Ted,

I don't see any warnings/errors in r100016, when built with
--enable-optimized and CXXFLAGS=-Werror

Do you still get the unused variable? Could you paste the full warning
please?

Best regards,
--Edwin


From clattner at apple.com  Wed Mar 31 13:01:41 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 11:01:41 -0700
Subject: [llvm-commits] [llvm] r99883 - in /llvm/trunk:
	include/llvm/CodeGen/LiveInterval.h
	include/llvm/Support/Allocator.h lib/CodeGen/LiveInterval.cpp
	lib/CodeGen/LiveIntervalAnalysis.cpp lib/Support/Allocator.cpp
In-Reply-To: <4BB33C84.8020607@gmail.com>
References: <20100330111748.9148F2A6C12C@llvm.org>
	<3197F787-B0C0-464A-B2DB-12B0D7972B21@apple.com>
	<4BB33C84.8020607@gmail.com>
Message-ID: <69A151AC-8ED1-43B2-BF29-96E1CD7CE934@apple.com>


On Mar 31, 2010, at 5:13 AM, T?r?k Edwin wrote:

> On 03/30/2010 09:33 PM, Chris Lattner wrote:
>> On Mar 30, 2010, at 4:17 AM, Torok Edwin wrote:
>> 
>>> Author: edwin
>>> Date: Tue Mar 30 06:17:48 2010
>>> New Revision: 99883
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=99883&view=rev
>>> Log:
>>> Reapply r99881 with some fixes: only call destructor in releaseMemory!
>> 
>> Edwin, this patch isn't safe at all.  What if you allocate different types in one bump pointer? 
> 
> Jakob and Benjamin have addressed that issue in r99919, I'll have a look
> at that commit shortly.
> 
>> Please revert it.
> 
> Is r99919 unsafe too? I can revert both then.

SpecificBumpAllocator seems right to me, thanks all!

-Chris


From clattner at apple.com  Wed Mar 31 13:07:43 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 11:07:43 -0700
Subject: [llvm-commits] [llvm] r99910 - in /llvm/trunk:
	include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrInfo.cpp
	lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp
	test/Bitcode/sse41_pmulld.ll test/Bitcode/sse41_pmulld.ll.bc
	test/CodeGen/X86/pmul.ll test/CodeGen/X86/pmulld.ll
In-Reply-To: <20100330184901.9CCA82A6C12C@llvm.org>
References: <20100330184901.9CCA82A6C12C@llvm.org>
Message-ID: <973DCAA6-E8DC-4A7E-A2F0-CC84B7781200@apple.com>


On Mar 30, 2010, at 11:49 AM, Eric Christopher wrote:

> Author: echristo
> Date: Tue Mar 30 13:49:01 2010
> New Revision: 99910
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=99910&view=rev
> Log:
> Remove the pmulld intrinsic and autoupdate it as a vector multiply.
> 
> Rewrite the pmulld patterns, and make sure that they fold in loads of
> arguments into the instruction.

Very nice Eric, thanks for doing this.  Please also make sure that llvm-gcc is doing the proper lowering of this builtin in llvm-i386.cpp

-Chris

> 
> Added:
>    llvm/trunk/test/Bitcode/sse41_pmulld.ll
>    llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc   (with props)
>    llvm/trunk/test/CodeGen/X86/pmulld.ll
> Modified:
>    llvm/trunk/include/llvm/IntrinsicsX86.td
>    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
>    llvm/trunk/lib/Target/X86/X86InstrSSE.td
>    llvm/trunk/lib/VMCore/AutoUpgrade.cpp
>    llvm/trunk/test/CodeGen/X86/pmul.ll
> 
> Modified: llvm/trunk/include/llvm/IntrinsicsX86.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=99910&r1=99909&r2=99910&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IntrinsicsX86.td (original)
> +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Mar 30 13:49:01 2010
> @@ -810,9 +810,6 @@
>   def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
>               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
>                         [IntrNoMem, Commutative]>;
> -  def int_x86_sse41_pmulld          : GCCBuiltin<"__builtin_ia32_pmulld128">,
> -              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
> -                        [IntrNoMem, Commutative]>;
> }
> 
> // Vector extract
> 
> Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=99910&r1=99909&r2=99910&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Tue Mar 30 13:49:01 2010
> @@ -597,7 +597,6 @@
>     { X86::PMULHUWrr,       X86::PMULHUWrm, 16 },
>     { X86::PMULHWrr,        X86::PMULHWrm, 16 },
>     { X86::PMULLDrr,        X86::PMULLDrm, 16 },
> -    { X86::PMULLDrr_int,    X86::PMULLDrm_int, 16 },
>     { X86::PMULLWrr,        X86::PMULLWrm, 16 },
>     { X86::PMULUDQrr,       X86::PMULUDQrm, 16 },
>     { X86::PORrr,           X86::PORrm, 16 },
> 
> Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=99910&r1=99909&r2=99910&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Mar 30 13:49:01 2010
> @@ -3448,8 +3448,28 @@
>                        OpSize;
>   }
> }
> -defm PMULLD       : SS41I_binop_patint<0x40, "pmulld", v4i32, mul,
> -                                       int_x86_sse41_pmulld, 1>;
> +
> +/// SS48I_binop_rm - Simple SSE41 binary operator.
> +let Constraints = "$src1 = $dst" in {
> +multiclass SS48I_binop_rm opc, string OpcodeStr, SDNode OpNode,
> +                        ValueType OpVT, bit Commutable = 0> {
> +  def rr : SS48I +                                 (ins VR128:$src1, VR128:$src2),
> +               !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
> +               [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]>,
> +               OpSize {
> +    let isCommutable = Commutable;
> +  }
> +  def rm : SS48I +                                 (ins VR128:$src1, i128mem:$src2),
> +               !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"),
> +               [(set VR128:$dst, (OpNode VR128:$src1,
> +                                  (bc_v4i32 (memopv2i64 addr:$src2))))]>,
> +               OpSize;
> +}
> +}
> +
> +defm PMULLD         : SS48I_binop_rm<0x40, "pmulld", mul, v4i32, 1>;
> 
> /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate
> let Constraints = "$src1 = $dst" in {
> 
> Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=99910&r1=99909&r2=99910&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original)
> +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Tue Mar 30 13:49:01 2010
> @@ -225,7 +225,12 @@
>       // Calls to these intrinsics are transformed into ShuffleVector's.
>       NewFn = 0;
>       return true;
> +    } else if (Name.compare(5, 16, "x86.sse41.pmulld", 16) == 0) {
> +      // Calls to these intrinsics are transformed into vector multiplies.
> +      NewFn = 0;
> +      return true;
>     }
> +    
> 
>     break;
>   }
> @@ -355,6 +360,18 @@
> 
>       //  Clean up the old call now that it has been completely upgraded.
>       CI->eraseFromParent();
> +    } else if (F->getName() == "llvm.x86.sse41.pmulld") {
> +      // Upgrade this set of intrinsics into vector multiplies.
> +      Instruction *Mul = BinaryOperator::CreateMul(CI->getOperand(1),
> +                                                   CI->getOperand(2),
> +                                                   CI->getName(),
> +                                                   CI);
> +      // Fix up all the uses with our new multiply.
> +      if (!CI->use_empty())
> +        CI->replaceAllUsesWith(Mul);
> +        
> +      // Remove upgraded multiply.
> +      CI->eraseFromParent();
>     } else {
>       llvm_unreachable("Unknown function for CallInst upgrade.");
>     }
> 
> Added: llvm/trunk/test/Bitcode/sse41_pmulld.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse41_pmulld.ll?rev=99910&view=auto
> ==============================================================================
> --- llvm/trunk/test/Bitcode/sse41_pmulld.ll (added)
> +++ llvm/trunk/test/Bitcode/sse41_pmulld.ll Tue Mar 30 13:49:01 2010
> @@ -0,0 +1,2 @@
> +; RUN: llvm-dis < %s.bc | not grep {i32 @llvm\\.pmulld}
> +; RUN: llvm-dis < %s.bc | grep mul
> \ No newline at end of file
> 
> Added: llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc?rev=99910&view=auto
> ==============================================================================
> Binary file - no diff available.
> 
> Propchange: llvm/trunk/test/Bitcode/sse41_pmulld.ll.bc
> ------------------------------------------------------------------------------
>    svn:mime-type = application/octet-stream
> 
> Modified: llvm/trunk/test/CodeGen/X86/pmul.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pmul.ll?rev=99910&r1=99909&r2=99910&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/pmul.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/pmul.ll Tue Mar 30 13:49:01 2010
> @@ -1,6 +1,6 @@
> ; RUN: llc < %s -march=x86 -mattr=sse41 -stack-alignment=16 > %t
> ; RUN: grep pmul %t | count 12
> -; RUN: grep mov %t | count 12
> +; RUN: grep mov %t | count 11
> 
> define <4 x i32> @a(<4 x i32> %i) nounwind  {
>         %A = mul <4 x i32> %i, < i32 117, i32 117, i32 117, i32 117 >
> 
> Added: llvm/trunk/test/CodeGen/X86/pmulld.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pmulld.ll?rev=99910&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/pmulld.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/pmulld.ll Tue Mar 30 13:49:01 2010
> @@ -0,0 +1,16 @@
> +; RUN: llc < %s -march=x86-64 -mattr=+sse41 -asm-verbose=0 | FileCheck %s
> +
> +define <4 x i32> @test1(<4 x i32> %A, <4 x i32> %B) nounwind {
> +; CHECK: test1:
> +; CHECK-NEXT: pmulld
> +  %C = mul <4 x i32> %A, %B
> +  ret <4 x i32> %C
> +}
> +
> +define <4 x i32> @test1a(<4 x i32> %A, <4 x i32> *%Bp) nounwind {
> +; CHECK: test1a:
> +; CHECK-NEXT: pmulld
> +  %B = load <4 x i32>* %Bp
> +  %C = mul <4 x i32> %A, %B
> +  ret <4 x i32> %C
> +}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




From echristo at apple.com  Wed Mar 31 13:08:21 2010
From: echristo at apple.com (Eric Christopher)
Date: Wed, 31 Mar 2010 11:08:21 -0700
Subject: [llvm-commits] [llvm] r99910 - in /llvm/trunk:
	include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrInfo.cpp
	lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp
	test/Bitcode/sse41_pmulld.ll test/Bitcode/sse41_pmulld.ll.bc
	test/CodeGen/X86/pmul.ll test/CodeGen/X86/pmulld.ll
In-Reply-To: <973DCAA6-E8DC-4A7E-A2F0-CC84B7781200@apple.com>
References: <20100330184901.9CCA82A6C12C@llvm.org>
	<973DCAA6-E8DC-4A7E-A2F0-CC84B7781200@apple.com>
Message-ID: <065E1E25-8BDC-4F1D-B3E6-F363A57A2F77@apple.com>


On Mar 31, 2010, at 11:07 AM, Chris Lattner wrote:

> Very nice Eric, thanks for doing this.  Please also make sure that llvm-gcc is doing the proper lowering of this builtin in llvm-i386.cpp

Yup. Did that on Friday :)

Thanks!

-eric


From clattner at apple.com  Wed Mar 31 13:08:44 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 11:08:44 -0700
Subject: [llvm-commits] [llvm] r99910 - in /llvm/trunk:
	include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrInfo.cpp
	lib/Target/X86/X86InstrSSE.td lib/VMCore/AutoUpgrade.cpp
	test/Bitcode/sse41_pmulld.ll test/Bitcode/sse41_pmulld.ll.bc
	test/CodeGen/X86/pmul.ll test/CodeGen/X86/pmulld.ll
In-Reply-To: <065E1E25-8BDC-4F1D-B3E6-F363A57A2F77@apple.com>
References: <20100330184901.9CCA82A6C12C@llvm.org>
	<973DCAA6-E8DC-4A7E-A2F0-CC84B7781200@apple.com>
	<065E1E25-8BDC-4F1D-B3E6-F363A57A2F77@apple.com>
Message-ID: <5AABEA56-CA9F-4EDB-9A95-4C7331BB8F15@apple.com>

great, thanks!

On Mar 31, 2010, at 11:08 AM, Eric Christopher wrote:

> 
> On Mar 31, 2010, at 11:07 AM, Chris Lattner wrote:
> 
>> Very nice Eric, thanks for doing this.  Please also make sure that llvm-gcc is doing the proper lowering of this builtin in llvm-i386.cpp
> 
> Yup. Did that on Friday :)
> 
> Thanks!
> 
> -eric




From clattner at apple.com  Wed Mar 31 13:16:01 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 11:16:01 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: <20100329232421.B9E1B2A6C12C@llvm.org>
References: <20100329232421.B9E1B2A6C12C@llvm.org>
Message-ID: 

Hey Jakob,

Can this use the normal bump pointer + recycler interface?

-Chris

On Mar 29, 2010, at 4:24 PM, Jakob Stoklund Olesen wrote:

> +++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Mon Mar 29 18:24:21 2010
> @@ -29,12 +29,108 @@
> using namespace llvm;
> 
> namespace {
> +
> +/// Allocate objects from a pool, allow objects to be recycled, and provide a
> +/// way of deleting everything.
> +template
> +class PoolAllocator {
> +  std::vector Pages, Avail;
> +public:
> +  ~PoolAllocator() { Clear(); }
> +
> +  T* Alloc() {
> +    if (Avail.empty()) {
> +      T *p = new T[PageSize];
> +      Pages.push_back(p);
> +      Avail.reserve(PageSize);
> +      for (unsigned n = 0; n != PageSize; ++n)
> +        Avail.push_back(p+n);
> +    }
> +    T *p = Avail.back();
> +    Avail.pop_back();
> +    return p;
> +  }
> +
> +  // Allow object to be reallocated. It won't be reconstructed.
> +  void Recycle(T *p) {
> +    p->clear();
> +    Avail.push_back(p);
> +  }
> +
> +  // Destroy all objects, make sure there are no external pointers to them.
> +  void Clear() {
> +    Avail.clear();
> +    while (!Pages.empty()) {
> +      delete[] Pages.back();
> +      Pages.pop_back();
> +    }
> +  }
> +};




From stoklund at 2pi.dk  Wed Mar 31 13:32:23 2010
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Wed, 31 Mar 2010 11:32:23 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: 
References: <20100329232421.B9E1B2A6C12C@llvm.org>
	
Message-ID: 


On Mar 31, 2010, at 11:16 AM, Chris Lattner wrote:

> Hey Jakob,
> 
> Can this use the normal bump pointer + recycler interface?


I didn't even know we had a recycler!

I was planning to move it to the new SpecificBumpPtrAllocator, I need to be able to run a destructor on all objects allocated.

It is easier to just destroy everything when you're done rather than untangling the data structures to make sure objects are only deallocated once.

/jakob




From baldrick at free.fr  Wed Mar 31 13:41:26 2010
From: baldrick at free.fr (Duncan Sands)
Date: Wed, 31 Mar 2010 20:41:26 +0200
Subject: [llvm-commits] [llvm] r100016
	-	/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
In-Reply-To: <20100331171316.73F042A6C12C@llvm.org>
References: <20100331171316.73F042A6C12C@llvm.org>
Message-ID: <4BB39756.9070406@free.fr>

Hi Jakob, thanks for fixing this.

>     assert(!A->collapsed()&&  "Cannot merge into collapsed");
>     assert(!B->collapsed()&&  "Cannot merge from collapsed");
> +	if (A == B)
> +    return true;

This is oddly indented.  The first added line indents using a tab stop.

Ciao,

Duncan.


From isanbard at gmail.com  Wed Mar 31 13:47:10 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 31 Mar 2010 18:47:10 -0000
Subject: [llvm-commits] [llvm] r100031 - in /llvm/trunk/lib/Target:
 ARM/AsmPrinter/ARMAsmPrinter.cpp PowerPC/AsmPrinter/PPCAsmPrinter.cpp
Message-ID: <20100331184710.5FFDA2A6C12C@llvm.org>

Author: void
Date: Wed Mar 31 13:47:10 2010
New Revision: 100031

URL: http://llvm.org/viewvc/llvm-project?rev=100031&view=rev
Log:
Comment the changes for r98218 and friends inside the source code.

Modified:
    llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
    llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp

Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp?rev=100031&r1=100030&r2=100031&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp Wed Mar 31 13:47:10 2010
@@ -1132,6 +1132,11 @@
           OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
         else
           // Internal to current translation unit.
+          //
+          // When we place the LSDA into the TEXT section, the type info pointers
+          // need to be indirect and pc-rel. We accomplish this by using NLPs.
+          // However, sometimes the types are local to the file. So we need to
+          // fill in the value for the NLP in those cases.
           OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
                                                         OutContext),
                                 4/*size*/, 0/*addrspace*/);

Modified: llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp?rev=100031&r1=100030&r2=100031&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp Wed Mar 31 13:47:10 2010
@@ -811,6 +811,11 @@
         OutStreamer.EmitIntValue(0, isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);
       else
         // Internal to current translation unit.
+        //
+        // When we place the LSDA into the TEXT section, the type info pointers
+        // need to be indirect and pc-rel. We accomplish this by using NLPs.
+        // However, sometimes the types are local to the file. So we need to
+        // fill in the value for the NLP in those cases.
         OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
                                                       OutContext),
                               isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);




From daniel at zuster.org  Wed Mar 31 13:48:43 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 18:48:43 -0000
Subject: [llvm-commits] [llvm] r100032 -
	/llvm/trunk/utils/lit/lit/TestRunner.py
Message-ID: <20100331184843.85E6E2A6C12C@llvm.org>

Author: ddunbar
Date: Wed Mar 31 13:48:43 2010
New Revision: 100032

URL: http://llvm.org/viewvc/llvm-project?rev=100032&view=rev
Log:
lit: Make sure to close any files we open as part of redirection.

PR6753.

Modified:
    llvm/trunk/utils/lit/lit/TestRunner.py

Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=100032&r1=100031&r2=100032&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Wed Mar 31 13:48:43 2010
@@ -63,6 +63,7 @@
     procs = []
     input = subprocess.PIPE
     stderrTempFiles = []
+    opened_files = []
     # To avoid deadlock, we use a single stderr stream for piped
     # output. This is null until we have seen some output using
     # stderr.
@@ -115,6 +116,7 @@
                     # Workaround a Win32 and/or subprocess bug when appending.
                     if r[1] == 'a':
                         r[2].seek(0, 2)
+                    opened_files.append(r[2])
                 result = r[2]
             final_redirects.append(result)
 
@@ -176,7 +178,7 @@
         else:
             err = ''
         procData[i] = (out,err)
-        
+
     # Read stderr out of the temp files.
     for i,f in stderrTempFiles:
         f.seek(0, 0)
@@ -199,6 +201,10 @@
         else:
             exitCode = res
 
+    # Explicitly close any redirected files.
+    for f in opened_files:
+        f.close()
+
     if cmd.negate:
         exitCode = not exitCode
 




From isanbard at gmail.com  Wed Mar 31 13:48:59 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 31 Mar 2010 18:48:59 -0000
Subject: [llvm-commits] [llvm] r100033 -
	/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
Message-ID: <20100331184859.1F7EE2A6C12C@llvm.org>

Author: void
Date: Wed Mar 31 13:48:58 2010
New Revision: 100033

URL: http://llvm.org/viewvc/llvm-project?rev=100033&view=rev
Log:
Comment the changes for r98218 and friends inside the source code.

Modified:
    llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp?rev=100033&r1=100032&r2=100033&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp Wed Mar 31 13:48:58 2010
@@ -524,6 +524,11 @@
           OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
         else
           // Internal to current translation unit.
+          //
+          // When we place the LSDA into the TEXT section, the type info
+          // pointers need to be indirect and pc-rel. We accomplish this by
+          // using NLPs.  However, sometimes the types are local to the file. So
+          // we need to fill in the value for the NLP in those cases.
           OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
                                                         OutContext),
                                 4/*size*/, 0/*addrspace*/);




From clattner at apple.com  Wed Mar 31 14:01:20 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 12:01:20 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: 
References: <20100329232421.B9E1B2A6C12C@llvm.org>
	
	
Message-ID: <288A05DC-9B23-4951-AF8D-33DA309590CE@apple.com>


On Mar 31, 2010, at 11:32 AM, Jakob Stoklund Olesen wrote:

> 
> On Mar 31, 2010, at 11:16 AM, Chris Lattner wrote:
> 
>> Hey Jakob,
>> 
>> Can this use the normal bump pointer + recycler interface?
> 
> 
> I didn't even know we had a recycler!
> 
> I was planning to move it to the new SpecificBumpPtrAllocator, I need to be able to run a destructor on all objects allocated.
> 
> It is easier to just destroy everything when you're done rather than untangling the data structures to make sure objects are only deallocated once.

Ok!

-Chris


From daniel at zuster.org  Wed Mar 31 14:14:05 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 19:14:05 -0000
Subject: [llvm-commits] [llvm] r100034 -
	/llvm/trunk/utils/lit/lit/TestRunner.py
Message-ID: <20100331191405.58F632A6C12C@llvm.org>

Author: ddunbar
Date: Wed Mar 31 14:14:05 2010
New Revision: 100034

URL: http://llvm.org/viewvc/llvm-project?rev=100034&view=rev
Log:
Add a FIXME.

Modified:
    llvm/trunk/utils/lit/lit/TestRunner.py

Modified: llvm/trunk/utils/lit/lit/TestRunner.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=100034&r1=100033&r2=100034&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestRunner.py (original)
+++ llvm/trunk/utils/lit/lit/TestRunner.py Wed Mar 31 14:14:05 2010
@@ -114,6 +114,8 @@
                     else:
                         r[2] = open(r[0], r[1])
                     # Workaround a Win32 and/or subprocess bug when appending.
+                    #
+                    # FIXME: Actually, this is probably an instance of PR6753.
                     if r[1] == 'a':
                         r[2].seek(0, 2)
                     opened_files.append(r[2])




From benny.kra at googlemail.com  Wed Mar 31 14:34:01 2010
From: benny.kra at googlemail.com (Benjamin Kramer)
Date: Wed, 31 Mar 2010 19:34:01 -0000
Subject: [llvm-commits] [llvm] r100035 - in
 /llvm/trunk/lib/CodeGen/AsmPrinter: DIE.cpp DIE.h DwarfDebug.cpp
 DwarfDebug.h
Message-ID: <20100331193401.ED1D62A6C12C@llvm.org>

Author: d0k
Date: Wed Mar 31 14:34:01 2010
New Revision: 100035

URL: http://llvm.org/viewvc/llvm-project?rev=100035&view=rev
Log:
DwarfDebug: Allocate DIEValues with a BumpPtrAllocator. Most of them are
POD-like anyway, so we don't even care about calling their d'tors (DIEBlock
being the exception).

~6% less mallocs and ~1% compile time improvement on clang -O0 -g oggenc.c


Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp?rev=100035&r1=100034&r2=100035&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.cpp Wed Mar 31 14:34:01 2010
@@ -19,6 +19,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/Format.h"
@@ -114,8 +115,8 @@
 
 /// addSiblingOffset - Add a sibling offset field to the front of the DIE.
 ///
-DIEValue *DIE::addSiblingOffset() {
-  DIEInteger *DI = new DIEInteger(0);
+DIEValue *DIE::addSiblingOffset(BumpPtrAllocator &A) {
+  DIEInteger *DI = new (A) DIEInteger(0);
   Values.insert(Values.begin(), DI);
   Abbrev.AddFirstAttribute(dwarf::DW_AT_sibling, dwarf::DW_FORM_ref4);
   return DI;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h?rev=100035&r1=100034&r2=100035&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DIE.h Wed Mar 31 14:34:01 2010
@@ -174,7 +174,7 @@
     /// The caller is responsible for deleting the return value at or after the
     /// same time it destroys this DIE.
     ///
-    DIEValue *addSiblingOffset();
+    DIEValue *addSiblingOffset(BumpPtrAllocator &A);
 
     /// addChild - Add a child to the DIE.
     ///

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=100035&r1=100034&r2=100035&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 14:34:01 2010
@@ -301,15 +301,15 @@
 DwarfDebug::DwarfDebug(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T)
   : DwarfPrinter(OS, A, T), ModuleCU(0),
     AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
-    DIEValues(), SectionSourceLines(), didInitial(false), shouldEmit(false),
+    DIEBlocks(), SectionSourceLines(), didInitial(false), shouldEmit(false),
     CurrentFnDbgScope(0), PrevDILoc(0), DebugTimer(0) {
   NextStringPoolNumber = 0;
   if (TimePassesIsEnabled)
     DebugTimer = new Timer("Dwarf Debug Writer");
 }
 DwarfDebug::~DwarfDebug() {
-  for (unsigned j = 0, M = DIEValues.size(); j < M; ++j)
-    delete DIEValues[j];
+  for (unsigned j = 0, M = DIEBlocks.size(); j < M; ++j)
+    DIEBlocks[j]->~DIEBlock();
 
   delete DebugTimer;
 }
@@ -349,8 +349,7 @@
 /// createDIEEntry - Creates a new DIEEntry to be a proxy for a debug
 /// information entry.
 DIEEntry *DwarfDebug::createDIEEntry(DIE *Entry) {
-  DIEEntry *Value = new DIEEntry(Entry);
-  DIEValues.push_back(Value);
+  DIEEntry *Value = new (DIEValueAllocator) DIEEntry(Entry);
   return Value;
 }
 
@@ -359,8 +358,7 @@
 void DwarfDebug::addUInt(DIE *Die, unsigned Attribute,
                          unsigned Form, uint64_t Integer) {
   if (!Form) Form = DIEInteger::BestForm(false, Integer);
-  DIEValue *Value = new DIEInteger(Integer);
-  DIEValues.push_back(Value);
+  DIEValue *Value = new (DIEValueAllocator) DIEInteger(Integer);
   Die->addValue(Attribute, Form, Value);
 }
 
@@ -369,8 +367,7 @@
 void DwarfDebug::addSInt(DIE *Die, unsigned Attribute,
                          unsigned Form, int64_t Integer) {
   if (!Form) Form = DIEInteger::BestForm(true, Integer);
-  DIEValue *Value = new DIEInteger(Integer);
-  DIEValues.push_back(Value);
+  DIEValue *Value = new (DIEValueAllocator) DIEInteger(Integer);
   Die->addValue(Attribute, Form, Value);
 }
 
@@ -378,8 +375,7 @@
 /// keeps string reference. 
 void DwarfDebug::addString(DIE *Die, unsigned Attribute, unsigned Form,
                            StringRef String) {
-  DIEValue *Value = new DIEString(String);
-  DIEValues.push_back(Value);
+  DIEValue *Value = new (DIEValueAllocator) DIEString(String);
   Die->addValue(Attribute, Form, Value);
 }
 
@@ -387,8 +383,7 @@
 ///
 void DwarfDebug::addLabel(DIE *Die, unsigned Attribute, unsigned Form,
                           const MCSymbol *Label) {
-  DIEValue *Value = new DIELabel(Label);
-  DIEValues.push_back(Value);
+  DIEValue *Value = new (DIEValueAllocator) DIELabel(Label);
   Die->addValue(Attribute, Form, Value);
 }
 
@@ -396,8 +391,7 @@
 ///
 void DwarfDebug::addDelta(DIE *Die, unsigned Attribute, unsigned Form,
                           const MCSymbol *Hi, const MCSymbol *Lo) {
-  DIEValue *Value = new DIEDelta(Hi, Lo);
-  DIEValues.push_back(Value);
+  DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo);
   Die->addValue(Attribute, Form, Value);
 }
 
@@ -406,7 +400,7 @@
 void DwarfDebug::addBlock(DIE *Die, unsigned Attribute, unsigned Form,
                           DIEBlock *Block) {
   Block->ComputeSize(TD);
-  DIEValues.push_back(Block);
+  DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on.
   Die->addValue(Attribute, Block->BestForm(), Block);
 }
 
@@ -560,7 +554,7 @@
   // Decode the original location, and use that as the start of the byref
   // variable's location.
   unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
-  DIEBlock *Block = new DIEBlock();
+  DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
 
   if (Location.isReg()) {
     if (Reg < 32) {
@@ -700,7 +694,7 @@
   // Decode the original location, and use that as the start of the byref
   // variable's location.
   unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
-  DIEBlock *Block = new DIEBlock();
+  DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
 
   if (Location.isReg()) {
     if (Reg < 32)
@@ -755,7 +749,7 @@
 void DwarfDebug::addAddress(DIE *Die, unsigned Attribute,
                             const MachineLocation &Location) {
   unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false);
-  DIEBlock *Block = new DIEBlock();
+  DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
 
   if (Location.isReg()) {
     if (Reg < 32) {
@@ -1102,7 +1096,7 @@
 
   addSourceLine(MemberDie, &DT);
 
-  DIEBlock *MemLocationDie = new DIEBlock();
+  DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
   addUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
 
   uint64_t Size = DT.getSizeInBits();
@@ -1138,7 +1132,7 @@
     // expression to extract appropriate offset from vtable.
     // BaseAddr = ObAddr + *((*ObAddr) - Offset)
 
-    DIEBlock *VBaseLocationDie = new DIEBlock();
+    DIEBlock *VBaseLocationDie = new (DIEValueAllocator) DIEBlock();
     addUInt(VBaseLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_dup);
     addUInt(VBaseLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
     addUInt(VBaseLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
@@ -1204,7 +1198,7 @@
   unsigned VK = SP.getVirtuality();
   if (VK) {
     addUInt(SPDie, dwarf::DW_AT_virtuality, dwarf::DW_FORM_flag, VK);
-    DIEBlock *Block = new DIEBlock();
+    DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
     addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_constu);
     addUInt(Block, 0, dwarf::DW_FORM_data1, SP.getVirtualIndex());
     addBlock(SPDie, dwarf::DW_AT_vtable_elem_location, 0, Block);
@@ -1509,7 +1503,7 @@
                      VS);
         } else if (DbgValueInsn->getOperand(0).getType() == 
                    MachineOperand::MO_Immediate) {
-          DIEBlock *Block = new DIEBlock();
+          DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
           unsigned Imm = DbgValueInsn->getOperand(0).getImm();
           addUInt(Block, 0, dwarf::DW_FORM_udata, Imm);
           addBlock(VariableDie, dwarf::DW_AT_const_value, 0, Block);
@@ -1729,7 +1723,7 @@
     DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable);
     addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification,
                 dwarf::DW_FORM_ref4, VariableDie);
-    DIEBlock *Block = new DIEBlock();
+    DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
     addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
     addLabel(Block, 0, dwarf::DW_FORM_udata,
              Asm->Mang->getSymbol(DI_GV.getGlobal()));
@@ -1737,7 +1731,7 @@
     addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
     ModuleCU->addDie(VariableSpecDIE);
   } else {
-    DIEBlock *Block = new DIEBlock();
+    DIEBlock *Block = new (DIEValueAllocator) DIEBlock();
     addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr);
     addLabel(Block, 0, dwarf::DW_FORM_udata,
              Asm->Mang->getSymbol(DI_GV.getGlobal()));
@@ -2383,7 +2377,7 @@
 
   // If not last sibling and has children then add sibling offset attribute.
   if (!Last && !Children.empty())
-    DIEValues.push_back(Die->addSiblingOffset());
+    Die->addSiblingOffset(DIEValueAllocator);
 
   // Record the abbreviation.
   assignAbbrevNumber(Die->getAbbrev());

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=100035&r1=100034&r2=100035&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Mar 31 14:34:01 2010
@@ -19,6 +19,7 @@
 #include "llvm/CodeGen/AsmPrinter.h"
 #include "llvm/CodeGen/MachineLocation.h"
 #include "llvm/Analysis/DebugInfo.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FoldingSet.h"
@@ -98,9 +99,11 @@
   /// Lines - List of source line correspondence.
   std::vector Lines;
 
-  /// DIEValues - A list of all the unique values in use.
-  ///
-  std::vector DIEValues;
+  /// DIEBlocks - A list of all the DIEBlocks in use.
+  std::vector DIEBlocks;
+
+  // DIEValueAllocator - All DIEValues are allocated through this allocator.
+  BumpPtrAllocator DIEValueAllocator;
 
   /// StringPool - A String->Symbol mapping of strings used by indirect
   /// references.




From kledzik at apple.com  Wed Mar 31 14:52:01 2010
From: kledzik at apple.com (Nick Kledzik)
Date: Wed, 31 Mar 2010 19:52:01 -0000
Subject: [llvm-commits] [compiler-rt] r100036 -
	/compiler-rt/trunk/lib/enable_execute_stack.c
Message-ID: <20100331195201.586DD2A6C12C@llvm.org>

Author: kledzik
Date: Wed Mar 31 14:52:01 2010
New Revision: 100036

URL: http://llvm.org/viewvc/llvm-project?rev=100036&view=rev
Log:
 check enable_execute_stack implementation

Modified:
    compiler-rt/trunk/lib/enable_execute_stack.c

Modified: compiler-rt/trunk/lib/enable_execute_stack.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/enable_execute_stack.c?rev=100036&r1=100035&r2=100036&view=diff
==============================================================================
--- compiler-rt/trunk/lib/enable_execute_stack.c (original)
+++ compiler-rt/trunk/lib/enable_execute_stack.c Wed Mar 31 14:52:01 2010
@@ -21,6 +21,11 @@
 #include 
 #endif /* __APPLE__ */
 
+#if __LP64__
+	#define TRAMPOLINE_SIZE 48
+#else
+	#define TRAMPOLINE_SIZE 40
+#endif
 
 /*
  * The compiler generates calls to __enable_execute_stack() when creating 
@@ -45,7 +50,7 @@
 	const uintptr_t pageAlignMask = ~(pageSize-1);
 	uintptr_t p = (uintptr_t)addr;
 	unsigned char* startPage = (unsigned char*)(p & pageAlignMask);
-	unsigned char* endPage = (unsigned char*)((p+48+pageSize) & pageAlignMask);
+	unsigned char* endPage = (unsigned char*)((p+TRAMPOLINE_SIZE+pageSize) & pageAlignMask);
 	size_t length = endPage - startPage;
 	(void) mprotect((void *)startPage, length, PROT_READ | PROT_WRITE | PROT_EXEC);
 }




From stoklund at 2pi.dk  Wed Mar 31 15:05:13 2010
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Wed, 31 Mar 2010 20:05:13 -0000
Subject: [llvm-commits] [llvm] r100037 -
	/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
Message-ID: <20100331200513.2910C2A6C12C@llvm.org>

Author: stoklund
Date: Wed Mar 31 15:05:12 2010
New Revision: 100037

URL: http://llvm.org/viewvc/llvm-project?rev=100037&view=rev
Log:
Use spaces, not tabs

Modified:
    llvm/trunk/lib/Target/X86/SSEDomainFix.cpp

Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=100037&r1=100036&r2=100037&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original)
+++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Wed Mar 31 15:05:12 2010
@@ -261,7 +261,7 @@
 bool SSEDomainFixPass::Merge(DomainValue *A, DomainValue *B) {
   assert(!A->collapsed() && "Cannot merge into collapsed");
   assert(!B->collapsed() && "Cannot merge from collapsed");
-	if (A == B)
+  if (A == B)
     return true;
   if (!A->compat(B->Mask))
     return false;




From stoklund at 2pi.dk  Wed Mar 31 15:07:00 2010
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Wed, 31 Mar 2010 13:07:00 -0700
Subject: [llvm-commits] [llvm] r100016
	-	/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
In-Reply-To: <4BB39756.9070406@free.fr>
References: <20100331171316.73F042A6C12C@llvm.org> <4BB39756.9070406@free.fr>
Message-ID: <55890CC3-D146-4386-99CF-4CAD22CDF328@2pi.dk>


On Mar 31, 2010, at 11:41 AM, Duncan Sands wrote:

> Hi Jakob, thanks for fixing this.
> 
>>    assert(!A->collapsed()&&  "Cannot merge into collapsed");
>>    assert(!B->collapsed()&&  "Cannot merge from collapsed");
>> +	if (A == B)
>> +    return true;
> 
> This is oddly indented.  The first added line indents using a tab stop.

Fixed in r100037.

Thanks, Duncan!

/jakob



From clattner at apple.com  Wed Mar 31 15:07:44 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 13:07:44 -0700
Subject: [llvm-commits] [llvm] r100035 - in
	/llvm/trunk/lib/CodeGen/AsmPrinter: DIE.cpp DIE.h
	DwarfDebug.cpp DwarfDebug.h
In-Reply-To: <20100331193401.ED1D62A6C12C@llvm.org>
References: <20100331193401.ED1D62A6C12C@llvm.org>
Message-ID: <84D9C869-D323-40DA-AB19-F867FBC0B994@apple.com>


On Mar 31, 2010, at 12:34 PM, Benjamin Kramer wrote:

> Author: d0k
> Date: Wed Mar 31 14:34:01 2010
> New Revision: 100035
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=100035&view=rev
> Log:
> DwarfDebug: Allocate DIEValues with a BumpPtrAllocator. Most of them are
> POD-like anyway, so we don't even care about calling their d'tors (DIEBlock
> being the exception).
> 
> ~6% less mallocs and ~1% compile time improvement on clang -O0 -g oggenc.c

Awesome!



From benny.kra at googlemail.com  Wed Mar 31 15:15:45 2010
From: benny.kra at googlemail.com (Benjamin Kramer)
Date: Wed, 31 Mar 2010 20:15:45 -0000
Subject: [llvm-commits] [llvm] r100038 -
	/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Message-ID: <20100331201545.476722A6C12C@llvm.org>

Author: d0k
Date: Wed Mar 31 15:15:45 2010
New Revision: 100038

URL: http://llvm.org/viewvc/llvm-project?rev=100038&view=rev
Log:
Reduce string trashing.

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=100038&r1=100037&r2=100038&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 15:15:45 2010
@@ -92,11 +92,11 @@
 
   /// addGlobal - Add a new global entity to the compile unit.
   ///
-  void addGlobal(const std::string &Name, DIE *Die) { Globals[Name] = Die; }
+  void addGlobal(StringRef Name, DIE *Die) { Globals[Name] = Die; }
 
   /// addGlobalType - Add a new global type to the compile unit.
   ///
-  void addGlobalType(const std::string &Name, DIE *Die) { 
+  void addGlobalType(StringRef Name, DIE *Die) { 
     GlobalTypes[Name] = Die; 
   }
 




From sabre at nondot.org  Wed Mar 31 15:32:51 2010
From: sabre at nondot.org (Chris Lattner)
Date: Wed, 31 Mar 2010 20:32:51 -0000
Subject: [llvm-commits] [llvm] r100042 -
	/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
Message-ID: <20100331203251.78DBC2A6C12C@llvm.org>

Author: lattner
Date: Wed Mar 31 15:32:51 2010
New Revision: 100042

URL: http://llvm.org/viewvc/llvm-project?rev=100042&view=rev
Log:
reduce indentation, minor cleanups.

Modified:
    llvm/trunk/lib/Target/X86/SSEDomainFix.cpp

Modified: llvm/trunk/lib/Target/X86/SSEDomainFix.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/SSEDomainFix.cpp?rev=100042&r1=100041&r2=100042&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/SSEDomainFix.cpp (original)
+++ llvm/trunk/lib/Target/X86/SSEDomainFix.cpp Wed Mar 31 15:32:51 2010
@@ -25,7 +25,6 @@
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
-
 using namespace llvm;
 
 namespace {
@@ -67,7 +66,7 @@
   }
 };
 
-/// A DomainValue is a bit like LiveIntervals' ValNo, but it laso keeps track
+/// A DomainValue is a bit like LiveIntervals' ValNo, but it also keeps track
 /// of execution domains.
 ///
 /// An open DomainValue represents a set of instructions that can still switch
@@ -168,7 +167,6 @@
   void visitGenericInstr(MachineInstr*);
   void visitSoftInstr(MachineInstr*, unsigned mask);
   void visitHardInstr(MachineInstr*, unsigned domain);
-
 };
 }
 
@@ -286,22 +284,24 @@
       if (fi == LiveOuts.end()) continue;
       DomainValue *pdv = fi->second[rx];
       if (!pdv) continue;
-      if (!LiveRegs || !LiveRegs[rx])
+      if (!LiveRegs || !LiveRegs[rx]) {
         SetLiveReg(rx, pdv);
-      else {
-        // We have a live DomainValue from more than one predecessor.
-        if (LiveRegs[rx]->collapsed()) {
-          // We are already collapsed, but predecessor is not. Force him.
-          if (!pdv->collapsed())
-            Collapse(pdv, LiveRegs[rx]->firstDomain());
-        } else {
-          // Currently open, merge in predecessor.
-          if (!pdv->collapsed())
-            Merge(LiveRegs[rx], pdv);
-          else
-            Collapse(LiveRegs[rx], pdv->firstDomain());
-        }
+        continue;
+      }
+
+      // We have a live DomainValue from more than one predecessor.
+      if (LiveRegs[rx]->collapsed()) {
+        // We are already collapsed, but predecessor is not. Force him.
+        if (!pdv->collapsed())
+          Collapse(pdv, LiveRegs[rx]->firstDomain());
+        continue;
       }
+      
+      // Currently open, merge in predecessor.
+      if (!pdv->collapsed())
+        Merge(LiveRegs[rx], pdv);
+      else
+        Collapse(LiveRegs[rx], pdv->firstDomain());
     }
   }
 }
@@ -338,21 +338,21 @@
   if (LiveRegs)
     for (unsigned i = mi->getDesc().getNumDefs(),
                   e = mi->getDesc().getNumOperands(); i != e; ++i) {
-    MachineOperand &mo = mi->getOperand(i);
-    if (!mo.isReg()) continue;
-    int rx = RegIndex(mo.getReg());
-    if (rx < 0) continue;
-    if (DomainValue *dv = LiveRegs[rx]) {
-      // Is it possible to use this collapsed register for free?
-      if (dv->collapsed()) {
-        if (unsigned m = collmask & dv->Mask)
-          collmask = m;
-      } else if (dv->compat(collmask))
-        used.push_back(rx);
-      else
-        Kill(rx);
+      MachineOperand &mo = mi->getOperand(i);
+      if (!mo.isReg()) continue;
+      int rx = RegIndex(mo.getReg());
+      if (rx < 0) continue;
+      if (DomainValue *dv = LiveRegs[rx]) {
+        // Is it possible to use this collapsed register for free?
+        if (dv->collapsed()) {
+          if (unsigned m = collmask & dv->Mask)
+            collmask = m;
+        } else if (dv->compat(collmask))
+          used.push_back(rx);
+        else
+          Kill(rx);
+      }
     }
-  }
 
   // If the collapsed operands force a single domain, propagate the collapse.
   if (isPowerOf2_32(collmask)) {
@@ -392,13 +392,17 @@
   //  priority to the latest ones.
   DomainValue *dv = 0;
   while (!doms.empty()) {
-    if (!dv)
-      dv = doms.back();
-    else if (!Merge(dv, doms.back()))
-      for (SmallVector::iterator i=used.begin(), e=used.end(); i!=e; ++i)
-        if (LiveRegs[*i] == doms.back())
-          Kill(*i);
-    doms.pop_back();
+    if (!dv) {
+      dv = doms.pop_back_val();
+      continue;
+    }
+    
+    DomainValue *ThisDV = doms.pop_back_val();
+    if (Merge(dv, ThisDV)) continue;
+    
+    for (SmallVector::iterator i=used.begin(), e=used.end(); i != e; ++i)
+      if (LiveRegs[*i] == ThisDV)
+        Kill(*i);
   }
 
   // dv is the DomainValue we are going to use for this instruction.




From clattner at apple.com  Wed Mar 31 15:35:45 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 13:35:45 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: <20100329232421.B9E1B2A6C12C@llvm.org>
References: <20100329232421.B9E1B2A6C12C@llvm.org>
Message-ID: 

On Mar 29, 2010, at 4:24 PM, Jakob Stoklund Olesen wrote:
> Author: stoklund
> Date: Mon Mar 29 18:24:21 2010
> New Revision: 99848
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=99848&view=rev
> Log:
> Basic implementation of SSEDomainFix pass.

Nice!  Looking through the implementation in mainline, some random thoughts:

  // Available domains. For an open DomainValue, it is the still possible
  // domains for collapsing. For a collapsed DomainValue it is the domains where
  // the register is available for free.
  unsigned Mask;

Can this be named "AvailableDomains" or something?  Naming it mask is weird, particularly in:

 bool compat(unsigned mask) const {
   return Mask & mask;
 }

Also, is there a better/more abstract representation that you can give this mask?  There is all sorts of bit twiddling and other stuff happening to these bits which just look like magic operations scattered around the code.  Defining a class like:

class AvailableDomains {
  unsigned DomainMask;
public:
...
  unsigned getFirstDomain() const;


Please name the predicates in DomainValue something like "isCompatible", "isCollapsed", "getFirstDomain", etc, to make it more obvious at use sites that this is a predicate.  Please put DomainValue in an anonymous namespace.

General question: why use calloc/free instead of new[]/delete[]?

After this pass of changes is ready I'll take a closer look, thanks for working on this pass!

-Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/113129a4/attachment.html 

From ggreif at gmail.com  Wed Mar 31 15:37:13 2010
From: ggreif at gmail.com (Gabor Greif)
Date: Wed, 31 Mar 2010 20:37:13 -0000
Subject: [llvm-commits] [llvm] r100043 -
 /llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll
Message-ID: <20100331203713.346E72A6C12C@llvm.org>

Author: ggreif
Date: Wed Mar 31 15:37:13 2010
New Revision: 100043

URL: http://llvm.org/viewvc/llvm-project?rev=100043&view=rev
Log:
testcase for r99914, provided by baldrick!

Added:
    llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll

Added: llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll?rev=100043&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll (added)
+++ llvm/trunk/test/Transforms/SimplifyCFG/2010-03-30-InvokeCrash.ll Wed Mar 31 15:37:13 2010
@@ -0,0 +1,18 @@
+; RUN: opt %s -simplifycfg -disable-output
+; END.
+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"
+
+declare void @bar(i32)
+
+define void @foo() {
+entry:
+ invoke void @bar(i32 undef)
+         to label %r unwind label %u
+
+r:                                                ; preds = %entry
+ ret void
+
+u:                                                ; preds = %entry
+ unwind
+}




From dalej at apple.com  Wed Mar 31 15:37:15 2010
From: dalej at apple.com (Dale Johannesen)
Date: Wed, 31 Mar 2010 20:37:15 -0000
Subject: [llvm-commits] [llvm] r100044 -
	/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
Message-ID: <20100331203715.8FA112A6C12D@llvm.org>

Author: johannes
Date: Wed Mar 31 15:37:15 2010
New Revision: 100044

URL: http://llvm.org/viewvc/llvm-project?rev=100044&view=rev
Log:
Fix a nasty dangling-pointer heisenbug that could
generate wrong code pretty much anywhere AFAICT.
A case that hits the bug reproducibly is impossible,
but the situation was like this:
Addr = ...
Store -> Addr
Addr2 = GEP , 0, 0
Store -> Addr2
Handling the first store, the code changed replaced Addr
with a sunkaddr and deleted Addr, but not its table
entry.  Code in OptimizedBlock replaced Addr2 with a
bitcast; if that happened to reuse the memory of Addr,
the old table entry was erroneously found when handling
the second store.


Modified:
    llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=100044&r1=100043&r2=100044&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Mar 31 15:37:15 2010
@@ -714,8 +714,12 @@
 
   MemoryInst->replaceUsesOfWith(Addr, SunkAddr);
 
-  if (Addr->use_empty())
+  if (Addr->use_empty()) {
     RecursivelyDeleteTriviallyDeadInstructions(Addr);
+    // This address is now available for reassignment, so erase the table entry;
+    // we don't want to match some completely different instruction.
+    SunkAddrs[Addr] = 0;
+  }
   return true;
 }
 




From kledzik at apple.com  Wed Mar 31 15:38:57 2010
From: kledzik at apple.com (Nick Kledzik)
Date: Wed, 31 Mar 2010 20:38:57 -0000
Subject: [llvm-commits] [compiler-rt] r100045 - in /compiler-rt/trunk/make:
 AppleBI.mk platform/darwin_bni.mk
Message-ID: <20100331203857.5607F2A6C12C@llvm.org>

Author: kledzik
Date: Wed Mar 31 15:38:57 2010
New Revision: 100045

URL: http://llvm.org/viewvc/llvm-project?rev=100045&view=rev
Log:
 Move libcompiler_rt over to a dylib target for Libsystem

Modified:
    compiler-rt/trunk/make/AppleBI.mk
    compiler-rt/trunk/make/platform/darwin_bni.mk

Modified: compiler-rt/trunk/make/AppleBI.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/AppleBI.mk?rev=100045&r1=100044&r2=100045&view=diff
==============================================================================
--- compiler-rt/trunk/make/AppleBI.mk (original)
+++ compiler-rt/trunk/make/AppleBI.mk Wed Mar 31 15:38:57 2010
@@ -28,27 +28,25 @@
 
 
 # Copy results to DSTROOT.
-install:  $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a
-	mkdir -p $(DSTROOT)/usr/local/lib/system
-	cp $(SYMROOT)/usr/local/lib/system/libcompiler_rt.a \
-	   $(DSTROOT)/usr/local/lib/system/libcompiler_rt.a
-	cd $(DSTROOT)/usr/local/lib/system; \
-	ln -s libcompiler_rt.a libcompiler_rt_profile.a; \
-	ln -s libcompiler_rt.a libcompiler_rt_debug.a
-
-
-# Rule to make fat libcompiler_rt.a.
-$(SYMROOT)/usr/local/lib/system/libcompiler_rt.a : $(foreach arch,$(RC_ARCHS), \
-                                                    $(OBJROOT)/$(arch)-pruned.a)
-	mkdir -p $(SYMROOT)/usr/local/lib/system
+install:  $(SYMROOT)/libcompiler_rt.dylib
+	mkdir -p $(DSTROOT)/usr/lib/system
+	strip -S $(SYMROOT)/libcompiler_rt.dylib \
+	    -o $(DSTROOT)/usr/lib/system/libcompiler_rt.dylib
+	cd $(DSTROOT)/usr/lib/system; \
+	    ln -s libcompiler_rt.dylib libcompiler_rt_profile.dylib; \
+	    ln -s libcompiler_rt.dylib libcompiler_rt_debug.dylib
+
+# Rule to make each dylib slice
+$(OBJROOT)/libcompiler_rt-%.dylib : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
+	echo "const char vers[] = \"@(#) $(RC_ProjectName)-$(RC_ProjectSourceVersion)\"; " > $(OBJROOT)/version.c
+	cc $(OBJROOT)/version.c -arch $* -dynamiclib \
+	   -install_name /usr/lib/system/libcompiler_rt.dylib \
+	   -compatibility_version 1 -current_version $(RC_ProjectSourceVersion) \
+	   -nodefaultlibs -lSystem -umbrella System -dead_strip \
+	   -Wl,-force_load,$^ -o $@ 
+
+# Rule to make fat dylib
+$(SYMROOT)/libcompiler_rt.dylib: $(foreach arch,$(RC_ARCHS), \
+									$(OBJROOT)/libcompiler_rt-$(arch).dylib)
 	lipo -create $^ -o  $@
 
-
-# Rule to add project info so that "what /usr/lib/libSystem.B.dylib" will work.
-$(OBJROOT)/%-pruned.a : $(OBJROOT)/darwin_bni/Release/%/libcompiler_rt.a
-	mkdir -p $(OBJROOT)/$*.tmp
-	cd $(OBJROOT)/$*.tmp; \
-	/Developer/Makefiles/bin/version.pl $(RC_ProjectName) > $(OBJROOT)/version.c; \
-	gcc -arch $* -c ${OBJROOT}/version.c -o version.o; \
-	ar -x $<; \
-	libtool -static *.o -o $@

Modified: compiler-rt/trunk/make/platform/darwin_bni.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/darwin_bni.mk?rev=100045&r1=100044&r2=100045&view=diff
==============================================================================
--- compiler-rt/trunk/make/platform/darwin_bni.mk (original)
+++ compiler-rt/trunk/make/platform/darwin_bni.mk Wed Mar 31 15:38:57 2010
@@ -9,7 +9,7 @@
 UniversalArchs := $(RC_ARCHS)
 
 
-CFLAGS := -Wall -O3 -fomit-frame-pointer
+CFLAGS := -Wall -Os -fomit-frame-pointer -g
 
 
 FUNCTIONS := absvdi2 absvsi2 addvdi3 addvsi3 ashldi3 ashrdi3 \




From bob.wilson at apple.com  Wed Mar 31 15:51:00 2010
From: bob.wilson at apple.com (Bob Wilson)
Date: Wed, 31 Mar 2010 20:51:00 -0000
Subject: [llvm-commits] [llvm] r100047 - in /llvm/trunk:
 include/llvm/Transforms/Utils/SSAUpdater.h
 lib/Transforms/Utils/SSAUpdater.cpp
Message-ID: <20100331205100.52A912A6C12C@llvm.org>

Author: bwilson
Date: Wed Mar 31 15:51:00 2010
New Revision: 100047

URL: http://llvm.org/viewvc/llvm-project?rev=100047&view=rev
Log:
Rewrite part of the SSAUpdater to be more careful about inserting redundant
PHIs.  The previous algorithm was unable to reliably detect when existing
PHIs in a cycle can be reused.  I'm still working on reducing a testcase.
Radar 7711900.

Modified:
    llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h
    llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp

Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=100047&r1=100046&r2=100047&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original)
+++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Wed Mar 31 15:51:00 2010
@@ -27,22 +27,28 @@
 /// transformation wants to rewrite a set of uses of one value with uses of a
 /// set of values.
 class SSAUpdater {
+public:
+  class BBInfo;
+
+private:
   /// AvailableVals - This keeps track of which value to use on a per-block
-  /// basis.  When we insert PHI nodes, we keep track of them here.  We use
-  /// TrackingVH's for the value of the map because we RAUW PHI nodes when we
-  /// eliminate them, and want the TrackingVH's to track this.
-  //typedef DenseMap > AvailableValsTy;
+  /// basis.  When we insert PHI nodes, we keep track of them here.
+  //typedef DenseMap AvailableValsTy;
   void *AV;
 
   /// PrototypeValue is an arbitrary representative value, which we derive names
   /// and a type for PHI nodes.
   Value *PrototypeValue;
 
-  /// IncomingPredInfo - We use this as scratch space when doing our recursive
-  /// walk.  This should only be used in GetValueInBlockInternal, normally it
-  /// should be empty.
-  //std::vector > > IncomingPredInfo;
-  void *IPI;
+  /// BBMap - The GetValueAtEndOfBlock method maintains this mapping from
+  /// basic blocks to BBInfo structures.
+  /// typedef DenseMap BBMapTy;
+  void *BM;
+
+  /// Allocator - The GetValueAtEndOfBlock method uses this BumpPtrAllocator to
+  /// hold its internal data.  The allocator and its storage is created and
+  /// discarded for each invocation of GetValueAtEndOfBlock.
+  void *BPA;
 
   /// InsertedPHIs - If this is non-null, the SSAUpdater adds all PHI nodes that
   /// it creates to the vector.
@@ -99,6 +105,14 @@
 
 private:
   Value *GetValueAtEndOfBlockInternal(BasicBlock *BB);
+  void FindPHIPlacement(BasicBlock *BB, BBInfo *Info, bool &Changed,
+                        unsigned Counter);
+  void FindAvailableVal(BasicBlock *BB, BBInfo *Info, unsigned Counter);
+  void FindExistingPHI(BasicBlock *BB, BBInfo *Info);
+  bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val);
+  void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
+  void ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI);
+
   void operator=(const SSAUpdater&); // DO NOT IMPLEMENT
   SSAUpdater(const SSAUpdater&);     // DO NOT IMPLEMENT
 };

Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100047&r1=100046&r2=100047&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Wed Mar 31 15:51:00 2010
@@ -14,31 +14,82 @@
 #include "llvm/Transforms/Utils/SSAUpdater.h"
 #include "llvm/Instructions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/Support/AlignOf.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/CFG.h"
 #include "llvm/Support/Debug.h"
-#include "llvm/Support/ValueHandle.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-typedef DenseMap > AvailableValsTy;
-typedef std::vector > >
-                IncomingPredInfoTy;
+/// BBInfo - Per-basic block information used internally by SSAUpdater.
+/// The predecessors of each block are cached here since pred_iterator is
+/// slow and we need to iterate over the blocks at least a few times.
+class SSAUpdater::BBInfo {
+public:
+  Value *AvailableVal; // Value to use in this block.
+  BasicBlock *DefBB;   // Block that defines the available value.
+  unsigned NumPreds;   // Number of predecessor blocks.
+  BasicBlock **Preds;  // Array[NumPreds] of predecessor blocks.
+  unsigned Counter;    // Marker to identify blocks already visited.
+  PHINode *PHITag;     // Marker for existing PHIs that match.
+
+  BBInfo(BasicBlock *BB, Value *V, BumpPtrAllocator *Allocator);
+};
+typedef DenseMap BBMapTy;
+
+SSAUpdater::BBInfo::BBInfo(BasicBlock *BB, Value *V,
+                           BumpPtrAllocator *Allocator)
+  : AvailableVal(V), DefBB(0), NumPreds(0), Preds(0), Counter(0), PHITag(0) {
+  // If this block has a known value, don't bother finding its predecessors.
+  if (V) {
+    DefBB = BB;
+    return;
+  }
+
+  // We can get our predecessor info by walking the pred_iterator list, but it
+  // is relatively slow.  If we already have PHI nodes in this block, walk one
+  // of them to get the predecessor list instead.
+  if (PHINode *SomePhi = dyn_cast(BB->begin())) {
+    NumPreds = SomePhi->getNumIncomingValues();
+    Preds = static_cast
+      (Allocator->Allocate(NumPreds * sizeof(BasicBlock*),
+                           AlignOf::Alignment));
+    for (unsigned pi = 0; pi != NumPreds; ++pi)
+      Preds[pi] = SomePhi->getIncomingBlock(pi);
+    return;
+  }
+
+  // Stash the predecessors in a temporary vector until we know how much space
+  // to allocate for them.
+  SmallVector TmpPreds;
+  for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
+    TmpPreds.push_back(*PI);
+    ++NumPreds;
+  } 
+  Preds = static_cast
+    (Allocator->Allocate(NumPreds * sizeof(BasicBlock*),
+                         AlignOf::Alignment));
+  memcpy(Preds, TmpPreds.data(), NumPreds * sizeof(BasicBlock*));
+}
 
+typedef DenseMap AvailableValsTy;
 static AvailableValsTy &getAvailableVals(void *AV) {
   return *static_cast(AV);
 }
 
-static IncomingPredInfoTy &getIncomingPredInfo(void *IPI) {
-  return *static_cast(IPI);
+static BBMapTy *getBBMap(void *BM) {
+  return static_cast(BM);
 }
 
+static BumpPtrAllocator *getAllocator(void *BPA) {
+  return static_cast(BPA);
+}
 
 SSAUpdater::SSAUpdater(SmallVectorImpl *NewPHI)
-  : AV(0), PrototypeValue(0), IPI(0), InsertedPHIs(NewPHI) {}
+  : AV(0), PrototypeValue(0), BM(0), BPA(0), InsertedPHIs(NewPHI) {}
 
 SSAUpdater::~SSAUpdater() {
   delete &getAvailableVals(AV);
-  delete &getIncomingPredInfo(IPI);
 }
 
 /// Initialize - Reset this object to get ready for a new set of SSA
@@ -48,11 +99,6 @@
     AV = new AvailableValsTy();
   else
     getAvailableVals(AV).clear();
-
-  if (IPI == 0)
-    IPI = new IncomingPredInfoTy();
-  else
-    getIncomingPredInfo(IPI).clear();
   PrototypeValue = ProtoValue;
 }
 
@@ -118,9 +164,9 @@
 /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is
 /// live at the end of the specified block.
 Value *SSAUpdater::GetValueAtEndOfBlock(BasicBlock *BB) {
-  assert(getIncomingPredInfo(IPI).empty() && "Unexpected Internal State");
+  assert(BM == 0 && BPA == 0 && "Unexpected Internal State");
   Value *Res = GetValueAtEndOfBlockInternal(BB);
-  assert(getIncomingPredInfo(IPI).empty() && "Unexpected Internal State");
+  assert(BM == 0 && BPA == 0 && "Unexpected Internal State");
   return Res;
 }
 
@@ -146,7 +192,7 @@
 Value *SSAUpdater::GetValueInMiddleOfBlock(BasicBlock *BB) {
   // If there is no definition of the renamed variable in this block, just use
   // GetValueAtEndOfBlock to do our work.
-  if (!getAvailableVals(AV).count(BB))
+  if (!HasValueForBlock(BB))
     return GetValueAtEndOfBlock(BB);
 
   // Otherwise, we have the hard case.  Get the live-in values for each
@@ -236,161 +282,228 @@
   U.set(V);
 }
 
-
 /// GetValueAtEndOfBlockInternal - Check to see if AvailableVals has an entry
 /// for the specified BB and if so, return it.  If not, construct SSA form by
-/// walking predecessors inserting PHI nodes as needed until we get to a block
-/// where the value is available.
-///
+/// first calculating the required placement of PHIs and then inserting new
+/// PHIs where needed.
 Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) {
   AvailableValsTy &AvailableVals = getAvailableVals(AV);
+  if (Value *V = AvailableVals[BB])
+    return V;
 
-  // Query AvailableVals by doing an insertion of null.
-  std::pair InsertRes =
-    AvailableVals.insert(std::make_pair(BB, TrackingVH()));
-
-  // Handle the case when the insertion fails because we have already seen BB.
-  if (!InsertRes.second) {
-    // If the insertion failed, there are two cases.  The first case is that the
-    // value is already available for the specified block.  If we get this, just
-    // return the value.
-    if (InsertRes.first->second != 0)
-      return InsertRes.first->second;
-
-    // Otherwise, if the value we find is null, then this is the value is not
-    // known but it is being computed elsewhere in our recursion.  This means
-    // that we have a cycle.  Handle this by inserting a PHI node and returning
-    // it.  When we get back to the first instance of the recursion we will fill
-    // in the PHI node.
-    return InsertRes.first->second =
-      PHINode::Create(PrototypeValue->getType(), PrototypeValue->getName(),
-                      &BB->front());
-  }
-
-  // Okay, the value isn't in the map and we just inserted a null in the entry
-  // to indicate that we're processing the block.  Since we have no idea what
-  // value is in this block, we have to recurse through our predecessors.
-  //
-  // While we're walking our predecessors, we keep track of them in a vector,
-  // then insert a PHI node in the end if we actually need one.  We could use a
-  // smallvector here, but that would take a lot of stack space for every level
-  // of the recursion, just use IncomingPredInfo as an explicit stack.
-  IncomingPredInfoTy &IncomingPredInfo = getIncomingPredInfo(IPI);
-  unsigned FirstPredInfoEntry = IncomingPredInfo.size();
-
-  // As we're walking the predecessors, keep track of whether they are all
-  // producing the same value.  If so, this value will capture it, if not, it
-  // will get reset to null.  We distinguish the no-predecessor case explicitly
-  // below.
-  TrackingVH ExistingValue;
-
-  // We can get our predecessor info by walking the pred_iterator list, but it
-  // is relatively slow.  If we already have PHI nodes in this block, walk one
-  // of them to get the predecessor list instead.
-  if (PHINode *SomePhi = dyn_cast(BB->begin())) {
-    for (unsigned i = 0, e = SomePhi->getNumIncomingValues(); i != e; ++i) {
-      BasicBlock *PredBB = SomePhi->getIncomingBlock(i);
-      Value *PredVal = GetValueAtEndOfBlockInternal(PredBB);
-      IncomingPredInfo.push_back(std::make_pair(PredBB, PredVal));
+  // Pool allocation used internally by GetValueAtEndOfBlock.
+  BumpPtrAllocator AllocatorObj;
+  BBMapTy BBMapObj;
+  BPA = &AllocatorObj;
+  BM = &BBMapObj;
+
+  BBInfo *Info = new (AllocatorObj) BBInfo(BB, 0, &AllocatorObj);
+  BBMapObj[BB] = Info;
+
+  bool Changed;
+  unsigned Counter = 1;
+  do {
+    Changed = false;
+    FindPHIPlacement(BB, Info, Changed, Counter);
+    ++Counter;
+  } while (Changed);
+
+  FindAvailableVal(BB, Info, Counter);
+
+  BPA = 0;
+  BM = 0;
+  return Info->AvailableVal;
+}
+
+/// FindPHIPlacement - Recursively visit the predecessors of a block to find
+/// the reaching definition for each predecessor and then determine whether
+/// a PHI is needed in this block.  
+void SSAUpdater::FindPHIPlacement(BasicBlock *BB, BBInfo *Info, bool &Changed,
+                                  unsigned Counter) {
+  AvailableValsTy &AvailableVals = getAvailableVals(AV);
+  BBMapTy *BBMap = getBBMap(BM);
+  BumpPtrAllocator *Allocator = getAllocator(BPA);
+  bool BBNeedsPHI = false;
+  BasicBlock *SamePredDefBB = 0;
+
+  // If there are no predecessors, then we must have found an unreachable
+  // block.  Treat it as a definition with 'undef'.
+  if (Info->NumPreds == 0) {
+    Info->AvailableVal = UndefValue::get(PrototypeValue->getType());
+    Info->DefBB = BB;
+    return;
+  }
 
-      // Set ExistingValue to singular value from all predecessors so far.
-      if (i == 0)
-        ExistingValue = PredVal;
-      else if (PredVal != ExistingValue)
-        ExistingValue = 0;
+  Info->Counter = Counter;
+  for (unsigned pi = 0; pi != Info->NumPreds; ++pi) {
+    BasicBlock *Pred = Info->Preds[pi];
+    BBMapTy::value_type &BBMapBucket = BBMap->FindAndConstruct(Pred);
+    if (!BBMapBucket.second) {
+      Value *PredVal = AvailableVals.lookup(Pred);
+      BBMapBucket.second = new (*Allocator) BBInfo(Pred, PredVal, Allocator);
     }
-  } else {
-    bool isFirstPred = true;
-    for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
-      BasicBlock *PredBB = *PI;
-      Value *PredVal = GetValueAtEndOfBlockInternal(PredBB);
-      IncomingPredInfo.push_back(std::make_pair(PredBB, PredVal));
+    BBInfo *PredInfo = BBMapBucket.second;
+    BasicBlock *DefBB = 0;
+    if (!PredInfo->AvailableVal) {
+      if (PredInfo->Counter != Counter)
+        FindPHIPlacement(Pred, PredInfo, Changed, Counter);
+
+      // Ignore back edges where the value is not yet known.
+      if (!PredInfo->DefBB)
+        continue;
+    }
+    DefBB = PredInfo->DefBB;
 
-      // Set ExistingValue to singular value from all predecessors so far.
-      if (isFirstPred) {
-        ExistingValue = PredVal;
-        isFirstPred = false;
-      } else if (PredVal != ExistingValue)
-        ExistingValue = 0;
+    if (!SamePredDefBB)
+      SamePredDefBB = DefBB;
+    else if (DefBB != SamePredDefBB)
+      BBNeedsPHI = true;
+  }
+
+  BasicBlock *NewDefBB = (BBNeedsPHI ? BB : SamePredDefBB);
+  if (Info->DefBB != NewDefBB) {
+    Changed = true;
+    Info->DefBB = NewDefBB;
+  }
+}
+
+/// FindAvailableVal - If this block requires a PHI, first check if an existing
+/// PHI matches the PHI placement and reaching definitions computed earlier,
+/// and if not, create a new PHI.  Visit all the block's predecessors to
+/// calculate the available value for each one and fill in the incoming values
+/// for a new PHI.
+void SSAUpdater::FindAvailableVal(BasicBlock *BB, BBInfo *Info,
+                                  unsigned Counter) {
+  if (Info->AvailableVal || Info->Counter == Counter)
+    return;
+
+  AvailableValsTy &AvailableVals = getAvailableVals(AV);
+  BBMapTy *BBMap = getBBMap(BM);
+
+  // Check if there needs to be a PHI in BB.
+  PHINode *NewPHI = 0;
+  if (Info->DefBB == BB) {
+    // Look for an existing PHI.
+    FindExistingPHI(BB, Info);
+    if (!Info->AvailableVal) {
+      NewPHI = PHINode::Create(PrototypeValue->getType(),
+                               PrototypeValue->getName(), &BB->front());
+      NewPHI->reserveOperandSpace(Info->NumPreds);
+      Info->AvailableVal = NewPHI;
+      AvailableVals[BB] = NewPHI;
     }
   }
 
-  // If there are no predecessors, then we must have found an unreachable block
-  // just return 'undef'.  Since there are no predecessors, InsertRes must not
-  // be invalidated.
-  if (IncomingPredInfo.size() == FirstPredInfoEntry)
-    return InsertRes.first->second = UndefValue::get(PrototypeValue->getType());
-
-  /// Look up BB's entry in AvailableVals.  'InsertRes' may be invalidated.  If
-  /// this block is involved in a loop, a no-entry PHI node will have been
-  /// inserted as InsertedVal.  Otherwise, we'll still have the null we inserted
-  /// above.
-  TrackingVH &InsertedVal = AvailableVals[BB];
-
-  // If the predecessor values are not all the same, then check to see if there
-  // is an existing PHI that can be used.
-  if (!ExistingValue)
-    ExistingValue = GetExistingPHI(BB,
-                                   IncomingPredInfo.begin()+FirstPredInfoEntry,
-                                   IncomingPredInfo.end());
-
-  // If there is an existing value we can use, then we don't need to insert a
-  // PHI.  This is the simple and common case.
-  if (ExistingValue) {
-    // If a PHI node got inserted, replace it with the existing value and delete
-    // it.
-    if (InsertedVal) {
-      PHINode *OldVal = cast(InsertedVal);
-      // Be careful about dead loops.  These RAUW's also update InsertedVal.
-      if (InsertedVal != ExistingValue)
-        OldVal->replaceAllUsesWith(ExistingValue);
-      else
-        OldVal->replaceAllUsesWith(UndefValue::get(InsertedVal->getType()));
-      OldVal->eraseFromParent();
-    } else {
-      InsertedVal = ExistingValue;
+  // Iterate through the block's predecessors.
+  Info->Counter = Counter;
+  for (unsigned pi = 0; pi != Info->NumPreds; ++pi) {
+    BasicBlock *Pred = Info->Preds[pi];
+    BBInfo *PredInfo = (*BBMap)[Pred];
+    FindAvailableVal(Pred, PredInfo, Counter);
+    if (NewPHI) {
+      // Skip to the nearest preceding definition.
+      if (PredInfo->DefBB != Pred)
+        PredInfo = (*BBMap)[PredInfo->DefBB];
+      NewPHI->addIncoming(PredInfo->AvailableVal, Pred);
+    } else if (!Info->AvailableVal)
+      Info->AvailableVal = PredInfo->AvailableVal;
+  }
+ 
+  if (NewPHI) {
+    DEBUG(dbgs() << "  Inserted PHI: " << *NewPHI << "\n");
+
+    // If the client wants to know about all new instructions, tell it.
+    if (InsertedPHIs) InsertedPHIs->push_back(NewPHI);
+  }
+}
+
+/// FindExistingPHI - Look through the PHI nodes in a block to see if any of
+/// them match what is needed.
+void SSAUpdater::FindExistingPHI(BasicBlock *BB, BBInfo *Info) {
+  PHINode *SomePHI;
+  for (BasicBlock::iterator It = BB->begin();
+       (SomePHI = dyn_cast(It)); ++It) {
+    if (CheckIfPHIMatches(BB, Info, SomePHI)) {
+      RecordMatchingPHI(BB, Info, SomePHI);
+      break;
     }
+    ClearPHITags(BB, Info, SomePHI);
+  }
+}
 
-    // Either path through the 'if' should have set InsertedVal -> ExistingVal.
-    assert((InsertedVal == ExistingValue || isa(InsertedVal)) &&
-           "RAUW didn't change InsertedVal to be ExistingValue");
-
-    // Drop the entries we added in IncomingPredInfo to restore the stack.
-    IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry,
-                           IncomingPredInfo.end());
-    return ExistingValue;
-  }
-
-  // Otherwise, we do need a PHI: insert one now if we don't already have one.
-  if (InsertedVal == 0)
-    InsertedVal = PHINode::Create(PrototypeValue->getType(),
-                                  PrototypeValue->getName(), &BB->front());
+/// CheckIfPHIMatches - Check if Val is a PHI node in block BB that matches
+/// the placement and values in the BBMap.
+bool SSAUpdater::CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val) {
+  if (Info->AvailableVal)
+    return Val == Info->AvailableVal;
+
+  // Check if Val is a PHI in this block.
+  PHINode *PHI = dyn_cast(Val);
+  if (!PHI || PHI->getParent() != BB)
+    return false;
 
-  PHINode *InsertedPHI = cast(InsertedVal);
-  InsertedPHI->reserveOperandSpace(IncomingPredInfo.size()-FirstPredInfoEntry);
+  // If this block has already been visited, check if this PHI matches.
+  if (Info->PHITag)
+    return PHI == Info->PHITag;
+  Info->PHITag = PHI;
+  bool IsMatch = true;
+
+  // Iterate through the predecessors.
+  BBMapTy *BBMap = getBBMap(BM);
+  for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
+    BasicBlock *Pred = PHI->getIncomingBlock(i);
+    Value *IncomingVal = PHI->getIncomingValue(i);
+    BBInfo *PredInfo = (*BBMap)[Pred];
+    // Skip to the nearest preceding definition.
+    if (PredInfo->DefBB != Pred) {
+      Pred = PredInfo->DefBB;
+      PredInfo = (*BBMap)[Pred];
+    }
+    if (!CheckIfPHIMatches(Pred, PredInfo, IncomingVal)) {
+      IsMatch = false;
+      break;
+    }
+  }
+  return IsMatch;
+}
 
-  // Fill in all the predecessors of the PHI.
-  for (IncomingPredInfoTy::iterator I =
-         IncomingPredInfo.begin()+FirstPredInfoEntry,
-       E = IncomingPredInfo.end(); I != E; ++I)
-    InsertedPHI->addIncoming(I->second, I->first);
-
-  // Drop the entries we added in IncomingPredInfo to restore the stack.
-  IncomingPredInfo.erase(IncomingPredInfo.begin()+FirstPredInfoEntry,
-                         IncomingPredInfo.end());
+/// RecordMatchingPHI - For a PHI node that matches, record it in both the
+/// BBMap and the AvailableVals mapping.  Recursively record its input PHIs
+/// as well.
+void SSAUpdater::RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
+  if (!Info || Info->AvailableVal)
+    return;
 
-  // See if the PHI node can be merged to a single value.  This can happen in
-  // loop cases when we get a PHI of itself and one other value.
-  if (Value *ConstVal = InsertedPHI->hasConstantValue()) {
-    InsertedPHI->replaceAllUsesWith(ConstVal);
-    InsertedPHI->eraseFromParent();
-    InsertedVal = ConstVal;
-  } else {
-    DEBUG(dbgs() << "  Inserted PHI: " << *InsertedPHI << "\n");
+  // Record the PHI.
+  AvailableValsTy &AvailableVals = getAvailableVals(AV);
+  AvailableVals[BB] = PHI;
+  Info->AvailableVal = PHI;
 
-    // If the client wants to know about all new instructions, tell it.
-    if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI);
+  // Iterate through the predecessors.
+  BBMapTy *BBMap = getBBMap(BM);
+  for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
+    PHINode *PHIVal = dyn_cast(PHI->getIncomingValue(i));
+    if (!PHIVal) continue;
+    BasicBlock *Pred = PHIVal->getParent();
+    RecordMatchingPHI(Pred, (*BBMap)[Pred], PHIVal);
   }
+}
 
-  return InsertedVal;
+/// ClearPHITags - When one of the existing PHI nodes fails to match, clear
+/// the PHITag values stored in the BBMap while checking to see if it matched.
+void SSAUpdater::ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI) {
+  if (!Info || Info->AvailableVal || !Info->PHITag)
+    return;
+
+  // Clear the tag.
+  Info->PHITag = 0;
+
+  // Iterate through the predecessors.
+  BBMapTy *BBMap = getBBMap(BM);
+  for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) {
+    PHINode *PHIVal = dyn_cast(PHI->getIncomingValue(i));
+    if (!PHIVal) continue;
+    BasicBlock *Pred = PHIVal->getParent();
+    ClearPHITags(Pred, (*BBMap)[Pred], PHIVal);
+  }
 }




From stoklund at 2pi.dk  Wed Mar 31 15:59:59 2010
From: stoklund at 2pi.dk (Jakob Stoklund Olesen)
Date: Wed, 31 Mar 2010 13:59:59 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: 
References: <20100329232421.B9E1B2A6C12C@llvm.org>
	
Message-ID: 


On Mar 31, 2010, at 1:35 PM, Chris Lattner wrote:

> On Mar 29, 2010, at 4:24 PM, Jakob Stoklund Olesen wrote:
>> Author: stoklund
>> Date: Mon Mar 29 18:24:21 2010
>> New Revision: 99848
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=99848&view=rev
>> Log:
>> Basic implementation of SSEDomainFix pass.
> 
> Nice!  Looking through the implementation in mainline, some random thoughts:
> 
>   // Available domains. For an open DomainValue, it is the still possible
>   // domains for collapsing. For a collapsed DomainValue it is the domains where
>   // the register is available for free.
>   unsigned Mask;
> 
> Can this be named "AvailableDomains" or something?  Naming it mask is weird, particularly in:
> 
>  bool compat(unsigned mask) const {
>    return Mask & mask;
>  }

Yes, fair enough.

> Also, is there a better/more abstract representation that you can give this mask?  There is all sorts of bit twiddling and other stuff happening to these bits which just look like magic operations scattered around the code.  Defining a class like:
> 
> class AvailableDomains {
>   unsigned DomainMask;
> public:
> ...
>   unsigned getFirstDomain() const;

Wrapping a bit mask in a class seems like overkill, but it is a good idea to gather all the bit twiddling in DomainValue methods.

> Please name the predicates in DomainValue something like "isCompatible", "isCollapsed", "getFirstDomain", etc, to make it more obvious at use sites that this is a predicate.

Sure.

>  Please put DomainValue in an anonymous namespace.

Everything already is. Should I open a new namespace per class to make it more obvious?

> General question: why use calloc/free instead of new[]/delete[]?

I started with "new DomainValue*[NumRegs]", but it didn't zero-init my pointers (?). I'll gladly use new[]+std::fill instead.

> After this pass of changes is ready I'll take a closer look, thanks for working on this pass!

Thanks, Chris!

/jakob




From stuart at apple.com  Wed Mar 31 16:10:54 2010
From: stuart at apple.com (Stuart Hastings)
Date: Wed, 31 Mar 2010 21:10:54 -0000
Subject: [llvm-commits] [llvm] r100048 - in
 /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h
Message-ID: <20100331211054.8B8CA2A6C12C@llvm.org>

Author: stuart
Date: Wed Mar 31 16:10:54 2010
New Revision: 100048

URL: http://llvm.org/viewvc/llvm-project?rev=100048&view=rev
Log:
Debug info can now properly represent functions inside classes inside other functions.  Partial fix for Radar 7424645.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=100048&r1=100047&r2=100048&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 16:10:54 2010
@@ -780,12 +780,26 @@
   } else if (Context.isNameSpace()) {
     DIE *ContextDIE = getOrCreateNameSpace(DINameSpace(Context.getNode()));
     ContextDIE->addChild(Die);
+  } else if (Context.isSubprogram()) {
+    DIE *ContextDIE = createSubprogramDIE(DISubprogram(Context.getNode()),
+                                          /*MakeDecl=*/false);
+    ContextDIE->addChild(Die);
   } else if (DIE *ContextDIE = ModuleCU->getDIE(Context.getNode()))
     ContextDIE->addChild(Die);
   else 
     ModuleCU->addDie(Die);
 }
 
+/// isFunctionContext - True if given Context is nested within a function. 
+bool DwarfDebug::isFunctionContext(DIE *context) {
+  if (context == (DIE *)0)
+    return false;
+  if (context->getTag() == dwarf::DW_TAG_subprogram)
+    return true;
+  else
+    return isFunctionContext(context->getParent());
+}
+
 /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
 /// given DIType.
 DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) {
@@ -967,6 +981,10 @@
     if (DIDescriptor(ContainingType.getNode()).isCompositeType())
       addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, 
                   getOrCreateTypeDIE(DIType(ContainingType.getNode())));
+    else {
+      DIDescriptor Context = CTy.getContext();
+      addToContextOwner(&Buffer, Context);
+    }
     break;
   }
   default:
@@ -1325,8 +1343,7 @@
  // function then gdb prefers the definition at top level and but does not
  // expect specification DIE in parent function. So avoid creating 
  // specification DIE for a function defined inside a function.
- if (SP.isDefinition() && !SP.getContext().isCompileUnit() &&
-     !SP.getContext().isFile() && !SP.getContext().isSubprogram()) {
+ if (SP.isDefinition() && !isFunctionContext(SPDie->getParent())) {
    addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
    
    // Add arguments. 
@@ -1754,19 +1771,15 @@
 void DwarfDebug::constructSubprogramDIE(MDNode *N) {
   DISubprogram SP(N);
 
-  // Check for pre-existence.
-  if (ModuleCU->getDIE(N))
-    return;
-
   if (!SP.isDefinition())
     // This is a method declaration which will be handled while constructing
     // class type.
     return;
 
-  DIE *SubprogramDie = createSubprogramDIE(SP);
-
-  // Add to map.
-  ModuleCU->insertDIE(N, SubprogramDie);
+  // Check for pre-existence.
+  DIE *SubprogramDie = ModuleCU->getDIE(N);
+  if (!SubprogramDie)
+    SubprogramDie = createSubprogramDIE(SP);
 
   // Add to context owner.
   addToContextOwner(SubprogramDie, SP.getContext());

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=100048&r1=100047&r2=100048&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Mar 31 16:10:54 2010
@@ -315,6 +315,9 @@
   /// addToContextOwner - Add Die into the list of its context owner's children.
   void addToContextOwner(DIE *Die, DIDescriptor Context);
 
+  /// isFunctionContext - True if given Context is nested within a function. 
+  bool isFunctionContext(DIE *context);
+
   /// addType - Add a new type attribute to the specified entity.
   void addType(DIE *Entity, DIType Ty);
 




From stuart at apple.com  Wed Mar 31 16:12:42 2010
From: stuart at apple.com (Stuart Hastings)
Date: Wed, 31 Mar 2010 21:12:42 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r100049 - in /llvm-gcc-4.2/trunk/gcc:
 llvm-backend.cpp llvm-convert.cpp llvm-debug.cpp llvm-debug.h
 llvm-internal.h
Message-ID: <20100331211242.7CCA82A6C12C@llvm.org>

Author: stuart
Date: Wed Mar 31 16:12:42 2010
New Revision: 100049

URL: http://llvm.org/viewvc/llvm-project?rev=100049&view=rev
Log:
Debug info can now properly represent functions inside classes inside other functions.  Partial fix for Radar 7424645.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.h
    llvm-gcc-4.2/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=100049&r1=100048&r2=100049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Mar 31 16:12:42 2010
@@ -512,6 +512,8 @@
   if (!flag_pch_file &&
       debug_info_level > DINFO_LEVEL_NONE)
     TheDebugInfo = new DebugInfo(TheModule);
+  else
+    TheDebugInfo = 0;
 }
 
 /// performLateBackendInitialization - Set backend options that may only be
@@ -533,8 +535,6 @@
 }
 
 void llvm_lang_dependent_init(const char *Name) {
-  if (TheDebugInfo)
-    TheDebugInfo->Initialize();
   if (Name)
     TheModule->setModuleIdentifier(Name);
 }
@@ -1010,7 +1010,7 @@
   // Convert the AST to raw/ugly LLVM code.
   Function *Fn;
   {
-    TreeToLLVM Emitter(fndecl);
+    TreeToLLVM *Emitter = getTreeToLLVM(fndecl);
     enum symbol_visibility vis = DECL_VISIBILITY (fndecl);
 
     if (vis != VISIBILITY_DEFAULT)
@@ -1018,7 +1018,7 @@
       // visibility that's not supported by the target.
       targetm.asm_out.visibility(fndecl, vis);
 
-    Fn = Emitter.EmitFunction();
+    Fn = Emitter->EmitFunction();
   }
 
 #if 0

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=100049&r1=100048&r2=100049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Mar 31 16:12:42 2010
@@ -148,7 +148,6 @@
 //===----------------------------------------------------------------------===//
 
 /// TheTreeToLLVM - Keep track of the current function being compiled.
-static TreeToLLVM *TheTreeToLLVM = 0;
 
 const TargetData &getTargetData() {
   return *TheTarget->getTargetData();
@@ -163,7 +162,7 @@
 }
 
 TreeToLLVM::TreeToLLVM(tree fndecl) :
-    TD(getTargetData()), Builder(Context, *TheFolder) {
+  TD(getTargetData()), Builder(Context, *TheFolder) {
   FnDecl = fndecl;
   Fn = 0;
   ReturnBB = UnwindBB = 0;
@@ -179,6 +178,7 @@
       TheDebugInfo->setLocationFile("");
       TheDebugInfo->setLocationLine(0);
     }
+    TheDebugInfo->Initialize();
   }
 
   AllocaInsertionPoint = 0;
@@ -188,13 +188,23 @@
   FuncEHException = 0;
   FuncEHSelector = 0;
   FuncEHGetTypeID = 0;
+}
+
+
+TreeToLLVM::~TreeToLLVM() {}
 
-  assert(TheTreeToLLVM == 0 && "Reentering function creation?");
-  TheTreeToLLVM = this;
+TreeToLLVM *getTreeToLLVM(tree fndecl) {
+  // FIXME: should this static move into the TreeToLLVM class decl?
+  static std::map FunctionMap;
+  TreeToLLVM *newTreeToLLVM = FunctionMap[fndecl];
+  if (!newTreeToLLVM)
+    newTreeToLLVM = FunctionMap[fndecl] = new TreeToLLVM(fndecl);
+  return newTreeToLLVM;
 }
 
-TreeToLLVM::~TreeToLLVM() {
-  TheTreeToLLVM = 0;
+TreeToLLVM *getCurrentTreeToLLVM(void) {
+  assert(current_function_decl && "no current_function_decl?");
+  return getTreeToLLVM(current_function_decl);
 }
 
 /// getLabelDeclBlock - Lazily get and create a basic block for the specified
@@ -308,7 +318,8 @@
       assert(TREE_CODE(TREE_TYPE(ResultDecl)) == REFERENCE_TYPE &&
              "Not type match and not passing by reference?");
       // Create an alloca for the ResultDecl.
-      Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
+      TreeToLLVM *Emitter = getCurrentTreeToLLVM();
+      Value *Tmp = Emitter->CreateTemporary(AI->getType());
       Builder.CreateStore(AI, Tmp);
 
       SET_DECL_LLVM(ResultDecl, Tmp);
@@ -451,7 +462,7 @@
   }
 }
 
-void TreeToLLVM::StartFunctionBody() {
+Function *TreeToLLVM::StartFunctionBody() {
   const char *Name = "";
   // Get the name of the function.
   if (tree ID = DECL_ASSEMBLER_NAME(FnDecl))
@@ -610,10 +621,10 @@
   // Set the BLOCK_NUMBER()s to the depth of each lexical block.
   setLexicalBlockDepths(FnDecl, block_declared_vars, 1);
 
-  SeenBlocks.clear();
-
-  if (EmitDebugInfo())
-    TheDebugInfo->EmitFunctionStart(FnDecl, Fn, Builder.GetInsertBlock());
+  if (TheDebugInfo) {
+    TheDebugInfo->EmitFunctionStart(FnDecl);
+    Builder.GetInsertBlock();
+  }
 
   // Loop over all of the arguments to the function, setting Argument names and
   // creating argument alloca's for the PARM_DECLs in case their address is
@@ -628,7 +639,7 @@
   ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl,
                                 DECL_BUILT_IN(FnDecl));
   // Remember this for use by FinishFunctionBody.
-  TheTreeToLLVM->ReturnOffset = Client.Offset;
+  ReturnOffset = Client.Offset;
 
   // Prepend the static chain (if any) to the list of arguments.
   tree Args = static_chain ? static_chain : DECL_ARGUMENTS(FnDecl);
@@ -709,12 +720,7 @@
         block_declared_vars.count(TREE_VALUE(t)) == 0)
       EmitAutomaticVariableDecl(TREE_VALUE(t));
   }
-
-  // Push the outermost lexical block onto the RegionStack.
-  switchLexicalBlock(DECL_INITIAL(FnDecl));
-
-  // Create a new block for the return node, but don't insert it yet.
-  ReturnBB = BasicBlock::Create(Context, "return");
+  return Fn;
 }
 
 Function *TreeToLLVM::FinishFunctionBody() {
@@ -802,9 +808,19 @@
 }
 
 Function *TreeToLLVM::EmitFunction() {
-  // Set up parameters and prepare for return, for the function.
+  // Set up parameters for the function.
   StartFunctionBody();
 
+  // We'll remember the lexical BLOCKs we've seen here.
+  SeenBlocks.clear();
+
+  // FIXME: Should these two statements move to StartFunctionBody() ?
+  // Push the outermost lexical block onto the RegionStack.
+  switchLexicalBlock(DECL_INITIAL(FnDecl));
+
+  // Create a new block for the return node, but don't insert it yet.
+  ReturnBB = BasicBlock::Create(Context, "return");
+
   // Emit the body of the function iterating over all BBs
   basic_block bb;
   edge e;
@@ -2610,7 +2626,7 @@
       if (!Loc) {
         // A value.  Store to a temporary, and return the temporary's address.
         // Any future access to this argument will reuse the same address.
-        Loc = TheTreeToLLVM->CreateTemporary(TheValue->getType());
+        Loc = getCurrentTreeToLLVM()->CreateTemporary(TheValue->getType());
         Builder.CreateStore(TheValue, Loc);
       }
       return Loc;
@@ -2650,7 +2666,7 @@
         assert(ConvertType(type) ==
                cast(RetBuf.Ptr->getType())->getElementType() &&
                "Inconsistent result types!");
-        TheTreeToLLVM->EmitAggregateCopy(*DestLoc, RetBuf, type);
+        getCurrentTreeToLLVM()->EmitAggregateCopy(*DestLoc, RetBuf, type);
         return 0;
       } else {
         // Read out the scalar return value now.
@@ -2693,7 +2709,7 @@
 
       if (DestLoc == 0) {
         // The result is unused, but still needs to be stored somewhere.
-        Value *Buf = TheTreeToLLVM->CreateTemporary(PtrArgTy->getElementType());
+        Value *Buf = getCurrentTreeToLLVM()->CreateTemporary(PtrArgTy->getElementType());
         CallOperands.push_back(Buf);
       } else if (useReturnSlot) {
         // Letting the call write directly to the final destination is safe and
@@ -2703,7 +2719,7 @@
         // Letting the call write directly to the final destination may not be
         // safe (eg: if DestLoc aliases a parameter) and is not required - pass
         // a buffer and copy it to DestLoc after the call.
-        RetBuf = TheTreeToLLVM->CreateTempLoc(PtrArgTy->getElementType());
+        RetBuf = getCurrentTreeToLLVM()->CreateTempLoc(PtrArgTy->getElementType());
         CallOperands.push_back(RetBuf.Ptr);
       }
 
@@ -2724,7 +2740,7 @@
              "Call returns a scalar but caller expects aggregate!");
       // Create a buffer to hold the result.  The result will be loaded out of
       // it after the call.
-      RetBuf = TheTreeToLLVM->CreateTempLoc(PtrArgTy->getElementType());
+      RetBuf = getCurrentTreeToLLVM()->CreateTempLoc(PtrArgTy->getElementType());
       CallOperands.push_back(RetBuf.Ptr);
 
       // Note the use of a shadow argument.
@@ -2748,7 +2764,7 @@
         if (Loc->getType() != CalledTy) {
           assert(type && "Inconsistent parameter types?");
           bool isSigned = !TYPE_UNSIGNED(type);
-          Loc = TheTreeToLLVM->CastToAnyType(Loc, isSigned, CalledTy, false);
+          Loc = getCurrentTreeToLLVM()->CastToAnyType(Loc, isSigned, CalledTy, false);
         }
       }
 
@@ -8451,18 +8467,18 @@
 
 /// EmitLV_LABEL_DECL - Someone took the address of a label.
 Constant *TreeConstantToLLVM::EmitLV_LABEL_DECL(tree exp) {
-  assert(TheTreeToLLVM &&
+  assert(getCurrentTreeToLLVM() &&
          "taking the address of a label while not compiling the function!");
 
   // Figure out which function this is for, verify it's the one we're compiling.
   if (DECL_CONTEXT(exp)) {
     assert(TREE_CODE(DECL_CONTEXT(exp)) == FUNCTION_DECL &&
            "Address of label in nested function?");
-    assert(TheTreeToLLVM->getFUNCTION_DECL() == DECL_CONTEXT(exp) &&
+    assert(getCurrentTreeToLLVM()->getFUNCTION_DECL() == DECL_CONTEXT(exp) &&
            "Taking the address of a label that isn't in the current fn!?");
   }
 
-  return TheTreeToLLVM->EmitLV_LABEL_DECL(exp);
+  return getCurrentTreeToLLVM()->EmitLV_LABEL_DECL(exp);
 }
 
 Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) {

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=100049&r1=100048&r2=100049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Mar 31 16:12:42 2010
@@ -289,12 +289,10 @@
   setCurrentLexicalBlock(desired);
 }
 
-/// EmitFunctionStart - Constructs the debug code for entering a function -
-/// "llvm.dbg.func.start."
-void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
-                                  BasicBlock *CurBB) {
-  setCurrentLexicalBlock(FnDecl);
+/// CreateSubprogramFromFnDecl - Constructs the debug code for
+/// entering a function - "llvm.dbg.func.start."
 
+DISubprogram DebugInfo::CreateSubprogramFromFnDecl(tree FnDecl) {
   DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
 
   std::map::iterator I = SPCache.find(FnDecl);
@@ -302,12 +300,9 @@
     DISubprogram SPDecl(cast(I->second));
     DISubprogram SP = 
       DebugFactory.CreateSubprogramDefinition(SPDecl);
-    SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
-
-    // Push function on region stack.
-    RegionStack.push_back(WeakVH(SP.getNode()));
-    RegionMap[FnDecl] = WeakVH(SP.getNode());
-    return;
+    if (SP.getNode() != SPDecl.getNode())
+      SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+    return SP;
   } 
 
   bool ArtificialFnWithAbstractOrigin = false;
@@ -329,12 +324,13 @@
     DISubprogram SPDecl(cast(I->second));
     DISubprogram SP = 
       DebugFactory.CreateSubprogramDefinition(SPDecl);
-    SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+    if (SP.getNode() != SPDecl.getNode())
+      SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
 
     // Push function on region stack.
     RegionStack.push_back(WeakVH(SP.getNode()));
     RegionMap[FnDecl] = WeakVH(SP.getNode());
-    return;
+    return SP;
   } 
 
   // Gather location information.
@@ -356,23 +352,36 @@
   }
 
   StringRef FnName = getFunctionName(FnDecl);
-
+  // If the Function * hasn't been created yet, use a bogus value for
+  // the debug internal linkage bit.
+  bool hasInternalLinkage = true;
+  if (GET_DECL_LLVM_INDEX(FnDecl)) {
+    Function *Fn = castDECL_LLVM(FnDecl);
+    hasInternalLinkage = Fn->hasInternalLinkage();
+  }
   DISubprogram SP = 
     DebugFactory.CreateSubprogram(SPContext,
                                   FnName, FnName,
                                   LinkageName,
                                   getOrCreateFile(Loc.file), lineno,
                                   FNType,
-                                  Fn->hasInternalLinkage(),
+                                  hasInternalLinkage,
                                   true /*definition*/,
                                   Virtuality, VIndex, ContainingType);
                           
 
   SPCache[FnDecl] = WeakVH(SP.getNode());
+  RegionMap[FnDecl] = WeakVH(SP.getNode());
+  return SP;
+}
 
+/// EmitFunctionStart - Constructs the debug code for entering a function -
+/// "llvm.dbg.func.start", and pushes it onto the RegionStack.
+void DebugInfo::EmitFunctionStart(tree FnDecl) {
+  setCurrentLexicalBlock(FnDecl);
+  DISubprogram SP = CreateSubprogramFromFnDecl(FnDecl);
   // Push function on region stack.
   RegionStack.push_back(WeakVH(SP.getNode()));
-  RegionMap[FnDecl] = WeakVH(SP.getNode());
 }
 
 /// getOrCreateNameSpace - Get name space descriptor for the tree node.
@@ -405,12 +414,20 @@
     DIType Ty = getOrCreateType(Node);
     return DIDescriptor(Ty.getNode());
   } else if (DECL_P (Node)) {
-    if (TREE_CODE (Node) == NAMESPACE_DECL) {
+    switch (TREE_CODE(Node)) {
+    default:
+      /// What kind of DECL is this?
+      return findRegion (DECL_CONTEXT (Node));
+    case NAMESPACE_DECL: {
       DIDescriptor NSContext = findRegion(DECL_CONTEXT(Node));
       DINameSpace NS = getOrCreateNameSpace(Node, NSContext);
       return DIDescriptor(NS.getNode());
     }
-    return findRegion (DECL_CONTEXT (Node));
+    case FUNCTION_DECL: {
+      DISubprogram SP = CreateSubprogramFromFnDecl(Node);
+      return SP;
+    }
+    }
   } else if (TREE_CODE(Node) == BLOCK) {
     // TREE_BLOCK is GCC's lexical block.
     // Recursively create all necessary contexts:
@@ -631,7 +648,7 @@
   sprintf(FwdTypeName, "fwd.type.%d", FwdTypeCount++);
   llvm::DIType FwdType = 
     DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
-                                     getOrCreateFile(main_input_filename),
+                                     findRegion(TYPE_CONTEXT(type)),
                                      FwdTypeName,
                                      getOrCreateFile(main_input_filename),
                                      0, 0, 0, 0, 0,
@@ -717,9 +734,10 @@
       return Ty;
     }
   
+  tree type_with_context = TYPE_CONTEXT(type) ? type : TREE_TYPE(type);
   StringRef PName = FromTy.getName();
   DIType PTy = 
-    DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)), 
+    DebugFactory.CreateDerivedType(Tag, findRegion(type_with_context), 
                                    Tag == DW_TAG_pointer_type ? 
                                    StringRef() : PName,
                                    getOrCreateFile(main_input_filename),

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=100049&r1=100048&r2=100049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Wed Mar 31 16:12:42 2010
@@ -118,9 +118,13 @@
   // by GCC's cfglayout.c:change_scope().
   void change_regions(tree_node *desired, tree_node *grand);
 
-  /// EmitFunctionStart - Constructs the debug code for entering a function -
+  /// CreateSubprogramFromFnDecl - Constructs the debug code for entering a function -
   /// "llvm.dbg.func.start."
-  void EmitFunctionStart(tree_node *FnDecl, Function *Fn, BasicBlock *CurBB);
+  DISubprogram CreateSubprogramFromFnDecl(tree_node *FnDecl);
+
+  /// EmitFunctionStart - Constructs the debug code for entering a function -
+  /// "llvm.dbg.func.start", and pushes it onto the RegionStack.
+  void EmitFunctionStart(tree_node *FnDecl);
 
   /// EmitFunctionEnd - Constructs the debug code for exiting a declarative
   /// region - "llvm.dbg.region.end."

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=100049&r1=100048&r2=100049&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Wed Mar 31 16:12:42 2010
@@ -75,7 +75,7 @@
 extern llvm::Module *TheModule;
 
 /// TheDebugInfo - This object is responsible for gather all debug information.
-/// If it's value is NULL then no debug information should be gathered.
+/// If its value is NULL then no debug information should be gathered.
 extern llvm::DebugInfo *TheDebugInfo;
 
 /// TheTarget - The current target being compiled for.
@@ -281,6 +281,7 @@
   BasicBlock *ReturnBB;
   BasicBlock *UnwindBB;
   unsigned ReturnOffset;
+
   // Lexical BLOCKS that we have previously seen and processed.
   treeset SeenBlocks;
 
@@ -397,6 +398,10 @@
   // allocation would change with -g, and users dislike that.
   void switchLexicalBlock(tree_node *exp);
 
+  /// StartFunctionBody - Start the emission of 'FnDecl', outputing all
+  /// declarations for parameters and setting things up.
+  Function *StartFunctionBody();
+  
 private: // Helper functions.
 
   // Walk over the lexical BLOCK() tree of the given FUNCTION_DECL;
@@ -405,10 +410,6 @@
   // the given set.
   void setLexicalBlockDepths(tree_node *t, treeset &s, unsigned level);
 
-  /// StartFunctionBody - Start the emission of 'fndecl', outputing all
-  /// declarations for parameters and setting things up.
-  void StartFunctionBody();
-  
   /// FinishFunctionBody - Once the body of the function has been emitted, this
   /// cleans up and returns the result function.
   Function *FinishFunctionBody();
@@ -608,6 +609,9 @@
   Constant *EmitLV_LABEL_DECL(tree_node *exp);
 };
 
+/// Locate a previously exiting TreeToLLVM.  Construct one if necessary.
+TreeToLLVM *getTreeToLLVM(tree_node *fndecl);
+
 /// TreeConstantToLLVM - An instance of this class is created and used to 
 /// convert tree constant values to LLVM.  This is primarily for things like
 /// global variable initializers.




From bob.wilson at apple.com  Wed Mar 31 16:38:43 2010
From: bob.wilson at apple.com (Bob Wilson)
Date: Wed, 31 Mar 2010 21:38:43 -0000
Subject: [llvm-commits] [llvm] r100050 -
	/llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
Message-ID: <20100331213843.53A4A2A6C12C@llvm.org>

Author: bwilson
Date: Wed Mar 31 16:38:43 2010
New Revision: 100050

URL: http://llvm.org/viewvc/llvm-project?rev=100050&view=rev
Log:
Add a redundant PHI testcase for SSAUpdater to go with svn r100047.

Added:
    llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll

Added: llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll?rev=100050&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll (added)
+++ llvm/trunk/test/Transforms/GVN/2010-03-31-RedundantPHIs.ll Wed Mar 31 16:38:43 2010
@@ -0,0 +1,46 @@
+; RUN: opt < %s -gvn -enable-full-load-pre -S | FileCheck %s
+
+define i8* @cat(i8* %s1, ...) nounwind {
+entry:
+  br i1 undef, label %bb, label %bb3
+
+bb:                                               ; preds = %entry
+  unreachable
+
+bb3:                                              ; preds = %entry
+  store i8* undef, i8** undef, align 4
+  br i1 undef, label %bb5, label %bb6
+
+bb5:                                              ; preds = %bb3
+  unreachable
+
+bb6:                                              ; preds = %bb3
+  br label %bb12
+
+bb8:                                              ; preds = %bb12
+  br i1 undef, label %bb9, label %bb10
+
+bb9:                                              ; preds = %bb8
+  %0 = load i8** undef, align 4                   ;  [#uses=0]
+  %1 = load i8** undef, align 4                   ;  [#uses=0]
+  br label %bb11
+
+bb10:                                             ; preds = %bb8
+  br label %bb11
+
+bb11:                                             ; preds = %bb10, %bb9
+; CHECK: bb11:
+; CHECK: phi
+; CHECK-NOT: phi
+  br label %bb12
+
+bb12:                                             ; preds = %bb11, %bb6
+; CHECK: bb12:
+; CHECK: phi
+; CHECK-NOT: phi
+  br i1 undef, label %bb8, label %bb13
+
+bb13:                                             ; preds = %bb12
+; CHECK: bb13:
+  ret i8* undef
+}




From dalej at apple.com  Wed Mar 31 16:48:15 2010
From: dalej at apple.com (Dale Johannesen)
Date: Wed, 31 Mar 2010 21:48:15 -0000
Subject: [llvm-commits] [test-suite] r100051 -
	/test-suite/trunk/TEST.optllcdbg.Makefile
Message-ID: <20100331214815.2CF212A6C12C@llvm.org>

Author: johannes
Date: Wed Mar 31 16:48:15 2010
New Revision: 100051

URL: http://llvm.org/viewvc/llvm-project?rev=100051&view=rev
Log:
grep out more Dwarf stuff that differs legitimately.


Modified:
    test-suite/trunk/TEST.optllcdbg.Makefile

Modified: test-suite/trunk/TEST.optllcdbg.Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/TEST.optllcdbg.Makefile?rev=100051&r1=100050&r2=100051&view=diff
==============================================================================
--- test-suite/trunk/TEST.optllcdbg.Makefile (original)
+++ test-suite/trunk/TEST.optllcdbg.Makefile Wed Mar 31 16:48:15 2010
@@ -33,7 +33,7 @@
 	$(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@
 
 Output/%.first.s: Output/%.t1c.s Output/.dir $(LLC)
-	grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' > $@
+	grep -v '\.long' < $< | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '\.quad' | grep -v '## DW_AT' | grep -v '## Abbrev' | grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '^#.*' | grep -v '^$$' | grep -v '__debug_str' | grep -v 'Lstring' > $@
 
 Output/%.t2a.bc: Output/%.linked.rbc Output/.dir $(LOPT)
 	$(LOPT) -strip-nondebug $< -f -o $@
@@ -45,7 +45,7 @@
 	$(LLC) $(LLC_DEBUG_FLAGS) $< -f -o $@
 
 Output/%.second.s: Output/%.t2c.s Output/.dir
-	grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' |  grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' > $@
+	grep -v DEBUG_VALUE < $< | grep -v '\.long' | grep -v '\.byte' | grep -v '\.short' | grep -v '\.asci' | grep -v '## DW_AT' | grep -v '## Abbrev' |  grep -v '## End Of Children' | grep -v '## Extended Op' | grep -v 'Ltmp[0-9]' | grep -v '## DIE' | grep -v '## $$' | grep -v '\.quad' | grep -v '^#' | grep -v '^$$' | grep -v '__debug_str' | grep -v 'Lstring' > $@
 
 Output/%.diff: Output/%.first.s Output/%.second.s
 	@-if diff $^ > $@; then \




From clattner at apple.com  Wed Mar 31 17:27:44 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 15:27:44 -0700
Subject: [llvm-commits] [llvm] r99848 - in /llvm/trunk/lib/Target/X86:
	SSEDomainFix.cpp X86InstrInfo.cpp X86InstrInfo.h
In-Reply-To: 
References: <20100329232421.B9E1B2A6C12C@llvm.org>
	
	
Message-ID: 


On Mar 31, 2010, at 1:59 PM, Jakob Stoklund Olesen wrote:

>> 
>> Please put DomainValue in an anonymous namespace.
> 
> Everything already is. Should I open a new namespace per class to make it more obvious?

Ah yes, please do.  I prefer to keep anon namespaces and tight as possible around the classes they protect, it makes it easier to tell what is or isn't in one.

Thanks!

-Chris 


From daniel at zuster.org  Wed Mar 31 17:36:07 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 22:36:07 -0000
Subject: [llvm-commits] [compiler-rt] r100055 -
	/compiler-rt/trunk/make/platform/clang_darwin.mk
Message-ID: <20100331223607.AE7DA2A6C12C@llvm.org>

Author: ddunbar
Date: Wed Mar 31 17:36:07 2010
New Revision: 100055

URL: http://llvm.org/viewvc/llvm-project?rev=100055&view=rev
Log:
clang/Darwin: Don't include enable_execute_stack in libcc_kext.a.

Modified:
    compiler-rt/trunk/make/platform/clang_darwin.mk

Modified: compiler-rt/trunk/make/platform/clang_darwin.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=100055&r1=100054&r2=100055&view=diff
==============================================================================
--- compiler-rt/trunk/make/platform/clang_darwin.mk (original)
+++ compiler-rt/trunk/make/platform/clang_darwin.mk Wed Mar 31 17:36:07 2010
@@ -61,7 +61,6 @@
 	divdi3 \
 	divsc3 \
 	do_global_dtors \
-	enable_execute_stack \
 	eprintf \
 	ffsdi2 \
 	fixdfdi \




From scallanan at apple.com  Wed Mar 31 17:42:16 2010
From: scallanan at apple.com (Sean Callanan)
Date: Wed, 31 Mar 2010 15:42:16 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
Message-ID: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>

The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism.  The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash.

The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead.  Further diagnostic information is printed to stderr.

Please let me know what you think.

Sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-disassembler-assert.diff
Type: application/octet-stream
Size: 15218 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/af69a5bd/attachment.obj 

From isanbard at gmail.com  Wed Mar 31 17:54:38 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 31 Mar 2010 22:54:38 -0000
Subject: [llvm-commits] [llvm] r100056 -
	/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Message-ID: <20100331225438.6EE352A6C12C@llvm.org>

Author: void
Date: Wed Mar 31 17:54:38 2010
New Revision: 100056

URL: http://llvm.org/viewvc/llvm-project?rev=100056&view=rev
Log:
Rewrite CorrectExtraCFGEdges() to make it more understandable.

* Set the "DestA" and "DestB" according to how they're understood by the
  method. I.e., if one or both of them should point to the "fall through" block,
  then point to the fall through block.

* Improve the loop that removes superfluous edges to be more understandable.

Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=100056&r1=100055&r2=100056&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Mar 31 17:54:38 2010
@@ -23,6 +23,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/LeakDetector.h"
 #include "llvm/Support/raw_ostream.h"
@@ -459,54 +460,41 @@
   //    conditional branch followed by an unconditional branch. DestA is the
   //    'true' destination and DestB is the 'false' destination.
 
-  bool MadeChange = false;
-  bool AddedFallThrough = false;
+  bool Changed = false;
 
   MachineFunction::iterator FallThru =
     llvm::next(MachineFunction::iterator(this));
-  
-  if (isCond) {
-    // If this block ends with a conditional branch that falls through to its
-    // successor, set DestB as the successor.
-    if (DestB == 0 && FallThru != getParent()->end()) {
+
+  if (DestA == 0 && DestB == 0) {
+    // Block falls through to successor.
+    DestA = FallThru;
+    DestB = FallThru;
+  } else if (DestA != 0 && DestB == 0) {
+    if (isCond)
+      // Block ends in conditional jump that falls through to successor.
       DestB = FallThru;
-      AddedFallThrough = true;
-    }
   } else {
-    // If this is an unconditional branch with no explicit dest, it must just be
-    // a fallthrough into DestA.
-    if (DestA == 0 && FallThru != getParent()->end()) {
-      DestA = FallThru;
-      AddedFallThrough = true;
-    }
+    assert(DestA && DestB && isCond &&
+           "CFG in a bad state. Cannot correct CFG edges");
   }
-  
+
+  // Remove superfluous edges. I.e., those which aren't destinations of this
+  // basic block, duplicate edges, or landing pads.
+  SmallPtrSet SeenMBBs;
   MachineBasicBlock::succ_iterator SI = succ_begin();
-  MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
   while (SI != succ_end()) {
     const MachineBasicBlock *MBB = *SI;
-    if (MBB == DestA) {
-      DestA = 0;
-      ++SI;
-    } else if (MBB == DestB) {
-      DestB = 0;
-      ++SI;
-    } else if (MBB->isLandingPad() && 
-               MBB != OrigDestA && MBB != OrigDestB) {
-      ++SI;
-    } else {
-      // Otherwise, this is a superfluous edge, remove it.
+    if (!SeenMBBs.insert(MBB) ||
+        (MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
+      // This is a superfluous edge, remove it.
       SI = removeSuccessor(SI);
-      MadeChange = true;
+      Changed = true;
+    } else {
+      ++SI;
     }
   }
 
-  if (!AddedFallThrough)
-    assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
-  else if (isCond)
-    assert(DestA == 0 && "MachineCFG is missing edges!");
-
-  return MadeChange;
+  return Changed;
 }
 
 /// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping




From stuart at apple.com  Wed Mar 31 18:08:46 2010
From: stuart at apple.com (Stuart Hastings)
Date: Wed, 31 Mar 2010 23:08:46 -0000
Subject: [llvm-commits] [llvm] r100058 - in
 /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h
Message-ID: <20100331230846.474AF2A6C12C@llvm.org>

Author: stuart
Date: Wed Mar 31 18:08:46 2010
New Revision: 100058

URL: http://llvm.org/viewvc/llvm-project?rev=100058&view=rev
Log:
Reverting 100048; it broke two Frontend debug info tests.

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=100058&r1=100057&r2=100058&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 31 18:08:46 2010
@@ -780,26 +780,12 @@
   } else if (Context.isNameSpace()) {
     DIE *ContextDIE = getOrCreateNameSpace(DINameSpace(Context.getNode()));
     ContextDIE->addChild(Die);
-  } else if (Context.isSubprogram()) {
-    DIE *ContextDIE = createSubprogramDIE(DISubprogram(Context.getNode()),
-                                          /*MakeDecl=*/false);
-    ContextDIE->addChild(Die);
   } else if (DIE *ContextDIE = ModuleCU->getDIE(Context.getNode()))
     ContextDIE->addChild(Die);
   else 
     ModuleCU->addDie(Die);
 }
 
-/// isFunctionContext - True if given Context is nested within a function. 
-bool DwarfDebug::isFunctionContext(DIE *context) {
-  if (context == (DIE *)0)
-    return false;
-  if (context->getTag() == dwarf::DW_TAG_subprogram)
-    return true;
-  else
-    return isFunctionContext(context->getParent());
-}
-
 /// getOrCreateTypeDIE - Find existing DIE or create new DIE for the
 /// given DIType.
 DIE *DwarfDebug::getOrCreateTypeDIE(DIType Ty) {
@@ -981,10 +967,6 @@
     if (DIDescriptor(ContainingType.getNode()).isCompositeType())
       addDIEEntry(&Buffer, dwarf::DW_AT_containing_type, dwarf::DW_FORM_ref4, 
                   getOrCreateTypeDIE(DIType(ContainingType.getNode())));
-    else {
-      DIDescriptor Context = CTy.getContext();
-      addToContextOwner(&Buffer, Context);
-    }
     break;
   }
   default:
@@ -1343,7 +1325,8 @@
  // function then gdb prefers the definition at top level and but does not
  // expect specification DIE in parent function. So avoid creating 
  // specification DIE for a function defined inside a function.
- if (SP.isDefinition() && !isFunctionContext(SPDie->getParent())) {
+ if (SP.isDefinition() && !SP.getContext().isCompileUnit() &&
+     !SP.getContext().isFile() && !SP.getContext().isSubprogram()) {
    addUInt(SPDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1);
    
    // Add arguments. 
@@ -1771,15 +1754,19 @@
 void DwarfDebug::constructSubprogramDIE(MDNode *N) {
   DISubprogram SP(N);
 
+  // Check for pre-existence.
+  if (ModuleCU->getDIE(N))
+    return;
+
   if (!SP.isDefinition())
     // This is a method declaration which will be handled while constructing
     // class type.
     return;
 
-  // Check for pre-existence.
-  DIE *SubprogramDie = ModuleCU->getDIE(N);
-  if (!SubprogramDie)
-    SubprogramDie = createSubprogramDIE(SP);
+  DIE *SubprogramDie = createSubprogramDIE(SP);
+
+  // Add to map.
+  ModuleCU->insertDIE(N, SubprogramDie);
 
   // Add to context owner.
   addToContextOwner(SubprogramDie, SP.getContext());

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=100058&r1=100057&r2=100058&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Mar 31 18:08:46 2010
@@ -315,9 +315,6 @@
   /// addToContextOwner - Add Die into the list of its context owner's children.
   void addToContextOwner(DIE *Die, DIDescriptor Context);
 
-  /// isFunctionContext - True if given Context is nested within a function. 
-  bool isFunctionContext(DIE *context);
-
   /// addType - Add a new type attribute to the specified entity.
   void addType(DIE *Entity, DIType Ty);
 




From stuart at apple.com  Wed Mar 31 18:08:50 2010
From: stuart at apple.com (Stuart Hastings)
Date: Wed, 31 Mar 2010 23:08:50 -0000
Subject: [llvm-commits] [llvm-gcc-4.2] r100059 - in /llvm-gcc-4.2/trunk/gcc:
 llvm-backend.cpp llvm-convert.cpp llvm-debug.cpp llvm-debug.h
 llvm-internal.h
Message-ID: <20100331230850.A0AE82A6C12D@llvm.org>

Author: stuart
Date: Wed Mar 31 18:08:50 2010
New Revision: 100059

URL: http://llvm.org/viewvc/llvm-project?rev=100059&view=rev
Log:
Reverting 100049; it broke two Frontend debug info tests.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-debug.h
    llvm-gcc-4.2/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=100059&r1=100058&r2=100059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Wed Mar 31 18:08:50 2010
@@ -512,8 +512,6 @@
   if (!flag_pch_file &&
       debug_info_level > DINFO_LEVEL_NONE)
     TheDebugInfo = new DebugInfo(TheModule);
-  else
-    TheDebugInfo = 0;
 }
 
 /// performLateBackendInitialization - Set backend options that may only be
@@ -535,6 +533,8 @@
 }
 
 void llvm_lang_dependent_init(const char *Name) {
+  if (TheDebugInfo)
+    TheDebugInfo->Initialize();
   if (Name)
     TheModule->setModuleIdentifier(Name);
 }
@@ -1010,7 +1010,7 @@
   // Convert the AST to raw/ugly LLVM code.
   Function *Fn;
   {
-    TreeToLLVM *Emitter = getTreeToLLVM(fndecl);
+    TreeToLLVM Emitter(fndecl);
     enum symbol_visibility vis = DECL_VISIBILITY (fndecl);
 
     if (vis != VISIBILITY_DEFAULT)
@@ -1018,7 +1018,7 @@
       // visibility that's not supported by the target.
       targetm.asm_out.visibility(fndecl, vis);
 
-    Fn = Emitter->EmitFunction();
+    Fn = Emitter.EmitFunction();
   }
 
 #if 0

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=100059&r1=100058&r2=100059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Mar 31 18:08:50 2010
@@ -148,6 +148,7 @@
 //===----------------------------------------------------------------------===//
 
 /// TheTreeToLLVM - Keep track of the current function being compiled.
+static TreeToLLVM *TheTreeToLLVM = 0;
 
 const TargetData &getTargetData() {
   return *TheTarget->getTargetData();
@@ -162,7 +163,7 @@
 }
 
 TreeToLLVM::TreeToLLVM(tree fndecl) :
-  TD(getTargetData()), Builder(Context, *TheFolder) {
+    TD(getTargetData()), Builder(Context, *TheFolder) {
   FnDecl = fndecl;
   Fn = 0;
   ReturnBB = UnwindBB = 0;
@@ -178,7 +179,6 @@
       TheDebugInfo->setLocationFile("");
       TheDebugInfo->setLocationLine(0);
     }
-    TheDebugInfo->Initialize();
   }
 
   AllocaInsertionPoint = 0;
@@ -188,23 +188,13 @@
   FuncEHException = 0;
   FuncEHSelector = 0;
   FuncEHGetTypeID = 0;
-}
-
-
-TreeToLLVM::~TreeToLLVM() {}
 
-TreeToLLVM *getTreeToLLVM(tree fndecl) {
-  // FIXME: should this static move into the TreeToLLVM class decl?
-  static std::map FunctionMap;
-  TreeToLLVM *newTreeToLLVM = FunctionMap[fndecl];
-  if (!newTreeToLLVM)
-    newTreeToLLVM = FunctionMap[fndecl] = new TreeToLLVM(fndecl);
-  return newTreeToLLVM;
+  assert(TheTreeToLLVM == 0 && "Reentering function creation?");
+  TheTreeToLLVM = this;
 }
 
-TreeToLLVM *getCurrentTreeToLLVM(void) {
-  assert(current_function_decl && "no current_function_decl?");
-  return getTreeToLLVM(current_function_decl);
+TreeToLLVM::~TreeToLLVM() {
+  TheTreeToLLVM = 0;
 }
 
 /// getLabelDeclBlock - Lazily get and create a basic block for the specified
@@ -318,8 +308,7 @@
       assert(TREE_CODE(TREE_TYPE(ResultDecl)) == REFERENCE_TYPE &&
              "Not type match and not passing by reference?");
       // Create an alloca for the ResultDecl.
-      TreeToLLVM *Emitter = getCurrentTreeToLLVM();
-      Value *Tmp = Emitter->CreateTemporary(AI->getType());
+      Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
       Builder.CreateStore(AI, Tmp);
 
       SET_DECL_LLVM(ResultDecl, Tmp);
@@ -462,7 +451,7 @@
   }
 }
 
-Function *TreeToLLVM::StartFunctionBody() {
+void TreeToLLVM::StartFunctionBody() {
   const char *Name = "";
   // Get the name of the function.
   if (tree ID = DECL_ASSEMBLER_NAME(FnDecl))
@@ -621,10 +610,10 @@
   // Set the BLOCK_NUMBER()s to the depth of each lexical block.
   setLexicalBlockDepths(FnDecl, block_declared_vars, 1);
 
-  if (TheDebugInfo) {
-    TheDebugInfo->EmitFunctionStart(FnDecl);
-    Builder.GetInsertBlock();
-  }
+  SeenBlocks.clear();
+
+  if (EmitDebugInfo())
+    TheDebugInfo->EmitFunctionStart(FnDecl, Fn, Builder.GetInsertBlock());
 
   // Loop over all of the arguments to the function, setting Argument names and
   // creating argument alloca's for the PARM_DECLs in case their address is
@@ -639,7 +628,7 @@
   ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl,
                                 DECL_BUILT_IN(FnDecl));
   // Remember this for use by FinishFunctionBody.
-  ReturnOffset = Client.Offset;
+  TheTreeToLLVM->ReturnOffset = Client.Offset;
 
   // Prepend the static chain (if any) to the list of arguments.
   tree Args = static_chain ? static_chain : DECL_ARGUMENTS(FnDecl);
@@ -720,7 +709,12 @@
         block_declared_vars.count(TREE_VALUE(t)) == 0)
       EmitAutomaticVariableDecl(TREE_VALUE(t));
   }
-  return Fn;
+
+  // Push the outermost lexical block onto the RegionStack.
+  switchLexicalBlock(DECL_INITIAL(FnDecl));
+
+  // Create a new block for the return node, but don't insert it yet.
+  ReturnBB = BasicBlock::Create(Context, "return");
 }
 
 Function *TreeToLLVM::FinishFunctionBody() {
@@ -808,19 +802,9 @@
 }
 
 Function *TreeToLLVM::EmitFunction() {
-  // Set up parameters for the function.
+  // Set up parameters and prepare for return, for the function.
   StartFunctionBody();
 
-  // We'll remember the lexical BLOCKs we've seen here.
-  SeenBlocks.clear();
-
-  // FIXME: Should these two statements move to StartFunctionBody() ?
-  // Push the outermost lexical block onto the RegionStack.
-  switchLexicalBlock(DECL_INITIAL(FnDecl));
-
-  // Create a new block for the return node, but don't insert it yet.
-  ReturnBB = BasicBlock::Create(Context, "return");
-
   // Emit the body of the function iterating over all BBs
   basic_block bb;
   edge e;
@@ -2626,7 +2610,7 @@
       if (!Loc) {
         // A value.  Store to a temporary, and return the temporary's address.
         // Any future access to this argument will reuse the same address.
-        Loc = getCurrentTreeToLLVM()->CreateTemporary(TheValue->getType());
+        Loc = TheTreeToLLVM->CreateTemporary(TheValue->getType());
         Builder.CreateStore(TheValue, Loc);
       }
       return Loc;
@@ -2666,7 +2650,7 @@
         assert(ConvertType(type) ==
                cast(RetBuf.Ptr->getType())->getElementType() &&
                "Inconsistent result types!");
-        getCurrentTreeToLLVM()->EmitAggregateCopy(*DestLoc, RetBuf, type);
+        TheTreeToLLVM->EmitAggregateCopy(*DestLoc, RetBuf, type);
         return 0;
       } else {
         // Read out the scalar return value now.
@@ -2709,7 +2693,7 @@
 
       if (DestLoc == 0) {
         // The result is unused, but still needs to be stored somewhere.
-        Value *Buf = getCurrentTreeToLLVM()->CreateTemporary(PtrArgTy->getElementType());
+        Value *Buf = TheTreeToLLVM->CreateTemporary(PtrArgTy->getElementType());
         CallOperands.push_back(Buf);
       } else if (useReturnSlot) {
         // Letting the call write directly to the final destination is safe and
@@ -2719,7 +2703,7 @@
         // Letting the call write directly to the final destination may not be
         // safe (eg: if DestLoc aliases a parameter) and is not required - pass
         // a buffer and copy it to DestLoc after the call.
-        RetBuf = getCurrentTreeToLLVM()->CreateTempLoc(PtrArgTy->getElementType());
+        RetBuf = TheTreeToLLVM->CreateTempLoc(PtrArgTy->getElementType());
         CallOperands.push_back(RetBuf.Ptr);
       }
 
@@ -2740,7 +2724,7 @@
              "Call returns a scalar but caller expects aggregate!");
       // Create a buffer to hold the result.  The result will be loaded out of
       // it after the call.
-      RetBuf = getCurrentTreeToLLVM()->CreateTempLoc(PtrArgTy->getElementType());
+      RetBuf = TheTreeToLLVM->CreateTempLoc(PtrArgTy->getElementType());
       CallOperands.push_back(RetBuf.Ptr);
 
       // Note the use of a shadow argument.
@@ -2764,7 +2748,7 @@
         if (Loc->getType() != CalledTy) {
           assert(type && "Inconsistent parameter types?");
           bool isSigned = !TYPE_UNSIGNED(type);
-          Loc = getCurrentTreeToLLVM()->CastToAnyType(Loc, isSigned, CalledTy, false);
+          Loc = TheTreeToLLVM->CastToAnyType(Loc, isSigned, CalledTy, false);
         }
       }
 
@@ -8467,18 +8451,18 @@
 
 /// EmitLV_LABEL_DECL - Someone took the address of a label.
 Constant *TreeConstantToLLVM::EmitLV_LABEL_DECL(tree exp) {
-  assert(getCurrentTreeToLLVM() &&
+  assert(TheTreeToLLVM &&
          "taking the address of a label while not compiling the function!");
 
   // Figure out which function this is for, verify it's the one we're compiling.
   if (DECL_CONTEXT(exp)) {
     assert(TREE_CODE(DECL_CONTEXT(exp)) == FUNCTION_DECL &&
            "Address of label in nested function?");
-    assert(getCurrentTreeToLLVM()->getFUNCTION_DECL() == DECL_CONTEXT(exp) &&
+    assert(TheTreeToLLVM->getFUNCTION_DECL() == DECL_CONTEXT(exp) &&
            "Taking the address of a label that isn't in the current fn!?");
   }
 
-  return getCurrentTreeToLLVM()->EmitLV_LABEL_DECL(exp);
+  return TheTreeToLLVM->EmitLV_LABEL_DECL(exp);
 }
 
 Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) {

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=100059&r1=100058&r2=100059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Wed Mar 31 18:08:50 2010
@@ -289,10 +289,12 @@
   setCurrentLexicalBlock(desired);
 }
 
-/// CreateSubprogramFromFnDecl - Constructs the debug code for
-/// entering a function - "llvm.dbg.func.start."
+/// EmitFunctionStart - Constructs the debug code for entering a function -
+/// "llvm.dbg.func.start."
+void DebugInfo::EmitFunctionStart(tree FnDecl, Function *Fn,
+                                  BasicBlock *CurBB) {
+  setCurrentLexicalBlock(FnDecl);
 
-DISubprogram DebugInfo::CreateSubprogramFromFnDecl(tree FnDecl) {
   DIType FNType = getOrCreateType(TREE_TYPE(FnDecl));
 
   std::map::iterator I = SPCache.find(FnDecl);
@@ -300,9 +302,12 @@
     DISubprogram SPDecl(cast(I->second));
     DISubprogram SP = 
       DebugFactory.CreateSubprogramDefinition(SPDecl);
-    if (SP.getNode() != SPDecl.getNode())
-      SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
-    return SP;
+    SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+
+    // Push function on region stack.
+    RegionStack.push_back(WeakVH(SP.getNode()));
+    RegionMap[FnDecl] = WeakVH(SP.getNode());
+    return;
   } 
 
   bool ArtificialFnWithAbstractOrigin = false;
@@ -324,13 +329,12 @@
     DISubprogram SPDecl(cast(I->second));
     DISubprogram SP = 
       DebugFactory.CreateSubprogramDefinition(SPDecl);
-    if (SP.getNode() != SPDecl.getNode())
-      SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
+    SPDecl.getNode()->replaceAllUsesWith(SP.getNode());
 
     // Push function on region stack.
     RegionStack.push_back(WeakVH(SP.getNode()));
     RegionMap[FnDecl] = WeakVH(SP.getNode());
-    return SP;
+    return;
   } 
 
   // Gather location information.
@@ -352,36 +356,23 @@
   }
 
   StringRef FnName = getFunctionName(FnDecl);
-  // If the Function * hasn't been created yet, use a bogus value for
-  // the debug internal linkage bit.
-  bool hasInternalLinkage = true;
-  if (GET_DECL_LLVM_INDEX(FnDecl)) {
-    Function *Fn = castDECL_LLVM(FnDecl);
-    hasInternalLinkage = Fn->hasInternalLinkage();
-  }
+
   DISubprogram SP = 
     DebugFactory.CreateSubprogram(SPContext,
                                   FnName, FnName,
                                   LinkageName,
                                   getOrCreateFile(Loc.file), lineno,
                                   FNType,
-                                  hasInternalLinkage,
+                                  Fn->hasInternalLinkage(),
                                   true /*definition*/,
                                   Virtuality, VIndex, ContainingType);
                           
 
   SPCache[FnDecl] = WeakVH(SP.getNode());
-  RegionMap[FnDecl] = WeakVH(SP.getNode());
-  return SP;
-}
 
-/// EmitFunctionStart - Constructs the debug code for entering a function -
-/// "llvm.dbg.func.start", and pushes it onto the RegionStack.
-void DebugInfo::EmitFunctionStart(tree FnDecl) {
-  setCurrentLexicalBlock(FnDecl);
-  DISubprogram SP = CreateSubprogramFromFnDecl(FnDecl);
   // Push function on region stack.
   RegionStack.push_back(WeakVH(SP.getNode()));
+  RegionMap[FnDecl] = WeakVH(SP.getNode());
 }
 
 /// getOrCreateNameSpace - Get name space descriptor for the tree node.
@@ -414,20 +405,12 @@
     DIType Ty = getOrCreateType(Node);
     return DIDescriptor(Ty.getNode());
   } else if (DECL_P (Node)) {
-    switch (TREE_CODE(Node)) {
-    default:
-      /// What kind of DECL is this?
-      return findRegion (DECL_CONTEXT (Node));
-    case NAMESPACE_DECL: {
+    if (TREE_CODE (Node) == NAMESPACE_DECL) {
       DIDescriptor NSContext = findRegion(DECL_CONTEXT(Node));
       DINameSpace NS = getOrCreateNameSpace(Node, NSContext);
       return DIDescriptor(NS.getNode());
     }
-    case FUNCTION_DECL: {
-      DISubprogram SP = CreateSubprogramFromFnDecl(Node);
-      return SP;
-    }
-    }
+    return findRegion (DECL_CONTEXT (Node));
   } else if (TREE_CODE(Node) == BLOCK) {
     // TREE_BLOCK is GCC's lexical block.
     // Recursively create all necessary contexts:
@@ -648,7 +631,7 @@
   sprintf(FwdTypeName, "fwd.type.%d", FwdTypeCount++);
   llvm::DIType FwdType = 
     DebugFactory.CreateCompositeType(llvm::dwarf::DW_TAG_subroutine_type,
-                                     findRegion(TYPE_CONTEXT(type)),
+                                     getOrCreateFile(main_input_filename),
                                      FwdTypeName,
                                      getOrCreateFile(main_input_filename),
                                      0, 0, 0, 0, 0,
@@ -734,10 +717,9 @@
       return Ty;
     }
   
-  tree type_with_context = TYPE_CONTEXT(type) ? type : TREE_TYPE(type);
   StringRef PName = FromTy.getName();
   DIType PTy = 
-    DebugFactory.CreateDerivedType(Tag, findRegion(type_with_context), 
+    DebugFactory.CreateDerivedType(Tag, findRegion(TYPE_CONTEXT(type)), 
                                    Tag == DW_TAG_pointer_type ? 
                                    StringRef() : PName,
                                    getOrCreateFile(main_input_filename),

Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.h?rev=100059&r1=100058&r2=100059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-debug.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-debug.h Wed Mar 31 18:08:50 2010
@@ -118,13 +118,9 @@
   // by GCC's cfglayout.c:change_scope().
   void change_regions(tree_node *desired, tree_node *grand);
 
-  /// CreateSubprogramFromFnDecl - Constructs the debug code for entering a function -
-  /// "llvm.dbg.func.start."
-  DISubprogram CreateSubprogramFromFnDecl(tree_node *FnDecl);
-
   /// EmitFunctionStart - Constructs the debug code for entering a function -
-  /// "llvm.dbg.func.start", and pushes it onto the RegionStack.
-  void EmitFunctionStart(tree_node *FnDecl);
+  /// "llvm.dbg.func.start."
+  void EmitFunctionStart(tree_node *FnDecl, Function *Fn, BasicBlock *CurBB);
 
   /// EmitFunctionEnd - Constructs the debug code for exiting a declarative
   /// region - "llvm.dbg.region.end."

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=100059&r1=100058&r2=100059&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Wed Mar 31 18:08:50 2010
@@ -75,7 +75,7 @@
 extern llvm::Module *TheModule;
 
 /// TheDebugInfo - This object is responsible for gather all debug information.
-/// If its value is NULL then no debug information should be gathered.
+/// If it's value is NULL then no debug information should be gathered.
 extern llvm::DebugInfo *TheDebugInfo;
 
 /// TheTarget - The current target being compiled for.
@@ -281,7 +281,6 @@
   BasicBlock *ReturnBB;
   BasicBlock *UnwindBB;
   unsigned ReturnOffset;
-
   // Lexical BLOCKS that we have previously seen and processed.
   treeset SeenBlocks;
 
@@ -398,10 +397,6 @@
   // allocation would change with -g, and users dislike that.
   void switchLexicalBlock(tree_node *exp);
 
-  /// StartFunctionBody - Start the emission of 'FnDecl', outputing all
-  /// declarations for parameters and setting things up.
-  Function *StartFunctionBody();
-  
 private: // Helper functions.
 
   // Walk over the lexical BLOCK() tree of the given FUNCTION_DECL;
@@ -410,6 +405,10 @@
   // the given set.
   void setLexicalBlockDepths(tree_node *t, treeset &s, unsigned level);
 
+  /// StartFunctionBody - Start the emission of 'fndecl', outputing all
+  /// declarations for parameters and setting things up.
+  void StartFunctionBody();
+  
   /// FinishFunctionBody - Once the body of the function has been emitted, this
   /// cleans up and returns the result function.
   Function *FinishFunctionBody();
@@ -609,9 +608,6 @@
   Constant *EmitLV_LABEL_DECL(tree_node *exp);
 };
 
-/// Locate a previously exiting TreeToLLVM.  Construct one if necessary.
-TreeToLLVM *getTreeToLLVM(tree_node *fndecl);
-
 /// TreeConstantToLLVM - An instance of this class is created and used to 
 /// convert tree constant values to LLVM.  This is primarily for things like
 /// global variable initializers.




From echristo at apple.com  Wed Mar 31 18:24:44 2010
From: echristo at apple.com (Eric Christopher)
Date: Wed, 31 Mar 2010 16:24:44 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
Message-ID: <9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>


On Mar 31, 2010, at 3:42 PM, Sean Callanan wrote:

> The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism.  The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash.
> 
> The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead.  Further diagnostic information is printed to stderr.
> 
> Please let me know what you think.

I can't tell with some of the diffs without looking closer but it appears that you have 3 different courses of action when you encounter an error:

a) print something, return -1
b) print something, return 0
c) print something, return

Is there any way to unify some of this? Perhaps even an enum with different types of errors for consumers?

-eric


From isanbard at gmail.com  Wed Mar 31 18:26:26 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 31 Mar 2010 23:26:26 -0000
Subject: [llvm-commits] [llvm] r100062 -
	/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Message-ID: <20100331232626.BB9282A6C12C@llvm.org>

Author: void
Date: Wed Mar 31 18:26:26 2010
New Revision: 100062

URL: http://llvm.org/viewvc/llvm-project?rev=100062&view=rev
Log:
Revert r100056. It was causing a failure on MSVC.

Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=100062&r1=100061&r2=100062&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Mar 31 18:26:26 2010
@@ -23,7 +23,6 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/LeakDetector.h"
 #include "llvm/Support/raw_ostream.h"
@@ -460,41 +459,54 @@
   //    conditional branch followed by an unconditional branch. DestA is the
   //    'true' destination and DestB is the 'false' destination.
 
-  bool Changed = false;
+  bool MadeChange = false;
+  bool AddedFallThrough = false;
 
   MachineFunction::iterator FallThru =
     llvm::next(MachineFunction::iterator(this));
-
-  if (DestA == 0 && DestB == 0) {
-    // Block falls through to successor.
-    DestA = FallThru;
-    DestB = FallThru;
-  } else if (DestA != 0 && DestB == 0) {
-    if (isCond)
-      // Block ends in conditional jump that falls through to successor.
+  
+  if (isCond) {
+    // If this block ends with a conditional branch that falls through to its
+    // successor, set DestB as the successor.
+    if (DestB == 0 && FallThru != getParent()->end()) {
       DestB = FallThru;
+      AddedFallThrough = true;
+    }
   } else {
-    assert(DestA && DestB && isCond &&
-           "CFG in a bad state. Cannot correct CFG edges");
+    // If this is an unconditional branch with no explicit dest, it must just be
+    // a fallthrough into DestA.
+    if (DestA == 0 && FallThru != getParent()->end()) {
+      DestA = FallThru;
+      AddedFallThrough = true;
+    }
   }
-
-  // Remove superfluous edges. I.e., those which aren't destinations of this
-  // basic block, duplicate edges, or landing pads.
-  SmallPtrSet SeenMBBs;
+  
   MachineBasicBlock::succ_iterator SI = succ_begin();
+  MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
   while (SI != succ_end()) {
     const MachineBasicBlock *MBB = *SI;
-    if (!SeenMBBs.insert(MBB) ||
-        (MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
-      // This is a superfluous edge, remove it.
-      SI = removeSuccessor(SI);
-      Changed = true;
-    } else {
+    if (MBB == DestA) {
+      DestA = 0;
+      ++SI;
+    } else if (MBB == DestB) {
+      DestB = 0;
+      ++SI;
+    } else if (MBB->isLandingPad() && 
+               MBB != OrigDestA && MBB != OrigDestB) {
       ++SI;
+    } else {
+      // Otherwise, this is a superfluous edge, remove it.
+      SI = removeSuccessor(SI);
+      MadeChange = true;
     }
   }
 
-  return Changed;
+  if (!AddedFallThrough)
+    assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
+  else if (isCond)
+    assert(DestA == 0 && "MachineCFG is missing edges!");
+
+  return MadeChange;
 }
 
 /// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping




From daniel at zuster.org  Wed Mar 31 18:34:01 2010
From: daniel at zuster.org (Daniel Dunbar)
Date: Wed, 31 Mar 2010 16:34:01 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
Message-ID: 

Hi Sean,

A couple comments:
 (1) Any new error handling code inside lib/ should not use something
like fprintf to stderr, rather it should use a clean API to
communicate errors up to clients.
 (2) Various nit picks like, 'if(' -> 'if (', don't implement
functionality with macros unless absolutely necessary, use 'bool'
instead of int when result is a bool, and everything Eric said.

For something like the disassembler, an approach we use in Clang and
other places is that the parsing functions should *always* recover and
not worry about communicating the error status up to their caller.
Instead they should just emit the diagnostic using a clean client API,
and the client is responsible for knowing that once an error is
encountered, it should limit its expectations on the result.

For tools which should never fail, and can always recover (the
disassembler should fit this), this makes the code cleaner because it
doesn't have to worry about unwinding on errors, instead it just
recovers by returning a result which is structurally sound, but the
client knows it can't rely on it to be valid because an error was
generated.

 - Daniel

On Wed, Mar 31, 2010 at 3:42 PM, Sean Callanan  wrote:
> The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism. ?The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash.
>
> The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead. ?Further diagnostic information is printed to stderr.
>
> Please let me know what you think.
>
> Sean
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>



From bob.wilson at apple.com  Wed Mar 31 18:38:06 2010
From: bob.wilson at apple.com (Bob Wilson)
Date: Wed, 31 Mar 2010 16:38:06 -0700
Subject: [llvm-commits] [llvm] r100062 -
	/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
In-Reply-To: <20100331232626.BB9282A6C12C@llvm.org>
References: <20100331232626.BB9282A6C12C@llvm.org>
Message-ID: <6E9398CF-F7A7-4716-B6F7-9118ABE3D71B@apple.com>

Are you sure?  I think that's the same test that's been failing intermittently.  Daniel tried to fix it (see http://llvm.org/bugs/show_bug.cgi?id=6753) but I think I also saw a comment from him that it wasn't really fixed.

On Mar 31, 2010, at 4:26 PM, Bill Wendling wrote:

> Author: void
> Date: Wed Mar 31 18:26:26 2010
> New Revision: 100062
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=100062&view=rev
> Log:
> Revert r100056. It was causing a failure on MSVC.
> 
> Modified:
>    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
> 
> Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=100062&r1=100061&r2=100062&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
> +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Mar 31 18:26:26 2010
> @@ -23,7 +23,6 @@
> #include "llvm/Target/TargetMachine.h"
> #include "llvm/Assembly/Writer.h"
> #include "llvm/ADT/SmallString.h"
> -#include "llvm/ADT/SmallPtrSet.h"
> #include "llvm/Support/Debug.h"
> #include "llvm/Support/LeakDetector.h"
> #include "llvm/Support/raw_ostream.h"
> @@ -460,41 +459,54 @@
>   //    conditional branch followed by an unconditional branch. DestA is the
>   //    'true' destination and DestB is the 'false' destination.
> 
> -  bool Changed = false;
> +  bool MadeChange = false;
> +  bool AddedFallThrough = false;
> 
>   MachineFunction::iterator FallThru =
>     llvm::next(MachineFunction::iterator(this));
> -
> -  if (DestA == 0 && DestB == 0) {
> -    // Block falls through to successor.
> -    DestA = FallThru;
> -    DestB = FallThru;
> -  } else if (DestA != 0 && DestB == 0) {
> -    if (isCond)
> -      // Block ends in conditional jump that falls through to successor.
> +  
> +  if (isCond) {
> +    // If this block ends with a conditional branch that falls through to its
> +    // successor, set DestB as the successor.
> +    if (DestB == 0 && FallThru != getParent()->end()) {
>       DestB = FallThru;
> +      AddedFallThrough = true;
> +    }
>   } else {
> -    assert(DestA && DestB && isCond &&
> -           "CFG in a bad state. Cannot correct CFG edges");
> +    // If this is an unconditional branch with no explicit dest, it must just be
> +    // a fallthrough into DestA.
> +    if (DestA == 0 && FallThru != getParent()->end()) {
> +      DestA = FallThru;
> +      AddedFallThrough = true;
> +    }
>   }
> -
> -  // Remove superfluous edges. I.e., those which aren't destinations of this
> -  // basic block, duplicate edges, or landing pads.
> -  SmallPtrSet SeenMBBs;
> +  
>   MachineBasicBlock::succ_iterator SI = succ_begin();
> +  MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
>   while (SI != succ_end()) {
>     const MachineBasicBlock *MBB = *SI;
> -    if (!SeenMBBs.insert(MBB) ||
> -        (MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
> -      // This is a superfluous edge, remove it.
> -      SI = removeSuccessor(SI);
> -      Changed = true;
> -    } else {
> +    if (MBB == DestA) {
> +      DestA = 0;
> +      ++SI;
> +    } else if (MBB == DestB) {
> +      DestB = 0;
> +      ++SI;
> +    } else if (MBB->isLandingPad() && 
> +               MBB != OrigDestA && MBB != OrigDestB) {
>       ++SI;
> +    } else {
> +      // Otherwise, this is a superfluous edge, remove it.
> +      SI = removeSuccessor(SI);
> +      MadeChange = true;
>     }
>   }
> 
> -  return Changed;
> +  if (!AddedFallThrough)
> +    assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
> +  else if (isCond)
> +    assert(DestA == 0 && "MachineCFG is missing edges!");
> +
> +  return MadeChange;
> }
> 
> /// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/8e47f769/attachment.html 

From foldr at codedgers.com  Wed Mar 31 18:51:55 2010
From: foldr at codedgers.com (Mikhail Glushenkov)
Date: Wed, 31 Mar 2010 23:51:55 -0000
Subject: [llvm-commits] [llvm] r100064 -
	/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
Message-ID: <20100331235155.54FF52A6C12C@llvm.org>

Author: foldr
Date: Wed Mar 31 18:51:55 2010
New Revision: 100064

URL: http://llvm.org/viewvc/llvm-project?rev=100064&view=rev
Log:
Pass -m32/-m64 to assembler.

Modified:
    llvm/trunk/tools/llvmc/plugins/Base/Base.td.in

Modified: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=100064&r1=100063&r2=100064&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original)
+++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in Wed Mar 31 18:51:55 2010
@@ -233,6 +233,8 @@
           (switch_on "c"), (stop_compilation),
           (not_empty "arch"), (forward "arch"),
           (not_empty "Xassembler"), (forward "Xassembler"),
+          (switch_on "m32"), (forward "m32"),
+          (switch_on "m64"), (forward "m64"),
           (not_empty "Wa,"), (forward "Wa,")))
 ]>;
 




From isanbard at gmail.com  Wed Mar 31 18:59:09 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Wed, 31 Mar 2010 16:59:09 -0700
Subject: [llvm-commits] [llvm] r100062 -
	/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
In-Reply-To: <6E9398CF-F7A7-4716-B6F7-9118ABE3D71B@apple.com>
References: <20100331232626.BB9282A6C12C@llvm.org>
	<6E9398CF-F7A7-4716-B6F7-9118ABE3D71B@apple.com>
Message-ID: <1685C66A-FAFC-4B49-811A-540793D61A13@gmail.com>

No, I'm not sure. It went green before my revert went in. I'm going to reapply this. Thanks for checking. :-)

-bw

On Mar 31, 2010, at 4:38 PM, Bob Wilson wrote:

> Are you sure?  I think that's the same test that's been failing intermittently.  Daniel tried to fix it (see http://llvm.org/bugs/show_bug.cgi?id=6753) but I think I also saw a comment from him that it wasn't really fixed.
> 
> On Mar 31, 2010, at 4:26 PM, Bill Wendling wrote:
> 
>> Author: void
>> Date: Wed Mar 31 18:26:26 2010
>> New Revision: 100062
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=100062&view=rev
>> Log:
>> Revert r100056. It was causing a failure on MSVC.
>> 
>> Modified:
>>    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
>> 
>> Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=100062&r1=100061&r2=100062&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Mar 31 18:26:26 2010
>> @@ -23,7 +23,6 @@
>> #include "llvm/Target/TargetMachine.h"
>> #include "llvm/Assembly/Writer.h"
>> #include "llvm/ADT/SmallString.h"
>> -#include "llvm/ADT/SmallPtrSet.h"
>> #include "llvm/Support/Debug.h"
>> #include "llvm/Support/LeakDetector.h"
>> #include "llvm/Support/raw_ostream.h"
>> @@ -460,41 +459,54 @@
>>   //    conditional branch followed by an unconditional branch. DestA is the
>>   //    'true' destination and DestB is the 'false' destination.
>> 
>> -  bool Changed = false;
>> +  bool MadeChange = false;
>> +  bool AddedFallThrough = false;
>> 
>>   MachineFunction::iterator FallThru =
>>     llvm::next(MachineFunction::iterator(this));
>> -
>> -  if (DestA == 0 && DestB == 0) {
>> -    // Block falls through to successor.
>> -    DestA = FallThru;
>> -    DestB = FallThru;
>> -  } else if (DestA != 0 && DestB == 0) {
>> -    if (isCond)
>> -      // Block ends in conditional jump that falls through to successor.
>> +  
>> +  if (isCond) {
>> +    // If this block ends with a conditional branch that falls through to its
>> +    // successor, set DestB as the successor.
>> +    if (DestB == 0 && FallThru != getParent()->end()) {
>>       DestB = FallThru;
>> +      AddedFallThrough = true;
>> +    }
>>   } else {
>> -    assert(DestA && DestB && isCond &&
>> -           "CFG in a bad state. Cannot correct CFG edges");
>> +    // If this is an unconditional branch with no explicit dest, it must just be
>> +    // a fallthrough into DestA.
>> +    if (DestA == 0 && FallThru != getParent()->end()) {
>> +      DestA = FallThru;
>> +      AddedFallThrough = true;
>> +    }
>>   }
>> -
>> -  // Remove superfluous edges. I.e., those which aren't destinations of this
>> -  // basic block, duplicate edges, or landing pads.
>> -  SmallPtrSet SeenMBBs;
>> +  
>>   MachineBasicBlock::succ_iterator SI = succ_begin();
>> +  MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
>>   while (SI != succ_end()) {
>>     const MachineBasicBlock *MBB = *SI;
>> -    if (!SeenMBBs.insert(MBB) ||
>> -        (MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
>> -      // This is a superfluous edge, remove it.
>> -      SI = removeSuccessor(SI);
>> -      Changed = true;
>> -    } else {
>> +    if (MBB == DestA) {
>> +      DestA = 0;
>> +      ++SI;
>> +    } else if (MBB == DestB) {
>> +      DestB = 0;
>> +      ++SI;
>> +    } else if (MBB->isLandingPad() && 
>> +               MBB != OrigDestA && MBB != OrigDestB) {
>>       ++SI;
>> +    } else {
>> +      // Otherwise, this is a superfluous edge, remove it.
>> +      SI = removeSuccessor(SI);
>> +      MadeChange = true;
>>     }
>>   }
>> 
>> -  return Changed;
>> +  if (!AddedFallThrough)
>> +    assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
>> +  else if (isCond)
>> +    assert(DestA == 0 && "MachineCFG is missing edges!");
>> +
>> +  return MadeChange;
>> }
>> 
>> /// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/51a46b30/attachment.html 

From scallanan at apple.com  Wed Mar 31 19:00:54 2010
From: scallanan at apple.com (Sean Callanan)
Date: Wed, 31 Mar 2010 17:00:54 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
	<9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>
Message-ID: <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>

Eric, Daniel,

thanks for your comments.  I've updated the patch to reflect your concerns:

- I return 0 or -1 in all cases, and never just plain return.  (0 is sometimes the right thing to return, given the return type.)
- All fprintf(stderr)s are #ifdef'd out pending a proper error-reporting API, which I'll propose separately
- Spaces have been inserted between if/for/switch and ( where I missed them
- I went through and audited all function-like macros:
	The error macro is useful because it uses __FILE__ and __LINE__.
	The CONSUME_FUNC macro defines a static function.  It is essentially a template but in C I can't use a template.
	The GENERIC_FIXUP_FUNC macro defines a static function.  It is a template but does something (adding prefixes to the head of an enum name) that not even a template could do.
  In short, the function-like macros I have save considerable code and perform functions that regular functions could not.

I think we ought to discuss a more general error-retrieval API on llvmdev, but I don't want to backpack this patch, which needs to be resolved pretty quickly, onto that discussion.

Sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-disassembler-assert.diff
Type: application/octet-stream
Size: 26999 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/6424b914/attachment.obj 
-------------- next part --------------


On Mar 31, 2010, at 4:24 PM, Eric Christopher wrote:

> 
> On Mar 31, 2010, at 3:42 PM, Sean Callanan wrote:
> 
>> The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism.  The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash.
>> 
>> The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead.  Further diagnostic information is printed to stderr.
>> 
>> Please let me know what you think.
> 
> I can't tell with some of the diffs without looking closer but it appears that you have 3 different courses of action when you encounter an error:
> 
> a) print something, return -1
> b) print something, return 0
> c) print something, return
> 
> Is there any way to unify some of this? Perhaps even an enum with different types of errors for consumers?
> 
> -eric


From isanbard at gmail.com  Wed Mar 31 19:00:43 2010
From: isanbard at gmail.com (Bill Wendling)
Date: Thu, 01 Apr 2010 00:00:43 -0000
Subject: [llvm-commits] [llvm] r100065 -
	/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Message-ID: <20100401000043.AB9422A6C12C@llvm.org>

Author: void
Date: Wed Mar 31 19:00:43 2010
New Revision: 100065

URL: http://llvm.org/viewvc/llvm-project?rev=100065&view=rev
Log:
Reapply r100056. It doesn't look like it's the one that's causing a failure.

Modified:
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=100065&r1=100064&r2=100065&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Wed Mar 31 19:00:43 2010
@@ -23,6 +23,7 @@
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Assembly/Writer.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/LeakDetector.h"
 #include "llvm/Support/raw_ostream.h"
@@ -459,54 +460,41 @@
   //    conditional branch followed by an unconditional branch. DestA is the
   //    'true' destination and DestB is the 'false' destination.
 
-  bool MadeChange = false;
-  bool AddedFallThrough = false;
+  bool Changed = false;
 
   MachineFunction::iterator FallThru =
     llvm::next(MachineFunction::iterator(this));
-  
-  if (isCond) {
-    // If this block ends with a conditional branch that falls through to its
-    // successor, set DestB as the successor.
-    if (DestB == 0 && FallThru != getParent()->end()) {
+
+  if (DestA == 0 && DestB == 0) {
+    // Block falls through to successor.
+    DestA = FallThru;
+    DestB = FallThru;
+  } else if (DestA != 0 && DestB == 0) {
+    if (isCond)
+      // Block ends in conditional jump that falls through to successor.
       DestB = FallThru;
-      AddedFallThrough = true;
-    }
   } else {
-    // If this is an unconditional branch with no explicit dest, it must just be
-    // a fallthrough into DestA.
-    if (DestA == 0 && FallThru != getParent()->end()) {
-      DestA = FallThru;
-      AddedFallThrough = true;
-    }
+    assert(DestA && DestB && isCond &&
+           "CFG in a bad state. Cannot correct CFG edges");
   }
-  
+
+  // Remove superfluous edges. I.e., those which aren't destinations of this
+  // basic block, duplicate edges, or landing pads.
+  SmallPtrSet SeenMBBs;
   MachineBasicBlock::succ_iterator SI = succ_begin();
-  MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
   while (SI != succ_end()) {
     const MachineBasicBlock *MBB = *SI;
-    if (MBB == DestA) {
-      DestA = 0;
-      ++SI;
-    } else if (MBB == DestB) {
-      DestB = 0;
-      ++SI;
-    } else if (MBB->isLandingPad() && 
-               MBB != OrigDestA && MBB != OrigDestB) {
-      ++SI;
-    } else {
-      // Otherwise, this is a superfluous edge, remove it.
+    if (!SeenMBBs.insert(MBB) ||
+        (MBB != DestA && MBB != DestB && !MBB->isLandingPad())) {
+      // This is a superfluous edge, remove it.
       SI = removeSuccessor(SI);
-      MadeChange = true;
+      Changed = true;
+    } else {
+      ++SI;
     }
   }
 
-  if (!AddedFallThrough)
-    assert(DestA == 0 && DestB == 0 && "MachineCFG is missing edges!");
-  else if (isCond)
-    assert(DestA == 0 && "MachineCFG is missing edges!");
-
-  return MadeChange;
+  return Changed;
 }
 
 /// findDebugLoc - find the next valid DebugLoc starting at MBBI, skipping




From grosbach at apple.com  Wed Mar 31 19:13:43 2010
From: grosbach at apple.com (Jim Grosbach)
Date: Thu, 01 Apr 2010 00:13:43 -0000
Subject: [llvm-commits] [llvm] r100066 - /llvm/trunk/lib/Target/ARM/ARM.td
Message-ID: <20100401001343.BDE6A2A6C12C@llvm.org>

Author: grosbach
Date: Wed Mar 31 19:13:43 2010
New Revision: 100066

URL: http://llvm.org/viewvc/llvm-project?rev=100066&view=rev
Log:
vml[as] are slow on 1136jf-s also.

Modified:
    llvm/trunk/lib/Target/ARM/ARM.td

Modified: llvm/trunk/lib/Target/ARM/ARM.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=100066&r1=100065&r2=100066&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARM.td (original)
+++ llvm/trunk/lib/Target/ARM/ARM.td Wed Mar 31 19:13:43 2010
@@ -107,7 +107,8 @@
 
 // V6 Processors.
 def : Processor<"arm1136j-s",       ARMV6Itineraries, [ArchV6]>;
-def : Processor<"arm1136jf-s",      ARMV6Itineraries, [ArchV6, FeatureVFP2]>;
+def : Processor<"arm1136jf-s",      ARMV6Itineraries, [ArchV6, FeatureVFP2,
+                                                       FeatureHasSlowVMLx]>;
 def : Processor<"arm1176jz-s",      ARMV6Itineraries, [ArchV6]>;
 def : Processor<"arm1176jzf-s",     ARMV6Itineraries, [ArchV6, FeatureVFP2]>;
 def : Processor<"mpcorenovfp",      ARMV6Itineraries, [ArchV6]>;




From echristo at apple.com  Wed Mar 31 19:17:33 2010
From: echristo at apple.com (Eric Christopher)
Date: Wed, 31 Mar 2010 17:17:33 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
	<9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>
	<776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>
Message-ID: 


On Mar 31, 2010, at 5:00 PM, Sean Callanan wrote:

> 

Probably don't want to #if 0 your error define.

-eric


From sabre at nondot.org  Wed Mar 31 19:37:44 2010
From: sabre at nondot.org (Chris Lattner)
Date: Thu, 01 Apr 2010 00:37:44 -0000
Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk:
 include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp
 lib/VMCore/LLVMContextImpl.h
Message-ID: <20100401003744.913E82A6C12C@llvm.org>

Author: lattner
Date: Wed Mar 31 19:37:44 2010
New Revision: 100072

URL: http://llvm.org/viewvc/llvm-project?rev=100072&view=rev
Log:
Add a new "NewDebugLoc" class which will eventually replace DebugLoc,
and will replace the 'DbgInfo' member in Instruction.

The benefit of NewDebugLoc is that it is compact (8 bytes vs 12/24 
bytes for the DbgInfo member in Instruction on a 32/64 bit system),
it means that we will end up not having to allocate MDNodes to 
represent the "DILocations" in common cases of -O0 -g, and it is
much more efficient to get things out of than the MDNode.


Added:
    llvm/trunk/lib/VMCore/DebugLoc.cpp
Modified:
    llvm/trunk/include/llvm/Support/DebugLoc.h
    llvm/trunk/lib/VMCore/LLVMContextImpl.h

Modified: llvm/trunk/include/llvm/Support/DebugLoc.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=100072&r1=100071&r2=100072&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/DebugLoc.h (original)
+++ llvm/trunk/include/llvm/Support/DebugLoc.h Wed Mar 31 19:37:44 2010
@@ -20,6 +20,61 @@
 
 namespace llvm {
   class MDNode;
+  class LLVMContext;
+  
+  /// DebugLoc - Debug location id.  This is carried by Instruction, SDNode,
+  /// and MachineInstr to compactly encode file/line/scope information for an
+  /// operation.
+  class NewDebugLoc {
+    /// LineCol - This 32-bit value encodes the line and column number for the
+    /// location, encoded as 24-bits for line and 8 bits for col.  A value of 0
+    /// for either means unknown.
+    unsigned LineCol;
+    
+    /// ScopeIdx - This is an opaque ID# for Scope/InlinedAt information,
+    /// decoded by LLVMContext.  0 is unknown.
+    int ScopeIdx;
+  public:
+    NewDebugLoc() : LineCol(0), ScopeIdx(0) {}  // Defaults to unknown.
+    
+    static NewDebugLoc get(unsigned Line, unsigned Col,
+                           MDNode *Scope, MDNode *InlinedAt);
+    
+    /// isUnknown - Return true if this is an unknown location.
+    bool isUnknown() const { return ScopeIdx == 0; }
+    
+    unsigned getLine() const {
+      return (LineCol << 8) >> 8;  // Mask out column.
+    }
+    
+    unsigned getCol() const {
+      return LineCol >> 24;
+    }
+    
+    /// getScope - This returns the scope pointer for this DebugLoc, or null if
+    /// invalid.
+    MDNode *getScope(const LLVMContext &Ctx) const;
+    
+    /// getInlinedAt - This returns the InlinedAt pointer for this DebugLoc, or
+    /// null if invalid or not present.
+    MDNode *getInlinedAt(const LLVMContext &Ctx) const;
+    
+    /// getScopeAndInlinedAt - Return both the Scope and the InlinedAt values.
+    void getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA,
+                              const LLVMContext &Ctx) const;
+    
+    
+    /// getAsMDNode - This method converts the compressed DebugLoc node into a
+    /// DILocation compatible MDNode.
+    MDNode *getAsMDNode(const LLVMContext &Ctx) const;
+    
+    bool operator==(const NewDebugLoc &DL) const {
+      return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx;
+    }
+    bool operator!=(const NewDebugLoc &DL) const { return !(*this == DL); }
+  };
+  
+  
 
   /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr
   /// to index into a vector of unique debug location tuples.

Added: llvm/trunk/lib/VMCore/DebugLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=100072&view=auto
==============================================================================
--- llvm/trunk/lib/VMCore/DebugLoc.cpp (added)
+++ llvm/trunk/lib/VMCore/DebugLoc.cpp Wed Mar 31 19:37:44 2010
@@ -0,0 +1,270 @@
+//===-- DebugLoc.cpp - Implement DebugLoc class ---------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/DebugLoc.h"
+#include "LLVMContextImpl.h"
+using namespace llvm;
+
+//===----------------------------------------------------------------------===//
+// DebugLoc Implementation
+//===----------------------------------------------------------------------===//
+
+MDNode *NewDebugLoc::getScope(const LLVMContext &Ctx) const {
+  if (ScopeIdx == 0) return 0;
+  
+  if (ScopeIdx > 0) {
+    // Positive ScopeIdx is an index into ScopeRecords, which has no inlined-at
+    // position specified.
+    assert(unsigned(ScopeIdx) <= Ctx.pImpl->ScopeRecords.size() &&
+           "Invalid ScopeIdx!");
+    return Ctx.pImpl->ScopeRecords[ScopeIdx-1].get();
+  }
+  
+  // Otherwise, the index is in the ScopeInlinedAtRecords array.
+  assert(unsigned(-ScopeIdx) <= Ctx.pImpl->ScopeInlinedAtRecords.size() &&
+         "Invalid ScopeIdx");
+  return Ctx.pImpl->ScopeInlinedAtRecords[-ScopeIdx-1].first.get();
+}
+
+MDNode *NewDebugLoc::getInlinedAt(const LLVMContext &Ctx) const {
+  // Positive ScopeIdx is an index into ScopeRecords, which has no inlined-at
+  // position specified.  Zero is invalid.
+  if (ScopeIdx >= 0) return 0;
+  
+  // Otherwise, the index is in the ScopeInlinedAtRecords array.
+  assert(unsigned(-ScopeIdx) <= Ctx.pImpl->ScopeInlinedAtRecords.size() &&
+         "Invalid ScopeIdx");
+  return Ctx.pImpl->ScopeInlinedAtRecords[-ScopeIdx-1].second.get();
+}
+
+/// Return both the Scope and the InlinedAt values.
+void NewDebugLoc::getScopeAndInlinedAt(MDNode *&Scope, MDNode *&IA,
+                                       const LLVMContext &Ctx) const {
+  if (ScopeIdx == 0) {
+    Scope = IA = 0;
+    return;
+  }
+  
+  if (ScopeIdx > 0) {
+    // Positive ScopeIdx is an index into ScopeRecords, which has no inlined-at
+    // position specified.
+    assert(unsigned(ScopeIdx) <= Ctx.pImpl->ScopeRecords.size() &&
+           "Invalid ScopeIdx!");
+    Scope = Ctx.pImpl->ScopeRecords[ScopeIdx-1].get();
+    IA = 0;
+    return;
+  }
+  
+  // Otherwise, the index is in the ScopeInlinedAtRecords array.
+  assert(unsigned(-ScopeIdx) <= Ctx.pImpl->ScopeInlinedAtRecords.size() &&
+         "Invalid ScopeIdx");
+  Scope = Ctx.pImpl->ScopeInlinedAtRecords[-ScopeIdx-1].first.get();
+  IA    = Ctx.pImpl->ScopeInlinedAtRecords[-ScopeIdx-1].second.get();
+}
+
+
+NewDebugLoc NewDebugLoc::get(unsigned Line, unsigned Col,
+                             MDNode *Scope, MDNode *InlinedAt) {
+  NewDebugLoc Result;
+  
+  // If no scope is available, this is an unknown location.
+  if (Scope == 0) return Result;
+  
+  // Saturate line and col to "unknown".
+  if (Col > 255) Col = 0;
+  if (Line >= (1 << 24)) Line = 0;
+  Result.LineCol = Line | (Col << 24);
+  
+  LLVMContext &Ctx = Scope->getContext();
+  
+  // If there is no inlined-at location, use the ScopeRecords array.
+  if (InlinedAt == 0)
+    Result.ScopeIdx = Ctx.pImpl->getOrAddScopeRecordIdxEntry(Scope, 0);
+  else
+    Result.ScopeIdx = Ctx.pImpl->getOrAddScopeInlinedAtIdxEntry(Scope,
+                                                                InlinedAt, 0);
+
+  return Result;
+}
+
+/// getAsMDNode - This method converts the compressed DebugLoc node into a
+/// DILocation compatible MDNode.
+MDNode *NewDebugLoc::getAsMDNode(const LLVMContext &Ctx) const {
+  if (isUnknown()) return 0;
+  
+  MDNode *Scope, *IA;
+  getScopeAndInlinedAt(Scope, IA, Ctx);
+  assert(Scope && "If scope is null, this should be isUnknown()");
+  
+  LLVMContext &Ctx2 = Scope->getContext();
+  const Type *Int32 = Type::getInt32Ty(Ctx2);
+  Value *Elts[] = {
+    ConstantInt::get(Int32, getLine()), ConstantInt::get(Int32, getCol()),
+    Scope, IA
+  };
+  return MDNode::get(Ctx2, &Elts[0], 4);
+}
+
+
+//===----------------------------------------------------------------------===//
+// LLVMContextImpl Implementation
+//===----------------------------------------------------------------------===//
+
+int LLVMContextImpl::getOrAddScopeRecordIdxEntry(MDNode *Scope,
+                                                 int ExistingIdx) {
+  // If we already have an entry for this scope, return it.
+  int &Idx = ScopeRecordIdx[Scope];
+  if (Idx) return Idx;
+  
+  // If we don't have an entry, but ExistingIdx is specified, use it.
+  if (ExistingIdx)
+    return Idx = ExistingIdx;
+  
+  // Otherwise add a new entry.
+  
+  // Start out ScopeRecords with a minimal reasonable size to avoid
+  // excessive reallocation starting out.
+  if (ScopeRecords.empty())
+    ScopeRecords.reserve(128);
+  
+  // Index is biased by 1 for index.
+  Idx = ScopeRecords.size()+1;
+  ScopeRecords.push_back(DebugRecVH(Scope, this, Idx));
+  return Idx;
+}
+
+int LLVMContextImpl::getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,
+                                                    int ExistingIdx) {
+  // If we already have an entry, return it.
+  int &Idx = ScopeInlinedAtIdx[std::make_pair(Scope, IA)];
+  if (Idx) return Idx;
+  
+  // If we don't have an entry, but ExistingIdx is specified, use it.
+  if (ExistingIdx)
+    return Idx = ExistingIdx;
+  
+  // Start out ScopeInlinedAtRecords with a minimal reasonable size to avoid
+  // excessive reallocation starting out.
+  if (ScopeInlinedAtRecords.empty())
+    ScopeInlinedAtRecords.reserve(128);
+    
+  // Index is biased by 1 and negated.
+  Idx = -ScopeInlinedAtRecords.size()-1;
+  ScopeInlinedAtRecords.push_back(std::make_pair(DebugRecVH(Scope, this, Idx),
+                                                 DebugRecVH(IA, this, Idx)));
+  return Idx;
+}
+
+
+//===----------------------------------------------------------------------===//
+// DebugRecVH Implementation
+//===----------------------------------------------------------------------===//
+
+/// deleted - The MDNode this is pointing to got deleted, so this pointer needs
+/// to drop to null and we need remove our entry from the DenseMap.
+void DebugRecVH::deleted() {
+  // If this is a  non-canonical reference, just drop the value to null, we know
+  // it doesn't have a map entry.
+  if (Idx == 0) {
+    setValPtr(0);
+    return;
+  }
+    
+  MDNode *Cur = get();
+  
+  // If the index is positive, it is an entry in ScopeRecords.
+  if (Idx > 0) {
+    assert(Ctx->ScopeRecordIdx[Cur] == Idx && "Mapping out of date!");
+    Ctx->ScopeRecordIdx.erase(Cur);
+    // Reset this VH to null and we're done.
+    setValPtr(0);
+    Idx = 0;
+    return;
+  }
+  
+  // Otherwise, it is an entry in ScopeInlinedAtRecords, we don't know if it
+  // is the scope or the inlined-at record entry.
+  assert(unsigned(-Idx-1) < Ctx->ScopeInlinedAtRecords.size());
+  std::pair &Entry = Ctx->ScopeInlinedAtRecords[-Idx-1];
+  assert((this == &Entry.first || this == &Entry.second) &&
+         "Mapping out of date!");
+  
+  MDNode *OldScope = Entry.first.get();
+  MDNode *OldInlinedAt = Entry.second.get();
+  assert(OldScope != 0 && OldInlinedAt != 0 &&
+         "Entry should be non-canonical if either val dropped to null");
+
+  // Otherwise, we do have an entry in it, nuke it and we're done.
+  assert(Ctx->ScopeInlinedAtIdx[std::make_pair(OldScope, OldInlinedAt)] == Idx&&
+         "Mapping out of date");
+  Ctx->ScopeInlinedAtIdx.erase(std::make_pair(OldScope, OldInlinedAt));
+  
+  // Reset this VH to null.
+  setValPtr(0);
+  Idx = 0;
+}
+
+void DebugRecVH::allUsesReplacedWith(Value *NewVa) {
+  // If being replaced with a non-mdnode value (e.g. undef) handle this as if
+  // the mdnode got deleted.
+  MDNode *NewVal = dyn_cast(NewVa);
+  if (NewVal == 0) return deleted();
+  
+  // If this is a non-canonical reference, just change it, we know it already
+  // doesn't have a map entry.
+  if (Idx == 0) {
+    setValPtr(NewVa);
+    return;
+  }
+  
+  MDNode *OldVal = get();
+  assert(OldVal != NewVa && "Node replaced with self?");
+  
+  // If the index is positive, it is an entry in ScopeRecords.
+  if (Idx > 0) {
+    assert(Ctx->ScopeRecordIdx[OldVal] == Idx && "Mapping out of date!");
+    Ctx->ScopeRecordIdx.erase(OldVal);
+    setValPtr(NewVal);
+
+    int NewEntry = Ctx->getOrAddScopeRecordIdxEntry(NewVal, Idx);
+    
+    // If NewVal already has an entry, this becomes a non-canonical reference,
+    // just drop Idx to 0 to signify this.
+    if (NewEntry != Idx)
+      Idx = 0;
+    return;
+  }
+  
+  // Otherwise, it is an entry in ScopeInlinedAtRecords, we don't know if it
+  // is the scope or the inlined-at record entry.
+  assert(unsigned(-Idx-1) < Ctx->ScopeInlinedAtRecords.size());
+  std::pair &Entry = Ctx->ScopeInlinedAtRecords[-Idx-1];
+  assert((this == &Entry.first || this == &Entry.second) &&
+         "Mapping out of date!");
+  
+  MDNode *OldScope = Entry.first.get();
+  MDNode *OldInlinedAt = Entry.second.get();
+  assert(OldScope != 0 && OldInlinedAt != 0 &&
+         "Entry should be non-canonical if either val dropped to null");
+  
+  // Otherwise, we do have an entry in it, nuke it and we're done.
+  assert(Ctx->ScopeInlinedAtIdx[std::make_pair(OldScope, OldInlinedAt)] == Idx&&
+         "Mapping out of date");
+  Ctx->ScopeInlinedAtIdx.erase(std::make_pair(OldScope, OldInlinedAt));
+  
+  // Reset this VH to the new value.
+  setValPtr(NewVal);
+
+  int NewIdx = Ctx->getOrAddScopeInlinedAtIdxEntry(Entry.first.get(),
+                                                   Entry.second.get(), Idx);
+  // If NewVal already has an entry, this becomes a non-canonical reference,
+  // just drop Idx to 0 to signify this.
+  if (NewIdx != Idx)
+    Idx = 0;
+}

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=100072&r1=100071&r2=100072&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Wed Mar 31 19:37:44 2010
@@ -90,6 +90,29 @@
   }
 };
 
+/// DebugRecVH - This is a CallbackVH used to keep the Scope -> index maps
+/// up to date as MDNodes mutate.  This class is implemented in DebugLoc.cpp.
+class DebugRecVH : public CallbackVH {
+  /// Ctx - This is the LLVM Context being referenced.
+  LLVMContextImpl *Ctx;
+  
+  /// Idx - The index into either ScopeRecordIdx or ScopeInlinedAtRecords that
+  /// this reference lives in.  If this is zero, then it represents a
+  /// non-canonical entry that has no DenseMap value.  This can happen due to
+  /// RAUW.
+  int Idx;
+public:
+  DebugRecVH(MDNode *n, LLVMContextImpl *ctx, int idx)
+    : CallbackVH(n), Ctx(ctx), Idx(idx) {}
+  
+  MDNode *get() const {
+    return cast_or_null(getValPtr());
+  }
+  
+  virtual void deleted();
+  virtual void allUsesReplacedWith(Value *VNew);
+};
+  
 class LLVMContextImpl {
 public:
   typedef DenseMap NullPtrConstants;
-  
   ConstantUniqueMap UndefValueConstants;
   
   DenseMap , BlockAddress*> BlockAddresses;
@@ -195,6 +217,27 @@
   /// context.
   DenseMap MetadataStore;
   
+  /// ScopeRecordIdx - This is the index in ScopeRecords for an MDNode scope
+  /// entry with no "inlined at" element.
+  DenseMap ScopeRecordIdx;
+  
+  /// ScopeRecords - These are the actual mdnodes (in a value handle) for an
+  /// index.  The ValueHandle ensures that ScopeRecordIdx stays up to date if
+  /// the MDNode is RAUW'd.
+  std::vector ScopeRecords;
+  
+  /// ScopeInlinedAtIdx - This is the index in ScopeInlinedAtRecords for an
+  /// scope/inlined-at pair.
+  DenseMap, int> ScopeInlinedAtIdx;
+  
+  /// ScopeInlinedAtRecords - These are the actual mdnodes (in value handles)
+  /// for an index.  The ValueHandle ensures that ScopeINlinedAtIdx stays up
+  /// to date.
+  std::vector > ScopeInlinedAtRecords;
+  
+  int getOrAddScopeRecordIdxEntry(MDNode *N, int ExistingIdx);
+  int getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA,int ExistingIdx);
+  
   LLVMContextImpl(LLVMContext &C);
   ~LLVMContextImpl();
 };




From dalej at apple.com  Wed Mar 31 19:45:01 2010
From: dalej at apple.com (Dale Johannesen)
Date: Wed, 31 Mar 2010 17:45:01 -0700
Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk:
	include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp
	lib/VMCore/LLVMContextImpl.h
Message-ID: 


On Mar 31, 2010, at 5:37 PMPDT, Chris Lattner wrote:
>>   class NewDebugLoc {
> +    /// LineCol - This 32-bit value encodes the line and column number for the
> +    /// location, encoded as 24-bits for line and 8 bits for col.  A value of 0
> +    /// for either means unknown.
> +    unsigned LineCol;
> +    

Machine-generated code often goes over 255 columns.   Are you sure you want to design this limitation in?




From dalej at apple.com  Wed Mar 31 19:46:55 2010
From: dalej at apple.com (Dale Johannesen)
Date: Thu, 01 Apr 2010 00:46:55 -0000
Subject: [llvm-commits] [test-suite] r100073 -
 /test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile
Message-ID: <20100401004655.266FC2A6C12C@llvm.org>

Author: johannes
Date: Wed Mar 31 19:46:54 2010
New Revision: 100073

URL: http://llvm.org/viewvc/llvm-project?rev=100073&view=rev
Log:
dale discovers FP_TOLERANCE.


Modified:
    test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile

Modified: test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile?rev=100073&r1=100072&r2=100073&view=diff
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile (original)
+++ test-suite/trunk/SingleSource/UnitTests/Vector/Altivec/Makefile Wed Mar 31 19:46:54 2010
@@ -2,6 +2,8 @@
 
 DIRS = 
 LEVEL = ../../../..
+# Needed because of MADDs in stepfft.
+FP_TOLERANCE := 0.002
 include $(LEVEL)/SingleSource/Makefile.singlesrc
 
 # FIXME: CBE doesn't support vectors: PR1126




From clattner at apple.com  Wed Mar 31 19:48:45 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 17:48:45 -0700
Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk:
	include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp
	lib/VMCore/LLVMContextImpl.h
In-Reply-To: 
References: 
Message-ID: 


On Mar 31, 2010, at 5:45 PM, Dale Johannesen wrote:

> 
> On Mar 31, 2010, at 5:37 PMPDT, Chris Lattner wrote:
>>>  class NewDebugLoc {
>> +    /// LineCol - This 32-bit value encodes the line and column number for the
>> +    /// location, encoded as 24-bits for line and 8 bits for col.  A value of 0
>> +    /// for either means unknown.
>> +    unsigned LineCol;
>> +    
> 
> Machine-generated code often goes over 255 columns.   Are you sure you want to design this limitation in?

Yep.  Only clang generates column numbers, and I don't know of any debuggers that do anything with them.  We can always change this in the future.

-Chris


From clattner at apple.com  Wed Mar 31 19:57:34 2010
From: clattner at apple.com (Chris Lattner)
Date: Wed, 31 Mar 2010 17:57:34 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
	<9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>
	<776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>
Message-ID: <3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com>


On Mar 31, 2010, at 5:00 PM, Sean Callanan wrote:

> Eric, Daniel,
> 
> thanks for your comments.  I've updated the patch to reflect your concerns:
> 
> - I return 0 or -1 in all cases, and never just plain return.  (0 is sometimes the right thing to return, given the return type.)

Thanks.

> - All fprintf(stderr)s are #ifdef'd out pending a proper error-reporting API, which I'll propose separately

Please don't check in #if 0'd code.  The idiom that we use in other apis that can fail is something like this:

int dosomething_that_could_fail(..., std::string *Error) {

...
  // Oh crap an error happened!
  if (Error) *Error = "whatever";
  return -1;
}

Then clients can handle this or not with code like:
std::string ErrorInfo;
if (dosomething_that_could_fail(..., &ErrorInfo) == -1)
  print(ErrorInfo); // or whatever.

However, I don't see how error messages from the disassembler are going to be very useful.  Errors like:

Corrupt table!  Unknown modrm_type
Cannot have Mod = 0b11 and a SIB byte
Expected a REG or R/M encoding in fixupReg
No modifier but an operand expects one.

Are not going to mean anything to anyone.  I don't think there is such thing as a useful error message that can come out of a disassembler other than "unrecognized instruction".  Given this, I don't see the value in an error reporting api at all here.


> 	The error macro is useful because it uses __FILE__ and __LINE__.

You don't want to report FILE and LINE through an error reporting API.  If you want this for debugging,
then just make these things abort when in debug mode or something.

> I think we ought to discuss a more general error-retrieval API on llvmdev, but I don't want to backpack this patch, which needs to be resolved pretty quickly, onto that discussion.

This patch looks ok to me once we resolve the value of the error message reporting stuff.  I think you should just rip it out or turn it into asserts (which are disabled in production mode).

-Chris


From sabre at nondot.org  Wed Mar 31 20:02:19 2010
From: sabre at nondot.org (Chris Lattner)
Date: Thu, 01 Apr 2010 01:02:19 -0000
Subject: [llvm-commits] [llvm] r100074 -
	/llvm/trunk/lib/VMCore/CMakeLists.txt
Message-ID: <20100401010219.62C662A6C12C@llvm.org>

Author: lattner
Date: Wed Mar 31 20:02:19 2010
New Revision: 100074

URL: http://llvm.org/viewvc/llvm-project?rev=100074&view=rev
Log:
update cmakefile.

Modified:
    llvm/trunk/lib/VMCore/CMakeLists.txt

Modified: llvm/trunk/lib/VMCore/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/CMakeLists.txt?rev=100074&r1=100073&r2=100074&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/CMakeLists.txt (original)
+++ llvm/trunk/lib/VMCore/CMakeLists.txt Wed Mar 31 20:02:19 2010
@@ -6,6 +6,7 @@
   ConstantFold.cpp
   Constants.cpp
   Core.cpp
+  DebugLoc.cpp
   Dominators.cpp
   Function.cpp
   GVMaterializer.cpp




From scallanan at apple.com  Wed Mar 31 20:13:14 2010
From: scallanan at apple.com (Sean Callanan)
Date: Wed, 31 Mar 2010 18:13:14 -0700
Subject: [llvm-commits] Error-handling fixes for the x86 disassembler
In-Reply-To: <3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com>
References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com>
	<9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com>
	<776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com>
	<3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com>
Message-ID: 

Chris,

On Mar 31, 2010, at 5:57 PM, Chris Lattner wrote:
> Please don't check in #if 0'd code.

thanks, fixed.

>  The idiom that we use in other apis that can fail is something like this:
> 
> int dosomething_that_could_fail(..., std::string *Error) {
> 
> ...
>  // Oh crap an error happened!
>  if (Error) *Error = "whatever";
>  return -1;
> }
> 
> Then clients can handle this or not with code like:
> std::string ErrorInfo;
> if (dosomething_that_could_fail(..., &ErrorInfo) == -1)
>  print(ErrorInfo); // or whatever.

That's probably a reasonable approach, assuming we can get other code to sign on to doing this and returning -1 instead of calling llvm_unreachable and ? in NDEBUG builds ? misbehaving silently.

> However, I don't see how error messages from the disassembler are going to be very useful.  Errors like:
> 
> Corrupt table!  Unknown modrm_type
> Cannot have Mod = 0b11 and a SIB byte
> Expected a REG or R/M encoding in fixupReg
> No modifier but an operand expects one.
> 
> Are not going to mean anything to anyone.  I don't think there is such thing as a useful error message that can come out of a disassembler other than "unrecognized instruction".  Given this, I don't see the value in an error reporting api at all here.

I'll just have error() call fprintf(stderr) unless NDEBUG is defined.  New patch attached.

> -Chris

Sean

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/7a768545/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x86-disassembler-assert.r3.diff
Type: application/octet-stream
Size: 26848 bytes
Desc: not available
Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/7a768545/attachment.obj 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/7a768545/attachment-0001.html 

From eli.friedman at gmail.com  Wed Mar 31 20:31:56 2010
From: eli.friedman at gmail.com (Eli Friedman)
Date: Wed, 31 Mar 2010 18:31:56 -0700
Subject: [llvm-commits] [compiler-rt] r100014 - in
	/compiler-rt/trunk/lib: absvdi2.c absvsi2.c absvti2.c
	addvdi3.c addvsi3.c addvti3.c clear_cache.c eprintf.c
	gcc_personality_v0.c int_lib.h mulvdi3.c mulvsi3.c mulvti3.c
	negvdi2.c negvsi2.c negvti2.c subvd
Message-ID: 

On Wed, Mar 31, 2010 at 10:00 AM, Daniel Dunbar  wrote:
> Author: ddunbar
> Date: Wed Mar 31 12:00:45 2010
> New Revision: 100014
>
> URL: http://llvm.org/viewvc/llvm-project?rev=100014&view=rev
> Log:
> Use a private compilerrt_abort() define instead of calling abort directly.
> ?- Fiddling with abort directly is annoying given the way we use system includes, although it would be nice to fix this so we could make sure calling abort directly is verboten.

I fail to see the correlation between using abort() and including
system headers; just declare "void abort(void);".

-Eli



From idadesub at users.sourceforge.net  Wed Mar 31 20:53:24 2010
From: idadesub at users.sourceforge.net (Erick Tryzelaar)
Date: Thu, 01 Apr 2010 01:53:24 -0000
Subject: [llvm-commits] [llvm] r100076 - /llvm/trunk/docs/ReleaseNotes.html
Message-ID: <20100401015324.F3F932A6C12C@llvm.org>

Author: erickt
Date: Wed Mar 31 20:53:24 2010
New Revision: 100076

URL: http://llvm.org/viewvc/llvm-project?rev=100076&view=rev
Log:
There are no known O'Caml problems at the moment.

Modified:
    llvm/trunk/docs/ReleaseNotes.html

Modified: llvm/trunk/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=100076&r1=100075&r2=100076&view=diff
==============================================================================
--- llvm/trunk/docs/ReleaseNotes.html (original)
+++ llvm/trunk/docs/ReleaseNotes.html Wed Mar 31 20:53:24 2010
@@ -1026,20 +1026,6 @@
 
 
- - - -
- -

The Llvm.Linkage module is broken, and has incorrect values. Only -Llvm.Linkage.External, Llvm.Linkage.Available_externally, and -Llvm.Linkage.Link_once will be correct. If you need any of the other linkage -modes, you'll have to write an external C library in order to expose the -functionality. This has been fixed in the trunk.

-
-
Additional Information From echristo at apple.com Wed Mar 31 22:05:46 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 01 Apr 2010 03:05:46 -0000 Subject: [llvm-commits] [llvm] r100078 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86InstrSSE.td Message-ID: <20100401030546.1DD322A6C12C@llvm.org> Author: echristo Date: Wed Mar 31 22:05:45 2010 New Revision: 100078 URL: http://llvm.org/viewvc/llvm-project?rev=100078&view=rev Log: Add aeskeygenassist intrinsic and rename all of the aes intrinsics to aes instead of sse4.2. Add a brief todo for a subtarget flag and rework the aeskeygenassist instruction to more closely match the docs. Modified: llvm/trunk/include/llvm/IntrinsicsX86.td llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=100078&r1=100077&r2=100078&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Wed Mar 31 22:05:45 2010 @@ -781,21 +781,25 @@ // Advanced Encryption Standard (AES) Instructions let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_sse42_aesimc : + def int_x86_aesni_aesimc : GCCBuiltin<"__builtin_ia32_aesimc128">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse42_aesenc : + def int_x86_aesni_aesenc : GCCBuiltin<"__builtin_ia32_aesenc128">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse42_aesenclast : + def int_x86_aesni_aesenclast : GCCBuiltin<"__builtin_ia32_aesenclast128">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse42_aesdec : + def int_x86_aesni_aesdec : GCCBuiltin<"__builtin_ia32_aesdec128">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; - def int_x86_sse42_aesdeclast : + def int_x86_aesni_aesdeclast : GCCBuiltin<"__builtin_ia32_aesdeclast128">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + def int_x86_aesni_aeskeygenassist : + GCCBuiltin<"__builtin_ia32_aeskeygenassist">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], + [IntrNoMem]>; } // Vector pack Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=100078&r1=100077&r2=100078&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed Mar 31 22:05:45 2010 @@ -3848,44 +3848,52 @@ def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))), (PCMPGTQrm VR128:$src1, addr:$src2)>; +// TODO: These should be AES as a feature set. defm AESIMC : SS42I_binop_rm_int<0xDB, "aesimc", - int_x86_sse42_aesimc>; + int_x86_aesni_aesimc>; defm AESENC : SS42I_binop_rm_int<0xDC, "aesenc", - int_x86_sse42_aesenc>; + int_x86_aesni_aesenc>; defm AESENCLAST : SS42I_binop_rm_int<0xDD, "aesenclast", - int_x86_sse42_aesenclast>; + int_x86_aesni_aesenclast>; defm AESDEC : SS42I_binop_rm_int<0xDE, "aesdec", - int_x86_sse42_aesdec>; + int_x86_aesni_aesdec>; defm AESDECLAST : SS42I_binop_rm_int<0xDF, "aesdeclast", - int_x86_sse42_aesdeclast>; + int_x86_aesni_aesdeclast>; -def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_aesni_aesimc VR128:$src1, VR128:$src2)), (AESIMCrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesimc VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_aesni_aesimc VR128:$src1, (memop addr:$src2))), (AESIMCrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, VR128:$src2)), (AESENCrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesenc VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_aesni_aesenc VR128:$src1, (memop addr:$src2))), (AESENCrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, VR128:$src2)), (AESENCLASTrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesenclast VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_aesni_aesenclast VR128:$src1, (memop addr:$src2))), (AESENCLASTrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, VR128:$src2)), (AESDECrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesdec VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_aesni_aesdec VR128:$src1, (memop addr:$src2))), (AESDECrm VR128:$src1, addr:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, VR128:$src2)), +def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, VR128:$src2)), (AESDECLASTrr VR128:$src1, VR128:$src2)>; -def : Pat<(v2i64 (int_x86_sse42_aesdeclast VR128:$src1, (memop addr:$src2))), +def : Pat<(v2i64 (int_x86_aesni_aesdeclast VR128:$src1, (memop addr:$src2))), (AESDECLASTrm VR128:$src1, addr:$src2)>; -def AESKEYGENASSIST128rr : SS42AI<0xDF, MRMSrcReg, (outs), - (ins VR128:$src1, VR128:$src2, i8imm:$src3), - "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize; -def AESKEYGENASSIST128rm : SS42AI<0xDF, MRMSrcMem, (outs), - (ins VR128:$src1, i128mem:$src2, i8imm:$src3), - "aeskeygenassist\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize; +def AESKEYGENASSIST128rr : SS42AI<0xDF, MRMSrcReg, (outs VR128:$dst), + (ins VR128:$src1, i32i8imm:$src2), + "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}", + [(set VR128:$dst, + (int_x86_aesni_aeskeygenassist VR128:$src1, imm:$src2))]>, + OpSize; +def AESKEYGENASSIST128rm : SS42AI<0xDF, MRMSrcMem, (outs VR128:$dst), + (ins i128mem:$src1, i32i8imm:$src2), + "aeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}", + [(set VR128:$dst, + (int_x86_aesni_aeskeygenassist (bitconvert (memopv2i64 addr:$src1)), + imm:$src2))]>, + OpSize; // crc intrinsic instruction // This set of instructions are only rm, the only difference is the size From clattner at apple.com Wed Mar 31 22:50:49 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 31 Mar 2010 20:50:49 -0700 Subject: [llvm-commits] Error-handling fixes for the x86 disassembler In-Reply-To: References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> <9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com> <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com> <3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com> Message-ID: <7FA5E35D-7B50-40D8-AFF7-0BDE4627D1DD@apple.com> On Mar 31, 2010, at 6:13 PM, Sean Callanan wrote: >> However, I don't see how error messages from the disassembler are going to be very useful. Errors like: >> >> Corrupt table! Unknown modrm_type >> Cannot have Mod = 0b11 and a SIB byte >> Expected a REG or R/M encoding in fixupReg >> No modifier but an operand expects one. >> >> Are not going to mean anything to anyone. I don't think there is such thing as a useful error message that can come out of a disassembler other than "unrecognized instruction". Given this, I don't see the value in an error reporting api at all here. > > I'll just have error() call fprintf(stderr) unless NDEBUG is defined. New patch attached. As daniel mentioned, nothing in lib can use printf. Why not have this abort if assertions are enabled? Causing a printout to happen (presumably as a debugging aid) does not make any sense if linked into a random app that uses the disassembler. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100331/ad2a6f98/attachment.html From sabre at nondot.org Wed Mar 31 22:55:42 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 03:55:42 -0000 Subject: [llvm-commits] [llvm] r100081 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp Message-ID: <20100401035542.F34A22A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 22:55:42 2010 New Revision: 100081 URL: http://llvm.org/viewvc/llvm-project?rev=100081&view=rev Log: add a method to decode a DILocation into a NewDebugLoc. Modified: llvm/trunk/include/llvm/Support/DebugLoc.h llvm/trunk/lib/VMCore/DebugLoc.cpp Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=100081&r1=100080&r2=100081&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Wed Mar 31 22:55:42 2010 @@ -40,6 +40,9 @@ static NewDebugLoc get(unsigned Line, unsigned Col, MDNode *Scope, MDNode *InlinedAt); + /// getFromDILocation - Translate the DILocation quad into a NewDebugLoc. + static NewDebugLoc getFromDILocation(MDNode *N); + /// isUnknown - Return true if this is an unknown location. bool isUnknown() const { return ScopeIdx == 0; } @@ -96,7 +99,7 @@ bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } }; - /// DebugLocTracker - This class tracks debug location information. + /// DebugLocTracker - This class tracks debug location information. /// struct DebugLocTracker { /// DebugLocations - A vector of unique DebugLocTuple's. Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=100081&r1=100080&r2=100081&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugLoc.cpp (original) +++ llvm/trunk/lib/VMCore/DebugLoc.cpp Wed Mar 31 22:55:42 2010 @@ -111,6 +111,21 @@ return MDNode::get(Ctx2, &Elts[0], 4); } +/// getFromDILocation - Translate the DILocation quad into a NewDebugLoc. +NewDebugLoc NewDebugLoc::getFromDILocation(MDNode *N) { + if (N == 0 || N->getNumOperands() != 4) return NewDebugLoc(); + + MDNode *Scope = dyn_cast_or_null(N->getOperand(2)); + if (Scope == 0) return NewDebugLoc(); + + unsigned LineNo = 0, ColNo = 0; + if (ConstantInt *Line = dyn_cast_or_null(N->getOperand(0))) + LineNo = Line->getZExtValue(); + if (ConstantInt *Col = dyn_cast_or_null(N->getOperand(1))) + ColNo = Col->getZExtValue(); + + return get(LineNo, ColNo, Scope, dyn_cast_or_null(N->getOperand(3))); +} //===----------------------------------------------------------------------===// // LLVMContextImpl Implementation From sabre at nondot.org Wed Mar 31 23:51:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 04:51:13 -0000 Subject: [llvm-commits] [llvm] r100082 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h Message-ID: <20100401045113.432C32A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 23:51:13 2010 New Revision: 100082 URL: http://llvm.org/viewvc/llvm-project?rev=100082&view=rev Log: eliminate a temporary smallvector Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=100082&r1=100081&r2=100082&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Mar 31 23:51:13 2010 @@ -1078,9 +1078,7 @@ /// ParseInstructionMetadata /// ::= !dbg !42 (',' !dbg !57)* -bool LLParser:: -ParseInstructionMetadata(SmallVectorImpl > &Result){ +bool LLParser::ParseInstructionMetadata(Instruction *Inst) { do { if (Lex.getKind() != lltok::MetadataVar) return TokError("expected metadata after comma"); @@ -1094,7 +1092,7 @@ return true; unsigned MDK = M->getMDKindID(Name.c_str()); - Result.push_back(std::make_pair(MDK, Node)); + Inst->setMetadata(MDK, Node); // If this is the end of the list, we're done. } while (EatIfPresent(lltok::comma)); @@ -2896,22 +2894,17 @@ // With a normal result, we check to see if the instruction is followed by // a comma and metadata. if (EatIfPresent(lltok::comma)) - if (ParseInstructionMetadata(MetadataOnInst)) + if (ParseInstructionMetadata(Inst)) return true; break; case InstExtraComma: // If the instruction parser ate an extra comma at the end of it, it // *must* be followed by metadata. - if (ParseInstructionMetadata(MetadataOnInst)) + if (ParseInstructionMetadata(Inst)) return true; break; } - // Set metadata attached with this instruction. - for (unsigned i = 0, e = MetadataOnInst.size(); i != e; ++i) - Inst->setMetadata(MetadataOnInst[i].first, MetadataOnInst[i].second); - MetadataOnInst.clear(); - BB->getInstList().push_back(Inst); // Set the name on the instruction. Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=100082&r1=100081&r2=100082&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Wed Mar 31 23:51:13 2010 @@ -171,8 +171,7 @@ bool ParseOptionalCallingConv(CallingConv::ID &CC); bool ParseOptionalAlignment(unsigned &Alignment); bool ParseOptionalStackAlignment(unsigned &Alignment); - bool ParseInstructionMetadata(SmallVectorImpl > &); + bool ParseInstructionMetadata(Instruction *Inst); bool ParseOptionalCommaAlign(unsigned &Alignment, bool &AteExtraComma); bool ParseIndexList(SmallVectorImpl &Indices,bool &AteExtraComma); bool ParseIndexList(SmallVectorImpl &Indices) { From sabre at nondot.org Wed Mar 31 23:53:22 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 04:53:22 -0000 Subject: [llvm-commits] [llvm] r100083 - /llvm/trunk/lib/AsmParser/LLLexer.h Message-ID: <20100401045322.BF3DB2A6C12C@llvm.org> Author: lattner Date: Wed Mar 31 23:53:22 2010 New Revision: 100083 URL: http://llvm.org/viewvc/llvm-project?rev=100083&view=rev Log: no really, we don't need to copy strings around in the accessor. Modified: llvm/trunk/lib/AsmParser/LLLexer.h Modified: llvm/trunk/lib/AsmParser/LLLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.h?rev=100083&r1=100082&r2=100083&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.h (original) +++ llvm/trunk/lib/AsmParser/LLLexer.h Wed Mar 31 23:53:22 2010 @@ -55,7 +55,7 @@ typedef SMLoc LocTy; LocTy getLoc() const { return SMLoc::getFromPointer(TokStart); } lltok::Kind getKind() const { return CurKind; } - const std::string getStrVal() const { return StrVal; } + const std::string &getStrVal() const { return StrVal; } const Type *getTyVal() const { return TyVal; } unsigned getUIntVal() const { return UIntVal; } const APSInt &getAPSIntVal() const { return APSIntVal; } From sabre at nondot.org Thu Apr 1 00:12:07 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 05:12:07 -0000 Subject: [llvm-commits] [llvm] r100084 - /llvm/trunk/lib/VMCore/DebugLoc.cpp Message-ID: <20100401051207.C64FC2A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 00:12:07 2010 New Revision: 100084 URL: http://llvm.org/viewvc/llvm-project?rev=100084&view=rev Log: fix a bug in DebugRecVH::deleted/allUsesReplacedWith. If an entry in the Scope+InlinedAt drops to a non-canonical form, we need to reset the idx member of both VH's to 0. Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp Modified: llvm/trunk/lib/VMCore/DebugLoc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugLoc.cpp?rev=100084&r1=100083&r2=100084&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugLoc.cpp (original) +++ llvm/trunk/lib/VMCore/DebugLoc.cpp Thu Apr 1 00:12:07 2010 @@ -220,9 +220,10 @@ "Mapping out of date"); Ctx->ScopeInlinedAtIdx.erase(std::make_pair(OldScope, OldInlinedAt)); - // Reset this VH to null. + // Reset this VH to null. Drop both 'Idx' values to null to indicate that + // we're in non-canonical form now. setValPtr(0); - Idx = 0; + Entry.first.Idx = Entry.second.Idx = 0; } void DebugRecVH::allUsesReplacedWith(Value *NewVa) { @@ -280,6 +281,8 @@ Entry.second.get(), Idx); // If NewVal already has an entry, this becomes a non-canonical reference, // just drop Idx to 0 to signify this. - if (NewIdx != Idx) - Idx = 0; + if (NewIdx != Idx) { + std::pair &Entry=Ctx->ScopeInlinedAtRecords[-Idx-1]; + Entry.first.Idx = Entry.second.Idx = 0; + } } From sabre at nondot.org Thu Apr 1 00:13:10 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 05:13:10 -0000 Subject: [llvm-commits] [llvm] r100085 - /llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll Message-ID: <20100401051310.3574B2A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 00:13:10 2010 New Revision: 100085 URL: http://llvm.org/viewvc/llvm-project?rev=100085&view=rev Log: change this from using '!dbg' to using '!dbgx'. The MD used here isn't valid for !dbg. Modified: llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll Modified: llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll?rev=100085&r1=100084&r2=100085&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll (original) +++ llvm/trunk/test/DebugInfo/2009-11-03-InsertExtractValue.ll Thu Apr 1 00:13:10 2010 @@ -3,9 +3,9 @@ !0 = metadata !{i32 42} define <{i32, i32}> @f1() { -; CHECK: !dbg !0 - %r = insertvalue <{ i32, i32 }> zeroinitializer, i32 4, 1, !dbg !0 -; CHECK: !dbg !0 - %e = extractvalue <{ i32, i32 }> %r, 0, !dbg !0 +; CHECK: !dbgx !0 + %r = insertvalue <{ i32, i32 }> zeroinitializer, i32 4, 1, !dbgx !0 +; CHECK: !dbgx !0 + %e = extractvalue <{ i32, i32 }> %r, 0, !dbgx !0 ret <{ i32, i32 }> %r } From sabre at nondot.org Thu Apr 1 00:14:45 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 05:14:45 -0000 Subject: [llvm-commits] [llvm] r100086 - in /llvm/trunk/lib/AsmParser: LLParser.cpp LLParser.h Message-ID: <20100401051445.A7E602A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 00:14:45 2010 New Revision: 100086 URL: http://llvm.org/viewvc/llvm-project?rev=100086&view=rev Log: rewrite handling of forward ref'd instruction metadata to used deferred resolution instead of creating a temporary node + rauw. There is no reason to create the temporary mdnode, then do rauw, then destroy it. Modified: llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=100086&r1=100085&r2=100086&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu Apr 1 00:14:45 2010 @@ -39,6 +39,27 @@ /// ValidateEndOfModule - Do final validity and sanity checks at the end of the /// module. bool LLParser::ValidateEndOfModule() { + // Handle any instruction metadata forward references. + if (!ForwardRefInstMetadata.empty()) { + for (DenseMap >::iterator + I = ForwardRefInstMetadata.begin(), E = ForwardRefInstMetadata.end(); + I != E; ++I) { + Instruction *Inst = I->first; + const std::vector &MDList = I->second; + + for (unsigned i = 0, e = MDList.size(); i != e; ++i) { + unsigned SlotNo = MDList[i].MDSlot; + + if (SlotNo >= NumberedMetadata.size() || NumberedMetadata[SlotNo] == 0) + return Error(MDList[i].Loc, "use of undefined metadata '!" + + utostr(SlotNo) + "'"); + Inst->setMetadata(MDList[i].MDKind, NumberedMetadata[SlotNo]); + } + } + ForwardRefInstMetadata.clear(); + } + + // Update auto-upgraded malloc calls to "malloc". // FIXME: Remove in LLVM 3.0. if (MallocF) { @@ -472,18 +493,30 @@ // MDNode: // ::= '!' MDNodeNumber +// +/// This version of ParseMDNodeID returns the slot number and null in the case +/// of a forward reference. +bool LLParser::ParseMDNodeID(MDNode *&Result, unsigned &SlotNo) { + // !{ ..., !42, ... } + if (ParseUInt32(SlotNo)) return true; + + // Check existing MDNode. + if (SlotNo < NumberedMetadata.size() && NumberedMetadata[SlotNo] != 0) + Result = NumberedMetadata[SlotNo]; + else + Result = 0; + return false; +} + bool LLParser::ParseMDNodeID(MDNode *&Result) { // !{ ..., !42, ... } unsigned MID = 0; - if (ParseUInt32(MID)) return true; + if (ParseMDNodeID(Result, MID)) return true; - // Check existing MDNode. - if (MID < NumberedMetadata.size() && NumberedMetadata[MID] != 0) { - Result = NumberedMetadata[MID]; - return false; - } + // If not a forward reference, just return it now. + if (Result) return false; - // Create MDNode forward reference. + // Otherwise, create MDNode forward reference. // FIXME: This is not unique enough! std::string FwdRefName = "llvm.mdnode.fwdref." + utostr(MID); @@ -1087,12 +1120,21 @@ Lex.Lex(); MDNode *Node; + unsigned NodeID; + SMLoc Loc = Lex.getLoc(); if (ParseToken(lltok::exclaim, "expected '!' here") || - ParseMDNodeID(Node)) + ParseMDNodeID(Node, NodeID)) return true; unsigned MDK = M->getMDKindID(Name.c_str()); - Inst->setMetadata(MDK, Node); + if (Node) { + // If we got the node, add it to the instruction. + Inst->setMetadata(MDK, Node); + } else { + MDRef R = { Loc, MDK, NodeID }; + // Otherwise, remember that this should be resolved later. + ForwardRefInstMetadata[Inst].push_back(R); + } // If this is the end of the list, we're done. } while (EatIfPresent(lltok::comma)); Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=100086&r1=100085&r2=100086&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Thu Apr 1 00:14:45 2010 @@ -76,6 +76,14 @@ LLVMContext& Context; LLLexer Lex; Module *M; + + // Instruction metadata resolution. Each instruction can have a list of + // MDRef info associated with them. + struct MDRef { + SMLoc Loc; + unsigned MDKind, MDSlot; + }; + DenseMap > ForwardRefInstMetadata; // Type resolution handling data structures. std::map > ForwardRefTypes; @@ -203,6 +211,7 @@ bool ParseNamedMetadata(); bool ParseMDString(MDString *&Result); bool ParseMDNodeID(MDNode *&Result); + bool ParseMDNodeID(MDNode *&Result, unsigned &SlotNo); // Type Parsing. bool ParseType(PATypeHolder &Result, bool AllowVoid = false); From sabre at nondot.org Thu Apr 1 00:20:21 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 05:20:21 -0000 Subject: [llvm-commits] [llvm] r100087 - /llvm/trunk/lib/AsmParser/LLParser.h Message-ID: <20100401052021.73DCA2A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 00:20:21 2010 New Revision: 100087 URL: http://llvm.org/viewvc/llvm-project?rev=100087&view=rev Log: include header. Modified: llvm/trunk/lib/AsmParser/LLParser.h Modified: llvm/trunk/lib/AsmParser/LLParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=100087&r1=100086&r2=100087&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.h (original) +++ llvm/trunk/lib/AsmParser/LLParser.h Thu Apr 1 00:20:21 2010 @@ -17,6 +17,7 @@ #include "LLLexer.h" #include "llvm/Module.h" #include "llvm/Type.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/Support/ValueHandle.h" #include From sabre at nondot.org Thu Apr 1 00:23:13 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 05:23:13 -0000 Subject: [llvm-commits] [llvm] r100088 - in /llvm/trunk: include/llvm/Instruction.h lib/VMCore/Instruction.cpp lib/VMCore/Metadata.cpp Message-ID: <20100401052314.0A6B22A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 00:23:13 2010 New Revision: 100088 URL: http://llvm.org/viewvc/llvm-project?rev=100088&view=rev Log: Switch the representation of the location in instruction from being a TrackingVH to a NewDebugLoc, shrinking sizeof(Instruction) a lot, and providing clients the ability to deal with locations in terms of NewDebugLoc instead of having to deal with Metadata. This is still fully compatible with all clients that *do* use MDNodes for everything of course. No functionality change. Modified: llvm/trunk/include/llvm/Instruction.h llvm/trunk/lib/VMCore/Instruction.cpp llvm/trunk/lib/VMCore/Metadata.cpp Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=100088&r1=100087&r2=100088&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Thu Apr 1 00:23:13 2010 @@ -17,7 +17,7 @@ #include "llvm/User.h" #include "llvm/ADT/ilist_node.h" -#include "llvm/Support/ValueHandle.h" +#include "llvm/Support/DebugLoc.h" namespace llvm { @@ -32,7 +32,7 @@ Instruction(const Instruction &); // Do not implement BasicBlock *Parent; - TrackingVH DbgInfo; // 'dbg' Metadata cache. + NewDebugLoc DbgLoc; // 'dbg' Metadata cache. enum { /// HasMetadataBit - This is a bit stored in the SubClassData field which @@ -125,7 +125,13 @@ /// hasMetadata() - Return true if this instruction has any metadata attached /// to it. bool hasMetadata() const { - return DbgInfo != 0 || hasMetadataHashEntry(); + return !DbgLoc.isUnknown() || hasMetadataHashEntry(); + } + + /// hasMetadataOtherThanDebugLoc - Return true if this instruction has + /// metadata attached to it other than a debug location. + bool hasMetadataOtherThanDebugLoc() const { + return hasMetadataHashEntry(); } /// getMetadata - Get the metadata of given kind attached to this Instruction. @@ -150,6 +156,14 @@ getAllMetadataImpl(MDs); } + /// getAllMetadataOtherThanDebugLoc - This does the same thing as + /// getAllMetadata, except that it filters out the debug location. + void getAllMetadataOtherThanDebugLoc(SmallVectorImpl > &MDs) const { + if (hasMetadataOtherThanDebugLoc()) + getAllMetadataOtherThanDebugLocImpl(MDs); + } + /// setMetadata - Set the metadata of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. @@ -163,8 +177,14 @@ /// getDbgMetadata - This is just an optimized helper function that is /// equivalent to calling getMetadata("dbg"). MDNode *getDbgMetadata() const { - return DbgInfo; + return DbgLoc.getAsMDNode(getContext()); } + + /// setDebugLoc - Set the debug location information for this instruction. + void setDebugLoc(const NewDebugLoc &Loc) { DbgLoc = Loc; } + + /// getDebugLoc - Return the debug location for this node as a DebugLoc. + const NewDebugLoc &getDebugLoc() const { return DbgLoc; } private: /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side @@ -177,6 +197,8 @@ MDNode *getMetadataImpl(unsigned KindID) const; MDNode *getMetadataImpl(const char *Kind) const; void getAllMetadataImpl(SmallVectorImpl > &)const; + void getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl > &) const; void removeAllMetadata(); public: //===--------------------------------------------------------------------===// Modified: llvm/trunk/lib/VMCore/Instruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instruction.cpp?rev=100088&r1=100087&r2=100088&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instruction.cpp (original) +++ llvm/trunk/lib/VMCore/Instruction.cpp Thu Apr 1 00:23:13 2010 @@ -22,7 +22,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, Instruction *InsertBefore) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) { + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -36,7 +36,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0), DbgInfo(0) { + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); Modified: llvm/trunk/lib/VMCore/Metadata.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Metadata.cpp?rev=100088&r1=100087&r2=100088&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Metadata.cpp (original) +++ llvm/trunk/lib/VMCore/Metadata.cpp Thu Apr 1 00:23:13 2010 @@ -425,7 +425,7 @@ } void Instruction::setDbgMetadata(MDNode *Node) { - DbgInfo = Node; + DbgLoc = NewDebugLoc::getFromDILocation(Node); } /// setMetadata - Set the metadata of of the specified kind to the specified @@ -436,7 +436,7 @@ // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) { - DbgInfo = Node; + DbgLoc = NewDebugLoc::getFromDILocation(Node); return; } @@ -488,7 +488,7 @@ MDNode *Instruction::getMetadataImpl(unsigned KindID) const { // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) - return DbgInfo; + return DbgLoc.getAsMDNode(getContext()); if (!hasMetadataHashEntry()) return 0; @@ -507,8 +507,9 @@ Result.clear(); // Handle 'dbg' as a special case since it is not stored in the hash table. - if (DbgInfo) { - Result.push_back(std::make_pair((unsigned)LLVMContext::MD_dbg, DbgInfo)); + if (!DbgLoc.isUnknown()) { + Result.push_back(std::make_pair((unsigned)LLVMContext::MD_dbg, + DbgLoc.getAsMDNode(getContext()))); if (!hasMetadataHashEntry()) return; } @@ -526,10 +527,29 @@ array_pod_sort(Result.begin(), Result.end()); } +void Instruction:: +getAllMetadataOtherThanDebugLocImpl(SmallVectorImpl > &Result) const { + Result.clear(); + assert(hasMetadataHashEntry() && + getContext().pImpl->MetadataStore.count(this) && + "Shouldn't have called this"); + const LLVMContextImpl::MDMapTy &Info = + getContext().pImpl->MetadataStore.find(this)->second; + assert(!Info.empty() && "Shouldn't have called this"); + + Result.append(Info.begin(), Info.end()); + + // Sort the resulting array so it is stable. + if (Result.size() > 1) + array_pod_sort(Result.begin(), Result.end()); +} + + /// removeAllMetadata - Remove all metadata from this instruction. void Instruction::removeAllMetadata() { assert(hasMetadata() && "Caller should check"); - DbgInfo = 0; + DbgLoc = NewDebugLoc(); if (hasMetadataHashEntry()) { getContext().pImpl->MetadataStore.erase(this); setHasMetadataHashEntry(false); From nicholas at mxc.ca Thu Apr 1 00:50:52 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 31 Mar 2010 22:50:52 -0700 Subject: [llvm-commits] Error-handling fixes for the x86 disassembler In-Reply-To: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> Message-ID: <4BB4343C.2090203@mxc.ca> Sean Callanan wrote: > The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism. The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash. > > The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead. Further diagnostic information is printed to stderr. Your new error() method and assert/llvm_unreachable are not interchangeable. An assert() or llvm_unreachable() are likely to be the last thing run before undefined behaviour. To do this properly please add llvm_recoverable_error() to llvm/Support/ErrorHandling.h and update every caller you want to be able to report a severe but optionally fatal error to use it. Then your client can install an error handler for the recoverable errors. Don't forget to audit all the calls you change to make sure that the program is correct even when it doesn't terminate at those points. Nick > Please let me know what you think. > > Sean > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Thu Apr 1 00:58:17 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 05:58:17 -0000 Subject: [llvm-commits] [llvm] r100089 - in /llvm/trunk/lib/Target/X86: X86.td X86Subtarget.cpp X86Subtarget.h Message-ID: <20100401055817.B2B3C2A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 00:58:17 2010 New Revision: 100089 URL: http://llvm.org/viewvc/llvm-project?rev=100089&view=rev Log: Nehalem unaligned memory access is fast. Modified: llvm/trunk/lib/Target/X86/X86.td llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h Modified: llvm/trunk/lib/Target/X86/X86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.td?rev=100089&r1=100088&r2=100089&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.td (original) +++ llvm/trunk/lib/Target/X86/X86.td Thu Apr 1 00:58:17 2010 @@ -59,6 +59,9 @@ [FeatureCMOV]>; def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true", "Bit testing of memory is slow">; +def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem", + "IsUAMemFast", "true", + "Fast unaligned memory access">; def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true", "Support SSE 4a instructions">; @@ -98,8 +101,10 @@ def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>; def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>; def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>; -def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>; -def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>; +def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem, + FeatureFastUAMem]>; +def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem, + FeatureFastUAMem]>; // Sandy Bridge does not have FMA def : Proc<"sandybridge", [FeatureSSE42, FeatureAVX, Feature64Bit]>; Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=100089&r1=100088&r2=100089&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Thu Apr 1 00:58:17 2010 @@ -266,6 +266,9 @@ unsigned Model = 0; DetectFamilyModel(EAX, Family, Model); IsBTMemSlow = IsAMD || (Family == 6 && Model >= 13); + // If it's Nehalem, unaligned memory access is fast. + if (Family == 15 && Model == 26) + IsUAMemFast = true; GetCpuIDAndInfo(0x80000001, &EAX, &EBX, &ECX, &EDX); HasX86_64 = (EDX >> 29) & 0x1; @@ -286,6 +289,7 @@ , HasFMA3(false) , HasFMA4(false) , IsBTMemSlow(false) + , IsUAMemFast(false) , HasVectorUAMem(false) , DarwinVers(0) , stackAlignment(8) Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=100089&r1=100088&r2=100089&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Thu Apr 1 00:58:17 2010 @@ -78,6 +78,9 @@ /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow. bool IsBTMemSlow; + /// IsUAMemFast - True if unaligned memory access is fast. + bool IsUAMemFast; + /// HasVectorUAMem - True if SIMD operations can have unaligned memory /// operands. This may require setting a feature bit in the /// processor. @@ -148,6 +151,7 @@ bool hasFMA3() const { return HasFMA3; } bool hasFMA4() const { return HasFMA4; } bool isBTMemSlow() const { return IsBTMemSlow; } + bool isUnalignedMemAccessFast() const { return IsUAMemFast; } bool hasVectorUAMem() const { return HasVectorUAMem; } bool isTargetDarwin() const { return TargetType == isDarwin; } From evan.cheng at apple.com Thu Apr 1 01:04:34 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 06:04:34 -0000 Subject: [llvm-commits] [llvm] r100090 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/SelectionDAG/ lib/Target/PowerPC/ lib/Target/X86/ test/CodeGen/X86/ Message-ID: <20100401060434.8DE232A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 01:04:33 2010 New Revision: 100090 URL: http://llvm.org/viewvc/llvm-project?rev=100090&view=rev Log: Fix sdisel memcpy, memset, memmove lowering: 1. Makes it possible to lower with floating point loads and stores. 2. Avoid unaligned loads / stores unless it's fast. 3. Fix some memcpy lowering logic bug related to when to optimize a load from constant string into a constant. 4. Adjust x86 memcpy lowering threshold to make it more sane. 5. Fix x86 target hook so it uses vector and floating point memory ops more effectively. rdar://7774704 Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll llvm/trunk/test/CodeGen/X86/byval7.ll llvm/trunk/test/CodeGen/X86/memcpy-2.ll llvm/trunk/test/CodeGen/X86/memset-2.ll llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll llvm/trunk/test/CodeGen/X86/unaligned-load.ll Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Apr 1 01:04:33 2010 @@ -522,7 +522,7 @@ /// counterpart (e.g. structs), otherwise it will assert. EVT getValueType(const Type *Ty, bool AllowUnknown = false) const { EVT VT = EVT::getEVT(Ty, AllowUnknown); - return VT == MVT:: iPTR ? PointerTy : VT; + return VT == MVT::iPTR ? PointerTy : VT; } /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate @@ -636,8 +636,8 @@ /// and store operations as a result of memset, memcpy, and memmove lowering. /// It returns EVT::Other if SelectionDAG should be responsible for /// determining it. - virtual EVT getOptimalMemOpType(uint64_t Size, unsigned Align, - bool isSrcConst, bool isSrcStr, + virtual EVT getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, SelectionDAG &DAG) const { return MVT::Other; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Apr 1 01:04:33 2010 @@ -5022,18 +5022,6 @@ SDValue Chain = LD->getChain(); SDValue Ptr = LD->getBasePtr(); - // Try to infer better alignment information than the load already has. - if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) { - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { - if (Align > LD->getAlignment()) - return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(), - LD->getValueType(0), - Chain, Ptr, LD->getSrcValue(), - LD->getSrcValueOffset(), LD->getMemoryVT(), - LD->isVolatile(), LD->isNonTemporal(), Align); - } - } - // If load is not volatile and there are no uses of the loaded value (and // the updated indexed value in case of indexed loads), change uses of the // chain value into uses of the chain input (i.e. delete the dead load). @@ -5099,6 +5087,18 @@ } } + // Try to infer better alignment information than the load already has. + if (OptLevel != CodeGenOpt::None && LD->isUnindexed()) { + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { + if (Align > LD->getAlignment()) + return DAG.getExtLoad(LD->getExtensionType(), N->getDebugLoc(), + LD->getValueType(0), + Chain, Ptr, LD->getSrcValue(), + LD->getSrcValueOffset(), LD->getMemoryVT(), + LD->isVolatile(), LD->isNonTemporal(), Align); + } + } + if (CombinerAA) { // Walk up chain skipping non-aliasing memory nodes. SDValue BetterChain = FindBetterChain(N, Chain); @@ -5250,17 +5250,6 @@ SDValue Value = ST->getValue(); SDValue Ptr = ST->getBasePtr(); - // Try to infer better alignment information than the store already has. - if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { - if (Align > ST->getAlignment()) - return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, - Ptr, ST->getSrcValue(), - ST->getSrcValueOffset(), ST->getMemoryVT(), - ST->isVolatile(), ST->isNonTemporal(), Align); - } - } - // If this is a store of a bit convert, store the input value if the // resultant store does not need a higher alignment than the original. if (Value.getOpcode() == ISD::BIT_CONVERT && !ST->isTruncatingStore() && @@ -5351,6 +5340,17 @@ } } + // Try to infer better alignment information than the store already has. + if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { + if (Align > ST->getAlignment()) + return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, + Ptr, ST->getSrcValue(), + ST->getSrcValueOffset(), ST->getMemoryVT(), + ST->isVolatile(), ST->isNonTemporal(), Align); + } + } + if (CombinerAA) { // Walk up chain skipping non-aliasing memory nodes. SDValue BetterChain = FindBetterChain(N, Chain); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 1 01:04:33 2010 @@ -3132,11 +3132,17 @@ if (Str.empty()) { if (VT.isInteger()) return DAG.getConstant(0, VT); - unsigned NumElts = VT.getVectorNumElements(); - MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; - return DAG.getNode(ISD::BIT_CONVERT, dl, VT, - DAG.getConstant(0, - EVT::getVectorVT(*DAG.getContext(), EltVT, NumElts))); + else if (VT.getSimpleVT().SimpleTy == MVT::f32 || + VT.getSimpleVT().SimpleTy == MVT::f64) + return DAG.getConstantFP(0.0, VT); + else if (VT.isVector()) { + unsigned NumElts = VT.getVectorNumElements(); + MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; + return DAG.getNode(ISD::BIT_CONVERT, dl, VT, + DAG.getConstant(0, EVT::getVectorVT(*DAG.getContext(), + EltVT, NumElts))); + } else + llvm_unreachable("Expected type!"); } assert(!VT.isVector() && "Can't handle vector type here!"); @@ -3184,51 +3190,33 @@ return false; } -/// MeetsMaxMemopRequirement - Determines if the number of memory ops required -/// to replace the memset / memcpy is below the threshold. It also returns the -/// types of the sequence of memory ops to perform memset / memcpy. -static -bool MeetsMaxMemopRequirement(std::vector &MemOps, - SDValue Dst, SDValue Src, - unsigned Limit, uint64_t Size, unsigned &Align, - std::string &Str, bool &isSrcStr, - SelectionDAG &DAG, - const TargetLowering &TLI) { - isSrcStr = isMemSrcFromString(Src, Str); - bool isSrcConst = isa(Src); - EVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG); - bool AllowUnalign = TLI.allowsUnalignedMemoryAccesses(VT); - if (VT != MVT::Other) { - const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); - unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); - // If source is a string constant, this will require an unaligned load. - if (NewAlign > Align && (isSrcConst || AllowUnalign)) { - if (Dst.getOpcode() != ISD::FrameIndex) { - // Can't change destination alignment. It requires a unaligned store. - if (AllowUnalign) - VT = MVT::Other; - } else { - int FI = cast(Dst)->getIndex(); - MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); - if (MFI->isFixedObjectIndex(FI)) { - // Can't change destination alignment. It requires a unaligned store. - if (AllowUnalign) - VT = MVT::Other; - } else { - // Give the stack frame object a larger alignment if needed. - if (MFI->getObjectAlignment(FI) < NewAlign) - MFI->setObjectAlignment(FI, NewAlign); - Align = NewAlign; - } - } - } - } +/// FindOptimalMemOpLowering - Determines the optimial series memory ops +/// to replace the memset / memcpy. Return true if the number of memory ops +/// is below the threshold. It returns the types of the sequence of +/// memory ops to perform memset / memcpy by reference. +static bool FindOptimalMemOpLowering(std::vector &MemOps, + SDValue Dst, SDValue Src, + unsigned Limit, uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, + SelectionDAG &DAG, + const TargetLowering &TLI) { + assert((SrcAlign == 0 || SrcAlign >= DstAlign) && + "Expecting memcpy / memset source to meet alignment requirement!"); + // If 'SrcAlign' is zero, that means the memory operation does not need load + // the value, i.e. memset or memcpy from constant string. Otherwise, it's + // the inferred alignment of the source. 'DstAlign', on the other hand, is the + // specified alignment of the memory operation. If it is zero, that means + // it's possible to change the alignment of the destination. + EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, DAG); if (VT == MVT::Other) { - if (TLI.allowsUnalignedMemoryAccesses(MVT::i64)) { + VT = TLI.getPointerTy(); + const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); + if (DstAlign >= TLI.getTargetData()->getABITypeAlignment(Ty) || + TLI.allowsUnalignedMemoryAccesses(VT)) { VT = MVT::i64; } else { - switch (Align & 7) { + switch (DstAlign & 7) { case 0: VT = MVT::i64; break; case 4: VT = MVT::i32; break; case 2: VT = MVT::i16; break; @@ -3250,7 +3238,7 @@ unsigned VTSize = VT.getSizeInBits() / 8; while (VTSize > Size) { // For now, only use non-vector load / store's for the left-over pieces. - if (VT.isVector()) { + if (VT.isVector() || VT.isFloatingPoint()) { VT = MVT::i64; while (!TLI.isTypeLegal(VT)) VT = (MVT::SimpleValueType)(VT.getSimpleVT().SimpleTy - 1); @@ -3286,15 +3274,33 @@ uint64_t Limit = -1ULL; if (!AlwaysInline) Limit = TLI.getMaxStoresPerMemcpy(); - unsigned DstAlign = Align; // Destination alignment can change. + bool DstAlignCanChange = false; + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + FrameIndexSDNode *FI = dyn_cast(Dst); + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) + DstAlignCanChange = true; + unsigned SrcAlign = DAG.InferPtrAlignment(Src); + if (Align > SrcAlign) + SrcAlign = Align; std::string Str; - bool CopyFromStr; - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, - Str, CopyFromStr, DAG, TLI)) + bool CopyFromStr = isMemSrcFromString(Src, Str); + bool isZeroStr = CopyFromStr && Str.empty(); + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, + (DstAlignCanChange ? 0 : Align), + (isZeroStr ? 0 : SrcAlign), DAG, TLI)) return SDValue(); + if (DstAlignCanChange) { + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); + if (NewAlign > Align) { + // Give the stack frame object a larger alignment if needed. + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) + MFI->setObjectAlignment(FI->getIndex(), NewAlign); + Align = NewAlign; + } + } - bool isZeroStr = CopyFromStr && Str.empty(); SmallVector OutChains; unsigned NumMemOps = MemOps.size(); uint64_t SrcOff = 0, DstOff = 0; @@ -3303,16 +3309,17 @@ unsigned VTSize = VT.getSizeInBits() / 8; SDValue Value, Store; - if (CopyFromStr && (isZeroStr || !VT.isVector())) { + if (CopyFromStr && + (isZeroStr || (VT.isInteger() && !VT.isVector()))) { // It's unlikely a store of a vector immediate can be done in a single // instruction. It would require a load from a constantpool first. - // We also handle store a vector with all zero's. + // We only handle zero vectors here. // FIXME: Handle other cases where store of vector immediate is done in // a single instruction. Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, Align); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3323,11 +3330,12 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); + SrcSV, SrcSVOff + SrcOff, VT, false, false, + MinAlign(SrcAlign, SrcOff)); Store = DAG.getTruncStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), DstSV, DstSVOff + DstOff, VT, false, false, - DstAlign); + Align); } OutChains.push_back(Store); SrcOff += VTSize; @@ -3339,11 +3347,11 @@ } static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, - SDValue Chain, SDValue Dst, - SDValue Src, uint64_t Size, - unsigned Align, bool AlwaysInline, - const Value *DstSV, uint64_t DstSVOff, - const Value *SrcSV, uint64_t SrcSVOff){ + SDValue Chain, SDValue Dst, + SDValue Src, uint64_t Size, + unsigned Align,bool AlwaysInline, + const Value *DstSV, uint64_t DstSVOff, + const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Expand memmove to a series of load and store ops if the size operand falls @@ -3352,15 +3360,32 @@ uint64_t Limit = -1ULL; if (!AlwaysInline) Limit = TLI.getMaxStoresPerMemmove(); - unsigned DstAlign = Align; // Destination alignment can change. - std::string Str; - bool CopyFromStr; - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, - Str, CopyFromStr, DAG, TLI)) + bool DstAlignCanChange = false; + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + FrameIndexSDNode *FI = dyn_cast(Dst); + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) + DstAlignCanChange = true; + unsigned SrcAlign = DAG.InferPtrAlignment(Src); + if (Align > SrcAlign) + SrcAlign = Align; + + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, + (DstAlignCanChange ? 0 : Align), + SrcAlign, DAG, TLI)) return SDValue(); - uint64_t SrcOff = 0, DstOff = 0; + if (DstAlignCanChange) { + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); + if (NewAlign > Align) { + // Give the stack frame object a larger alignment if needed. + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) + MFI->setObjectAlignment(FI->getIndex(), NewAlign); + Align = NewAlign; + } + } + uint64_t SrcOff = 0, DstOff = 0; SmallVector LoadValues; SmallVector LoadChains; SmallVector OutChains; @@ -3372,7 +3397,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, false, false, Align); + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3387,7 +3412,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, DstAlign); + DstSV, DstSVOff + DstOff, false, false, Align); OutChains.push_back(Store); DstOff += VTSize; } @@ -3397,24 +3422,38 @@ } static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, - SDValue Chain, SDValue Dst, - SDValue Src, uint64_t Size, - unsigned Align, - const Value *DstSV, uint64_t DstSVOff) { + SDValue Chain, SDValue Dst, + SDValue Src, uint64_t Size, + unsigned Align, + const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); // Expand memset to a series of load/store ops if the size operand // falls below a certain threshold. std::vector MemOps; - std::string Str; - bool CopyFromStr; - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), - Size, Align, Str, CopyFromStr, DAG, TLI)) + bool DstAlignCanChange = false; + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); + FrameIndexSDNode *FI = dyn_cast(Dst); + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) + DstAlignCanChange = true; + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), + Size, (DstAlignCanChange ? 0 : Align), 0, + DAG, TLI)) return SDValue(); + if (DstAlignCanChange) { + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); + if (NewAlign > Align) { + // Give the stack frame object a larger alignment if needed. + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) + MFI->setObjectAlignment(FI->getIndex(), NewAlign); + Align = NewAlign; + } + } + SmallVector OutChains; uint64_t DstOff = 0; - unsigned NumMemOps = MemOps.size(); for (unsigned i = 0; i < NumMemOps; i++) { EVT VT = MemOps[i]; @@ -3445,10 +3484,9 @@ if (ConstantSize->isNullValue()) return Chain; - SDValue Result = - getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); + SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, + ConstantSize->getZExtValue(),Align, + false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -6106,8 +6144,18 @@ // If this is a GlobalAddress + cst, return the alignment. GlobalValue *GV; int64_t GVOffset = 0; - if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) - return MinAlign(GV->getAlignment(), GVOffset); + if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) { + // If GV has specified alignment, then use it. Otherwise, use the preferred + // alignment. + unsigned Align = GV->getAlignment(); + if (!Align) { + if (GlobalVariable *GVar = dyn_cast(GV)) { + const TargetData *TD = TLI.getTargetData(); + Align = TD->getPreferredAlignment(GVar); + } + } + return MinAlign(Align, GVOffset); + } // If this is a direct reference to a stack slot, use information about the // stack slot's alignment. Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Apr 1 01:04:33 2010 @@ -5539,8 +5539,8 @@ return false; } -EVT PPCTargetLowering::getOptimalMemOpType(uint64_t Size, unsigned Align, - bool isSrcConst, bool isSrcStr, +EVT PPCTargetLowering::getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, SelectionDAG &DAG) const { if (this->PPCSubTarget.isPPC64()) { return MVT::i64; Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Thu Apr 1 01:04:33 2010 @@ -347,8 +347,8 @@ virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; - virtual EVT getOptimalMemOpType(uint64_t Size, unsigned Align, - bool isSrcConst, bool isSrcStr, + virtual EVT getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, SelectionDAG &DAG) const; /// getFunctionAlignment - Return the Log2 alignment of this function. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 01:04:33 2010 @@ -1012,7 +1012,7 @@ // FIXME: These should be based on subtarget info. Plus, the values should // be smaller when we are in optimizing for size mode. maxStoresPerMemset = 16; // For @llvm.memset -> sequence of stores - maxStoresPerMemcpy = 16; // For @llvm.memcpy -> sequence of stores + maxStoresPerMemcpy = 8; // For @llvm.memcpy -> sequence of stores maxStoresPerMemmove = 3; // For @llvm.memmove -> sequence of stores setPrefLoopAlignment(16); benefitFromCodePlacementOpt = true; @@ -1074,19 +1074,27 @@ /// lowering. It returns MVT::iAny if SelectionDAG should be responsible for /// determining it. EVT -X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned Align, - bool isSrcConst, bool isSrcStr, +X86TargetLowering::getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, SelectionDAG &DAG) const { // FIXME: This turns off use of xmm stores for memset/memcpy on targets like // linux. This is because the stack realignment code can't handle certain // cases like PR2962. This should be removed when PR2962 is fixed. const Function *F = DAG.getMachineFunction().getFunction(); - bool NoImplicitFloatOps = F->hasFnAttr(Attribute::NoImplicitFloat); - if (!NoImplicitFloatOps && Subtarget->getStackAlignment() >= 16) { - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE2() && Size >= 16) - return MVT::v4i32; - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE1() && Size >= 16) - return MVT::v4f32; + if (!F->hasFnAttr(Attribute::NoImplicitFloat)) { + if (Size >= 16 && + (Subtarget->isUnalignedMemAccessFast() || + (DstAlign == 0 || DstAlign >= 16) && + (SrcAlign == 0 || SrcAlign >= 16)) && + Subtarget->getStackAlignment() >= 16) { + if (Subtarget->hasSSE2()) + return MVT::v4i32; + if (Subtarget->hasSSE1()) + return MVT::v4f32; + } else if (Size >= 8 && + Subtarget->getStackAlignment() >= 8 && + Subtarget->hasSSE2()) + return MVT::f64; } if (Subtarget->is64Bit() && Size >= 8) return MVT::i64; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Thu Apr 1 01:04:33 2010 @@ -423,8 +423,8 @@ /// and store operations as a result of memset, memcpy, and memmove /// lowering. It returns EVT::iAny if SelectionDAG should be responsible for /// determining it. - virtual EVT getOptimalMemOpType(uint64_t Size, unsigned Align, - bool isSrcConst, bool isSrcStr, + virtual EVT getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, SelectionDAG &DAG) const; /// allowsUnalignedMemoryAccesses - Returns true if the target allows Modified: llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll (original) +++ llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll Thu Apr 1 01:04:33 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7 | FileCheck %s ; rdar://7396984 @str = private constant [28 x i8] c"xxxxxxxxxxxxxxxxxxxxxxxxxxx\00", align 1 Modified: llvm/trunk/test/CodeGen/X86/byval7.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/byval7.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/byval7.ll (original) +++ llvm/trunk/test/CodeGen/X86/byval7.ll Thu Apr 1 01:04:33 2010 @@ -1,10 +1,17 @@ -; RUN: llc < %s -march=x86 -mcpu=yonah | egrep {add|lea} | grep 16 +; RUN: llc < %s -march=x86 -mcpu=yonah | FileCheck %s %struct.S = type { <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64>, + <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64> } define i32 @main() nounwind { entry: +; 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] %tmp15 = getelementptr %struct.S* %s, i32 0, i32 0 ; <<2 x i64>*> [#uses=1] store <2 x i64> < i64 8589934595, i64 1 >, <2 x i64>* %tmp15, align 16 Modified: llvm/trunk/test/CodeGen/X86/memcpy-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memcpy-2.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memcpy-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memcpy-2.ll Thu Apr 1 01:04:33 2010 @@ -1,15 +1,105 @@ -; RUN: llc < %s -march=x86 -mattr=-sse -mtriple=i686-apple-darwin8.8.0 | grep mov | count 7 -; RUN: llc < %s -march=x86 -mattr=+sse -mtriple=i686-apple-darwin8.8.0 | grep mov | count 5 +; RUN: llc < %s -mattr=+sse2 -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=SSE2 +; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=SSE1 +; RUN: llc < %s -mattr=-sse -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=NOSSE %struct.ParmT = type { [25 x i8], i8, i8* } @.str12 = internal constant [25 x i8] c"image\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" ; <[25 x i8]*> [#uses=1] -declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) nounwind - -define void @t(i32 %argc, i8** %argv) nounwind { +define void @t1(i32 %argc, i8** %argv) nounwind { entry: +; SSE2: t1: +; SSE2: movaps _.str12, %xmm0 +; SSE2: movaps %xmm0 +; SSE2: movb $0 +; SSE2: movl $0 +; SSE2: movl $0 + +; SSE1: t1: +; SSE1: movaps _.str12, %xmm0 +; SSE1: movaps %xmm0 +; SSE1: movb $0 +; SSE1: movl $0 +; SSE1: movl $0 + +; NOSSE: t1: +; NOSSE: movb $0 +; NOSSE: movl $0 +; NOSSE: movl $0 +; NOSSE: movl $0 +; NOSSE: movl $0 +; NOSSE: movl $101 +; NOSSE: movl $1734438249 %parms.i = alloca [13 x %struct.ParmT] ; <[13 x %struct.ParmT]*> [#uses=1] %parms1.i = getelementptr [13 x %struct.ParmT]* %parms.i, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] call void @llvm.memcpy.i32( i8* %parms1.i, i8* getelementptr ([25 x i8]* @.str12, i32 0, i32 0), i32 25, i32 1 ) nounwind unreachable } + +;rdar://7774704 +%struct.s0 = type { [2 x double] } + +define void @t2(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp { +entry: +; SSE2: t2: +; SSE2: movaps (%eax), %xmm0 +; SSE2: movaps %xmm0, (%eax) + +; SSE1: t2: +; SSE1: movaps (%eax), %xmm0 +; SSE1: movaps %xmm0, (%eax) + +; NOSSE: t2: +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl + %tmp2 = bitcast %struct.s0* %a to i8* ; [#uses=1] + %tmp3 = bitcast %struct.s0* %b to i8* ; [#uses=1] + tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 16) + ret void +} + +define void @t3(%struct.s0* nocapture %a, %struct.s0* nocapture %b) nounwind ssp { +entry: +; SSE2: t3: +; SSE2: movsd (%eax), %xmm0 +; SSE2: movsd 8(%eax), %xmm1 +; SSE2: movsd %xmm1, 8(%eax) +; SSE2: movsd %xmm0, (%eax) + +; SSE1: t3: +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl +; SSE1: movl + +; NOSSE: t3: +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl +; NOSSE: movl + %tmp2 = bitcast %struct.s0* %a to i8* ; [#uses=1] + %tmp3 = bitcast %struct.s0* %b to i8* ; [#uses=1] + tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 8) + ret void +} + +declare void @llvm.memcpy.i32(i8* nocapture, i8* nocapture, i32, i32) nounwind Modified: llvm/trunk/test/CodeGen/X86/memset-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset-2.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memset-2.ll Thu Apr 1 01:04:33 2010 @@ -1,47 +1,13 @@ -; RUN: llc < %s | not grep rep -; RUN: llc < %s | grep memset +; RUN: llc < %s | FileCheck %s target triple = "i386" declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind -define fastcc i32 @cli_scanzip(i32 %desc) nounwind { +define fastcc void @t() nounwind { entry: - br label %bb8.i.i.i.i - -bb8.i.i.i.i: ; preds = %bb8.i.i.i.i, %entry - icmp eq i32 0, 0 ; :0 [#uses=1] - br i1 %0, label %bb61.i.i.i, label %bb8.i.i.i.i - -bb32.i.i.i: ; preds = %bb61.i.i.i - ptrtoint i8* %tail.0.i.i.i to i32 ; :1 [#uses=1] - sub i32 0, %1 ; :2 [#uses=1] - icmp sgt i32 %2, 19 ; :3 [#uses=1] - br i1 %3, label %bb34.i.i.i, label %bb61.i.i.i - -bb34.i.i.i: ; preds = %bb32.i.i.i - load i32* null, align 4 ; :4 [#uses=1] - icmp eq i32 %4, 101010256 ; :5 [#uses=1] - br i1 %5, label %bb8.i11.i.i.i, label %bb61.i.i.i - -bb8.i11.i.i.i: ; preds = %bb8.i11.i.i.i, %bb34.i.i.i - icmp eq i32 0, 0 ; :6 [#uses=1] - br i1 %6, label %cli_dbgmsg.exit49.i, label %bb8.i11.i.i.i - -cli_dbgmsg.exit49.i: ; preds = %bb8.i11.i.i.i - icmp eq [32768 x i8]* null, null ; :7 [#uses=1] - br i1 %7, label %bb1.i28.i, label %bb8.i.i - -bb61.i.i.i: ; preds = %bb61.i.i.i, %bb34.i.i.i, %bb32.i.i.i, %bb8.i.i.i.i - %tail.0.i.i.i = getelementptr [1024 x i8]* null, i32 0, i32 0 ; [#uses=2] - load i8* %tail.0.i.i.i, align 1 ; :8 [#uses=1] - icmp eq i8 %8, 80 ; :9 [#uses=1] - br i1 %9, label %bb32.i.i.i, label %bb61.i.i.i - -bb1.i28.i: ; preds = %cli_dbgmsg.exit49.i - call void @llvm.memset.i32( i8* null, i8 0, i32 88, i32 1 ) nounwind - unreachable - -bb8.i.i: ; preds = %bb8.i.i, %cli_dbgmsg.exit49.i - br label %bb8.i.i +; CHECK: t: +; CHECK: call memset + call void @llvm.memset.i32( i8* null, i8 0, i32 188, i32 1 ) nounwind + unreachable } Modified: llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll (original) +++ llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll Thu Apr 1 01:04:33 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin | grep stosl +; RUN: llc < %s -mtriple=i386-apple-darwin | grep movl | count 20 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | grep movq | count 10 define void @bork() nounwind { Modified: llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll (original) +++ llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll Thu Apr 1 01:04:33 2010 @@ -1,4 +1,4 @@ -; RUN: llc < %s | not grep movs +; RUN: llc < %s | grep movsd | count 8 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" Modified: llvm/trunk/test/CodeGen/X86/unaligned-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unaligned-load.ll?rev=100090&r1=100089&r2=100090&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/unaligned-load.ll (original) +++ llvm/trunk/test/CodeGen/X86/unaligned-load.ll Thu Apr 1 01:04:33 2010 @@ -1,4 +1,5 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck %s +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -mcpu=core2 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck -check-prefix=CORE2 %s +; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -mcpu=corei7 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck -check-prefix=COREI7 %s @.str1 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, SOME STRING\00", align 8 @.str3 = internal constant [31 x i8] c"DHRYSTONE PROGRAM, 2'ND STRING\00", align 8 @@ -11,7 +12,11 @@ bb: %String2Loc9 = getelementptr inbounds [31 x i8]* %String2Loc, i64 0, i64 0 call void @llvm.memcpy.i64(i8* %String2Loc9, i8* getelementptr inbounds ([31 x i8]* @.str3, i64 0, i64 0), i64 31, i32 1) -; CHECK: movups _.str3 +; CORE2: movsd _.str3+16 +; CORE2: movsd _.str3+8 +; CORE2: movsd _.str3 + +; COREI7: movups _.str3 br label %bb return: @@ -20,8 +25,14 @@ declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind -; CHECK: .align 3 -; CHECK-NEXT: _.str1: -; CHECK-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" -; CHECK: .align 3 -; CHECK-NEXT: _.str3: +; CORE2: .align 3 +; CORE2-NEXT: _.str1: +; CORE2-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" +; CORE2: .align 3 +; CORE2-NEXT: _.str3: + +; COREI7: .align 3 +; COREI7-NEXT: _.str1: +; COREI7-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" +; COREI7: .align 3 +; COREI7-NEXT: _.str3: From clattner at apple.com Thu Apr 1 01:06:58 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 31 Mar 2010 23:06:58 -0700 Subject: [llvm-commits] [llvm] r100088 - in /llvm/trunk: include/llvm/Instruction.h lib/VMCore/Instruction.cpp lib/VMCore/Metadata.cpp In-Reply-To: <20100401052314.0A6B22A6C12C@llvm.org> References: <20100401052314.0A6B22A6C12C@llvm.org> Message-ID: <473C6BEC-AE7A-431E-A754-61F0A67D2E98@apple.com> On Mar 31, 2010, at 10:23 PM, Chris Lattner wrote: > Author: lattner > Date: Thu Apr 1 00:23:13 2010 > New Revision: 100088 > > URL: http://llvm.org/viewvc/llvm-project?rev=100088&view=rev > Log: > Switch the representation of the location in instruction from > being a TrackingVH to a NewDebugLoc, shrinking > sizeof(Instruction) a lot, and providing clients the ability > to deal with locations in terms of NewDebugLoc instead of > having to deal with Metadata. This is still fully compatible > with all clients that *do* use MDNodes for everything of > course. > > No functionality change. Actually, there is one functionality change with this: this causes various debug loc clients to do validation. If given an invalid loc, it drops to null. -Chris From sabre at nondot.org Thu Apr 1 01:29:56 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 06:29:56 -0000 Subject: [llvm-commits] [llvm] r100092 - /llvm/trunk/include/llvm/Support/DebugLoc.h Message-ID: <20100401062956.8D4852A6C12C@llvm.org> Author: lattner Date: Thu Apr 1 01:29:56 2010 New Revision: 100092 URL: http://llvm.org/viewvc/llvm-project?rev=100092&view=rev Log: add comments, don't require inlined-at to be specified. Modified: llvm/trunk/include/llvm/Support/DebugLoc.h Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=100092&r1=100091&r2=100092&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Thu Apr 1 01:29:56 2010 @@ -37,8 +37,10 @@ public: NewDebugLoc() : LineCol(0), ScopeIdx(0) {} // Defaults to unknown. + /// get - Get a new DebugLoc that corresponds to the specified line/col + /// scope/inline location. static NewDebugLoc get(unsigned Line, unsigned Col, - MDNode *Scope, MDNode *InlinedAt); + MDNode *Scope, MDNode *InlinedAt = 0); /// getFromDILocation - Translate the DILocation quad into a NewDebugLoc. static NewDebugLoc getFromDILocation(MDNode *N); From sabre at nondot.org Thu Apr 1 01:31:44 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 06:31:44 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r100094 - /llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Message-ID: <20100401063144.778EC2A6C12D@llvm.org> Author: lattner Date: Thu Apr 1 01:31:44 2010 New Revision: 100094 URL: http://llvm.org/viewvc/llvm-project?rev=100094&view=rev Log: adjust to IRBuilder change and use faster DebugLoc apis. Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp?rev=100094&r1=100093&r2=100094&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-debug.cpp Thu Apr 1 01:31:44 2010 @@ -470,12 +470,8 @@ // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); - - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, VarScope, DO); - Call->setDbgMetadata(DL.getNode()); + Call->setDebugLoc(NewDebugLoc::get(CurLineNo, 0, VarScope.getNode())); } @@ -524,12 +520,8 @@ if (RegionStack.empty()) return; - llvm::DIDescriptor DR(cast(RegionStack.back())); - llvm::DIScope DS = llvm::DIScope(DR.getNode()); - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); - Builder.SetCurrentDebugLocation(DL.getNode()); + MDNode *Scope = cast(RegionStack.back()); + Builder.SetCurrentDebugLocation(NewDebugLoc::get(CurLineNo,0/*col*/,Scope)); } } From sabre at nondot.org Thu Apr 1 01:31:45 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 01 Apr 2010 06:31:45 -0000 Subject: [llvm-commits] [llvm] r100095 - in /llvm/trunk: include/llvm/Support/IRBuilder.h lib/VMCore/Core.cpp Message-ID: <20100401063145.A5D162A6C12E@llvm.org> Author: lattner Date: Thu Apr 1 01:31:45 2010 New Revision: 100095 URL: http://llvm.org/viewvc/llvm-project?rev=100095&view=rev Log: switch IRBuilder to use NewDebugLoc for locations instead of raw mdnodes. This allows frontends to specify debug locations without ever creating an MDNode for the DILocation. This requires a corresponding clang/llvm-gcc change which I'll try to commit as simultaneously as possible. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100095&r1=100094&r2=100095&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Thu Apr 1 01:31:45 2010 @@ -40,7 +40,7 @@ /// IRBuilderBase - Common base class shared among various IRBuilders. class IRBuilderBase { - MDNode *CurDbgLocation; + NewDebugLoc CurDbgLocation; protected: BasicBlock *BB; BasicBlock::iterator InsertPt; @@ -48,7 +48,7 @@ public: IRBuilderBase(LLVMContext &context) - : CurDbgLocation(0), Context(context) { + : Context(context) { ClearInsertionPoint(); } @@ -64,6 +64,7 @@ BasicBlock *GetInsertBlock() const { return BB; } BasicBlock::iterator GetInsertPoint() const { return InsertPt; } + LLVMContext &getContext() const { return Context; } /// SetInsertPoint - This specifies that created instructions should be /// appended to the end of the specified block. @@ -81,19 +82,19 @@ /// SetCurrentDebugLocation - Set location information used by debugging /// information. - void SetCurrentDebugLocation(MDNode *L) { + void SetCurrentDebugLocation(const NewDebugLoc &L) { CurDbgLocation = L; } /// getCurrentDebugLocation - Get location information used by debugging /// information. - MDNode *getCurrentDebugLocation() const { return CurDbgLocation; } + const NewDebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; } /// SetInstDebugLocation - If this builder has a current debug location, set /// it on the specified instruction. void SetInstDebugLocation(Instruction *I) const { - if (CurDbgLocation) - I->setDbgMetadata(CurDbgLocation); + if (!CurDbgLocation.isUnknown()) + I->setDebugLoc(CurDbgLocation); } //===--------------------------------------------------------------------===// @@ -215,7 +216,7 @@ template InstTy *Insert(InstTy *I, const Twine &Name = "") const { this->InsertHelper(I, Name, BB, InsertPt); - if (getCurrentDebugLocation() != 0) + if (!getCurrentDebugLocation().isUnknown()) this->SetInstDebugLocation(I); return I; } Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=100095&r1=100094&r2=100095&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Apr 1 01:31:45 2010 @@ -1651,7 +1651,7 @@ } void LLVMClearInsertionPosition(LLVMBuilderRef Builder) { - unwrap(Builder)->ClearInsertionPoint (); + unwrap(Builder)->ClearInsertionPoint(); } void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr) { @@ -1670,11 +1670,13 @@ /*--.. Metadata builders ...................................................--*/ void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L) { - unwrap(Builder)->SetCurrentDebugLocation(L? unwrap(L) : NULL); + MDNode *Loc = L ? unwrap(L) : NULL; + unwrap(Builder)->SetCurrentDebugLocation(NewDebugLoc::getFromDILocation(Loc)); } LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder) { - return wrap(unwrap(Builder)->getCurrentDebugLocation()); + return wrap(unwrap(Builder)->getCurrentDebugLocation() + .getAsMDNode(unwrap(Builder)->getContext())); } void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst) { From nicholas at mxc.ca Thu Apr 1 02:34:00 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 01 Apr 2010 07:34:00 -0000 Subject: [llvm-commits] [llvm] r100097 - /llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Message-ID: <20100401073400.3A6F22A6C12D@llvm.org> Author: nicholas Date: Thu Apr 1 02:34:00 2010 New Revision: 100097 URL: http://llvm.org/viewvc/llvm-project?rev=100097&view=rev Log: Clean up this file a little, no functionality change. This is a subset of my patch back in r94322. Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=100097&r1=100096&r2=100097&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Thu Apr 1 02:34:00 2010 @@ -50,7 +50,7 @@ /// argument. Used so that arguments and return values can be used /// interchangably. struct RetOrArg { - RetOrArg(const Function* F, unsigned Idx, bool IsArg) : F(F), Idx(Idx), + RetOrArg(const Function *F, unsigned Idx, bool IsArg) : F(F), Idx(Idx), IsArg(IsArg) {} const Function *F; unsigned Idx; @@ -280,7 +280,7 @@ /// for void functions and 1 for functions not returning a struct. It returns /// the number of struct elements for functions returning a struct. static unsigned NumRetVals(const Function *F) { - if (F->getReturnType() == Type::getVoidTy(F->getContext())) + if (F->getReturnType()->isVoidTy()) return 0; else if (const StructType *STy = dyn_cast(F->getReturnType())) return STy->getNumElements(); @@ -305,7 +305,7 @@ /// SurveyUse - This looks at a single use of an argument or return value /// and determines if it should be alive or not. Adds this use to MaybeLiveUses -/// if it causes the used value to become MaybeAlive. +/// if it causes the used value to become MaybeLive. /// /// RetValNum is the return value number to use when this use is used in a /// return instruction. This is used in the recursion, you should always leave @@ -603,8 +603,8 @@ // -1 means unused, other numbers are the new index SmallVector NewRetIdxs(RetCount, -1); std::vector RetTypes; - if (RetTy == Type::getVoidTy(F->getContext())) { - NRetTy = Type::getVoidTy(F->getContext()); + if (RetTy->isVoidTy()) { + NRetTy = RetTy; } else { const StructType *STy = dyn_cast(RetTy); if (STy) @@ -653,7 +653,7 @@ // values. Otherwise, ensure that we don't have any conflicting attributes // here. Currently, this should not be possible, but special handling might be // required when new return value attributes are added. - if (NRetTy == Type::getVoidTy(F->getContext())) + if (NRetTy->isVoidTy()) RAttrs &= ~Attribute::typeIncompatible(NRetTy); else assert((RAttrs & Attribute::typeIncompatible(NRetTy)) == 0 @@ -705,8 +705,7 @@ } // Create the new function type based on the recomputed parameters. - FunctionType *NFTy = FunctionType::get(NRetTy, Params, - FTy->isVarArg()); + FunctionType *NFTy = FunctionType::get(NRetTy, Params, FTy->isVarArg()); // No change? if (NFTy == FTy) @@ -791,7 +790,7 @@ // Return type not changed? Just replace users then. Call->replaceAllUsesWith(New); New->takeName(Call); - } else if (New->getType() == Type::getVoidTy(F->getContext())) { + } else if (New->getType()->isVoidTy()) { // Our return value has uses, but they will get removed later on. // Replace by null for now. Call->replaceAllUsesWith(Constant::getNullValue(Call->getType())); @@ -931,9 +930,9 @@ SurveyFunction(*I); // Now, remove all dead arguments and return values from each function in - // turn + // turn. for (Module::iterator I = M.begin(), E = M.end(); I != E; ) { - // Increment now, because the function will probably get removed (ie + // Increment now, because the function will probably get removed (ie. // replaced by a new one). Function *F = I++; Changed |= RemoveDeadStuffFromFunction(F); From ggreif at gmail.com Thu Apr 1 03:21:08 2010 From: ggreif at gmail.com (Gabor Greif) Date: Thu, 01 Apr 2010 08:21:08 -0000 Subject: [llvm-commits] [llvm] r100100 - in /llvm/trunk: ./ docs/ProgrammersManual.html include/llvm/Support/CallSite.h lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/Transforms/Scalar/SCCP.cpp lib/VMCore/Function.cpp lib/VMCore/Instructions.cpp Message-ID: <20100401082109.319A52A6C12C@llvm.org> Author: ggreif Date: Thu Apr 1 03:21:08 2010 New Revision: 100100 URL: http://llvm.org/viewvc/llvm-project?rev=100100&view=rev Log: Introduce ImmutableCallSite, useful for contexts where no mutation is necessary. Inherits from new templated baseclass CallSiteBase<> which is highly customizable. Base CallSite on it too, in a configuration that allows full mutation. Adapt some call sites in analyses to employ ImmutableCallSite. Modified: llvm/trunk/ (props changed) llvm/trunk/docs/ProgrammersManual.html (props changed) llvm/trunk/include/llvm/Support/CallSite.h llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/lib/Transforms/Scalar/SCCP.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/Instructions.cpp Propchange: llvm/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Apr 1 03:21:08 2010 @@ -1 +1,2 @@ /llvm/branches/ggreif/InvokeInst-operands:98645-99398 +/llvm/branches/ggreif/const-CallSite:99517-100006 Propchange: llvm/trunk/docs/ProgrammersManual.html ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Thu Apr 1 03:21:08 2010 @@ -0,0 +1,3 @@ +/llvm/branches/ggreif/InvokeInst-operands/docs/ProgrammersManual.html:98645-99398 +/llvm/branches/ggreif/const-CallSite/docs/ProgrammersManual.html:99517-100006 +/llvm/trunk/docs/ProgrammersManual.html:70891 Modified: llvm/trunk/include/llvm/Support/CallSite.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CallSite.h?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CallSite.h (original) +++ llvm/trunk/include/llvm/Support/CallSite.h Thu Apr 1 03:21:08 2010 @@ -8,15 +8,18 @@ //===----------------------------------------------------------------------===// // // This file defines the CallSite class, which is a handy wrapper for code that -// wants to treat Call and Invoke instructions in a generic way. +// wants to treat Call and Invoke instructions in a generic way. When in non- +// mutation context (e.g. an analysis) ImmutableCallSite should be used. +// Finally, when some degree of customization is necessary between these two +// extremes, CallSiteBase<> can be supplied with fine-tuned parameters. // -// NOTE: This class is supposed to have "value semantics". So it should be -// passed by value, not by reference; it should not be "new"ed or "delete"d. It -// is efficiently copyable, assignable and constructable, with cost equivalent -// to copying a pointer (notice that it has only a single data member). -// The internal representation carries a flag which indicates which of the two -// variants is enclosed. This allows for cheaper checks when various accessors -// of CallSite are employed. +// NOTE: These classes are supposed to have "value semantics". So they should be +// passed by value, not by reference; they should not be "new"ed or "delete"d. +// They are efficiently copyable, assignable and constructable, with cost +// equivalent to copying a pointer (notice that they have only a single data +// member). The internal representation carries a flag which indicates which of +// the two variants is enclosed. This allows for cheaper checks when various +// accessors of CallSite are employed. // //===----------------------------------------------------------------------===// @@ -34,72 +37,42 @@ class CallInst; class InvokeInst; -class CallSite { - PointerIntPair I; +template +class CallSiteBase { +protected: + PointerIntPair I; public: - CallSite() : I(0, false) {} - CallSite(CallInst *CI) : I(reinterpret_cast(CI), true) {} - CallSite(InvokeInst *II) : I(reinterpret_cast(II), false) {} - CallSite(Instruction *C); - - bool operator==(const CallSite &CS) const { return I == CS.I; } - bool operator!=(const CallSite &CS) const { return I != CS.I; } + CallSiteBase() : I(0, false) {} + CallSiteBase(CallTy *CI) : I(reinterpret_cast(CI), true) {} + CallSiteBase(InvokeTy *II) : I(reinterpret_cast(II), false) {} + CallSiteBase(ValTy *II) { *this = get(II); } + CallSiteBase(InstrTy *II) { + assert(II && "Null instruction given?"); + *this = get(II); + assert(I.getPointer()); + } - /// CallSite::get - This static method is sort of like a constructor. It will - /// create an appropriate call site for a Call or Invoke instruction, but it - /// can also create a null initialized CallSite object for something which is - /// NOT a call site. + /// CallSiteBase::get - This static method is sort of like a constructor. It + /// will create an appropriate call site for a Call or Invoke instruction, but + /// it can also create a null initialized CallSiteBase object for something + /// which is NOT a call site. /// - static CallSite get(Value *V) { - if (Instruction *I = dyn_cast(V)) { - if (I->getOpcode() == Instruction::Call) - return CallSite(reinterpret_cast(I)); - else if (I->getOpcode() == Instruction::Invoke) - return CallSite(reinterpret_cast(I)); + static CallSiteBase get(ValTy *V) { + if (InstrTy *II = dyn_cast(V)) { + if (II->getOpcode() == Instruction::Call) + return CallSiteBase(reinterpret_cast(II)); + else if (II->getOpcode() == Instruction::Invoke) + return CallSiteBase(reinterpret_cast(II)); } - return CallSite(); + return CallSiteBase(); } - /// getCallingConv/setCallingConv - get or set the calling convention of the - /// call. - CallingConv::ID getCallingConv() const; - void setCallingConv(CallingConv::ID CC); - - /// getAttributes/setAttributes - get or set the parameter attributes of - /// the call. - const AttrListPtr &getAttributes() const; - void setAttributes(const AttrListPtr &PAL); - - /// paramHasAttr - whether the call or the callee has the given attribute. - bool paramHasAttr(uint16_t i, Attributes attr) const; - - /// @brief Extract the alignment for a call or parameter (0=unknown). - uint16_t getParamAlignment(uint16_t i) const; - - /// @brief Return true if the call should not be inlined. - bool isNoInline() const; - void setIsNoInline(bool Value = true); - - /// @brief Determine if the call does not access memory. - bool doesNotAccessMemory() const; - void setDoesNotAccessMemory(bool doesNotAccessMemory = true); - - /// @brief Determine if the call does not access or only reads memory. - bool onlyReadsMemory() const; - void setOnlyReadsMemory(bool onlyReadsMemory = true); - - /// @brief Determine if the call cannot return. - bool doesNotReturn() const; - void setDoesNotReturn(bool doesNotReturn = true); - - /// @brief Determine if the call cannot unwind. - bool doesNotThrow() const; - void setDoesNotThrow(bool doesNotThrow = true); - - /// getType - Return the type of the instruction that generated this call site - /// - const Type *getType() const { return getInstruction()->getType(); } - /// isCall - true if a CallInst is enclosed. /// Note that !isCall() does not mean it is an InvokeInst enclosed, /// it also could signify a NULL Instruction pointer. @@ -109,18 +82,13 @@ /// bool isInvoke() const { return getInstruction() && !I.getInt(); } - /// getInstruction - Return the instruction this call site corresponds to - /// - Instruction *getInstruction() const { return I.getPointer(); } - - /// getCaller - Return the caller function for this call site - /// - Function *getCaller() const { return getInstruction() - ->getParent()->getParent(); } + InstrTy *getInstruction() const { return I.getPointer(); } + InstrTy *operator->() const { return I.getPointer(); } + operator bool() const { return I.getPointer(); } /// getCalledValue - Return the pointer to function that is being called... /// - Value *getCalledValue() const { + ValTy *getCalledValue() const { assert(getInstruction() && "Not a call or invoke instruction!"); return *getCallee(); } @@ -128,8 +96,8 @@ /// getCalledFunction - Return the function being called if this is a direct /// call, otherwise return null (if it's an indirect call). /// - Function *getCalledFunction() const { - return dyn_cast(getCalledValue()); + FunTy *getCalledFunction() const { + return dyn_cast(getCalledValue()); } /// setCalledFunction - Set the callee to the specified value... @@ -139,7 +107,14 @@ *getCallee() = V; } - Value *getArgument(unsigned ArgNo) const { + /// isCallee - Determine whether the passed iterator points to the + /// callee operand's Use. + /// + bool isCallee(value_use_iterator UI) const { + return getCallee() == &UI.getUse(); + } + + ValTy *getArgument(unsigned ArgNo) const { assert(arg_begin() + ArgNo < arg_end() && "Argument # out of range!"); return *(arg_begin()+ArgNo); } @@ -152,69 +127,142 @@ /// Given a value use iterator, returns the argument that corresponds to it. /// Iterator must actually correspond to an argument. - unsigned getArgumentNo(Value::use_iterator I) const { + unsigned getArgumentNo(value_use_iterator I) const { assert(getInstruction() && "Not a call or invoke instruction!"); assert(arg_begin() <= &I.getUse() && &I.getUse() < arg_end() && "Argument # out of range!"); - return &I.getUse() - arg_begin(); } - /// Given an operand number, returns the argument that corresponds to it. - /// OperandNo must be a valid operand number that actually corresponds to an - /// argument. - unsigned getArgumentNo(unsigned OperandNo) const { - assert(OperandNo >= getArgumentOffset() && "Operand number passed was not " - "a valid argument"); - return OperandNo - getArgumentOffset(); - } - - /// hasArgument - Returns true if this CallSite passes the given Value* as an - /// argument to the called function. - bool hasArgument(const Value *Arg) const; - /// arg_iterator - The type of iterator to use when looping over actual /// arguments at this call site... - typedef User::op_iterator arg_iterator; + typedef IterTy arg_iterator; /// arg_begin/arg_end - Return iterators corresponding to the actual argument /// list for a call site. - arg_iterator arg_begin() const { + IterTy arg_begin() const { assert(getInstruction() && "Not a call or invoke instruction!"); // Skip non-arguments - return getInstruction()->op_begin() + getArgumentOffset(); + return (*this)->op_begin() + getArgumentOffset(); } - arg_iterator arg_end() const { return getInstruction()->op_end() - getArgumentEndOffset(); } + IterTy arg_end() const { return (*this)->op_end() - getArgumentEndOffset(); } bool arg_empty() const { return arg_end() == arg_begin(); } unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); } - - bool operator<(const CallSite &CS) const { - return getInstruction() < CS.getInstruction(); - } - - bool isCallee(Value::use_iterator UI) const { - return getCallee() == &UI.getUse(); - } - bool isCallee(Value::const_use_iterator UI) const { - return getCallee() == &UI.getUse(); - } + private: /// Returns the operand number of the first argument unsigned getArgumentOffset() const { if (isCall()) - return 1; // Skip Function + return 1; // Skip Function (ATM) else return 0; // Args are at the front } unsigned getArgumentEndOffset() const { if (isCall()) - return 0; // Unchanged + return 0; // Unchanged (ATM) else return 3; // Skip BB, BB, Function } + IterTy getCallee() const { + // FIXME: this is slow, since we do not have the fast versions + // of the op_*() functions here. See CallSite::getCallee. + // + if (isCall()) + return getInstruction()->op_begin(); // Unchanged (ATM) + else + return getInstruction()->op_end() - 3; // Skip BB, BB, Function + } +}; + +/// ImmutableCallSite - establish a view to a call site for examination +class ImmutableCallSite : public CallSiteBase<> { + typedef CallSiteBase<> _Base; +public: + ImmutableCallSite(const Value* V) : _Base(V) {} + ImmutableCallSite(const CallInst *CI) : _Base(CI) {} + ImmutableCallSite(const InvokeInst *II) : _Base(II) {} + ImmutableCallSite(const Instruction *II) : _Base(II) {} +}; + +class CallSite : public CallSiteBase { + typedef CallSiteBase _Base; +public: + CallSite() {} + CallSite(_Base B) : _Base(B) {} + CallSite(CallInst *CI) : _Base(CI) {} + CallSite(InvokeInst *II) : _Base(II) {} + CallSite(Instruction *II) : _Base(II) {} + + bool operator==(const CallSite &CS) const { return I == CS.I; } + bool operator!=(const CallSite &CS) const { return I != CS.I; } + + /// CallSite::get - This static method is sort of like a constructor. It will + /// create an appropriate call site for a Call or Invoke instruction, but it + /// can also create a null initialized CallSite object for something which is + /// NOT a call site. + /// + static CallSite get(Value *V) { + return _Base::get(V); + } + + /// getCallingConv/setCallingConv - get or set the calling convention of the + /// call. + CallingConv::ID getCallingConv() const; + void setCallingConv(CallingConv::ID CC); + + /// getAttributes/setAttributes - get or set the parameter attributes of + /// the call. + const AttrListPtr &getAttributes() const; + void setAttributes(const AttrListPtr &PAL); + + /// paramHasAttr - whether the call or the callee has the given attribute. + bool paramHasAttr(uint16_t i, Attributes attr) const; + + /// @brief Extract the alignment for a call or parameter (0=unknown). + uint16_t getParamAlignment(uint16_t i) const; + + /// @brief Return true if the call should not be inlined. + bool isNoInline() const; + void setIsNoInline(bool Value = true); + + /// @brief Determine if the call does not access memory. + bool doesNotAccessMemory() const; + void setDoesNotAccessMemory(bool doesNotAccessMemory = true); + + /// @brief Determine if the call does not access or only reads memory. + bool onlyReadsMemory() const; + void setOnlyReadsMemory(bool onlyReadsMemory = true); + + /// @brief Determine if the call cannot return. + bool doesNotReturn() const; + void setDoesNotReturn(bool doesNotReturn = true); + + /// @brief Determine if the call cannot unwind. + bool doesNotThrow() const; + void setDoesNotThrow(bool doesNotThrow = true); + + /// getType - Return the type of the instruction that generated this call site + /// + const Type *getType() const { return (*this)->getType(); } + + /// getCaller - Return the caller function for this call site + /// + Function *getCaller() const { return (*this)->getParent()->getParent(); } + + /// hasArgument - Returns true if this CallSite passes the given Value* as an + /// argument to the called function. + bool hasArgument(const Value *Arg) const; + + bool operator<(const CallSite &CS) const { + return getInstruction() < CS.getInstruction(); + } + +private: User::op_iterator getCallee() const; }; Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Thu Apr 1 03:21:08 2010 @@ -129,11 +129,11 @@ private: Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses); - Liveness SurveyUse(Value::use_iterator U, UseVector &MaybeLiveUses, + Liveness SurveyUse(Value::const_use_iterator U, UseVector &MaybeLiveUses, unsigned RetValNum = 0); - Liveness SurveyUses(Value *V, UseVector &MaybeLiveUses); + Liveness SurveyUses(const Value *V, UseVector &MaybeLiveUses); - void SurveyFunction(Function &F); + void SurveyFunction(const Function &F); void MarkValue(const RetOrArg &RA, Liveness L, const UseVector &MaybeLiveUses); void MarkLive(const RetOrArg &RA); @@ -310,10 +310,10 @@ /// RetValNum is the return value number to use when this use is used in a /// return instruction. This is used in the recursion, you should always leave /// it at 0. -DAE::Liveness DAE::SurveyUse(Value::use_iterator U, UseVector &MaybeLiveUses, - unsigned RetValNum) { - User *V = *U; - if (ReturnInst *RI = dyn_cast(V)) { +DAE::Liveness DAE::SurveyUse(Value::const_use_iterator U, + UseVector &MaybeLiveUses, unsigned RetValNum) { + const User *V = *U; + if (const ReturnInst *RI = dyn_cast(V)) { // The value is returned from a function. It's only live when the // function's return value is live. We use RetValNum here, for the case // that U is really a use of an insertvalue instruction that uses the @@ -322,7 +322,7 @@ // We might be live, depending on the liveness of Use. return MarkIfNotLive(Use, MaybeLiveUses); } - if (InsertValueInst *IV = dyn_cast(V)) { + if (const InsertValueInst *IV = dyn_cast(V)) { if (U.getOperandNo() != InsertValueInst::getAggregateOperandIndex() && IV->hasIndices()) // The use we are examining is inserted into an aggregate. Our liveness @@ -334,7 +334,7 @@ // we don't change RetValNum, but do survey all our uses. Liveness Result = MaybeLive; - for (Value::use_iterator I = IV->use_begin(), + for (Value::const_use_iterator I = IV->use_begin(), E = V->use_end(); I != E; ++I) { Result = SurveyUse(I, MaybeLiveUses, RetValNum); if (Result == Live) @@ -342,9 +342,9 @@ } return Result; } - CallSite CS = CallSite::get(V); - if (CS.getInstruction()) { - Function *F = CS.getCalledFunction(); + + if (ImmutableCallSite CS = V) { + const Function *F = CS.getCalledFunction(); if (F) { // Used in a direct call. @@ -359,7 +359,7 @@ return Live; assert(CS.getArgument(ArgNo) - == CS.getInstruction()->getOperand(U.getOperandNo()) + == CS->getOperand(U.getOperandNo()) && "Argument is not where we expected it"); // Value passed to a normal call. It's only live when the corresponding @@ -378,11 +378,11 @@ /// Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses. If /// the result is Live, MaybeLiveUses might be modified but its content should /// be ignored (since it might not be complete). -DAE::Liveness DAE::SurveyUses(Value *V, UseVector &MaybeLiveUses) { +DAE::Liveness DAE::SurveyUses(const Value *V, UseVector &MaybeLiveUses) { // Assume it's dead (which will only hold if there are no uses at all..). Liveness Result = MaybeLive; // Check each use. - for (Value::use_iterator I = V->use_begin(), + for (Value::const_use_iterator I = V->use_begin(), E = V->use_end(); I != E; ++I) { Result = SurveyUse(I, MaybeLiveUses); if (Result == Live) @@ -399,7 +399,7 @@ // We consider arguments of non-internal functions to be intrinsically alive as // well as arguments to functions which have their "address taken". // -void DAE::SurveyFunction(Function &F) { +void DAE::SurveyFunction(const Function &F) { unsigned RetCount = NumRetVals(&F); // Assume all return values are dead typedef SmallVector RetVals; @@ -411,8 +411,8 @@ // MaybeLive. Initialized to a list of RetCount empty lists. RetUses MaybeLiveRetUses(RetCount); - for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) - if (ReturnInst *RI = dyn_cast(BB->getTerminator())) + for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) + if (const ReturnInst *RI = dyn_cast(BB->getTerminator())) if (RI->getNumOperands() != 0 && RI->getOperand(0)->getType() != F.getFunctionType()->getReturnType()) { // We don't support old style multiple return values. @@ -431,17 +431,18 @@ unsigned NumLiveRetVals = 0; const Type *STy = dyn_cast(F.getReturnType()); // Loop all uses of the function. - for (Value::use_iterator I = F.use_begin(), E = F.use_end(); I != E; ++I) { + for (Value::const_use_iterator I = F.use_begin(), E = F.use_end(); + I != E; ++I) { // If the function is PASSED IN as an argument, its address has been // taken. - CallSite CS = CallSite::get(*I); - if (!CS.getInstruction() || !CS.isCallee(I)) { + ImmutableCallSite CS(*I); + if (!CS || !CS.isCallee(I)) { MarkLive(F); return; } // If this use is anything other than a call site, the function is alive. - Instruction *TheCall = CS.getInstruction(); + const Instruction *TheCall = CS.getInstruction(); if (!TheCall) { // Not a direct call site? MarkLive(F); return; @@ -454,9 +455,9 @@ if (NumLiveRetVals != RetCount) { if (STy) { // Check all uses of the return value. - for (Value::use_iterator I = TheCall->use_begin(), + for (Value::const_use_iterator I = TheCall->use_begin(), E = TheCall->use_end(); I != E; ++I) { - ExtractValueInst *Ext = dyn_cast(*I); + const ExtractValueInst *Ext = dyn_cast(*I); if (Ext && Ext->hasIndices()) { // This use uses a part of our return value, survey the uses of // that part and store the results for this index only. @@ -493,7 +494,7 @@ // Now, check all of our arguments. unsigned i = 0; UseVector MaybeLiveArgUses; - for (Function::arg_iterator AI = F.arg_begin(), + for (Function::const_arg_iterator AI = F.arg_begin(), E = F.arg_end(); AI != E; ++AI, ++i) { // See what the effect of this use is (recording any uses that cause // MaybeLive in MaybeLiveArgUses). @@ -690,7 +691,8 @@ AttributesVec.push_back(AttributeWithIndex::get(~0, FnAttrs)); // Reconstruct the AttributesList based on the vector we constructed. - AttrListPtr NewPAL = AttrListPtr::get(AttributesVec.begin(), AttributesVec.end()); + AttrListPtr NewPAL = AttrListPtr::get(AttributesVec.begin(), + AttributesVec.end()); // Work around LLVM bug PR56: the CWriter cannot emit varargs functions which // have zero fixed arguments. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 1 03:21:08 2010 @@ -119,7 +119,7 @@ /// null/false. When the first accessing function is noticed, it is recorded. /// When a second different accessing function is noticed, /// HasMultipleAccessingFunctions is set to true. - Function *AccessingFunction; + const Function *AccessingFunction; bool HasMultipleAccessingFunctions; /// HasNonInstructionUser - Set to true if this global has a user that is not @@ -140,11 +140,11 @@ // by constants itself. Note that constants cannot be cyclic, so this test is // pretty easy to implement recursively. // -static bool SafeToDestroyConstant(Constant *C) { +static bool SafeToDestroyConstant(const Constant *C) { if (isa(C)) return false; - for (Value::use_iterator UI = C->use_begin(), E = C->use_end(); UI != E; ++UI) - if (Constant *CU = dyn_cast(*UI)) { + for (Value::const_use_iterator UI = C->use_begin(), E = C->use_end(); UI != E; ++UI) + if (const Constant *CU = dyn_cast(*UI)) { if (!SafeToDestroyConstant(CU)) return false; } else return false; @@ -156,26 +156,26 @@ /// structure. If the global has its address taken, return true to indicate we /// can't do anything with it. /// -static bool AnalyzeGlobal(Value *V, GlobalStatus &GS, - SmallPtrSet &PHIUsers) { - for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) - if (ConstantExpr *CE = dyn_cast(*UI)) { +static bool AnalyzeGlobal(const Value *V, GlobalStatus &GS, + SmallPtrSet &PHIUsers) { + for (Value::const_use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) + if (const ConstantExpr *CE = dyn_cast(*UI)) { GS.HasNonInstructionUser = true; if (AnalyzeGlobal(CE, GS, PHIUsers)) return true; - } else if (Instruction *I = dyn_cast(*UI)) { + } else if (const Instruction *I = dyn_cast(*UI)) { if (!GS.HasMultipleAccessingFunctions) { - Function *F = I->getParent()->getParent(); + const Function *F = I->getParent()->getParent(); if (GS.AccessingFunction == 0) GS.AccessingFunction = F; else if (GS.AccessingFunction != F) GS.HasMultipleAccessingFunctions = true; } - if (LoadInst *LI = dyn_cast(I)) { + if (const LoadInst *LI = dyn_cast(I)) { GS.isLoaded = true; if (LI->isVolatile()) return true; // Don't hack on volatile loads. - } else if (StoreInst *SI = dyn_cast(I)) { + } else if (const StoreInst *SI = dyn_cast(I)) { // Don't allow a store OF the address, only stores TO the address. if (SI->getOperand(0) == V) return true; @@ -185,14 +185,13 @@ // value, not an aggregate), keep more specific information about // stores. if (GS.StoredType != GlobalStatus::isStored) { - if (GlobalVariable *GV = dyn_cast(SI->getOperand(1))){ + if (const GlobalVariable *GV = dyn_cast(SI->getOperand(1))){ Value *StoredVal = SI->getOperand(0); if (StoredVal == GV->getInitializer()) { if (GS.StoredType < GlobalStatus::isInitializerStored) GS.StoredType = GlobalStatus::isInitializerStored; } else if (isa(StoredVal) && cast(StoredVal)->getOperand(0) == GV) { - // G = G if (GS.StoredType < GlobalStatus::isInitializerStored) GS.StoredType = GlobalStatus::isInitializerStored; } else if (GS.StoredType < GlobalStatus::isStoredOnce) { @@ -212,7 +211,7 @@ if (AnalyzeGlobal(I, GS, PHIUsers)) return true; } else if (isa(I)) { if (AnalyzeGlobal(I, GS, PHIUsers)) return true; - } else if (PHINode *PN = dyn_cast(I)) { + } else if (const PHINode *PN = dyn_cast(I)) { // PHI nodes we can check just like select or GEP instructions, but we // have to be careful about infinite recursion. if (PHIUsers.insert(PN)) // Not already visited. @@ -230,7 +229,7 @@ } else { return true; // Any other non-load instruction might take address! } - } else if (Constant *C = dyn_cast(*UI)) { + } else if (const Constant *C = dyn_cast(*UI)) { GS.HasNonInstructionUser = true; // We might have a dead and dangling constant hanging off of here. if (!SafeToDestroyConstant(C)) @@ -1029,23 +1028,23 @@ /// LoadUsesSimpleEnoughForHeapSRA - Verify that all uses of V (a load, or a phi /// of a load) are simple enough to perform heap SRA on. This permits GEP's /// that index through the array and struct field, icmps of null, and PHIs. -static bool LoadUsesSimpleEnoughForHeapSRA(Value *V, - SmallPtrSet &LoadUsingPHIs, - SmallPtrSet &LoadUsingPHIsPerLoad) { +static bool LoadUsesSimpleEnoughForHeapSRA(const Value *V, + SmallPtrSet &LoadUsingPHIs, + SmallPtrSet &LoadUsingPHIsPerLoad) { // We permit two users of the load: setcc comparing against the null // pointer, and a getelementptr of a specific form. - for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){ - Instruction *User = cast(*UI); + for (Value::const_use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;++UI){ + const Instruction *User = cast(*UI); // Comparison against null is ok. - if (ICmpInst *ICI = dyn_cast(User)) { + if (const ICmpInst *ICI = dyn_cast(User)) { if (!isa(ICI->getOperand(1))) return false; continue; } // getelementptr is also ok, but only a simple form. - if (GetElementPtrInst *GEPI = dyn_cast(User)) { + if (const GetElementPtrInst *GEPI = dyn_cast(User)) { // Must index into the array and into the struct. if (GEPI->getNumOperands() < 3) return false; @@ -1054,7 +1053,7 @@ continue; } - if (PHINode *PN = dyn_cast(User)) { + if (const PHINode *PN = dyn_cast(User)) { if (!LoadUsingPHIsPerLoad.insert(PN)) // This means some phi nodes are dependent on each other. // Avoid infinite looping! @@ -1081,13 +1080,13 @@ /// AllGlobalLoadUsesSimpleEnoughForHeapSRA - If all users of values loaded from /// GV are simple enough to perform HeapSRA, return true. -static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA(GlobalVariable *GV, +static bool AllGlobalLoadUsesSimpleEnoughForHeapSRA(const GlobalVariable *GV, Instruction *StoredVal) { - SmallPtrSet LoadUsingPHIs; - SmallPtrSet LoadUsingPHIsPerLoad; - for (Value::use_iterator UI = GV->use_begin(), E = GV->use_end(); UI != E; + SmallPtrSet LoadUsingPHIs; + SmallPtrSet LoadUsingPHIsPerLoad; + for (Value::const_use_iterator UI = GV->use_begin(), E = GV->use_end(); UI != E; ++UI) - if (LoadInst *LI = dyn_cast(*UI)) { + if (const LoadInst *LI = dyn_cast(*UI)) { if (!LoadUsesSimpleEnoughForHeapSRA(LI, LoadUsingPHIs, LoadUsingPHIsPerLoad)) return false; @@ -1099,16 +1098,16 @@ // that all inputs the to the PHI nodes are in the same equivalence sets. // Check to verify that all operands of the PHIs are either PHIS that can be // transformed, loads from GV, or MI itself. - for (SmallPtrSet::iterator I = LoadUsingPHIs.begin(), + for (SmallPtrSet::const_iterator I = LoadUsingPHIs.begin(), E = LoadUsingPHIs.end(); I != E; ++I) { - PHINode *PN = *I; + const PHINode *PN = *I; for (unsigned op = 0, e = PN->getNumIncomingValues(); op != e; ++op) { Value *InVal = PN->getIncomingValue(op); // PHI of the stored value itself is ok. if (InVal == StoredVal) continue; - if (PHINode *InPN = dyn_cast(InVal)) { + if (const PHINode *InPN = dyn_cast(InVal)) { // One of the PHIs in our set is (optimistically) ok. if (LoadUsingPHIs.count(InPN)) continue; @@ -1116,7 +1115,7 @@ } // Load from GV is ok. - if (LoadInst *LI = dyn_cast(InVal)) + if (const LoadInst *LI = dyn_cast(InVal)) if (LI->getOperand(0) == GV) continue; @@ -1664,7 +1663,7 @@ /// it if possible. If we make a change, return true. bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, Module::global_iterator &GVI) { - SmallPtrSet PHIUsers; + SmallPtrSet PHIUsers; GlobalStatus GS; GV->removeDeadConstantUsers(); @@ -1715,12 +1714,13 @@ GS.AccessingFunction->hasExternalLinkage() && GV->getType()->getAddressSpace() == 0) { DEBUG(dbgs() << "LOCALIZING GLOBAL: " << *GV); - Instruction* FirstI = GS.AccessingFunction->getEntryBlock().begin(); + Instruction& FirstI = const_cast(*GS.AccessingFunction + ->getEntryBlock().begin()); const Type* ElemTy = GV->getType()->getElementType(); // FIXME: Pass Global's alignment when globals have alignment - AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), FirstI); + AllocaInst* Alloca = new AllocaInst(ElemTy, NULL, GV->getName(), &FirstI); if (!isa(GV->getInitializer())) - new StoreInst(GV->getInitializer(), Alloca, FirstI); + new StoreInst(GV->getInitializer(), Alloca, &FirstI); GV->replaceAllUsesWith(Alloca); GV->eraseFromParent(); Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Apr 1 03:21:08 2010 @@ -1717,7 +1717,7 @@ return true; // Storing addr of GV. } else if (isa(U) || isa(U)) { // Make sure we are calling the function, not passing the address. - CallSite CS((Instruction*)U); + ImmutableCallSite CS(cast(U)); if (!CS.isCallee(UI)) return true; } else if (const LoadInst *LI = dyn_cast(U)) { Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Thu Apr 1 03:21:08 2010 @@ -408,7 +408,7 @@ const User *U = *I; if (!isa(U) && !isa(U)) return PutOffender ? (*PutOffender = U, true) : true; - CallSite CS(const_cast(static_cast(U))); + ImmutableCallSite CS(cast(U)); if (!CS.isCallee(I)) return PutOffender ? (*PutOffender = U, true) : true; } Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=100100&r1=100099&r2=100100&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Thu Apr 1 03:21:08 2010 @@ -43,11 +43,6 @@ else \ cast(II)->METHOD -CallSite::CallSite(Instruction *C) { - assert((isa(C) || isa(C)) && "Not a call!"); - I.setPointer(C); - I.setInt(isa(C)); -} CallingConv::ID CallSite::getCallingConv() const { CALLSITE_DELEGATE_GETTER(getCallingConv()); } From evan.cheng at apple.com Thu Apr 1 03:25:26 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 08:25:26 -0000 Subject: [llvm-commits] [llvm] r100101 - in /llvm/trunk/test/CodeGen/X86: memcpy-2.ll memset64-on-x86-32.ll small-byval-memcpy.ll Message-ID: <20100401082526.89E7C2A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 03:25:26 2010 New Revision: 100101 URL: http://llvm.org/viewvc/llvm-project?rev=100101&view=rev Log: Add -mcpu to memcpy / memset tests to ensure they behave the same on all hosts / targets. Modified: llvm/trunk/test/CodeGen/X86/memcpy-2.ll llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll Modified: llvm/trunk/test/CodeGen/X86/memcpy-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memcpy-2.ll?rev=100101&r1=100100&r2=100101&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memcpy-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memcpy-2.ll Thu Apr 1 03:25:26 2010 @@ -1,6 +1,6 @@ -; RUN: llc < %s -mattr=+sse2 -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=SSE2 -; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=SSE1 -; RUN: llc < %s -mattr=-sse -mtriple=i686-apple-darwin | FileCheck %s -check-prefix=NOSSE +; RUN: llc < %s -mattr=+sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE2 +; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE1 +; RUN: llc < %s -mattr=-sse -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=NOSSE %struct.ParmT = type { [25 x i8], i8, i8* } @.str12 = internal constant [25 x i8] c"image\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" ; <[25 x i8]*> [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll?rev=100101&r1=100100&r2=100101&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll (original) +++ llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll Thu Apr 1 03:25:26 2010 @@ -1,5 +1,6 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin | grep movl | count 20 -; RUN: llc < %s -mtriple=x86_64-apple-darwin | grep movq | count 10 +; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=nehalem | grep movaps | count 5 +; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=core2 | grep movl | count 20 +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core2 | grep movq | count 10 define void @bork() nounwind { entry: Modified: llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll?rev=100101&r1=100100&r2=100101&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll (original) +++ llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll Thu Apr 1 03:25:26 2010 @@ -1,7 +1,5 @@ -; RUN: llc < %s | grep movsd | count 8 - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin8" +; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=core2 | grep movsd | count 8 +; RUN: llc < %s -mtriple=i386-apple-darwin -mcpu=nehalem | grep movups | count 2 define void @ccosl({ x86_fp80, x86_fp80 }* noalias sret %agg.result, { x86_fp80, x86_fp80 }* byval align 4 %z) nounwind { entry: From baldrick at free.fr Thu Apr 1 04:17:23 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 01 Apr 2010 11:17:23 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r100049 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp llvm-convert.cpp llvm-debug.cpp llvm-debug.h llvm-internal.h In-Reply-To: <20100331211242.7CCA82A6C12C@llvm.org> References: <20100331211242.7CCA82A6C12C@llvm.org> Message-ID: <4BB464A3.5080509@free.fr> Hi Stuart, > @@ -512,6 +512,8 @@ > if (!flag_pch_file&& > debug_info_level> DINFO_LEVEL_NONE) > TheDebugInfo = new DebugInfo(TheModule); > + else > + TheDebugInfo = 0; why is this needed? > @@ -1010,7 +1010,7 @@ > // Convert the AST to raw/ugly LLVM code. > Function *Fn; > { > - TreeToLLVM Emitter(fndecl); > + TreeToLLVM *Emitter = getTreeToLLVM(fndecl); It seems that you are keeping the TreeToLLVM object for every function processed. This seems rather wasteful. Surely you can store much less than this. Also, what if gcc garbage collects the fndecl and reallocates the memory for another function (I don't know if this is actually possible) - then getTreeToLLVM will return the wrong result if it is called with the newly allocated function later. > @@ -179,6 +178,7 @@ > TheDebugInfo->setLocationFile(""); > TheDebugInfo->setLocationLine(0); > } > + TheDebugInfo->Initialize(); Here it looks like you first use TheDebugInfo, and only afterwards initialize it. Ciao, Duncan. From baldrick at free.fr Thu Apr 1 05:17:39 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 01 Apr 2010 10:17:39 -0000 Subject: [llvm-commits] [dragonegg] r100103 - /dragonegg/trunk/llvm-debug.cpp Message-ID: <20100401101739.679842A6C12C@llvm.org> Author: baldrick Date: Thu Apr 1 05:17:39 2010 New Revision: 100103 URL: http://llvm.org/viewvc/llvm-project?rev=100103&view=rev Log: Port commit 100094 (lattner) from llvm-gcc: adjust to IRBuilder change and use faster DebugLoc apis. Modified: dragonegg/trunk/llvm-debug.cpp Modified: dragonegg/trunk/llvm-debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-debug.cpp?rev=100103&r1=100102&r2=100103&view=diff ============================================================================== --- dragonegg/trunk/llvm-debug.cpp (original) +++ dragonegg/trunk/llvm-debug.cpp Thu Apr 1 05:17:39 2010 @@ -416,12 +416,7 @@ // Insert an llvm.dbg.declare into the current block. Instruction *Call = DebugFactory.InsertDeclare(AI, D, Builder.GetInsertBlock()); - - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, VarScope, DO); - - Call->setMetadata("dbg", DL.getNode()); + Call->setDebugLoc(NewDebugLoc::get(CurLineNo, 0, VarScope.getNode())); } /// EmitStopPoint - Emit a call to llvm.dbg.stoppoint to indicate a change of @@ -442,12 +437,8 @@ if (RegionStack.empty()) return; - llvm::DIDescriptor DR(cast(RegionStack.back())); - llvm::DIScope DS = llvm::DIScope(DR.getNode()); - llvm::DILocation DO(NULL); - llvm::DILocation DL = - DebugFactory.CreateLocation(CurLineNo, 0 /* column */, DS, DO); - Builder.SetCurrentDebugLocation(DL.getNode()); + MDNode *Scope = cast(RegionStack.back()); + Builder.SetCurrentDebugLocation(NewDebugLoc::get(CurLineNo,0/*col*/,Scope)); } /// EmitGlobalVariable - Emit information about a global variable. From aaronngray.lists at googlemail.com Thu Apr 1 07:25:22 2010 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Thu, 1 Apr 2010 13:25:22 +0100 Subject: [llvm-commits] COFF MCSectionCOFF & TLOF patch Message-ID: Hi Chris, Here's a patch to fix MCSectionCOFF, removing IsDirective and the tabs from MCSectionCOFF and fixing TLOF calls to MCSectionCOFF. Its been tested with 'make TESTSUITE=CodeGen/X86 check'. Patch attached and inline. Aaron Index: include/llvm/MC/MCSection.h =================================================================== --- include/llvm/MC/MCSection.h (revision 100074) +++ include/llvm/MC/MCSection.h (working copy) @@ -45,23 +45,13 @@ // The memory for this string is stored in the same MCContext as *this. StringRef Name; - /// IsDirective - This is true if the section name is a directive, not - /// something that should be printed with ".section". - /// - /// FIXME: This is a hack. Switch to a semantic view of the section instead - /// of a syntactic one. - bool IsDirective; - - MCSectionCOFF(StringRef name, bool isDirective, SectionKind K) - : MCSection(K), Name(name), IsDirective(isDirective) { - } + MCSectionCOFF(StringRef name, SectionKind K) : MCSection(K), Name(name) {} public: - static MCSectionCOFF *Create(StringRef Name, bool IsDirective, + static MCSectionCOFF *Create(StringRef Name, SectionKind K, MCContext &Ctx); StringRef getName() const { return Name; } - bool isDirective() const { return IsDirective; } virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; Index: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h =================================================================== --- include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (revision 100074) +++ include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (working copy) @@ -200,8 +200,7 @@ /// getCOFFSection - Return the MCSection for the specified COFF section. /// FIXME: Switch this to a semantic view eventually. - const MCSection *getCOFFSection(StringRef Name, bool isDirective, - SectionKind K) const; + const MCSection *getCOFFSection(StringRef Name, SectionKind K) const; }; } // end namespace llvm Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp =================================================================== --- lib/CodeGen/TargetLoweringObjectFileImpl.cpp (revision 100074) +++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp (working copy) @@ -803,7 +803,7 @@ const MCSection *TargetLoweringObjectFileCOFF:: -getCOFFSection(StringRef Name, bool isDirective, SectionKind Kind) const { +getCOFFSection(StringRef Name, SectionKind Kind) const { // Create the map if it doesn't already exist. if (UniquingMap == 0) UniquingMap = new MachOUniqueMapTy(); @@ -813,7 +813,7 @@ const MCSectionCOFF *&Entry = Map[Name]; if (Entry) return Entry; - return Entry = MCSectionCOFF::Create(Name, isDirective, Kind, getContext()); + return Entry = MCSectionCOFF::Create(Name, Kind, getContext()); } void TargetLoweringObjectFileCOFF::Initialize(MCContext &Ctx, @@ -821,63 +821,51 @@ if (UniquingMap != 0) ((COFFUniqueMapTy*)UniquingMap)->clear(); TargetLoweringObjectFile::Initialize(Ctx, TM); - TextSection = getCOFFSection("\t.text", true, SectionKind::getText()); - DataSection = getCOFFSection("\t.data", true, SectionKind::getDataRel()); + TextSection = getCOFFSection(".text", SectionKind::getText()); + DataSection = getCOFFSection(".data", SectionKind::getDataRel()); StaticCtorSection = - getCOFFSection(".ctors", false, SectionKind::getDataRel()); + getCOFFSection(".ctors", SectionKind::getDataRel()); StaticDtorSection = - getCOFFSection(".dtors", false, SectionKind::getDataRel()); + getCOFFSection(".dtors", SectionKind::getDataRel()); // FIXME: We're emitting LSDA info into a readonly section on COFF, even // though it contains relocatable pointers. In PIC mode, this is probably a // big runtime hit for C++ apps. Either the contents of the LSDA need to be // adjusted or this should be a data section. LSDASection = - getCOFFSection(".gcc_except_table", false, SectionKind::getReadOnly()); + getCOFFSection(".gcc_except_table", SectionKind::getReadOnly()); EHFrameSection = - getCOFFSection(".eh_frame", false, SectionKind::getDataRel()); + getCOFFSection(".eh_frame", SectionKind::getDataRel()); // Debug info. - // FIXME: Don't use 'directive' mode here. DwarfAbbrevSection = - getCOFFSection("\t.section\t.debug_abbrev,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_abbrev", SectionKind::getMetadata()); DwarfInfoSection = - getCOFFSection("\t.section\t.debug_info,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_info", SectionKind::getMetadata()); DwarfLineSection = - getCOFFSection("\t.section\t.debug_line,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_line", SectionKind::getMetadata()); DwarfFrameSection = - getCOFFSection("\t.section\t.debug_frame,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_frame", SectionKind::getMetadata()); DwarfPubNamesSection = - getCOFFSection("\t.section\t.debug_pubnames,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_pubnames", SectionKind::getMetadata()); DwarfPubTypesSection = - getCOFFSection("\t.section\t.debug_pubtypes,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_pubtypes", SectionKind::getMetadata()); DwarfStrSection = - getCOFFSection("\t.section\t.debug_str,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_str", SectionKind::getMetadata()); DwarfLocSection = - getCOFFSection("\t.section\t.debug_loc,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_loc", SectionKind::getMetadata()); DwarfARangesSection = - getCOFFSection("\t.section\t.debug_aranges,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_aranges", SectionKind::getMetadata()); DwarfRangesSection = - getCOFFSection("\t.section\t.debug_ranges,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_ranges", SectionKind::getMetadata()); DwarfMacroInfoSection = - getCOFFSection("\t.section\t.debug_macinfo,\"dr\"", - true, SectionKind::getMetadata()); + getCOFFSection(".debug_macinfo", SectionKind::getMetadata()); } const MCSection *TargetLoweringObjectFileCOFF:: getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const { - return getCOFFSection(GV->getSection(), false, Kind); + return getCOFFSection(GV->getSection(), Kind); } static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) { @@ -901,7 +889,7 @@ SmallString<128> Name(Prefix, Prefix+strlen(Prefix)); MCSymbol *Sym = Mang->getSymbol(GV); Name.append(Sym->getName().begin(), Sym->getName().end()); - return getCOFFSection(Name.str(), false, Kind); + return getCOFFSection(Name.str(), Kind); } if (Kind.isText()) Index: lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp =================================================================== --- lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (revision 100074) +++ lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp (working copy) @@ -594,8 +594,7 @@ // Output linker support code for dllexported globals on windows. if (!DLLExportedGlobals.empty() || !DLLExportedFns.empty()) { - OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".section .drectve", - true, + OutStreamer.SwitchSection(TLOFCOFF.getCOFFSection(".drectve", SectionKind::getMetadata())); for (unsigned i = 0, e = DLLExportedGlobals.size(); i != e; ++i) O << "\t.ascii \" -export:" << *DLLExportedGlobals[i] << ",data\"\n"; Index: lib/MC/MCSection.cpp =================================================================== --- lib/MC/MCSection.cpp (revision 100074) +++ lib/MC/MCSection.cpp (working copy) @@ -25,19 +25,17 @@ //===----------------------------------------------------------------------===// MCSectionCOFF *MCSectionCOFF:: -Create(StringRef Name, bool IsDirective, SectionKind K, MCContext &Ctx) { +Create(StringRef Name, SectionKind K, MCContext &Ctx) { char *NameCopy = static_cast( Ctx.Allocate(Name.size(), /*Alignment=*/1)); memcpy(NameCopy, Name.data(), Name.size()); - return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()), - IsDirective, K); + return new (Ctx) MCSectionCOFF(StringRef(NameCopy, Name.size()), K); } void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const { - - if (isDirective()) { - OS << getName() << '\n'; + if (getName() == StringRef(".text") || getName() == StringRef(".data")) { + OS << "\t" << getName() << '\n'; return; } OS << "\t.section\t" << getName() << ",\""; @@ -45,5 +43,7 @@ OS << 'x'; if (getKind().isWriteable()) OS << 'w'; + if (getKind().isMetadata()) + OS << "dr"; OS << "\"\n"; } -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/6dbba8de/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-coff-mai-tlof.patch Type: application/octet-stream Size: 9292 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/6dbba8de/attachment.obj From anton at korobeynikov.info Thu Apr 1 07:36:02 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 1 Apr 2010 16:36:02 +0400 Subject: [llvm-commits] COFF MCSectionCOFF & TLOF patch In-Reply-To: References: Message-ID: Hello, Aaron > Its been tested with 'make TESTSUITE=CodeGen/X86 check'. I doubt this is enough test for COFF targets. Have you tried something non-trivial? E.g. llvm-gcc compilation & compilation of something huge? Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Thu Apr 1 07:39:06 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Thu, 1 Apr 2010 16:39:06 +0400 Subject: [llvm-commits] COFF MCSectionCOFF & TLOF patch In-Reply-To: References: Message-ID: Aaron, > + if (getKind().isMetadata()) > + OS << "dr"; This is definitely incorrect. "d" means debug and "r" - read-only. These section flags should be emitted separately. The section kind should have been messed somewhere. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From aaronngray.lists at googlemail.com Thu Apr 1 07:51:40 2010 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Thu, 1 Apr 2010 13:51:40 +0100 Subject: [llvm-commits] COFF MCSectionCOFF & TLOF patch In-Reply-To: References: Message-ID: 2010/4/1 Anton Korobeynikov > Aaron, > > > + if (getKind().isMetadata()) > > + OS << "dr"; > This is definitely incorrect. "d" means debug and "r" - read-only. > These section flags should be emitted separately. The section kind > should have been messed somewhere. Okay, I should have looked at this further, but it should be compatible and transparent compared with existing code. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/00c7cc74/attachment.html From aaronngray.lists at googlemail.com Thu Apr 1 07:54:11 2010 From: aaronngray.lists at googlemail.com (Aaron Gray) Date: Thu, 1 Apr 2010 13:54:11 +0100 Subject: [llvm-commits] COFF MCSectionCOFF & TLOF patch In-Reply-To: References: Message-ID: On 1 April 2010 13:36, Anton Korobeynikov wrote: > Hello, Aaron > > > Its been tested with 'make TESTSUITE=CodeGen/X86 check'. > I doubt this is enough test for COFF targets. Have you tried something > non-trivial? E.g. llvm-gcc compilation & compilation of something > huge? > Right, llvm-gcc is broken on Cygwin so I cannot really do further testing. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/2afb886e/attachment.html From benny.kra at googlemail.com Thu Apr 1 09:35:22 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 01 Apr 2010 14:35:22 -0000 Subject: [llvm-commits] [llvm] r100106 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <20100401143522.C16C62A6C12C@llvm.org> Author: d0k Date: Thu Apr 1 09:35:22 2010 New Revision: 100106 URL: http://llvm.org/viewvc/llvm-project?rev=100106&view=rev Log: Various improvements to MemoryBuffer::getFile: - Use a RAII object to close the FD. - Use sys::StrError instead of thread-unsafe strerror calls. - Recover gracefully if read returns zero. This works around an issue on DragonFlyBSD where /dev/null has an st_size of 136 but we can't read 136 bytes from it. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=100106&r1=100105&r2=100106&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Thu Apr 1 09:35:22 2010 @@ -14,6 +14,8 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/System/Errno.h" #include "llvm/System/Path.h" #include "llvm/System/Process.h" #include "llvm/System/Program.h" @@ -167,6 +169,14 @@ sys::Path::UnMapFilePages(getBufferStart(), getBufferSize()); } }; + +/// FileCloser - RAII object to make sure an FD gets closed properly. +class FileCloser { + int FD; +public: + FileCloser(int FD) : FD(FD) {} + ~FileCloser() { ::close(FD); } +}; } MemoryBuffer *MemoryBuffer::getFile(StringRef Filename, std::string *ErrStr, @@ -178,9 +188,10 @@ SmallString<256> PathBuf(Filename.begin(), Filename.end()); int FD = ::open(PathBuf.c_str(), O_RDONLY|OpenFlags); if (FD == -1) { - if (ErrStr) *ErrStr = strerror(errno); + if (ErrStr) *ErrStr = sys::StrError(); return 0; } + FileCloser FC(FD); // Close FD on return. // If we don't know the file size, use fstat to find out. fstat on an open // file descriptor is cheaper than stat on a random path. @@ -190,8 +201,7 @@ // TODO: This should use fstat64 when available. if (fstat(FD, FileInfoPtr) == -1) { - if (ErrStr) *ErrStr = strerror(errno); - ::close(FD); + if (ErrStr) *ErrStr = sys::StrError(); return 0; } FileSize = FileInfoPtr->st_size; @@ -208,7 +218,6 @@ (FileSize & (sys::Process::GetPageSize()-1)) != 0) { if (const char *Pages = sys::Path::MapInFilePages(FD, FileSize)) { // Close the file descriptor, now that the whole file is in memory. - ::close(FD); return new MemoryBufferMMapFile(Filename, Pages, FileSize); } } @@ -217,30 +226,30 @@ if (!Buf) { // Failed to create a buffer. if (ErrStr) *ErrStr = "could not allocate buffer"; - ::close(FD); return 0; } OwningPtr SB(Buf); char *BufPtr = const_cast(SB->getBufferStart()); - + size_t BytesLeft = FileSize; while (BytesLeft) { ssize_t NumRead = ::read(FD, BufPtr, BytesLeft); - if (NumRead > 0) { - BytesLeft -= NumRead; - BufPtr += NumRead; - } else if (NumRead == -1 && errno == EINTR) { - // try again - } else { - // error reading. - if (ErrStr) *ErrStr = strerror(errno); - close(FD); + if (NumRead == -1) { + if (errno == EINTR) + continue; + // Error while reading. + if (ErrStr) *ErrStr = sys::StrError(); return 0; + } else if (NumRead == 0) { + Buf->BufferEnd = BufPtr; + *BufPtr = 0; // Null terminate buffer. + return SB.take(); } + BytesLeft -= NumRead; + BufPtr += NumRead; } - close(FD); - + return SB.take(); } From benny.kra at googlemail.com Thu Apr 1 09:39:55 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 01 Apr 2010 14:39:55 -0000 Subject: [llvm-commits] [llvm] r100107 - /llvm/trunk/lib/Support/MemoryBuffer.cpp Message-ID: <20100401143955.A56EE2A6C12C@llvm.org> Author: d0k Date: Thu Apr 1 09:39:55 2010 New Revision: 100107 URL: http://llvm.org/viewvc/llvm-project?rev=100107&view=rev Log: Remove accidental include and add a comment. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=100107&r1=100106&r2=100107&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Thu Apr 1 09:39:55 2010 @@ -14,7 +14,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/System/Errno.h" #include "llvm/System/Path.h" #include "llvm/System/Process.h" @@ -242,8 +241,9 @@ if (ErrStr) *ErrStr = sys::StrError(); return 0; } else if (NumRead == 0) { + // We hit EOF early, truncate and terminate buffer. Buf->BufferEnd = BufPtr; - *BufPtr = 0; // Null terminate buffer. + *BufPtr = 0; return SB.take(); } BytesLeft -= NumRead; From dpatel at apple.com Thu Apr 1 12:16:48 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 Apr 2010 17:16:48 -0000 Subject: [llvm-commits] [llvm] r100116 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100401171648.2FC182A6C12C@llvm.org> Author: dpatel Date: Thu Apr 1 12:16:48 2010 New Revision: 100116 URL: http://llvm.org/viewvc/llvm-project?rev=100116&view=rev Log: Cosmetic changes. Update comment, rename a local variable. 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=100116&r1=100115&r2=100116&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Apr 1 12:16:48 2010 @@ -1234,13 +1234,13 @@ return SPDie; } -/// getUpdatedDbgScope - Find or create DbgScope assicated with the instruction. -/// Initialize scope and update scope hierarchy. +/// getUpdatedDbgScope - Find DbgScope assicated with the instruction. +/// Update scope hierarchy. Create abstract scope if required. DbgScope *DwarfDebug::getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt) { assert(N && "Invalid Scope encoding!"); assert(MI && "Missing machine instruction!"); - bool GetConcreteScope = InlinedAt != 0; + bool isAConcreteScope = InlinedAt != 0; DbgScope *NScope = NULL; @@ -1254,7 +1254,7 @@ return NScope; DbgScope *Parent = NULL; - if (GetConcreteScope) { + if (isAConcreteScope) { DILocation IL(InlinedAt); Parent = getUpdatedDbgScope(IL.getScope().getNode(), MI, IL.getOrigLocation().getNode()); @@ -1276,7 +1276,7 @@ CurrentFnDbgScope = NScope; } - if (GetConcreteScope) { + if (isAConcreteScope) { ConcreteScopes[InlinedAt] = NScope; getOrCreateAbstractScope(N); } From dpatel at apple.com Thu Apr 1 12:32:01 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 Apr 2010 17:32:01 -0000 Subject: [llvm-commits] [llvm] r100117 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100401173201.3128A2A6C12C@llvm.org> Author: dpatel Date: Thu Apr 1 12:32:01 2010 New Revision: 100117 URL: http://llvm.org/viewvc/llvm-project?rev=100117&view=rev Log: Skip instructions until new scope is seen. 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=100117&r1=100116&r2=100117&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Apr 1 12:32:01 2010 @@ -2146,6 +2146,8 @@ DenseMap MIIndexMap; unsigned MIIndex = 0; + MDNode *PrevScope = NULL; + MDNode *PrevInlinedAt = NULL; // Scan each instruction and create scopes. First build working set of scopes. for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { @@ -2159,17 +2161,23 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); - if (!DLTScope.getNode()) continue; + MDNode *NewScope = DLTScope.getNode(); + if (!NewScope) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. if (DLTScope.isCompileUnit()) continue; - createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode()); + MDNode *NewInlinedAt = DLT.getOrigLocation().getNode(); + if (NewScope == PrevScope && NewInlinedAt == PrevInlinedAt) continue; + createDbgScope(NewScope, NewInlinedAt); + PrevScope = NewScope; + PrevInlinedAt = NewInlinedAt; } } - // Build scope hierarchy using working set of scopes. + PrevScope = NULL; + PrevInlinedAt = NULL; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); @@ -2181,14 +2189,18 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); - if (!DLTScope.getNode()) continue; + MDNode *NewScope = DLTScope.getNode(); + if (!NewScope) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. if (DLTScope.isCompileUnit()) continue; - DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn, - DLT.getOrigLocation().getNode()); + MDNode *NewInlinedAt = DLT.getOrigLocation().getNode(); + if (NewScope == PrevScope && NewInlinedAt == PrevInlinedAt) continue; + DbgScope *Scope = getUpdatedDbgScope(NewScope, MInsn, NewInlinedAt); Scope->setLastInsn(MInsn); + PrevScope = NewScope; + PrevInlinedAt = NewInlinedAt; } } From evan.cheng at apple.com Thu Apr 1 13:19:11 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 18:19:11 -0000 Subject: [llvm-commits] [llvm] r100118 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCISelLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h test/CodeGen/X86/memset-2.ll Message-ID: <20100401181912.3FD552A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 13:19:11 2010 New Revision: 100118 URL: http://llvm.org/viewvc/llvm-project?rev=100118&view=rev Log: - Avoid using floating point stores to implement memset unless the value is zero. - Do not try to infer GV alignment unless its type is sized. It's not possible to infer alignment if it has opaque type. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/test/CodeGen/X86/memset-2.ll Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Apr 1 13:19:11 2010 @@ -638,7 +638,7 @@ /// determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - SelectionDAG &DAG) const { + bool SafeToUseFP, SelectionDAG &DAG) const { return MVT::Other; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 1 13:19:11 2010 @@ -3195,9 +3195,9 @@ /// is below the threshold. It returns the types of the sequence of /// memory ops to perform memset / memcpy by reference. static bool FindOptimalMemOpLowering(std::vector &MemOps, - SDValue Dst, SDValue Src, unsigned Limit, uint64_t Size, unsigned DstAlign, unsigned SrcAlign, + bool SafeToUseFP, SelectionDAG &DAG, const TargetLowering &TLI) { assert((SrcAlign == 0 || SrcAlign >= DstAlign) && @@ -3207,7 +3207,7 @@ // the inferred alignment of the source. 'DstAlign', on the other hand, is the // specified alignment of the memory operation. If it is zero, that means // it's possible to change the alignment of the destination. - EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, DAG); + EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, SafeToUseFP, DAG); if (VT == MVT::Other) { VT = TLI.getPointerTy(); @@ -3285,9 +3285,9 @@ std::string Str; bool CopyFromStr = isMemSrcFromString(Src, Str); bool isZeroStr = CopyFromStr && Str.empty(); - if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, + if (!FindOptimalMemOpLowering(MemOps, Limit, Size, (DstAlignCanChange ? 0 : Align), - (isZeroStr ? 0 : SrcAlign), DAG, TLI)) + (isZeroStr ? 0 : SrcAlign), true, DAG, TLI)) return SDValue(); if (DstAlignCanChange) { @@ -3369,9 +3369,9 @@ if (Align > SrcAlign) SrcAlign = Align; - if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, + if (!FindOptimalMemOpLowering(MemOps, Limit, Size, (DstAlignCanChange ? 0 : Align), - SrcAlign, DAG, TLI)) + SrcAlign, true, DAG, TLI)) return SDValue(); if (DstAlignCanChange) { @@ -3436,9 +3436,11 @@ FrameIndexSDNode *FI = dyn_cast(Dst); if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) DstAlignCanChange = true; - if (!FindOptimalMemOpLowering(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), + bool IsZero = isa(Src) && + cast(Src)->isNullValue(); + if (!FindOptimalMemOpLowering(MemOps, TLI.getMaxStoresPerMemset(), Size, (DstAlignCanChange ? 0 : Align), 0, - DAG, TLI)) + IsZero, DAG, TLI)) return SDValue(); if (DstAlignCanChange) { @@ -6150,8 +6152,10 @@ unsigned Align = GV->getAlignment(); if (!Align) { if (GlobalVariable *GVar = dyn_cast(GV)) { - const TargetData *TD = TLI.getTargetData(); - Align = TD->getPreferredAlignment(GVar); + if (GV->getType()->getElementType()->isSized()) { + const TargetData *TD = TLI.getTargetData(); + Align = TD->getPreferredAlignment(GVar); + } } } return MinAlign(Align, GVOffset); Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Apr 1 13:19:11 2010 @@ -5541,6 +5541,7 @@ EVT PPCTargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, + bool SafeToUseFP, SelectionDAG &DAG) const { if (this->PPCSubTarget.isPPC64()) { return MVT::i64; Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Thu Apr 1 13:19:11 2010 @@ -349,7 +349,7 @@ virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - SelectionDAG &DAG) const; + bool SafeToUseFP, SelectionDAG &DAG) const; /// getFunctionAlignment - Return the Log2 alignment of this function. virtual unsigned getFunctionAlignment(const Function *F) const; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 13:19:11 2010 @@ -1076,6 +1076,7 @@ EVT X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, + bool SafeToUseFP, SelectionDAG &DAG) const { // FIXME: This turns off use of xmm stores for memset/memcpy on targets like // linux. This is because the stack realignment code can't handle certain @@ -1089,9 +1090,10 @@ Subtarget->getStackAlignment() >= 16) { if (Subtarget->hasSSE2()) return MVT::v4i32; - if (Subtarget->hasSSE1()) + if (SafeToUseFP && Subtarget->hasSSE1()) return MVT::v4f32; - } else if (Size >= 8 && + } else if (SafeToUseFP && + Size >= 8 && Subtarget->getStackAlignment() >= 8 && Subtarget->hasSSE2()) return MVT::f64; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Thu Apr 1 13:19:11 2010 @@ -425,7 +425,7 @@ /// determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - SelectionDAG &DAG) const; + bool SafeToUseFP, SelectionDAG &DAG) const; /// allowsUnalignedMemoryAccesses - Returns true if the target allows /// unaligned memory accesses. of the specified type. Modified: llvm/trunk/test/CodeGen/X86/memset-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset-2.ll?rev=100118&r1=100117&r2=100118&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memset-2.ll Thu Apr 1 13:19:11 2010 @@ -4,10 +4,18 @@ declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind -define fastcc void @t() nounwind { +define fastcc void @t1() nounwind { entry: -; CHECK: t: +; CHECK: t1: ; CHECK: call memset call void @llvm.memset.i32( i8* null, i8 0, i32 188, i32 1 ) nounwind unreachable } + +define fastcc void @t2(i8 signext %c) nounwind { +entry: +; CHECK: t2: +; CHECK: call memset + call void @llvm.memset.i32( i8* undef, i8 %c, i32 76, i32 1 ) nounwind + unreachable +} From bob.wilson at apple.com Thu Apr 1 13:47:00 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 01 Apr 2010 18:47:00 -0000 Subject: [llvm-commits] [llvm] r100126 - in /llvm/trunk: include/llvm/Transforms/Utils/SSAUpdater.h lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100401184700.1E04B2A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 13:46:59 2010 New Revision: 100126 URL: http://llvm.org/viewvc/llvm-project?rev=100126&view=rev Log: The SSAUpdater should avoid recursive traversals of the CFG, since that may blow out the stack for really big functions. Start by fixing an easy case. Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=100126&r1=100125&r2=100126&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Thu Apr 1 13:46:59 2010 @@ -111,7 +111,7 @@ void FindExistingPHI(BasicBlock *BB, BBInfo *Info); bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val); void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI); - void ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI); + void ClearPHITags(PHINode *PHI); void operator=(const SSAUpdater&); // DO NOT IMPLEMENT SSAUpdater(const SSAUpdater&); // DO NOT IMPLEMENT Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100126&r1=100125&r2=100126&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 13:46:59 2010 @@ -427,7 +427,7 @@ RecordMatchingPHI(BB, Info, SomePHI); break; } - ClearPHITags(BB, Info, SomePHI); + ClearPHITags(SomePHI); } } @@ -490,20 +490,28 @@ } /// ClearPHITags - When one of the existing PHI nodes fails to match, clear -/// the PHITag values stored in the BBMap while checking to see if it matched. -void SSAUpdater::ClearPHITags(BasicBlock *BB, BBInfo *Info, PHINode *PHI) { - if (!Info || Info->AvailableVal || !Info->PHITag) - return; - - // Clear the tag. - Info->PHITag = 0; - - // Iterate through the predecessors. +/// the PHITag values that were stored in the BBMap when checking to see if +/// it matched. +void SSAUpdater::ClearPHITags(PHINode *PHI) { BBMapTy *BBMap = getBBMap(BM); - for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *PHIVal = dyn_cast(PHI->getIncomingValue(i)); - if (!PHIVal) continue; - BasicBlock *Pred = PHIVal->getParent(); - ClearPHITags(Pred, (*BBMap)[Pred], PHIVal); + SmallVector WorkList; + WorkList.push_back(PHI); + + while (!WorkList.empty()) { + PHI = WorkList.pop_back_val(); + BasicBlock *BB = PHI->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal || !Info->PHITag) + continue; + + // Clear the tag. + Info->PHITag = 0; + + // Iterate through the PHI's incoming values. + for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { + PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingVal) continue; + WorkList.push_back(IncomingVal); + } } } From gohman at apple.com Thu Apr 1 14:49:08 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 1 Apr 2010 12:49:08 -0700 Subject: [llvm-commits] [llvm] r100090 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/SelectionDAG/ lib/Target/PowerPC/ lib/Target/X86/ test/CodeGen/X86/ In-Reply-To: <20100401060434.8DE232A6C12C@llvm.org> References: <20100401060434.8DE232A6C12C@llvm.org> Message-ID: <3736A7CA-6DE9-432E-8742-16CBD33651BF@apple.com> Hi Evan, A few comments below. On Mar 31, 2010, at 11:04 PM, Evan Cheng wrote: > Author: evancheng > Date: Thu Apr 1 01:04:33 2010 > New Revision: 100090 > > URL: http://llvm.org/viewvc/llvm-project?rev=100090&view=rev > Log: > Fix sdisel memcpy, memset, memmove lowering: > 1. Makes it possible to lower with floating point loads and stores. > 2. Avoid unaligned loads / stores unless it's fast. > 3. Fix some memcpy lowering logic bug related to when to optimize a > load from constant string into a constant. > 4. Adjust x86 memcpy lowering threshold to make it more sane. > 5. Fix x86 target hook so it uses vector and floating point memory > ops more effectively. > rdar://7774704 > > Modified: > llvm/trunk/include/llvm/Target/TargetLowering.h > llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h > llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.h > llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll > llvm/trunk/test/CodeGen/X86/byval7.ll > llvm/trunk/test/CodeGen/X86/memcpy-2.ll > llvm/trunk/test/CodeGen/X86/memset-2.ll > llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll > llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll > llvm/trunk/test/CodeGen/X86/unaligned-load.ll > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=100090&r1=100089&r2=100090&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Apr 1 01:04:33 2010 > @@ -5250,17 +5250,6 @@ > SDValue Value = ST->getValue(); > SDValue Ptr = ST->getBasePtr(); > > - // Try to infer better alignment information than the store already has. > - if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { > - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { > - if (Align > ST->getAlignment()) > - return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, > - Ptr, ST->getSrcValue(), > - ST->getSrcValueOffset(), ST->getMemoryVT(), > - ST->isVolatile(), ST->isNonTemporal(), Align); > - } > - } > - > // If this is a store of a bit convert, store the input value if the > // resultant store does not need a higher alignment than the original. > if (Value.getOpcode() == ISD::BIT_CONVERT && !ST->isTruncatingStore() && > @@ -5351,6 +5340,17 @@ > } > } > > + // Try to infer better alignment information than the store already has. > + if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { > + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { > + if (Align > ST->getAlignment()) > + return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, > + Ptr, ST->getSrcValue(), > + ST->getSrcValueOffset(), ST->getMemoryVT(), > + ST->isVolatile(), ST->isNonTemporal(), Align); > + } > + } > + Why did this code block move? It seems that the code it now follows would also benefit from having more precise alignment information. On the other hand, instcombine's alignment refinement code has been substantially improved since this code in dagcombine was originally written, so dagcombine may no longer need it at all. > if (CombinerAA) { > // Walk up chain skipping non-aliasing memory nodes. > SDValue BetterChain = FindBetterChain(N, Chain); > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100090&r1=100089&r2=100090&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 1 01:04:33 2010 > @@ -3132,11 +3132,17 @@ > if (Str.empty()) { > if (VT.isInteger()) > return DAG.getConstant(0, VT); > - unsigned NumElts = VT.getVectorNumElements(); > - MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; > - return DAG.getNode(ISD::BIT_CONVERT, dl, VT, > - DAG.getConstant(0, > - EVT::getVectorVT(*DAG.getContext(), EltVT, NumElts))); > + else if (VT.getSimpleVT().SimpleTy == MVT::f32 || > + VT.getSimpleVT().SimpleTy == MVT::f64) > + return DAG.getConstantFP(0.0, VT); > + else if (VT.isVector()) { > + unsigned NumElts = VT.getVectorNumElements(); > + MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; > + return DAG.getNode(ISD::BIT_CONVERT, dl, VT, > + DAG.getConstant(0, EVT::getVectorVT(*DAG.getContext(), > + EltVT, NumElts))); > + } else > + llvm_unreachable("Expected type!"); > } > > assert(!VT.isVector() && "Can't handle vector type here!"); > @@ -3184,51 +3190,33 @@ > return false; > } > > -/// MeetsMaxMemopRequirement - Determines if the number of memory ops required > -/// to replace the memset / memcpy is below the threshold. It also returns the > -/// types of the sequence of memory ops to perform memset / memcpy. > -static > -bool MeetsMaxMemopRequirement(std::vector &MemOps, > - SDValue Dst, SDValue Src, > - unsigned Limit, uint64_t Size, unsigned &Align, > - std::string &Str, bool &isSrcStr, > - SelectionDAG &DAG, > - const TargetLowering &TLI) { > - isSrcStr = isMemSrcFromString(Src, Str); > - bool isSrcConst = isa(Src); > - EVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG); > - bool AllowUnalign = TLI.allowsUnalignedMemoryAccesses(VT); > - if (VT != MVT::Other) { > - const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); > - unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); > - // If source is a string constant, this will require an unaligned load. > - if (NewAlign > Align && (isSrcConst || AllowUnalign)) { > - if (Dst.getOpcode() != ISD::FrameIndex) { > - // Can't change destination alignment. It requires a unaligned store. > - if (AllowUnalign) > - VT = MVT::Other; > - } else { > - int FI = cast(Dst)->getIndex(); > - MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); > - if (MFI->isFixedObjectIndex(FI)) { > - // Can't change destination alignment. It requires a unaligned store. > - if (AllowUnalign) > - VT = MVT::Other; > - } else { > - // Give the stack frame object a larger alignment if needed. > - if (MFI->getObjectAlignment(FI) < NewAlign) > - MFI->setObjectAlignment(FI, NewAlign); > - Align = NewAlign; > - } > - } > - } > - } > +/// FindOptimalMemOpLowering - Determines the optimial series memory ops > +/// to replace the memset / memcpy. Return true if the number of memory ops > +/// is below the threshold. It returns the types of the sequence of > +/// memory ops to perform memset / memcpy by reference. > +static bool FindOptimalMemOpLowering(std::vector &MemOps, > + SDValue Dst, SDValue Src, > + unsigned Limit, uint64_t Size, > + unsigned DstAlign, unsigned SrcAlign, > + SelectionDAG &DAG, > + const TargetLowering &TLI) { > + assert((SrcAlign == 0 || SrcAlign >= DstAlign) && > + "Expecting memcpy / memset source to meet alignment requirement!"); > + // If 'SrcAlign' is zero, that means the memory operation does not need load > + // the value, i.e. memset or memcpy from constant string. Otherwise, it's > + // the inferred alignment of the source. 'DstAlign', on the other hand, is the > + // specified alignment of the memory operation. If it is zero, that means > + // it's possible to change the alignment of the destination. > + EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, DAG); > > if (VT == MVT::Other) { > - if (TLI.allowsUnalignedMemoryAccesses(MVT::i64)) { > + VT = TLI.getPointerTy(); > + const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); > + if (DstAlign >= TLI.getTargetData()->getABITypeAlignment(Ty) || > + TLI.allowsUnalignedMemoryAccesses(VT)) { > VT = MVT::i64; > } else { > - switch (Align & 7) { > + switch (DstAlign & 7) { > case 0: VT = MVT::i64; break; > case 4: VT = MVT::i32; break; > case 2: VT = MVT::i16; break; > @@ -3250,7 +3238,7 @@ > unsigned VTSize = VT.getSizeInBits() / 8; > while (VTSize > Size) { > // For now, only use non-vector load / store's for the left-over pieces. > - if (VT.isVector()) { > + if (VT.isVector() || VT.isFloatingPoint()) { > VT = MVT::i64; > while (!TLI.isTypeLegal(VT)) > VT = (MVT::SimpleValueType)(VT.getSimpleVT().SimpleTy - 1); > @@ -3286,15 +3274,33 @@ > uint64_t Limit = -1ULL; > if (!AlwaysInline) > Limit = TLI.getMaxStoresPerMemcpy(); > - unsigned DstAlign = Align; // Destination alignment can change. > + bool DstAlignCanChange = false; > + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); > + FrameIndexSDNode *FI = dyn_cast(Dst); > + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) > + DstAlignCanChange = true; > + unsigned SrcAlign = DAG.InferPtrAlignment(Src); > + if (Align > SrcAlign) > + SrcAlign = Align; > std::string Str; > - bool CopyFromStr; > - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, > - Str, CopyFromStr, DAG, TLI)) > + bool CopyFromStr = isMemSrcFromString(Src, Str); > + bool isZeroStr = CopyFromStr && Str.empty(); > + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, > + (DstAlignCanChange ? 0 : Align), > + (isZeroStr ? 0 : SrcAlign), DAG, TLI)) > return SDValue(); > > + if (DstAlignCanChange) { > + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); > + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); > + if (NewAlign > Align) { > + // Give the stack frame object a larger alignment if needed. > + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) > + MFI->setObjectAlignment(FI->getIndex(), NewAlign); > + Align = NewAlign; > + } > + } > > - bool isZeroStr = CopyFromStr && Str.empty(); > SmallVector OutChains; > unsigned NumMemOps = MemOps.size(); > uint64_t SrcOff = 0, DstOff = 0; > @@ -3303,16 +3309,17 @@ > unsigned VTSize = VT.getSizeInBits() / 8; > SDValue Value, Store; > > - if (CopyFromStr && (isZeroStr || !VT.isVector())) { > + if (CopyFromStr && > + (isZeroStr || (VT.isInteger() && !VT.isVector()))) { > // It's unlikely a store of a vector immediate can be done in a single > // instruction. It would require a load from a constantpool first. > - // We also handle store a vector with all zero's. > + // We only handle zero vectors here. > // FIXME: Handle other cases where store of vector immediate is done in > // a single instruction. > Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); > Store = DAG.getStore(Chain, dl, Value, > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, false, false, DstAlign); > + DstSV, DstSVOff + DstOff, false, false, Align); > } else { > // The type might not be legal for the target. This should only happen > // if the type is smaller than a legal type, as on PPC, so the right > @@ -3323,11 +3330,12 @@ > assert(NVT.bitsGE(VT)); > Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, > getMemBasePlusOffset(Src, SrcOff, DAG), > - SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); > + SrcSV, SrcSVOff + SrcOff, VT, false, false, > + MinAlign(SrcAlign, SrcOff)); > Store = DAG.getTruncStore(Chain, dl, Value, > getMemBasePlusOffset(Dst, DstOff, DAG), > DstSV, DstSVOff + DstOff, VT, false, false, > - DstAlign); > + Align); > } > OutChains.push_back(Store); > SrcOff += VTSize; > @@ -3339,11 +3347,11 @@ > } > > static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, > - SDValue Chain, SDValue Dst, > - SDValue Src, uint64_t Size, > - unsigned Align, bool AlwaysInline, > - const Value *DstSV, uint64_t DstSVOff, > - const Value *SrcSV, uint64_t SrcSVOff){ > + SDValue Chain, SDValue Dst, > + SDValue Src, uint64_t Size, > + unsigned Align,bool AlwaysInline, > + const Value *DstSV, uint64_t DstSVOff, > + const Value *SrcSV, uint64_t SrcSVOff) { > const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > > // Expand memmove to a series of load and store ops if the size operand falls > @@ -3352,15 +3360,32 @@ > uint64_t Limit = -1ULL; > if (!AlwaysInline) > Limit = TLI.getMaxStoresPerMemmove(); > - unsigned DstAlign = Align; // Destination alignment can change. > - std::string Str; > - bool CopyFromStr; > - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, > - Str, CopyFromStr, DAG, TLI)) > + bool DstAlignCanChange = false; > + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); > + FrameIndexSDNode *FI = dyn_cast(Dst); > + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) > + DstAlignCanChange = true; > + unsigned SrcAlign = DAG.InferPtrAlignment(Src); > + if (Align > SrcAlign) > + SrcAlign = Align; > + > + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, > + (DstAlignCanChange ? 0 : Align), > + SrcAlign, DAG, TLI)) > return SDValue(); > > - uint64_t SrcOff = 0, DstOff = 0; > + if (DstAlignCanChange) { > + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); > + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); > + if (NewAlign > Align) { > + // Give the stack frame object a larger alignment if needed. > + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) > + MFI->setObjectAlignment(FI->getIndex(), NewAlign); > + Align = NewAlign; > + } > + } > > + uint64_t SrcOff = 0, DstOff = 0; > SmallVector LoadValues; > SmallVector LoadChains; > SmallVector OutChains; > @@ -3372,7 +3397,7 @@ > > Value = DAG.getLoad(VT, dl, Chain, > getMemBasePlusOffset(Src, SrcOff, DAG), > - SrcSV, SrcSVOff + SrcOff, false, false, Align); > + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); > LoadValues.push_back(Value); > LoadChains.push_back(Value.getValue(1)); > SrcOff += VTSize; > @@ -3387,7 +3412,7 @@ > > Store = DAG.getStore(Chain, dl, LoadValues[i], > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, false, false, DstAlign); > + DstSV, DstSVOff + DstOff, false, false, Align); > OutChains.push_back(Store); > DstOff += VTSize; > } > @@ -3397,24 +3422,38 @@ > } > > static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, > - SDValue Chain, SDValue Dst, > - SDValue Src, uint64_t Size, > - unsigned Align, > - const Value *DstSV, uint64_t DstSVOff) { > + SDValue Chain, SDValue Dst, > + SDValue Src, uint64_t Size, > + unsigned Align, > + const Value *DstSV, uint64_t DstSVOff) { > const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > > // Expand memset to a series of load/store ops if the size operand > // falls below a certain threshold. > std::vector MemOps; > - std::string Str; > - bool CopyFromStr; > - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), > - Size, Align, Str, CopyFromStr, DAG, TLI)) > + bool DstAlignCanChange = false; > + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); > + FrameIndexSDNode *FI = dyn_cast(Dst); > + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) > + DstAlignCanChange = true; > + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), > + Size, (DstAlignCanChange ? 0 : Align), 0, > + DAG, TLI)) > return SDValue(); > > + if (DstAlignCanChange) { > + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); > + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); > + if (NewAlign > Align) { > + // Give the stack frame object a larger alignment if needed. > + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) > + MFI->setObjectAlignment(FI->getIndex(), NewAlign); > + Align = NewAlign; > + } > + } > + > SmallVector OutChains; > uint64_t DstOff = 0; > - > unsigned NumMemOps = MemOps.size(); > for (unsigned i = 0; i < NumMemOps; i++) { > EVT VT = MemOps[i]; > @@ -3445,10 +3484,9 @@ > if (ConstantSize->isNullValue()) > return Chain; > > - SDValue Result = > - getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > - ConstantSize->getZExtValue(), > - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); > + SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > + ConstantSize->getZExtValue(),Align, > + false, DstSV, DstSVOff, SrcSV, SrcSVOff); > if (Result.getNode()) > return Result; > } > @@ -6106,8 +6144,18 @@ > // If this is a GlobalAddress + cst, return the alignment. > GlobalValue *GV; > int64_t GVOffset = 0; > - if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) > - return MinAlign(GV->getAlignment(), GVOffset); > + if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) { > + // If GV has specified alignment, then use it. Otherwise, use the preferred > + // alignment. > + unsigned Align = GV->getAlignment(); > + if (!Align) { > + if (GlobalVariable *GVar = dyn_cast(GV)) { > + const TargetData *TD = TLI.getTargetData(); > + Align = TD->getPreferredAlignment(GVar); > + } > + } I don't think it's safe to check for the preferred alignment here. If the variable is defined in a different translation unit, it may not be aligned more than the ABI alignment or the GV->getAlignment() value. The optimizer should already be upgrading global variables to their preferred alignment when safe, so codegen shouldn't have to replicate this. > + return MinAlign(Align, GVOffset); > + } > > // If this is a direct reference to a stack slot, use information about the > // stack slot's alignment. > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100090&r1=100089&r2=100090&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 01:04:33 2010 > @@ -1012,7 +1012,7 @@ > // FIXME: These should be based on subtarget info. Plus, the values should > // be smaller when we are in optimizing for size mode. > maxStoresPerMemset = 16; // For @llvm.memset -> sequence of stores > - maxStoresPerMemcpy = 16; // For @llvm.memcpy -> sequence of stores > + maxStoresPerMemcpy = 8; // For @llvm.memcpy -> sequence of stores > maxStoresPerMemmove = 3; // For @llvm.memmove -> sequence of stores > setPrefLoopAlignment(16); > benefitFromCodePlacementOpt = true; > @@ -1074,19 +1074,27 @@ > /// lowering. It returns MVT::iAny if SelectionDAG should be responsible for > /// determining it. > EVT > -X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned Align, > - bool isSrcConst, bool isSrcStr, > +X86TargetLowering::getOptimalMemOpType(uint64_t Size, > + unsigned DstAlign, unsigned SrcAlign, > SelectionDAG &DAG) const { > // FIXME: This turns off use of xmm stores for memset/memcpy on targets like > // linux. This is because the stack realignment code can't handle certain > // cases like PR2962. This should be removed when PR2962 is fixed. > const Function *F = DAG.getMachineFunction().getFunction(); > - bool NoImplicitFloatOps = F->hasFnAttr(Attribute::NoImplicitFloat); > - if (!NoImplicitFloatOps && Subtarget->getStackAlignment() >= 16) { > - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE2() && Size >= 16) > - return MVT::v4i32; > - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE1() && Size >= 16) > - return MVT::v4f32; > + if (!F->hasFnAttr(Attribute::NoImplicitFloat)) { > + if (Size >= 16 && > + (Subtarget->isUnalignedMemAccessFast() || > + (DstAlign == 0 || DstAlign >= 16) && > + (SrcAlign == 0 || SrcAlign >= 16)) && It's not obvious what this code intends. What does a 0 align value mean in this context? > + Subtarget->getStackAlignment() >= 16) { > + if (Subtarget->hasSSE2()) > + return MVT::v4i32; > + if (Subtarget->hasSSE1()) > + return MVT::v4f32; > + } else if (Size >= 8 && > + Subtarget->getStackAlignment() >= 8 && > + Subtarget->hasSSE2()) > + return MVT::f64; > } Why is f64 chosen here? I guess it's because all targets where i64 is legal have SSE2, so they wouldn't get here. That's a bit subtle though; could you add a comment about this? Thanks, Dan > if (Subtarget->is64Bit() && Size >= 8) > return MVT::i64; > From scallanan at apple.com Thu Apr 1 14:52:56 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 1 Apr 2010 12:52:56 -0700 Subject: [llvm-commits] Error-handling fixes for the x86 disassembler In-Reply-To: <4BB4343C.2090203@mxc.ca> References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> <4BB4343C.2090203@mxc.ca> Message-ID: <4BEDEB35-ECDF-4BDE-A901-75AED667C5C3@apple.com> All right, so here's step one: adding llvm_recoverable_error() as suggested by Nick. Does this look OK? If so, I can update the main patch to use this function. Sean -------------- next part -------------- A non-text attachment was scrubbed... Name: error-handling.diff Type: application/octet-stream Size: 1567 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/8f0a3682/attachment.obj -------------- next part -------------- On Mar 31, 2010, at 10:50 PM, Nick Lewycky wrote: > Sean Callanan wrote: >> The attached patch fixes error handling for the x86 disassembler, eliminating llvm_unreachable() and assert() in favor of using the legitimate error-handling mechanism. The rationale is to allow clients of libEnhancedDisassembly to handle errors themselves, rather than forcing them to crash. >> >> The difference is that now assert() and llvm_unreachable() will never be called (even before, this was extremely unlikely), and the proper error-handling mechanism is used instead. Further diagnostic information is printed to stderr. > > Your new error() method and assert/llvm_unreachable are not interchangeable. An assert() or llvm_unreachable() are likely to be the last thing run before undefined behaviour. > > To do this properly please add llvm_recoverable_error() to llvm/Support/ErrorHandling.h and update every caller you want to be able to report a severe but optionally fatal error to use it. Then your client can install an error handler for the recoverable errors. Don't forget to audit all the calls you change to make sure that the program is correct even when it doesn't terminate at those points. > > Nick > >> Please let me know what you think. >> >> Sean >> >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From bob.wilson at apple.com Thu Apr 1 14:53:48 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 01 Apr 2010 19:53:48 -0000 Subject: [llvm-commits] [llvm] r100130 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100401195348.710DB2A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 14:53:48 2010 New Revision: 100130 URL: http://llvm.org/viewvc/llvm-project?rev=100130&view=rev Log: Simplify the code to check for existing PHIs, now that it is only used in one place. This removes the template function added in svn 94690. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100130&r1=100129&r2=100130&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 14:53:48 2010 @@ -135,32 +135,6 @@ return true; } -/// GetExistingPHI - Check if BB already contains a phi node that is equivalent -/// to the specified mapping from predecessor blocks to incoming values. -static Value *GetExistingPHI(BasicBlock *BB, - DenseMap &ValueMapping) { - PHINode *SomePHI; - for (BasicBlock::iterator It = BB->begin(); - (SomePHI = dyn_cast(It)); ++It) { - if (IsEquivalentPHI(SomePHI, ValueMapping)) - return SomePHI; - } - return 0; -} - -/// GetExistingPHI - Check if BB already contains an equivalent phi node. -/// The InputIt type must be an iterator over std::pair -/// objects that specify the mapping from predecessor blocks to incoming values. -template -static Value *GetExistingPHI(BasicBlock *BB, const InputIt &I, - const InputIt &E) { - // Avoid create the mapping if BB has no phi nodes at all. - if (!isa(BB->begin())) - return 0; - DenseMap ValueMapping(I, E); - return GetExistingPHI(BB, ValueMapping); -} - /// GetValueAtEndOfBlock - Construct SSA form, materializing a value that is /// live at the end of the specified block. Value *SSAUpdater::GetValueAtEndOfBlock(BasicBlock *BB) { @@ -239,10 +213,18 @@ if (SingularValue != 0) return SingularValue; - // Otherwise, we do need a PHI. - if (Value *ExistingPHI = GetExistingPHI(BB, PredValues.begin(), - PredValues.end())) - return ExistingPHI; + // Otherwise, we do need a PHI: check to see if we already have one available + // in this block that produces the right value. + if (isa(BB->begin())) { + DenseMap ValueMapping(PredValues.begin(), + PredValues.end()); + PHINode *SomePHI; + for (BasicBlock::iterator It = BB->begin(); + (SomePHI = dyn_cast(It)); ++It) { + if (IsEquivalentPHI(SomePHI, ValueMapping)) + return SomePHI; + } + } // Ok, we have no way out, insert a new one now. PHINode *InsertedPHI = PHINode::Create(PrototypeValue->getType(), From evan.cheng at apple.com Thu Apr 1 15:02:45 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 1 Apr 2010 13:02:45 -0700 Subject: [llvm-commits] [llvm] r100090 - in /llvm/trunk: include/llvm/Target/ lib/CodeGen/SelectionDAG/ lib/Target/PowerPC/ lib/Target/X86/ test/CodeGen/X86/ In-Reply-To: <3736A7CA-6DE9-432E-8742-16CBD33651BF@apple.com> References: <20100401060434.8DE232A6C12C@llvm.org> <3736A7CA-6DE9-432E-8742-16CBD33651BF@apple.com> Message-ID: On Apr 1, 2010, at 12:49 PM, Dan Gohman wrote: > Hi Evan, > > A few comments below. > > On Mar 31, 2010, at 11:04 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Thu Apr 1 01:04:33 2010 >> New Revision: 100090 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=100090&view=rev >> Log: >> Fix sdisel memcpy, memset, memmove lowering: >> 1. Makes it possible to lower with floating point loads and stores. >> 2. Avoid unaligned loads / stores unless it's fast. >> 3. Fix some memcpy lowering logic bug related to when to optimize a >> load from constant string into a constant. >> 4. Adjust x86 memcpy lowering threshold to make it more sane. >> 5. Fix x86 target hook so it uses vector and floating point memory >> ops more effectively. >> rdar://7774704 >> >> Modified: >> llvm/trunk/include/llvm/Target/TargetLowering.h >> llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp >> llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.h >> llvm/trunk/test/CodeGen/X86/2009-11-16-UnfoldMemOpBug.ll >> llvm/trunk/test/CodeGen/X86/byval7.ll >> llvm/trunk/test/CodeGen/X86/memcpy-2.ll >> llvm/trunk/test/CodeGen/X86/memset-2.ll >> llvm/trunk/test/CodeGen/X86/memset64-on-x86-32.ll >> llvm/trunk/test/CodeGen/X86/small-byval-memcpy.ll >> llvm/trunk/test/CodeGen/X86/unaligned-load.ll >> > >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=100090&r1=100089&r2=100090&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Apr 1 01:04:33 2010 > >> @@ -5250,17 +5250,6 @@ >> SDValue Value = ST->getValue(); >> SDValue Ptr = ST->getBasePtr(); >> >> - // Try to infer better alignment information than the store already has. >> - if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { >> - if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { >> - if (Align > ST->getAlignment()) >> - return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, >> - Ptr, ST->getSrcValue(), >> - ST->getSrcValueOffset(), ST->getMemoryVT(), >> - ST->isVolatile(), ST->isNonTemporal(), Align); >> - } >> - } >> - >> // If this is a store of a bit convert, store the input value if the >> // resultant store does not need a higher alignment than the original. >> if (Value.getOpcode() == ISD::BIT_CONVERT && !ST->isTruncatingStore() && >> @@ -5351,6 +5340,17 @@ >> } >> } >> >> + // Try to infer better alignment information than the store already has. >> + if (OptLevel != CodeGenOpt::None && ST->isUnindexed()) { >> + if (unsigned Align = DAG.InferPtrAlignment(Ptr)) { >> + if (Align > ST->getAlignment()) >> + return DAG.getTruncStore(Chain, N->getDebugLoc(), Value, >> + Ptr, ST->getSrcValue(), >> + ST->getSrcValueOffset(), ST->getMemoryVT(), >> + ST->isVolatile(), ST->isNonTemporal(), Align); >> + } >> + } >> + > > Why did this code block move? It seems that the code it now follows > would also benefit from having more precise alignment information. This code creates a truncating store and it ends up inhibiting other store dag combines. > > On the other hand, instcombine's alignment refinement code has been > substantially improved since this code in dagcombine was originally > written, so dagcombine may no longer need it at all. That's definitely not what I am seeing though. > >> if (CombinerAA) { >> // Walk up chain skipping non-aliasing memory nodes. >> SDValue BetterChain = FindBetterChain(N, Chain); >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100090&r1=100089&r2=100090&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 1 01:04:33 2010 >> @@ -3132,11 +3132,17 @@ >> if (Str.empty()) { >> if (VT.isInteger()) >> return DAG.getConstant(0, VT); >> - unsigned NumElts = VT.getVectorNumElements(); >> - MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; >> - return DAG.getNode(ISD::BIT_CONVERT, dl, VT, >> - DAG.getConstant(0, >> - EVT::getVectorVT(*DAG.getContext(), EltVT, NumElts))); >> + else if (VT.getSimpleVT().SimpleTy == MVT::f32 || >> + VT.getSimpleVT().SimpleTy == MVT::f64) >> + return DAG.getConstantFP(0.0, VT); >> + else if (VT.isVector()) { >> + unsigned NumElts = VT.getVectorNumElements(); >> + MVT EltVT = (VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; >> + return DAG.getNode(ISD::BIT_CONVERT, dl, VT, >> + DAG.getConstant(0, EVT::getVectorVT(*DAG.getContext(), >> + EltVT, NumElts))); >> + } else >> + llvm_unreachable("Expected type!"); >> } >> >> assert(!VT.isVector() && "Can't handle vector type here!"); >> @@ -3184,51 +3190,33 @@ >> return false; >> } >> >> -/// MeetsMaxMemopRequirement - Determines if the number of memory ops required >> -/// to replace the memset / memcpy is below the threshold. It also returns the >> -/// types of the sequence of memory ops to perform memset / memcpy. >> -static >> -bool MeetsMaxMemopRequirement(std::vector &MemOps, >> - SDValue Dst, SDValue Src, >> - unsigned Limit, uint64_t Size, unsigned &Align, >> - std::string &Str, bool &isSrcStr, >> - SelectionDAG &DAG, >> - const TargetLowering &TLI) { >> - isSrcStr = isMemSrcFromString(Src, Str); >> - bool isSrcConst = isa(Src); >> - EVT VT = TLI.getOptimalMemOpType(Size, Align, isSrcConst, isSrcStr, DAG); >> - bool AllowUnalign = TLI.allowsUnalignedMemoryAccesses(VT); >> - if (VT != MVT::Other) { >> - const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); >> - unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); >> - // If source is a string constant, this will require an unaligned load. >> - if (NewAlign > Align && (isSrcConst || AllowUnalign)) { >> - if (Dst.getOpcode() != ISD::FrameIndex) { >> - // Can't change destination alignment. It requires a unaligned store. >> - if (AllowUnalign) >> - VT = MVT::Other; >> - } else { >> - int FI = cast(Dst)->getIndex(); >> - MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); >> - if (MFI->isFixedObjectIndex(FI)) { >> - // Can't change destination alignment. It requires a unaligned store. >> - if (AllowUnalign) >> - VT = MVT::Other; >> - } else { >> - // Give the stack frame object a larger alignment if needed. >> - if (MFI->getObjectAlignment(FI) < NewAlign) >> - MFI->setObjectAlignment(FI, NewAlign); >> - Align = NewAlign; >> - } >> - } >> - } >> - } >> +/// FindOptimalMemOpLowering - Determines the optimial series memory ops >> +/// to replace the memset / memcpy. Return true if the number of memory ops >> +/// is below the threshold. It returns the types of the sequence of >> +/// memory ops to perform memset / memcpy by reference. >> +static bool FindOptimalMemOpLowering(std::vector &MemOps, >> + SDValue Dst, SDValue Src, >> + unsigned Limit, uint64_t Size, >> + unsigned DstAlign, unsigned SrcAlign, >> + SelectionDAG &DAG, >> + const TargetLowering &TLI) { >> + assert((SrcAlign == 0 || SrcAlign >= DstAlign) && >> + "Expecting memcpy / memset source to meet alignment requirement!"); >> + // If 'SrcAlign' is zero, that means the memory operation does not need load >> + // the value, i.e. memset or memcpy from constant string. Otherwise, it's >> + // the inferred alignment of the source. 'DstAlign', on the other hand, is the >> + // specified alignment of the memory operation. If it is zero, that means >> + // it's possible to change the alignment of the destination. >> + EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, DAG); >> >> if (VT == MVT::Other) { >> - if (TLI.allowsUnalignedMemoryAccesses(MVT::i64)) { >> + VT = TLI.getPointerTy(); >> + const Type *Ty = VT.getTypeForEVT(*DAG.getContext()); >> + if (DstAlign >= TLI.getTargetData()->getABITypeAlignment(Ty) || >> + TLI.allowsUnalignedMemoryAccesses(VT)) { >> VT = MVT::i64; >> } else { >> - switch (Align & 7) { >> + switch (DstAlign & 7) { >> case 0: VT = MVT::i64; break; >> case 4: VT = MVT::i32; break; >> case 2: VT = MVT::i16; break; >> @@ -3250,7 +3238,7 @@ >> unsigned VTSize = VT.getSizeInBits() / 8; >> while (VTSize > Size) { >> // For now, only use non-vector load / store's for the left-over pieces. >> - if (VT.isVector()) { >> + if (VT.isVector() || VT.isFloatingPoint()) { >> VT = MVT::i64; >> while (!TLI.isTypeLegal(VT)) >> VT = (MVT::SimpleValueType)(VT.getSimpleVT().SimpleTy - 1); >> @@ -3286,15 +3274,33 @@ >> uint64_t Limit = -1ULL; >> if (!AlwaysInline) >> Limit = TLI.getMaxStoresPerMemcpy(); >> - unsigned DstAlign = Align; // Destination alignment can change. >> + bool DstAlignCanChange = false; >> + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); >> + FrameIndexSDNode *FI = dyn_cast(Dst); >> + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) >> + DstAlignCanChange = true; >> + unsigned SrcAlign = DAG.InferPtrAlignment(Src); >> + if (Align > SrcAlign) >> + SrcAlign = Align; >> std::string Str; >> - bool CopyFromStr; >> - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, >> - Str, CopyFromStr, DAG, TLI)) >> + bool CopyFromStr = isMemSrcFromString(Src, Str); >> + bool isZeroStr = CopyFromStr && Str.empty(); >> + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, >> + (DstAlignCanChange ? 0 : Align), >> + (isZeroStr ? 0 : SrcAlign), DAG, TLI)) >> return SDValue(); >> >> + if (DstAlignCanChange) { >> + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); >> + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); >> + if (NewAlign > Align) { >> + // Give the stack frame object a larger alignment if needed. >> + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) >> + MFI->setObjectAlignment(FI->getIndex(), NewAlign); >> + Align = NewAlign; >> + } >> + } >> >> - bool isZeroStr = CopyFromStr && Str.empty(); >> SmallVector OutChains; >> unsigned NumMemOps = MemOps.size(); >> uint64_t SrcOff = 0, DstOff = 0; >> @@ -3303,16 +3309,17 @@ >> unsigned VTSize = VT.getSizeInBits() / 8; >> SDValue Value, Store; >> >> - if (CopyFromStr && (isZeroStr || !VT.isVector())) { >> + if (CopyFromStr && >> + (isZeroStr || (VT.isInteger() && !VT.isVector()))) { >> // It's unlikely a store of a vector immediate can be done in a single >> // instruction. It would require a load from a constantpool first. >> - // We also handle store a vector with all zero's. >> + // We only handle zero vectors here. >> // FIXME: Handle other cases where store of vector immediate is done in >> // a single instruction. >> Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); >> Store = DAG.getStore(Chain, dl, Value, >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, false, false, DstAlign); >> + DstSV, DstSVOff + DstOff, false, false, Align); >> } else { >> // The type might not be legal for the target. This should only happen >> // if the type is smaller than a legal type, as on PPC, so the right >> @@ -3323,11 +3330,12 @@ >> assert(NVT.bitsGE(VT)); >> Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, >> getMemBasePlusOffset(Src, SrcOff, DAG), >> - SrcSV, SrcSVOff + SrcOff, VT, false, false, Align); >> + SrcSV, SrcSVOff + SrcOff, VT, false, false, >> + MinAlign(SrcAlign, SrcOff)); >> Store = DAG.getTruncStore(Chain, dl, Value, >> getMemBasePlusOffset(Dst, DstOff, DAG), >> DstSV, DstSVOff + DstOff, VT, false, false, >> - DstAlign); >> + Align); >> } >> OutChains.push_back(Store); >> SrcOff += VTSize; >> @@ -3339,11 +3347,11 @@ >> } >> >> static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, >> - SDValue Chain, SDValue Dst, >> - SDValue Src, uint64_t Size, >> - unsigned Align, bool AlwaysInline, >> - const Value *DstSV, uint64_t DstSVOff, >> - const Value *SrcSV, uint64_t SrcSVOff){ >> + SDValue Chain, SDValue Dst, >> + SDValue Src, uint64_t Size, >> + unsigned Align,bool AlwaysInline, >> + const Value *DstSV, uint64_t DstSVOff, >> + const Value *SrcSV, uint64_t SrcSVOff) { >> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >> >> // Expand memmove to a series of load and store ops if the size operand falls >> @@ -3352,15 +3360,32 @@ >> uint64_t Limit = -1ULL; >> if (!AlwaysInline) >> Limit = TLI.getMaxStoresPerMemmove(); >> - unsigned DstAlign = Align; // Destination alignment can change. >> - std::string Str; >> - bool CopyFromStr; >> - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, Limit, Size, DstAlign, >> - Str, CopyFromStr, DAG, TLI)) >> + bool DstAlignCanChange = false; >> + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); >> + FrameIndexSDNode *FI = dyn_cast(Dst); >> + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) >> + DstAlignCanChange = true; >> + unsigned SrcAlign = DAG.InferPtrAlignment(Src); >> + if (Align > SrcAlign) >> + SrcAlign = Align; >> + >> + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, Limit, Size, >> + (DstAlignCanChange ? 0 : Align), >> + SrcAlign, DAG, TLI)) >> return SDValue(); >> >> - uint64_t SrcOff = 0, DstOff = 0; >> + if (DstAlignCanChange) { >> + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); >> + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); >> + if (NewAlign > Align) { >> + // Give the stack frame object a larger alignment if needed. >> + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) >> + MFI->setObjectAlignment(FI->getIndex(), NewAlign); >> + Align = NewAlign; >> + } >> + } >> >> + uint64_t SrcOff = 0, DstOff = 0; >> SmallVector LoadValues; >> SmallVector LoadChains; >> SmallVector OutChains; >> @@ -3372,7 +3397,7 @@ >> >> Value = DAG.getLoad(VT, dl, Chain, >> getMemBasePlusOffset(Src, SrcOff, DAG), >> - SrcSV, SrcSVOff + SrcOff, false, false, Align); >> + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); >> LoadValues.push_back(Value); >> LoadChains.push_back(Value.getValue(1)); >> SrcOff += VTSize; >> @@ -3387,7 +3412,7 @@ >> >> Store = DAG.getStore(Chain, dl, LoadValues[i], >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, false, false, DstAlign); >> + DstSV, DstSVOff + DstOff, false, false, Align); >> OutChains.push_back(Store); >> DstOff += VTSize; >> } >> @@ -3397,24 +3422,38 @@ >> } >> >> static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, >> - SDValue Chain, SDValue Dst, >> - SDValue Src, uint64_t Size, >> - unsigned Align, >> - const Value *DstSV, uint64_t DstSVOff) { >> + SDValue Chain, SDValue Dst, >> + SDValue Src, uint64_t Size, >> + unsigned Align, >> + const Value *DstSV, uint64_t DstSVOff) { >> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >> >> // Expand memset to a series of load/store ops if the size operand >> // falls below a certain threshold. >> std::vector MemOps; >> - std::string Str; >> - bool CopyFromStr; >> - if (!MeetsMaxMemopRequirement(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), >> - Size, Align, Str, CopyFromStr, DAG, TLI)) >> + bool DstAlignCanChange = false; >> + MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); >> + FrameIndexSDNode *FI = dyn_cast(Dst); >> + if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) >> + DstAlignCanChange = true; >> + if (!FindOptimalMemOpLowering(MemOps, Dst, Src, TLI.getMaxStoresPerMemset(), >> + Size, (DstAlignCanChange ? 0 : Align), 0, >> + DAG, TLI)) >> return SDValue(); >> >> + if (DstAlignCanChange) { >> + const Type *Ty = MemOps[0].getTypeForEVT(*DAG.getContext()); >> + unsigned NewAlign = (unsigned) TLI.getTargetData()->getABITypeAlignment(Ty); >> + if (NewAlign > Align) { >> + // Give the stack frame object a larger alignment if needed. >> + if (MFI->getObjectAlignment(FI->getIndex()) < NewAlign) >> + MFI->setObjectAlignment(FI->getIndex(), NewAlign); >> + Align = NewAlign; >> + } >> + } >> + >> SmallVector OutChains; >> uint64_t DstOff = 0; >> - >> unsigned NumMemOps = MemOps.size(); >> for (unsigned i = 0; i < NumMemOps; i++) { >> EVT VT = MemOps[i]; >> @@ -3445,10 +3484,9 @@ >> if (ConstantSize->isNullValue()) >> return Chain; >> >> - SDValue Result = >> - getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >> - ConstantSize->getZExtValue(), >> - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> + SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >> + ConstantSize->getZExtValue(),Align, >> + false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> if (Result.getNode()) >> return Result; >> } >> @@ -6106,8 +6144,18 @@ >> // If this is a GlobalAddress + cst, return the alignment. >> GlobalValue *GV; >> int64_t GVOffset = 0; >> - if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) >> - return MinAlign(GV->getAlignment(), GVOffset); >> + if (TLI.isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) { >> + // If GV has specified alignment, then use it. Otherwise, use the preferred >> + // alignment. >> + unsigned Align = GV->getAlignment(); >> + if (!Align) { >> + if (GlobalVariable *GVar = dyn_cast(GV)) { >> + const TargetData *TD = TLI.getTargetData(); >> + Align = TD->getPreferredAlignment(GVar); >> + } >> + } > > I don't think it's safe to check for the preferred alignment here. If the > variable is defined in a different translation unit, it may not be aligned > more than the ABI alignment or the GV->getAlignment() value. Ok, I'll skip declarations. > > The optimizer should already be upgrading global variables to their > preferred alignment when safe, so codegen shouldn't have to replicate this. Again, that doesn't match what I am seeing. > >> + return MinAlign(Align, GVOffset); >> + } >> >> // If this is a direct reference to a stack slot, use information about the >> // stack slot's alignment. >> > >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100090&r1=100089&r2=100090&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 01:04:33 2010 >> @@ -1012,7 +1012,7 @@ >> // FIXME: These should be based on subtarget info. Plus, the values should >> // be smaller when we are in optimizing for size mode. >> maxStoresPerMemset = 16; // For @llvm.memset -> sequence of stores >> - maxStoresPerMemcpy = 16; // For @llvm.memcpy -> sequence of stores >> + maxStoresPerMemcpy = 8; // For @llvm.memcpy -> sequence of stores >> maxStoresPerMemmove = 3; // For @llvm.memmove -> sequence of stores >> setPrefLoopAlignment(16); >> benefitFromCodePlacementOpt = true; >> @@ -1074,19 +1074,27 @@ >> /// lowering. It returns MVT::iAny if SelectionDAG should be responsible for >> /// determining it. >> EVT >> -X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned Align, >> - bool isSrcConst, bool isSrcStr, >> +X86TargetLowering::getOptimalMemOpType(uint64_t Size, >> + unsigned DstAlign, unsigned SrcAlign, >> SelectionDAG &DAG) const { >> // FIXME: This turns off use of xmm stores for memset/memcpy on targets like >> // linux. This is because the stack realignment code can't handle certain >> // cases like PR2962. This should be removed when PR2962 is fixed. >> const Function *F = DAG.getMachineFunction().getFunction(); >> - bool NoImplicitFloatOps = F->hasFnAttr(Attribute::NoImplicitFloat); >> - if (!NoImplicitFloatOps && Subtarget->getStackAlignment() >= 16) { >> - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE2() && Size >= 16) >> - return MVT::v4i32; >> - if ((isSrcConst || isSrcStr) && Subtarget->hasSSE1() && Size >= 16) >> - return MVT::v4f32; >> + if (!F->hasFnAttr(Attribute::NoImplicitFloat)) { >> + if (Size >= 16 && >> + (Subtarget->isUnalignedMemAccessFast() || >> + (DstAlign == 0 || DstAlign >= 16) && >> + (SrcAlign == 0 || SrcAlign >= 16)) && > > It's not obvious what this code intends. What does a 0 align value > mean in this context? 0 means don't care. I added comments to the client side. I'll add them here as well. > >> + Subtarget->getStackAlignment() >= 16) { >> + if (Subtarget->hasSSE2()) >> + return MVT::v4i32; >> + if (Subtarget->hasSSE1()) >> + return MVT::v4f32; >> + } else if (Size >= 8 && >> + Subtarget->getStackAlignment() >= 8 && >> + Subtarget->hasSSE2()) >> + return MVT::f64; >> } > > Why is f64 chosen here? I guess it's because all targets where > i64 is legal have SSE2, so they wouldn't get here. That's a bit > subtle though; could you add a comment about this? Ok, I suppose it should choose i64 if that's legal. f64 can be used when i64 is not legal though. Evan > > Thanks, > > Dan > >> if (Subtarget->is64Bit() && Size >= 8) >> return MVT::i64; >> > From bob.wilson at apple.com Thu Apr 1 15:04:30 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 01 Apr 2010 20:04:30 -0000 Subject: [llvm-commits] [llvm] r100131 - in /llvm/trunk: include/llvm/Transforms/Utils/SSAUpdater.h lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100401200430.5D9AB2A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 15:04:30 2010 New Revision: 100131 URL: http://llvm.org/viewvc/llvm-project?rev=100131&view=rev Log: Change another SSAUpdater function to avoid recursion. Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=100131&r1=100130&r2=100131&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Thu Apr 1 15:04:30 2010 @@ -110,7 +110,7 @@ void FindAvailableVal(BasicBlock *BB, BBInfo *Info, unsigned Counter); void FindExistingPHI(BasicBlock *BB, BBInfo *Info); bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val); - void RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI); + void RecordMatchingPHI(PHINode *PHI); void ClearPHITags(PHINode *PHI); void operator=(const SSAUpdater&); // DO NOT IMPLEMENT Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100131&r1=100130&r2=100131&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 15:04:30 2010 @@ -406,7 +406,7 @@ for (BasicBlock::iterator It = BB->begin(); (SomePHI = dyn_cast(It)); ++It) { if (CheckIfPHIMatches(BB, Info, SomePHI)) { - RecordMatchingPHI(BB, Info, SomePHI); + RecordMatchingPHI(SomePHI); break; } ClearPHITags(SomePHI); @@ -449,25 +449,31 @@ return IsMatch; } -/// RecordMatchingPHI - For a PHI node that matches, record it in both the -/// BBMap and the AvailableVals mapping. Recursively record its input PHIs -/// as well. -void SSAUpdater::RecordMatchingPHI(BasicBlock *BB, BBInfo *Info, PHINode *PHI) { - if (!Info || Info->AvailableVal) - return; - - // Record the PHI. +/// RecordMatchingPHI - For a PHI node that matches, record it and its input +/// PHIs in both the BBMap and the AvailableVals mapping. +void SSAUpdater::RecordMatchingPHI(PHINode *PHI) { + BBMapTy *BBMap = getBBMap(BM); AvailableValsTy &AvailableVals = getAvailableVals(AV); - AvailableVals[BB] = PHI; - Info->AvailableVal = PHI; + SmallVector WorkList; + WorkList.push_back(PHI); - // Iterate through the predecessors. - BBMapTy *BBMap = getBBMap(BM); - for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *PHIVal = dyn_cast(PHI->getIncomingValue(i)); - if (!PHIVal) continue; - BasicBlock *Pred = PHIVal->getParent(); - RecordMatchingPHI(Pred, (*BBMap)[Pred], PHIVal); + while (!WorkList.empty()) { + PHI = WorkList.pop_back_val(); + BasicBlock *BB = PHI->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal) + return; + + // Record the PHI. + AvailableVals[BB] = PHI; + Info->AvailableVal = PHI; + + // Iterate through the PHI's incoming values. + for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { + PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingVal) continue; + WorkList.push_back(IncomingVal); + } } } From evan.cheng at apple.com Thu Apr 1 15:10:42 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 20:10:42 -0000 Subject: [llvm-commits] [llvm] r100132 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCISelLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h Message-ID: <20100401201043.07DDA2A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 15:10:42 2010 New Revision: 100132 URL: http://llvm.org/viewvc/llvm-project?rev=100132&view=rev Log: Add comments about DstAlign and SrcAlign. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100132&r1=100131&r2=100132&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Thu Apr 1 15:10:42 2010 @@ -634,8 +634,11 @@ /// getOptimalMemOpType - Returns the target specific optimal type for load /// and store operations as a result of memset, memcpy, and memmove lowering. - /// It returns EVT::Other if SelectionDAG should be responsible for - /// determining it. + /// If DstAlign is zero that means it's safe to destination alignment can + /// satisfy any constraint. Similarly if SrcAlign is zero it means there isn't + /// a need to check it against alignment requirement, probably because the + /// source does not need to be loaded. It returns EVT::Other if SelectionDAG + /// should be responsible for determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool SafeToUseFP, SelectionDAG &DAG) const { Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100132&r1=100131&r2=100132&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Thu Apr 1 15:10:42 2010 @@ -5539,6 +5539,13 @@ return false; } +/// getOptimalMemOpType - Returns the target specific optimal type for load +/// and store operations as a result of memset, memcpy, and memmove lowering. +/// If DstAlign is zero that means it's safe to destination alignment can +/// satisfy any constraint. Similarly if SrcAlign is zero it means there +/// isn't a need to check it against alignment requirement, probably because +/// the source does not need to be loaded. It returns EVT::Other if +/// SelectionDAG should be responsible for determining it. EVT PPCTargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool SafeToUseFP, Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=100132&r1=100131&r2=100132&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Thu Apr 1 15:10:42 2010 @@ -347,6 +347,13 @@ virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; + /// getOptimalMemOpType - Returns the target specific optimal type for load + /// and store operations as a result of memset, memcpy, and memmove lowering. + /// If DstAlign is zero that means it's safe to destination alignment can + /// satisfy any constraint. Similarly if SrcAlign is zero it means there + /// isn't a need to check it against alignment requirement, probably because + /// the source does not need to be loaded. It returns EVT::Other if + /// SelectionDAG should be responsible for determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool SafeToUseFP, SelectionDAG &DAG) const; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100132&r1=100131&r2=100132&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 15:10:42 2010 @@ -1070,9 +1070,12 @@ } /// getOptimalMemOpType - Returns the target specific optimal type for load -/// and store operations as a result of memset, memcpy, and memmove -/// lowering. It returns MVT::iAny if SelectionDAG should be responsible for -/// determining it. +/// and store operations as a result of memset, memcpy, and memmove lowering. +/// If DstAlign is zero that means it's safe to destination alignment can +/// satisfy any constraint. Similarly if SrcAlign is zero it means there +/// isn't a need to check it against alignment requirement, probably because +/// the source does not need to be loaded. It returns EVT::Other if +/// SelectionDAG should be responsible for determining it. EVT X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100132&r1=100131&r2=100132&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Thu Apr 1 15:10:42 2010 @@ -420,9 +420,12 @@ virtual unsigned getByValTypeAlignment(const Type *Ty) const; /// getOptimalMemOpType - Returns the target specific optimal type for load - /// and store operations as a result of memset, memcpy, and memmove - /// lowering. It returns EVT::iAny if SelectionDAG should be responsible for - /// determining it. + /// and store operations as a result of memset, memcpy, and memmove lowering. + /// If DstAlign is zero that means it's safe to destination alignment can + /// satisfy any constraint. Similarly if SrcAlign is zero it means there + /// isn't a need to check it against alignment requirement, probably because + /// the source does not need to be loaded. It returns EVT::Other if + /// SelectionDAG should be responsible for determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, bool SafeToUseFP, SelectionDAG &DAG) const; From evan.cheng at apple.com Thu Apr 1 15:13:28 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 20:13:28 -0000 Subject: [llvm-commits] [llvm] r100133 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Message-ID: <20100401201328.31E072A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 15:13:28 2010 New Revision: 100133 URL: http://llvm.org/viewvc/llvm-project?rev=100133&view=rev Log: Skip checking preferred alignment of GVs defined in other translation units all together. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100133&r1=100132&r2=100133&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 1 15:13:28 2010 @@ -6152,7 +6152,7 @@ unsigned Align = GV->getAlignment(); if (!Align) { if (GlobalVariable *GVar = dyn_cast(GV)) { - if (GV->getType()->getElementType()->isSized()) { + if (GVar->hasInitializer()) { const TargetData *TD = TLI.getTargetData(); Align = TD->getPreferredAlignment(GVar); } From gohman at apple.com Thu Apr 1 15:23:20 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 1 Apr 2010 13:23:20 -0700 Subject: [llvm-commits] [llvm] r100100 - in /llvm/trunk: ./ docs/ProgrammersManual.html include/llvm/Support/CallSite.h lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/Transforms/Scalar/SCCP.cpp lib/VMCore/Function.cpp lib/VMCore/Instructions.cpp In-Reply-To: <20100401082109.319A52A6C12C@llvm.org> References: <20100401082109.319A52A6C12C@llvm.org> Message-ID: <54D67564-EDD7-438B-841A-60BAA51119F2@apple.com> On Apr 1, 2010, at 1:21 AM, Gabor Greif wrote: > > Propchange: llvm/trunk/ > ------------------------------------------------------------------------------ > --- svn:mergeinfo (original) > +++ svn:mergeinfo Thu Apr 1 03:21:08 2010 > @@ -1 +1,2 @@ > /llvm/branches/ggreif/InvokeInst-operands:98645-99398 > +/llvm/branches/ggreif/const-CallSite:99517-100006 > > Propchange: llvm/trunk/docs/ProgrammersManual.html > ------------------------------------------------------------------------------ > --- svn:mergeinfo (added) > +++ svn:mergeinfo Thu Apr 1 03:21:08 2010 > @@ -0,0 +1,3 @@ > +/llvm/branches/ggreif/InvokeInst-operands/docs/ProgrammersManual.html:98645-99398 > +/llvm/branches/ggreif/const-CallSite/docs/ProgrammersManual.html:99517-100006 > +/llvm/trunk/docs/ProgrammersManual.html:70891 Hi Gabor, What's the status of these properties? They don't look entirely intentional. Dan From dpatel at apple.com Thu Apr 1 15:22:45 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 Apr 2010 20:22:45 -0000 Subject: [llvm-commits] [llvm] r100134 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100401202245.277112A6C12C@llvm.org> Author: dpatel Date: Thu Apr 1 15:22:44 2010 New Revision: 100134 URL: http://llvm.org/viewvc/llvm-project?rev=100134&view=rev Log: Do not eagerly record known previous location. DBG_VALUE may not cause a new label due to one or other reason. 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=100134&r1=100133&r2=100134&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Apr 1 15:22:44 2010 @@ -2051,7 +2051,6 @@ // Check and update last known location info. if(DILoc.getNode() == PrevDILoc) return; - PrevDILoc = DILoc.getNode(); // DBG_VALUE instruction establishes new value. if (MI->isDebugValue()) { @@ -2061,6 +2060,7 @@ MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), DILoc.getColumnNumber(), DILoc.getScope().getNode()); + PrevDILoc = DILoc.getNode(); DI->second->setDbgValueLabel(Label); } return; @@ -2071,6 +2071,7 @@ MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), DILoc.getColumnNumber(), DILoc.getScope().getNode()); + PrevDILoc = DILoc.getNode(); // update DbgScope if this instruction starts a new scope. InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI); From evan.cheng at apple.com Thu Apr 1 15:27:46 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 01 Apr 2010 20:27:46 -0000 Subject: [llvm-commits] [llvm] r100137 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/memcpy-2.ll test/CodeGen/X86/unaligned-load.ll Message-ID: <20100401202746.360F52A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 15:27:45 2010 New Revision: 100137 URL: http://llvm.org/viewvc/llvm-project?rev=100137&view=rev Log: In 64-bit mode, use i64 to lower memcpy / memset instead of f64. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/memcpy-2.ll llvm/trunk/test/CodeGen/X86/unaligned-load.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100137&r1=100136&r2=100137&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 15:27:45 2010 @@ -1097,6 +1097,7 @@ return MVT::v4f32; } else if (SafeToUseFP && Size >= 8 && + !Subtarget->is64Bit() && Subtarget->getStackAlignment() >= 8 && Subtarget->hasSSE2()) return MVT::f64; Modified: llvm/trunk/test/CodeGen/X86/memcpy-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memcpy-2.ll?rev=100137&r1=100136&r2=100137&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memcpy-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memcpy-2.ll Thu Apr 1 15:27:45 2010 @@ -1,6 +1,7 @@ ; RUN: llc < %s -mattr=+sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE2 ; RUN: llc < %s -mattr=+sse,-sse2 -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=SSE1 ; RUN: llc < %s -mattr=-sse -mtriple=i686-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=NOSSE +; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=core2 | FileCheck %s -check-prefix=X86-64 %struct.ParmT = type { [25 x i8], i8, i8* } @.str12 = internal constant [25 x i8] c"image\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00" ; <[25 x i8]*> [#uses=1] @@ -29,6 +30,12 @@ ; NOSSE: movl $0 ; NOSSE: movl $101 ; NOSSE: movl $1734438249 + +; X86-64: t1: +; X86-64: movaps _.str12(%rip), %xmm0 +; X86-64: movaps %xmm0 +; X86-64: movb $0 +; X86-64: movq $0 %parms.i = alloca [13 x %struct.ParmT] ; <[13 x %struct.ParmT]*> [#uses=1] %parms1.i = getelementptr [13 x %struct.ParmT]* %parms.i, i32 0, i32 0, i32 0, i32 0 ; [#uses=1] call void @llvm.memcpy.i32( i8* %parms1.i, i8* getelementptr ([25 x i8]* @.str12, i32 0, i32 0), i32 25, i32 1 ) nounwind @@ -59,6 +66,10 @@ ; NOSSE: movl ; NOSSE: movl ; NOSSE: movl + +; X86-64: t2: +; X86-64: movaps (%rsi), %xmm0 +; X86-64: movaps %xmm0, (%rdi) %tmp2 = bitcast %struct.s0* %a to i8* ; [#uses=1] %tmp3 = bitcast %struct.s0* %b to i8* ; [#uses=1] tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 16) @@ -96,6 +107,12 @@ ; NOSSE: movl ; NOSSE: movl ; NOSSE: movl + +; X86-64: t3: +; X86-64: movq (%rsi), %rax +; X86-64: movq 8(%rsi), %rcx +; X86-64: movq %rcx, 8(%rdi) +; X86-64: movq %rax, (%rdi) %tmp2 = bitcast %struct.s0* %a to i8* ; [#uses=1] %tmp3 = bitcast %struct.s0* %b to i8* ; [#uses=1] tail call void @llvm.memcpy.i32(i8* %tmp2, i8* %tmp3, i32 16, i32 8) Modified: llvm/trunk/test/CodeGen/X86/unaligned-load.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unaligned-load.ll?rev=100137&r1=100136&r2=100137&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/unaligned-load.ll (original) +++ llvm/trunk/test/CodeGen/X86/unaligned-load.ll Thu Apr 1 15:27:45 2010 @@ -1,3 +1,4 @@ +; RUN: llc < %s -mtriple=i386-apple-darwin10.0 -mcpu=core2 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck -check-prefix=I386 %s ; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -mcpu=core2 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck -check-prefix=CORE2 %s ; RUN: llc < %s -mtriple=x86_64-apple-darwin10.0 -mcpu=corei7 -relocation-model=dynamic-no-pic --asm-verbose=0 | FileCheck -check-prefix=COREI7 %s @@ -12,9 +13,13 @@ bb: %String2Loc9 = getelementptr inbounds [31 x i8]* %String2Loc, i64 0, i64 0 call void @llvm.memcpy.i64(i8* %String2Loc9, i8* getelementptr inbounds ([31 x i8]* @.str3, i64 0, i64 0), i64 31, i32 1) -; CORE2: movsd _.str3+16 -; CORE2: movsd _.str3+8 -; CORE2: movsd _.str3 +; I386: movsd _.str3+16 +; I386: movsd _.str3+8 +; I386: movsd _.str3 + +; CORE2: movabsq +; CORE2: movabsq +; CORE2: movabsq ; COREI7: movups _.str3 br label %bb @@ -30,9 +35,3 @@ ; CORE2-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" ; CORE2: .align 3 ; CORE2-NEXT: _.str3: - -; COREI7: .align 3 -; COREI7-NEXT: _.str1: -; COREI7-NEXT: .asciz "DHRYSTONE PROGRAM, SOME STRING" -; COREI7: .align 3 -; COREI7-NEXT: _.str3: From nicolas.geoffray at gmail.com Thu Apr 1 15:28:46 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Thu, 1 Apr 2010 22:28:46 +0200 Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp lib/VMCore/LLVMContextImpl.h In-Reply-To: References: Message-ID: Hi Chris, On Thu, Apr 1, 2010 at 2:48 AM, Chris Lattner wrote: > > > Machine-generated code often goes over 255 columns. Are you sure you > want to design this limitation in? > > Yep. Only clang generates column numbers, and I don't know of any > debuggers that do anything with them. We can always change this in the > future. > > Actually, I was using these values (column, line number) to store some runtime informations on an instruction (line number in a Java source file, Java bytecode number, etc). While I know that the interface is somehow not fully defined yet for debug location, having the possibility to get a number of high-level information on a machine instruction through this debugging utility was really useful. Nicolas > -Chris > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/3a169a81/attachment.html From nicolas.geoffray at gmail.com Thu Apr 1 15:31:02 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Thu, 1 Apr 2010 22:31:02 +0200 Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp lib/VMCore/LLVMContextImpl.h In-Reply-To: References: Message-ID: Oh, and I should also add that this broke at least one client of LLVM and debug information: VMKit ;) On Thu, Apr 1, 2010 at 10:28 PM, nicolas geoffray < nicolas.geoffray at gmail.com> wrote: > Hi Chris, > > On Thu, Apr 1, 2010 at 2:48 AM, Chris Lattner wrote: >> >> > Machine-generated code often goes over 255 columns. Are you sure you >> want to design this limitation in? >> >> Yep. Only clang generates column numbers, and I don't know of any >> debuggers that do anything with them. We can always change this in the >> future. >> >> > > Actually, I was using these values (column, line number) to store some > runtime informations on an instruction (line number in a Java source file, > Java bytecode number, etc). While I know that the interface is somehow not > fully defined yet for debug location, having the possibility to get a number > of high-level information on a machine instruction through this debugging > utility was really useful. > > Nicolas > > > >> -Chris >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/73a28e60/attachment.html From criswell at uiuc.edu Thu Apr 1 16:59:06 2010 From: criswell at uiuc.edu (John Criswell) Date: Thu, 01 Apr 2010 21:59:06 -0000 Subject: [llvm-commits] [poolalloc] r100141 - /poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp Message-ID: <20100401215906.D613B2A6C12C@llvm.org> Author: criswell Date: Thu Apr 1 16:59:06 2010 New Revision: 100141 URL: http://llvm.org/viewvc/llvm-project?rev=100141&view=rev Log: Updated the code to handle the fact that DSNode::getType() can return NULL. Updated the code to the new LLVM API: we need to use ConstantPointerNull::get() to get null pointer constants. Modified: poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp Modified: poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp?rev=100141&r1=100140&r2=100141&view=diff ============================================================================== --- poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp (original) +++ poolalloc/branches/release_26/lib/PoolAllocate/Heuristic.cpp Thu Apr 1 16:59:06 2010 @@ -122,8 +122,14 @@ /// unsigned Heuristic::getRecommendedAlignment(const DSNode *N) { const Type * VoidType = Type::getVoidTy(getGlobalContext()); - if (N->getType() == VoidType) // Is this void or collapsed? - return 0; // No known alignment, let runtime decide. + + // + // If this node has a void type (which can be signified by getType() + // returning NULL) or the node is collapsed, then there is no known + // alignment. We will return 0 to let the runtime decide. + // + if ((!(N->getType())) || (N->getType() == VoidType)) + return 0; const TargetData &TD = N->getParentGraph()->getTargetData(); @@ -454,7 +460,7 @@ if (!NullGlobal) { Module *M = I->getParent()->getParent()->getParent(); const Type * PoolTy = PoolAllocate::PoolDescPtrTy; - Constant * Init = ConstantAggregateZero::get(PoolTy); + Constant * Init = ConstantPointerNull::get(cast(PoolTy)); NullGlobal = new GlobalVariable(*M, PoolAllocate::PoolDescPtrTy, false, GlobalValue::ExternalLinkage, From criswell at uiuc.edu Thu Apr 1 16:59:35 2010 From: criswell at uiuc.edu (John Criswell) Date: Thu, 01 Apr 2010 21:59:35 -0000 Subject: [llvm-commits] [poolalloc] r100142 - /poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <20100401215935.222DC2A6C12C@llvm.org> Author: criswell Date: Thu Apr 1 16:59:34 2010 New Revision: 100142 URL: http://llvm.org/viewvc/llvm-project?rev=100142&view=rev Log: Do not insert poolregister() calls for stack-allocated objects. Let SAFECode do that for now. Modified: poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp?rev=100142&r1=100141&r2=100142&view=diff ============================================================================== --- poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/branches/release_26/lib/PoolAllocate/TransformFunctionBody.cpp Thu Apr 1 16:59:34 2010 @@ -279,34 +279,15 @@ } void FuncTransform::visitAllocaInst(AllocaInst &MI) { - // Don't do anything if bounds checking will not be done by SAFECode later. - if (!(PAInfo.BoundsChecksEnabled)) return; - - // Get the pool handle for the node that this contributes to... - DSNode *Node = getDSNodeHFor(&MI).getNode(); - if (Node->isArray()) { - Value *PH = getPoolHandle(&MI); - if (PH == 0 || isa(PH)) return; - TargetData &TD = PAInfo.getAnalysis(); - Value *AllocSize = ConstantInt::get(Int32Type, TD.getTypeAllocSize(MI.getAllocatedType())); - - if (MI.isArrayAllocation()) - AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize, - MI.getOperand(0), "sizetmp", &MI); - - // TransformAllocationInstr(&MI, AllocSize); - BasicBlock::iterator InsertPt(MI); - ++InsertPt; - Instruction *Casted = CastInst::CreatePointerCast(&MI, PointerType::getUnqual(Int8Type), - MI.getName()+".casted", InsertPt); - std::vector args; - args.push_back (PH); - args.push_back (Casted); - args.push_back (AllocSize); - Instruction *V = CallInst::Create(PAInfo.PoolRegister, - args.begin(), args.end(), "", InsertPt); - AddPoolUse(*V, PH, PoolUses); - } + // + // SAFECode will register alloca instructions with the run-time, so do not + // do that here. + // + // FIXME: + // There is a chance that we may need to update PoolUses to make sure that + // the pool handle is available in this function. + // + return; } From greened at obbligato.org Thu Apr 1 17:43:57 2010 From: greened at obbligato.org (David Greene) Date: Thu, 01 Apr 2010 22:43:57 -0000 Subject: [llvm-commits] [llvm] r100143 - in /llvm/trunk: include/llvm/Analysis/LoopPass.h include/llvm/Assembly/PrintModulePass.h include/llvm/CallGraphSCCPass.h include/llvm/CodeGen/MachineFunctionPass.h include/llvm/CodeGen/Passes.h include/llvm/Pass.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineFunctionPass.cpp lib/CodeGen/MachineFunctionPrinterPass.cpp lib/VMCore/Pass.cpp lib/VMCore/PassManager.cpp lib/VMCore/PrintModulePass.cpp Message-ID: <20100401224357.9F5082A6C12C@llvm.org> Author: greened Date: Thu Apr 1 17:43:57 2010 New Revision: 100143 URL: http://llvm.org/viewvc/llvm-project?rev=100143&view=rev Log: Add some switches helpful for debugging: -print-before= Dump IR before running pass . -print-before-all Dump IR before running each pass. -print-after-all Dump IR after running each pass. These are helpful when tracking down a miscompilation. It is easy to get IR dumps and do diffs on them, etc. To make this work well, add a new getPrinterPass API to Pass so that each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass suitable for dumping out the kind of object the Pass works on. Added: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h llvm/trunk/include/llvm/Assembly/PrintModulePass.h llvm/trunk/include/llvm/CallGraphSCCPass.h llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/PrintModulePass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Thu Apr 1 17:43:57 2010 @@ -31,6 +31,10 @@ explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} + /// getPrinterPass - Get a pass to print the function corresponding + /// to a Loop. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + // runOnLoop - This method should be implemented by the subclass to perform // whatever action is necessary for the specified Loop. virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0; Modified: llvm/trunk/include/llvm/Assembly/PrintModulePass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/PrintModulePass.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/PrintModulePass.h (original) +++ llvm/trunk/include/llvm/Assembly/PrintModulePass.h Thu Apr 1 17:43:57 2010 @@ -27,7 +27,9 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. - ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false); + ModulePass *createPrintModulePass(raw_ostream *OS, + bool DeleteStream=false, + const std::string &Banner = ""); /// createPrintFunctionPass - Create and return a pass that prints /// functions to the specified raw_ostream as they are processed. Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallGraphSCCPass.h (original) +++ llvm/trunk/include/llvm/CallGraphSCCPass.h Thu Apr 1 17:43:57 2010 @@ -35,6 +35,10 @@ explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} + /// createPrinterPass - Get a pass that prints the Module + /// corresponding to a CallGraph. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. virtual bool doInitialization(CallGraph &CG) { Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h Thu Apr 1 17:43:57 2010 @@ -34,6 +34,9 @@ explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} + /// createPrinterPass - Get a machine function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. /// Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Thu Apr 1 17:43:57 2010 @@ -21,6 +21,7 @@ namespace llvm { class FunctionPass; + class MachineFunctionPass; class PassInfo; class TargetLowering; class RegisterCoalescer; @@ -36,8 +37,9 @@ /// MachineFunctionPrinter pass - This pass prints out the machine function to /// the given stream, as a debugging tool. - FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner =""); + MachineFunctionPass * + createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner =""); /// MachineLoopInfo pass - This pass is a loop analysis pass. /// Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Thu Apr 1 17:43:57 2010 @@ -30,6 +30,7 @@ #define LLVM_PASS_H #include "llvm/System/DataTypes.h" + #include #include #include @@ -120,6 +121,11 @@ virtual void print(raw_ostream &O, const Module *M) const; void dump() const; // dump - Print to stderr. + /// createPrinterPass - Get a Pass appropriate to print the IR this + /// pass operates one (Module, Function or MachineFunction). + virtual Pass *createPrinterPass(raw_ostream &O, + const std::string &Banner) const = 0; + /// Each pass is responsible for assigning a pass manager to itself. /// PMS is the stack of available pass manager. virtual void assignPassManager(PMStack &, @@ -233,6 +239,9 @@ /// class ModulePass : public Pass { public: + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// runOnModule - Virtual method overriden by subclasses to process the module /// being operated on. virtual bool runOnModule(Module &M) = 0; @@ -293,6 +302,9 @@ explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -343,6 +355,9 @@ explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Thu Apr 1 17:43:57 2010 @@ -87,10 +87,40 @@ bool IsCheckingMode); }; +/// PrintCallGraphPass - Print a Module corresponding to a call graph. +/// +class PrintCallGraphPass : public CallGraphSCCPass { +private: + std::string Banner; + raw_ostream &Out; // raw_ostream to print on. + +public: + static char ID; + PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} + PrintCallGraphPass(const std::string &B, raw_ostream &o) + : CallGraphSCCPass(&ID), Banner(B), Out(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + bool runOnSCC(std::vector &SCC) { + Out << Banner; + for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); + n != ne; + ++n) { + (*n)->getFunction()->print(Out); + } + return false; + } +}; + } // end anonymous namespace. char CGPassManager::ID = 0; +char PrintCallGraphPass::ID = 0; + bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, CallGraph &CG, bool &CallGraphUpToDate) { bool Changed = false; @@ -396,6 +426,11 @@ return Changed; } +Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return new PrintCallGraphPass(Banner, O); +} + /// Assign pass manager to manage this pass. void CallGraphSCCPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Thu Apr 1 17:43:57 2010 @@ -14,9 +14,44 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" +#include "llvm/Assembly/PrintModulePass.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" using namespace llvm; +namespace { + +/// PrintLoopPass - Print a Function corresponding to a Loop. +/// +class PrintLoopPass : public LoopPass { +private: + std::string Banner; + raw_ostream &Out; // raw_ostream to print on. + +public: + static char ID; + PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {} + PrintLoopPass(const std::string &B, raw_ostream &o) + : LoopPass(&ID), Banner(B), Out(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + bool runOnLoop(Loop *L, LPPassManager &) { + Out << Banner; + for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); + b != be; + ++b) { + (*b)->print(Out); + } + return false; + } +}; + +char PrintLoopPass::ID = 0; +} + //===----------------------------------------------------------------------===// // LPPassManager // @@ -306,6 +341,11 @@ //===----------------------------------------------------------------------===// // LoopPass +Pass *LoopPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return new PrintLoopPass(Banner, O); +} + // Check if this pass is suitable for the current LPPassManager, if // available. This pass P is not suitable for a LPPassManager if P // is not preserving higher level analysis info used by other Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Thu Apr 1 17:43:57 2010 @@ -39,40 +39,6 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -namespace { - struct Printer : public MachineFunctionPass { - static char ID; - - raw_ostream &OS; - const std::string Banner; - - Printer(raw_ostream &os, const std::string &banner) - : MachineFunctionPass(&ID), OS(os), Banner(banner) {} - - const char *getPassName() const { return "MachineFunction Printer"; } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - bool runOnMachineFunction(MachineFunction &MF) { - OS << "# " << Banner << ":\n"; - MF.print(OS); - return false; - } - }; - char Printer::ID = 0; -} - -/// Returns a newly-created MachineFunction Printer pass. The default banner is -/// empty. -/// -FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner){ - return new Printer(OS, Banner); -} - //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Thu Apr 1 17:43:57 2010 @@ -15,8 +15,14 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/Passes.h" using namespace llvm; +Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createMachineFunctionPrinterPass(O, Banner); +} + bool MachineFunctionPass::runOnFunction(Function &F) { // Do not codegen any 'available_externally' functions at all, they have // definitions outside the translation unit. Added: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp?rev=100143&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (added) +++ llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Thu Apr 1 17:43:57 2010 @@ -0,0 +1,60 @@ +//===-- MachineFunctionPrinterPass.cpp ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// MachineFunctionPrinterPass implementation. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +namespace { +/// MachineFunctionPrinterPass - This is a pass to dump the IR of a +/// MachineFunction. +/// +struct MachineFunctionPrinterPass : public MachineFunctionPass { + static char ID; + + raw_ostream &OS; + const std::string Banner; + + MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} + + const char *getPassName() const { return "MachineFunction Printer"; } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) { + OS << "# " << Banner << ":\n"; + MF.print(OS); + return false; + } +}; + +char MachineFunctionPrinterPass::ID = 0; +} + +namespace llvm { +/// Returns a newly-created MachineFunction Printer pass. The +/// default banner is empty. +/// +MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner){ + return new MachineFunctionPrinterPass(OS, Banner); +} + +} Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Thu Apr 1 17:43:57 2010 @@ -18,6 +18,7 @@ #include "llvm/Module.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PassNameParser.h" @@ -42,6 +43,11 @@ // Force out-of-line virtual method. ModulePass::~ModulePass() { } +Pass *ModulePass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); +} + PassManagerType ModulePass::getPotentialPassManagerType() const { return PMT_ModulePassManager; } @@ -113,6 +119,11 @@ // FunctionPass Implementation // +Pass *FunctionPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createPrintFunctionPass(Banner, &O); +} + // run - On a module, we run this pass by initializing, runOnFunction'ing once // for every function in the module, then by finalizing. // @@ -155,6 +166,13 @@ // BasicBlockPass Implementation // +Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + + llvm_unreachable("BasicBlockPass printing unsupported."); + return 0; +} + // To run this pass on a function, we simply call runOnBasicBlock once for each // function. // Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Apr 1 17:43:57 2010 @@ -13,6 +13,7 @@ #include "llvm/PassManagers.h" +#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -20,6 +21,7 @@ #include "llvm/Module.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" #include "llvm/System/Threading.h" @@ -55,6 +57,57 @@ clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), clEnumValEnd)); + +typedef llvm::cl::list +PassOptionList; + +// Print IR out before/after specified passes. +static PassOptionList +PrintBefore("print-before", + llvm::cl::desc("Print IR before specified passes")); + +static PassOptionList +PrintAfter("print-after", + llvm::cl::desc("Print IR after specified passes")); + +static cl::opt +PrintBeforeAll("print-before-all", + llvm::cl::desc("Print IR before each pass"), + cl::init(false)); +static cl::opt +PrintAfterAll("print-after-all", + llvm::cl::desc("Print IR after each pass"), + cl::init(false)); + +/// This is a helper to determine whether to print IR before or +/// after a pass. + +static bool ShouldPrintBeforeOrAfterPass(Pass *P, + PassOptionList &PassesToPrint) { + for (unsigned i = 0, ie = PassesToPrint.size(); i < ie; ++i) { + const llvm::PassInfo *PassInf = PassesToPrint[i]; + if (PassInf && P->getPassInfo()) + if (PassInf->getPassArgument() == + P->getPassInfo()->getPassArgument()) { + return true; + } + } + return false; +} + + +/// This is a utility to check whether a pass should have IR dumped +/// before it. +static bool ShouldPrintBeforePass(Pass *P) { + return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(P, PrintBefore); +} + +/// This is a utility to check whether a pass should have IR dumped +/// after it. +static bool ShouldPrintAfterPass(Pass *P) { + return PrintAfterAll || ShouldPrintBeforeOrAfterPass(P, PrintAfter); +} + } // End of llvm namespace /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions @@ -182,6 +235,11 @@ schedulePass(P); } + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintFunctionPass(Banner, &O); + } + // Prepare for running an on the fly pass, freeing memory if needed // from a previous run. void releaseMemoryOnTheFly(); @@ -252,6 +310,11 @@ } } + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); + } + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnModule(Module &M); @@ -331,6 +394,11 @@ schedulePass(P); } + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); + } + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool run(Module &M); @@ -1208,7 +1276,14 @@ /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. void FunctionPassManager::add(Pass *P) { + if (ShouldPrintBeforePass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") + + P->getPassName() + " ***")); FPM->add(P); + + if (ShouldPrintAfterPass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") + + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep @@ -1519,7 +1594,15 @@ /// will be destroyed as well, so there is no need to delete the pass. This /// implies that all passes MUST be allocated with 'new'. void PassManager::add(Pass *P) { + if (ShouldPrintBeforePass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") + + P->getPassName() + " ***")); + PM->add(P); + + if (ShouldPrintAfterPass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") + + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep track of Modified: llvm/trunk/lib/VMCore/PrintModulePass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PrintModulePass.cpp?rev=100143&r1=100142&r2=100143&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PrintModulePass.cpp (original) +++ llvm/trunk/lib/VMCore/PrintModulePass.cpp Thu Apr 1 17:43:57 2010 @@ -23,21 +23,22 @@ namespace { class PrintModulePass : public ModulePass { + std::string Banner; raw_ostream *Out; // raw_ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: static char ID; PrintModulePass() : ModulePass(&ID), Out(&dbgs()), DeleteStream(false) {} - PrintModulePass(raw_ostream *o, bool DS) - : ModulePass(&ID), Out(o), DeleteStream(DS) {} + PrintModulePass(const std::string &B, raw_ostream *o, bool DS) + : ModulePass(&ID), Banner(B), Out(o), DeleteStream(DS) {} ~PrintModulePass() { if (DeleteStream) delete Out; } bool runOnModule(Module &M) { - (*Out) << M; + (*Out) << Banner << M; return false; } @@ -85,8 +86,9 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS, - bool DeleteStream) { - return new PrintModulePass(OS, DeleteStream); + bool DeleteStream, + const std::string &Banner) { + return new PrintModulePass(Banner, OS, DeleteStream); } /// createPrintFunctionPass - Create and return a pass that prints From dpatel at apple.com Thu Apr 1 17:47:30 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 01 Apr 2010 22:47:30 -0000 Subject: [llvm-commits] [llvm] r100145 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100401224730.1B89D2A6C12C@llvm.org> Author: dpatel Date: Thu Apr 1 17:47:29 2010 New Revision: 100145 URL: http://llvm.org/viewvc/llvm-project?rev=100145&view=rev Log: Revert r100117. 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=100145&r1=100144&r2=100145&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Apr 1 17:47:29 2010 @@ -2147,8 +2147,6 @@ DenseMap MIIndexMap; unsigned MIIndex = 0; - MDNode *PrevScope = NULL; - MDNode *PrevInlinedAt = NULL; // Scan each instruction and create scopes. First build working set of scopes. for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { @@ -2162,23 +2160,17 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); - MDNode *NewScope = DLTScope.getNode(); - if (!NewScope) continue; + if (!DLTScope.getNode()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. if (DLTScope.isCompileUnit()) continue; - MDNode *NewInlinedAt = DLT.getOrigLocation().getNode(); - if (NewScope == PrevScope && NewInlinedAt == PrevInlinedAt) continue; - createDbgScope(NewScope, NewInlinedAt); - PrevScope = NewScope; - PrevInlinedAt = NewInlinedAt; + createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode()); } } + // Build scope hierarchy using working set of scopes. - PrevScope = NULL; - PrevInlinedAt = NULL; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); @@ -2190,18 +2182,14 @@ if (DL.isUnknown()) continue; DILocation DLT = MF->getDILocation(DL); DIScope DLTScope = DLT.getScope(); - MDNode *NewScope = DLTScope.getNode(); - if (!NewScope) continue; + if (!DLTScope.getNode()) continue; // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. if (DLTScope.isCompileUnit()) continue; - MDNode *NewInlinedAt = DLT.getOrigLocation().getNode(); - if (NewScope == PrevScope && NewInlinedAt == PrevInlinedAt) continue; - DbgScope *Scope = getUpdatedDbgScope(NewScope, MInsn, NewInlinedAt); + DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn, + DLT.getOrigLocation().getNode()); Scope->setLastInsn(MInsn); - PrevScope = NewScope; - PrevInlinedAt = NewInlinedAt; } } From echristo at apple.com Thu Apr 1 17:54:42 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 01 Apr 2010 22:54:42 -0000 Subject: [llvm-commits] [llvm] r100146 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Assembly/ include/llvm/CodeGen/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Target/X86/ lib/VMCore/ Message-ID: <20100401225442.84A062A6C12C@llvm.org> Author: echristo Date: Thu Apr 1 17:54:42 2010 New Revision: 100146 URL: http://llvm.org/viewvc/llvm-project?rev=100146&view=rev Log: Revert r100143. Removed: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h llvm/trunk/include/llvm/Assembly/PrintModulePass.h llvm/trunk/include/llvm/CallGraphSCCPass.h llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/PrintModulePass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Thu Apr 1 17:54:42 2010 @@ -31,10 +31,6 @@ explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} - /// getPrinterPass - Get a pass to print the function corresponding - /// to a Loop. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - // runOnLoop - This method should be implemented by the subclass to perform // whatever action is necessary for the specified Loop. virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0; Modified: llvm/trunk/include/llvm/Assembly/PrintModulePass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/PrintModulePass.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/PrintModulePass.h (original) +++ llvm/trunk/include/llvm/Assembly/PrintModulePass.h Thu Apr 1 17:54:42 2010 @@ -27,9 +27,7 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. - ModulePass *createPrintModulePass(raw_ostream *OS, - bool DeleteStream=false, - const std::string &Banner = ""); + ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false); /// createPrintFunctionPass - Create and return a pass that prints /// functions to the specified raw_ostream as they are processed. Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallGraphSCCPass.h (original) +++ llvm/trunk/include/llvm/CallGraphSCCPass.h Thu Apr 1 17:54:42 2010 @@ -35,10 +35,6 @@ explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} - /// createPrinterPass - Get a pass that prints the Module - /// corresponding to a CallGraph. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. virtual bool doInitialization(CallGraph &CG) { Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h Thu Apr 1 17:54:42 2010 @@ -34,9 +34,6 @@ explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} - /// createPrinterPass - Get a machine function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. /// Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Thu Apr 1 17:54:42 2010 @@ -21,7 +21,6 @@ namespace llvm { class FunctionPass; - class MachineFunctionPass; class PassInfo; class TargetLowering; class RegisterCoalescer; @@ -37,9 +36,8 @@ /// MachineFunctionPrinter pass - This pass prints out the machine function to /// the given stream, as a debugging tool. - MachineFunctionPass * - createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner =""); + FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner =""); /// MachineLoopInfo pass - This pass is a loop analysis pass. /// Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Thu Apr 1 17:54:42 2010 @@ -30,7 +30,6 @@ #define LLVM_PASS_H #include "llvm/System/DataTypes.h" - #include #include #include @@ -121,11 +120,6 @@ virtual void print(raw_ostream &O, const Module *M) const; void dump() const; // dump - Print to stderr. - /// createPrinterPass - Get a Pass appropriate to print the IR this - /// pass operates one (Module, Function or MachineFunction). - virtual Pass *createPrinterPass(raw_ostream &O, - const std::string &Banner) const = 0; - /// Each pass is responsible for assigning a pass manager to itself. /// PMS is the stack of available pass manager. virtual void assignPassManager(PMStack &, @@ -239,9 +233,6 @@ /// class ModulePass : public Pass { public: - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// runOnModule - Virtual method overriden by subclasses to process the module /// being operated on. virtual bool runOnModule(Module &M) = 0; @@ -302,9 +293,6 @@ explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -355,9 +343,6 @@ explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Thu Apr 1 17:54:42 2010 @@ -87,40 +87,10 @@ bool IsCheckingMode); }; -/// PrintCallGraphPass - Print a Module corresponding to a call graph. -/// -class PrintCallGraphPass : public CallGraphSCCPass { -private: - std::string Banner; - raw_ostream &Out; // raw_ostream to print on. - -public: - static char ID; - PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} - PrintCallGraphPass(const std::string &B, raw_ostream &o) - : CallGraphSCCPass(&ID), Banner(B), Out(o) {} - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - - bool runOnSCC(std::vector &SCC) { - Out << Banner; - for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); - n != ne; - ++n) { - (*n)->getFunction()->print(Out); - } - return false; - } -}; - } // end anonymous namespace. char CGPassManager::ID = 0; -char PrintCallGraphPass::ID = 0; - bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, CallGraph &CG, bool &CallGraphUpToDate) { bool Changed = false; @@ -426,11 +396,6 @@ return Changed; } -Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return new PrintCallGraphPass(Banner, O); -} - /// Assign pass manager to manage this pass. void CallGraphSCCPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Thu Apr 1 17:54:42 2010 @@ -14,44 +14,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" using namespace llvm; -namespace { - -/// PrintLoopPass - Print a Function corresponding to a Loop. -/// -class PrintLoopPass : public LoopPass { -private: - std::string Banner; - raw_ostream &Out; // raw_ostream to print on. - -public: - static char ID; - PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {} - PrintLoopPass(const std::string &B, raw_ostream &o) - : LoopPass(&ID), Banner(B), Out(o) {} - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - - bool runOnLoop(Loop *L, LPPassManager &) { - Out << Banner; - for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); - b != be; - ++b) { - (*b)->print(Out); - } - return false; - } -}; - -char PrintLoopPass::ID = 0; -} - //===----------------------------------------------------------------------===// // LPPassManager // @@ -341,11 +306,6 @@ //===----------------------------------------------------------------------===// // LoopPass -Pass *LoopPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return new PrintLoopPass(Banner, O); -} - // Check if this pass is suitable for the current LPPassManager, if // available. This pass P is not suitable for a LPPassManager if P // is not preserving higher level analysis info used by other Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Thu Apr 1 17:54:42 2010 @@ -39,6 +39,40 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; +namespace { + struct Printer : public MachineFunctionPass { + static char ID; + + raw_ostream &OS; + const std::string Banner; + + Printer(raw_ostream &os, const std::string &banner) + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} + + const char *getPassName() const { return "MachineFunction Printer"; } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) { + OS << "# " << Banner << ":\n"; + MF.print(OS); + return false; + } + }; + char Printer::ID = 0; +} + +/// Returns a newly-created MachineFunction Printer pass. The default banner is +/// empty. +/// +FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner){ + return new Printer(OS, Banner); +} + //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Thu Apr 1 17:54:42 2010 @@ -15,14 +15,8 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/Passes.h" using namespace llvm; -Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createMachineFunctionPrinterPass(O, Banner); -} - bool MachineFunctionPass::runOnFunction(Function &F) { // Do not codegen any 'available_externally' functions at all, they have // definitions outside the translation unit. Removed: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp?rev=100145&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (removed) @@ -1,60 +0,0 @@ -//===-- MachineFunctionPrinterPass.cpp ------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// MachineFunctionPrinterPass implementation. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -namespace { -/// MachineFunctionPrinterPass - This is a pass to dump the IR of a -/// MachineFunction. -/// -struct MachineFunctionPrinterPass : public MachineFunctionPass { - static char ID; - - raw_ostream &OS; - const std::string Banner; - - MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) - : MachineFunctionPass(&ID), OS(os), Banner(banner) {} - - const char *getPassName() const { return "MachineFunction Printer"; } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - bool runOnMachineFunction(MachineFunction &MF) { - OS << "# " << Banner << ":\n"; - MF.print(OS); - return false; - } -}; - -char MachineFunctionPrinterPass::ID = 0; -} - -namespace llvm { -/// Returns a newly-created MachineFunction Printer pass. The -/// default banner is empty. -/// -MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner){ - return new MachineFunctionPrinterPass(OS, Banner); -} - -} Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Thu Apr 1 17:54:42 2010 @@ -234,9 +234,6 @@ PCMPEQB, PCMPEQW, PCMPEQD, PCMPEQQ, PCMPGTB, PCMPGTW, PCMPGTD, PCMPGTQ, - // Advanced Encryption Standard (AES) Instructions - AESIMC, AESENC, AESENCLAST, AESDEC, AESDECLAST, - // ADD, SUB, SMUL, UMUL, etc. - Arithmetic operations with FLAGS results. ADD, SUB, SMUL, UMUL, INC, DEC, OR, XOR, AND, Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Thu Apr 1 17:54:42 2010 @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PassNameParser.h" @@ -43,11 +42,6 @@ // Force out-of-line virtual method. ModulePass::~ModulePass() { } -Pass *ModulePass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); -} - PassManagerType ModulePass::getPotentialPassManagerType() const { return PMT_ModulePassManager; } @@ -119,11 +113,6 @@ // FunctionPass Implementation // -Pass *FunctionPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createPrintFunctionPass(Banner, &O); -} - // run - On a module, we run this pass by initializing, runOnFunction'ing once // for every function in the module, then by finalizing. // @@ -166,13 +155,6 @@ // BasicBlockPass Implementation // -Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - - llvm_unreachable("BasicBlockPass printing unsupported."); - return 0; -} - // To run this pass on a function, we simply call runOnBasicBlock once for each // function. // Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Apr 1 17:54:42 2010 @@ -13,7 +13,6 @@ #include "llvm/PassManagers.h" -#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -21,7 +20,6 @@ #include "llvm/Module.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" #include "llvm/System/Threading.h" @@ -57,57 +55,6 @@ clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), clEnumValEnd)); - -typedef llvm::cl::list -PassOptionList; - -// Print IR out before/after specified passes. -static PassOptionList -PrintBefore("print-before", - llvm::cl::desc("Print IR before specified passes")); - -static PassOptionList -PrintAfter("print-after", - llvm::cl::desc("Print IR after specified passes")); - -static cl::opt -PrintBeforeAll("print-before-all", - llvm::cl::desc("Print IR before each pass"), - cl::init(false)); -static cl::opt -PrintAfterAll("print-after-all", - llvm::cl::desc("Print IR after each pass"), - cl::init(false)); - -/// This is a helper to determine whether to print IR before or -/// after a pass. - -static bool ShouldPrintBeforeOrAfterPass(Pass *P, - PassOptionList &PassesToPrint) { - for (unsigned i = 0, ie = PassesToPrint.size(); i < ie; ++i) { - const llvm::PassInfo *PassInf = PassesToPrint[i]; - if (PassInf && P->getPassInfo()) - if (PassInf->getPassArgument() == - P->getPassInfo()->getPassArgument()) { - return true; - } - } - return false; -} - - -/// This is a utility to check whether a pass should have IR dumped -/// before it. -static bool ShouldPrintBeforePass(Pass *P) { - return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(P, PrintBefore); -} - -/// This is a utility to check whether a pass should have IR dumped -/// after it. -static bool ShouldPrintAfterPass(Pass *P) { - return PrintAfterAll || ShouldPrintBeforeOrAfterPass(P, PrintAfter); -} - } // End of llvm namespace /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions @@ -235,11 +182,6 @@ schedulePass(P); } - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintFunctionPass(Banner, &O); - } - // Prepare for running an on the fly pass, freeing memory if needed // from a previous run. void releaseMemoryOnTheFly(); @@ -310,11 +252,6 @@ } } - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); - } - /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnModule(Module &M); @@ -394,11 +331,6 @@ schedulePass(P); } - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); - } - /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool run(Module &M); @@ -1276,14 +1208,7 @@ /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. void FunctionPassManager::add(Pass *P) { - if (ShouldPrintBeforePass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") - + P->getPassName() + " ***")); FPM->add(P); - - if (ShouldPrintAfterPass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") - + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep @@ -1594,15 +1519,7 @@ /// will be destroyed as well, so there is no need to delete the pass. This /// implies that all passes MUST be allocated with 'new'. void PassManager::add(Pass *P) { - if (ShouldPrintBeforePass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") - + P->getPassName() + " ***")); - PM->add(P); - - if (ShouldPrintAfterPass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") - + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep track of Modified: llvm/trunk/lib/VMCore/PrintModulePass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PrintModulePass.cpp?rev=100146&r1=100145&r2=100146&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PrintModulePass.cpp (original) +++ llvm/trunk/lib/VMCore/PrintModulePass.cpp Thu Apr 1 17:54:42 2010 @@ -23,22 +23,21 @@ namespace { class PrintModulePass : public ModulePass { - std::string Banner; raw_ostream *Out; // raw_ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: static char ID; PrintModulePass() : ModulePass(&ID), Out(&dbgs()), DeleteStream(false) {} - PrintModulePass(const std::string &B, raw_ostream *o, bool DS) - : ModulePass(&ID), Banner(B), Out(o), DeleteStream(DS) {} + PrintModulePass(raw_ostream *o, bool DS) + : ModulePass(&ID), Out(o), DeleteStream(DS) {} ~PrintModulePass() { if (DeleteStream) delete Out; } bool runOnModule(Module &M) { - (*Out) << Banner << M; + (*Out) << M; return false; } @@ -86,9 +85,8 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS, - bool DeleteStream, - const std::string &Banner) { - return new PrintModulePass(Banner, OS, DeleteStream); + bool DeleteStream) { + return new PrintModulePass(OS, DeleteStream); } /// createPrintFunctionPass - Create and return a pass that prints From clattner at apple.com Thu Apr 1 17:55:35 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 1 Apr 2010 15:55:35 -0700 Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp lib/VMCore/LLVMContextImpl.h In-Reply-To: References: Message-ID: On Apr 1, 2010, at 1:28 PM, nicolas geoffray wrote: > Hi Chris, > > On Thu, Apr 1, 2010 at 2:48 AM, Chris Lattner wrote: > > Machine-generated code often goes over 255 columns. Are you sure you want to design this limitation in? > > Yep. Only clang generates column numbers, and I don't know of any debuggers that do anything with them. We can always change this in the future. > > > > Actually, I was using these values (column, line number) to store some runtime informations on an instruction (line number in a Java source file, Java bytecode number, etc). While I know that the interface is somehow not fully defined yet for debug location, having the possibility to get a number of high-level information on a machine instruction through this debugging utility was really useful. Sure, you're welcome to continue doing that with metadata, just don't use the !dbg tag. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/bdf7731c/attachment.html From echristo at apple.com Thu Apr 1 17:59:26 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 1 Apr 2010 15:59:26 -0700 Subject: [llvm-commits] [llvm] r100146 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Assembly/ include/llvm/CodeGen/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Target/X86/ lib/VMCore/ In-Reply-To: <20100401225442.84A062A6C12C@llvm.org> References: <20100401225442.84A062A6C12C@llvm.org> Message-ID: On Apr 1, 2010, at 3:54 PM, Eric Christopher wrote: > Author: echristo > Date: Thu Apr 1 17:54:42 2010 > New Revision: 100146 > > URL: http://llvm.org/viewvc/llvm-project?rev=100146&view=rev > Log: > Revert r100143. Reverted this since it appears to be breaking the build bots. -eric From dag at cray.com Thu Apr 1 18:06:15 2010 From: dag at cray.com (David Greene) Date: Thu, 1 Apr 2010 18:06:15 -0500 Subject: [llvm-commits] [llvm] r100146 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Assembly/ include/llvm/CodeGen/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Target/X86/ lib/VMCore/ In-Reply-To: References: <20100401225442.84A062A6C12C@llvm.org> Message-ID: <201004011806.25488.dag@cray.com> On Thursday 01 April 2010 17:59:26 Eric Christopher wrote: > On Apr 1, 2010, at 3:54 PM, Eric Christopher wrote: > > Author: echristo > > Date: Thu Apr 1 17:54:42 2010 > > New Revision: 100146 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=100146&view=rev > > Log: > > Revert r100143. > > Reverted this since it appears to be breaking the build bots. I have no idea what happened. I literally built four different ways on this end and it was fine. I'll investigate. -Dave From bob.wilson at apple.com Thu Apr 1 18:05:58 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 01 Apr 2010 23:05:58 -0000 Subject: [llvm-commits] [llvm] r100147 - in /llvm/trunk: include/llvm/Transforms/Utils/SSAUpdater.h lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100401230558.64B442A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 18:05:58 2010 New Revision: 100147 URL: http://llvm.org/viewvc/llvm-project?rev=100147&view=rev Log: Rewrite another SSAUpdater function to avoid recursion. Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h?rev=100147&r1=100146&r2=100147&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/SSAUpdater.h Thu Apr 1 18:05:58 2010 @@ -108,8 +108,8 @@ void FindPHIPlacement(BasicBlock *BB, BBInfo *Info, bool &Changed, unsigned Counter); void FindAvailableVal(BasicBlock *BB, BBInfo *Info, unsigned Counter); - void FindExistingPHI(BasicBlock *BB, BBInfo *Info); - bool CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val); + void FindExistingPHI(BasicBlock *BB); + bool CheckIfPHIMatches(PHINode *PHI); void RecordMatchingPHI(PHINode *PHI); void ClearPHITags(PHINode *PHI); Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100147&r1=100146&r2=100147&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 18:05:58 2010 @@ -366,7 +366,7 @@ PHINode *NewPHI = 0; if (Info->DefBB == BB) { // Look for an existing PHI. - FindExistingPHI(BB, Info); + FindExistingPHI(BB); if (!Info->AvailableVal) { NewPHI = PHINode::Create(PrototypeValue->getType(), PrototypeValue->getName(), &BB->front()); @@ -401,11 +401,11 @@ /// FindExistingPHI - Look through the PHI nodes in a block to see if any of /// them match what is needed. -void SSAUpdater::FindExistingPHI(BasicBlock *BB, BBInfo *Info) { +void SSAUpdater::FindExistingPHI(BasicBlock *BB) { PHINode *SomePHI; for (BasicBlock::iterator It = BB->begin(); (SomePHI = dyn_cast(It)); ++It) { - if (CheckIfPHIMatches(BB, Info, SomePHI)) { + if (CheckIfPHIMatches(SomePHI)) { RecordMatchingPHI(SomePHI); break; } @@ -413,40 +413,54 @@ } } -/// CheckIfPHIMatches - Check if Val is a PHI node in block BB that matches -/// the placement and values in the BBMap. -bool SSAUpdater::CheckIfPHIMatches(BasicBlock *BB, BBInfo *Info, Value *Val) { - if (Info->AvailableVal) - return Val == Info->AvailableVal; - - // Check if Val is a PHI in this block. - PHINode *PHI = dyn_cast(Val); - if (!PHI || PHI->getParent() != BB) - return false; - - // If this block has already been visited, check if this PHI matches. - if (Info->PHITag) - return PHI == Info->PHITag; - Info->PHITag = PHI; - bool IsMatch = true; - - // Iterate through the predecessors. +/// CheckIfPHIMatches - Check if a PHI node matches the placement and values +/// in the BBMap. +bool SSAUpdater::CheckIfPHIMatches(PHINode *PHI) { BBMapTy *BBMap = getBBMap(BM); - for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - BasicBlock *Pred = PHI->getIncomingBlock(i); - Value *IncomingVal = PHI->getIncomingValue(i); - BBInfo *PredInfo = (*BBMap)[Pred]; - // Skip to the nearest preceding definition. - if (PredInfo->DefBB != Pred) { - Pred = PredInfo->DefBB; - PredInfo = (*BBMap)[Pred]; - } - if (!CheckIfPHIMatches(Pred, PredInfo, IncomingVal)) { - IsMatch = false; - break; + SmallVector WorkList; + WorkList.push_back(PHI); + + // Mark that the block containing this PHI has been visited. + (*BBMap)[PHI->getParent()]->PHITag = PHI; + + while (!WorkList.empty()) { + PHI = WorkList.pop_back_val(); + + // Iterate through the PHI's incoming values. + for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { + Value *IncomingVal = PHI->getIncomingValue(i); + BasicBlock *Pred = PHI->getIncomingBlock(i); + BBInfo *PredInfo = (*BBMap)[Pred]; + // Skip to the nearest preceding definition. + if (PredInfo->DefBB != Pred) { + Pred = PredInfo->DefBB; + PredInfo = (*BBMap)[Pred]; + } + + // Check if it matches the expected value. + if (PredInfo->AvailableVal) { + if (IncomingVal == PredInfo->AvailableVal) + continue; + return false; + } + + // Check if the value is a PHI in the correct block. + PHINode *IncomingPHIVal = dyn_cast(IncomingVal); + if (!IncomingPHIVal || IncomingPHIVal->getParent() != Pred) + return false; + + // If this block has already been visited, check if this PHI matches. + if (PredInfo->PHITag) { + if (IncomingPHIVal == PredInfo->PHITag) + continue; + return false; + } + PredInfo->PHITag = IncomingPHIVal; + + WorkList.push_back(IncomingPHIVal); } } - return IsMatch; + return true; } /// RecordMatchingPHI - For a PHI node that matches, record it and its input From bob.wilson at apple.com Thu Apr 1 18:06:38 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 01 Apr 2010 23:06:38 -0000 Subject: [llvm-commits] [llvm] r100148 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100401230638.4E1972A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 18:06:38 2010 New Revision: 100148 URL: http://llvm.org/viewvc/llvm-project?rev=100148&view=rev Log: Remove trailing whitespace. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100148&r1=100147&r2=100148&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 18:06:38 2010 @@ -65,7 +65,7 @@ for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) { TmpPreds.push_back(*PI); ++NumPreds; - } + } Preds = static_cast (Allocator->Allocate(NumPreds * sizeof(BasicBlock*), AlignOf::Alignment)); @@ -119,7 +119,7 @@ /// IsEquivalentPHI - Check if PHI has the same incoming value as specified /// in ValueMapping for each predecessor block. -static bool IsEquivalentPHI(PHINode *PHI, +static bool IsEquivalentPHI(PHINode *PHI, DenseMap &ValueMapping) { unsigned PHINumValues = PHI->getNumIncomingValues(); if (PHINumValues != ValueMapping.size()) @@ -254,7 +254,7 @@ /// which use their value in the corresponding predecessor. void SSAUpdater::RewriteUse(Use &U) { Instruction *User = cast(U.getUser()); - + Value *V; if (PHINode *UserPN = dyn_cast(User)) V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U)); @@ -299,7 +299,7 @@ /// FindPHIPlacement - Recursively visit the predecessors of a block to find /// the reaching definition for each predecessor and then determine whether -/// a PHI is needed in this block. +/// a PHI is needed in this block. void SSAUpdater::FindPHIPlacement(BasicBlock *BB, BBInfo *Info, bool &Changed, unsigned Counter) { AvailableValsTy &AvailableVals = getAvailableVals(AV); @@ -390,7 +390,7 @@ } else if (!Info->AvailableVal) Info->AvailableVal = PredInfo->AvailableVal; } - + if (NewPHI) { DEBUG(dbgs() << " Inserted PHI: " << *NewPHI << "\n"); From isanbard at gmail.com Thu Apr 1 18:08:27 2010 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 01 Apr 2010 23:08:27 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r100149 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100401230827.A409D2A6C12C@llvm.org> Author: void Date: Thu Apr 1 18:08:27 2010 New Revision: 100149 URL: http://llvm.org/viewvc/llvm-project?rev=100149&view=rev Log: Set the proper linkage for the ".llvm.eh.catch.all.value" variable. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=100149&r1=100148&r2=100149&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Apr 1 18:08:27 2010 @@ -2165,7 +2165,7 @@ Init = cast(Emit(catch_all_type, 0)); CatchAll = new GlobalVariable(*TheModule, Init->getType(), true, - GlobalVariable::PrivateLinkage, + GlobalVariable::LinkOnceAnyLinkage, Init, ".llvm.eh.catch.all.value"); } From clattner at apple.com Thu Apr 1 18:13:25 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 1 Apr 2010 16:13:25 -0700 Subject: [llvm-commits] [llvm] r100146 - in /llvm/trunk: include/llvm/ include/llvm/Analysis/ include/llvm/Assembly/ include/llvm/CodeGen/ lib/Analysis/ lib/Analysis/IPA/ lib/CodeGen/ lib/Target/X86/ lib/VMCore/ In-Reply-To: <201004011806.25488.dag@cray.com> References: <20100401225442.84A062A6C12C@llvm.org> <201004011806.25488.dag@cray.com> Message-ID: <2AD6128B-5A45-4A5A-8E9C-1EED648AF8B4@apple.com> On Apr 1, 2010, at 4:06 PM, David Greene wrote: > On Thursday 01 April 2010 17:59:26 Eric Christopher wrote: >> On Apr 1, 2010, at 3:54 PM, Eric Christopher wrote: >>> Author: echristo >>> Date: Thu Apr 1 17:54:42 2010 >>> New Revision: 100146 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=100146&view=rev >>> Log: >>> Revert r100143. >> >> Reverted this since it appears to be breaking the build bots. > > I have no idea what happened. I literally built four different ways on > this end and it was fine. You can see what happened on the build bot, for example: http://google1.osuosl.org:8011/builders/llvm-i686-linux/builds/8607/steps/compile/logs/stdio From dag at cray.com Thu Apr 1 18:25:34 2010 From: dag at cray.com (David Greene) Date: Thu, 1 Apr 2010 18:25:34 -0500 Subject: [llvm-commits] =?iso-8859-1?q?=5Bllvm=5D_r100146_-_in_/llvm/trunk?= =?iso-8859-1?q?=3A_include/llvm/_include/llvm/Analysis/_include/llvm/Asse?= =?iso-8859-1?q?mbly/=09include/llvm/CodeGen/_lib/Analysis/_lib/Analysis/I?= =?iso-8859-1?q?PA/=09lib/CodeGen/_lib/Target/X86/_lib/VMCore/?= In-Reply-To: <2AD6128B-5A45-4A5A-8E9C-1EED648AF8B4@apple.com> References: <20100401225442.84A062A6C12C@llvm.org> <201004011806.25488.dag@cray.com> <2AD6128B-5A45-4A5A-8E9C-1EED648AF8B4@apple.com> Message-ID: <201004011825.50726.dag@cray.com> On Thursday 01 April 2010 18:13:25 Chris Lattner wrote: > > I have no idea what happened. I literally built four different ways on > > this end and it was fine. > > You can see what happened on the build bot, for example: > http://google1.osuosl.org:8011/builders/llvm-i686-linux/builds/8607/steps/c >ompile/logs/stdio _______________________________________________ Yeah, I know, but the error message doesn't make sense WRT to the code I have here... Hmm...I suspect it's a missing header. Library differences, perhaps? If our version of libstdc++ includes somewhere it would hide the problem from me. -Dave From dag at cray.com Thu Apr 1 18:35:03 2010 From: dag at cray.com (David Greene) Date: Thu, 1 Apr 2010 18:35:03 -0500 Subject: [llvm-commits] =?iso-8859-1?q?=5Bllvm=5D_r100146_-_in_/llvm/trunk?= =?iso-8859-1?q?=3A_include/llvm/_include/llvm/Analysis/_include/llvm/Asse?= =?iso-8859-1?q?mbly/=09include/llvm/CodeGen/_lib/Analysis/_lib/Analysis/I?= =?iso-8859-1?q?PA/=09lib/CodeGen/_lib/Target/X86/_lib/VMCore/?= In-Reply-To: <201004011825.50726.dag@cray.com> References: <20100401225442.84A062A6C12C@llvm.org> <2AD6128B-5A45-4A5A-8E9C-1EED648AF8B4@apple.com> <201004011825.50726.dag@cray.com> Message-ID: <201004011835.13842.dag@cray.com> On Thursday 01 April 2010 18:25:34 David Greene wrote: > On Thursday 01 April 2010 18:13:25 Chris Lattner wrote: > > > I have no idea what happened. I literally built four different ways on > > > this end and it was fine. > > > > You can see what happened on the build bot, for example: > > http://google1.osuosl.org:8011/builders/llvm-i686-linux/builds/8607/steps > >/c ompile/logs/stdio _______________________________________________ > > Yeah, I know, but the error message doesn't make sense WRT to the > code I have here... > > Hmm...I suspect it's a missing header. Library differences, > perhaps? If our version of libstdc++ includes somewhere it > would hide the problem from me. It's gotta be a library difference. I'm compiling clean again and it got past Dominators.cpp just fine. I'll add a #include and try again. -Dave From gohman at apple.com Thu Apr 1 19:03:52 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 00:03:52 -0000 Subject: [llvm-commits] [llvm] r100156 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <20100402000352.2229C2A6C12C@llvm.org> Author: djg Date: Thu Apr 1 19:03:51 2010 New Revision: 100156 URL: http://llvm.org/viewvc/llvm-project?rev=100156&view=rev Log: If the bitcode reader input stream isn't a multiple of 4 bytes, it's more likely not a bitcode file at all, rather than being a bitcode file which is truncated. Check for this case and issue a more relevant error message. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=100156&r1=100155&r2=100156&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Apr 1 19:03:51 2010 @@ -1527,12 +1527,16 @@ bool BitcodeReader::ParseBitcodeInto(Module *M) { TheModule = 0; - if (Buffer->getBufferSize() & 3) - return Error("Bitcode stream should be a multiple of 4 bytes in length"); - unsigned char *BufPtr = (unsigned char *)Buffer->getBufferStart(); unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); + if (Buffer->getBufferSize() & 3) { + if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd)) + return Error("Invalid bitcode signature"); + else + return Error("Bitcode stream should be a multiple of 4 bytes in length"); + } + // If we have a wrapper header, parse it and ignore the non-bc file contents. // The magic number is 0x0B17C0DE stored in little endian. if (isBitcodeWrapper(BufPtr, BufEnd)) From ggreif at gmail.com Thu Apr 1 19:08:26 2010 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 02 Apr 2010 00:08:26 -0000 Subject: [llvm-commits] [llvm] r100157 - in /llvm/trunk: ./ docs/ProgrammersManual.html Message-ID: <20100402000826.EBAA32A6C12C@llvm.org> Author: ggreif Date: Thu Apr 1 19:08:26 2010 New Revision: 100157 URL: http://llvm.org/viewvc/llvm-project?rev=100157&view=rev Log: remove these merge-tracking properties as they might interfere with merges to other branches (as Dan pointed out) Modified: llvm/trunk/ (props changed) llvm/trunk/docs/ProgrammersManual.html (props changed) Propchange: llvm/trunk/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo (removed) @@ -1,2 +0,0 @@ -/llvm/branches/ggreif/InvokeInst-operands:98645-99398 -/llvm/branches/ggreif/const-CallSite:99517-100006 Propchange: llvm/trunk/docs/ProgrammersManual.html ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo (removed) @@ -1,3 +0,0 @@ -/llvm/branches/ggreif/InvokeInst-operands/docs/ProgrammersManual.html:98645-99398 -/llvm/branches/ggreif/const-CallSite/docs/ProgrammersManual.html:99517-100006 -/llvm/trunk/docs/ProgrammersManual.html:70891 From bob.wilson at apple.com Thu Apr 1 19:10:41 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 02 Apr 2010 00:10:41 -0000 Subject: [llvm-commits] [llvm] r100158 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100402001041.C48CF2A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 19:10:41 2010 New Revision: 100158 URL: http://llvm.org/viewvc/llvm-project?rev=100158&view=rev Log: Check for terminating conditions before adding PHIs to the worklists. This is more efficient than adding them to the worklist and then ignoring them. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100158&r1=100157&r2=100158&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 19:10:41 2010 @@ -471,22 +471,27 @@ SmallVector WorkList; WorkList.push_back(PHI); + // Record this PHI. + BasicBlock *BB = PHI->getParent(); + AvailableVals[BB] = PHI; + (*BBMap)[BB]->AvailableVal = PHI; + while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); - BasicBlock *BB = PHI->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal) - return; - - // Record the PHI. - AvailableVals[BB] = PHI; - Info->AvailableVal = PHI; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingVal) continue; - WorkList.push_back(IncomingVal); + PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingPHIVal) continue; + BB = IncomingPHIVal->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal) + continue; + + // Record the PHI and add it to the worklist. + AvailableVals[BB] = IncomingPHIVal; + Info->AvailableVal = IncomingPHIVal; + WorkList.push_back(IncomingPHIVal); } } } @@ -499,21 +504,24 @@ SmallVector WorkList; WorkList.push_back(PHI); + // Clear the tag for this PHI. + (*BBMap)[PHI->getParent()]->PHITag = 0; + while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); - BasicBlock *BB = PHI->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal || !Info->PHITag) - continue; - - // Clear the tag. - Info->PHITag = 0; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingVal) continue; - WorkList.push_back(IncomingVal); + PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingPHIVal) continue; + BasicBlock *BB = IncomingPHIVal->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal || !Info->PHITag) + continue; + + // Clear the tag and add the PHI to the worklist. + Info->PHITag = 0; + WorkList.push_back(IncomingPHIVal); } } } From ggreif at gmail.com Thu Apr 1 19:13:37 2010 From: ggreif at gmail.com (Gabor Greif) Date: Fri, 2 Apr 2010 02:13:37 +0200 Subject: [llvm-commits] [llvm] r100100 - in /llvm/trunk: ./ docs/ProgrammersManual.html include/llvm/Support/CallSite.h lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/Transforms/Scalar/SCCP.cpp lib/VMCore/Function.cpp Message-ID: On Thu, Apr 1, 2010 at 10:23 PM, Dan Gohman wrote: > > On Apr 1, 2010, at 1:21 AM, Gabor Greif wrote: >> >> Propchange: llvm/trunk/ >> ------------------------------------------------------------------------------ >> --- svn:mergeinfo (original) >> +++ svn:mergeinfo Thu Apr ?1 03:21:08 2010 >> @@ -1 +1,2 @@ >> /llvm/branches/ggreif/InvokeInst-operands:98645-99398 >> +/llvm/branches/ggreif/const-CallSite:99517-100006 >> >> Propchange: llvm/trunk/docs/ProgrammersManual.html >> ------------------------------------------------------------------------------ >> --- svn:mergeinfo (added) >> +++ svn:mergeinfo Thu Apr ?1 03:21:08 2010 >> @@ -0,0 +1,3 @@ >> +/llvm/branches/ggreif/InvokeInst-operands/docs/ProgrammersManual.html:98645-99398 >> +/llvm/branches/ggreif/const-CallSite/docs/ProgrammersManual.html:99517-100006 >> +/llvm/trunk/docs/ProgrammersManual.html:70891 > > Hi Gabor, > > What's the status of these properties? They don't look entirely intentional. Yeah I have zapped them as discussed on IRC (r100157). Cheers, Gabor > > Dan > > From gohman at apple.com Thu Apr 1 19:14:16 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 00:14:16 -0000 Subject: [llvm-commits] [llvm] r100160 - in /llvm/trunk: lib/Transforms/IPO/GlobalOpt.cpp test/Transforms/GlobalOpt/gv-align.ll Message-ID: <20100402001416.9A5442A6C12C@llvm.org> Author: djg Date: Thu Apr 1 19:14:16 2010 New Revision: 100160 URL: http://llvm.org/viewvc/llvm-project?rev=100160&view=rev Log: Make globalopt refine global variable alignment. Added: llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=100160&r1=100159&r2=100160&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 1 19:14:16 2010 @@ -1880,6 +1880,7 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) { bool Changed = false; + TargetData *TD = getAnalysisIfAvailable(); for (Module::global_iterator GVI = M.global_begin(), E = M.global_end(); GVI != E; ) { GlobalVariable *GV = GVI++; @@ -1889,11 +1890,16 @@ // Simplify the initializer. if (GV->hasInitializer()) if (ConstantExpr *CE = dyn_cast(GV->getInitializer())) { - TargetData *TD = getAnalysisIfAvailable(); Constant *New = ConstantFoldConstantExpression(CE, TD); if (New && New != CE) GV->setInitializer(New); } + // Refine the alignment value. + if (TD && GV->hasDefinitiveInitializer()) { + unsigned Align = TD->getPreferredAlignment(GV); + if (Align > GV->getAlignment()) + GV->setAlignment(Align); + } // Do more involved optimizations if the global is internal. if (!GV->isConstant() && GV->hasLocalLinkage() && GV->hasInitializer()) Added: llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll?rev=100160&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll (added) +++ llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll Thu Apr 1 19:14:16 2010 @@ -0,0 +1,6 @@ +; RUN: opt -globalopt -S < %s | grep {, align 16} + +; Globalopt should refine the alignment for global variables. + +target datalayout = "e-p:64:64:64" + at a = global [4 x i32] [i32 2, i32 3, i32 4, i32 5 ] From gohman at apple.com Thu Apr 1 19:46:07 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 00:46:07 -0000 Subject: [llvm-commits] [llvm] r100161 - /llvm/trunk/lib/Target/TargetData.cpp Message-ID: <20100402004607.BC2302A6C12C@llvm.org> Author: djg Date: Thu Apr 1 19:46:07 2010 New Revision: 100161 URL: http://llvm.org/viewvc/llvm-project?rev=100161&view=rev Log: Change variables which are exactly 16 bytes to be 16-byte-aligned too. This fixes test/Transforms/GlobalOpt/gv-align.ll. Modified: llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=100161&r1=100160&r2=100161&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Thu Apr 1 19:46:07 2010 @@ -651,7 +651,7 @@ if (Alignment < 16) { // If the global is not external, see if it is large. If so, give it a // larger alignment. - if (getTypeSizeInBits(ElemType) > 128) + if (getTypeSizeInBits(ElemType) >= 128) Alignment = 16; // 16-byte alignment. } } From scallanan at apple.com Thu Apr 1 19:53:42 2010 From: scallanan at apple.com (Sean Callanan) Date: Fri, 02 Apr 2010 00:53:42 -0000 Subject: [llvm-commits] [llvm] r100163 - /llvm/trunk/tools/edis/Makefile Message-ID: <20100402005342.862612A6C12C@llvm.org> Author: spyffe Date: Thu Apr 1 19:53:42 2010 New Revision: 100163 URL: http://llvm.org/viewvc/llvm-project?rev=100163&view=rev Log: Updated the install location for EnhancedDisassembly on Mac OS X to use @rpath rather than an absolute path. Also allowed the version to be set using an environment variable. Modified: llvm/trunk/tools/edis/Makefile Modified: llvm/trunk/tools/edis/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/Makefile?rev=100163&r1=100162&r2=100163&view=diff ============================================================================== --- llvm/trunk/tools/edis/Makefile (original) +++ llvm/trunk/tools/edis/Makefile Thu Apr 1 19:53:42 2010 @@ -25,26 +25,23 @@ include $(LEVEL)/Makefile.common ifeq ($(HOST_OS),Darwin) - # set dylib internal version number to llvmCore submission number - ifdef LLVM_SUBMIT_VERSION - LLVMLibsOptions := $(LLVMLibsOptions) -Wl,-current_version \ - -Wl,$(LLVM_SUBMIT_VERSION).$(LLVM_SUBMIT_SUBVERSION) \ - -Wl,-compatibility_version -Wl,1 - endif # extra options to override libtool defaults LLVMLibsOptions := $(LLVMLibsOptions) \ -avoid-version \ -Wl,-exported_symbols_list -Wl,$(PROJ_SRC_DIR)/EnhancedDisassembly.exports \ - -Wl,-dead_strip \ - -Wl,-seg1addr -Wl,0xE0000000 + -Wl,-dead_strip + + ifdef EDIS_VERSION + LLVMLibsOptions := -Wl,-current_version -Wl,$(EDIS_VERSION) \ + -Wl,-compatibility_version -Wl,1 + endif # Mac OS X 10.4 and earlier tools do not allow a second -install_name on command line - # Path is /Developer/usr/local/lib for now; will use an rpath-based mechanism soon DARWIN_VERS := $(shell echo $(TARGET_TRIPLE) | sed 's/.*darwin\([0-9]*\).*/\1/') ifneq ($(DARWIN_VERS),8) LLVMLibsOptions := $(LLVMLibsOptions) \ -no-undefined -Wl,-install_name \ - -Wl,"/Developer/usr/local/lib/lib$(LIBRARYNAME)$(SHLIBEXT)" + -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)" endif endif From bob.wilson at apple.com Thu Apr 1 20:22:49 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 02 Apr 2010 01:22:49 -0000 Subject: [llvm-commits] [llvm] r100164 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100402012249.DBE922A6C12C@llvm.org> Author: bwilson Date: Thu Apr 1 20:22:49 2010 New Revision: 100164 URL: http://llvm.org/viewvc/llvm-project?rev=100164&view=rev Log: Revert 100158 in case it is causing some of the buildbot problems. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100164&r1=100163&r2=100164&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Thu Apr 1 20:22:49 2010 @@ -471,27 +471,22 @@ SmallVector WorkList; WorkList.push_back(PHI); - // Record this PHI. - BasicBlock *BB = PHI->getParent(); - AvailableVals[BB] = PHI; - (*BBMap)[BB]->AvailableVal = PHI; - while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); + BasicBlock *BB = PHI->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal) + return; + + // Record the PHI. + AvailableVals[BB] = PHI; + Info->AvailableVal = PHI; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingPHIVal) continue; - BB = IncomingPHIVal->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal) - continue; - - // Record the PHI and add it to the worklist. - AvailableVals[BB] = IncomingPHIVal; - Info->AvailableVal = IncomingPHIVal; - WorkList.push_back(IncomingPHIVal); + PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingVal) continue; + WorkList.push_back(IncomingVal); } } } @@ -504,24 +499,21 @@ SmallVector WorkList; WorkList.push_back(PHI); - // Clear the tag for this PHI. - (*BBMap)[PHI->getParent()]->PHITag = 0; - while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); + BasicBlock *BB = PHI->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal || !Info->PHITag) + continue; + + // Clear the tag. + Info->PHITag = 0; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingPHIVal) continue; - BasicBlock *BB = IncomingPHIVal->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal || !Info->PHITag) - continue; - - // Clear the tag and add the PHI to the worklist. - Info->PHITag = 0; - WorkList.push_back(IncomingPHIVal); + PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingVal) continue; + WorkList.push_back(IncomingVal); } } } From gohman at apple.com Thu Apr 1 20:24:08 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 01:24:08 -0000 Subject: [llvm-commits] [llvm] r100165 - /llvm/trunk/test/CodeGen/X86/global-sections.ll Message-ID: <20100402012408.9F0682A6C12C@llvm.org> Author: djg Date: Thu Apr 1 20:24:08 2010 New Revision: 100165 URL: http://llvm.org/viewvc/llvm-project?rev=100165&view=rev Log: Update this test for the new preferred alignment heuristics. Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=100165&r1=100164&r2=100165&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original) +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Thu Apr 1 20:24:08 2010 @@ -113,7 +113,7 @@ ; DARWIN: .globl _G9 ; DARWIN: _G9: -; LINUX: .section .rodata.str4.4,"aMS", at progbits,4 +; LINUX: .section .rodata.str4.16,"aMS", at progbits,4 ; LINUX: .globl G9 ; LINUX:G9 From gohman at apple.com Thu Apr 1 20:26:13 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 01:26:13 -0000 Subject: [llvm-commits] [llvm] r100166 - /llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Message-ID: <20100402012613.6F0832A6C12C@llvm.org> Author: djg Date: Thu Apr 1 20:26:13 2010 New Revision: 100166 URL: http://llvm.org/viewvc/llvm-project?rev=100166&view=rev Log: Remove this initializer so that the optimizer doesn't convert unaligned loads into aligned loads. Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll?rev=100166&r1=100165&r2=100166&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Thu Apr 1 20:26:13 2010 @@ -4,7 +4,7 @@ ; RUN: grep movups %t | count 2 target triple = "i686-apple-darwin" - at x = global [4 x i32] [ i32 1, i32 2, i32 3, i32 4 ] ; <[4 x i32]*> [#uses=4] + at x = external global [4 x i32] define <2 x i64> @test1() { %tmp = load i32* getelementptr ([4 x i32]* @x, i32 0, i32 0) ; [#uses=1] From chandlerc at gmail.com Thu Apr 1 20:31:24 2010 From: chandlerc at gmail.com (Chandler Carruth) Date: Fri, 02 Apr 2010 01:31:24 -0000 Subject: [llvm-commits] [llvm] r100167 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100402013125.1DBBC2A6C12C@llvm.org> Author: chandlerc Date: Thu Apr 1 20:31:24 2010 New Revision: 100167 URL: http://llvm.org/viewvc/llvm-project?rev=100167&view=rev Log: Disambiguate conditional expression for newer GCCs. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100167&r1=100166&r2=100167&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 20:31:24 2010 @@ -1088,8 +1088,8 @@ if (!F->hasFnAttr(Attribute::NoImplicitFloat)) { if (Size >= 16 && (Subtarget->isUnalignedMemAccessFast() || - (DstAlign == 0 || DstAlign >= 16) && - (SrcAlign == 0 || SrcAlign >= 16)) && + ((DstAlign == 0 || DstAlign >= 16) && + (SrcAlign == 0 || SrcAlign >= 16))) && Subtarget->getStackAlignment() >= 16) { if (Subtarget->hasSSE2()) return MVT::v4i32; From dalej at apple.com Thu Apr 1 20:38:09 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 02 Apr 2010 01:38:09 -0000 Subject: [llvm-commits] [llvm] r100168 - in /llvm/trunk/lib: CodeGen/BranchFolding.cpp Target/ARM/ARMBaseInstrInfo.cpp Target/Alpha/AlphaInstrInfo.cpp Target/CellSPU/SPUInstrInfo.cpp Target/MSP430/MSP430InstrInfo.cpp Target/Mips/MipsInstrInfo.cpp Target/PIC16/PIC16InstrInfo.cpp Target/PowerPC/PPCInstrInfo.cpp Target/SystemZ/SystemZInstrInfo.cpp Target/X86/X86InstrInfo.cpp Target/XCore/XCoreInstrInfo.cpp Message-ID: <20100402013809.D15582A6C12C@llvm.org> Author: johannes Date: Thu Apr 1 20:38:09 2010 New Revision: 100168 URL: http://llvm.org/viewvc/llvm-project?rev=100168&view=rev Log: Teach AnalyzeBranch, RemoveBranch and the branch folder to be tolerant of debug info following the branch(es) at the end of a block. Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp Modified: llvm/trunk/lib/CodeGen/BranchFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/BranchFolding.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/BranchFolding.cpp (original) +++ llvm/trunk/lib/CodeGen/BranchFolding.cpp Thu Apr 1 20:38:09 2010 @@ -972,15 +972,21 @@ // MBB1 doesn't, we prefer to fall through into MBB1. This allows us to // optimize branches that branch to either a return block or an assert block // into a fallthrough to the return. - if (MBB1->empty() || MBB2->empty()) return false; + if (IsEmptyBlock(MBB1) || IsEmptyBlock(MBB2)) return false; // If there is a clear successor ordering we make sure that one block // will fall through to the next if (MBB1->isSuccessor(MBB2)) return true; if (MBB2->isSuccessor(MBB1)) return false; - MachineInstr *MBB1I = --MBB1->end(); - MachineInstr *MBB2I = --MBB2->end(); + // Neither block consists entirely of debug info (per IsEmptyBlock check), + // so we needn't test for falling off the beginning here. + MachineBasicBlock::iterator MBB1I = --MBB1->end(); + while (MBB1I->isDebugValue()) + --MBB1I; + MachineBasicBlock::iterator MBB2I = --MBB2->end(); + while (MBB2I->isDebugValue()) + --MBB2I; return MBB2I->getDesc().isCall() && !MBB1I->getDesc().isCall(); } Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -204,7 +204,15 @@ bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -275,6 +283,11 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (!isUncondBranchOpcode(I->getOpcode()) && !isCondBranchOpcode(I->getOpcode())) return 0; Modified: llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Alpha/AlphaInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -301,7 +301,15 @@ bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -362,6 +370,11 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (I->getOpcode() != Alpha::BR && I->getOpcode() != Alpha::COND_BRANCH_I && I->getOpcode() != Alpha::COND_BRANCH_F) Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -450,7 +450,15 @@ bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -513,6 +521,11 @@ if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (!isCondBranch(I) && !isUncondBranch(I)) return 0; Modified: llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/MSP430/MSP430InstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -173,6 +173,8 @@ while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; if (I->getOpcode() != MSP430::JMP && I->getOpcode() != MSP430::JCC) break; @@ -241,6 +243,9 @@ MachineBasicBlock::iterator I = MBB.end(); while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; + // Working from the bottom, when we see a non-terminator // instruction, we're done. if (!isUnpredicatedTerminator(I)) Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -433,7 +433,15 @@ { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -562,6 +570,11 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (I->getOpcode() != Mips::J && GetCondFromBranchOpc(I->getOpcode()) == Mips::COND_INVALID) return 0; Modified: llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16InstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -226,6 +226,11 @@ // Get the terminator instruction. --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return true; + --I; + } // Handle unconditional branches. If the unconditional branch's target is // successor basic block then remove the unconditional branch. if (I->getOpcode() == PIC16::br_uncond && AllowModify) { Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -213,7 +213,15 @@ bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -281,6 +289,11 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (I->getOpcode() != PPC::B && I->getOpcode() != PPC::BCC) return 0; Modified: llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/SystemZ/SystemZInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -424,6 +424,8 @@ MachineBasicBlock::iterator I = MBB.end(); while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; // Working from the bottom, when we see a non-terminator // instruction, we're done. if (!isUnpredicatedTerminator(I)) @@ -500,6 +502,8 @@ while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; if (I->getOpcode() != SystemZ::JMP && getCondFromBranchOpc(I->getOpcode()) == SystemZCC::INVALID) break; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -1686,6 +1686,8 @@ MachineBasicBlock::iterator I = MBB.end(); while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; // Working from the bottom, when we see a non-terminator instruction, we're // done. @@ -1782,6 +1784,8 @@ while (I != MBB.begin()) { --I; + if (I->isDebugValue()) + continue; if (I->getOpcode() != X86::JMP_4 && GetCondFromBranchOpc(I->getOpcode()) == X86::COND_INVALID) break; Modified: llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp?rev=100168&r1=100167&r2=100168&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreInstrInfo.cpp Thu Apr 1 20:38:09 2010 @@ -215,7 +215,15 @@ bool AllowModify) const { // If the block has no terminators, it just falls into the block after it. MachineBasicBlock::iterator I = MBB.end(); - if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) + if (I == MBB.begin()) + return false; + --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return false; + --I; + } + if (!isUnpredicatedTerminator(I)) return false; // Get the last instruction in the block. @@ -326,6 +334,11 @@ MachineBasicBlock::iterator I = MBB.end(); if (I == MBB.begin()) return 0; --I; + while (I->isDebugValue()) { + if (I == MBB.begin()) + return 0; + --I; + } if (!IsBRU(I->getOpcode()) && !IsCondBranch(I->getOpcode())) return 0; From scallanan at apple.com Thu Apr 1 20:48:17 2010 From: scallanan at apple.com (Sean Callanan) Date: Thu, 1 Apr 2010 18:48:17 -0700 Subject: [llvm-commits] Error-handling fixes for the x86 disassembler In-Reply-To: <7FA5E35D-7B50-40D8-AFF7-0BDE4627D1DD@apple.com> References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> <9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com> <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com> <3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com> <7FA5E35D-7B50-40D8-AFF7-0BDE4627D1DD@apple.com> Message-ID: <1A7274D9-B8F0-4F2C-AF09-88DD0D49C65A@apple.com> We talked about this a little off-list, and decided to have the disassembler return an error code in all cases, but only print a debug message on NDEBUG builds. The idea was to use the DEBUG macro and debugs() stream. The attached patch implements these updates. Please let me know what you think. Sean On Mar 31, 2010, at 8:50 PM, Chris Lattner wrote: > On Mar 31, 2010, at 6:13 PM, Sean Callanan wrote: >>> However, I don't see how error messages from the disassembler are going to be very useful. Errors like: >>> >>> Corrupt table! Unknown modrm_type >>> Cannot have Mod = 0b11 and a SIB byte >>> Expected a REG or R/M encoding in fixupReg >>> No modifier but an operand expects one. >>> >>> Are not going to mean anything to anyone. I don't think there is such thing as a useful error message that can come out of a disassembler other than "unrecognized instruction". Given this, I don't see the value in an error reporting api at all here. >> >> I'll just have error() call fprintf(stderr) unless NDEBUG is defined. New patch attached. > > As daniel mentioned, nothing in lib can use printf. > > Why not have this abort if assertions are enabled? Causing a printout to happen (presumably as a debugging aid) does not make any sense if linked into a random app that uses the disassembler. > > -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: x86-disassembler-assert.r4.diff Type: application/octet-stream Size: 28061 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment.obj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/b666ff36/attachment-0001.html From evan.cheng at apple.com Thu Apr 1 21:21:24 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 Apr 2010 02:21:24 -0000 Subject: [llvm-commits] [llvm] r100170 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll Message-ID: <20100402022124.4C4762A6C12C@llvm.org> Author: evancheng Date: Thu Apr 1 21:21:24 2010 New Revision: 100170 URL: http://llvm.org/viewvc/llvm-project?rev=100170&view=rev Log: After trivial coalescing, the MI being visited may have become a copy. Avoid adding it to CSE hash table since copies aren't being considered for CSE and they may be deleted. rdar://7819990 Added: llvm/trunk/test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll 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=100170&r1=100169&r2=100170&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineCSE.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineCSE.cpp Thu Apr 1 21:21:24 2010 @@ -294,8 +294,12 @@ bool FoundCSE = VNT.count(MI); if (!FoundCSE) { // Look for trivial copy coalescing opportunities. - if (PerformTrivialCoalescing(MI, MBB)) + if (PerformTrivialCoalescing(MI, MBB)) { + // After coalescing MI itself may become a copy. + if (isCopy(MI, TII)) + continue; FoundCSE = VNT.count(MI); + } } // FIXME: commute commutable instructions? Added: llvm/trunk/test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll?rev=100170&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll (added) +++ llvm/trunk/test/CodeGen/PowerPC/2010-04-01-MachineCSEBug.ll Thu Apr 1 21:21:24 2010 @@ -0,0 +1,70 @@ +; RUN: llc < %s -mtriple=powerpc-apple-darwin10.0 +; rdar://7819990 + +%0 = type { i32 } +%1 = type { i64 } +%struct.Buffer = type { [1024 x i8], i64, i64, i64 } +%struct.InStream = type { %struct.Buffer, %0, %1, i32*, %struct.InStreamMethods* } +%struct.InStreamMethods = type { void (%struct.InStream*, i8*, i32)*, void (%struct.InStream*, i64)*, i64 (%struct.InStream*)*, void (%struct.InStream*)* } + +define i64 @t(%struct.InStream* %is) nounwind optsize ssp { +entry: + br i1 undef, label %is_read_byte.exit, label %bb.i + +bb.i: ; preds = %entry + br label %is_read_byte.exit + +is_read_byte.exit: ; preds = %bb.i, %entry + br i1 undef, label %is_read_byte.exit22, label %bb.i21 + +bb.i21: ; preds = %is_read_byte.exit + unreachable + +is_read_byte.exit22: ; preds = %is_read_byte.exit + br i1 undef, label %is_read_byte.exit19, label %bb.i18 + +bb.i18: ; preds = %is_read_byte.exit22 + br label %is_read_byte.exit19 + +is_read_byte.exit19: ; preds = %bb.i18, %is_read_byte.exit22 + br i1 undef, label %is_read_byte.exit16, label %bb.i15 + +bb.i15: ; preds = %is_read_byte.exit19 + unreachable + +is_read_byte.exit16: ; preds = %is_read_byte.exit19 + %0 = shl i64 undef, 32 ; [#uses=1] + br i1 undef, label %is_read_byte.exit13, label %bb.i12 + +bb.i12: ; preds = %is_read_byte.exit16 + unreachable + +is_read_byte.exit13: ; preds = %is_read_byte.exit16 + %1 = shl i64 undef, 24 ; [#uses=1] + br i1 undef, label %is_read_byte.exit10, label %bb.i9 + +bb.i9: ; preds = %is_read_byte.exit13 + unreachable + +is_read_byte.exit10: ; preds = %is_read_byte.exit13 + %2 = shl i64 undef, 16 ; [#uses=1] + br i1 undef, label %is_read_byte.exit7, label %bb.i6 + +bb.i6: ; preds = %is_read_byte.exit10 + br label %is_read_byte.exit7 + +is_read_byte.exit7: ; preds = %bb.i6, %is_read_byte.exit10 + %3 = shl i64 undef, 8 ; [#uses=1] + br i1 undef, label %is_read_byte.exit4, label %bb.i3 + +bb.i3: ; preds = %is_read_byte.exit7 + unreachable + +is_read_byte.exit4: ; preds = %is_read_byte.exit7 + %4 = or i64 0, %0 ; [#uses=1] + %5 = or i64 %4, %1 ; [#uses=1] + %6 = or i64 %5, %2 ; [#uses=1] + %7 = or i64 %6, %3 ; [#uses=1] + %8 = or i64 %7, 0 ; [#uses=1] + ret i64 %8 +} From gohman at apple.com Thu Apr 1 22:04:37 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 03:04:37 -0000 Subject: [llvm-commits] [llvm] r100172 - in /llvm/trunk: lib/Target/TargetData.cpp lib/Transforms/IPO/GlobalOpt.cpp test/CodeGen/X86/global-sections.ll test/CodeGen/X86/vec_shuffle-6.ll test/Transforms/GlobalOpt/gv-align.ll Message-ID: <20100402030437.C14FE2A6C12C@llvm.org> Author: djg Date: Thu Apr 1 22:04:37 2010 New Revision: 100172 URL: http://llvm.org/viewvc/llvm-project?rev=100172&view=rev Log: Revert the recent alignment changes. They're broken for -Os because, in particular, they end up aligning strings at 16-byte boundaries, and there's no way for GlobalOpt to check OptForSize. Removed: llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll Modified: llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp llvm/trunk/test/CodeGen/X86/global-sections.ll llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=100172&r1=100171&r2=100172&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Thu Apr 1 22:04:37 2010 @@ -651,7 +651,7 @@ if (Alignment < 16) { // If the global is not external, see if it is large. If so, give it a // larger alignment. - if (getTypeSizeInBits(ElemType) >= 128) + if (getTypeSizeInBits(ElemType) > 128) Alignment = 16; // 16-byte alignment. } } Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=100172&r1=100171&r2=100172&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 1 22:04:37 2010 @@ -1880,7 +1880,6 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) { bool Changed = false; - TargetData *TD = getAnalysisIfAvailable(); for (Module::global_iterator GVI = M.global_begin(), E = M.global_end(); GVI != E; ) { GlobalVariable *GV = GVI++; @@ -1890,16 +1889,11 @@ // Simplify the initializer. if (GV->hasInitializer()) if (ConstantExpr *CE = dyn_cast(GV->getInitializer())) { + TargetData *TD = getAnalysisIfAvailable(); Constant *New = ConstantFoldConstantExpression(CE, TD); if (New && New != CE) GV->setInitializer(New); } - // Refine the alignment value. - if (TD && GV->hasDefinitiveInitializer()) { - unsigned Align = TD->getPreferredAlignment(GV); - if (Align > GV->getAlignment()) - GV->setAlignment(Align); - } // Do more involved optimizations if the global is internal. if (!GV->isConstant() && GV->hasLocalLinkage() && GV->hasInitializer()) Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=100172&r1=100171&r2=100172&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/global-sections.ll (original) +++ llvm/trunk/test/CodeGen/X86/global-sections.ll Thu Apr 1 22:04:37 2010 @@ -113,7 +113,7 @@ ; DARWIN: .globl _G9 ; DARWIN: _G9: -; LINUX: .section .rodata.str4.16,"aMS", at progbits,4 +; LINUX: .section .rodata.str4.4,"aMS", at progbits,4 ; LINUX: .globl G9 ; LINUX:G9 Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll?rev=100172&r1=100171&r2=100172&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll (original) +++ llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Thu Apr 1 22:04:37 2010 @@ -4,7 +4,7 @@ ; RUN: grep movups %t | count 2 target triple = "i686-apple-darwin" - at x = external global [4 x i32] + at x = global [4 x i32] [ i32 1, i32 2, i32 3, i32 4 ] ; <[4 x i32]*> [#uses=4] define <2 x i64> @test1() { %tmp = load i32* getelementptr ([4 x i32]* @x, i32 0, i32 0) ; [#uses=1] Removed: llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll?rev=100171&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll (original) +++ llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll (removed) @@ -1,6 +0,0 @@ -; RUN: opt -globalopt -S < %s | grep {, align 16} - -; Globalopt should refine the alignment for global variables. - -target datalayout = "e-p:64:64:64" - at a = global [4 x i32] [i32 2, i32 3, i32 4, i32 5 ] From clattner at apple.com Thu Apr 1 22:13:59 2010 From: clattner at apple.com (Chris Lattner) Date: Thu, 1 Apr 2010 20:13:59 -0700 Subject: [llvm-commits] Error-handling fixes for the x86 disassembler In-Reply-To: <1A7274D9-B8F0-4F2C-AF09-88DD0D49C65A@apple.com> References: <10C45C23-BCDC-4CA8-8755-954FBC08CB17@apple.com> <9FE6B3AE-503D-41DC-956B-837471A88E85@apple.com> <776D3AA0-92A0-4802-900A-A3F3B6E30470@apple.com> <3DEE1615-9C8E-4D49-87BC-B9B3A93FBDD7@apple.com> <7FA5E35D-7B50-40D8-AFF7-0BDE4627D1DD@apple.com> <1A7274D9-B8F0-4F2C-AF09-88DD0D49C65A@apple.com> Message-ID: <13027EC7-2FDE-4530-8E52-D5DF9DFF9C6B@apple.com> On Apr 1, 2010, at 6:48 PM, Sean Callanan wrote: > We talked about this a little off-list, and decided to have the disassembler return an error code in all cases, but only print a debug message on NDEBUG builds. The idea was to use the DEBUG macro and debugs() stream. > > The attached patch implements these updates. Please let me know what you think. The patch generally looks good to me, remind me again why X86DisassemblerDecoder.c has to be a C file though? - translateInstruction(instr, internalInstr); - return true; + if (translateInstruction(instr, internalInstr)) + return false; + else + return true; This can just be: return !translateInstruction(... However, it looks like translateInstruction can just return a bool instead of 0/-1. If you do this, please use true for error to follow other llvm precedent, and allowing the ! to go away. Likewise for translateRM etc. + if (!(insn.eaBase != EA_BASE_sib && insn.eaBase != EA_BASE_sib64)) { Please apply demorgan's law to simplify the condition. + if (!(stackPos < 8)) { Please simplify. +#ifndef NDEBUG +#define debug(s) do { x86DisassemblerDebug(__FILE__, __LINE__, s); } while (0); +#else +#define debug(s) do { } while (0); +#endif The typical do/while(0) idiom doesn't include the trailing ; in the macro. Otherwise, looks fine, please commit with changes, -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100401/6c03589a/attachment.html From echristo at apple.com Thu Apr 1 23:32:37 2010 From: echristo at apple.com (Eric Christopher) Date: Fri, 02 Apr 2010 04:32:37 -0000 Subject: [llvm-commits] [llvm] r100176 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100402043237.97E922A6C12C@llvm.org> Author: echristo Date: Thu Apr 1 23:32:37 2010 New Revision: 100176 URL: http://llvm.org/viewvc/llvm-project?rev=100176&view=rev Log: Remove FIXME - if there's a better way to do this it isn't here. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100176&r1=100175&r2=100176&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Apr 1 23:32:37 2010 @@ -794,9 +794,6 @@ } // Promote v16i8, v8i16, v4i32 load, select, and, or, xor to v2i64. - // FIXME: This produces lots of inefficiencies in isel since - // we then need notice that most of our operands have been implicitly - // converted to v2i64. for (unsigned i = (unsigned)MVT::v16i8; i != (unsigned)MVT::v2i64; i++) { MVT::SimpleValueType SVT = (MVT::SimpleValueType)i; EVT VT = SVT; From bob.wilson at apple.com Fri Apr 2 00:09:46 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 02 Apr 2010 05:09:46 -0000 Subject: [llvm-commits] [llvm] r100177 - /llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20100402050946.37D022A6C12C@llvm.org> Author: bwilson Date: Fri Apr 2 00:09:46 2010 New Revision: 100177 URL: http://llvm.org/viewvc/llvm-project?rev=100177&view=rev Log: Recommit 100158 now that the buildbots are happy again. Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=100177&r1=100176&r2=100177&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Fri Apr 2 00:09:46 2010 @@ -471,22 +471,27 @@ SmallVector WorkList; WorkList.push_back(PHI); + // Record this PHI. + BasicBlock *BB = PHI->getParent(); + AvailableVals[BB] = PHI; + (*BBMap)[BB]->AvailableVal = PHI; + while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); - BasicBlock *BB = PHI->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal) - return; - - // Record the PHI. - AvailableVals[BB] = PHI; - Info->AvailableVal = PHI; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingVal) continue; - WorkList.push_back(IncomingVal); + PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingPHIVal) continue; + BB = IncomingPHIVal->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal) + continue; + + // Record the PHI and add it to the worklist. + AvailableVals[BB] = IncomingPHIVal; + Info->AvailableVal = IncomingPHIVal; + WorkList.push_back(IncomingPHIVal); } } } @@ -499,21 +504,24 @@ SmallVector WorkList; WorkList.push_back(PHI); + // Clear the tag for this PHI. + (*BBMap)[PHI->getParent()]->PHITag = 0; + while (!WorkList.empty()) { PHI = WorkList.pop_back_val(); - BasicBlock *BB = PHI->getParent(); - BBInfo *Info = (*BBMap)[BB]; - if (!Info || Info->AvailableVal || !Info->PHITag) - continue; - - // Clear the tag. - Info->PHITag = 0; // Iterate through the PHI's incoming values. for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) { - PHINode *IncomingVal = dyn_cast(PHI->getIncomingValue(i)); - if (!IncomingVal) continue; - WorkList.push_back(IncomingVal); + PHINode *IncomingPHIVal = dyn_cast(PHI->getIncomingValue(i)); + if (!IncomingPHIVal) continue; + BasicBlock *BB = IncomingPHIVal->getParent(); + BBInfo *Info = (*BBMap)[BB]; + if (!Info || Info->AvailableVal || !Info->PHITag) + continue; + + // Clear the tag and add the PHI to the worklist. + Info->PHITag = 0; + WorkList.push_back(IncomingPHIVal); } } } From baldrick at free.fr Fri Apr 2 02:19:07 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 09:19:07 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r100149 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <20100401230827.A409D2A6C12C@llvm.org> References: <20100401230827.A409D2A6C12C@llvm.org> Message-ID: <4BB59A6B.2050601@free.fr> Hi Bill, > Set the proper linkage for the ".llvm.eh.catch.all.value" variable. while you are there, maybe you can fix the problem that this variable breaks LTO with multi-language programs. For example, if I compile some C++ then .llvm.eh.catch.all.value is set to null; with Ada it is to set some different Ada value. If I link the bitcode for these two together than the result won't work, either because the Ada value will be used for the C++, or because the C++ value will be used with the Ada. This variable should really be some kind of map from the personality function to the catch-all. Ciao, Duncan. From baldrick at free.fr Fri Apr 2 02:29:28 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 07:29:28 -0000 Subject: [llvm-commits] [dragonegg] r100181 - /dragonegg/trunk/gcc-patches/i386_static.diff Message-ID: <20100402072928.E68C42A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 02:29:28 2010 New Revision: 100181 URL: http://llvm.org/viewvc/llvm-project?rev=100181&view=rev Log: Refresh this patch. Modified: dragonegg/trunk/gcc-patches/i386_static.diff Modified: dragonegg/trunk/gcc-patches/i386_static.diff URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/gcc-patches/i386_static.diff?rev=100181&r1=100180&r2=100181&view=diff ============================================================================== --- dragonegg/trunk/gcc-patches/i386_static.diff (original) +++ dragonegg/trunk/gcc-patches/i386_static.diff Fri Apr 2 02:29:28 2010 @@ -1,8 +1,8 @@ Index: mainline/gcc/config/i386/i386.c =================================================================== ---- mainline.orig/gcc/config/i386/i386.c 2010-02-19 15:06:17.872956905 +0100 -+++ mainline/gcc/config/i386/i386.c 2010-02-19 15:13:17.162961421 +0100 -@@ -4988,7 +4988,8 @@ +--- mainline.orig/gcc/config/i386/i386.c 2010-04-02 09:11:58.733574308 +0200 ++++ mainline/gcc/config/i386/i386.c 2010-04-02 09:29:11.276111437 +0200 +@@ -4992,7 +4992,8 @@ case, we return the original mode and warn ABI change if CUM isn't NULL. */ @@ -12,7 +12,7 @@ type_natural_mode (const_tree type, CUMULATIVE_ARGS *cum) { enum machine_mode mode = TYPE_MODE (type); -@@ -5119,7 +5120,9 @@ +@@ -5123,7 +5124,9 @@ See the x86-64 PS ABI for details. */ @@ -23,7 +23,7 @@ classify_argument (enum machine_mode mode, const_tree type, enum x86_64_reg_class classes[MAX_CLASSES], int bit_offset) { -@@ -5500,7 +5503,9 @@ +@@ -5504,7 +5507,9 @@ /* Examine the argument and return set number of register required in each class. Return 0 iff parameter should be passed in memory. */ @@ -34,7 +34,7 @@ examine_argument (enum machine_mode mode, const_tree type, int in_return, int *int_nregs, int *sse_nregs) { -@@ -6182,7 +6187,8 @@ +@@ -6186,7 +6191,8 @@ /* Return true when TYPE should be 128bit aligned for 32bit argument passing ABI. */ From nicolas.geoffray at gmail.com Fri Apr 2 03:06:53 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Fri, 2 Apr 2010 10:06:53 +0200 Subject: [llvm-commits] [llvm] r100072 - in /llvm/trunk: include/llvm/Support/DebugLoc.h lib/VMCore/DebugLoc.cpp lib/VMCore/LLVMContextImpl.h In-Reply-To: References: Message-ID: Hi Chris, On Fri, Apr 2, 2010 at 12:55 AM, Chris Lattner wrote: > > > Sure, you're welcome to continue doing that with metadata, just don't use > the !dbg tag. > > The problem is that currently, the JIT only returns the !dbg tag to JITEventListeners. Nicolas -Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100402/5ffa8862/attachment.html From baldrick at free.fr Fri Apr 2 03:44:52 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 08:44:52 -0000 Subject: [llvm-commits] [dragonegg] r100182 - /dragonegg/trunk/www/index.html Message-ID: <20100402084452.7E84E2A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 03:44:52 2010 New Revision: 100182 URL: http://llvm.org/viewvc/llvm-project?rev=100182&view=rev Log: Explain more about getting LLVM IR output. Modified: dragonegg/trunk/www/index.html Modified: dragonegg/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/www/index.html?rev=100182&r1=100181&r2=100182&view=diff ============================================================================== --- dragonegg/trunk/www/index.html (original) +++ dragonegg/trunk/www/index.html Fri Apr 2 03:44:52 2010 @@ -67,7 +67,7 @@

DragonEgg in action

-

Here is the result of compiling a simple "hello world" program with gcc-4.5.

+

Here is the result of compiling a simple "hello world" program with gcc-4.5:

 $ gcc hello.c -S -O1 -o -
 	.file	"hello.c"
@@ -90,7 +90,7 @@
   

Adding -fplugin=path/dragonegg.so to the gcc command line causes - the program to be optimized and codegened by LLVM instead.

+ the program to be optimized and codegened by LLVM instead:

 $ gcc hello.c -S -O1 -o - -fplugin=./dragonegg.so
 	.file	"hello.c"
@@ -120,7 +120,10 @@
 	.section	.note.GNU-stack,"", at progbits
   
-

Adding -fplugin-arg-dragonegg-emit-ir causes LLVM IR to be output.

+

Adding -fplugin-arg-dragonegg-emit-ir or -flto causes + LLVM IR to be output (you need to request assembler output, -S, rather + than object code output, -c, since otherwise gcc will pass the LLVM IR + to the system assembler, which will doubtless fail to assemble it):

 $ gcc hello.c -S -O1 -o - -fplugin=./dragonegg.so -fplugin-arg-dragonegg-emit-ir
 ; ModuleID = 'hello.c'




From baldrick at free.fr  Fri Apr  2 04:23:15 2010
From: baldrick at free.fr (Duncan Sands)
Date: Fri, 02 Apr 2010 09:23:15 -0000
Subject: [llvm-commits] [llvm] r100183 - /llvm/trunk/docs/ReleaseNotes.html
Message-ID: <20100402092315.7B47D2A6C12C@llvm.org>

Author: baldrick
Date: Fri Apr  2 04:23:15 2010
New Revision: 100183

URL: http://llvm.org/viewvc/llvm-project?rev=100183&view=rev
Log:
Add notes about dragonegg.

Modified:
    llvm/trunk/docs/ReleaseNotes.html

Modified: llvm/trunk/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.html?rev=100183&r1=100182&r2=100183&view=diff
==============================================================================
--- llvm/trunk/docs/ReleaseNotes.html (original)
+++ llvm/trunk/docs/ReleaseNotes.html Fri Apr  2 04:23:15 2010
@@ -221,15 +221,35 @@
 
 
 
 
 

-The goal of DragonEgg is to make -gcc-4.5 act like llvm-gcc without requiring any gcc modifications whatsoever. -DragonEgg is a shared library (dragonegg.so) -that is loaded by gcc at runtime. It ... +DragonEgg is a port of llvm-gcc to +gcc-4.5. Unlike llvm-gcc, which makes many intrusive changes to the underlying +gcc-4.2 code, dragonegg in theory does not require any gcc-4.5 modifications +whatsoever (currently one small patch is needed). This is thanks to the new +gcc plugin architecture, which +makes it possible to modify the behaviour of gcc at runtime by loading a plugin, +which is nothing more than a dynamic library which conforms to the gcc plugin +interface. DragonEgg is a gcc plugin that causes the LLVM optimizers to be run +instead of the gcc optimizers, and the LLVM code generators instead of the gcc +code generators, just like llvm-gcc. To use it, you add +"-fplugin=path/dragonegg.so" to the gcc-4.5 command line, and gcc-4.5 magically +becomes llvm-gcc-4.5! +

+ +

+DragonEgg is still a work in progress. Currently C works very well, while C++, +Ada and Fortran work fairly well. All other languages either don't work at all, +or only work poorly. For the moment only the x86-32 and x86-64 targets are +supported, and only on linux. +

+ +

+DragonEgg has not yet been released. Once gcc-4.5 has been released, dragonegg +will probably be released as part of the following LLVM release.

From edwintorok at gmail.com Fri Apr 2 08:20:51 2010 From: edwintorok at gmail.com (Torok Edwin) Date: Fri, 02 Apr 2010 13:20:51 -0000 Subject: [llvm-commits] [llvm] r100184 - /llvm/trunk/include/llvm/Support/Allocator.h Message-ID: <20100402132051.8FC8A2A6C12C@llvm.org> Author: edwin Date: Fri Apr 2 08:20:51 2010 New Revision: 100184 URL: http://llvm.org/viewvc/llvm-project?rev=100184&view=rev Log: Fix SpecificBumpPtrAllocator iteration. Need to start from (char*)(Slab+1), and not from (char*)Slab+1. This fixes crashes in Win64 debug mode. Thanks to Nicolas Capens! Modified: llvm/trunk/include/llvm/Support/Allocator.h Modified: llvm/trunk/include/llvm/Support/Allocator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Allocator.h?rev=100184&r1=100183&r2=100184&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/Allocator.h (original) +++ llvm/trunk/include/llvm/Support/Allocator.h Fri Apr 2 08:20:51 2010 @@ -200,7 +200,7 @@ while (Slab) { char *End = Slab == Allocator.CurSlab ? Allocator.CurPtr : (char *)Slab + Slab->Size; - for (char *Ptr = (char*)Slab+1; Ptr < End; Ptr += sizeof(T)) { + for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) { Ptr = Allocator.AlignPtr(Ptr, alignof()); if (Ptr + sizeof(T) <= End) reinterpret_cast(Ptr)->~T(); From gohman at apple.com Fri Apr 2 09:48:32 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 14:48:32 -0000 Subject: [llvm-commits] [llvm] r100186 - in /llvm/trunk: lib/Transforms/Scalar/IndVarSimplify.cpp test/Transforms/IndVarSimplify/dangling-use.ll Message-ID: <20100402144832.0E3342A6C12C@llvm.org> Author: djg Date: Fri Apr 2 09:48:31 2010 New Revision: 100186 URL: http://llvm.org/viewvc/llvm-project?rev=100186&view=rev Log: Manually notify ScalarEvolution before making an operand replacement, since it can't currently observe such changes automatically. Added: llvm/trunk/test/Transforms/IndVarSimplify/dangling-use.ll 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=100186&r1=100185&r2=100186&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Fri Apr 2 09:48:31 2010 @@ -510,6 +510,13 @@ // Now expand it into actual Instructions and patch it into place. Value *NewVal = Rewriter.expandCodeFor(AR, UseTy, InsertPt); + // Inform ScalarEvolution that this value is changing. The change doesn't + // affect its value, but it does potentially affect which use lists the + // value will be on after the replacement, which affects ScalarEvolution's + // ability to walk use lists and drop dangling pointers when a value is + // deleted. + SE->forgetValue(User); + // Patch the new value into place. if (Op->hasName()) NewVal->takeName(Op); Added: llvm/trunk/test/Transforms/IndVarSimplify/dangling-use.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/dangling-use.ll?rev=100186&view=auto ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/dangling-use.ll (added) +++ llvm/trunk/test/Transforms/IndVarSimplify/dangling-use.ll Fri Apr 2 09:48:31 2010 @@ -0,0 +1,41 @@ +; RUN: opt -indvars -disable-output < %s + +target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i8: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-n32" +target triple = "powerpc-apple-darwin11" + +define void @vec_inverse_5_7_vert_loop_copyseparate(i8* %x, i32 %n, i32 %rowbytes) nounwind { +entry: + %tmp1 = sdiv i32 %n, 3 ; [#uses=1] + %tmp2 = sdiv i32 %rowbytes, 5 ; [#uses=2] + br label %bb49 + +bb49: ; preds = %bb48, %entry + %x_addr.0 = phi i8* [ %x, %entry ], [ %tmp481, %bb48 ] ; [#uses=2] + br label %bb10 + +bb10: ; preds = %bb49 + %tmp326 = mul nsw i32 %tmp1, %tmp2 ; [#uses=1] + %tmp351 = getelementptr inbounds i8* %x_addr.0, i32 %tmp326 ; [#uses=1] + br i1 false, label %bb.nph, label %bb48 + +bb.nph: ; preds = %bb10 + br label %bb23 + +bb23: ; preds = %bb28, %bb.nph + %pOriginHi.01 = phi i8* [ %tmp351, %bb.nph ], [ %pOriginHi.0, %bb28 ] ; [#uses=2] + %tmp378 = bitcast i8* %pOriginHi.01 to i8* ; [#uses=1] + store i8* %tmp378, i8** null + %tmp385 = getelementptr inbounds i8* %pOriginHi.01, i32 %tmp2 ; [#uses=1] + br label %bb28 + +bb28: ; preds = %bb23 + %pOriginHi.0 = phi i8* [ %tmp385, %bb23 ] ; [#uses=1] + br i1 false, label %bb23, label %bb28.bb48_crit_edge + +bb28.bb48_crit_edge: ; preds = %bb28 + br label %bb48 + +bb48: ; preds = %bb28.bb48_crit_edge, %bb10 + %tmp481 = getelementptr inbounds i8* %x_addr.0, i32 1 ; [#uses=1] + br label %bb49 +} From gohman at apple.com Fri Apr 2 09:57:50 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 02 Apr 2010 14:57:50 -0000 Subject: [llvm-commits] [llvm] r100187 - /llvm/trunk/include/llvm/Support/SlowOperationInformer.h Message-ID: <20100402145750.19E352A6C12C@llvm.org> Author: djg Date: Fri Apr 2 09:57:49 2010 New Revision: 100187 URL: http://llvm.org/viewvc/llvm-project?rev=100187&view=rev Log: Add an explicit keyword. Modified: llvm/trunk/include/llvm/Support/SlowOperationInformer.h Modified: llvm/trunk/include/llvm/Support/SlowOperationInformer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/SlowOperationInformer.h?rev=100187&r1=100186&r2=100187&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/SlowOperationInformer.h (original) +++ llvm/trunk/include/llvm/Support/SlowOperationInformer.h Fri Apr 2 09:57:49 2010 @@ -41,7 +41,7 @@ SlowOperationInformer(const SlowOperationInformer&); // DO NOT IMPLEMENT void operator=(const SlowOperationInformer&); // DO NOT IMPLEMENT public: - SlowOperationInformer(const std::string &Name); + explicit SlowOperationInformer(const std::string &Name); ~SlowOperationInformer(); /// progress - Clients should periodically call this method when they can From baldrick at free.fr Fri Apr 2 10:57:23 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 15:57:23 -0000 Subject: [llvm-commits] [dragonegg] r100189 - /dragonegg/trunk/README Message-ID: <20100402155723.33F6C2A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 10:57:23 2010 New Revision: 100189 URL: http://llvm.org/viewvc/llvm-project?rev=100189&view=rev Log: Add a note about gcc with --enable-lto requiring libelf. Modified: dragonegg/trunk/README Modified: dragonegg/trunk/README URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/README?rev=100189&r1=100188&r2=100189&view=diff ============================================================================== --- dragonegg/trunk/README (original) +++ dragonegg/trunk/README Fri Apr 2 10:57:23 2010 @@ -19,6 +19,9 @@ Hopefully one day the plugin will work with an unpatched gcc, but for the moment a small patch needs to be applied. Configure gcc with your favorite options and also with --enable-lto. Build gcc and install it somewhere. +If you don't have libelf installed then the build will fail, because gcc's +LTO code makes use of it, see + http://gcc.gnu.org/wiki/LinkTimeOptimization#Building_the_branch Darwin special: the gcc configure script thinks darwin doesn't support dynamic libraries and concludes that plugins won't work. Delete or improve the check. From baldrick at free.fr Fri Apr 2 11:53:24 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 16:53:24 -0000 Subject: [llvm-commits] [dragonegg] r100190 - in /dragonegg/trunk: llvm-convert.cpp llvm-internal.h Message-ID: <20100402165324.53ACB2A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 11:53:24 2010 New Revision: 100190 URL: http://llvm.org/viewvc/llvm-project?rev=100190&view=rev Log: Set up the exception selector. For the moment I'm ignoring all issues related to cleanups. Modified: dragonegg/trunk/llvm-convert.cpp dragonegg/trunk/llvm-internal.h Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=100190&r1=100189&r2=100190&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Apr 2 11:53:24 2010 @@ -257,8 +257,6 @@ AllocaInsertionPoint = 0; - FuncEHException = 0; - FuncEHSelector = 0; FuncEHGetTypeID = 0; assert(TheTreeToLLVM == 0 && "Reentering function creation?"); @@ -1839,12 +1837,8 @@ /// CreateExceptionValues - Create values used internally by exception handling. void TreeToLLVM::CreateExceptionValues() { // Check to see if the exception values have been constructed. - if (FuncEHException) return; + if (FuncEHGetTypeID) return; - FuncEHException = Intrinsic::getDeclaration(TheModule, - Intrinsic::eh_exception); - FuncEHSelector = Intrinsic::getDeclaration(TheModule, - Intrinsic::eh_selector); FuncEHGetTypeID = Intrinsic::getDeclaration(TheModule, Intrinsic::eh_typeid_for); } @@ -1865,14 +1859,28 @@ return ExceptionPtr; } -/// AddHandler - Append the given region to a vector of exception handlers. -/// A callback passed to foreach_reachable_handler. -//FIXMEstatic void AddHandler (eh_region region, void *data) { -//FIXME ((std::vector *)data)->push_back(region); -//FIXME} +/// getExceptionFilter - Return the local holding the filter value for the +/// given exception handling region, creating it if necessary. +AllocaInst *TreeToLLVM::getExceptionFilter(unsigned RegionNo) { + if (RegionNo >= ExceptionFilters.size()) + ExceptionFilters.resize(RegionNo + 1, 0); + + AllocaInst *&ExceptionFilter = ExceptionFilters[RegionNo]; + + if (!ExceptionFilter) { + ExceptionFilter = CreateTemporary(Type::getInt32PtrTy(Context)); + ExceptionFilter->setName("filt_tmp"); + } + + return ExceptionFilter; +} /// EmitLandingPads - Emit EH landing pads. void TreeToLLVM::EmitLandingPads() { + // If there are no invokes then there is nothing to do. + if (Invokes.empty()) + return; + // If a GCC landing pad is shared by several exception handling regions, or if // there is a normal edge to it, then create an LLVM landing pad for each eh // region. Calls to eh.exception and eh.selector will be placed in the LLVM @@ -1947,8 +1955,11 @@ // handling region at the start of the corresponding landing pad. At this // point each exception handling region has its own landing pad, which is // only reachable via the unwind edges of the region's invokes. -//FIXME std::vector Args; -//FIXME std::vector Handlers; + std::vector Args; + Function *EHException = Intrinsic::getDeclaration(TheModule, + Intrinsic::eh_exception); + Function *EHSelector = Intrinsic::getDeclaration(TheModule, + Intrinsic::eh_selector); for (unsigned RegionNo = 1; RegionNo < Invokes.size(); ++RegionNo){ // Get the list of invokes for this exception handling region. SmallVector &InvokesForRegion = Invokes[RegionNo]; @@ -1956,8 +1967,6 @@ if (InvokesForRegion.empty()) continue; - CreateExceptionValues(); - // All of the invokes unwind to the same basic block: the landing pad. BasicBlock *LPad = InvokesForRegion[0]->getUnwindDest(); @@ -1965,64 +1974,69 @@ Builder.SetInsertPoint(LPad, LPad->getFirstNonPHI()); // Fetch the exception pointer. - Value *ExcPtr = Builder.CreateCall(FuncEHException, "exc_ptr"); + Value *ExcPtr = Builder.CreateCall(EHException, "exc_ptr"); // Store it if made use of elsewhere. if (RegionNo < ExceptionPtrs.size() && ExceptionPtrs[RegionNo]) Builder.CreateStore(ExcPtr, ExceptionPtrs[RegionNo]); -//FIXME // Fetch and store the exception selector. -//FIXME -//FIXME // The exception and the personality function. -//FIXME Args.push_back(ExcPtr); -//FIXME -//FIXME assert(llvm_eh_personality_libfunc -//FIXME && "no exception handling personality function!"); -//FIXME Args.push_back(Builder.CreateBitCast(DECL_LOCAL(llvm_eh_personality_libfunc), -//FIXME Type::getInt8PtrTy(Context))); -//FIXME -//FIXME // Add selections for each handler. -//FIXME foreach_reachable_handler(i, false, false, AddHandler, &Handlers); -//FIXME -//FIXME for (std::vector::iterator I = Handlers.begin(), -//FIXME E = Handlers.end(); I != E; ++I) { -//FIXME eh_region region = *I; -//FIXME -//FIXME // Create a post landing pad for the handler. -//FIXME getPostPad(get_eh_region_number(region)); -//FIXME -//FIXME int RegionKind = classify_eh_handler(region); -//FIXME if (RegionKind < 0) { -//FIXME // Filter - note the length. -//FIXME tree TypeList = get_eh_type_list(region); -//FIXME unsigned Length = list_length(TypeList); -//FIXME Args.reserve(Args.size() + Length + 1); -//FIXME Args.push_back(ConstantInt::get(Type::getInt32Ty, Length + 1)); -//FIXME -//FIXME // Add the type infos. -//FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { -//FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(EmitRegister(TType)); -//FIXME } -//FIXME } else if (RegionKind > 0) { -//FIXME // Catch. -//FIXME tree TypeList = get_eh_type_list(region); -//FIXME -//FIXME if (!TypeList) { -//FIXME // Catch-all - push a null pointer. -//FIXME Args.push_back( -//FIXME Constant::getNullValue(Type::getInt8PtrTy(Context)) -//FIXME ); -//FIXME } else { -//FIXME // Add the type infos. -//FIXME for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { -//FIXME tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); -//FIXME Args.push_back(EmitRegister(TType)); -//FIXME } -//FIXME } -//FIXME } -//FIXME } -//FIXME + // Fetch and store the exception selector. + + // The first argument is the exception pointer. + Args.push_back(ExcPtr); + + // It is followed by the personality function. + tree personality = DECL_FUNCTION_PERSONALITY(FnDecl); + if (!personality) { + assert(function_needs_eh_personality(cfun) == eh_personality_any && + "No exception handling personality!"); + personality = lang_hooks.eh_personality(); + } + Args.push_back(Builder.CreateBitCast(DECL_LLVM(personality), + Type::getInt8PtrTy(Context))); + + for (eh_region r = get_eh_region_from_number(RegionNo); r; r = r->outer) + switch (r->type) { + case ERT_ALLOWED_EXCEPTIONS: { + // Filter - note the length. + tree TypeList = r->u.allowed.type_list; + unsigned Length = list_length(TypeList); + Args.reserve(Args.size() + Length + 1); + Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), Length + 1)); + + // Add the type infos. + for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { + tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); + Args.push_back(EmitRegister(TType)); + } + } + case ERT_CLEANUP: + break; + case ERT_MUST_NOT_THROW: + // Same as a zero-length filter. + Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), 1)); + break; + case ERT_TRY: { + // Catches. + + for (eh_catch c = r->u.eh_try.first_catch; c ; c = c->next_catch) { + tree TypeList = c->type_list; + + if (!TypeList) + // Catch-all - push a null pointer. + Args.push_back( + Constant::getNullValue(Type::getInt8PtrTy(Context)) + ); + else + // Add the type infos. + for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { + tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); + Args.push_back(EmitRegister(TType)); + } + } + } + } + //FIXME if (can_throw_external_1(i, false, false)) { //FIXME // Some exceptions from this region may not be caught by any handler. //FIXME // Since invokes are required to branch to the unwind label no matter @@ -2045,14 +2059,16 @@ //FIXME } //FIXME Args.push_back(CatchAll); //FIXME } -//FIXME -//FIXME // Emit the selector call. -//FIXME Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(), -//FIXME "eh_select"); -//FIXME Builder.CreateStore(Select, ExceptionSelectorValue); -//FIXME Handlers.clear(); -//FIXME Args.clear(); + // Emit the selector call. + Value *Filter = Builder.CreateCall(EHSelector, Args.begin(), Args.end(), + "filter"); + + // Store it if made use of elsewhere. + if (RegionNo < ExceptionFilters.size() && ExceptionFilters[RegionNo]) + Builder.CreateStore(Filter, ExceptionFilters[RegionNo]); + + Args.clear(); } Invokes.clear(); Modified: dragonegg/trunk/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-internal.h?rev=100190&r1=100189&r2=100190&view=diff ============================================================================== --- dragonegg/trunk/llvm-internal.h (original) +++ dragonegg/trunk/llvm-internal.h Fri Apr 2 11:53:24 2010 @@ -430,11 +430,8 @@ /// ExceptionPtrs - The local holding the exception pointer for a EH region. SmallVector ExceptionPtrs; - /// FuncEHException - Function used to receive the exception. - Function *FuncEHException; - - /// FuncEHSelector - Function used to receive the exception selector. - Function *FuncEHSelector; + /// ExceptionFilters - The local holding the filter value for a EH region. + SmallVector ExceptionFilters; /// FuncEHGetTypeID - Function used to return type id for give typeinfo. Function *FuncEHGetTypeID; @@ -572,6 +569,10 @@ /// given exception handling region, creating it if necessary. AllocaInst *getExceptionPtr(unsigned RegionNo); + /// getExceptionFilter - Return the local holding the filter value for the + /// given exception handling region, creating it if necessary. + AllocaInst *getExceptionFilter(unsigned RegionNo); + private: void EmitAutomaticVariableDecl(tree_node *decl); From wangmp at apple.com Fri Apr 2 11:58:17 2010 From: wangmp at apple.com (Mon Ping Wang) Date: Fri, 2 Apr 2010 09:58:17 -0700 Subject: [llvm-commits] Patch: address space support for memcpy/memmove/memset In-Reply-To: <2757EFD3-4A6B-4F49-9329-35B2BE1679EF@apple.com> References: <89548B9C-55E6-40DF-8E7D-9B1C30162EA4@apple.com> <2757EFD3-4A6B-4F49-9329-35B2BE1679EF@apple.com> Message-ID: <2EA75B81-8DC4-4FB1-A215-9770E06C5A59@apple.com> Hi Eric, In the tests, I see Bitcode/memcpy.ll plus a few other tests. Should be there something more than that? Thanks, -- Mon Ping On Mar 30, 2010, at 3:12 PM, Eric Christopher wrote: > > On Mar 24, 2010, at 4:01 PM, Mon Ping Wang wrote: > >> Please let me know if I miss something. > > Could you also please add a testcase for the AutoUpgrade parts you added? > > Thanks. > > -eric From wangmp at apple.com Fri Apr 2 13:04:16 2010 From: wangmp at apple.com (Mon P Wang) Date: Fri, 02 Apr 2010 18:04:16 -0000 Subject: [llvm-commits] [llvm] r100191 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Bitcode/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ Message-ID: <20100402180416.BF9932A6C12C@llvm.org> Author: wangmp Date: Fri Apr 2 13:04:15 2010 New Revision: 100191 URL: http://llvm.org/viewvc/llvm-project?rev=100191&view=rev Log: Reapply address space patch after fixing an issue in MemCopyOptimizer. Added support for address spaces and added a isVolatile field to memcpy, memmove, and memset, e.g., llvm.memcpy.i32(i8*, i8*, i32, i32) -> llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/Analysis/BasicAA/modref.ll llvm/trunk/test/Bitcode/memcpy.ll llvm/trunk/test/Transforms/InstCombine/memset_chk.ll llvm/trunk/test/Transforms/InstCombine/objsize.ll llvm/trunk/test/Transforms/MemCpyOpt/align.ll llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Apr 2 13:04:15 2010 @@ -534,17 +534,17 @@ SDValue getStackArgumentTokenFactor(SDValue Chain); SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool AlwaysInline, + SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, + SDValue Size, unsigned Align, bool isVol, const Value *DstSV, uint64_t DstOSVff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, + SDValue Size, unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff); /// getSetCC - Helper function to make it easier to build SetCC's if you just Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Apr 2 13:04:15 2010 @@ -133,6 +133,13 @@ return getAlignmentCst()->getZExtValue(); } + ConstantInt *getVolatileCst() const { + return cast(const_cast(getOperand(5))); + } + bool isVolatile() const { + return getVolatileCst()->getZExtValue() != 0; + } + /// getDest - This is just like getRawDest, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. @@ -155,7 +162,11 @@ void setAlignment(Constant* A) { setOperand(4, A); } - + + void setVolatile(Constant* V) { + setOperand(5, V); + } + const Type *getAlignmentType() const { return getOperand(4)->getType(); } Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Fri Apr 2 13:04:15 2010 @@ -224,16 +224,16 @@ // def int_memcpy : Intrinsic<[], - [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memmove : Intrinsic<[], - [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memset : Intrinsic<[], - [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, - llvm_i32_ty], + [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, + llvm_i32_ty, llvm_i1_ty], [IntrWriteArgMem, NoCapture<0>]>; // These functions do not actually read memory, but they are sensitive to the Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Apr 2 13:04:15 2010 @@ -917,6 +917,11 @@ Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; return Insert(CallInst::Create(Callee, Args, Args+4), Name); } + CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, + Value *Arg4, Value *Arg5, const Twine &Name = "") { + Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; + return Insert(CallInst::Create(Callee, Args, Args+5), Name); + } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 13:04:15 2010 @@ -1187,7 +1187,7 @@ EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { @@ -1204,7 +1204,7 @@ EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { return SDValue(); @@ -1220,7 +1220,7 @@ EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, + SDValue Op3, unsigned Align, bool isVolatile, const Value *DstSV, uint64_t DstOff) { return SDValue(); } Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Fri Apr 2 13:04:15 2010 @@ -46,8 +46,8 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD); /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src @@ -57,8 +57,8 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD); /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. @@ -70,8 +70,8 @@ const TargetData *TD); /// EmitMemSet - Emit a call to the memset function - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, - const TargetData *TD); + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, + IRBuilder<> &B, const TargetData *TD); /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' /// (e.g. 'floor'). This function is known to take a single of type matching Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 13:04:15 2010 @@ -3263,7 +3263,8 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool AlwaysInline, + unsigned Align, bool isVol, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3319,7 +3320,7 @@ Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, Align); + DstSV, DstSVOff + DstOff, isVol, false, Align); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3330,11 +3331,11 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, false, false, + SrcSV, SrcSVOff + SrcOff, VT, isVol, false, MinAlign(SrcAlign, SrcOff)); Store = DAG.getTruncStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, VT, false, false, + DstSV, DstSVOff + DstOff, VT, isVol, false, Align); } OutChains.push_back(Store); @@ -3349,7 +3350,8 @@ static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align,bool AlwaysInline, + unsigned Align, bool isVol, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3397,7 +3399,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); + SrcSV, SrcSVOff + SrcOff, isVol, false, SrcAlign); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3412,7 +3414,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, Align); + DstSV, DstSVOff + DstOff, isVol, false, Align); OutChains.push_back(Store); DstOff += VTSize; } @@ -3424,7 +3426,7 @@ static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3463,7 +3465,7 @@ SDValue Value = getMemsetValue(Src, VT, DAG, dl); SDValue Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, false, false, 0); + DstSV, DstSVOff + DstOff, isVol, false, 0); OutChains.push_back(Store); DstOff += VTSize; } @@ -3474,7 +3476,7 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool AlwaysInline, + unsigned Align, bool isVol, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3488,7 +3490,7 @@ SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(),Align, - false, DstSV, DstSVOff, SrcSV, SrcSVOff); + isVol, false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3497,7 +3499,7 @@ // code. If the target chooses to do this, this is the next best. SDValue Result = TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, - AlwaysInline, + isVol, AlwaysInline, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; @@ -3507,11 +3509,12 @@ if (AlwaysInline) { assert(ConstantSize && "AlwaysInline requires a constant size!"); return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, true, - DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, isVol, + true, DstSV, DstSVOff, SrcSV, SrcSVOff); } // Emit a library call. + assert(!isVol && "library memcpy does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3532,7 +3535,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3546,8 +3549,8 @@ SDValue Result = getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), - Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, isVol, + false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3555,12 +3558,13 @@ // Then check to see if we should lower the memmove with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; // Emit a library call. + assert(!isVol && "library memmove does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3581,7 +3585,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, + unsigned Align, bool isVol, const Value *DstSV, uint64_t DstSVOff) { // Check to see if we should lower the memset to stores first. @@ -3594,7 +3598,7 @@ SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), - Align, DstSV, DstSVOff); + Align, isVol, DstSV, DstSVOff); if (Result.getNode()) return Result; } @@ -3602,12 +3606,13 @@ // Then check to see if we should lower the memset with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, DstSV, DstSVOff); if (Result.getNode()) return Result; // Emit a library call. + assert(!isVol && "library memset does not support volatile"); const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Apr 2 13:04:15 2010 @@ -3731,28 +3731,50 @@ case Intrinsic::longjmp: return "_longjmp"+!TLI.usesUnderscoreLongJmp(); case Intrinsic::memcpy: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + cast(I.getOperand(2)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, + bool isVol = cast(I.getOperand(5))->getZExtValue(); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } case Intrinsic::memset: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, + bool isVol = cast(I.getOperand(5))->getZExtValue(); + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, I.getOperand(1), 0)); return 0; } case Intrinsic::memmove: { + // Assert for address < 256 since we support only user defined address + // spaces. + assert(cast(I.getOperand(1)->getType())->getAddressSpace() + < 256 && + cast(I.getOperand(2)->getType())->getAddressSpace() + < 256 && + "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); + bool isVol = cast(I.getOperand(5))->getZExtValue(); // If the source and destination are known to not be aliases, we can // lower memmove as memcpy. @@ -3761,12 +3783,12 @@ Size = C->getZExtValue(); if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == AliasAnalysis::NoAlias) { - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, - I.getOperand(1), 0, I.getOperand(2), 0)); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Apr 2 13:04:15 2010 @@ -861,7 +861,8 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*AlwaysInline=*/false, NULL, 0, NULL, 0); + /*isVolatile=*/false, /*AlwaysInline=*/false, + NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack. @@ -2053,7 +2054,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ // Do repeated 4-byte loads and stores. To be improved. @@ -2089,7 +2090,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff, false, false, 0); + SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -2100,7 +2101,7 @@ TFOps[i] = DAG.getStore(Chain, dl, Loads[i], DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff, false, false, 0); + DstSV, DstSVOff + DstOff, isVolatile, false, 0); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Apr 2 13:04:15 2010 @@ -305,7 +305,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue LowerCallResult(SDValue Chain, SDValue InFlag, Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Apr 2 13:04:15 2010 @@ -2392,7 +2392,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - false, NULL, 0, NULL, 0); + false, false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 2 13:04:15 2010 @@ -1433,7 +1433,8 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*AlwaysInline=*/true, NULL, 0, NULL, 0); + /*isVolatile*/false, /*AlwaysInline=*/true, + NULL, 0, NULL, 0); } /// IsTailCallConvention - Return true if the calling convention is one that @@ -6550,6 +6551,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, + bool isVolatile, const Value *DstSV, uint64_t DstSVOff) { ConstantSDNode *ConstantSize = dyn_cast(Size); @@ -6678,7 +6680,7 @@ DAG.getConstant(Offset, AddrVT)), Src, DAG.getConstant(BytesLeft, SizeVT), - Align, DstSV, DstSVOff + Offset); + Align, isVolatile, DstSV, DstSVOff + Offset); } // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. @@ -6689,7 +6691,7 @@ X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { // This requires the copy size to be a constant, preferrably @@ -6748,7 +6750,7 @@ DAG.getNode(ISD::ADD, dl, SrcVT, Src, DAG.getConstant(Offset, SrcVT)), DAG.getConstant(BytesLeft, SizeVT), - Align, AlwaysInline, + Align, isVolatile, AlwaysInline, DstSV, DstSVOff + Offset, SrcSV, SrcSVOff + Offset)); } @@ -6831,8 +6833,8 @@ DebugLoc dl = Op.getDebugLoc(); return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, - DAG.getIntPtrConstant(24), 8, false, - DstSV, 0, SrcSV, 0); + DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, + false, DstSV, 0, SrcSV, 0); } SDValue Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Apr 2 13:04:15 2010 @@ -737,12 +737,13 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, + bool isVolatile, const Value *DstSV, uint64_t DstSVOff); SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool AlwaysInline, + bool isVolatile, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); @@ -752,7 +753,7 @@ /// block, the number of args, and whether or not the second arg is /// in memory or not. MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, - unsigned argNum, bool inMem) const; + unsigned argNum, bool inMem) const; /// Utility function to emit atomic bitwise operations (and, or, xor). /// It takes the bitwise instruction to expand, the associated machine basic Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Apr 2 13:04:15 2010 @@ -1443,7 +1443,7 @@ return DAG.getMemmove(Chain, dl, ST->getBasePtr(), LD->getBasePtr(), DAG.getConstant(StoreBits/8, MVT::i32), - Alignment, ST->getSrcValue(), + Alignment, false, ST->getSrcValue(), ST->getSrcValueOffset(), LD->getSrcValue(), LD->getSrcValueOffset()); } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Apr 2 13:04:15 2010 @@ -136,8 +136,14 @@ return 0; // If not 1/2/4/8 bytes, exit. // Use an integer load+store unless we can find something better. - Type *NewPtrTy = - PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); + unsigned SrcAddrSp = + cast(MI->getOperand(2)->getType())->getAddressSpace(); + unsigned DstAddrSp = + cast(MI->getOperand(1)->getType())->getAddressSpace(); + + const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); + Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); + Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); // Memcpy forces the use of i8* for the source and destination. That means // that if you're using memcpy to move one double around, you'll get a cast @@ -167,8 +173,10 @@ break; } - if (SrcETy->isSingleValueType()) - NewPtrTy = PointerType::getUnqual(SrcETy); + if (SrcETy->isSingleValueType()) { + NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); + NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); + } } } @@ -178,11 +186,12 @@ SrcAlign = std::max(SrcAlign, CopyAlign); DstAlign = std::max(DstAlign, CopyAlign); - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); - Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); + Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); InsertNewInstBefore(L, *MI); - InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); + InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), + *MI); // Set the size of the copy to 0, it will be deleted on the next iteration. MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); @@ -275,10 +284,11 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - const Type *Tys[1]; - Tys[0] = CI.getOperand(3)->getType(); + const Type *Tys[3] = { CI.getOperand(1)->getType(), + CI.getOperand(2)->getType(), + CI.getOperand(3)->getType() }; CI.setOperand(0, - Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); + Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); Changed = true; } } Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri Apr 2 13:04:15 2010 @@ -413,7 +413,6 @@ // interesting as a small compile-time optimization. Ranges.addStore(0, SI); - Function *MemSetF = 0; // Now that we have full information about ranges, loop over the ranges and // emit memset's for anything big enough to be worthwhile. @@ -433,29 +432,40 @@ // memset block. This ensure that the memset is dominated by any addressing // instruction needed by the start of the block. BasicBlock::iterator InsertPt = BI; - - if (MemSetF == 0) { - const Type *Ty = Type::getInt64Ty(Context); - MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); - } - + // Get the starting pointer of the block. StartPtr = Range.StartPtr; - + + // Determine alignment + unsigned Alignment = Range.Alignment; + if (Alignment == 0) { + const Type *EltType = + cast(StartPtr->getType())->getElementType(); + Alignment = TD->getABITypeAlignment(EltType); + } + // Cast the start ptr to be i8* as memset requires. - const Type *i8Ptr = Type::getInt8PtrTy(Context); - if (StartPtr->getType() != i8Ptr) + const PointerType* StartPTy = cast(StartPtr->getType()); + const PointerType *i8Ptr = Type::getInt8PtrTy(Context, + StartPTy->getAddressSpace()); + if (StartPTy!= i8Ptr) StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), InsertPt); - + Value *Ops[] = { StartPtr, ByteVal, // Start, value // size ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), // align - ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) + ConstantInt::get(Type::getInt32Ty(Context), Alignment), + // volatile + ConstantInt::get(Type::getInt1Ty(Context), 0), }; - Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); + const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; + + Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); + + Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); DEBUG(dbgs() << "Replace stores:\n"; for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) dbgs() << *Range.TheStores[i]; @@ -680,16 +690,19 @@ return false; // If all checks passed, then we can transform these memcpy's - const Type *Ty = M->getLength()->getType(); + const Type *ArgTys[3] = { M->getRawDest()->getType(), + MDep->getRawSource()->getType(), + M->getLength()->getType() }; Function *MemCpyFun = Intrinsic::getDeclaration( M->getParent()->getParent()->getParent(), - M->getIntrinsicID(), &Ty, 1); + M->getIntrinsicID(), ArgTys, 3); - Value *Args[4] = { - M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() + Value *Args[5] = { + M->getRawDest(), MDep->getRawSource(), M->getLength(), + M->getAlignmentCst(), M->getVolatileCst() }; - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); // If C and M don't interfere, then this is a valid transformation. If they @@ -728,8 +741,10 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - const Type *Ty = M->getLength()->getType(); - M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); + const Type *ArgTys[3] = { M->getRawDest()->getType(), + M->getRawSource()->getType(), + M->getLength()->getType() }; + M->setOperand(0,Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); // MemDep may have over conservative information about this instruction, just // conservatively flush it from the cache. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Apr 2 13:04:15 2010 @@ -858,8 +858,17 @@ EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); // Cast the other pointer (if we have one) to BytePtrTy. - if (OtherElt && OtherElt->getType() != BytePtrTy) - OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); + if (OtherElt && OtherElt->getType() != BytePtrTy) { + // Preserve address space of OtherElt + const PointerType* OtherPTy = cast(OtherElt->getType()); + const PointerType* PTy = cast(BytePtrTy); + if (OtherPTy->getElementType() != PTy->getElementType()) { + Type *NewOtherPTy = PointerType::get(PTy->getElementType(), + OtherPTy->getAddressSpace()); + OtherElt = new BitCastInst(OtherElt, NewOtherPTy, + OtherElt->getNameStr(), MI); + } + } unsigned EltSize = TD->getTypeAllocSize(EltTy); @@ -870,17 +879,28 @@ SROADest ? OtherElt : EltPtr, // Src ptr ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size // Align - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), + MI->getVolatileCst() }; - CallInst::Create(TheFn, Ops, Ops + 4, "", MI); + // In case we fold the address space overloaded memcpy of A to B + // with memcpy of B to C, change the function to be a memcpy of A to C. + const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), + Ops[2]->getType() }; + Module *M = MI->getParent()->getParent()->getParent(); + TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); + CallInst::Create(TheFn, Ops, Ops + 5, "", MI); } else { assert(isa(MI)); Value *Ops[] = { EltPtr, MI->getOperand(2), // Dest, Value, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size - Zero // Align + Zero, // Align + ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile }; - CallInst::Create(TheFn, Ops, Ops + 4, "", MI); + const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; + Module *M = MI->getParent()->getParent()->getParent(); + TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); + CallInst::Create(TheFn, Ops, Ops + 5, "", MI); } } DeadInsts.push_back(MI); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Apr 2 13:04:15 2010 @@ -142,7 +142,8 @@ // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. EmitMemCpy(CpyDst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), + 1, false, B, TD); } }; @@ -383,7 +384,8 @@ CI->getOperand(3), B, TD); else EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), + 1, false, B, TD); return Dst; } }; @@ -411,8 +413,8 @@ if (SrcLen == 0) { // strncpy(x, "", y) -> memset(x, '\0', y, 1) - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, - B, TD); + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), + LenOp, false, B, TD); return Dst; } @@ -432,7 +434,8 @@ // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), + 1, false, B, TD); return Dst; } @@ -593,7 +596,7 @@ // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, B, TD); + CI->getOperand(3), 1, false, B, TD); return CI->getOperand(1); } }; @@ -615,7 +618,7 @@ // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) EmitMemMove(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, B, TD); + CI->getOperand(3), 1, false, B, TD); return CI->getOperand(1); } }; @@ -637,8 +640,8 @@ // memset(p, v, n) -> llvm.memset(p, v, n, 1) Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), - false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); + false); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); return CI->getOperand(1); } }; @@ -999,7 +1002,7 @@ // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. ConstantInt::get(TD->getIntPtrType(*Context), - FormatStr.size()+1), 1, B, TD); + FormatStr.size()+1), 1, false, B, TD); return ConstantInt::get(CI->getType(), FormatStr.size()); } @@ -1013,11 +1016,11 @@ // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), - Type::getInt8Ty(*Context), "char"); + Type::getInt8Ty(*Context), "char"); Value *Ptr = CastToCStr(CI->getOperand(1), B); B.CreateStore(V, Ptr); Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), - "nul"); + "nul"); B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); return ConstantInt::get(CI->getType(), 1); @@ -1034,7 +1037,7 @@ Value *IncLen = B.CreateAdd(Len, ConstantInt::get(Len->getType(), 1), "leninc"); - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); // The sprintf result is the unincremented number of bytes in the string. return B.CreateIntCast(Len, CI->getType(), false); Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Fri Apr 2 13:04:15 2010 @@ -109,15 +109,16 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always /// expects that Len has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); - const Type *Ty = Len->getType(); - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); + const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); - return B.CreateCall4(MemCpy, Dst, Src, Len, - ConstantInt::get(B.getInt32Ty(), Align)); + return B.CreateCall5(MemCpy, Dst, Src, Len, + ConstantInt::get(B.getInt32Ty(), Align), + ConstantInt::get(B.getInt1Ty(), isVolatile)); } /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. @@ -146,16 +147,18 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, - unsigned Align, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, + bool isVolatile, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); LLVMContext &Context = B.GetInsertBlock()->getContext(); - const Type *Ty = TD->getIntPtrType(Context); - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); + const Type *ArgTys[3] = { Dst->getType(), Src->getType(), + TD->getIntPtrType(Context) }; + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); Value *A = ConstantInt::get(B.getInt32Ty(), Align); - return B.CreateCall4(MemMove, Dst, Src, Len, A); + Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); + return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); } /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is @@ -206,15 +209,15 @@ } /// EmitMemSet - Emit a call to the memset function -Value *llvm::EmitMemSet(Value *Dst, Value *Val, - Value *Len, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, + IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Intrinsic::ID IID = Intrinsic::memset; - const Type *Tys[1]; - Tys[0] = Len->getType(); - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); + const Type *Tys[2] = { Dst->getType(), Len->getType() }; + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); Value *Align = ConstantInt::get(B.getInt32Ty(), 1); - return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); + Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); + return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); } /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. @@ -381,7 +384,7 @@ if (Name == "__memcpy_chk") { if (isFoldable(4, 3, false)) { EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, B, TD); + 1, false, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -396,7 +399,7 @@ if (Name == "__memmove_chk") { if (isFoldable(4, 3, false)) { EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, B, TD); + 1, false, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -407,7 +410,7 @@ if (isFoldable(4, 3, false)) { Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); replaceCall(CI->getOperand(1)); return true; } Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Apr 2 13:04:15 2010 @@ -297,10 +297,10 @@ I->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - const Type *Tys[] = { Type::getInt64Ty(Context) }; + const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, - Tys, 1); + Tys, 3); Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); @@ -309,17 +309,18 @@ Size = ConstantExpr::getSizeOf(AggTy); else Size = ConstantInt::get(Type::getInt64Ty(Context), - TD->getTypeStoreSize(AggTy)); + TD->getTypeStoreSize(AggTy)); // Always generate a memcpy of alignment 1 here because we don't know // the alignment of the src pointer. Other optimizations can infer // better alignment. Value *CallArgs[] = { DestCast, SrcCast, Size, - ConstantInt::get(Type::getInt32Ty(Context), 1) + ConstantInt::get(Type::getInt32Ty(Context), 1), + ConstantInt::get(Type::getInt1Ty(Context), 0) }; CallInst *TheMemCpy = - CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); + CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); // If we have a call graph, update it. if (CG) { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Apr 2 13:04:15 2010 @@ -145,6 +145,54 @@ } break; + case 'm': { + // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the + // new format that allows overloading the pointer for different address + // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) + const char* NewFnName = NULL; + if (Name.compare(5,8,"memcpy.i",8) == 0) { + if (Name[13] == '8') + NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; + else if (Name.compare(13,2,"16") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; + else if (Name.compare(13,2,"32") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; + else if (Name.compare(13,2,"64") == 0) + NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; + } else if (Name.compare(5,9,"memmove.i",9) == 0) { + if (Name[14] == '8') + NewFnName = "llvm.memmove.p0i8.p0i8.i8"; + else if (Name.compare(14,2,"16") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i16"; + else if (Name.compare(14,2,"32") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i32"; + else if (Name.compare(14,2,"64") == 0) + NewFnName = "llvm.memmove.p0i8.p0i8.i64"; + } + else if (Name.compare(5,8,"memset.i",8) == 0) { + if (Name[13] == '8') + NewFnName = "llvm.memset.p0i8.i8"; + else if (Name.compare(13,2,"16") == 0) + NewFnName = "llvm.memset.p0i8.i16"; + else if (Name.compare(13,2,"32") == 0) + NewFnName = "llvm.memset.p0i8.i32"; + else if (Name.compare(13,2,"64") == 0) + NewFnName = "llvm.memset.p0i8.i64"; + } + if (NewFnName) { + const FunctionType *FTy = F->getFunctionType(); + NewFn = cast(M->getOrInsertFunction(NewFnName, + FTy->getReturnType(), + FTy->getParamType(0), + FTy->getParamType(1), + FTy->getParamType(2), + FTy->getParamType(3), + Type::getInt1Ty(F->getContext()), + (Type *)0)); + return true; + } + break; + } case 'p': // This upgrades the llvm.part.select overloaded intrinsic names to only // use one type specifier in the name. We only care about the old format @@ -472,6 +520,28 @@ CI->eraseFromParent(); } break; + case Intrinsic::memcpy: + case Intrinsic::memmove: + case Intrinsic::memset: { + // Add isVolatile + const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); + Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), + CI->getOperand(3), CI->getOperand(4), + llvm::ConstantInt::get(I1Ty, 0) }; + CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, + CI->getName(), CI); + NewCI->setTailCall(CI->isTailCall()); + NewCI->setCallingConv(CI->getCallingConv()); + // Handle any uses of the old CallInst. + if (!CI->use_empty()) + // Replace all uses of the old call with the new cast which has the + // correct type. + CI->replaceAllUsesWith(NewCI); + + // Clean up the old call now that it has been completely upgraded. + CI->eraseFromParent(); + break; + } } } Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Fri Apr 2 13:04:15 2010 @@ -103,7 +103,7 @@ ret i32 %sub ; CHECK: @test4 ; CHECK: load i32* @G -; CHECK: memset.i32 +; CHECK: memset.p0i8.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } @@ -118,7 +118,7 @@ ret i32 %sub ; CHECK: @test5 ; CHECK: load i32* @G -; CHECK: memcpy.i32 +; CHECK: memcpy.p0i8.p0i8.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } Modified: llvm/trunk/test/Bitcode/memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/memcpy.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Bitcode/memcpy.ll (original) +++ llvm/trunk/test/Bitcode/memcpy.ll Fri Apr 2 13:04:15 2010 @@ -8,6 +8,7 @@ tail call void @llvm.memcpy.i64( i8* %tmp.1, i8* %tmp.3, i64 100000, i32 1 ) tail call void @llvm.memset.i32( i8* %tmp.3, i8 14, i32 10000, i32 0 ) tail call void @llvm.memmove.i32( i8* %tmp.1, i8* %tmp.3, i32 123124, i32 1 ) + tail call void @llvm.memmove.i64( i8* %tmp.1, i8* %tmp.3, i64 123124, i32 1 ) ret void } @@ -19,3 +20,4 @@ declare void @llvm.memmove.i32(i8*, i8*, i32, i32) +declare void @llvm.memmove.i64(i8*, i8*, i32, i32) Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Fri Apr 2 13:04:15 2010 @@ -7,7 +7,7 @@ define i32 @t() nounwind ssp { ; CHECK: @t -; CHECK: @llvm.memset.i64 +; CHECK: @llvm.memset.p0i8.i64 entry: %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Fri Apr 2 13:04:15 2010 @@ -113,7 +113,7 @@ %1 = bitcast %struct.data* %0 to i8* %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) +; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind ret i32 0 } @@ -128,7 +128,7 @@ %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) %2 = load i8** @s, align 8 ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) +; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind ret void } Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Fri Apr 2 13:04:15 2010 @@ -4,7 +4,7 @@ ; The resulting memset is only 4-byte aligned, despite containing ; a 16-byte alignmed store in the middle. -; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) +; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) define void @foo(i32* %p) { %a0 = getelementptr i32* %p, i64 0 Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Fri Apr 2 13:04:15 2010 @@ -21,7 +21,7 @@ %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) -; CHECK: @llvm.memcpy.i32 +; CHECK: @llvm.memcpy.p0i8.p0i8.i32 ret i32 0 } Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=100191&r1=100190&r2=100191&view=diff ============================================================================== --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Fri Apr 2 13:04:15 2010 @@ -1,7 +1,7 @@ ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} ; PR1047 -define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { +define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { entry: ret void } From wangmp at apple.com Fri Apr 2 13:04:25 2010 From: wangmp at apple.com (Mon P Wang) Date: Fri, 02 Apr 2010 18:04:25 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r100192 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100402180425.A8A792A6C12C@llvm.org> Author: wangmp Date: Fri Apr 2 13:04:25 2010 New Revision: 100192 URL: http://llvm.org/viewvc/llvm-project?rev=100192&view=rev Log: Reapply patch for adding support for address spaces and added a isVolatile field to memcpy, memmove, and memset. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=100192&r1=100191&r2=100192&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Apr 2 13:04:25 2010 @@ -1559,15 +1559,17 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 3), Ops, Ops+5); return Ops[0]; } @@ -1575,15 +1577,17 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 3), Ops, Ops+5); return Ops[0]; } @@ -1591,15 +1595,17 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[4] = { + Value *Ops[5] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align) + ConstantInt::get(Type::getInt32Ty(Context), Align), + ConstantInt::get(Type::getInt1Ty(Context), false) }; + const Type *ArgTypes[2] = {SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, - &IntPtr, 1), Ops, Ops+4); + ArgTypes, 2), Ops, Ops+5); return Ops[0]; } From baldrick at free.fr Fri Apr 2 13:22:21 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 18:22:21 -0000 Subject: [llvm-commits] [dragonegg] r100195 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20100402182221.33B742A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 13:22:21 2010 New Revision: 100195 URL: http://llvm.org/viewvc/llvm-project?rev=100195&view=rev Log: Type infos are constants, not registers. Part 1 of fixing the dragonegg self-host build. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=100195&r1=100194&r2=100195&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Apr 2 13:22:21 2010 @@ -2007,7 +2007,7 @@ // Add the type infos. for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); - Args.push_back(EmitRegister(TType)); + Args.push_back(TreeConstantToLLVM::Convert(TType)); } } case ERT_CLEANUP: @@ -2031,7 +2031,7 @@ // Add the type infos. for (; TypeList; TypeList = TREE_CHAIN(TypeList)) { tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList)); - Args.push_back(EmitRegister(TType)); + Args.push_back(TreeConstantToLLVM::Convert(TType)); } } } @@ -2055,7 +2055,7 @@ //FIXME Type::getInt8PtrTy(Context)); //FIXME else //FIXME // This language has a type that catches all others. -//FIXME CatchAll = EmitRegister(catch_all_type); +//FIXME CatchAll = TreeConstantToLLVM::Convert(catch_all_type); //FIXME } //FIXME Args.push_back(CatchAll); //FIXME } From baldrick at free.fr Fri Apr 2 13:31:42 2010 From: baldrick at free.fr (Duncan Sands) Date: Fri, 02 Apr 2010 18:31:42 -0000 Subject: [llvm-commits] [dragonegg] r100198 - /dragonegg/trunk/llvm-convert.cpp Message-ID: <20100402183142.9F3C52A6C12C@llvm.org> Author: baldrick Date: Fri Apr 2 13:31:42 2010 New Revision: 100198 URL: http://llvm.org/viewvc/llvm-project?rev=100198&view=rev Log: Quick "fix" for the rest of the dragonegg self-host failure. Modified: dragonegg/trunk/llvm-convert.cpp Modified: dragonegg/trunk/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=100198&r1=100197&r2=100198&view=diff ============================================================================== --- dragonegg/trunk/llvm-convert.cpp (original) +++ dragonegg/trunk/llvm-convert.cpp Fri Apr 2 13:31:42 2010 @@ -7115,7 +7115,7 @@ } void TreeToLLVM::RenderGIMPLE_RESX(gimple stmt) { - Builder.CreateUnwind(); // FIXME + Builder.CreateUnreachable(); // FIXME //FIXME int RegionNo = gimple_resx_region(stmt); //FIXME std::vector Handlers; //FIXME From wangmp at apple.com Fri Apr 2 13:43:02 2010 From: wangmp at apple.com (Mon P Wang) Date: Fri, 02 Apr 2010 18:43:02 -0000 Subject: [llvm-commits] [llvm] r100199 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Bitcode/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ Message-ID: <20100402184302.D7E7F2A6C12C@llvm.org> Author: wangmp Date: Fri Apr 2 13:43:02 2010 New Revision: 100199 URL: http://llvm.org/viewvc/llvm-project?rev=100199&view=rev Log: Revert r100191 since it breaks objc in clang Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h llvm/trunk/include/llvm/IntrinsicInst.h llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/AutoUpgrade.cpp llvm/trunk/test/Analysis/BasicAA/modref.ll llvm/trunk/test/Bitcode/memcpy.ll llvm/trunk/test/Transforms/InstCombine/memset_chk.ll llvm/trunk/test/Transforms/InstCombine/objsize.ll llvm/trunk/test/Transforms/MemCpyOpt/align.ll llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Apr 2 13:43:02 2010 @@ -534,17 +534,17 @@ SDValue getStackArgumentTokenFactor(SDValue Chain); SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, + SDValue Size, unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, + SDValue Size, unsigned Align, const Value *DstSV, uint64_t DstOSVff, const Value *SrcSV, uint64_t SrcSVOff); SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, - SDValue Size, unsigned Align, bool isVol, + SDValue Size, unsigned Align, const Value *DstSV, uint64_t DstSVOff); /// getSetCC - Helper function to make it easier to build SetCC's if you just Modified: llvm/trunk/include/llvm/IntrinsicInst.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicInst.h (original) +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Apr 2 13:43:02 2010 @@ -133,13 +133,6 @@ return getAlignmentCst()->getZExtValue(); } - ConstantInt *getVolatileCst() const { - return cast(const_cast(getOperand(5))); - } - bool isVolatile() const { - return getVolatileCst()->getZExtValue() != 0; - } - /// getDest - This is just like getRawDest, but it strips off any cast /// instructions that feed it, giving the original input. The returned /// value is guaranteed to be a pointer. @@ -162,11 +155,7 @@ void setAlignment(Constant* A) { setOperand(4, A); } - - void setVolatile(Constant* V) { - setOperand(5, V); - } - + const Type *getAlignmentType() const { return getOperand(4)->getType(); } Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Fri Apr 2 13:43:02 2010 @@ -224,16 +224,16 @@ // def int_memcpy : Intrinsic<[], - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memmove : Intrinsic<[], - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; def int_memset : Intrinsic<[], - [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, - llvm_i32_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, + llvm_i32_ty], [IntrWriteArgMem, NoCapture<0>]>; // These functions do not actually read memory, but they are sensitive to the Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Apr 2 13:43:02 2010 @@ -917,11 +917,6 @@ Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; return Insert(CallInst::Create(Callee, Args, Args+4), Name); } - CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, - Value *Arg4, Value *Arg5, const Twine &Name = "") { - Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; - return Insert(CallInst::Create(Callee, Args, Args+5), Name); - } template CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 13:43:02 2010 @@ -1187,7 +1187,7 @@ EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { @@ -1204,7 +1204,7 @@ EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, const Value *DstSV, uint64_t DstOff, const Value *SrcSV, uint64_t SrcOff) { return SDValue(); @@ -1220,7 +1220,7 @@ EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Op1, SDValue Op2, - SDValue Op3, unsigned Align, bool isVolatile, + SDValue Op3, unsigned Align, const Value *DstSV, uint64_t DstOff) { return SDValue(); } Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Fri Apr 2 13:43:02 2010 @@ -46,8 +46,8 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD); /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src @@ -57,8 +57,8 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD); + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD); /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. @@ -70,8 +70,8 @@ const TargetData *TD); /// EmitMemSet - Emit a call to the memset function - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, - IRBuilder<> &B, const TargetData *TD); + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, + const TargetData *TD); /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' /// (e.g. 'floor'). This function is known to take a single of type matching Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 13:43:02 2010 @@ -3263,8 +3263,7 @@ static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, - bool AlwaysInline, + unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3320,7 +3319,7 @@ Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, Align); + DstSV, DstSVOff + DstOff, false, false, Align); } else { // The type might not be legal for the target. This should only happen // if the type is smaller than a legal type, as on PPC, so the right @@ -3331,11 +3330,11 @@ assert(NVT.bitsGE(VT)); Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, VT, isVol, false, + SrcSV, SrcSVOff + SrcOff, VT, false, false, MinAlign(SrcAlign, SrcOff)); Store = DAG.getTruncStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, VT, isVol, false, + DstSV, DstSVOff + DstOff, VT, false, false, Align); } OutChains.push_back(Store); @@ -3350,8 +3349,7 @@ static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, - bool AlwaysInline, + unsigned Align,bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3399,7 +3397,7 @@ Value = DAG.getLoad(VT, dl, Chain, getMemBasePlusOffset(Src, SrcOff, DAG), - SrcSV, SrcSVOff + SrcOff, isVol, false, SrcAlign); + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); LoadValues.push_back(Value); LoadChains.push_back(Value.getValue(1)); SrcOff += VTSize; @@ -3414,7 +3412,7 @@ Store = DAG.getStore(Chain, dl, LoadValues[i], getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, Align); + DstSV, DstSVOff + DstOff, false, false, Align); OutChains.push_back(Store); DstOff += VTSize; } @@ -3426,7 +3424,7 @@ static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, uint64_t Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff) { const TargetLowering &TLI = DAG.getTargetLoweringInfo(); @@ -3465,7 +3463,7 @@ SDValue Value = getMemsetValue(Src, VT, DAG, dl); SDValue Store = DAG.getStore(Chain, dl, Value, getMemBasePlusOffset(Dst, DstOff, DAG), - DstSV, DstSVOff + DstOff, isVol, false, 0); + DstSV, DstSVOff + DstOff, false, false, 0); OutChains.push_back(Store); DstOff += VTSize; } @@ -3476,7 +3474,7 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, bool AlwaysInline, + unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3490,7 +3488,7 @@ SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(),Align, - isVol, false, DstSV, DstSVOff, SrcSV, SrcSVOff); + false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3499,7 +3497,7 @@ // code. If the target chooses to do this, this is the next best. SDValue Result = TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, - isVol, AlwaysInline, + AlwaysInline, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; @@ -3509,12 +3507,11 @@ if (AlwaysInline) { assert(ConstantSize && "AlwaysInline requires a constant size!"); return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, isVol, - true, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), Align, true, + DstSV, DstSVOff, SrcSV, SrcSVOff); } // Emit a library call. - assert(!isVol && "library memcpy does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3535,7 +3532,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { @@ -3549,8 +3546,8 @@ SDValue Result = getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, - ConstantSize->getZExtValue(), Align, isVol, - false, DstSV, DstSVOff, SrcSV, SrcSVOff); + ConstantSize->getZExtValue(), + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; } @@ -3558,13 +3555,12 @@ // Then check to see if we should lower the memmove with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, DstSV, DstSVOff, SrcSV, SrcSVOff); if (Result.getNode()) return Result; // Emit a library call. - assert(!isVol && "library memmove does not support volatile"); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); @@ -3585,7 +3581,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, SDValue Size, - unsigned Align, bool isVol, + unsigned Align, const Value *DstSV, uint64_t DstSVOff) { // Check to see if we should lower the memset to stores first. @@ -3598,7 +3594,7 @@ SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), - Align, isVol, DstSV, DstSVOff); + Align, DstSV, DstSVOff); if (Result.getNode()) return Result; } @@ -3606,13 +3602,12 @@ // Then check to see if we should lower the memset with target-specific // code. If the target chooses to do this, this is the next best. SDValue Result = - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, DstSV, DstSVOff); if (Result.getNode()) return Result; // Emit a library call. - assert(!isVol && "library memset does not support volatile"); const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Apr 2 13:43:02 2010 @@ -3731,50 +3731,28 @@ case Intrinsic::longjmp: return "_longjmp"+!TLI.usesUnderscoreLongJmp(); case Intrinsic::memcpy: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - cast(I.getOperand(2)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } case Intrinsic::memset: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, I.getOperand(1), 0)); return 0; } case Intrinsic::memmove: { - // Assert for address < 256 since we support only user defined address - // spaces. - assert(cast(I.getOperand(1)->getType())->getAddressSpace() - < 256 && - cast(I.getOperand(2)->getType())->getAddressSpace() - < 256 && - "Unknown address space"); SDValue Op1 = getValue(I.getOperand(1)); SDValue Op2 = getValue(I.getOperand(2)); SDValue Op3 = getValue(I.getOperand(3)); unsigned Align = cast(I.getOperand(4))->getZExtValue(); - bool isVol = cast(I.getOperand(5))->getZExtValue(); // If the source and destination are known to not be aliases, we can // lower memmove as memcpy. @@ -3783,12 +3761,12 @@ Size = C->getZExtValue(); if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == AliasAnalysis::NoAlias) { - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, - false, I.getOperand(1), 0, I.getOperand(2), 0)); + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, + I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, I.getOperand(1), 0, I.getOperand(2), 0)); return 0; } Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Apr 2 13:43:02 2010 @@ -861,8 +861,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*isVolatile=*/false, /*AlwaysInline=*/false, - NULL, 0, NULL, 0); + /*AlwaysInline=*/false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack. @@ -2054,7 +2053,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff){ // Do repeated 4-byte loads and stores. To be improved. @@ -2090,7 +2089,7 @@ Loads[i] = DAG.getLoad(VT, dl, Chain, DAG.getNode(ISD::ADD, dl, MVT::i32, Src, DAG.getConstant(SrcOff, MVT::i32)), - SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); + SrcSV, SrcSVOff + SrcOff, false, false, 0); TFOps[i] = Loads[i].getValue(1); SrcOff += VTSize; } @@ -2101,7 +2100,7 @@ TFOps[i] = DAG.getStore(Chain, dl, Loads[i], DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, DAG.getConstant(DstOff, MVT::i32)), - DstSV, DstSVOff + DstOff, isVolatile, false, 0); + DstSV, DstSVOff + DstOff, false, false, 0); DstOff += VTSize; } Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Apr 2 13:43:02 2010 @@ -305,7 +305,7 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); SDValue LowerCallResult(SDValue Chain, SDValue InFlag, Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Apr 2 13:43:02 2010 @@ -2392,7 +2392,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - false, false, NULL, 0, NULL, 0); + false, NULL, 0, NULL, 0); } /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 2 13:43:02 2010 @@ -1433,8 +1433,7 @@ DebugLoc dl) { SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), - /*isVolatile*/false, /*AlwaysInline=*/true, - NULL, 0, NULL, 0); + /*AlwaysInline=*/true, NULL, 0, NULL, 0); } /// IsTailCallConvention - Return true if the calling convention is one that @@ -6551,7 +6550,6 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, const Value *DstSV, uint64_t DstSVOff) { ConstantSDNode *ConstantSize = dyn_cast(Size); @@ -6680,7 +6678,7 @@ DAG.getConstant(Offset, AddrVT)), Src, DAG.getConstant(BytesLeft, SizeVT), - Align, isVolatile, DstSV, DstSVOff + Offset); + Align, DstSV, DstSVOff + Offset); } // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. @@ -6691,7 +6689,7 @@ X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { // This requires the copy size to be a constant, preferrably @@ -6750,7 +6748,7 @@ DAG.getNode(ISD::ADD, dl, SrcVT, Src, DAG.getConstant(Offset, SrcVT)), DAG.getConstant(BytesLeft, SizeVT), - Align, isVolatile, AlwaysInline, + Align, AlwaysInline, DstSV, DstSVOff + Offset, SrcSV, SrcSVOff + Offset)); } @@ -6833,8 +6831,8 @@ DebugLoc dl = Op.getDebugLoc(); return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, - DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, - false, DstSV, 0, SrcSV, 0); + DAG.getIntPtrConstant(24), 8, false, + DstSV, 0, SrcSV, 0); } SDValue Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Apr 2 13:43:02 2010 @@ -737,13 +737,12 @@ SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, const Value *DstSV, uint64_t DstSVOff); SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, SDValue Chain, SDValue Dst, SDValue Src, SDValue Size, unsigned Align, - bool isVolatile, bool AlwaysInline, + bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff); @@ -753,7 +752,7 @@ /// block, the number of args, and whether or not the second arg is /// in memory or not. MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, - unsigned argNum, bool inMem) const; + unsigned argNum, bool inMem) const; /// Utility function to emit atomic bitwise operations (and, or, xor). /// It takes the bitwise instruction to expand, the associated machine basic Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Apr 2 13:43:02 2010 @@ -1443,7 +1443,7 @@ return DAG.getMemmove(Chain, dl, ST->getBasePtr(), LD->getBasePtr(), DAG.getConstant(StoreBits/8, MVT::i32), - Alignment, false, ST->getSrcValue(), + Alignment, ST->getSrcValue(), ST->getSrcValueOffset(), LD->getSrcValue(), LD->getSrcValueOffset()); } Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Apr 2 13:43:02 2010 @@ -136,14 +136,8 @@ return 0; // If not 1/2/4/8 bytes, exit. // Use an integer load+store unless we can find something better. - unsigned SrcAddrSp = - cast(MI->getOperand(2)->getType())->getAddressSpace(); - unsigned DstAddrSp = - cast(MI->getOperand(1)->getType())->getAddressSpace(); - - const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); - Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); - Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); + Type *NewPtrTy = + PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); // Memcpy forces the use of i8* for the source and destination. That means // that if you're using memcpy to move one double around, you'll get a cast @@ -173,10 +167,8 @@ break; } - if (SrcETy->isSingleValueType()) { - NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); - NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); - } + if (SrcETy->isSingleValueType()) + NewPtrTy = PointerType::getUnqual(SrcETy); } } @@ -186,12 +178,11 @@ SrcAlign = std::max(SrcAlign, CopyAlign); DstAlign = std::max(DstAlign, CopyAlign); - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); - Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); + Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); InsertNewInstBefore(L, *MI); - InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), - *MI); + InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); // Set the size of the copy to 0, it will be deleted on the next iteration. MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); @@ -284,11 +275,10 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - const Type *Tys[3] = { CI.getOperand(1)->getType(), - CI.getOperand(2)->getType(), - CI.getOperand(3)->getType() }; + const Type *Tys[1]; + Tys[0] = CI.getOperand(3)->getType(); CI.setOperand(0, - Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); + Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); Changed = true; } } Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri Apr 2 13:43:02 2010 @@ -413,6 +413,7 @@ // interesting as a small compile-time optimization. Ranges.addStore(0, SI); + Function *MemSetF = 0; // Now that we have full information about ranges, loop over the ranges and // emit memset's for anything big enough to be worthwhile. @@ -432,40 +433,29 @@ // memset block. This ensure that the memset is dominated by any addressing // instruction needed by the start of the block. BasicBlock::iterator InsertPt = BI; - + + if (MemSetF == 0) { + const Type *Ty = Type::getInt64Ty(Context); + MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); + } + // Get the starting pointer of the block. StartPtr = Range.StartPtr; - - // Determine alignment - unsigned Alignment = Range.Alignment; - if (Alignment == 0) { - const Type *EltType = - cast(StartPtr->getType())->getElementType(); - Alignment = TD->getABITypeAlignment(EltType); - } - + // Cast the start ptr to be i8* as memset requires. - const PointerType* StartPTy = cast(StartPtr->getType()); - const PointerType *i8Ptr = Type::getInt8PtrTy(Context, - StartPTy->getAddressSpace()); - if (StartPTy!= i8Ptr) + const Type *i8Ptr = Type::getInt8PtrTy(Context); + if (StartPtr->getType() != i8Ptr) StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), InsertPt); - + Value *Ops[] = { StartPtr, ByteVal, // Start, value // size ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), // align - ConstantInt::get(Type::getInt32Ty(Context), Alignment), - // volatile - ConstantInt::get(Type::getInt1Ty(Context), 0), + ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) }; - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; - - Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); - - Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); DEBUG(dbgs() << "Replace stores:\n"; for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) dbgs() << *Range.TheStores[i]; @@ -690,19 +680,16 @@ return false; // If all checks passed, then we can transform these memcpy's - const Type *ArgTys[3] = { M->getRawDest()->getType(), - MDep->getRawSource()->getType(), - M->getLength()->getType() }; + const Type *Ty = M->getLength()->getType(); Function *MemCpyFun = Intrinsic::getDeclaration( M->getParent()->getParent()->getParent(), - M->getIntrinsicID(), ArgTys, 3); + M->getIntrinsicID(), &Ty, 1); - Value *Args[5] = { - M->getRawDest(), MDep->getRawSource(), M->getLength(), - M->getAlignmentCst(), M->getVolatileCst() + Value *Args[4] = { + M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() }; - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); // If C and M don't interfere, then this is a valid transformation. If they @@ -741,10 +728,8 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - const Type *ArgTys[3] = { M->getRawDest()->getType(), - M->getRawSource()->getType(), - M->getLength()->getType() }; - M->setOperand(0,Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); + const Type *Ty = M->getLength()->getType(); + M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); // MemDep may have over conservative information about this instruction, just // conservatively flush it from the cache. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Apr 2 13:43:02 2010 @@ -858,17 +858,8 @@ EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); // Cast the other pointer (if we have one) to BytePtrTy. - if (OtherElt && OtherElt->getType() != BytePtrTy) { - // Preserve address space of OtherElt - const PointerType* OtherPTy = cast(OtherElt->getType()); - const PointerType* PTy = cast(BytePtrTy); - if (OtherPTy->getElementType() != PTy->getElementType()) { - Type *NewOtherPTy = PointerType::get(PTy->getElementType(), - OtherPTy->getAddressSpace()); - OtherElt = new BitCastInst(OtherElt, NewOtherPTy, - OtherElt->getNameStr(), MI); - } - } + if (OtherElt && OtherElt->getType() != BytePtrTy) + OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); unsigned EltSize = TD->getTypeAllocSize(EltTy); @@ -879,28 +870,17 @@ SROADest ? OtherElt : EltPtr, // Src ptr ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size // Align - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), - MI->getVolatileCst() + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) }; - // In case we fold the address space overloaded memcpy of A to B - // with memcpy of B to C, change the function to be a memcpy of A to C. - const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), - Ops[2]->getType() }; - Module *M = MI->getParent()->getParent()->getParent(); - TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } else { assert(isa(MI)); Value *Ops[] = { EltPtr, MI->getOperand(2), // Dest, Value, ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size - Zero, // Align - ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile + Zero // Align }; - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; - Module *M = MI->getParent()->getParent()->getParent(); - TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); } } DeadInsts.push_back(MI); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Apr 2 13:43:02 2010 @@ -142,8 +142,7 @@ // We have enough information to now generate the memcpy call to do the // concatenation for us. Make a memcpy to copy the nul byte with align = 1. EmitMemCpy(CpyDst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); } }; @@ -384,8 +383,7 @@ CI->getOperand(3), B, TD); else EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); return Dst; } }; @@ -413,8 +411,8 @@ if (SrcLen == 0) { // strncpy(x, "", y) -> memset(x, '\0', y, 1) - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), - LenOp, false, B, TD); + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, + B, TD); return Dst; } @@ -434,8 +432,7 @@ // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] EmitMemCpy(Dst, Src, - ConstantInt::get(TD->getIntPtrType(*Context), Len), - 1, false, B, TD); + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); return Dst; } @@ -596,7 +593,7 @@ // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, false, B, TD); + CI->getOperand(3), 1, B, TD); return CI->getOperand(1); } }; @@ -618,7 +615,7 @@ // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) EmitMemMove(CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), 1, false, B, TD); + CI->getOperand(3), 1, B, TD); return CI->getOperand(1); } }; @@ -640,8 +637,8 @@ // memset(p, v, n) -> llvm.memset(p, v, n, 1) Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), - false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); + false); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); return CI->getOperand(1); } }; @@ -1002,7 +999,7 @@ // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. ConstantInt::get(TD->getIntPtrType(*Context), - FormatStr.size()+1), 1, false, B, TD); + FormatStr.size()+1), 1, B, TD); return ConstantInt::get(CI->getType(), FormatStr.size()); } @@ -1016,11 +1013,11 @@ // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; Value *V = B.CreateTrunc(CI->getOperand(3), - Type::getInt8Ty(*Context), "char"); + Type::getInt8Ty(*Context), "char"); Value *Ptr = CastToCStr(CI->getOperand(1), B); B.CreateStore(V, Ptr); Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), - "nul"); + "nul"); B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); return ConstantInt::get(CI->getType(), 1); @@ -1037,7 +1034,7 @@ Value *IncLen = B.CreateAdd(Len, ConstantInt::get(Len->getType(), 1), "leninc"); - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); // The sprintf result is the unincremented number of bytes in the string. return B.CreateIntCast(Len, CI->getType(), false); Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Fri Apr 2 13:43:02 2010 @@ -109,16 +109,15 @@ /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always /// expects that Len has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); + const Type *Ty = Len->getType(); + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); - return B.CreateCall5(MemCpy, Dst, Src, Len, - ConstantInt::get(B.getInt32Ty(), Align), - ConstantInt::get(B.getInt1Ty(), isVolatile)); + return B.CreateCall4(MemCpy, Dst, Src, Len, + ConstantInt::get(B.getInt32Ty(), Align)); } /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. @@ -147,18 +146,16 @@ /// EmitMemMove - Emit a call to the memmove function to the builder. This /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, + unsigned Align, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); LLVMContext &Context = B.GetInsertBlock()->getContext(); - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), - TD->getIntPtrType(Context) }; - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); + const Type *Ty = TD->getIntPtrType(Context); + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); Dst = CastToCStr(Dst, B); Src = CastToCStr(Src, B); Value *A = ConstantInt::get(B.getInt32Ty(), Align); - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); - return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); + return B.CreateCall4(MemMove, Dst, Src, Len, A); } /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is @@ -209,15 +206,15 @@ } /// EmitMemSet - Emit a call to the memset function -Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, - IRBuilder<> &B, const TargetData *TD) { +Value *llvm::EmitMemSet(Value *Dst, Value *Val, + Value *Len, IRBuilder<> &B, const TargetData *TD) { Module *M = B.GetInsertBlock()->getParent()->getParent(); Intrinsic::ID IID = Intrinsic::memset; - const Type *Tys[2] = { Dst->getType(), Len->getType() }; - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); + const Type *Tys[1]; + Tys[0] = Len->getType(); + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); Value *Align = ConstantInt::get(B.getInt32Ty(), 1); - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); - return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); + return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); } /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. @@ -384,7 +381,7 @@ if (Name == "__memcpy_chk") { if (isFoldable(4, 3, false)) { EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, false, B, TD); + 1, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -399,7 +396,7 @@ if (Name == "__memmove_chk") { if (isFoldable(4, 3, false)) { EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), - 1, false, B, TD); + 1, B, TD); replaceCall(CI->getOperand(1)); return true; } @@ -410,7 +407,7 @@ if (isFoldable(4, 3, false)) { Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), false); - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); replaceCall(CI->getOperand(1)); return true; } Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Apr 2 13:43:02 2010 @@ -297,10 +297,10 @@ I->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; + const Type *Tys[] = { Type::getInt64Ty(Context) }; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, - Tys, 3); + Tys, 1); Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); @@ -309,18 +309,17 @@ Size = ConstantExpr::getSizeOf(AggTy); else Size = ConstantInt::get(Type::getInt64Ty(Context), - TD->getTypeStoreSize(AggTy)); + TD->getTypeStoreSize(AggTy)); // Always generate a memcpy of alignment 1 here because we don't know // the alignment of the src pointer. Other optimizations can infer // better alignment. Value *CallArgs[] = { DestCast, SrcCast, Size, - ConstantInt::get(Type::getInt32Ty(Context), 1), - ConstantInt::get(Type::getInt1Ty(Context), 0) + ConstantInt::get(Type::getInt32Ty(Context), 1) }; CallInst *TheMemCpy = - CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); + CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); // If we have a call graph, update it. if (CG) { Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Apr 2 13:43:02 2010 @@ -145,54 +145,6 @@ } break; - case 'm': { - // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the - // new format that allows overloading the pointer for different address - // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) - const char* NewFnName = NULL; - if (Name.compare(5,8,"memcpy.i",8) == 0) { - if (Name[13] == '8') - NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; - else if (Name.compare(13,2,"16") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; - else if (Name.compare(13,2,"32") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; - else if (Name.compare(13,2,"64") == 0) - NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; - } else if (Name.compare(5,9,"memmove.i",9) == 0) { - if (Name[14] == '8') - NewFnName = "llvm.memmove.p0i8.p0i8.i8"; - else if (Name.compare(14,2,"16") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i16"; - else if (Name.compare(14,2,"32") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i32"; - else if (Name.compare(14,2,"64") == 0) - NewFnName = "llvm.memmove.p0i8.p0i8.i64"; - } - else if (Name.compare(5,8,"memset.i",8) == 0) { - if (Name[13] == '8') - NewFnName = "llvm.memset.p0i8.i8"; - else if (Name.compare(13,2,"16") == 0) - NewFnName = "llvm.memset.p0i8.i16"; - else if (Name.compare(13,2,"32") == 0) - NewFnName = "llvm.memset.p0i8.i32"; - else if (Name.compare(13,2,"64") == 0) - NewFnName = "llvm.memset.p0i8.i64"; - } - if (NewFnName) { - const FunctionType *FTy = F->getFunctionType(); - NewFn = cast(M->getOrInsertFunction(NewFnName, - FTy->getReturnType(), - FTy->getParamType(0), - FTy->getParamType(1), - FTy->getParamType(2), - FTy->getParamType(3), - Type::getInt1Ty(F->getContext()), - (Type *)0)); - return true; - } - break; - } case 'p': // This upgrades the llvm.part.select overloaded intrinsic names to only // use one type specifier in the name. We only care about the old format @@ -520,28 +472,6 @@ CI->eraseFromParent(); } break; - case Intrinsic::memcpy: - case Intrinsic::memmove: - case Intrinsic::memset: { - // Add isVolatile - const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); - Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), - CI->getOperand(3), CI->getOperand(4), - llvm::ConstantInt::get(I1Ty, 0) }; - CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, - CI->getName(), CI); - NewCI->setTailCall(CI->isTailCall()); - NewCI->setCallingConv(CI->getCallingConv()); - // Handle any uses of the old CallInst. - if (!CI->use_empty()) - // Replace all uses of the old call with the new cast which has the - // correct type. - CI->replaceAllUsesWith(NewCI); - - // Clean up the old call now that it has been completely upgraded. - CI->eraseFromParent(); - break; - } } } Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Fri Apr 2 13:43:02 2010 @@ -103,7 +103,7 @@ ret i32 %sub ; CHECK: @test4 ; CHECK: load i32* @G -; CHECK: memset.p0i8.i32 +; CHECK: memset.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } @@ -118,7 +118,7 @@ ret i32 %sub ; CHECK: @test5 ; CHECK: load i32* @G -; CHECK: memcpy.p0i8.p0i8.i32 +; CHECK: memcpy.i32 ; CHECK-NOT: load ; CHECK: sub i32 %tmp, %tmp } Modified: llvm/trunk/test/Bitcode/memcpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/memcpy.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Bitcode/memcpy.ll (original) +++ llvm/trunk/test/Bitcode/memcpy.ll Fri Apr 2 13:43:02 2010 @@ -8,7 +8,6 @@ tail call void @llvm.memcpy.i64( i8* %tmp.1, i8* %tmp.3, i64 100000, i32 1 ) tail call void @llvm.memset.i32( i8* %tmp.3, i8 14, i32 10000, i32 0 ) tail call void @llvm.memmove.i32( i8* %tmp.1, i8* %tmp.3, i32 123124, i32 1 ) - tail call void @llvm.memmove.i64( i8* %tmp.1, i8* %tmp.3, i64 123124, i32 1 ) ret void } @@ -20,4 +19,3 @@ declare void @llvm.memmove.i32(i8*, i8*, i32, i32) -declare void @llvm.memmove.i64(i8*, i8*, i32, i32) Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Fri Apr 2 13:43:02 2010 @@ -7,7 +7,7 @@ define i32 @t() nounwind ssp { ; CHECK: @t -; CHECK: @llvm.memset.p0i8.i64 +; CHECK: @llvm.memset.i64 entry: %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Fri Apr 2 13:43:02 2010 @@ -113,7 +113,7 @@ %1 = bitcast %struct.data* %0 to i8* %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) +; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind ret i32 0 } @@ -128,7 +128,7 @@ %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) %2 = load i8** @s, align 8 ; CHECK-NOT: @llvm.objectsize -; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) +; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind ret void } Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Fri Apr 2 13:43:02 2010 @@ -4,7 +4,7 @@ ; The resulting memset is only 4-byte aligned, despite containing ; a 16-byte alignmed store in the middle. -; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) +; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) define void @foo(i32* %p) { %a0 = getelementptr i32* %p, i64 0 Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Fri Apr 2 13:43:02 2010 @@ -21,7 +21,7 @@ %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) -; CHECK: @llvm.memcpy.p0i8.p0i8.i32 +; CHECK: @llvm.memcpy.i32 ret i32 0 } Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=100199&r1=100198&r2=100199&view=diff ============================================================================== --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Fri Apr 2 13:43:02 2010 @@ -1,7 +1,7 @@ ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} ; PR1047 -define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { +define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { entry: ret void } From wangmp at apple.com Fri Apr 2 13:44:29 2010 From: wangmp at apple.com (Mon P Wang) Date: Fri, 02 Apr 2010 18:44:29 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r100202 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100402184429.74A942A6C12C@llvm.org> Author: wangmp Date: Fri Apr 2 13:44:29 2010 New Revision: 100202 URL: http://llvm.org/viewvc/llvm-project?rev=100202&view=rev Log: Revert r100192 since the associated llvm patch is causing problems for clang Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=100202&r1=100201&r2=100202&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Apr 2 13:44:29 2010 @@ -1559,17 +1559,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, - ArgTypes, 3), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } @@ -1577,17 +1575,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, - ArgTypes, 3), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } @@ -1595,17 +1591,15 @@ unsigned Align) { const Type *SBP = Type::getInt8PtrTy(Context); const Type *IntPtr = TD.getIntPtrType(Context); - Value *Ops[5] = { + Value *Ops[4] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), CastToSIntType(Size, IntPtr), - ConstantInt::get(Type::getInt32Ty(Context), Align), - ConstantInt::get(Type::getInt1Ty(Context), false) + ConstantInt::get(Type::getInt32Ty(Context), Align) }; - const Type *ArgTypes[2] = {SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, - ArgTypes, 2), Ops, Ops+5); + &IntPtr, 1), Ops, Ops+4); return Ops[0]; } From greened at obbligato.org Fri Apr 2 13:46:27 2010 From: greened at obbligato.org (David Greene) Date: Fri, 02 Apr 2010 18:46:27 -0000 Subject: [llvm-commits] [llvm] r100204 - in /llvm/trunk: include/llvm/Analysis/LoopPass.h include/llvm/Assembly/PrintModulePass.h include/llvm/CallGraphSCCPass.h include/llvm/CodeGen/MachineFunctionPass.h include/llvm/CodeGen/Passes.h include/llvm/Pass.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineFunctionPass.cpp lib/CodeGen/MachineFunctionPrinterPass.cpp lib/VMCore/Pass.cpp lib/VMCore/PassManager.cpp lib/VMCore/PrintModulePass.cpp Message-ID: <20100402184627.43F492A6C12C@llvm.org> Author: greened Date: Fri Apr 2 13:46:26 2010 New Revision: 100204 URL: http://llvm.org/viewvc/llvm-project?rev=100204&view=rev Log: Let's try this again. Re-apply 100143 including an apparent missing include. For some reason the buildbot choked on this while my builds did not. It's probably due to a difference in system headers. --- Add some switches helpful for debugging: -print-before= Dump IR before running pass . -print-before-all Dump IR before running each pass. -print-after-all Dump IR after running each pass. These are helpful when tracking down a miscompilation. It is easy to get IR dumps and do diffs on them, etc. To make this work well, add a new getPrinterPass API to Pass so that each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass suitable for dumping out the kind of object the Pass works on. Added: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h llvm/trunk/include/llvm/Assembly/PrintModulePass.h llvm/trunk/include/llvm/CallGraphSCCPass.h llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/PrintModulePass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Fri Apr 2 13:46:26 2010 @@ -31,6 +31,10 @@ explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} + /// getPrinterPass - Get a pass to print the function corresponding + /// to a Loop. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + // runOnLoop - This method should be implemented by the subclass to perform // whatever action is necessary for the specified Loop. virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0; Modified: llvm/trunk/include/llvm/Assembly/PrintModulePass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/PrintModulePass.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/PrintModulePass.h (original) +++ llvm/trunk/include/llvm/Assembly/PrintModulePass.h Fri Apr 2 13:46:26 2010 @@ -27,7 +27,9 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. - ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false); + ModulePass *createPrintModulePass(raw_ostream *OS, + bool DeleteStream=false, + const std::string &Banner = ""); /// createPrintFunctionPass - Create and return a pass that prints /// functions to the specified raw_ostream as they are processed. Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallGraphSCCPass.h (original) +++ llvm/trunk/include/llvm/CallGraphSCCPass.h Fri Apr 2 13:46:26 2010 @@ -35,6 +35,10 @@ explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} + /// createPrinterPass - Get a pass that prints the Module + /// corresponding to a CallGraph. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. virtual bool doInitialization(CallGraph &CG) { Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h Fri Apr 2 13:46:26 2010 @@ -34,6 +34,9 @@ explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} + /// createPrinterPass - Get a machine function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. /// Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Apr 2 13:46:26 2010 @@ -21,6 +21,7 @@ namespace llvm { class FunctionPass; + class MachineFunctionPass; class PassInfo; class TargetLowering; class RegisterCoalescer; @@ -36,8 +37,9 @@ /// MachineFunctionPrinter pass - This pass prints out the machine function to /// the given stream, as a debugging tool. - FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner =""); + MachineFunctionPass * + createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner =""); /// MachineLoopInfo pass - This pass is a loop analysis pass. /// Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Fri Apr 2 13:46:26 2010 @@ -30,7 +30,9 @@ #define LLVM_PASS_H #include "llvm/System/DataTypes.h" + #include +#include #include #include @@ -120,6 +122,11 @@ virtual void print(raw_ostream &O, const Module *M) const; void dump() const; // dump - Print to stderr. + /// createPrinterPass - Get a Pass appropriate to print the IR this + /// pass operates one (Module, Function or MachineFunction). + virtual Pass *createPrinterPass(raw_ostream &O, + const std::string &Banner) const = 0; + /// Each pass is responsible for assigning a pass manager to itself. /// PMS is the stack of available pass manager. virtual void assignPassManager(PMStack &, @@ -233,6 +240,9 @@ /// class ModulePass : public Pass { public: + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// runOnModule - Virtual method overriden by subclasses to process the module /// being operated on. virtual bool runOnModule(Module &M) = 0; @@ -293,6 +303,9 @@ explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -343,6 +356,9 @@ explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; + /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Fri Apr 2 13:46:26 2010 @@ -87,10 +87,40 @@ bool IsCheckingMode); }; +/// PrintCallGraphPass - Print a Module corresponding to a call graph. +/// +class PrintCallGraphPass : public CallGraphSCCPass { +private: + std::string Banner; + raw_ostream &Out; // raw_ostream to print on. + +public: + static char ID; + PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} + PrintCallGraphPass(const std::string &B, raw_ostream &o) + : CallGraphSCCPass(&ID), Banner(B), Out(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + bool runOnSCC(std::vector &SCC) { + Out << Banner; + for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); + n != ne; + ++n) { + (*n)->getFunction()->print(Out); + } + return false; + } +}; + } // end anonymous namespace. char CGPassManager::ID = 0; +char PrintCallGraphPass::ID = 0; + bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, CallGraph &CG, bool &CallGraphUpToDate) { bool Changed = false; @@ -396,6 +426,11 @@ return Changed; } +Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return new PrintCallGraphPass(Banner, O); +} + /// Assign pass manager to manage this pass. void CallGraphSCCPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Fri Apr 2 13:46:26 2010 @@ -14,9 +14,44 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" +#include "llvm/Assembly/PrintModulePass.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" using namespace llvm; +namespace { + +/// PrintLoopPass - Print a Function corresponding to a Loop. +/// +class PrintLoopPass : public LoopPass { +private: + std::string Banner; + raw_ostream &Out; // raw_ostream to print on. + +public: + static char ID; + PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {} + PrintLoopPass(const std::string &B, raw_ostream &o) + : LoopPass(&ID), Banner(B), Out(o) {} + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + } + + bool runOnLoop(Loop *L, LPPassManager &) { + Out << Banner; + for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); + b != be; + ++b) { + (*b)->print(Out); + } + return false; + } +}; + +char PrintLoopPass::ID = 0; +} + //===----------------------------------------------------------------------===// // LPPassManager // @@ -306,6 +341,11 @@ //===----------------------------------------------------------------------===// // LoopPass +Pass *LoopPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return new PrintLoopPass(Banner, O); +} + // Check if this pass is suitable for the current LPPassManager, if // available. This pass P is not suitable for a LPPassManager if P // is not preserving higher level analysis info used by other Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Apr 2 13:46:26 2010 @@ -39,40 +39,6 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; -namespace { - struct Printer : public MachineFunctionPass { - static char ID; - - raw_ostream &OS; - const std::string Banner; - - Printer(raw_ostream &os, const std::string &banner) - : MachineFunctionPass(&ID), OS(os), Banner(banner) {} - - const char *getPassName() const { return "MachineFunction Printer"; } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - bool runOnMachineFunction(MachineFunction &MF) { - OS << "# " << Banner << ":\n"; - MF.print(OS); - return false; - } - }; - char Printer::ID = 0; -} - -/// Returns a newly-created MachineFunction Printer pass. The default banner is -/// empty. -/// -FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner){ - return new Printer(OS, Banner); -} - //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Fri Apr 2 13:46:26 2010 @@ -15,8 +15,14 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/Passes.h" using namespace llvm; +Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createMachineFunctionPrinterPass(O, Banner); +} + bool MachineFunctionPass::runOnFunction(Function &F) { // Do not codegen any 'available_externally' functions at all, they have // definitions outside the translation unit. Added: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp?rev=100204&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (added) +++ llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Fri Apr 2 13:46:26 2010 @@ -0,0 +1,60 @@ +//===-- MachineFunctionPrinterPass.cpp ------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// MachineFunctionPrinterPass implementation. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +namespace { +/// MachineFunctionPrinterPass - This is a pass to dump the IR of a +/// MachineFunction. +/// +struct MachineFunctionPrinterPass : public MachineFunctionPass { + static char ID; + + raw_ostream &OS; + const std::string Banner; + + MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} + + const char *getPassName() const { return "MachineFunction Printer"; } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) { + OS << "# " << Banner << ":\n"; + MF.print(OS); + return false; + } +}; + +char MachineFunctionPrinterPass::ID = 0; +} + +namespace llvm { +/// Returns a newly-created MachineFunction Printer pass. The +/// default banner is empty. +/// +MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner){ + return new MachineFunctionPrinterPass(OS, Banner); +} + +} Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Fri Apr 2 13:46:26 2010 @@ -18,6 +18,7 @@ #include "llvm/Module.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PassNameParser.h" @@ -42,6 +43,11 @@ // Force out-of-line virtual method. ModulePass::~ModulePass() { } +Pass *ModulePass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); +} + PassManagerType ModulePass::getPotentialPassManagerType() const { return PMT_ModulePassManager; } @@ -113,6 +119,11 @@ // FunctionPass Implementation // +Pass *FunctionPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + return createPrintFunctionPass(Banner, &O); +} + // run - On a module, we run this pass by initializing, runOnFunction'ing once // for every function in the module, then by finalizing. // @@ -155,6 +166,13 @@ // BasicBlockPass Implementation // +Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, + const std::string &Banner) const { + + llvm_unreachable("BasicBlockPass printing unsupported."); + return 0; +} + // To run this pass on a function, we simply call runOnBasicBlock once for each // function. // Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Fri Apr 2 13:46:26 2010 @@ -13,6 +13,7 @@ #include "llvm/PassManagers.h" +#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -20,6 +21,7 @@ #include "llvm/Module.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" #include "llvm/System/Threading.h" @@ -55,6 +57,57 @@ clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), clEnumValEnd)); + +typedef llvm::cl::list +PassOptionList; + +// Print IR out before/after specified passes. +static PassOptionList +PrintBefore("print-before", + llvm::cl::desc("Print IR before specified passes")); + +static PassOptionList +PrintAfter("print-after", + llvm::cl::desc("Print IR after specified passes")); + +static cl::opt +PrintBeforeAll("print-before-all", + llvm::cl::desc("Print IR before each pass"), + cl::init(false)); +static cl::opt +PrintAfterAll("print-after-all", + llvm::cl::desc("Print IR after each pass"), + cl::init(false)); + +/// This is a helper to determine whether to print IR before or +/// after a pass. + +static bool ShouldPrintBeforeOrAfterPass(Pass *P, + PassOptionList &PassesToPrint) { + for (unsigned i = 0, ie = PassesToPrint.size(); i < ie; ++i) { + const llvm::PassInfo *PassInf = PassesToPrint[i]; + if (PassInf && P->getPassInfo()) + if (PassInf->getPassArgument() == + P->getPassInfo()->getPassArgument()) { + return true; + } + } + return false; +} + + +/// This is a utility to check whether a pass should have IR dumped +/// before it. +static bool ShouldPrintBeforePass(Pass *P) { + return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(P, PrintBefore); +} + +/// This is a utility to check whether a pass should have IR dumped +/// after it. +static bool ShouldPrintAfterPass(Pass *P) { + return PrintAfterAll || ShouldPrintBeforeOrAfterPass(P, PrintAfter); +} + } // End of llvm namespace /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions @@ -182,6 +235,11 @@ schedulePass(P); } + /// createPrinterPass - Get a function printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintFunctionPass(Banner, &O); + } + // Prepare for running an on the fly pass, freeing memory if needed // from a previous run. void releaseMemoryOnTheFly(); @@ -252,6 +310,11 @@ } } + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); + } + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnModule(Module &M); @@ -331,6 +394,11 @@ schedulePass(P); } + /// createPrinterPass - Get a module printer pass. + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { + return createPrintModulePass(&O, false, Banner); + } + /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool run(Module &M); @@ -1208,7 +1276,14 @@ /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. void FunctionPassManager::add(Pass *P) { + if (ShouldPrintBeforePass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") + + P->getPassName() + " ***")); FPM->add(P); + + if (ShouldPrintAfterPass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") + + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep @@ -1519,7 +1594,15 @@ /// will be destroyed as well, so there is no need to delete the pass. This /// implies that all passes MUST be allocated with 'new'. void PassManager::add(Pass *P) { + if (ShouldPrintBeforePass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") + + P->getPassName() + " ***")); + PM->add(P); + + if (ShouldPrintAfterPass(P)) + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") + + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep track of Modified: llvm/trunk/lib/VMCore/PrintModulePass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PrintModulePass.cpp?rev=100204&r1=100203&r2=100204&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PrintModulePass.cpp (original) +++ llvm/trunk/lib/VMCore/PrintModulePass.cpp Fri Apr 2 13:46:26 2010 @@ -23,21 +23,22 @@ namespace { class PrintModulePass : public ModulePass { + std::string Banner; raw_ostream *Out; // raw_ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: static char ID; PrintModulePass() : ModulePass(&ID), Out(&dbgs()), DeleteStream(false) {} - PrintModulePass(raw_ostream *o, bool DS) - : ModulePass(&ID), Out(o), DeleteStream(DS) {} + PrintModulePass(const std::string &B, raw_ostream *o, bool DS) + : ModulePass(&ID), Banner(B), Out(o), DeleteStream(DS) {} ~PrintModulePass() { if (DeleteStream) delete Out; } bool runOnModule(Module &M) { - (*Out) << M; + (*Out) << Banner << M; return false; } @@ -85,8 +86,9 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS, - bool DeleteStream) { - return new PrintModulePass(OS, DeleteStream); + bool DeleteStream, + const std::string &Banner) { + return new PrintModulePass(Banner, OS, DeleteStream); } /// createPrintFunctionPass - Create and return a pass that prints From bob.wilson at apple.com Fri Apr 2 13:50:38 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 2 Apr 2010 11:50:38 -0700 Subject: [llvm-commits] [llvm] r100199 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Bitcode/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <20100402184302.D7E7F2A6C12C@llvm.org> References: <20100402184302.D7E7F2A6C12C@llvm.org> Message-ID: Are you sure? Was it the virt.cpp failure? All of the initial buildbot complaints were synced to 100192, so they were missing the clang change in 100193. On Apr 2, 2010, at 11:43 AM, Mon P Wang wrote: > Author: wangmp > Date: Fri Apr 2 13:43:02 2010 > New Revision: 100199 > > URL: http://llvm.org/viewvc/llvm-project?rev=100199&view=rev > Log: > Revert r100191 since it breaks objc in clang > > Modified: > llvm/trunk/include/llvm/CodeGen/SelectionDAG.h > llvm/trunk/include/llvm/IntrinsicInst.h > llvm/trunk/include/llvm/Intrinsics.td > llvm/trunk/include/llvm/Support/IRBuilder.h > llvm/trunk/include/llvm/Target/TargetLowering.h > llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > llvm/trunk/lib/Target/ARM/ARMISelLowering.h > llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > llvm/trunk/lib/Target/X86/X86ISelLowering.h > llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp > llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp > llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > llvm/trunk/lib/VMCore/AutoUpgrade.cpp > llvm/trunk/test/Analysis/BasicAA/modref.ll > llvm/trunk/test/Bitcode/memcpy.ll > llvm/trunk/test/Transforms/InstCombine/memset_chk.ll > llvm/trunk/test/Transforms/InstCombine/objsize.ll > llvm/trunk/test/Transforms/MemCpyOpt/align.ll > llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll > llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll > > Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) > +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Apr 2 13:43:02 2010 > @@ -534,17 +534,17 @@ > SDValue getStackArgumentTokenFactor(SDValue Chain); > > SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, > + SDValue Size, unsigned Align, bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff); > > SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - SDValue Size, unsigned Align, bool isVol, > + SDValue Size, unsigned Align, > const Value *DstSV, uint64_t DstOSVff, > const Value *SrcSV, uint64_t SrcSVOff); > > SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, > - SDValue Size, unsigned Align, bool isVol, > + SDValue Size, unsigned Align, > const Value *DstSV, uint64_t DstSVOff); > > /// getSetCC - Helper function to make it easier to build SetCC's if you just > > Modified: llvm/trunk/include/llvm/IntrinsicInst.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/IntrinsicInst.h (original) > +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Apr 2 13:43:02 2010 > @@ -133,13 +133,6 @@ > return getAlignmentCst()->getZExtValue(); > } > > - ConstantInt *getVolatileCst() const { > - return cast(const_cast(getOperand(5))); > - } > - bool isVolatile() const { > - return getVolatileCst()->getZExtValue() != 0; > - } > - > /// getDest - This is just like getRawDest, but it strips off any cast > /// instructions that feed it, giving the original input. The returned > /// value is guaranteed to be a pointer. > @@ -162,11 +155,7 @@ > void setAlignment(Constant* A) { > setOperand(4, A); > } > - > - void setVolatile(Constant* V) { > - setOperand(5, V); > - } > - > + > const Type *getAlignmentType() const { > return getOperand(4)->getType(); > } > > Modified: llvm/trunk/include/llvm/Intrinsics.td > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Intrinsics.td (original) > +++ llvm/trunk/include/llvm/Intrinsics.td Fri Apr 2 13:43:02 2010 > @@ -224,16 +224,16 @@ > // > > def int_memcpy : Intrinsic<[], > - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, > - llvm_i32_ty, llvm_i1_ty], > + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, > + llvm_i32_ty], > [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; > def int_memmove : Intrinsic<[], > - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, > - llvm_i32_ty, llvm_i1_ty], > + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, > + llvm_i32_ty], > [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; > def int_memset : Intrinsic<[], > - [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, > - llvm_i32_ty, llvm_i1_ty], > + [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, > + llvm_i32_ty], > [IntrWriteArgMem, NoCapture<0>]>; > > // These functions do not actually read memory, but they are sensitive to the > > Modified: llvm/trunk/include/llvm/Support/IRBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Apr 2 13:43:02 2010 > @@ -917,11 +917,6 @@ > Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; > return Insert(CallInst::Create(Callee, Args, Args+4), Name); > } > - CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, > - Value *Arg4, Value *Arg5, const Twine &Name = "") { > - Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; > - return Insert(CallInst::Create(Callee, Args, Args+5), Name); > - } > > template > CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, > > Modified: llvm/trunk/include/llvm/Target/TargetLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) > +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 13:43:02 2010 > @@ -1187,7 +1187,7 @@ > EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, > SDValue Op1, SDValue Op2, > - SDValue Op3, unsigned Align, bool isVolatile, > + SDValue Op3, unsigned Align, > bool AlwaysInline, > const Value *DstSV, uint64_t DstOff, > const Value *SrcSV, uint64_t SrcOff) { > @@ -1204,7 +1204,7 @@ > EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, > SDValue Op1, SDValue Op2, > - SDValue Op3, unsigned Align, bool isVolatile, > + SDValue Op3, unsigned Align, > const Value *DstSV, uint64_t DstOff, > const Value *SrcSV, uint64_t SrcOff) { > return SDValue(); > @@ -1220,7 +1220,7 @@ > EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, > SDValue Op1, SDValue Op2, > - SDValue Op3, unsigned Align, bool isVolatile, > + SDValue Op3, unsigned Align, > const Value *DstSV, uint64_t DstOff) { > return SDValue(); > } > > Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) > +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Fri Apr 2 13:43:02 2010 > @@ -46,8 +46,8 @@ > > /// EmitMemCpy - Emit a call to the memcpy function to the builder. This > /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, > - bool isVolatile, IRBuilder<> &B, const TargetData *TD); > + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, > + unsigned Align, IRBuilder<> &B, const TargetData *TD); > > /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. > /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src > @@ -57,8 +57,8 @@ > > /// EmitMemMove - Emit a call to the memmove function to the builder. This > /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, > - bool isVolatile, IRBuilder<> &B, const TargetData *TD); > + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, > + unsigned Align, IRBuilder<> &B, const TargetData *TD); > > /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is > /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. > @@ -70,8 +70,8 @@ > const TargetData *TD); > > /// EmitMemSet - Emit a call to the memset function > - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, > - IRBuilder<> &B, const TargetData *TD); > + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, > + const TargetData *TD); > > /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' > /// (e.g. 'floor'). This function is known to take a single of type matching > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 13:43:02 2010 > @@ -3263,8 +3263,7 @@ > static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, SDValue Dst, > SDValue Src, uint64_t Size, > - unsigned Align, bool isVol, > - bool AlwaysInline, > + unsigned Align, bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff) { > const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > @@ -3320,7 +3319,7 @@ > Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); > Store = DAG.getStore(Chain, dl, Value, > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, isVol, false, Align); > + DstSV, DstSVOff + DstOff, false, false, Align); > } else { > // The type might not be legal for the target. This should only happen > // if the type is smaller than a legal type, as on PPC, so the right > @@ -3331,11 +3330,11 @@ > assert(NVT.bitsGE(VT)); > Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, > getMemBasePlusOffset(Src, SrcOff, DAG), > - SrcSV, SrcSVOff + SrcOff, VT, isVol, false, > + SrcSV, SrcSVOff + SrcOff, VT, false, false, > MinAlign(SrcAlign, SrcOff)); > Store = DAG.getTruncStore(Chain, dl, Value, > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, VT, isVol, false, > + DstSV, DstSVOff + DstOff, VT, false, false, > Align); > } > OutChains.push_back(Store); > @@ -3350,8 +3349,7 @@ > static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, SDValue Dst, > SDValue Src, uint64_t Size, > - unsigned Align, bool isVol, > - bool AlwaysInline, > + unsigned Align,bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff) { > const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > @@ -3399,7 +3397,7 @@ > > Value = DAG.getLoad(VT, dl, Chain, > getMemBasePlusOffset(Src, SrcOff, DAG), > - SrcSV, SrcSVOff + SrcOff, isVol, false, SrcAlign); > + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); > LoadValues.push_back(Value); > LoadChains.push_back(Value.getValue(1)); > SrcOff += VTSize; > @@ -3414,7 +3412,7 @@ > > Store = DAG.getStore(Chain, dl, LoadValues[i], > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, isVol, false, Align); > + DstSV, DstSVOff + DstOff, false, false, Align); > OutChains.push_back(Store); > DstOff += VTSize; > } > @@ -3426,7 +3424,7 @@ > static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, SDValue Dst, > SDValue Src, uint64_t Size, > - unsigned Align, bool isVol, > + unsigned Align, > const Value *DstSV, uint64_t DstSVOff) { > const TargetLowering &TLI = DAG.getTargetLoweringInfo(); > > @@ -3465,7 +3463,7 @@ > SDValue Value = getMemsetValue(Src, VT, DAG, dl); > SDValue Store = DAG.getStore(Chain, dl, Value, > getMemBasePlusOffset(Dst, DstOff, DAG), > - DstSV, DstSVOff + DstOff, isVol, false, 0); > + DstSV, DstSVOff + DstOff, false, false, 0); > OutChains.push_back(Store); > DstOff += VTSize; > } > @@ -3476,7 +3474,7 @@ > > SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, > SDValue Src, SDValue Size, > - unsigned Align, bool isVol, bool AlwaysInline, > + unsigned Align, bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff) { > > @@ -3490,7 +3488,7 @@ > > SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > ConstantSize->getZExtValue(),Align, > - isVol, false, DstSV, DstSVOff, SrcSV, SrcSVOff); > + false, DstSV, DstSVOff, SrcSV, SrcSVOff); > if (Result.getNode()) > return Result; > } > @@ -3499,7 +3497,7 @@ > // code. If the target chooses to do this, this is the next best. > SDValue Result = > TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, > - isVol, AlwaysInline, > + AlwaysInline, > DstSV, DstSVOff, SrcSV, SrcSVOff); > if (Result.getNode()) > return Result; > @@ -3509,12 +3507,11 @@ > if (AlwaysInline) { > assert(ConstantSize && "AlwaysInline requires a constant size!"); > return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, > - ConstantSize->getZExtValue(), Align, isVol, > - true, DstSV, DstSVOff, SrcSV, SrcSVOff); > + ConstantSize->getZExtValue(), Align, true, > + DstSV, DstSVOff, SrcSV, SrcSVOff); > } > > // Emit a library call. > - assert(!isVol && "library memcpy does not support volatile"); > TargetLowering::ArgListTy Args; > TargetLowering::ArgListEntry Entry; > Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); > @@ -3535,7 +3532,7 @@ > > SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, > SDValue Src, SDValue Size, > - unsigned Align, bool isVol, > + unsigned Align, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff) { > > @@ -3549,8 +3546,8 @@ > > SDValue Result = > getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, > - ConstantSize->getZExtValue(), Align, isVol, > - false, DstSV, DstSVOff, SrcSV, SrcSVOff); > + ConstantSize->getZExtValue(), > + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); > if (Result.getNode()) > return Result; > } > @@ -3558,13 +3555,12 @@ > // Then check to see if we should lower the memmove with target-specific > // code. If the target chooses to do this, this is the next best. > SDValue Result = > - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, > + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, > DstSV, DstSVOff, SrcSV, SrcSVOff); > if (Result.getNode()) > return Result; > > // Emit a library call. > - assert(!isVol && "library memmove does not support volatile"); > TargetLowering::ArgListTy Args; > TargetLowering::ArgListEntry Entry; > Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); > @@ -3585,7 +3581,7 @@ > > SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, > SDValue Src, SDValue Size, > - unsigned Align, bool isVol, > + unsigned Align, > const Value *DstSV, uint64_t DstSVOff) { > > // Check to see if we should lower the memset to stores first. > @@ -3598,7 +3594,7 @@ > > SDValue Result = > getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), > - Align, isVol, DstSV, DstSVOff); > + Align, DstSV, DstSVOff); > if (Result.getNode()) > return Result; > } > @@ -3606,13 +3602,12 @@ > // Then check to see if we should lower the memset with target-specific > // code. If the target chooses to do this, this is the next best. > SDValue Result = > - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, > + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, > DstSV, DstSVOff); > if (Result.getNode()) > return Result; > > // Emit a library call. > - assert(!isVol && "library memset does not support volatile"); > const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); > TargetLowering::ArgListTy Args; > TargetLowering::ArgListEntry Entry; > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Apr 2 13:43:02 2010 > @@ -3731,50 +3731,28 @@ > case Intrinsic::longjmp: > return "_longjmp"+!TLI.usesUnderscoreLongJmp(); > case Intrinsic::memcpy: { > - // Assert for address < 256 since we support only user defined address > - // spaces. > - assert(cast(I.getOperand(1)->getType())->getAddressSpace() > - < 256 && > - cast(I.getOperand(2)->getType())->getAddressSpace() > - < 256 && > - "Unknown address space"); > SDValue Op1 = getValue(I.getOperand(1)); > SDValue Op2 = getValue(I.getOperand(2)); > SDValue Op3 = getValue(I.getOperand(3)); > unsigned Align = cast(I.getOperand(4))->getZExtValue(); > - bool isVol = cast(I.getOperand(5))->getZExtValue(); > - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, > + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, > I.getOperand(1), 0, I.getOperand(2), 0)); > return 0; > } > case Intrinsic::memset: { > - // Assert for address < 256 since we support only user defined address > - // spaces. > - assert(cast(I.getOperand(1)->getType())->getAddressSpace() > - < 256 && > - "Unknown address space"); > SDValue Op1 = getValue(I.getOperand(1)); > SDValue Op2 = getValue(I.getOperand(2)); > SDValue Op3 = getValue(I.getOperand(3)); > unsigned Align = cast(I.getOperand(4))->getZExtValue(); > - bool isVol = cast(I.getOperand(5))->getZExtValue(); > - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, > I.getOperand(1), 0)); > return 0; > } > case Intrinsic::memmove: { > - // Assert for address < 256 since we support only user defined address > - // spaces. > - assert(cast(I.getOperand(1)->getType())->getAddressSpace() > - < 256 && > - cast(I.getOperand(2)->getType())->getAddressSpace() > - < 256 && > - "Unknown address space"); > SDValue Op1 = getValue(I.getOperand(1)); > SDValue Op2 = getValue(I.getOperand(2)); > SDValue Op3 = getValue(I.getOperand(3)); > unsigned Align = cast(I.getOperand(4))->getZExtValue(); > - bool isVol = cast(I.getOperand(5))->getZExtValue(); > > // If the source and destination are known to not be aliases, we can > // lower memmove as memcpy. > @@ -3783,12 +3761,12 @@ > Size = C->getZExtValue(); > if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == > AliasAnalysis::NoAlias) { > - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > - false, I.getOperand(1), 0, I.getOperand(2), 0)); > + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, > + I.getOperand(1), 0, I.getOperand(2), 0)); > return 0; > } > > - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, > + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, > I.getOperand(1), 0, I.getOperand(2), 0)); > return 0; > } > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Apr 2 13:43:02 2010 > @@ -861,8 +861,7 @@ > DebugLoc dl) { > SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); > return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - /*isVolatile=*/false, /*AlwaysInline=*/false, > - NULL, 0, NULL, 0); > + /*AlwaysInline=*/false, NULL, 0, NULL, 0); > } > > /// LowerMemOpCallTo - Store the argument to the stack. > @@ -2054,7 +2053,7 @@ > SDValue Chain, > SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, bool AlwaysInline, > + bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff){ > // Do repeated 4-byte loads and stores. To be improved. > @@ -2090,7 +2089,7 @@ > Loads[i] = DAG.getLoad(VT, dl, Chain, > DAG.getNode(ISD::ADD, dl, MVT::i32, Src, > DAG.getConstant(SrcOff, MVT::i32)), > - SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); > + SrcSV, SrcSVOff + SrcOff, false, false, 0); > TFOps[i] = Loads[i].getValue(1); > SrcOff += VTSize; > } > @@ -2101,7 +2100,7 @@ > TFOps[i] = DAG.getStore(Chain, dl, Loads[i], > DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, > DAG.getConstant(DstOff, MVT::i32)), > - DstSV, DstSVOff + DstOff, isVolatile, false, 0); > + DstSV, DstSVOff + DstOff, false, false, 0); > DstOff += VTSize; > } > Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Apr 2 13:43:02 2010 > @@ -305,7 +305,7 @@ > SDValue Chain, > SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, bool AlwaysInline, > + bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff); > SDValue LowerCallResult(SDValue Chain, SDValue InFlag, > > Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Apr 2 13:43:02 2010 > @@ -2392,7 +2392,7 @@ > DebugLoc dl) { > SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); > return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - false, false, NULL, 0, NULL, 0); > + false, NULL, 0, NULL, 0); > } > > /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 2 13:43:02 2010 > @@ -1433,8 +1433,7 @@ > DebugLoc dl) { > SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); > return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), > - /*isVolatile*/false, /*AlwaysInline=*/true, > - NULL, 0, NULL, 0); > + /*AlwaysInline=*/true, NULL, 0, NULL, 0); > } > > /// IsTailCallConvention - Return true if the calling convention is one that > @@ -6551,7 +6550,6 @@ > SDValue Chain, > SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, > const Value *DstSV, > uint64_t DstSVOff) { > ConstantSDNode *ConstantSize = dyn_cast(Size); > @@ -6680,7 +6678,7 @@ > DAG.getConstant(Offset, AddrVT)), > Src, > DAG.getConstant(BytesLeft, SizeVT), > - Align, isVolatile, DstSV, DstSVOff + Offset); > + Align, DstSV, DstSVOff + Offset); > } > > // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. > @@ -6691,7 +6689,7 @@ > X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, bool AlwaysInline, > + bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff) { > // This requires the copy size to be a constant, preferrably > @@ -6750,7 +6748,7 @@ > DAG.getNode(ISD::ADD, dl, SrcVT, Src, > DAG.getConstant(Offset, SrcVT)), > DAG.getConstant(BytesLeft, SizeVT), > - Align, isVolatile, AlwaysInline, > + Align, AlwaysInline, > DstSV, DstSVOff + Offset, > SrcSV, SrcSVOff + Offset)); > } > @@ -6833,8 +6831,8 @@ > DebugLoc dl = Op.getDebugLoc(); > > return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, > - DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, > - false, DstSV, 0, SrcSV, 0); > + DAG.getIntPtrConstant(24), 8, false, > + DstSV, 0, SrcSV, 0); > } > > SDValue > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Apr 2 13:43:02 2010 > @@ -737,13 +737,12 @@ > SDValue Chain, > SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, > const Value *DstSV, uint64_t DstSVOff); > SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, > SDValue Chain, > SDValue Dst, SDValue Src, > SDValue Size, unsigned Align, > - bool isVolatile, bool AlwaysInline, > + bool AlwaysInline, > const Value *DstSV, uint64_t DstSVOff, > const Value *SrcSV, uint64_t SrcSVOff); > > @@ -753,7 +752,7 @@ > /// block, the number of args, and whether or not the second arg is > /// in memory or not. > MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, > - unsigned argNum, bool inMem) const; > + unsigned argNum, bool inMem) const; > > /// Utility function to emit atomic bitwise operations (and, or, xor). > /// It takes the bitwise instruction to expand, the associated machine basic > > Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Apr 2 13:43:02 2010 > @@ -1443,7 +1443,7 @@ > return DAG.getMemmove(Chain, dl, ST->getBasePtr(), > LD->getBasePtr(), > DAG.getConstant(StoreBits/8, MVT::i32), > - Alignment, false, ST->getSrcValue(), > + Alignment, ST->getSrcValue(), > ST->getSrcValueOffset(), LD->getSrcValue(), > LD->getSrcValueOffset()); > } > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Apr 2 13:43:02 2010 > @@ -136,14 +136,8 @@ > return 0; // If not 1/2/4/8 bytes, exit. > > // Use an integer load+store unless we can find something better. > - unsigned SrcAddrSp = > - cast(MI->getOperand(2)->getType())->getAddressSpace(); > - unsigned DstAddrSp = > - cast(MI->getOperand(1)->getType())->getAddressSpace(); > - > - const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); > - Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); > - Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); > + Type *NewPtrTy = > + PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); > > // Memcpy forces the use of i8* for the source and destination. That means > // that if you're using memcpy to move one double around, you'll get a cast > @@ -173,10 +167,8 @@ > break; > } > > - if (SrcETy->isSingleValueType()) { > - NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); > - NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); > - } > + if (SrcETy->isSingleValueType()) > + NewPtrTy = PointerType::getUnqual(SrcETy); > } > } > > @@ -186,12 +178,11 @@ > SrcAlign = std::max(SrcAlign, CopyAlign); > DstAlign = std::max(DstAlign, CopyAlign); > > - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); > - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); > - Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); > + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); > + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); > + Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); > InsertNewInstBefore(L, *MI); > - InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), > - *MI); > + InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); > > // Set the size of the copy to 0, it will be deleted on the next iteration. > MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); > @@ -284,11 +275,10 @@ > if (GVSrc->isConstant()) { > Module *M = CI.getParent()->getParent()->getParent(); > Intrinsic::ID MemCpyID = Intrinsic::memcpy; > - const Type *Tys[3] = { CI.getOperand(1)->getType(), > - CI.getOperand(2)->getType(), > - CI.getOperand(3)->getType() }; > + const Type *Tys[1]; > + Tys[0] = CI.getOperand(3)->getType(); > CI.setOperand(0, > - Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); > + Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); > Changed = true; > } > } > > Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri Apr 2 13:43:02 2010 > @@ -413,6 +413,7 @@ > // interesting as a small compile-time optimization. > Ranges.addStore(0, SI); > > + Function *MemSetF = 0; > > // Now that we have full information about ranges, loop over the ranges and > // emit memset's for anything big enough to be worthwhile. > @@ -432,40 +433,29 @@ > // memset block. This ensure that the memset is dominated by any addressing > // instruction needed by the start of the block. > BasicBlock::iterator InsertPt = BI; > - > + > + if (MemSetF == 0) { > + const Type *Ty = Type::getInt64Ty(Context); > + MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); > + } > + > // Get the starting pointer of the block. > StartPtr = Range.StartPtr; > - > - // Determine alignment > - unsigned Alignment = Range.Alignment; > - if (Alignment == 0) { > - const Type *EltType = > - cast(StartPtr->getType())->getElementType(); > - Alignment = TD->getABITypeAlignment(EltType); > - } > - > + > // Cast the start ptr to be i8* as memset requires. > - const PointerType* StartPTy = cast(StartPtr->getType()); > - const PointerType *i8Ptr = Type::getInt8PtrTy(Context, > - StartPTy->getAddressSpace()); > - if (StartPTy!= i8Ptr) > + const Type *i8Ptr = Type::getInt8PtrTy(Context); > + if (StartPtr->getType() != i8Ptr) > StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), > InsertPt); > - > + > Value *Ops[] = { > StartPtr, ByteVal, // Start, value > // size > ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), > // align > - ConstantInt::get(Type::getInt32Ty(Context), Alignment), > - // volatile > - ConstantInt::get(Type::getInt1Ty(Context), 0), > + ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) > }; > - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; > - > - Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > - > - Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); > + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); > DEBUG(dbgs() << "Replace stores:\n"; > for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) > dbgs() << *Range.TheStores[i]; > @@ -690,19 +680,16 @@ > return false; > > // If all checks passed, then we can transform these memcpy's > - const Type *ArgTys[3] = { M->getRawDest()->getType(), > - MDep->getRawSource()->getType(), > - M->getLength()->getType() }; > + const Type *Ty = M->getLength()->getType(); > Function *MemCpyFun = Intrinsic::getDeclaration( > M->getParent()->getParent()->getParent(), > - M->getIntrinsicID(), ArgTys, 3); > + M->getIntrinsicID(), &Ty, 1); > > - Value *Args[5] = { > - M->getRawDest(), MDep->getRawSource(), M->getLength(), > - M->getAlignmentCst(), M->getVolatileCst() > + Value *Args[4] = { > + M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() > }; > > - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); > + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); > > > // If C and M don't interfere, then this is a valid transformation. If they > @@ -741,10 +728,8 @@ > > // If not, then we know we can transform this. > Module *Mod = M->getParent()->getParent()->getParent(); > - const Type *ArgTys[3] = { M->getRawDest()->getType(), > - M->getRawSource()->getType(), > - M->getLength()->getType() }; > - M->setOperand(0,Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); > + const Type *Ty = M->getLength()->getType(); > + M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); > > // MemDep may have over conservative information about this instruction, just > // conservatively flush it from the cache. > > Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Apr 2 13:43:02 2010 > @@ -858,17 +858,8 @@ > EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); > > // Cast the other pointer (if we have one) to BytePtrTy. > - if (OtherElt && OtherElt->getType() != BytePtrTy) { > - // Preserve address space of OtherElt > - const PointerType* OtherPTy = cast(OtherElt->getType()); > - const PointerType* PTy = cast(BytePtrTy); > - if (OtherPTy->getElementType() != PTy->getElementType()) { > - Type *NewOtherPTy = PointerType::get(PTy->getElementType(), > - OtherPTy->getAddressSpace()); > - OtherElt = new BitCastInst(OtherElt, NewOtherPTy, > - OtherElt->getNameStr(), MI); > - } > - } > + if (OtherElt && OtherElt->getType() != BytePtrTy) > + OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); > > unsigned EltSize = TD->getTypeAllocSize(EltTy); > > @@ -879,28 +870,17 @@ > SROADest ? OtherElt : EltPtr, // Src ptr > ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size > // Align > - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), > - MI->getVolatileCst() > + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) > }; > - // In case we fold the address space overloaded memcpy of A to B > - // with memcpy of B to C, change the function to be a memcpy of A to C. > - const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), > - Ops[2]->getType() }; > - Module *M = MI->getParent()->getParent()->getParent(); > - TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); > - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); > + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); > } else { > assert(isa(MI)); > Value *Ops[] = { > EltPtr, MI->getOperand(2), // Dest, Value, > ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size > - Zero, // Align > - ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile > + Zero // Align > }; > - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; > - Module *M = MI->getParent()->getParent()->getParent(); > - TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); > + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); > } > } > DeadInsts.push_back(MI); > > Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Apr 2 13:43:02 2010 > @@ -142,8 +142,7 @@ > // We have enough information to now generate the memcpy call to do the > // concatenation for us. Make a memcpy to copy the nul byte with align = 1. > EmitMemCpy(CpyDst, Src, > - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), > - 1, false, B, TD); > + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); > } > }; > > @@ -384,8 +383,7 @@ > CI->getOperand(3), B, TD); > else > EmitMemCpy(Dst, Src, > - ConstantInt::get(TD->getIntPtrType(*Context), Len), > - 1, false, B, TD); > + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); > return Dst; > } > }; > @@ -413,8 +411,8 @@ > > if (SrcLen == 0) { > // strncpy(x, "", y) -> memset(x, '\0', y, 1) > - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), > - LenOp, false, B, TD); > + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, > + B, TD); > return Dst; > } > > @@ -434,8 +432,7 @@ > > // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] > EmitMemCpy(Dst, Src, > - ConstantInt::get(TD->getIntPtrType(*Context), Len), > - 1, false, B, TD); > + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); > > return Dst; > } > @@ -596,7 +593,7 @@ > > // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) > EmitMemCpy(CI->getOperand(1), CI->getOperand(2), > - CI->getOperand(3), 1, false, B, TD); > + CI->getOperand(3), 1, B, TD); > return CI->getOperand(1); > } > }; > @@ -618,7 +615,7 @@ > > // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) > EmitMemMove(CI->getOperand(1), CI->getOperand(2), > - CI->getOperand(3), 1, false, B, TD); > + CI->getOperand(3), 1, B, TD); > return CI->getOperand(1); > } > }; > @@ -640,8 +637,8 @@ > > // memset(p, v, n) -> llvm.memset(p, v, n, 1) > Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), > - false); > - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); > + false); > + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); > return CI->getOperand(1); > } > }; > @@ -1002,7 +999,7 @@ > // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) > EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. > ConstantInt::get(TD->getIntPtrType(*Context), > - FormatStr.size()+1), 1, false, B, TD); > + FormatStr.size()+1), 1, B, TD); > return ConstantInt::get(CI->getType(), FormatStr.size()); > } > > @@ -1016,11 +1013,11 @@ > // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 > if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; > Value *V = B.CreateTrunc(CI->getOperand(3), > - Type::getInt8Ty(*Context), "char"); > + Type::getInt8Ty(*Context), "char"); > Value *Ptr = CastToCStr(CI->getOperand(1), B); > B.CreateStore(V, Ptr); > Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), > - "nul"); > + "nul"); > B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); > > return ConstantInt::get(CI->getType(), 1); > @@ -1037,7 +1034,7 @@ > Value *IncLen = B.CreateAdd(Len, > ConstantInt::get(Len->getType(), 1), > "leninc"); > - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); > + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); > > // The sprintf result is the unincremented number of bytes in the string. > return B.CreateIntCast(Len, CI->getType(), false); > > Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Fri Apr 2 13:43:02 2010 > @@ -109,16 +109,15 @@ > > /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always > /// expects that Len has type 'intptr_t' and Dst/Src are pointers. > -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, > - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, > + unsigned Align, IRBuilder<> &B, const TargetData *TD) { > Module *M = B.GetInsertBlock()->getParent()->getParent(); > - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; > - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); > + const Type *Ty = Len->getType(); > + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); > Dst = CastToCStr(Dst, B); > Src = CastToCStr(Src, B); > - return B.CreateCall5(MemCpy, Dst, Src, Len, > - ConstantInt::get(B.getInt32Ty(), Align), > - ConstantInt::get(B.getInt1Ty(), isVolatile)); > + return B.CreateCall4(MemCpy, Dst, Src, Len, > + ConstantInt::get(B.getInt32Ty(), Align)); > } > > /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. > @@ -147,18 +146,16 @@ > > /// EmitMemMove - Emit a call to the memmove function to the builder. This > /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. > -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, > - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, > + unsigned Align, IRBuilder<> &B, const TargetData *TD) { > Module *M = B.GetInsertBlock()->getParent()->getParent(); > LLVMContext &Context = B.GetInsertBlock()->getContext(); > - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), > - TD->getIntPtrType(Context) }; > - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); > + const Type *Ty = TD->getIntPtrType(Context); > + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); > Dst = CastToCStr(Dst, B); > Src = CastToCStr(Src, B); > Value *A = ConstantInt::get(B.getInt32Ty(), Align); > - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); > - return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); > + return B.CreateCall4(MemMove, Dst, Src, Len, A); > } > > /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is > @@ -209,15 +206,15 @@ > } > > /// EmitMemSet - Emit a call to the memset function > -Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, > - IRBuilder<> &B, const TargetData *TD) { > +Value *llvm::EmitMemSet(Value *Dst, Value *Val, > + Value *Len, IRBuilder<> &B, const TargetData *TD) { > Module *M = B.GetInsertBlock()->getParent()->getParent(); > Intrinsic::ID IID = Intrinsic::memset; > - const Type *Tys[2] = { Dst->getType(), Len->getType() }; > - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); > + const Type *Tys[1]; > + Tys[0] = Len->getType(); > + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); > Value *Align = ConstantInt::get(B.getInt32Ty(), 1); > - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); > - return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); > + return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); > } > > /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. > @@ -384,7 +381,7 @@ > if (Name == "__memcpy_chk") { > if (isFoldable(4, 3, false)) { > EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), > - 1, false, B, TD); > + 1, B, TD); > replaceCall(CI->getOperand(1)); > return true; > } > @@ -399,7 +396,7 @@ > if (Name == "__memmove_chk") { > if (isFoldable(4, 3, false)) { > EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), > - 1, false, B, TD); > + 1, B, TD); > replaceCall(CI->getOperand(1)); > return true; > } > @@ -410,7 +407,7 @@ > if (isFoldable(4, 3, false)) { > Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), > false); > - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); > + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); > replaceCall(CI->getOperand(1)); > return true; > } > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Apr 2 13:43:02 2010 > @@ -297,10 +297,10 @@ > I->getName(), > &*Caller->begin()->begin()); > // Emit a memcpy. > - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > + const Type *Tys[] = { Type::getInt64Ty(Context) }; > Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), > Intrinsic::memcpy, > - Tys, 3); > + Tys, 1); > Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); > Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); > > @@ -309,18 +309,17 @@ > Size = ConstantExpr::getSizeOf(AggTy); > else > Size = ConstantInt::get(Type::getInt64Ty(Context), > - TD->getTypeStoreSize(AggTy)); > + TD->getTypeStoreSize(AggTy)); > > // Always generate a memcpy of alignment 1 here because we don't know > // the alignment of the src pointer. Other optimizations can infer > // better alignment. > Value *CallArgs[] = { > DestCast, SrcCast, Size, > - ConstantInt::get(Type::getInt32Ty(Context), 1), > - ConstantInt::get(Type::getInt1Ty(Context), 0) > + ConstantInt::get(Type::getInt32Ty(Context), 1) > }; > CallInst *TheMemCpy = > - CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); > + CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); > > // If we have a call graph, update it. > if (CG) { > > Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) > +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Apr 2 13:43:02 2010 > @@ -145,54 +145,6 @@ > } > break; > > - case 'm': { > - // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the > - // new format that allows overloading the pointer for different address > - // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) > - const char* NewFnName = NULL; > - if (Name.compare(5,8,"memcpy.i",8) == 0) { > - if (Name[13] == '8') > - NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; > - else if (Name.compare(13,2,"16") == 0) > - NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; > - else if (Name.compare(13,2,"32") == 0) > - NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; > - else if (Name.compare(13,2,"64") == 0) > - NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; > - } else if (Name.compare(5,9,"memmove.i",9) == 0) { > - if (Name[14] == '8') > - NewFnName = "llvm.memmove.p0i8.p0i8.i8"; > - else if (Name.compare(14,2,"16") == 0) > - NewFnName = "llvm.memmove.p0i8.p0i8.i16"; > - else if (Name.compare(14,2,"32") == 0) > - NewFnName = "llvm.memmove.p0i8.p0i8.i32"; > - else if (Name.compare(14,2,"64") == 0) > - NewFnName = "llvm.memmove.p0i8.p0i8.i64"; > - } > - else if (Name.compare(5,8,"memset.i",8) == 0) { > - if (Name[13] == '8') > - NewFnName = "llvm.memset.p0i8.i8"; > - else if (Name.compare(13,2,"16") == 0) > - NewFnName = "llvm.memset.p0i8.i16"; > - else if (Name.compare(13,2,"32") == 0) > - NewFnName = "llvm.memset.p0i8.i32"; > - else if (Name.compare(13,2,"64") == 0) > - NewFnName = "llvm.memset.p0i8.i64"; > - } > - if (NewFnName) { > - const FunctionType *FTy = F->getFunctionType(); > - NewFn = cast(M->getOrInsertFunction(NewFnName, > - FTy->getReturnType(), > - FTy->getParamType(0), > - FTy->getParamType(1), > - FTy->getParamType(2), > - FTy->getParamType(3), > - Type::getInt1Ty(F->getContext()), > - (Type *)0)); > - return true; > - } > - break; > - } > case 'p': > // This upgrades the llvm.part.select overloaded intrinsic names to only > // use one type specifier in the name. We only care about the old format > @@ -520,28 +472,6 @@ > CI->eraseFromParent(); > } > break; > - case Intrinsic::memcpy: > - case Intrinsic::memmove: > - case Intrinsic::memset: { > - // Add isVolatile > - const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); > - Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), > - CI->getOperand(3), CI->getOperand(4), > - llvm::ConstantInt::get(I1Ty, 0) }; > - CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, > - CI->getName(), CI); > - NewCI->setTailCall(CI->isTailCall()); > - NewCI->setCallingConv(CI->getCallingConv()); > - // Handle any uses of the old CallInst. > - if (!CI->use_empty()) > - // Replace all uses of the old call with the new cast which has the > - // correct type. > - CI->replaceAllUsesWith(NewCI); > - > - // Clean up the old call now that it has been completely upgraded. > - CI->eraseFromParent(); > - break; > - } > } > } > > > Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) > +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Fri Apr 2 13:43:02 2010 > @@ -103,7 +103,7 @@ > ret i32 %sub > ; CHECK: @test4 > ; CHECK: load i32* @G > -; CHECK: memset.p0i8.i32 > +; CHECK: memset.i32 > ; CHECK-NOT: load > ; CHECK: sub i32 %tmp, %tmp > } > @@ -118,7 +118,7 @@ > ret i32 %sub > ; CHECK: @test5 > ; CHECK: load i32* @G > -; CHECK: memcpy.p0i8.p0i8.i32 > +; CHECK: memcpy.i32 > ; CHECK-NOT: load > ; CHECK: sub i32 %tmp, %tmp > } > > Modified: llvm/trunk/test/Bitcode/memcpy.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/memcpy.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Bitcode/memcpy.ll (original) > +++ llvm/trunk/test/Bitcode/memcpy.ll Fri Apr 2 13:43:02 2010 > @@ -8,7 +8,6 @@ > tail call void @llvm.memcpy.i64( i8* %tmp.1, i8* %tmp.3, i64 100000, i32 1 ) > tail call void @llvm.memset.i32( i8* %tmp.3, i8 14, i32 10000, i32 0 ) > tail call void @llvm.memmove.i32( i8* %tmp.1, i8* %tmp.3, i32 123124, i32 1 ) > - tail call void @llvm.memmove.i64( i8* %tmp.1, i8* %tmp.3, i64 123124, i32 1 ) > ret void > } > > @@ -20,4 +19,3 @@ > > declare void @llvm.memmove.i32(i8*, i8*, i32, i32) > > -declare void @llvm.memmove.i64(i8*, i8*, i32, i32) > > Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Fri Apr 2 13:43:02 2010 > @@ -7,7 +7,7 @@ > > define i32 @t() nounwind ssp { > ; CHECK: @t > -; CHECK: @llvm.memset.p0i8.i64 > +; CHECK: @llvm.memset.i64 > entry: > %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] > %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] > > Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Fri Apr 2 13:43:02 2010 > @@ -113,7 +113,7 @@ > %1 = bitcast %struct.data* %0 to i8* > %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind > ; CHECK-NOT: @llvm.objectsize > -; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) > +; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) > %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind > ret i32 0 > } > @@ -128,7 +128,7 @@ > %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) > %2 = load i8** @s, align 8 > ; CHECK-NOT: @llvm.objectsize > -; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) > +; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) > %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind > ret void > } > > Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) > +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Fri Apr 2 13:43:02 2010 > @@ -4,7 +4,7 @@ > ; The resulting memset is only 4-byte aligned, despite containing > ; a 16-byte alignmed store in the middle. > > -; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) > +; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) > > define void @foo(i32* %p) { > %a0 = getelementptr i32* %p, i64 0 > > Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) > +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Fri Apr 2 13:43:02 2010 > @@ -21,7 +21,7 @@ > %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 > %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 > %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) > -; CHECK: @llvm.memcpy.p0i8.p0i8.i32 > +; CHECK: @llvm.memcpy.i32 > ret i32 0 > } > > > Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=100199&r1=100198&r2=100199&view=diff > ============================================================================== > --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) > +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Fri Apr 2 13:43:02 2010 > @@ -1,7 +1,7 @@ > ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} > ; PR1047 > > -define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { > +define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { > entry: > ret void > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From benny.kra at googlemail.com Fri Apr 2 14:09:51 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 02 Apr 2010 19:09:51 -0000 Subject: [llvm-commits] [llvm] r100206 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <20100402190951.ED1F82A6C12C@llvm.org> Author: d0k Date: Fri Apr 2 14:09:51 2010 New Revision: 100206 URL: http://llvm.org/viewvc/llvm-project?rev=100206&view=rev Log: Update CMake. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=100206&r1=100205&r2=100206&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Fri Apr 2 14:09:51 2010 @@ -27,6 +27,7 @@ MachineFunction.cpp MachineFunctionAnalysis.cpp MachineFunctionPass.cpp + MachineFunctionPrinterPass.cpp MachineInstr.cpp MachineLICM.cpp MachineLoopInfo.cpp From evan.cheng at apple.com Fri Apr 2 14:14:45 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 2 Apr 2010 12:14:45 -0700 Subject: [llvm-commits] [llvm] r100199 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Bitcode/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: References: <20100402184302.D7E7F2A6C12C@llvm.org> Message-ID: <82528343-5E91-4638-9810-02F1B3D681EC@apple.com> TOT is still failing a lot of tests. Evan On Apr 2, 2010, at 11:50 AM, Bob Wilson wrote: > Are you sure? Was it the virt.cpp failure? All of the initial buildbot complaints were synced to 100192, so they were missing the clang change in 100193. > > On Apr 2, 2010, at 11:43 AM, Mon P Wang wrote: > >> Author: wangmp >> Date: Fri Apr 2 13:43:02 2010 >> New Revision: 100199 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=100199&view=rev >> Log: >> Revert r100191 since it breaks objc in clang >> >> Modified: >> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> llvm/trunk/include/llvm/IntrinsicInst.h >> llvm/trunk/include/llvm/Intrinsics.td >> llvm/trunk/include/llvm/Support/IRBuilder.h >> llvm/trunk/include/llvm/Target/TargetLowering.h >> llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >> llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >> llvm/trunk/lib/Target/ARM/ARMISelLowering.h >> llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> llvm/trunk/lib/Target/X86/X86ISelLowering.h >> llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp >> llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >> llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >> llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp >> llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >> llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp >> llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >> llvm/trunk/lib/VMCore/AutoUpgrade.cpp >> llvm/trunk/test/Analysis/BasicAA/modref.ll >> llvm/trunk/test/Bitcode/memcpy.ll >> llvm/trunk/test/Transforms/InstCombine/memset_chk.ll >> llvm/trunk/test/Transforms/InstCombine/objsize.ll >> llvm/trunk/test/Transforms/MemCpyOpt/align.ll >> llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll >> llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll >> >> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Apr 2 13:43:02 2010 >> @@ -534,17 +534,17 @@ >> SDValue getStackArgumentTokenFactor(SDValue Chain); >> >> SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >> - SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, >> + SDValue Size, unsigned Align, bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff); >> >> SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >> - SDValue Size, unsigned Align, bool isVol, >> + SDValue Size, unsigned Align, >> const Value *DstSV, uint64_t DstOSVff, >> const Value *SrcSV, uint64_t SrcSVOff); >> >> SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >> - SDValue Size, unsigned Align, bool isVol, >> + SDValue Size, unsigned Align, >> const Value *DstSV, uint64_t DstSVOff); >> >> /// getSetCC - Helper function to make it easier to build SetCC's if you just >> >> Modified: llvm/trunk/include/llvm/IntrinsicInst.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/IntrinsicInst.h (original) >> +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Apr 2 13:43:02 2010 >> @@ -133,13 +133,6 @@ >> return getAlignmentCst()->getZExtValue(); >> } >> >> - ConstantInt *getVolatileCst() const { >> - return cast(const_cast(getOperand(5))); >> - } >> - bool isVolatile() const { >> - return getVolatileCst()->getZExtValue() != 0; >> - } >> - >> /// getDest - This is just like getRawDest, but it strips off any cast >> /// instructions that feed it, giving the original input. The returned >> /// value is guaranteed to be a pointer. >> @@ -162,11 +155,7 @@ >> void setAlignment(Constant* A) { >> setOperand(4, A); >> } >> - >> - void setVolatile(Constant* V) { >> - setOperand(5, V); >> - } >> - >> + >> const Type *getAlignmentType() const { >> return getOperand(4)->getType(); >> } >> >> Modified: llvm/trunk/include/llvm/Intrinsics.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Intrinsics.td (original) >> +++ llvm/trunk/include/llvm/Intrinsics.td Fri Apr 2 13:43:02 2010 >> @@ -224,16 +224,16 @@ >> // >> >> def int_memcpy : Intrinsic<[], >> - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, >> - llvm_i32_ty, llvm_i1_ty], >> + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, >> + llvm_i32_ty], >> [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; >> def int_memmove : Intrinsic<[], >> - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, >> - llvm_i32_ty, llvm_i1_ty], >> + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, >> + llvm_i32_ty], >> [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; >> def int_memset : Intrinsic<[], >> - [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, >> - llvm_i32_ty, llvm_i1_ty], >> + [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, >> + llvm_i32_ty], >> [IntrWriteArgMem, NoCapture<0>]>; >> >> // These functions do not actually read memory, but they are sensitive to the >> >> Modified: llvm/trunk/include/llvm/Support/IRBuilder.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) >> +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Apr 2 13:43:02 2010 >> @@ -917,11 +917,6 @@ >> Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; >> return Insert(CallInst::Create(Callee, Args, Args+4), Name); >> } >> - CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, >> - Value *Arg4, Value *Arg5, const Twine &Name = "") { >> - Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; >> - return Insert(CallInst::Create(Callee, Args, Args+5), Name); >> - } >> >> template >> CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, >> >> Modified: llvm/trunk/include/llvm/Target/TargetLowering.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) >> +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 13:43:02 2010 >> @@ -1187,7 +1187,7 @@ >> EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, >> SDValue Op1, SDValue Op2, >> - SDValue Op3, unsigned Align, bool isVolatile, >> + SDValue Op3, unsigned Align, >> bool AlwaysInline, >> const Value *DstSV, uint64_t DstOff, >> const Value *SrcSV, uint64_t SrcOff) { >> @@ -1204,7 +1204,7 @@ >> EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, >> SDValue Op1, SDValue Op2, >> - SDValue Op3, unsigned Align, bool isVolatile, >> + SDValue Op3, unsigned Align, >> const Value *DstSV, uint64_t DstOff, >> const Value *SrcSV, uint64_t SrcOff) { >> return SDValue(); >> @@ -1220,7 +1220,7 @@ >> EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, >> SDValue Op1, SDValue Op2, >> - SDValue Op3, unsigned Align, bool isVolatile, >> + SDValue Op3, unsigned Align, >> const Value *DstSV, uint64_t DstOff) { >> return SDValue(); >> } >> >> Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) >> +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Fri Apr 2 13:43:02 2010 >> @@ -46,8 +46,8 @@ >> >> /// EmitMemCpy - Emit a call to the memcpy function to the builder. This >> /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. >> - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, >> - bool isVolatile, IRBuilder<> &B, const TargetData *TD); >> + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, >> + unsigned Align, IRBuilder<> &B, const TargetData *TD); >> >> /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. >> /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src >> @@ -57,8 +57,8 @@ >> >> /// EmitMemMove - Emit a call to the memmove function to the builder. This >> /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. >> - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, >> - bool isVolatile, IRBuilder<> &B, const TargetData *TD); >> + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, >> + unsigned Align, IRBuilder<> &B, const TargetData *TD); >> >> /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is >> /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. >> @@ -70,8 +70,8 @@ >> const TargetData *TD); >> >> /// EmitMemSet - Emit a call to the memset function >> - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, >> - IRBuilder<> &B, const TargetData *TD); >> + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, >> + const TargetData *TD); >> >> /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' >> /// (e.g. 'floor'). This function is known to take a single of type matching >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 13:43:02 2010 >> @@ -3263,8 +3263,7 @@ >> static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, SDValue Dst, >> SDValue Src, uint64_t Size, >> - unsigned Align, bool isVol, >> - bool AlwaysInline, >> + unsigned Align, bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff) { >> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >> @@ -3320,7 +3319,7 @@ >> Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); >> Store = DAG.getStore(Chain, dl, Value, >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, isVol, false, Align); >> + DstSV, DstSVOff + DstOff, false, false, Align); >> } else { >> // The type might not be legal for the target. This should only happen >> // if the type is smaller than a legal type, as on PPC, so the right >> @@ -3331,11 +3330,11 @@ >> assert(NVT.bitsGE(VT)); >> Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, >> getMemBasePlusOffset(Src, SrcOff, DAG), >> - SrcSV, SrcSVOff + SrcOff, VT, isVol, false, >> + SrcSV, SrcSVOff + SrcOff, VT, false, false, >> MinAlign(SrcAlign, SrcOff)); >> Store = DAG.getTruncStore(Chain, dl, Value, >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, VT, isVol, false, >> + DstSV, DstSVOff + DstOff, VT, false, false, >> Align); >> } >> OutChains.push_back(Store); >> @@ -3350,8 +3349,7 @@ >> static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, SDValue Dst, >> SDValue Src, uint64_t Size, >> - unsigned Align, bool isVol, >> - bool AlwaysInline, >> + unsigned Align,bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff) { >> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >> @@ -3399,7 +3397,7 @@ >> >> Value = DAG.getLoad(VT, dl, Chain, >> getMemBasePlusOffset(Src, SrcOff, DAG), >> - SrcSV, SrcSVOff + SrcOff, isVol, false, SrcAlign); >> + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); >> LoadValues.push_back(Value); >> LoadChains.push_back(Value.getValue(1)); >> SrcOff += VTSize; >> @@ -3414,7 +3412,7 @@ >> >> Store = DAG.getStore(Chain, dl, LoadValues[i], >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, isVol, false, Align); >> + DstSV, DstSVOff + DstOff, false, false, Align); >> OutChains.push_back(Store); >> DstOff += VTSize; >> } >> @@ -3426,7 +3424,7 @@ >> static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, SDValue Dst, >> SDValue Src, uint64_t Size, >> - unsigned Align, bool isVol, >> + unsigned Align, >> const Value *DstSV, uint64_t DstSVOff) { >> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >> >> @@ -3465,7 +3463,7 @@ >> SDValue Value = getMemsetValue(Src, VT, DAG, dl); >> SDValue Store = DAG.getStore(Chain, dl, Value, >> getMemBasePlusOffset(Dst, DstOff, DAG), >> - DstSV, DstSVOff + DstOff, isVol, false, 0); >> + DstSV, DstSVOff + DstOff, false, false, 0); >> OutChains.push_back(Store); >> DstOff += VTSize; >> } >> @@ -3476,7 +3474,7 @@ >> >> SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, >> SDValue Src, SDValue Size, >> - unsigned Align, bool isVol, bool AlwaysInline, >> + unsigned Align, bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff) { >> >> @@ -3490,7 +3488,7 @@ >> >> SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >> ConstantSize->getZExtValue(),Align, >> - isVol, false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> + false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> if (Result.getNode()) >> return Result; >> } >> @@ -3499,7 +3497,7 @@ >> // code. If the target chooses to do this, this is the next best. >> SDValue Result = >> TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, >> - isVol, AlwaysInline, >> + AlwaysInline, >> DstSV, DstSVOff, SrcSV, SrcSVOff); >> if (Result.getNode()) >> return Result; >> @@ -3509,12 +3507,11 @@ >> if (AlwaysInline) { >> assert(ConstantSize && "AlwaysInline requires a constant size!"); >> return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >> - ConstantSize->getZExtValue(), Align, isVol, >> - true, DstSV, DstSVOff, SrcSV, SrcSVOff); >> + ConstantSize->getZExtValue(), Align, true, >> + DstSV, DstSVOff, SrcSV, SrcSVOff); >> } >> >> // Emit a library call. >> - assert(!isVol && "library memcpy does not support volatile"); >> TargetLowering::ArgListTy Args; >> TargetLowering::ArgListEntry Entry; >> Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); >> @@ -3535,7 +3532,7 @@ >> >> SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, >> SDValue Src, SDValue Size, >> - unsigned Align, bool isVol, >> + unsigned Align, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff) { >> >> @@ -3549,8 +3546,8 @@ >> >> SDValue Result = >> getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, >> - ConstantSize->getZExtValue(), Align, isVol, >> - false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> + ConstantSize->getZExtValue(), >> + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); >> if (Result.getNode()) >> return Result; >> } >> @@ -3558,13 +3555,12 @@ >> // Then check to see if we should lower the memmove with target-specific >> // code. If the target chooses to do this, this is the next best. >> SDValue Result = >> - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, >> + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, >> DstSV, DstSVOff, SrcSV, SrcSVOff); >> if (Result.getNode()) >> return Result; >> >> // Emit a library call. >> - assert(!isVol && "library memmove does not support volatile"); >> TargetLowering::ArgListTy Args; >> TargetLowering::ArgListEntry Entry; >> Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); >> @@ -3585,7 +3581,7 @@ >> >> SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, >> SDValue Src, SDValue Size, >> - unsigned Align, bool isVol, >> + unsigned Align, >> const Value *DstSV, uint64_t DstSVOff) { >> >> // Check to see if we should lower the memset to stores first. >> @@ -3598,7 +3594,7 @@ >> >> SDValue Result = >> getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), >> - Align, isVol, DstSV, DstSVOff); >> + Align, DstSV, DstSVOff); >> if (Result.getNode()) >> return Result; >> } >> @@ -3606,13 +3602,12 @@ >> // Then check to see if we should lower the memset with target-specific >> // code. If the target chooses to do this, this is the next best. >> SDValue Result = >> - TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, >> + TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, >> DstSV, DstSVOff); >> if (Result.getNode()) >> return Result; >> >> // Emit a library call. >> - assert(!isVol && "library memset does not support volatile"); >> const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType(*getContext()); >> TargetLowering::ArgListTy Args; >> TargetLowering::ArgListEntry Entry; >> >> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) >> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Apr 2 13:43:02 2010 >> @@ -3731,50 +3731,28 @@ >> case Intrinsic::longjmp: >> return "_longjmp"+!TLI.usesUnderscoreLongJmp(); >> case Intrinsic::memcpy: { >> - // Assert for address < 256 since we support only user defined address >> - // spaces. >> - assert(cast(I.getOperand(1)->getType())->getAddressSpace() >> - < 256 && >> - cast(I.getOperand(2)->getType())->getAddressSpace() >> - < 256 && >> - "Unknown address space"); >> SDValue Op1 = getValue(I.getOperand(1)); >> SDValue Op2 = getValue(I.getOperand(2)); >> SDValue Op3 = getValue(I.getOperand(3)); >> unsigned Align = cast(I.getOperand(4))->getZExtValue(); >> - bool isVol = cast(I.getOperand(5))->getZExtValue(); >> - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, false, >> + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, >> I.getOperand(1), 0, I.getOperand(2), 0)); >> return 0; >> } >> case Intrinsic::memset: { >> - // Assert for address < 256 since we support only user defined address >> - // spaces. >> - assert(cast(I.getOperand(1)->getType())->getAddressSpace() >> - < 256 && >> - "Unknown address space"); >> SDValue Op1 = getValue(I.getOperand(1)); >> SDValue Op2 = getValue(I.getOperand(2)); >> SDValue Op3 = getValue(I.getOperand(3)); >> unsigned Align = cast(I.getOperand(4))->getZExtValue(); >> - bool isVol = cast(I.getOperand(5))->getZExtValue(); >> - DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, isVol, >> + DAG.setRoot(DAG.getMemset(getRoot(), dl, Op1, Op2, Op3, Align, >> I.getOperand(1), 0)); >> return 0; >> } >> case Intrinsic::memmove: { >> - // Assert for address < 256 since we support only user defined address >> - // spaces. >> - assert(cast(I.getOperand(1)->getType())->getAddressSpace() >> - < 256 && >> - cast(I.getOperand(2)->getType())->getAddressSpace() >> - < 256 && >> - "Unknown address space"); >> SDValue Op1 = getValue(I.getOperand(1)); >> SDValue Op2 = getValue(I.getOperand(2)); >> SDValue Op3 = getValue(I.getOperand(3)); >> unsigned Align = cast(I.getOperand(4))->getZExtValue(); >> - bool isVol = cast(I.getOperand(5))->getZExtValue(); >> >> // If the source and destination are known to not be aliases, we can >> // lower memmove as memcpy. >> @@ -3783,12 +3761,12 @@ >> Size = C->getZExtValue(); >> if (AA->alias(I.getOperand(1), Size, I.getOperand(2), Size) == >> AliasAnalysis::NoAlias) { >> - DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, isVol, >> - false, I.getOperand(1), 0, I.getOperand(2), 0)); >> + DAG.setRoot(DAG.getMemcpy(getRoot(), dl, Op1, Op2, Op3, Align, false, >> + I.getOperand(1), 0, I.getOperand(2), 0)); >> return 0; >> } >> >> - DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, isVol, >> + DAG.setRoot(DAG.getMemmove(getRoot(), dl, Op1, Op2, Op3, Align, >> I.getOperand(1), 0, I.getOperand(2), 0)); >> return 0; >> } >> >> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Apr 2 13:43:02 2010 >> @@ -861,8 +861,7 @@ >> DebugLoc dl) { >> SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); >> return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), >> - /*isVolatile=*/false, /*AlwaysInline=*/false, >> - NULL, 0, NULL, 0); >> + /*AlwaysInline=*/false, NULL, 0, NULL, 0); >> } >> >> /// LowerMemOpCallTo - Store the argument to the stack. >> @@ -2054,7 +2053,7 @@ >> SDValue Chain, >> SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, bool AlwaysInline, >> + bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff){ >> // Do repeated 4-byte loads and stores. To be improved. >> @@ -2090,7 +2089,7 @@ >> Loads[i] = DAG.getLoad(VT, dl, Chain, >> DAG.getNode(ISD::ADD, dl, MVT::i32, Src, >> DAG.getConstant(SrcOff, MVT::i32)), >> - SrcSV, SrcSVOff + SrcOff, isVolatile, false, 0); >> + SrcSV, SrcSVOff + SrcOff, false, false, 0); >> TFOps[i] = Loads[i].getValue(1); >> SrcOff += VTSize; >> } >> @@ -2101,7 +2100,7 @@ >> TFOps[i] = DAG.getStore(Chain, dl, Loads[i], >> DAG.getNode(ISD::ADD, dl, MVT::i32, Dst, >> DAG.getConstant(DstOff, MVT::i32)), >> - DstSV, DstSVOff + DstOff, isVolatile, false, 0); >> + DstSV, DstSVOff + DstOff, false, false, 0); >> DstOff += VTSize; >> } >> Chain = DAG.getNode(ISD::TokenFactor, dl, MVT::Other, &TFOps[0], i); >> >> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) >> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Apr 2 13:43:02 2010 >> @@ -305,7 +305,7 @@ >> SDValue Chain, >> SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, bool AlwaysInline, >> + bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff); >> SDValue LowerCallResult(SDValue Chain, SDValue InFlag, >> >> Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Apr 2 13:43:02 2010 >> @@ -2392,7 +2392,7 @@ >> DebugLoc dl) { >> SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); >> return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), >> - false, false, NULL, 0, NULL, 0); >> + false, NULL, 0, NULL, 0); >> } >> >> /// LowerMemOpCallTo - Store the argument to the stack or remember it in case of >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 2 13:43:02 2010 >> @@ -1433,8 +1433,7 @@ >> DebugLoc dl) { >> SDValue SizeNode = DAG.getConstant(Flags.getByValSize(), MVT::i32); >> return DAG.getMemcpy(Chain, dl, Dst, Src, SizeNode, Flags.getByValAlign(), >> - /*isVolatile*/false, /*AlwaysInline=*/true, >> - NULL, 0, NULL, 0); >> + /*AlwaysInline=*/true, NULL, 0, NULL, 0); >> } >> >> /// IsTailCallConvention - Return true if the calling convention is one that >> @@ -6551,7 +6550,6 @@ >> SDValue Chain, >> SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, >> const Value *DstSV, >> uint64_t DstSVOff) { >> ConstantSDNode *ConstantSize = dyn_cast(Size); >> @@ -6680,7 +6678,7 @@ >> DAG.getConstant(Offset, AddrVT)), >> Src, >> DAG.getConstant(BytesLeft, SizeVT), >> - Align, isVolatile, DstSV, DstSVOff + Offset); >> + Align, DstSV, DstSVOff + Offset); >> } >> >> // TODO: Use a Tokenfactor, as in memcpy, instead of a single chain. >> @@ -6691,7 +6689,7 @@ >> X86TargetLowering::EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, bool AlwaysInline, >> + bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff) { >> // This requires the copy size to be a constant, preferrably >> @@ -6750,7 +6748,7 @@ >> DAG.getNode(ISD::ADD, dl, SrcVT, Src, >> DAG.getConstant(Offset, SrcVT)), >> DAG.getConstant(BytesLeft, SizeVT), >> - Align, isVolatile, AlwaysInline, >> + Align, AlwaysInline, >> DstSV, DstSVOff + Offset, >> SrcSV, SrcSVOff + Offset)); >> } >> @@ -6833,8 +6831,8 @@ >> DebugLoc dl = Op.getDebugLoc(); >> >> return DAG.getMemcpy(Chain, dl, DstPtr, SrcPtr, >> - DAG.getIntPtrConstant(24), 8, /*isVolatile*/false, >> - false, DstSV, 0, SrcSV, 0); >> + DAG.getIntPtrConstant(24), 8, false, >> + DstSV, 0, SrcSV, 0); >> } >> >> SDValue >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Apr 2 13:43:02 2010 >> @@ -737,13 +737,12 @@ >> SDValue Chain, >> SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, >> const Value *DstSV, uint64_t DstSVOff); >> SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, >> SDValue Chain, >> SDValue Dst, SDValue Src, >> SDValue Size, unsigned Align, >> - bool isVolatile, bool AlwaysInline, >> + bool AlwaysInline, >> const Value *DstSV, uint64_t DstSVOff, >> const Value *SrcSV, uint64_t SrcSVOff); >> >> @@ -753,7 +752,7 @@ >> /// block, the number of args, and whether or not the second arg is >> /// in memory or not. >> MachineBasicBlock *EmitPCMP(MachineInstr *BInstr, MachineBasicBlock *BB, >> - unsigned argNum, bool inMem) const; >> + unsigned argNum, bool inMem) const; >> >> /// Utility function to emit atomic bitwise operations (and, or, xor). >> /// It takes the bitwise instruction to expand, the associated machine basic >> >> Modified: llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp Fri Apr 2 13:43:02 2010 >> @@ -1443,7 +1443,7 @@ >> return DAG.getMemmove(Chain, dl, ST->getBasePtr(), >> LD->getBasePtr(), >> DAG.getConstant(StoreBits/8, MVT::i32), >> - Alignment, false, ST->getSrcValue(), >> + Alignment, ST->getSrcValue(), >> ST->getSrcValueOffset(), LD->getSrcValue(), >> LD->getSrcValueOffset()); >> } >> >> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Fri Apr 2 13:43:02 2010 >> @@ -136,14 +136,8 @@ >> return 0; // If not 1/2/4/8 bytes, exit. >> >> // Use an integer load+store unless we can find something better. >> - unsigned SrcAddrSp = >> - cast(MI->getOperand(2)->getType())->getAddressSpace(); >> - unsigned DstAddrSp = >> - cast(MI->getOperand(1)->getType())->getAddressSpace(); >> - >> - const IntegerType* IntType = IntegerType::get(MI->getContext(), Size<<3); >> - Type *NewSrcPtrTy = PointerType::get(IntType, SrcAddrSp); >> - Type *NewDstPtrTy = PointerType::get(IntType, DstAddrSp); >> + Type *NewPtrTy = >> + PointerType::getUnqual(IntegerType::get(MI->getContext(), Size<<3)); >> >> // Memcpy forces the use of i8* for the source and destination. That means >> // that if you're using memcpy to move one double around, you'll get a cast >> @@ -173,10 +167,8 @@ >> break; >> } >> >> - if (SrcETy->isSingleValueType()) { >> - NewSrcPtrTy = PointerType::get(SrcETy, SrcAddrSp); >> - NewDstPtrTy = PointerType::get(SrcETy, DstAddrSp); >> - } >> + if (SrcETy->isSingleValueType()) >> + NewPtrTy = PointerType::getUnqual(SrcETy); >> } >> } >> >> @@ -186,12 +178,11 @@ >> SrcAlign = std::max(SrcAlign, CopyAlign); >> DstAlign = std::max(DstAlign, CopyAlign); >> >> - Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewSrcPtrTy); >> - Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewDstPtrTy); >> - Instruction *L = new LoadInst(Src, "tmp", MI->isVolatile(), SrcAlign); >> + Value *Src = Builder->CreateBitCast(MI->getOperand(2), NewPtrTy); >> + Value *Dest = Builder->CreateBitCast(MI->getOperand(1), NewPtrTy); >> + Instruction *L = new LoadInst(Src, "tmp", false, SrcAlign); >> InsertNewInstBefore(L, *MI); >> - InsertNewInstBefore(new StoreInst(L, Dest, MI->isVolatile(), DstAlign), >> - *MI); >> + InsertNewInstBefore(new StoreInst(L, Dest, false, DstAlign), *MI); >> >> // Set the size of the copy to 0, it will be deleted on the next iteration. >> MI->setOperand(3, Constant::getNullValue(MemOpLength->getType())); >> @@ -284,11 +275,10 @@ >> if (GVSrc->isConstant()) { >> Module *M = CI.getParent()->getParent()->getParent(); >> Intrinsic::ID MemCpyID = Intrinsic::memcpy; >> - const Type *Tys[3] = { CI.getOperand(1)->getType(), >> - CI.getOperand(2)->getType(), >> - CI.getOperand(3)->getType() }; >> + const Type *Tys[1]; >> + Tys[0] = CI.getOperand(3)->getType(); >> CI.setOperand(0, >> - Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); >> + Intrinsic::getDeclaration(M, MemCpyID, Tys, 1)); >> Changed = true; >> } >> } >> >> Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Fri Apr 2 13:43:02 2010 >> @@ -413,6 +413,7 @@ >> // interesting as a small compile-time optimization. >> Ranges.addStore(0, SI); >> >> + Function *MemSetF = 0; >> >> // Now that we have full information about ranges, loop over the ranges and >> // emit memset's for anything big enough to be worthwhile. >> @@ -432,40 +433,29 @@ >> // memset block. This ensure that the memset is dominated by any addressing >> // instruction needed by the start of the block. >> BasicBlock::iterator InsertPt = BI; >> - >> + >> + if (MemSetF == 0) { >> + const Type *Ty = Type::getInt64Ty(Context); >> + MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, &Ty, 1); >> + } >> + >> // Get the starting pointer of the block. >> StartPtr = Range.StartPtr; >> - >> - // Determine alignment >> - unsigned Alignment = Range.Alignment; >> - if (Alignment == 0) { >> - const Type *EltType = >> - cast(StartPtr->getType())->getElementType(); >> - Alignment = TD->getABITypeAlignment(EltType); >> - } >> - >> + >> // Cast the start ptr to be i8* as memset requires. >> - const PointerType* StartPTy = cast(StartPtr->getType()); >> - const PointerType *i8Ptr = Type::getInt8PtrTy(Context, >> - StartPTy->getAddressSpace()); >> - if (StartPTy!= i8Ptr) >> + const Type *i8Ptr = Type::getInt8PtrTy(Context); >> + if (StartPtr->getType() != i8Ptr) >> StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(), >> InsertPt); >> - >> + >> Value *Ops[] = { >> StartPtr, ByteVal, // Start, value >> // size >> ConstantInt::get(Type::getInt64Ty(Context), Range.End-Range.Start), >> // align >> - ConstantInt::get(Type::getInt32Ty(Context), Alignment), >> - // volatile >> - ConstantInt::get(Type::getInt1Ty(Context), 0), >> + ConstantInt::get(Type::getInt32Ty(Context), Range.Alignment) >> }; >> - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; >> - >> - Function *MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); >> - >> - Value *C = CallInst::Create(MemSetF, Ops, Ops+5, "", InsertPt); >> + Value *C = CallInst::Create(MemSetF, Ops, Ops+4, "", InsertPt); >> DEBUG(dbgs() << "Replace stores:\n"; >> for (unsigned i = 0, e = Range.TheStores.size(); i != e; ++i) >> dbgs() << *Range.TheStores[i]; >> @@ -690,19 +680,16 @@ >> return false; >> >> // If all checks passed, then we can transform these memcpy's >> - const Type *ArgTys[3] = { M->getRawDest()->getType(), >> - MDep->getRawSource()->getType(), >> - M->getLength()->getType() }; >> + const Type *Ty = M->getLength()->getType(); >> Function *MemCpyFun = Intrinsic::getDeclaration( >> M->getParent()->getParent()->getParent(), >> - M->getIntrinsicID(), ArgTys, 3); >> + M->getIntrinsicID(), &Ty, 1); >> >> - Value *Args[5] = { >> - M->getRawDest(), MDep->getRawSource(), M->getLength(), >> - M->getAlignmentCst(), M->getVolatileCst() >> + Value *Args[4] = { >> + M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst() >> }; >> >> - CallInst *C = CallInst::Create(MemCpyFun, Args, Args+5, "", M); >> + CallInst *C = CallInst::Create(MemCpyFun, Args, Args+4, "", M); >> >> >> // If C and M don't interfere, then this is a valid transformation. If they >> @@ -741,10 +728,8 @@ >> >> // If not, then we know we can transform this. >> Module *Mod = M->getParent()->getParent()->getParent(); >> - const Type *ArgTys[3] = { M->getRawDest()->getType(), >> - M->getRawSource()->getType(), >> - M->getLength()->getType() }; >> - M->setOperand(0,Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); >> + const Type *Ty = M->getLength()->getType(); >> + M->setOperand(0, Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, &Ty, 1)); >> >> // MemDep may have over conservative information about this instruction, just >> // conservatively flush it from the cache. >> >> Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Apr 2 13:43:02 2010 >> @@ -858,17 +858,8 @@ >> EltPtr = new BitCastInst(EltPtr, BytePtrTy, EltPtr->getName(), MI); >> >> // Cast the other pointer (if we have one) to BytePtrTy. >> - if (OtherElt && OtherElt->getType() != BytePtrTy) { >> - // Preserve address space of OtherElt >> - const PointerType* OtherPTy = cast(OtherElt->getType()); >> - const PointerType* PTy = cast(BytePtrTy); >> - if (OtherPTy->getElementType() != PTy->getElementType()) { >> - Type *NewOtherPTy = PointerType::get(PTy->getElementType(), >> - OtherPTy->getAddressSpace()); >> - OtherElt = new BitCastInst(OtherElt, NewOtherPTy, >> - OtherElt->getNameStr(), MI); >> - } >> - } >> + if (OtherElt && OtherElt->getType() != BytePtrTy) >> + OtherElt = new BitCastInst(OtherElt, BytePtrTy, OtherElt->getName(), MI); >> >> unsigned EltSize = TD->getTypeAllocSize(EltTy); >> >> @@ -879,28 +870,17 @@ >> SROADest ? OtherElt : EltPtr, // Src ptr >> ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size >> // Align >> - ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign), >> - MI->getVolatileCst() >> + ConstantInt::get(Type::getInt32Ty(MI->getContext()), OtherEltAlign) >> }; >> - // In case we fold the address space overloaded memcpy of A to B >> - // with memcpy of B to C, change the function to be a memcpy of A to C. >> - const Type *Tys[] = { Ops[0]->getType(), Ops[1]->getType(), >> - Ops[2]->getType() }; >> - Module *M = MI->getParent()->getParent()->getParent(); >> - TheFn = Intrinsic::getDeclaration(M, MI->getIntrinsicID(), Tys, 3); >> - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); >> + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); >> } else { >> assert(isa(MI)); >> Value *Ops[] = { >> EltPtr, MI->getOperand(2), // Dest, Value, >> ConstantInt::get(MI->getOperand(3)->getType(), EltSize), // Size >> - Zero, // Align >> - ConstantInt::get(Type::getInt1Ty(MI->getContext()), 0) // isVolatile >> + Zero // Align >> }; >> - const Type *Tys[] = { Ops[0]->getType(), Ops[2]->getType() }; >> - Module *M = MI->getParent()->getParent()->getParent(); >> - TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); >> - CallInst::Create(TheFn, Ops, Ops + 5, "", MI); >> + CallInst::Create(TheFn, Ops, Ops + 4, "", MI); >> } >> } >> DeadInsts.push_back(MI); >> >> Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Fri Apr 2 13:43:02 2010 >> @@ -142,8 +142,7 @@ >> // We have enough information to now generate the memcpy call to do the >> // concatenation for us. Make a memcpy to copy the nul byte with align = 1. >> EmitMemCpy(CpyDst, Src, >> - ConstantInt::get(TD->getIntPtrType(*Context), Len+1), >> - 1, false, B, TD); >> + ConstantInt::get(TD->getIntPtrType(*Context), Len+1), 1, B, TD); >> } >> }; >> >> @@ -384,8 +383,7 @@ >> CI->getOperand(3), B, TD); >> else >> EmitMemCpy(Dst, Src, >> - ConstantInt::get(TD->getIntPtrType(*Context), Len), >> - 1, false, B, TD); >> + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); >> return Dst; >> } >> }; >> @@ -413,8 +411,8 @@ >> >> if (SrcLen == 0) { >> // strncpy(x, "", y) -> memset(x, '\0', y, 1) >> - EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), >> - LenOp, false, B, TD); >> + EmitMemSet(Dst, ConstantInt::get(Type::getInt8Ty(*Context), '\0'), LenOp, >> + B, TD); >> return Dst; >> } >> >> @@ -434,8 +432,7 @@ >> >> // strncpy(x, s, c) -> memcpy(x, s, c, 1) [s and c are constant] >> EmitMemCpy(Dst, Src, >> - ConstantInt::get(TD->getIntPtrType(*Context), Len), >> - 1, false, B, TD); >> + ConstantInt::get(TD->getIntPtrType(*Context), Len), 1, B, TD); >> >> return Dst; >> } >> @@ -596,7 +593,7 @@ >> >> // memcpy(x, y, n) -> llvm.memcpy(x, y, n, 1) >> EmitMemCpy(CI->getOperand(1), CI->getOperand(2), >> - CI->getOperand(3), 1, false, B, TD); >> + CI->getOperand(3), 1, B, TD); >> return CI->getOperand(1); >> } >> }; >> @@ -618,7 +615,7 @@ >> >> // memmove(x, y, n) -> llvm.memmove(x, y, n, 1) >> EmitMemMove(CI->getOperand(1), CI->getOperand(2), >> - CI->getOperand(3), 1, false, B, TD); >> + CI->getOperand(3), 1, B, TD); >> return CI->getOperand(1); >> } >> }; >> @@ -640,8 +637,8 @@ >> >> // memset(p, v, n) -> llvm.memset(p, v, n, 1) >> Value *Val = B.CreateIntCast(CI->getOperand(2), Type::getInt8Ty(*Context), >> - false); >> - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); >> + false); >> + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); >> return CI->getOperand(1); >> } >> }; >> @@ -1002,7 +999,7 @@ >> // sprintf(str, fmt) -> llvm.memcpy(str, fmt, strlen(fmt)+1, 1) >> EmitMemCpy(CI->getOperand(1), CI->getOperand(2), // Copy the nul byte. >> ConstantInt::get(TD->getIntPtrType(*Context), >> - FormatStr.size()+1), 1, false, B, TD); >> + FormatStr.size()+1), 1, B, TD); >> return ConstantInt::get(CI->getType(), FormatStr.size()); >> } >> >> @@ -1016,11 +1013,11 @@ >> // sprintf(dst, "%c", chr) --> *(i8*)dst = chr; *((i8*)dst+1) = 0 >> if (!CI->getOperand(3)->getType()->isIntegerTy()) return 0; >> Value *V = B.CreateTrunc(CI->getOperand(3), >> - Type::getInt8Ty(*Context), "char"); >> + Type::getInt8Ty(*Context), "char"); >> Value *Ptr = CastToCStr(CI->getOperand(1), B); >> B.CreateStore(V, Ptr); >> Ptr = B.CreateGEP(Ptr, ConstantInt::get(Type::getInt32Ty(*Context), 1), >> - "nul"); >> + "nul"); >> B.CreateStore(Constant::getNullValue(Type::getInt8Ty(*Context)), Ptr); >> >> return ConstantInt::get(CI->getType(), 1); >> @@ -1037,7 +1034,7 @@ >> Value *IncLen = B.CreateAdd(Len, >> ConstantInt::get(Len->getType(), 1), >> "leninc"); >> - EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, false, B, TD); >> + EmitMemCpy(CI->getOperand(1), CI->getOperand(3), IncLen, 1, B, TD); >> >> // The sprintf result is the unincremented number of bytes in the string. >> return B.CreateIntCast(Len, CI->getType(), false); >> >> Modified: llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp Fri Apr 2 13:43:02 2010 >> @@ -109,16 +109,15 @@ >> >> /// EmitMemCpy - Emit a call to the memcpy function to the builder. This always >> /// expects that Len has type 'intptr_t' and Dst/Src are pointers. >> -Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, >> - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { >> +Value *llvm::EmitMemCpy(Value *Dst, Value *Src, Value *Len, >> + unsigned Align, IRBuilder<> &B, const TargetData *TD) { >> Module *M = B.GetInsertBlock()->getParent()->getParent(); >> - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), Len->getType() }; >> - Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, ArgTys, 3); >> + const Type *Ty = Len->getType(); >> + Value *MemCpy = Intrinsic::getDeclaration(M, Intrinsic::memcpy, &Ty, 1); >> Dst = CastToCStr(Dst, B); >> Src = CastToCStr(Src, B); >> - return B.CreateCall5(MemCpy, Dst, Src, Len, >> - ConstantInt::get(B.getInt32Ty(), Align), >> - ConstantInt::get(B.getInt1Ty(), isVolatile)); >> + return B.CreateCall4(MemCpy, Dst, Src, Len, >> + ConstantInt::get(B.getInt32Ty(), Align)); >> } >> >> /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. >> @@ -147,18 +146,16 @@ >> >> /// EmitMemMove - Emit a call to the memmove function to the builder. This >> /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. >> -Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, >> - bool isVolatile, IRBuilder<> &B, const TargetData *TD) { >> +Value *llvm::EmitMemMove(Value *Dst, Value *Src, Value *Len, >> + unsigned Align, IRBuilder<> &B, const TargetData *TD) { >> Module *M = B.GetInsertBlock()->getParent()->getParent(); >> LLVMContext &Context = B.GetInsertBlock()->getContext(); >> - const Type *ArgTys[3] = { Dst->getType(), Src->getType(), >> - TD->getIntPtrType(Context) }; >> - Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, ArgTys, 3); >> + const Type *Ty = TD->getIntPtrType(Context); >> + Value *MemMove = Intrinsic::getDeclaration(M, Intrinsic::memmove, &Ty, 1); >> Dst = CastToCStr(Dst, B); >> Src = CastToCStr(Src, B); >> Value *A = ConstantInt::get(B.getInt32Ty(), Align); >> - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); >> - return B.CreateCall5(MemMove, Dst, Src, Len, A, Vol); >> + return B.CreateCall4(MemMove, Dst, Src, Len, A); >> } >> >> /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is >> @@ -209,15 +206,15 @@ >> } >> >> /// EmitMemSet - Emit a call to the memset function >> -Value *llvm::EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, >> - IRBuilder<> &B, const TargetData *TD) { >> +Value *llvm::EmitMemSet(Value *Dst, Value *Val, >> + Value *Len, IRBuilder<> &B, const TargetData *TD) { >> Module *M = B.GetInsertBlock()->getParent()->getParent(); >> Intrinsic::ID IID = Intrinsic::memset; >> - const Type *Tys[2] = { Dst->getType(), Len->getType() }; >> - Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 2); >> + const Type *Tys[1]; >> + Tys[0] = Len->getType(); >> + Value *MemSet = Intrinsic::getDeclaration(M, IID, Tys, 1); >> Value *Align = ConstantInt::get(B.getInt32Ty(), 1); >> - Value *Vol = ConstantInt::get(B.getInt1Ty(), isVolatile); >> - return B.CreateCall5(MemSet, CastToCStr(Dst, B), Val, Len, Align, Vol); >> + return B.CreateCall4(MemSet, CastToCStr(Dst, B), Val, Len, Align); >> } >> >> /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g. >> @@ -384,7 +381,7 @@ >> if (Name == "__memcpy_chk") { >> if (isFoldable(4, 3, false)) { >> EmitMemCpy(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), >> - 1, false, B, TD); >> + 1, B, TD); >> replaceCall(CI->getOperand(1)); >> return true; >> } >> @@ -399,7 +396,7 @@ >> if (Name == "__memmove_chk") { >> if (isFoldable(4, 3, false)) { >> EmitMemMove(CI->getOperand(1), CI->getOperand(2), CI->getOperand(3), >> - 1, false, B, TD); >> + 1, B, TD); >> replaceCall(CI->getOperand(1)); >> return true; >> } >> @@ -410,7 +407,7 @@ >> if (isFoldable(4, 3, false)) { >> Value *Val = B.CreateIntCast(CI->getOperand(2), B.getInt8Ty(), >> false); >> - EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), false, B, TD); >> + EmitMemSet(CI->getOperand(1), Val, CI->getOperand(3), B, TD); >> replaceCall(CI->getOperand(1)); >> return true; >> } >> >> Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Apr 2 13:43:02 2010 >> @@ -297,10 +297,10 @@ >> I->getName(), >> &*Caller->begin()->begin()); >> // Emit a memcpy. >> - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; >> + const Type *Tys[] = { Type::getInt64Ty(Context) }; >> Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), >> Intrinsic::memcpy, >> - Tys, 3); >> + Tys, 1); >> Value *DestCast = new BitCastInst(NewAlloca, VoidPtrTy, "tmp", TheCall); >> Value *SrcCast = new BitCastInst(*AI, VoidPtrTy, "tmp", TheCall); >> >> @@ -309,18 +309,17 @@ >> Size = ConstantExpr::getSizeOf(AggTy); >> else >> Size = ConstantInt::get(Type::getInt64Ty(Context), >> - TD->getTypeStoreSize(AggTy)); >> + TD->getTypeStoreSize(AggTy)); >> >> // Always generate a memcpy of alignment 1 here because we don't know >> // the alignment of the src pointer. Other optimizations can infer >> // better alignment. >> Value *CallArgs[] = { >> DestCast, SrcCast, Size, >> - ConstantInt::get(Type::getInt32Ty(Context), 1), >> - ConstantInt::get(Type::getInt1Ty(Context), 0) >> + ConstantInt::get(Type::getInt32Ty(Context), 1) >> }; >> CallInst *TheMemCpy = >> - CallInst::Create(MemCpyFn, CallArgs, CallArgs+5, "", TheCall); >> + CallInst::Create(MemCpyFn, CallArgs, CallArgs+4, "", TheCall); >> >> // If we have a call graph, update it. >> if (CG) { >> >> Modified: llvm/trunk/lib/VMCore/AutoUpgrade.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AutoUpgrade.cpp?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/AutoUpgrade.cpp (original) >> +++ llvm/trunk/lib/VMCore/AutoUpgrade.cpp Fri Apr 2 13:43:02 2010 >> @@ -145,54 +145,6 @@ >> } >> break; >> >> - case 'm': { >> - // This upgrades the llvm.memcpy, llvm.memmove, and llvm.memset to the >> - // new format that allows overloading the pointer for different address >> - // space (e.g., llvm.memcpy.i16 => llvm.memcpy.p0i8.p0i8.i16) >> - const char* NewFnName = NULL; >> - if (Name.compare(5,8,"memcpy.i",8) == 0) { >> - if (Name[13] == '8') >> - NewFnName = "llvm.memcpy.p0i8.p0i8.i8"; >> - else if (Name.compare(13,2,"16") == 0) >> - NewFnName = "llvm.memcpy.p0i8.p0i8.i16"; >> - else if (Name.compare(13,2,"32") == 0) >> - NewFnName = "llvm.memcpy.p0i8.p0i8.i32"; >> - else if (Name.compare(13,2,"64") == 0) >> - NewFnName = "llvm.memcpy.p0i8.p0i8.i64"; >> - } else if (Name.compare(5,9,"memmove.i",9) == 0) { >> - if (Name[14] == '8') >> - NewFnName = "llvm.memmove.p0i8.p0i8.i8"; >> - else if (Name.compare(14,2,"16") == 0) >> - NewFnName = "llvm.memmove.p0i8.p0i8.i16"; >> - else if (Name.compare(14,2,"32") == 0) >> - NewFnName = "llvm.memmove.p0i8.p0i8.i32"; >> - else if (Name.compare(14,2,"64") == 0) >> - NewFnName = "llvm.memmove.p0i8.p0i8.i64"; >> - } >> - else if (Name.compare(5,8,"memset.i",8) == 0) { >> - if (Name[13] == '8') >> - NewFnName = "llvm.memset.p0i8.i8"; >> - else if (Name.compare(13,2,"16") == 0) >> - NewFnName = "llvm.memset.p0i8.i16"; >> - else if (Name.compare(13,2,"32") == 0) >> - NewFnName = "llvm.memset.p0i8.i32"; >> - else if (Name.compare(13,2,"64") == 0) >> - NewFnName = "llvm.memset.p0i8.i64"; >> - } >> - if (NewFnName) { >> - const FunctionType *FTy = F->getFunctionType(); >> - NewFn = cast(M->getOrInsertFunction(NewFnName, >> - FTy->getReturnType(), >> - FTy->getParamType(0), >> - FTy->getParamType(1), >> - FTy->getParamType(2), >> - FTy->getParamType(3), >> - Type::getInt1Ty(F->getContext()), >> - (Type *)0)); >> - return true; >> - } >> - break; >> - } >> case 'p': >> // This upgrades the llvm.part.select overloaded intrinsic names to only >> // use one type specifier in the name. We only care about the old format >> @@ -520,28 +472,6 @@ >> CI->eraseFromParent(); >> } >> break; >> - case Intrinsic::memcpy: >> - case Intrinsic::memmove: >> - case Intrinsic::memset: { >> - // Add isVolatile >> - const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); >> - Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), >> - CI->getOperand(3), CI->getOperand(4), >> - llvm::ConstantInt::get(I1Ty, 0) }; >> - CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, >> - CI->getName(), CI); >> - NewCI->setTailCall(CI->isTailCall()); >> - NewCI->setCallingConv(CI->getCallingConv()); >> - // Handle any uses of the old CallInst. >> - if (!CI->use_empty()) >> - // Replace all uses of the old call with the new cast which has the >> - // correct type. >> - CI->replaceAllUsesWith(NewCI); >> - >> - // Clean up the old call now that it has been completely upgraded. >> - CI->eraseFromParent(); >> - break; >> - } >> } >> } >> >> >> Modified: llvm/trunk/test/Analysis/BasicAA/modref.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/modref.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Analysis/BasicAA/modref.ll (original) >> +++ llvm/trunk/test/Analysis/BasicAA/modref.ll Fri Apr 2 13:43:02 2010 >> @@ -103,7 +103,7 @@ >> ret i32 %sub >> ; CHECK: @test4 >> ; CHECK: load i32* @G >> -; CHECK: memset.p0i8.i32 >> +; CHECK: memset.i32 >> ; CHECK-NOT: load >> ; CHECK: sub i32 %tmp, %tmp >> } >> @@ -118,7 +118,7 @@ >> ret i32 %sub >> ; CHECK: @test5 >> ; CHECK: load i32* @G >> -; CHECK: memcpy.p0i8.p0i8.i32 >> +; CHECK: memcpy.i32 >> ; CHECK-NOT: load >> ; CHECK: sub i32 %tmp, %tmp >> } >> >> Modified: llvm/trunk/test/Bitcode/memcpy.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/memcpy.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Bitcode/memcpy.ll (original) >> +++ llvm/trunk/test/Bitcode/memcpy.ll Fri Apr 2 13:43:02 2010 >> @@ -8,7 +8,6 @@ >> tail call void @llvm.memcpy.i64( i8* %tmp.1, i8* %tmp.3, i64 100000, i32 1 ) >> tail call void @llvm.memset.i32( i8* %tmp.3, i8 14, i32 10000, i32 0 ) >> tail call void @llvm.memmove.i32( i8* %tmp.1, i8* %tmp.3, i32 123124, i32 1 ) >> - tail call void @llvm.memmove.i64( i8* %tmp.1, i8* %tmp.3, i64 123124, i32 1 ) >> ret void >> } >> >> @@ -20,4 +19,3 @@ >> >> declare void @llvm.memmove.i32(i8*, i8*, i32, i32) >> >> -declare void @llvm.memmove.i64(i8*, i8*, i32, i32) >> >> Modified: llvm/trunk/test/Transforms/InstCombine/memset_chk.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/memset_chk.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Transforms/InstCombine/memset_chk.ll (original) >> +++ llvm/trunk/test/Transforms/InstCombine/memset_chk.ll Fri Apr 2 13:43:02 2010 >> @@ -7,7 +7,7 @@ >> >> define i32 @t() nounwind ssp { >> ; CHECK: @t >> -; CHECK: @llvm.memset.p0i8.i64 >> +; CHECK: @llvm.memset.i64 >> entry: >> %0 = alloca %struct.data, align 8 ; <%struct.data*> [#uses=1] >> %1 = bitcast %struct.data* %0 to i8* ; [#uses=1] >> >> Modified: llvm/trunk/test/Transforms/InstCombine/objsize.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/objsize.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Transforms/InstCombine/objsize.ll (original) >> +++ llvm/trunk/test/Transforms/InstCombine/objsize.ll Fri Apr 2 13:43:02 2010 >> @@ -113,7 +113,7 @@ >> %1 = bitcast %struct.data* %0 to i8* >> %2 = call i64 @llvm.objectsize.i64(i8* %1, i1 false) nounwind >> ; CHECK-NOT: @llvm.objectsize >> -; CHECK: @llvm.memset.p0i8.i64(i8* %1, i8 0, i64 1824, i32 8, i1 false) >> +; CHECK: @llvm.memset.i64(i8* %1, i8 0, i64 1824, i32 8) >> %3 = call i8* @__memset_chk(i8* %1, i32 0, i64 1824, i64 %2) nounwind >> ret i32 0 >> } >> @@ -128,7 +128,7 @@ >> %1 = tail call i32 @llvm.objectsize.i32(i8* %0, i1 false) >> %2 = load i8** @s, align 8 >> ; CHECK-NOT: @llvm.objectsize >> -; CHECK: @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 10, i32 1, i1 false) >> +; CHECK: @llvm.memcpy.i32(i8* %0, i8* %1, i32 10, i32 1) >> %3 = tail call i8* @__memcpy_chk(i8* %0, i8* %2, i32 10, i32 %1) nounwind >> ret void >> } >> >> Modified: llvm/trunk/test/Transforms/MemCpyOpt/align.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/align.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Transforms/MemCpyOpt/align.ll (original) >> +++ llvm/trunk/test/Transforms/MemCpyOpt/align.ll Fri Apr 2 13:43:02 2010 >> @@ -4,7 +4,7 @@ >> ; The resulting memset is only 4-byte aligned, despite containing >> ; a 16-byte alignmed store in the middle. >> >> -; CHECK: call void @llvm.memset.p0i8.i64(i8* %a01, i8 0, i64 16, i32 4, i1 false) >> +; CHECK: call void @llvm.memset.i64(i8* %a01, i8 0, i64 16, i32 4) >> >> define void @foo(i32* %p) { >> %a0 = getelementptr i32* %p, i64 0 >> >> Modified: llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll (original) >> +++ llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll Fri Apr 2 13:43:02 2010 >> @@ -21,7 +21,7 @@ >> %arg1 = getelementptr [1024 x i8]* %target, i32 0, i32 0 >> %arg2 = getelementptr [6 x i8]* @hello, i32 0, i32 0 >> %rslt1 = call i8* @strcpy( i8* %arg1, i8* %arg2 ) >> -; CHECK: @llvm.memcpy.p0i8.p0i8.i32 >> +; CHECK: @llvm.memcpy.i32 >> ret i32 0 >> } >> >> >> Modified: llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll?rev=100199&r1=100198&r2=100199&view=diff >> ============================================================================== >> --- llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll (original) >> +++ llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll Fri Apr 2 13:43:02 2010 >> @@ -1,7 +1,7 @@ >> ; RUN: not llvm-as < %s |& grep {llvm intrinsics cannot be defined} >> ; PR1047 >> >> -define void @llvm.memcpy.p0i8.p0i8.i32(i8*, i8*, i32, i32, i1) { >> +define void @llvm.memcpy.i32(i8*, i8*, i32, i32) { >> entry: >> ret void >> } >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Fri Apr 2 14:29:15 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 Apr 2010 19:29:15 -0000 Subject: [llvm-commits] [llvm] r100207 - in /llvm/trunk: include/llvm/Analysis/LoopPass.h include/llvm/Assembly/PrintModulePass.h include/llvm/CallGraphSCCPass.h include/llvm/CodeGen/MachineFunctionPass.h include/llvm/CodeGen/Passes.h include/llvm/Pass.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineFunctionPass.cpp lib/CodeGen/MachineFunctionPrinterPass.cpp lib/VMCore/Pass.cpp lib/VMCore/PassManager.cpp lib/VMCore/PrintModulePass.cpp Message-ID: <20100402192915.5FDF02A6C12C@llvm.org> Author: evancheng Date: Fri Apr 2 14:29:15 2010 New Revision: 100207 URL: http://llvm.org/viewvc/llvm-project?rev=100207&view=rev Log: Revert 100204. It broke a bunch of tests and apparently changed what passes are run during codegen. Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h llvm/trunk/include/llvm/Assembly/PrintModulePass.h llvm/trunk/include/llvm/CallGraphSCCPass.h llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp llvm/trunk/lib/Analysis/LoopPass.cpp llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp llvm/trunk/lib/VMCore/PrintModulePass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Fri Apr 2 14:29:15 2010 @@ -31,10 +31,6 @@ explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} - /// getPrinterPass - Get a pass to print the function corresponding - /// to a Loop. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - // runOnLoop - This method should be implemented by the subclass to perform // whatever action is necessary for the specified Loop. virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0; Modified: llvm/trunk/include/llvm/Assembly/PrintModulePass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/PrintModulePass.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/Assembly/PrintModulePass.h (original) +++ llvm/trunk/include/llvm/Assembly/PrintModulePass.h Fri Apr 2 14:29:15 2010 @@ -27,9 +27,7 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. - ModulePass *createPrintModulePass(raw_ostream *OS, - bool DeleteStream=false, - const std::string &Banner = ""); + ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false); /// createPrintFunctionPass - Create and return a pass that prints /// functions to the specified raw_ostream as they are processed. Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/CallGraphSCCPass.h (original) +++ llvm/trunk/include/llvm/CallGraphSCCPass.h Fri Apr 2 14:29:15 2010 @@ -35,10 +35,6 @@ explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} - /// createPrinterPass - Get a pass that prints the Module - /// corresponding to a CallGraph. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - This method is called before the SCC's of the program /// has been processed, allowing the pass to do initialization as necessary. virtual bool doInitialization(CallGraph &CG) { Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h Fri Apr 2 14:29:15 2010 @@ -34,9 +34,6 @@ explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} - /// createPrinterPass - Get a machine function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// runOnMachineFunction - This method must be overloaded to perform the /// desired machine code transformation or analysis. /// Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Apr 2 14:29:15 2010 @@ -21,7 +21,6 @@ namespace llvm { class FunctionPass; - class MachineFunctionPass; class PassInfo; class TargetLowering; class RegisterCoalescer; @@ -37,9 +36,8 @@ /// MachineFunctionPrinter pass - This pass prints out the machine function to /// the given stream, as a debugging tool. - MachineFunctionPass * - createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner =""); + FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner =""); /// MachineLoopInfo pass - This pass is a loop analysis pass. /// Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Fri Apr 2 14:29:15 2010 @@ -30,9 +30,7 @@ #define LLVM_PASS_H #include "llvm/System/DataTypes.h" - #include -#include #include #include @@ -122,11 +120,6 @@ virtual void print(raw_ostream &O, const Module *M) const; void dump() const; // dump - Print to stderr. - /// createPrinterPass - Get a Pass appropriate to print the IR this - /// pass operates one (Module, Function or MachineFunction). - virtual Pass *createPrinterPass(raw_ostream &O, - const std::string &Banner) const = 0; - /// Each pass is responsible for assigning a pass manager to itself. /// PMS is the stack of available pass manager. virtual void assignPassManager(PMStack &, @@ -240,9 +233,6 @@ /// class ModulePass : public Pass { public: - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// runOnModule - Virtual method overriden by subclasses to process the module /// being operated on. virtual bool runOnModule(Module &M) = 0; @@ -303,9 +293,6 @@ explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// @@ -356,9 +343,6 @@ explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; - /// doInitialization - Virtual method overridden by subclasses to do /// any necessary per-module initialization. /// Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Fri Apr 2 14:29:15 2010 @@ -87,40 +87,10 @@ bool IsCheckingMode); }; -/// PrintCallGraphPass - Print a Module corresponding to a call graph. -/// -class PrintCallGraphPass : public CallGraphSCCPass { -private: - std::string Banner; - raw_ostream &Out; // raw_ostream to print on. - -public: - static char ID; - PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} - PrintCallGraphPass(const std::string &B, raw_ostream &o) - : CallGraphSCCPass(&ID), Banner(B), Out(o) {} - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - - bool runOnSCC(std::vector &SCC) { - Out << Banner; - for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); - n != ne; - ++n) { - (*n)->getFunction()->print(Out); - } - return false; - } -}; - } // end anonymous namespace. char CGPassManager::ID = 0; -char PrintCallGraphPass::ID = 0; - bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, CallGraph &CG, bool &CallGraphUpToDate) { bool Changed = false; @@ -426,11 +396,6 @@ return Changed; } -Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return new PrintCallGraphPass(Banner, O); -} - /// Assign pass manager to manage this pass. void CallGraphSCCPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Fri Apr 2 14:29:15 2010 @@ -14,44 +14,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/LoopPass.h" -#include "llvm/Assembly/PrintModulePass.h" -#include "llvm/Support/Debug.h" #include "llvm/Support/Timer.h" using namespace llvm; -namespace { - -/// PrintLoopPass - Print a Function corresponding to a Loop. -/// -class PrintLoopPass : public LoopPass { -private: - std::string Banner; - raw_ostream &Out; // raw_ostream to print on. - -public: - static char ID; - PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {} - PrintLoopPass(const std::string &B, raw_ostream &o) - : LoopPass(&ID), Banner(B), Out(o) {} - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - - bool runOnLoop(Loop *L, LPPassManager &) { - Out << Banner; - for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); - b != be; - ++b) { - (*b)->print(Out); - } - return false; - } -}; - -char PrintLoopPass::ID = 0; -} - //===----------------------------------------------------------------------===// // LPPassManager // @@ -341,11 +306,6 @@ //===----------------------------------------------------------------------===// // LoopPass -Pass *LoopPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return new PrintLoopPass(Banner, O); -} - // Check if this pass is suitable for the current LPPassManager, if // available. This pass P is not suitable for a LPPassManager if P // is not preserving higher level analysis info used by other Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Apr 2 14:29:15 2010 @@ -39,6 +39,40 @@ #include "llvm/Support/raw_ostream.h" using namespace llvm; +namespace { + struct Printer : public MachineFunctionPass { + static char ID; + + raw_ostream &OS; + const std::string Banner; + + Printer(raw_ostream &os, const std::string &banner) + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} + + const char *getPassName() const { return "MachineFunction Printer"; } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesAll(); + MachineFunctionPass::getAnalysisUsage(AU); + } + + bool runOnMachineFunction(MachineFunction &MF) { + OS << "# " << Banner << ":\n"; + MF.print(OS); + return false; + } + }; + char Printer::ID = 0; +} + +/// Returns a newly-created MachineFunction Printer pass. The default banner is +/// empty. +/// +FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, + const std::string &Banner){ + return new Printer(OS, Banner); +} + //===----------------------------------------------------------------------===// // MachineFunction implementation //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Fri Apr 2 14:29:15 2010 @@ -15,14 +15,8 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/Passes.h" using namespace llvm; -Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createMachineFunctionPrinterPass(O, Banner); -} - bool MachineFunctionPass::runOnFunction(Function &F) { // Do not codegen any 'available_externally' functions at all, they have // definitions outside the translation unit. Modified: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Fri Apr 2 14:29:15 2010 @@ -1,60 +0,0 @@ -//===-- MachineFunctionPrinterPass.cpp ------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// MachineFunctionPrinterPass implementation. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineFunction.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -namespace { -/// MachineFunctionPrinterPass - This is a pass to dump the IR of a -/// MachineFunction. -/// -struct MachineFunctionPrinterPass : public MachineFunctionPass { - static char ID; - - raw_ostream &OS; - const std::string Banner; - - MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) - : MachineFunctionPass(&ID), OS(os), Banner(banner) {} - - const char *getPassName() const { return "MachineFunction Printer"; } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - MachineFunctionPass::getAnalysisUsage(AU); - } - - bool runOnMachineFunction(MachineFunction &MF) { - OS << "# " << Banner << ":\n"; - MF.print(OS); - return false; - } -}; - -char MachineFunctionPrinterPass::ID = 0; -} - -namespace llvm { -/// Returns a newly-created MachineFunction Printer pass. The -/// default banner is empty. -/// -MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, - const std::string &Banner){ - return new MachineFunctionPrinterPass(OS, Banner); -} - -} Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Fri Apr 2 14:29:15 2010 @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringMap.h" -#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PassNameParser.h" @@ -43,11 +42,6 @@ // Force out-of-line virtual method. ModulePass::~ModulePass() { } -Pass *ModulePass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); -} - PassManagerType ModulePass::getPotentialPassManagerType() const { return PMT_ModulePassManager; } @@ -119,11 +113,6 @@ // FunctionPass Implementation // -Pass *FunctionPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - return createPrintFunctionPass(Banner, &O); -} - // run - On a module, we run this pass by initializing, runOnFunction'ing once // for every function in the module, then by finalizing. // @@ -166,13 +155,6 @@ // BasicBlockPass Implementation // -Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, - const std::string &Banner) const { - - llvm_unreachable("BasicBlockPass printing unsupported."); - return 0; -} - // To run this pass on a function, we simply call runOnBasicBlock once for each // function. // Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Fri Apr 2 14:29:15 2010 @@ -13,7 +13,6 @@ #include "llvm/PassManagers.h" -#include "llvm/Assembly/PrintModulePass.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -21,7 +20,6 @@ #include "llvm/Module.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" #include "llvm/System/Threading.h" @@ -57,57 +55,6 @@ clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), clEnumValEnd)); - -typedef llvm::cl::list -PassOptionList; - -// Print IR out before/after specified passes. -static PassOptionList -PrintBefore("print-before", - llvm::cl::desc("Print IR before specified passes")); - -static PassOptionList -PrintAfter("print-after", - llvm::cl::desc("Print IR after specified passes")); - -static cl::opt -PrintBeforeAll("print-before-all", - llvm::cl::desc("Print IR before each pass"), - cl::init(false)); -static cl::opt -PrintAfterAll("print-after-all", - llvm::cl::desc("Print IR after each pass"), - cl::init(false)); - -/// This is a helper to determine whether to print IR before or -/// after a pass. - -static bool ShouldPrintBeforeOrAfterPass(Pass *P, - PassOptionList &PassesToPrint) { - for (unsigned i = 0, ie = PassesToPrint.size(); i < ie; ++i) { - const llvm::PassInfo *PassInf = PassesToPrint[i]; - if (PassInf && P->getPassInfo()) - if (PassInf->getPassArgument() == - P->getPassInfo()->getPassArgument()) { - return true; - } - } - return false; -} - - -/// This is a utility to check whether a pass should have IR dumped -/// before it. -static bool ShouldPrintBeforePass(Pass *P) { - return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(P, PrintBefore); -} - -/// This is a utility to check whether a pass should have IR dumped -/// after it. -static bool ShouldPrintAfterPass(Pass *P) { - return PrintAfterAll || ShouldPrintBeforeOrAfterPass(P, PrintAfter); -} - } // End of llvm namespace /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions @@ -235,11 +182,6 @@ schedulePass(P); } - /// createPrinterPass - Get a function printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintFunctionPass(Banner, &O); - } - // Prepare for running an on the fly pass, freeing memory if needed // from a previous run. void releaseMemoryOnTheFly(); @@ -310,11 +252,6 @@ } } - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); - } - /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool runOnModule(Module &M); @@ -394,11 +331,6 @@ schedulePass(P); } - /// createPrinterPass - Get a module printer pass. - Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { - return createPrintModulePass(&O, false, Banner); - } - /// run - Execute all of the passes scheduled for execution. Keep track of /// whether any of the passes modifies the module, and if so, return true. bool run(Module &M); @@ -1276,14 +1208,7 @@ /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. void FunctionPassManager::add(Pass *P) { - if (ShouldPrintBeforePass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") - + P->getPassName() + " ***")); FPM->add(P); - - if (ShouldPrintAfterPass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") - + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep @@ -1594,15 +1519,7 @@ /// will be destroyed as well, so there is no need to delete the pass. This /// implies that all passes MUST be allocated with 'new'. void PassManager::add(Pass *P) { - if (ShouldPrintBeforePass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") - + P->getPassName() + " ***")); - PM->add(P); - - if (ShouldPrintAfterPass(P)) - add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") - + P->getPassName() + " ***")); } /// run - Execute all of the passes scheduled for execution. Keep track of Modified: llvm/trunk/lib/VMCore/PrintModulePass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PrintModulePass.cpp?rev=100207&r1=100206&r2=100207&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PrintModulePass.cpp (original) +++ llvm/trunk/lib/VMCore/PrintModulePass.cpp Fri Apr 2 14:29:15 2010 @@ -23,22 +23,21 @@ namespace { class PrintModulePass : public ModulePass { - std::string Banner; raw_ostream *Out; // raw_ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: static char ID; PrintModulePass() : ModulePass(&ID), Out(&dbgs()), DeleteStream(false) {} - PrintModulePass(const std::string &B, raw_ostream *o, bool DS) - : ModulePass(&ID), Banner(B), Out(o), DeleteStream(DS) {} + PrintModulePass(raw_ostream *o, bool DS) + : ModulePass(&ID), Out(o), DeleteStream(DS) {} ~PrintModulePass() { if (DeleteStream) delete Out; } bool runOnModule(Module &M) { - (*Out) << Banner << M; + (*Out) << M; return false; } @@ -86,9 +85,8 @@ /// createPrintModulePass - Create and return a pass that writes the /// module to the specified raw_ostream. ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS, - bool DeleteStream, - const std::string &Banner) { - return new PrintModulePass(Banner, OS, DeleteStream); + bool DeleteStream) { + return new PrintModulePass(OS, DeleteStream); } /// createPrintFunctionPass - Create and return a pass that prints From evan.cheng at apple.com Fri Apr 2 14:30:10 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 2 Apr 2010 12:30:10 -0700 Subject: [llvm-commits] [llvm] r100204 - in /llvm/trunk: include/llvm/Analysis/LoopPass.h include/llvm/Assembly/PrintModulePass.h include/llvm/CallGraphSCCPass.h include/llvm/CodeGen/MachineFunctionPass.h include/llvm/CodeGen/Passes.h include/llvm/Pass.h lib/Analysis/IPA/CallGraphSCCPass.cpp lib/Analysis/LoopPass.cpp lib/CodeGen/MachineFunction.cpp lib/CodeGen/MachineFunctionPass.cpp lib/CodeGen/MachineFunctionPrinterPass.cpp lib/VMCore/Pass.cpp lib/VMCore/PassManager.cpp lib/VMCore/PrintModulePass.cpp In-Reply-To: <20100402184627.43F492A6C12C@llvm.org> References: <20100402184627.43F492A6C12C@llvm.org> Message-ID: <016354AC-8717-48FB-9C4B-741CA4A6C8C9@apple.com> David, this broke a bunch of tests. e.g. test/CodeGen/Thumb2/machine-licm.ll It changes which codegen passes are being run. Before: Pass Arguments: -preverify -domtree -verify -verify -loops -loopsimplify -scalar-evolution -iv-users -loopsimplify -iv-users -loop-reduce -domtree -domfrontier -unreachableblockelim -codegenprepare -stack-protector -preverify -domtree -verify -machine-function-analysis -opt-phis -dead-mi-elimination -opt-exts -machinedomtree -machine-loops -machinelicm -machine-cse -machine-sink -unreachable-mbb-elimination -livevars -phi-node-elimination -twoaddressinstruction -processimpdefs -slotindexes -liveintervals -machinedomtree -machine-loops -simple-register-coalescing -calcspillweights -livestacks -virtregmap -linearscan-regalloc -stack-slot-coloring -prologepilog -machinedomtree -machine-loops -machinedomtree -machine-loops -if-converter -machinedomtree -machine-loops After: Pass Arguments: -preverify -domtree -verify -verify -loops -loopsimplify -scalar-evolution -iv-users -loopsimplify -iv-users -loop-reduce -domtree -domfrontier -unreachableblockelim -codegenprepare -stack-protector -preverify -domtree -verify -machine-function-analysis -opt-phis -dead-mi-elimination -opt-exts -machinedomtree -machine-loops -machinelicm -machine-sink -unreachable-mbb-elimination -livevars -phi-node-elimination -twoaddressinstruction -processimpdefs -slotindexes -liveintervals -machinedomtree -machine-loops -simple-register-coalescing -calcspillweights -livestacks -virtregmap -linearscan-regalloc -stack-slot-coloring -prologepilog -machinedomtree -machine-loops -machinedomtree -machine-loops -if-converter -machinedomtree -machine-loops Note -machine-cse is gone. I'll revert it. Evan On Apr 2, 2010, at 11:46 AM, David Greene wrote: > Author: greened > Date: Fri Apr 2 13:46:26 2010 > New Revision: 100204 > > URL: http://llvm.org/viewvc/llvm-project?rev=100204&view=rev > Log: > > Let's try this again. Re-apply 100143 including an apparent missing > include. For some reason the buildbot choked on this while my > builds did not. It's probably due to a difference in system headers. > > --- > > Add some switches helpful for debugging: > > -print-before= > > Dump IR before running pass . > > -print-before-all > > Dump IR before running each pass. > > -print-after-all > > Dump IR after running each pass. > > These are helpful when tracking down a miscompilation. It is easy to > get IR dumps and do diffs on them, etc. > > To make this work well, add a new getPrinterPass API to Pass so that > each kind of pass (ModulePass, FunctionPass, etc.) can create a Pass > suitable for dumping out the kind of object the Pass works on. > > Added: > llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp > Modified: > llvm/trunk/include/llvm/Analysis/LoopPass.h > llvm/trunk/include/llvm/Assembly/PrintModulePass.h > llvm/trunk/include/llvm/CallGraphSCCPass.h > llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h > llvm/trunk/include/llvm/CodeGen/Passes.h > llvm/trunk/include/llvm/Pass.h > llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp > llvm/trunk/lib/Analysis/LoopPass.cpp > llvm/trunk/lib/CodeGen/MachineFunction.cpp > llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp > llvm/trunk/lib/VMCore/Pass.cpp > llvm/trunk/lib/VMCore/PassManager.cpp > llvm/trunk/lib/VMCore/PrintModulePass.cpp > > Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) > +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Fri Apr 2 13:46:26 2010 > @@ -31,6 +31,10 @@ > explicit LoopPass(intptr_t pid) : Pass(PT_Loop, pid) {} > explicit LoopPass(void *pid) : Pass(PT_Loop, pid) {} > > + /// getPrinterPass - Get a pass to print the function corresponding > + /// to a Loop. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > // runOnLoop - This method should be implemented by the subclass to perform > // whatever action is necessary for the specified Loop. > virtual bool runOnLoop(Loop *L, LPPassManager &LPM) = 0; > > Modified: llvm/trunk/include/llvm/Assembly/PrintModulePass.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Assembly/PrintModulePass.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Assembly/PrintModulePass.h (original) > +++ llvm/trunk/include/llvm/Assembly/PrintModulePass.h Fri Apr 2 13:46:26 2010 > @@ -27,7 +27,9 @@ > > /// createPrintModulePass - Create and return a pass that writes the > /// module to the specified raw_ostream. > - ModulePass *createPrintModulePass(raw_ostream *OS, bool DeleteStream=false); > + ModulePass *createPrintModulePass(raw_ostream *OS, > + bool DeleteStream=false, > + const std::string &Banner = ""); > > /// createPrintFunctionPass - Create and return a pass that prints > /// functions to the specified raw_ostream as they are processed. > > Modified: llvm/trunk/include/llvm/CallGraphSCCPass.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CallGraphSCCPass.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CallGraphSCCPass.h (original) > +++ llvm/trunk/include/llvm/CallGraphSCCPass.h Fri Apr 2 13:46:26 2010 > @@ -35,6 +35,10 @@ > explicit CallGraphSCCPass(intptr_t pid) : Pass(PT_CallGraphSCC, pid) {} > explicit CallGraphSCCPass(void *pid) : Pass(PT_CallGraphSCC, pid) {} > > + /// createPrinterPass - Get a pass that prints the Module > + /// corresponding to a CallGraph. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > /// doInitialization - This method is called before the SCC's of the program > /// has been processed, allowing the pass to do initialization as necessary. > virtual bool doInitialization(CallGraph &CG) { > > Modified: llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h (original) > +++ llvm/trunk/include/llvm/CodeGen/MachineFunctionPass.h Fri Apr 2 13:46:26 2010 > @@ -34,6 +34,9 @@ > explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} > explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} > > + /// createPrinterPass - Get a machine function printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > /// runOnMachineFunction - This method must be overloaded to perform the > /// desired machine code transformation or analysis. > /// > > Modified: llvm/trunk/include/llvm/CodeGen/Passes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) > +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Apr 2 13:46:26 2010 > @@ -21,6 +21,7 @@ > namespace llvm { > > class FunctionPass; > + class MachineFunctionPass; > class PassInfo; > class TargetLowering; > class RegisterCoalescer; > @@ -36,8 +37,9 @@ > > /// MachineFunctionPrinter pass - This pass prints out the machine function to > /// the given stream, as a debugging tool. > - FunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, > - const std::string &Banner =""); > + MachineFunctionPass * > + createMachineFunctionPrinterPass(raw_ostream &OS, > + const std::string &Banner =""); > > /// MachineLoopInfo pass - This pass is a loop analysis pass. > /// > > Modified: llvm/trunk/include/llvm/Pass.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Pass.h (original) > +++ llvm/trunk/include/llvm/Pass.h Fri Apr 2 13:46:26 2010 > @@ -30,7 +30,9 @@ > #define LLVM_PASS_H > > #include "llvm/System/DataTypes.h" > + > #include > +#include > #include > #include > > @@ -120,6 +122,11 @@ > virtual void print(raw_ostream &O, const Module *M) const; > void dump() const; // dump - Print to stderr. > > + /// createPrinterPass - Get a Pass appropriate to print the IR this > + /// pass operates one (Module, Function or MachineFunction). > + virtual Pass *createPrinterPass(raw_ostream &O, > + const std::string &Banner) const = 0; > + > /// Each pass is responsible for assigning a pass manager to itself. > /// PMS is the stack of available pass manager. > virtual void assignPassManager(PMStack &, > @@ -233,6 +240,9 @@ > /// > class ModulePass : public Pass { > public: > + /// createPrinterPass - Get a module printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > /// runOnModule - Virtual method overriden by subclasses to process the module > /// being operated on. > virtual bool runOnModule(Module &M) = 0; > @@ -293,6 +303,9 @@ > explicit FunctionPass(intptr_t pid) : Pass(PT_Function, pid) {} > explicit FunctionPass(const void *pid) : Pass(PT_Function, pid) {} > > + /// createPrinterPass - Get a function printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > /// doInitialization - Virtual method overridden by subclasses to do > /// any necessary per-module initialization. > /// > @@ -343,6 +356,9 @@ > explicit BasicBlockPass(intptr_t pid) : Pass(PT_BasicBlock, pid) {} > explicit BasicBlockPass(const void *pid) : Pass(PT_BasicBlock, pid) {} > > + /// createPrinterPass - Get a function printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; > + > /// doInitialization - Virtual method overridden by subclasses to do > /// any necessary per-module initialization. > /// > > Modified: llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp (original) > +++ llvm/trunk/lib/Analysis/IPA/CallGraphSCCPass.cpp Fri Apr 2 13:46:26 2010 > @@ -87,10 +87,40 @@ > bool IsCheckingMode); > }; > > +/// PrintCallGraphPass - Print a Module corresponding to a call graph. > +/// > +class PrintCallGraphPass : public CallGraphSCCPass { > +private: > + std::string Banner; > + raw_ostream &Out; // raw_ostream to print on. > + > +public: > + static char ID; > + PrintCallGraphPass() : CallGraphSCCPass(&ID), Out(dbgs()) {} > + PrintCallGraphPass(const std::string &B, raw_ostream &o) > + : CallGraphSCCPass(&ID), Banner(B), Out(o) {} > + > + virtual void getAnalysisUsage(AnalysisUsage &AU) const { > + AU.setPreservesAll(); > + } > + > + bool runOnSCC(std::vector &SCC) { > + Out << Banner; > + for (std::vector::iterator n = SCC.begin(), ne = SCC.end(); > + n != ne; > + ++n) { > + (*n)->getFunction()->print(Out); > + } > + return false; > + } > +}; > + > } // end anonymous namespace. > > char CGPassManager::ID = 0; > > +char PrintCallGraphPass::ID = 0; > + > bool CGPassManager::RunPassOnSCC(Pass *P, std::vector &CurSCC, > CallGraph &CG, bool &CallGraphUpToDate) { > bool Changed = false; > @@ -396,6 +426,11 @@ > return Changed; > } > > +Pass *CallGraphSCCPass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + return new PrintCallGraphPass(Banner, O); > +} > + > /// Assign pass manager to manage this pass. > void CallGraphSCCPass::assignPassManager(PMStack &PMS, > PassManagerType PreferredType) { > > Modified: llvm/trunk/lib/Analysis/LoopPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) > +++ llvm/trunk/lib/Analysis/LoopPass.cpp Fri Apr 2 13:46:26 2010 > @@ -14,9 +14,44 @@ > //===----------------------------------------------------------------------===// > > #include "llvm/Analysis/LoopPass.h" > +#include "llvm/Assembly/PrintModulePass.h" > +#include "llvm/Support/Debug.h" > #include "llvm/Support/Timer.h" > using namespace llvm; > > +namespace { > + > +/// PrintLoopPass - Print a Function corresponding to a Loop. > +/// > +class PrintLoopPass : public LoopPass { > +private: > + std::string Banner; > + raw_ostream &Out; // raw_ostream to print on. > + > +public: > + static char ID; > + PrintLoopPass() : LoopPass(&ID), Out(dbgs()) {} > + PrintLoopPass(const std::string &B, raw_ostream &o) > + : LoopPass(&ID), Banner(B), Out(o) {} > + > + virtual void getAnalysisUsage(AnalysisUsage &AU) const { > + AU.setPreservesAll(); > + } > + > + bool runOnLoop(Loop *L, LPPassManager &) { > + Out << Banner; > + for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); > + b != be; > + ++b) { > + (*b)->print(Out); > + } > + return false; > + } > +}; > + > +char PrintLoopPass::ID = 0; > +} > + > //===----------------------------------------------------------------------===// > // LPPassManager > // > @@ -306,6 +341,11 @@ > //===----------------------------------------------------------------------===// > // LoopPass > > +Pass *LoopPass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + return new PrintLoopPass(Banner, O); > +} > + > // Check if this pass is suitable for the current LPPassManager, if > // available. This pass P is not suitable for a LPPassManager if P > // is not preserving higher level analysis info used by other > > Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Apr 2 13:46:26 2010 > @@ -39,40 +39,6 @@ > #include "llvm/Support/raw_ostream.h" > using namespace llvm; > > -namespace { > - struct Printer : public MachineFunctionPass { > - static char ID; > - > - raw_ostream &OS; > - const std::string Banner; > - > - Printer(raw_ostream &os, const std::string &banner) > - : MachineFunctionPass(&ID), OS(os), Banner(banner) {} > - > - const char *getPassName() const { return "MachineFunction Printer"; } > - > - virtual void getAnalysisUsage(AnalysisUsage &AU) const { > - AU.setPreservesAll(); > - MachineFunctionPass::getAnalysisUsage(AU); > - } > - > - bool runOnMachineFunction(MachineFunction &MF) { > - OS << "# " << Banner << ":\n"; > - MF.print(OS); > - return false; > - } > - }; > - char Printer::ID = 0; > -} > - > -/// Returns a newly-created MachineFunction Printer pass. The default banner is > -/// empty. > -/// > -FunctionPass *llvm::createMachineFunctionPrinterPass(raw_ostream &OS, > - const std::string &Banner){ > - return new Printer(OS, Banner); > -} > - > //===----------------------------------------------------------------------===// > // MachineFunction implementation > //===----------------------------------------------------------------------===// > > Modified: llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp (original) > +++ llvm/trunk/lib/CodeGen/MachineFunctionPass.cpp Fri Apr 2 13:46:26 2010 > @@ -15,8 +15,14 @@ > #include "llvm/Analysis/AliasAnalysis.h" > #include "llvm/CodeGen/MachineFunctionAnalysis.h" > #include "llvm/CodeGen/MachineFunctionPass.h" > +#include "llvm/CodeGen/Passes.h" > using namespace llvm; > > +Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + return createMachineFunctionPrinterPass(O, Banner); > +} > + > bool MachineFunctionPass::runOnFunction(Function &F) { > // Do not codegen any 'available_externally' functions at all, they have > // definitions outside the translation unit. > > Added: llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp?rev=100204&view=auto > ============================================================================== > --- llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp (added) > +++ llvm/trunk/lib/CodeGen/MachineFunctionPrinterPass.cpp Fri Apr 2 13:46:26 2010 > @@ -0,0 +1,60 @@ > +//===-- MachineFunctionPrinterPass.cpp ------------------------------------===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// MachineFunctionPrinterPass implementation. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/CodeGen/Passes.h" > +#include "llvm/CodeGen/MachineFunctionPass.h" > +#include "llvm/CodeGen/MachineFunction.h" > +#include "llvm/Support/raw_ostream.h" > + > +using namespace llvm; > + > +namespace { > +/// MachineFunctionPrinterPass - This is a pass to dump the IR of a > +/// MachineFunction. > +/// > +struct MachineFunctionPrinterPass : public MachineFunctionPass { > + static char ID; > + > + raw_ostream &OS; > + const std::string Banner; > + > + MachineFunctionPrinterPass(raw_ostream &os, const std::string &banner) > + : MachineFunctionPass(&ID), OS(os), Banner(banner) {} > + > + const char *getPassName() const { return "MachineFunction Printer"; } > + > + virtual void getAnalysisUsage(AnalysisUsage &AU) const { > + AU.setPreservesAll(); > + MachineFunctionPass::getAnalysisUsage(AU); > + } > + > + bool runOnMachineFunction(MachineFunction &MF) { > + OS << "# " << Banner << ":\n"; > + MF.print(OS); > + return false; > + } > +}; > + > +char MachineFunctionPrinterPass::ID = 0; > +} > + > +namespace llvm { > +/// Returns a newly-created MachineFunction Printer pass. The > +/// default banner is empty. > +/// > +MachineFunctionPass *createMachineFunctionPrinterPass(raw_ostream &OS, > + const std::string &Banner){ > + return new MachineFunctionPrinterPass(OS, Banner); > +} > + > +} > > Modified: llvm/trunk/lib/VMCore/Pass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Pass.cpp (original) > +++ llvm/trunk/lib/VMCore/Pass.cpp Fri Apr 2 13:46:26 2010 > @@ -18,6 +18,7 @@ > #include "llvm/Module.h" > #include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/StringMap.h" > +#include "llvm/Assembly/PrintModulePass.h" > #include "llvm/Support/Debug.h" > #include "llvm/Support/ManagedStatic.h" > #include "llvm/Support/PassNameParser.h" > @@ -42,6 +43,11 @@ > // Force out-of-line virtual method. > ModulePass::~ModulePass() { } > > +Pass *ModulePass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + return createPrintModulePass(&O, false, Banner); > +} > + > PassManagerType ModulePass::getPotentialPassManagerType() const { > return PMT_ModulePassManager; > } > @@ -113,6 +119,11 @@ > // FunctionPass Implementation > // > > +Pass *FunctionPass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + return createPrintFunctionPass(Banner, &O); > +} > + > // run - On a module, we run this pass by initializing, runOnFunction'ing once > // for every function in the module, then by finalizing. > // > @@ -155,6 +166,13 @@ > // BasicBlockPass Implementation > // > > +Pass *BasicBlockPass::createPrinterPass(raw_ostream &O, > + const std::string &Banner) const { > + > + llvm_unreachable("BasicBlockPass printing unsupported."); > + return 0; > +} > + > // To run this pass on a function, we simply call runOnBasicBlock once for each > // function. > // > > Modified: llvm/trunk/lib/VMCore/PassManager.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/PassManager.cpp (original) > +++ llvm/trunk/lib/VMCore/PassManager.cpp Fri Apr 2 13:46:26 2010 > @@ -13,6 +13,7 @@ > > > #include "llvm/PassManagers.h" > +#include "llvm/Assembly/PrintModulePass.h" > #include "llvm/Assembly/Writer.h" > #include "llvm/Support/CommandLine.h" > #include "llvm/Support/Debug.h" > @@ -20,6 +21,7 @@ > #include "llvm/Module.h" > #include "llvm/Support/ErrorHandling.h" > #include "llvm/Support/ManagedStatic.h" > +#include "llvm/Support/PassNameParser.h" > #include "llvm/Support/raw_ostream.h" > #include "llvm/System/Mutex.h" > #include "llvm/System/Threading.h" > @@ -55,6 +57,57 @@ > clEnumVal(Executions, "print pass name before it is executed"), > clEnumVal(Details , "print pass details when it is executed"), > clEnumValEnd)); > + > +typedef llvm::cl::list > +PassOptionList; > + > +// Print IR out before/after specified passes. > +static PassOptionList > +PrintBefore("print-before", > + llvm::cl::desc("Print IR before specified passes")); > + > +static PassOptionList > +PrintAfter("print-after", > + llvm::cl::desc("Print IR after specified passes")); > + > +static cl::opt > +PrintBeforeAll("print-before-all", > + llvm::cl::desc("Print IR before each pass"), > + cl::init(false)); > +static cl::opt > +PrintAfterAll("print-after-all", > + llvm::cl::desc("Print IR after each pass"), > + cl::init(false)); > + > +/// This is a helper to determine whether to print IR before or > +/// after a pass. > + > +static bool ShouldPrintBeforeOrAfterPass(Pass *P, > + PassOptionList &PassesToPrint) { > + for (unsigned i = 0, ie = PassesToPrint.size(); i < ie; ++i) { > + const llvm::PassInfo *PassInf = PassesToPrint[i]; > + if (PassInf && P->getPassInfo()) > + if (PassInf->getPassArgument() == > + P->getPassInfo()->getPassArgument()) { > + return true; > + } > + } > + return false; > +} > + > + > +/// This is a utility to check whether a pass should have IR dumped > +/// before it. > +static bool ShouldPrintBeforePass(Pass *P) { > + return PrintBeforeAll || ShouldPrintBeforeOrAfterPass(P, PrintBefore); > +} > + > +/// This is a utility to check whether a pass should have IR dumped > +/// after it. > +static bool ShouldPrintAfterPass(Pass *P) { > + return PrintAfterAll || ShouldPrintBeforeOrAfterPass(P, PrintAfter); > +} > + > } // End of llvm namespace > > /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions > @@ -182,6 +235,11 @@ > schedulePass(P); > } > > + /// createPrinterPass - Get a function printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { > + return createPrintFunctionPass(Banner, &O); > + } > + > // Prepare for running an on the fly pass, freeing memory if needed > // from a previous run. > void releaseMemoryOnTheFly(); > @@ -252,6 +310,11 @@ > } > } > > + /// createPrinterPass - Get a module printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { > + return createPrintModulePass(&O, false, Banner); > + } > + > /// run - Execute all of the passes scheduled for execution. Keep track of > /// whether any of the passes modifies the module, and if so, return true. > bool runOnModule(Module &M); > @@ -331,6 +394,11 @@ > schedulePass(P); > } > > + /// createPrinterPass - Get a module printer pass. > + Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { > + return createPrintModulePass(&O, false, Banner); > + } > + > /// run - Execute all of the passes scheduled for execution. Keep track of > /// whether any of the passes modifies the module, and if so, return true. > bool run(Module &M); > @@ -1208,7 +1276,14 @@ > /// there is no need to delete the pass. (TODO delete passes.) > /// This implies that all passes MUST be allocated with 'new'. > void FunctionPassManager::add(Pass *P) { > + if (ShouldPrintBeforePass(P)) > + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") > + + P->getPassName() + " ***")); > FPM->add(P); > + > + if (ShouldPrintAfterPass(P)) > + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") > + + P->getPassName() + " ***")); > } > > /// run - Execute all of the passes scheduled for execution. Keep > @@ -1519,7 +1594,15 @@ > /// will be destroyed as well, so there is no need to delete the pass. This > /// implies that all passes MUST be allocated with 'new'. > void PassManager::add(Pass *P) { > + if (ShouldPrintBeforePass(P)) > + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump Before ") > + + P->getPassName() + " ***")); > + > PM->add(P); > + > + if (ShouldPrintAfterPass(P)) > + add(P->createPrinterPass(dbgs(), std::string("*** IR Dump After ") > + + P->getPassName() + " ***")); > } > > /// run - Execute all of the passes scheduled for execution. Keep track of > > Modified: llvm/trunk/lib/VMCore/PrintModulePass.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PrintModulePass.cpp?rev=100204&r1=100203&r2=100204&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/PrintModulePass.cpp (original) > +++ llvm/trunk/lib/VMCore/PrintModulePass.cpp Fri Apr 2 13:46:26 2010 > @@ -23,21 +23,22 @@ > namespace { > > class PrintModulePass : public ModulePass { > + std::string Banner; > raw_ostream *Out; // raw_ostream to print on > bool DeleteStream; // Delete the ostream in our dtor? > public: > static char ID; > PrintModulePass() : ModulePass(&ID), Out(&dbgs()), > DeleteStream(false) {} > - PrintModulePass(raw_ostream *o, bool DS) > - : ModulePass(&ID), Out(o), DeleteStream(DS) {} > + PrintModulePass(const std::string &B, raw_ostream *o, bool DS) > + : ModulePass(&ID), Banner(B), Out(o), DeleteStream(DS) {} > > ~PrintModulePass() { > if (DeleteStream) delete Out; > } > > bool runOnModule(Module &M) { > - (*Out) << M; > + (*Out) << Banner << M; > return false; > } > > @@ -85,8 +86,9 @@ > /// createPrintModulePass - Create and return a pass that writes the > /// module to the specified raw_ostream. > ModulePass *llvm::createPrintModulePass(llvm::raw_ostream *OS, > - bool DeleteStream) { > - return new PrintModulePass(OS, DeleteStream); > + bool DeleteStream, > + const std::string &Banner) { > + return new PrintModulePass(Banner, OS, DeleteStream); > } > > /// createPrintFunctionPass - Create and return a pass that prints > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Fri Apr 2 14:36:14 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 02 Apr 2010 19:36:14 -0000 Subject: [llvm-commits] [llvm] r100208 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/PowerPC/PPCISelLowering.h lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h test/CodeGen/X86/memset-2.ll test/CodeGen/X86/memset-3.ll Message-ID: <20100402193615.2A1572A6C12C@llvm.org> Author: evancheng Date: Fri Apr 2 14:36:14 2010 New Revision: 100208 URL: http://llvm.org/viewvc/llvm-project?rev=100208&view=rev Log: Correctly lower memset / memcpy of undef. It should be a nop. PR6767. Added: llvm/trunk/test/CodeGen/X86/memset-3.ll Modified: llvm/trunk/include/llvm/Target/TargetLowering.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/test/CodeGen/X86/memset-2.ll Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 14:36:14 2010 @@ -633,15 +633,19 @@ } /// getOptimalMemOpType - Returns the target specific optimal type for load - /// and store operations as a result of memset, memcpy, and memmove lowering. - /// If DstAlign is zero that means it's safe to destination alignment can - /// satisfy any constraint. Similarly if SrcAlign is zero it means there isn't - /// a need to check it against alignment requirement, probably because the - /// source does not need to be loaded. It returns EVT::Other if SelectionDAG - /// should be responsible for determining it. + /// and store operations as a result of memset, memcpy, and memmove + /// lowering. If DstAlign is zero that means it's safe to destination + /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it + /// means there isn't a need to check it against alignment requirement, + /// probably because the source does not need to be loaded. If + /// 'NonScalarIntSafe' is true, that means it's safe to return a + /// non-scalar-integer type, e.g. empty string source, constant, or loaded + /// from memory. It returns EVT::Other if SelectionDAG should be responsible + /// for determining it. virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, SelectionDAG &DAG) const { + bool NonScalarIntSafe, + SelectionDAG &DAG) const { return MVT::Other; } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 14:36:14 2010 @@ -3094,6 +3094,8 @@ /// operand. static SDValue getMemsetValue(SDValue Value, EVT VT, SelectionDAG &DAG, DebugLoc dl) { + assert(Value.getOpcode() != ISD::UNDEF); + unsigned NumBits = VT.getScalarType().getSizeInBits(); if (ConstantSDNode *C = dyn_cast(Value)) { APInt Val = APInt(NumBits, C->getZExtValue() & 255); @@ -3197,7 +3199,7 @@ static bool FindOptimalMemOpLowering(std::vector &MemOps, unsigned Limit, uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, + bool NonScalarIntSafe, SelectionDAG &DAG, const TargetLowering &TLI) { assert((SrcAlign == 0 || SrcAlign >= DstAlign) && @@ -3207,7 +3209,8 @@ // the inferred alignment of the source. 'DstAlign', on the other hand, is the // specified alignment of the memory operation. If it is zero, that means // it's possible to change the alignment of the destination. - EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, SafeToUseFP, DAG); + EVT VT = TLI.getOptimalMemOpType(Size, DstAlign, SrcAlign, + NonScalarIntSafe, DAG); if (VT == MVT::Other) { VT = TLI.getPointerTy(); @@ -3266,10 +3269,13 @@ unsigned Align, bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { - const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + // Turn a memcpy of undef to nop. + if (Src.getOpcode() == ISD::UNDEF) + return Chain; // Expand memcpy to a series of load and store ops if the size operand falls // below a certain threshold. + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); std::vector MemOps; uint64_t Limit = -1ULL; if (!AlwaysInline) @@ -3352,10 +3358,13 @@ unsigned Align,bool AlwaysInline, const Value *DstSV, uint64_t DstSVOff, const Value *SrcSV, uint64_t SrcSVOff) { - const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + // Turn a memmove of undef to nop. + if (Src.getOpcode() == ISD::UNDEF) + return Chain; // Expand memmove to a series of load and store ops if the size operand falls // below a certain threshold. + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); std::vector MemOps; uint64_t Limit = -1ULL; if (!AlwaysInline) @@ -3426,21 +3435,24 @@ SDValue Src, uint64_t Size, unsigned Align, const Value *DstSV, uint64_t DstSVOff) { - const TargetLowering &TLI = DAG.getTargetLoweringInfo(); + // Turn a memset of undef to nop. + if (Src.getOpcode() == ISD::UNDEF) + return Chain; // Expand memset to a series of load/store ops if the size operand // falls below a certain threshold. + const TargetLowering &TLI = DAG.getTargetLoweringInfo(); std::vector MemOps; bool DstAlignCanChange = false; MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo(); FrameIndexSDNode *FI = dyn_cast(Dst); if (FI && !MFI->isFixedObjectIndex(FI->getIndex())) DstAlignCanChange = true; - bool IsZero = isa(Src) && - cast(Src)->isNullValue(); + bool NonScalarIntSafe = + isa(Src) && cast(Src)->isNullValue(); if (!FindOptimalMemOpLowering(MemOps, TLI.getMaxStoresPerMemset(), Size, (DstAlignCanChange ? 0 : Align), 0, - IsZero, DAG, TLI)) + NonScalarIntSafe, DAG, TLI)) return SDValue(); if (DstAlignCanChange) { @@ -3592,9 +3604,9 @@ if (ConstantSize->isNullValue()) return Chain; - SDValue Result = - getMemsetStores(*this, dl, Chain, Dst, Src, ConstantSize->getZExtValue(), - Align, DstSV, DstSVOff); + SDValue Result = getMemsetStores(*this, dl, Chain, Dst, Src, + ConstantSize->getZExtValue(), + Align, DstSV, DstSVOff); if (Result.getNode()) return Result; } Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Fri Apr 2 14:36:14 2010 @@ -5540,15 +5540,18 @@ } /// getOptimalMemOpType - Returns the target specific optimal type for load -/// and store operations as a result of memset, memcpy, and memmove lowering. -/// If DstAlign is zero that means it's safe to destination alignment can -/// satisfy any constraint. Similarly if SrcAlign is zero it means there -/// isn't a need to check it against alignment requirement, probably because -/// the source does not need to be loaded. It returns EVT::Other if -/// SelectionDAG should be responsible for determining it. +/// and store operations as a result of memset, memcpy, and memmove +/// lowering. If DstAlign is zero that means it's safe to destination +/// alignment can satisfy any constraint. Similarly if SrcAlign is zero it +/// means there isn't a need to check it against alignment requirement, +/// probably because the source does not need to be loaded. If +/// 'NonScalarIntSafe' is true, that means it's safe to return a +/// non-scalar-integer type, e.g. empty string source, constant, or loaded +/// from memory. It returns EVT::Other if SelectionDAG should be responsible +/// for determining it. EVT PPCTargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, + bool NonScalarIntSafe, SelectionDAG &DAG) const { if (this->PPCSubTarget.isPPC64()) { return MVT::i64; Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original) +++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Fri Apr 2 14:36:14 2010 @@ -348,15 +348,19 @@ virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; /// getOptimalMemOpType - Returns the target specific optimal type for load - /// and store operations as a result of memset, memcpy, and memmove lowering. - /// If DstAlign is zero that means it's safe to destination alignment can - /// satisfy any constraint. Similarly if SrcAlign is zero it means there - /// isn't a need to check it against alignment requirement, probably because - /// the source does not need to be loaded. It returns EVT::Other if - /// SelectionDAG should be responsible for determining it. - virtual EVT getOptimalMemOpType(uint64_t Size, - unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, SelectionDAG &DAG) const; + /// and store operations as a result of memset, memcpy, and memmove + /// lowering. If DstAlign is zero that means it's safe to destination + /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it + /// means there isn't a need to check it against alignment requirement, + /// probably because the source does not need to be loaded. If + /// 'NonScalarIntSafe' is true, that means it's safe to return a + /// non-scalar-integer type, e.g. empty string source, constant, or loaded + /// from memory. It returns EVT::Other if SelectionDAG should be responsible + /// for determining it. + virtual EVT + getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, + bool NonScalarIntSafe, SelectionDAG &DAG) const; /// getFunctionAlignment - Return the Log2 alignment of this function. virtual unsigned getFunctionAlignment(const Function *F) const; Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Apr 2 14:36:14 2010 @@ -1071,18 +1071,21 @@ /// If DstAlign is zero that means it's safe to destination alignment can /// satisfy any constraint. Similarly if SrcAlign is zero it means there /// isn't a need to check it against alignment requirement, probably because -/// the source does not need to be loaded. It returns EVT::Other if -/// SelectionDAG should be responsible for determining it. +/// the source does not need to be loaded. If 'NonScalarIntSafe' is true, that +/// means it's safe to return a non-scalar-integer type, e.g. constant string +/// source or loaded from memory. It returns EVT::Other if SelectionDAG should +/// be responsible for determining it. EVT X86TargetLowering::getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, + bool NonScalarIntSafe, SelectionDAG &DAG) const { // FIXME: This turns off use of xmm stores for memset/memcpy on targets like // linux. This is because the stack realignment code can't handle certain // cases like PR2962. This should be removed when PR2962 is fixed. const Function *F = DAG.getMachineFunction().getFunction(); - if (!F->hasFnAttr(Attribute::NoImplicitFloat)) { + if (NonScalarIntSafe && + !F->hasFnAttr(Attribute::NoImplicitFloat)) { if (Size >= 16 && (Subtarget->isUnalignedMemAccessFast() || ((DstAlign == 0 || DstAlign >= 16) && @@ -1090,10 +1093,9 @@ Subtarget->getStackAlignment() >= 16) { if (Subtarget->hasSSE2()) return MVT::v4i32; - if (SafeToUseFP && Subtarget->hasSSE1()) + if (Subtarget->hasSSE1()) return MVT::v4f32; - } else if (SafeToUseFP && - Size >= 8 && + } else if (Size >= 8 && !Subtarget->is64Bit() && Subtarget->getStackAlignment() >= 8 && Subtarget->hasSSE2()) Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Fri Apr 2 14:36:14 2010 @@ -417,15 +417,19 @@ virtual unsigned getByValTypeAlignment(const Type *Ty) const; /// getOptimalMemOpType - Returns the target specific optimal type for load - /// and store operations as a result of memset, memcpy, and memmove lowering. - /// If DstAlign is zero that means it's safe to destination alignment can - /// satisfy any constraint. Similarly if SrcAlign is zero it means there - /// isn't a need to check it against alignment requirement, probably because - /// the source does not need to be loaded. It returns EVT::Other if - /// SelectionDAG should be responsible for determining it. - virtual EVT getOptimalMemOpType(uint64_t Size, - unsigned DstAlign, unsigned SrcAlign, - bool SafeToUseFP, SelectionDAG &DAG) const; + /// and store operations as a result of memset, memcpy, and memmove + /// lowering. If DstAlign is zero that means it's safe to destination + /// alignment can satisfy any constraint. Similarly if SrcAlign is zero it + /// means there isn't a need to check it against alignment requirement, + /// probably because the source does not need to be loaded. If + /// 'NonScalarIntSafe' is true, that means it's safe to return a + /// non-scalar-integer type, e.g. empty string source, constant, or loaded + /// from memory. It returns EVT::Other if SelectionDAG should be responsible + /// for determining it. + virtual EVT + getOptimalMemOpType(uint64_t Size, + unsigned DstAlign, unsigned SrcAlign, + bool NonScalarIntSafe, SelectionDAG &DAG) const; /// allowsUnalignedMemoryAccesses - Returns true if the target allows /// unaligned memory accesses. of the specified type. Modified: llvm/trunk/test/CodeGen/X86/memset-2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset-2.ll?rev=100208&r1=100207&r2=100208&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset-2.ll (original) +++ llvm/trunk/test/CodeGen/X86/memset-2.ll Fri Apr 2 14:36:14 2010 @@ -1,13 +1,11 @@ -; RUN: llc < %s | FileCheck %s - -target triple = "i386" +; RUN: llc -mtriple=i386-apple-darwin < %s | FileCheck %s declare void @llvm.memset.i32(i8*, i8, i32, i32) nounwind define fastcc void @t1() nounwind { entry: ; CHECK: t1: -; CHECK: call memset +; CHECK: call _memset call void @llvm.memset.i32( i8* null, i8 0, i32 188, i32 1 ) nounwind unreachable } @@ -15,7 +13,7 @@ define fastcc void @t2(i8 signext %c) nounwind { entry: ; CHECK: t2: -; CHECK: call memset +; CHECK: call _memset call void @llvm.memset.i32( i8* undef, i8 %c, i32 76, i32 1 ) nounwind unreachable } Added: llvm/trunk/test/CodeGen/X86/memset-3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memset-3.ll?rev=100208&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/memset-3.ll (added) +++ llvm/trunk/test/CodeGen/X86/memset-3.ll Fri Apr 2 14:36:14 2010 @@ -0,0 +1,12 @@ +; RUN: llc -mtriple=i386-apple-darwin < %s | not grep memset +; PR6767 + +define void @t() nounwind ssp { +entry: + %buf = alloca [512 x i8], align 1 + %ptr = getelementptr inbounds [512 x i8]* %buf, i32 0, i32 0 + call void @llvm.memset.i32(i8* %ptr, i8 undef, i32 512, i32 1) + unreachable +} + +declare void @llvm.memset.i32(i8* nocapture, i8, i32, i32) nounwind From sabre at nondot.org Fri Apr 2 14:42:40 2010 From: sabre at nondot.org (Chris Lattner) Date: Fri, 02 Apr 2010 19:42:40 -0000 Subject: [llvm-commits] [llvm] r100209 - in /llvm/trunk: include/llvm/Analysis/ include/llvm/CodeGen/ include/llvm/Support/ lib/Analysis/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/CodeGen/SelectionDAG/ lib/ExecutionEngine/JIT/ lib/Target/PIC16/ Message-ID: <20100402194240.6263C2A6C12C@llvm.org> Author: lattner Date: Fri Apr 2 14:42:39 2010 New Revision: 100209 URL: http://llvm.org/viewvc/llvm-project?rev=100209&view=rev Log: Switch the code generator (except the JIT) onto the new DebugLoc representation. This eliminates the 'DILocation' MDNodes for file/line/col tuples from -O0 -g codegen. This remove the old DebugLoc class, making it a typedef for DebugLoc, I'll rename NewDebugLoc next. I didn't update the JIT to use the new apis, so it will continue to work, but be as slow as before. Someone should eventually do this or, better yet, rip out the JIT debug info stuff and build the JIT on top of MC. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/include/llvm/CodeGen/MachineFunction.h llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h llvm/trunk/include/llvm/Support/DebugLoc.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/MachineFunction.cpp llvm/trunk/lib/CodeGen/MachineInstr.cpp llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Fri Apr 2 14:42:39 2010 @@ -31,8 +31,6 @@ class Type; class Value; class DbgDeclareInst; - class DebugLoc; - struct DebugLocTracker; class Instruction; class MDNode; class LLVMContext; @@ -710,11 +708,6 @@ std::string &Type, unsigned &LineNo, std::string &File, std::string &Dir); - /// ExtractDebugLocation - Extract debug location information - /// from DILocation. - DebugLoc ExtractDebugLocation(DILocation &Loc, - DebugLocTracker &DebugLocInfo); - /// getDISubprogram - Find subprogram that is enclosing this scope. DISubprogram getDISubprogram(MDNode *Scope); Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Fri Apr 2 14:42:39 2010 @@ -26,7 +26,6 @@ namespace llvm { -class DILocation; class Value; class Function; class MachineRegisterInfo; @@ -112,9 +111,6 @@ // of a function. DebugLoc DefaultDebugLoc; - // Tracks debug locations. - DebugLocTracker DebugLocInfo; - /// FunctionNumber - This provides a unique ID for each function emitted in /// this translation unit. /// @@ -402,9 +398,6 @@ // Debug location. // - /// getDILocation - Get the DILocation for a given DebugLoc object. - DILocation getDILocation(DebugLoc DL) const; - /// getDefaultDebugLoc - Get the default debug location for the machine /// function. DebugLoc getDefaultDebugLoc() const { return DefaultDebugLoc; } @@ -412,9 +405,6 @@ /// setDefaultDebugLoc - Get the default debug location for the machine /// function. void setDefaultDebugLoc(DebugLoc DL) { DefaultDebugLoc = DL; } - - /// getDebugLocInfo - Get the debug info location tracker. - DebugLocTracker &getDebugLocInfo() { return DebugLocInfo; } }; //===--------------------------------------------------------------------===// Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Fri Apr 2 14:42:39 2010 @@ -37,6 +37,7 @@ #include "llvm/CodeGen/MachineLocation.h" #include "llvm/MC/MCContext.h" #include "llvm/Support/Dwarf.h" +#include "llvm/Support/DebugLoc.h" #include "llvm/Support/ValueHandle.h" #include "llvm/System/DataTypes.h" #include "llvm/ADT/DenseMap.h" @@ -156,8 +157,8 @@ public: static char ID; // Pass identification, replacement for typeid - typedef std::pair > UnsignedAndMDNodePair; - typedef SmallVector< std::pair, UnsignedAndMDNodePair>, 4> + typedef std::pair UnsignedDebugLocPair; + typedef SmallVector, UnsignedDebugLocPair>, 4> VariableDbgInfoMapTy; VariableDbgInfoMapTy VariableDbgInfo; @@ -330,10 +331,10 @@ /// of one is required to emit exception handling info. Function *getPersonality() const; - /// setVariableDbgInfo - Collect information used to emit debugging information - /// of a variable. - void setVariableDbgInfo(MDNode *N, unsigned Slot, MDNode *Scope) { - VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Scope))); + /// setVariableDbgInfo - Collect information used to emit debugging + /// information of a variable. + void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc) { + VariableDbgInfo.push_back(std::make_pair(N, std::make_pair(Slot, Loc))); } VariableDbgInfoMapTy &getVariableDbgInfo() { return VariableDbgInfo; } Modified: llvm/trunk/include/llvm/Support/DebugLoc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/DebugLoc.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/DebugLoc.h (original) +++ llvm/trunk/include/llvm/Support/DebugLoc.h Fri Apr 2 14:42:39 2010 @@ -77,44 +77,16 @@ return LineCol == DL.LineCol && ScopeIdx == DL.ScopeIdx; } bool operator!=(const NewDebugLoc &DL) const { return !(*this == DL); } + + + + + static NewDebugLoc getUnknownLoc() { NewDebugLoc L; return L; } }; + typedef NewDebugLoc DebugLoc; - /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr - /// to index into a vector of unique debug location tuples. - class DebugLoc { - unsigned Idx; - public: - DebugLoc() : Idx(~0U) {} // Defaults to invalid. - - static DebugLoc getUnknownLoc() { DebugLoc L; L.Idx = ~0U; return L; } - static DebugLoc get(unsigned idx) { DebugLoc L; L.Idx = idx; return L; } - - unsigned getIndex() const { return Idx; } - - /// isUnknown - Return true if there is no debug info for the SDNode / - /// MachineInstr. - bool isUnknown() const { return Idx == ~0U; } - - bool operator==(const DebugLoc &DL) const { return Idx == DL.Idx; } - bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } - }; - - /// DebugLocTracker - This class tracks debug location information. - /// - struct DebugLocTracker { - /// DebugLocations - A vector of unique DebugLocTuple's. - /// - std::vector DebugLocations; - - /// DebugIdMap - This maps DebugLocTuple's to indices into the - /// DebugLocations vector. - DenseMap DebugIdMap; - - DebugLocTracker() {} - }; - } // end namespace llvm #endif /* LLVM_DEBUGLOC_H */ Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Fri Apr 2 14:42:39 2010 @@ -24,7 +24,6 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" -#include "llvm/Support/DebugLoc.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; using namespace llvm::dwarf; @@ -1372,23 +1371,6 @@ return true; } -/// ExtractDebugLocation - Extract debug location information -/// from DILocation. -DebugLoc llvm::ExtractDebugLocation(DILocation &Loc, - DebugLocTracker &DebugLocInfo) { - DenseMap::iterator II - = DebugLocInfo.DebugIdMap.find(Loc.getNode()); - if (II != DebugLocInfo.DebugIdMap.end()) - return DebugLoc::get(II->second); - - // Add a new location entry. - unsigned Id = DebugLocInfo.DebugLocations.size(); - DebugLocInfo.DebugLocations.push_back(Loc.getNode()); - DebugLocInfo.DebugIdMap[Loc.getNode()] = Id; - - return DebugLoc::get(Id); -} - /// getDISubprogram - Find subprogram that is enclosing this scope. DISubprogram llvm::getDISubprogram(MDNode *Scope) { DIDescriptor D(Scope); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Apr 2 14:42:39 2010 @@ -340,19 +340,17 @@ const MachineFunction *MF = MI.getParent()->getParent(); const TargetMachine &TM = MF->getTarget(); - if (!MI.getDebugLoc().isUnknown()) { - DILocation DLT = MF->getDILocation(MI.getDebugLoc()); - - // Print source line info. - DIScope Scope = DLT.getScope(); + DebugLoc DL = MI.getDebugLoc(); + if (!DL.isUnknown()) { // Print source line info. + DIScope Scope(DL.getScope(MF->getFunction()->getContext())); // Omit the directory, because it's likely to be long and uninteresting. if (Scope.Verify()) CommentOS << Scope.getFilename(); else CommentOS << ""; - CommentOS << ':' << DLT.getLineNumber(); - if (DLT.getColumnNumber() != 0) - CommentOS << ':' << DLT.getColumnNumber(); + CommentOS << ':' << DL.getLine(); + if (DL.getCol() != 0) + CommentOS << ':' << DL.getCol(); CommentOS << '\n'; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Apr 2 14:42:39 2010 @@ -302,7 +302,7 @@ : DwarfPrinter(OS, A, T), ModuleCU(0), AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(), DIEBlocks(), SectionSourceLines(), didInitial(false), shouldEmit(false), - CurrentFnDbgScope(0), PrevDILoc(0), DebugTimer(0) { + CurrentFnDbgScope(0), DebugTimer(0) { NextStringPoolNumber = 0; if (TimePassesIsEnabled) DebugTimer = new Timer("Dwarf Debug Writer"); @@ -1932,13 +1932,14 @@ /// findAbstractVariable - Find abstract variable, if any, associated with Var. DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var, unsigned FrameIdx, - DILocation &ScopeLoc) { + DebugLoc ScopeLoc) { DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode()); if (AbsDbgVariable) return AbsDbgVariable; - DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope().getNode()); + LLVMContext &Ctx = Var.getNode()->getContext(); + DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx)); if (!Scope) return NULL; @@ -1953,13 +1954,14 @@ /// FIXME : Refactor findAbstractVariable. DbgVariable *DwarfDebug::findAbstractVariable(DIVariable &Var, const MachineInstr *MI, - DILocation &ScopeLoc) { + DebugLoc ScopeLoc) { DbgVariable *AbsDbgVariable = AbstractVariables.lookup(Var.getNode()); if (AbsDbgVariable) return AbsDbgVariable; - DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope().getNode()); + LLVMContext &Ctx = Var.getNode()->getContext(); + DbgScope *Scope = AbstractScopes.lookup(ScopeLoc.getScope(Ctx)); if (!Scope) return NULL; @@ -1975,24 +1977,27 @@ void DwarfDebug::collectVariableInfo() { if (!MMI) return; + const LLVMContext &Ctx = MF->getFunction()->getContext(); + MachineModuleInfo::VariableDbgInfoMapTy &VMap = MMI->getVariableDbgInfo(); for (MachineModuleInfo::VariableDbgInfoMapTy::iterator VI = VMap.begin(), VE = VMap.end(); VI != VE; ++VI) { MDNode *Var = VI->first; if (!Var) continue; - DIVariable DV (Var); - std::pair< unsigned, MDNode *> VP = VI->second; - DILocation ScopeLoc(VP.second); - - DbgScope *Scope = - ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode()); - if (!Scope) - Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode()); + DIVariable DV(Var); + const std::pair &VP = VI->second; + + DbgScope *Scope = 0; + if (MDNode *IA = VP.second.getInlinedAt(Ctx)) + Scope = ConcreteScopes.lookup(IA); + if (Scope == 0) + Scope = DbgScopeMap.lookup(VP.second.getScope(Ctx)); + // If variable scope is not found then skip this variable. - if (!Scope) + if (Scope == 0) continue; - DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.first, ScopeLoc); + DbgVariable *AbsDbgVariable = findAbstractVariable(DV, VP.first, VP.second); DbgVariable *RegVar = new DbgVariable(DV, VP.first, AbsDbgVariable); Scope->addVariable(RegVar); } @@ -2021,16 +2026,17 @@ DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; - DILocation ScopeLoc = MF->getDILocation(DL); - DbgScope *Scope = - ConcreteScopes.lookup(ScopeLoc.getOrigLocation().getNode()); - if (!Scope) - Scope = DbgScopeMap.lookup(ScopeLoc.getScope().getNode()); + DbgScope *Scope = 0; + if (MDNode *IA = DL.getInlinedAt(Ctx)) + Scope = ConcreteScopes.lookup(IA); + if (Scope == 0) + Scope = DbgScopeMap.lookup(DL.getScope(Ctx)); + // If variable scope is not found then skip this variable. - if (!Scope) + if (Scope == 0) continue; - DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, ScopeLoc); + DbgVariable *AbsDbgVariable = findAbstractVariable(DV, MInsn, DL); DbgVariable *RegVar = new DbgVariable(DV, MInsn, AbsDbgVariable); DbgValueStartMap[MInsn] = RegVar; Scope->addVariable(RegVar); @@ -2044,12 +2050,15 @@ DebugLoc DL = MI->getDebugLoc(); if (DL.isUnknown()) return; - DILocation DILoc = MF->getDILocation(DL); - if (!DILoc.getScope().Verify()) - return; // Check and update last known location info. - if(DILoc.getNode() == PrevDILoc) + if (DL == PrevInstLoc) + return; + + MDNode *Scope = DL.getScope(MF->getFunction()->getContext()); + + // FIXME: Should only verify each scope once! + if (!DIScope(Scope).Verify()) return; // DBG_VALUE instruction establishes new value. @@ -2057,10 +2066,8 @@ DenseMap::iterator DI = DbgValueStartMap.find(MI); if (DI != DbgValueStartMap.end()) { - MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), - DILoc.getColumnNumber(), - DILoc.getScope().getNode()); - PrevDILoc = DILoc.getNode(); + MCSymbol *Label = recordSourceLine(DL.getLine(), DL.getCol(), Scope); + PrevInstLoc = DL; DI->second->setDbgValueLabel(Label); } return; @@ -2068,10 +2075,8 @@ // Emit a label to indicate location change. This is used for line // table even if this instruction does start a new scope. - MCSymbol *Label = recordSourceLine(DILoc.getLineNumber(), - DILoc.getColumnNumber(), - DILoc.getScope().getNode()); - PrevDILoc = DILoc.getNode(); + MCSymbol *Label = recordSourceLine(DL.getLine(), DL.getCol(), Scope); + PrevInstLoc = DL; // update DbgScope if this instruction starts a new scope. InsnToDbgScopeMapTy::iterator I = DbgScopeBeginMap.find(MI); @@ -2094,15 +2099,12 @@ DebugLoc DL = MI->getDebugLoc(); if (DL.isUnknown()) return; - DILocation DILoc = MF->getDILocation(DL); - if (!DILoc.getScope().Verify()) - return; - + // Emit a label and update DbgScope if this instruction ends a scope. InsnToDbgScopeMapTy::iterator I = DbgScopeEndMap.find(MI); if (I == DbgScopeEndMap.end()) return; - + MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(Label); @@ -2115,7 +2117,6 @@ /// createDbgScope - Create DbgScope for the scope. void DwarfDebug::createDbgScope(MDNode *Scope, MDNode *InlinedAt) { - if (!InlinedAt) { DbgScope *WScope = DbgScopeMap.lookup(Scope); if (WScope) @@ -2147,6 +2148,8 @@ DenseMap MIIndexMap; unsigned MIIndex = 0; + LLVMContext &Ctx = MF->getFunction()->getContext(); + // Scan each instruction and create scopes. First build working set of scopes. for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) { @@ -2156,16 +2159,17 @@ // FIXME : Remove DBG_VALUE check. if (MInsn->isDebugValue()) continue; MIIndexMap[MInsn] = MIIndex++; + DebugLoc DL = MInsn->getDebugLoc(); if (DL.isUnknown()) continue; - DILocation DLT = MF->getDILocation(DL); - DIScope DLTScope = DLT.getScope(); - if (!DLTScope.getNode()) continue; + + MDNode *Scope = DL.getScope(Ctx); + // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - if (DLTScope.isCompileUnit()) continue; - createDbgScope(DLTScope.getNode(), DLT.getOrigLocation().getNode()); + if (DIScope(Scope).isCompileUnit()) continue; + createDbgScope(Scope, DL.getInlinedAt(Ctx)); } } @@ -2179,17 +2183,17 @@ // FIXME : Remove DBG_VALUE check. if (MInsn->isDebugValue()) continue; DebugLoc DL = MInsn->getDebugLoc(); - if (DL.isUnknown()) continue; - DILocation DLT = MF->getDILocation(DL); - DIScope DLTScope = DLT.getScope(); - if (!DLTScope.getNode()) continue; + if (DL.isUnknown()) continue; + + MDNode *Scope = DL.getScope(Ctx); + if (Scope == 0) continue; + // There is no need to create another DIE for compile unit. For all // other scopes, create one DbgScope now. This will be translated // into a scope DIE at the end. - if (DLTScope.isCompileUnit()) continue; - DbgScope *Scope = getUpdatedDbgScope(DLTScope.getNode(), MInsn, - DLT.getOrigLocation().getNode()); - Scope->setLastInsn(MInsn); + if (DIScope(Scope).isCompileUnit()) continue; + DbgScope *DScope = getUpdatedDbgScope(Scope, MInsn, DL.getInlinedAt(Ctx)); + DScope->setLastInsn(MInsn); } } @@ -2255,20 +2259,21 @@ // Emit label for the implicitly defined dbg.stoppoint at the start of the // function. DebugLoc FDL = MF->getDefaultDebugLoc(); - if (!FDL.isUnknown()) { - DILocation DLT = MF->getDILocation(FDL); - DISubprogram SP = getDISubprogram(DLT.getScope().getNode()); - unsigned Line, Col; - if (SP.Verify()) { - Line = SP.getLineNumber(); - Col = 0; - } else { - Line = DLT.getLineNumber(); - Col = DLT.getColumnNumber(); - } - - recordSourceLine(Line, Col, DLT.getScope().getNode()); + if (FDL.isUnknown()) return; + + MDNode *Scope = FDL.getScope(MF->getFunction()->getContext()); + + DISubprogram SP = getDISubprogram(Scope); + unsigned Line, Col; + if (SP.Verify()) { + Line = SP.getLineNumber(); + Col = 0; + } else { + Line = FDL.getLine(); + Col = FDL.getCol(); } + + recordSourceLine(Line, Col, Scope); } /// endFunction - Gather and emit post-function debug information. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Apr 2 14:42:39 2010 @@ -195,7 +195,7 @@ /// Previous instruction's location information. This is used to determine /// label location to indicate scope boundries in dwarf debug info. - mutable const MDNode *PrevDILoc; + DebugLoc PrevInstLoc; /// DebugTimer - Timer for the Dwarf debug writer. Timer *DebugTimer; @@ -361,7 +361,8 @@ /// getUpdatedDbgScope - Find or create DbgScope assicated with /// the instruction. Initialize scope and update scope hierarchy. - DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, MDNode *InlinedAt); + DbgScope *getUpdatedDbgScope(MDNode *N, const MachineInstr *MI, + MDNode *InlinedAt); /// createDbgScope - Create DbgScope for the scope. void createDbgScope(MDNode *Scope, MDNode *InlinedAt); @@ -370,9 +371,9 @@ /// findAbstractVariable - Find abstract variable associated with Var. DbgVariable *findAbstractVariable(DIVariable &Var, unsigned FrameIdx, - DILocation &Loc); + DebugLoc Loc); DbgVariable *findAbstractVariable(DIVariable &Var, const MachineInstr *MI, - DILocation &Loc); + DebugLoc Loc); /// updateSubprogramScopeDIE - Find DIE for the given subprogram and /// attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes. Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Fri Apr 2 14:42:39 2010 @@ -436,15 +436,6 @@ return VReg; } -/// getDILocation - Get the DILocation for a given DebugLoc object. -DILocation MachineFunction::getDILocation(DebugLoc DL) const { - unsigned Idx = DL.getIndex(); - assert(Idx < DebugLocInfo.DebugLocations.size() && - "Invalid index into debug locations!"); - return DILocation(DebugLocInfo.DebugLocations[Idx]); -} - - /// getJTISymbol - Return the MCSymbol for the specified non-empty jump table. /// If isLinkerPrivate is specified, an 'l' label is returned, otherwise a /// normal 'L' label is returned. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Fri Apr 2 14:42:39 2010 @@ -1221,17 +1221,16 @@ // TODO: print InlinedAtLoc information - DILocation DLT = MF->getDILocation(debugLoc); - DIScope Scope = DLT.getScope(); + DIScope Scope(debugLoc.getScope(MF->getFunction()->getContext())); OS << " dbg:"; // Omit the directory, since it's usually long and uninteresting. if (Scope.Verify()) OS << Scope.getFilename(); else OS << ""; - OS << ':' << DLT.getLineNumber(); - if (DLT.getColumnNumber() != 0) - OS << ':' << DLT.getColumnNumber(); + OS << ':' << debugLoc.getLine(); + if (debugLoc.getCol() != 0) + OS << ':' << debugLoc.getCol(); } OS << "\n"; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Apr 2 14:42:39 2010 @@ -340,8 +340,8 @@ StaticAllocaMap.find(AI); if (SI == StaticAllocaMap.end()) break; // VLAs. int FI = SI->second; - if (MDNode *Dbg = DI->getDbgMetadata()) - MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); + if (!DI->getDebugLoc().isUnknown()) + MMI->setVariableDbgInfo(DI->getVariable(), FI, DI->getDebugLoc()); // Building the map above is target independent. Generating DBG_VALUE // inline is target dependent; do this now. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Apr 2 14:42:39 2010 @@ -3800,8 +3800,8 @@ int FI = SI->second; if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getDbgMetadata()) - MMI->setVariableDbgInfo(Variable, FI, Dbg); + if (!DI.getDebugLoc().isUnknown()) + MMI->setVariableDbgInfo(Variable, FI, DI.getDebugLoc()); return 0; } case Intrinsic::dbg_value: { @@ -3851,9 +3851,10 @@ if (SI == FuncInfo.StaticAllocaMap.end()) return 0; // VLAs. int FI = SI->second; + if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getDbgMetadata()) - MMI->setVariableDbgInfo(Variable, FI, Dbg); + if (!DI.getDebugLoc().isUnknown()) + MMI->setVariableDbgInfo(Variable, FI, DI.getDebugLoc()); return 0; } case Intrinsic::eh_exception: { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Apr 2 14:42:39 2010 @@ -368,21 +368,18 @@ /// attached with this instruction. static void SetDebugLoc(Instruction *I, SelectionDAGBuilder *SDB, FastISel *FastIS, MachineFunction *MF) { - MDNode *Dbg = I->getDbgMetadata(); - if (Dbg == 0) return; + DebugLoc DL = I->getDebugLoc(); + if (DL.isUnknown()) return; - DILocation DILoc(Dbg); - DebugLoc Loc = ExtractDebugLocation(DILoc, MF->getDebugLocInfo()); - - SDB->setCurDebugLoc(Loc); + SDB->setCurDebugLoc(DL); if (FastIS) - FastIS->setCurDebugLoc(Loc); + FastIS->setCurDebugLoc(DL); // If the function doesn't have a default debug location yet, set // it. This is kind of a hack. if (MF->getDefaultDebugLoc().isUnknown()) - MF->setDefaultDebugLoc(Loc); + MF->setDefaultDebugLoc(DL); } /// ResetDebugLoc - Set MF's and SDB's DebugLocs to Unknown. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Fri Apr 2 14:42:39 2010 @@ -821,21 +821,20 @@ } void JITEmitter::processDebugLoc(DebugLoc DL, bool BeforePrintingInsn) { - if (!DL.isUnknown()) { - DILocation CurDLT = EmissionDetails.MF->getDILocation(DL); + if (DL.isUnknown()) return; + if (!BeforePrintingInsn) return; - if (BeforePrintingInsn) { - if (CurDLT.getScope().getNode() != 0 - && PrevDLT.getNode() != CurDLT.getNode()) { - JITEvent_EmittedFunctionDetails::LineStart NextLine; - NextLine.Address = getCurrentPCValue(); - NextLine.Loc = DL; - EmissionDetails.LineStarts.push_back(NextLine); - } - - PrevDLT = CurDLT; - } + // FIXME: This is horribly inefficient. + DILocation CurDLT(DL.getAsMDNode(CurFn->getContext())); + + if (CurDLT.getScope().getNode() != 0 && PrevDLT.getNode() !=CurDLT.getNode()){ + JITEvent_EmittedFunctionDetails::LineStart NextLine; + NextLine.Address = getCurrentPCValue(); + NextLine.Loc = DL; + EmissionDetails.LineStarts.push_back(NextLine); } + + PrevDLT = CurDLT; } static unsigned GetConstantPoolSizeInBytes(MachineConstantPool *MCP, Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.cpp Fri Apr 2 14:42:39 2010 @@ -256,15 +256,11 @@ /// void PIC16DbgInfo::ChangeDebugLoc(const MachineFunction &MF, const DebugLoc &DL, bool IsInBeginFunction) { - if (! EmitDebugDirectives) return; - assert (! DL.isUnknown() && "can't change to invalid debug loc"); - - DILocation Loc = MF.getDILocation(DL); - MDNode *CU = Loc.getScope().getNode(); - unsigned line = Loc.getLineNumber(); + if (!EmitDebugDirectives) return; + assert(!DL.isUnknown() && "can't change to invalid debug loc"); - SwitchToCU(CU); - SwitchToLine(line, IsInBeginFunction); + SwitchToCU(DL.getScope(MF.getFunction()->getContext())); + SwitchToLine(DL.getLine(), IsInBeginFunction); } /// SwitchToLine - Emit line directive for a new line. Modified: llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h?rev=100209&r1=100208&r2=100209&view=diff ============================================================================== --- llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h (original) +++ llvm/trunk/lib/Target/PIC16/PIC16DebugInfo.h Fri Apr 2 14:42:39 2010 @@ -19,7 +19,7 @@ namespace llvm { class MachineFunction; - class DebugLoc; + class NewDebugLoc; typedef NewDebugLoc DebugLoc; namespace PIC16Dbg { enum VarType { T_NULL, From evan.cheng at apple.com Fri Apr 2 15:06:18 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 2 Apr 2010 13:06:18 -0700 Subject: [llvm-commits] [llvm] r100199 - in /llvm/trunk: include/llvm/ include/llvm/CodeGen/ include/llvm/Support/ include/llvm/Target/ include/llvm/Transforms/Utils/ lib/CodeGen/SelectionDAG/ lib/Target/ARM/ lib/Target/PowerPC/ lib/Target/X86/ lib/Target/XCore/ lib/Transforms/InstCombine/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ test/Analysis/BasicAA/ test/Bitcode/ test/Transforms/InstCombine/ test/Transforms/MemCpyOpt/ test/Transforms/SimplifyLibCalls/ test/Verifier/ In-Reply-To: <82528343-5E91-4638-9810-02F1B3D681EC@apple.com> References: <20100402184302.D7E7F2A6C12C@llvm.org> <82528343-5E91-4638-9810-02F1B3D681EC@apple.com> Message-ID: <32E72C7C-5637-4B02-9DF8-DFE388FFC69C@apple.com> Reverted David's patch, now we are good. Evan On Apr 2, 2010, at 12:14 PM, Evan Cheng wrote: > TOT is still failing a lot of tests. > > Evan > On Apr 2, 2010, at 11:50 AM, Bob Wilson wrote: > >> Are you sure? Was it the virt.cpp failure? All of the initial buildbot complaints were synced to 100192, so they were missing the clang change in 100193. >> >> On Apr 2, 2010, at 11:43 AM, Mon P Wang wrote: >> >>> Author: wangmp >>> Date: Fri Apr 2 13:43:02 2010 >>> New Revision: 100199 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=100199&view=rev >>> Log: >>> Revert r100191 since it breaks objc in clang >>> >>> Modified: >>> llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>> llvm/trunk/include/llvm/IntrinsicInst.h >>> llvm/trunk/include/llvm/Intrinsics.td >>> llvm/trunk/include/llvm/Support/IRBuilder.h >>> llvm/trunk/include/llvm/Target/TargetLowering.h >>> llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h >>> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>> llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp >>> llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >>> llvm/trunk/lib/Target/ARM/ARMISelLowering.h >>> llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp >>> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >>> llvm/trunk/lib/Target/X86/X86ISelLowering.h >>> llvm/trunk/lib/Target/XCore/XCoreISelLowering.cpp >>> llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >>> llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >>> llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp >>> llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >>> llvm/trunk/lib/Transforms/Utils/BuildLibCalls.cpp >>> llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >>> llvm/trunk/lib/VMCore/AutoUpgrade.cpp >>> llvm/trunk/test/Analysis/BasicAA/modref.ll >>> llvm/trunk/test/Bitcode/memcpy.ll >>> llvm/trunk/test/Transforms/InstCombine/memset_chk.ll >>> llvm/trunk/test/Transforms/InstCombine/objsize.ll >>> llvm/trunk/test/Transforms/MemCpyOpt/align.ll >>> llvm/trunk/test/Transforms/SimplifyLibCalls/StrCpy.ll >>> llvm/trunk/test/Verifier/2006-12-12-IntrinsicDefine.ll >>> >>> Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAG.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAG.h?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/CodeGen/SelectionDAG.h (original) >>> +++ llvm/trunk/include/llvm/CodeGen/SelectionDAG.h Fri Apr 2 13:43:02 2010 >>> @@ -534,17 +534,17 @@ >>> SDValue getStackArgumentTokenFactor(SDValue Chain); >>> >>> SDValue getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >>> - SDValue Size, unsigned Align, bool isVol, bool AlwaysInline, >>> + SDValue Size, unsigned Align, bool AlwaysInline, >>> const Value *DstSV, uint64_t DstSVOff, >>> const Value *SrcSV, uint64_t SrcSVOff); >>> >>> SDValue getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >>> - SDValue Size, unsigned Align, bool isVol, >>> + SDValue Size, unsigned Align, >>> const Value *DstSV, uint64_t DstOSVff, >>> const Value *SrcSV, uint64_t SrcSVOff); >>> >>> SDValue getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, SDValue Src, >>> - SDValue Size, unsigned Align, bool isVol, >>> + SDValue Size, unsigned Align, >>> const Value *DstSV, uint64_t DstSVOff); >>> >>> /// getSetCC - Helper function to make it easier to build SetCC's if you just >>> >>> Modified: llvm/trunk/include/llvm/IntrinsicInst.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicInst.h?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/IntrinsicInst.h (original) >>> +++ llvm/trunk/include/llvm/IntrinsicInst.h Fri Apr 2 13:43:02 2010 >>> @@ -133,13 +133,6 @@ >>> return getAlignmentCst()->getZExtValue(); >>> } >>> >>> - ConstantInt *getVolatileCst() const { >>> - return cast(const_cast(getOperand(5))); >>> - } >>> - bool isVolatile() const { >>> - return getVolatileCst()->getZExtValue() != 0; >>> - } >>> - >>> /// getDest - This is just like getRawDest, but it strips off any cast >>> /// instructions that feed it, giving the original input. The returned >>> /// value is guaranteed to be a pointer. >>> @@ -162,11 +155,7 @@ >>> void setAlignment(Constant* A) { >>> setOperand(4, A); >>> } >>> - >>> - void setVolatile(Constant* V) { >>> - setOperand(5, V); >>> - } >>> - >>> + >>> const Type *getAlignmentType() const { >>> return getOperand(4)->getType(); >>> } >>> >>> Modified: llvm/trunk/include/llvm/Intrinsics.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Intrinsics.td (original) >>> +++ llvm/trunk/include/llvm/Intrinsics.td Fri Apr 2 13:43:02 2010 >>> @@ -224,16 +224,16 @@ >>> // >>> >>> def int_memcpy : Intrinsic<[], >>> - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, >>> - llvm_i32_ty, llvm_i1_ty], >>> + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, >>> + llvm_i32_ty], >>> [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; >>> def int_memmove : Intrinsic<[], >>> - [llvm_anyptr_ty, llvm_anyptr_ty, llvm_anyint_ty, >>> - llvm_i32_ty, llvm_i1_ty], >>> + [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty, >>> + llvm_i32_ty], >>> [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>; >>> def int_memset : Intrinsic<[], >>> - [llvm_anyptr_ty, llvm_i8_ty, llvm_anyint_ty, >>> - llvm_i32_ty, llvm_i1_ty], >>> + [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty, >>> + llvm_i32_ty], >>> [IntrWriteArgMem, NoCapture<0>]>; >>> >>> // These functions do not actually read memory, but they are sensitive to the >>> >>> Modified: llvm/trunk/include/llvm/Support/IRBuilder.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) >>> +++ llvm/trunk/include/llvm/Support/IRBuilder.h Fri Apr 2 13:43:02 2010 >>> @@ -917,11 +917,6 @@ >>> Value *Args[] = { Arg1, Arg2, Arg3, Arg4 }; >>> return Insert(CallInst::Create(Callee, Args, Args+4), Name); >>> } >>> - CallInst *CreateCall5(Value *Callee, Value *Arg1, Value *Arg2, Value *Arg3, >>> - Value *Arg4, Value *Arg5, const Twine &Name = "") { >>> - Value *Args[] = { Arg1, Arg2, Arg3, Arg4, Arg5 }; >>> - return Insert(CallInst::Create(Callee, Args, Args+5), Name); >>> - } >>> >>> template >>> CallInst *CreateCall(Value *Callee, InputIterator ArgBegin, >>> >>> Modified: llvm/trunk/include/llvm/Target/TargetLowering.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) >>> +++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Apr 2 13:43:02 2010 >>> @@ -1187,7 +1187,7 @@ >>> EmitTargetCodeForMemcpy(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, >>> SDValue Op1, SDValue Op2, >>> - SDValue Op3, unsigned Align, bool isVolatile, >>> + SDValue Op3, unsigned Align, >>> bool AlwaysInline, >>> const Value *DstSV, uint64_t DstOff, >>> const Value *SrcSV, uint64_t SrcOff) { >>> @@ -1204,7 +1204,7 @@ >>> EmitTargetCodeForMemmove(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, >>> SDValue Op1, SDValue Op2, >>> - SDValue Op3, unsigned Align, bool isVolatile, >>> + SDValue Op3, unsigned Align, >>> const Value *DstSV, uint64_t DstOff, >>> const Value *SrcSV, uint64_t SrcOff) { >>> return SDValue(); >>> @@ -1220,7 +1220,7 @@ >>> EmitTargetCodeForMemset(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, >>> SDValue Op1, SDValue Op2, >>> - SDValue Op3, unsigned Align, bool isVolatile, >>> + SDValue Op3, unsigned Align, >>> const Value *DstSV, uint64_t DstOff) { >>> return SDValue(); >>> } >>> >>> Modified: llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h (original) >>> +++ llvm/trunk/include/llvm/Transforms/Utils/BuildLibCalls.h Fri Apr 2 13:43:02 2010 >>> @@ -46,8 +46,8 @@ >>> >>> /// EmitMemCpy - Emit a call to the memcpy function to the builder. This >>> /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. >>> - Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, unsigned Align, >>> - bool isVolatile, IRBuilder<> &B, const TargetData *TD); >>> + Value *EmitMemCpy(Value *Dst, Value *Src, Value *Len, >>> + unsigned Align, IRBuilder<> &B, const TargetData *TD); >>> >>> /// EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder. >>> /// This expects that the Len and ObjSize have type 'intptr_t' and Dst/Src >>> @@ -57,8 +57,8 @@ >>> >>> /// EmitMemMove - Emit a call to the memmove function to the builder. This >>> /// always expects that the size has type 'intptr_t' and Dst/Src are pointers. >>> - Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, unsigned Align, >>> - bool isVolatile, IRBuilder<> &B, const TargetData *TD); >>> + Value *EmitMemMove(Value *Dst, Value *Src, Value *Len, >>> + unsigned Align, IRBuilder<> &B, const TargetData *TD); >>> >>> /// EmitMemChr - Emit a call to the memchr function. This assumes that Ptr is >>> /// a pointer, Val is an i32 value, and Len is an 'intptr_t' value. >>> @@ -70,8 +70,8 @@ >>> const TargetData *TD); >>> >>> /// EmitMemSet - Emit a call to the memset function >>> - Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, bool isVolatile, >>> - IRBuilder<> &B, const TargetData *TD); >>> + Value *EmitMemSet(Value *Dst, Value *Val, Value *Len, IRBuilder<> &B, >>> + const TargetData *TD); >>> >>> /// EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' >>> /// (e.g. 'floor'). This function is known to take a single of type matching >>> >>> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=100199&r1=100198&r2=100199&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Apr 2 13:43:02 2010 >>> @@ -3263,8 +3263,7 @@ >>> static SDValue getMemcpyLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, SDValue Dst, >>> SDValue Src, uint64_t Size, >>> - unsigned Align, bool isVol, >>> - bool AlwaysInline, >>> + unsigned Align, bool AlwaysInline, >>> const Value *DstSV, uint64_t DstSVOff, >>> const Value *SrcSV, uint64_t SrcSVOff) { >>> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >>> @@ -3320,7 +3319,7 @@ >>> Value = getMemsetStringVal(VT, dl, DAG, TLI, Str, SrcOff); >>> Store = DAG.getStore(Chain, dl, Value, >>> getMemBasePlusOffset(Dst, DstOff, DAG), >>> - DstSV, DstSVOff + DstOff, isVol, false, Align); >>> + DstSV, DstSVOff + DstOff, false, false, Align); >>> } else { >>> // The type might not be legal for the target. This should only happen >>> // if the type is smaller than a legal type, as on PPC, so the right >>> @@ -3331,11 +3330,11 @@ >>> assert(NVT.bitsGE(VT)); >>> Value = DAG.getExtLoad(ISD::EXTLOAD, dl, NVT, Chain, >>> getMemBasePlusOffset(Src, SrcOff, DAG), >>> - SrcSV, SrcSVOff + SrcOff, VT, isVol, false, >>> + SrcSV, SrcSVOff + SrcOff, VT, false, false, >>> MinAlign(SrcAlign, SrcOff)); >>> Store = DAG.getTruncStore(Chain, dl, Value, >>> getMemBasePlusOffset(Dst, DstOff, DAG), >>> - DstSV, DstSVOff + DstOff, VT, isVol, false, >>> + DstSV, DstSVOff + DstOff, VT, false, false, >>> Align); >>> } >>> OutChains.push_back(Store); >>> @@ -3350,8 +3349,7 @@ >>> static SDValue getMemmoveLoadsAndStores(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, SDValue Dst, >>> SDValue Src, uint64_t Size, >>> - unsigned Align, bool isVol, >>> - bool AlwaysInline, >>> + unsigned Align,bool AlwaysInline, >>> const Value *DstSV, uint64_t DstSVOff, >>> const Value *SrcSV, uint64_t SrcSVOff) { >>> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >>> @@ -3399,7 +3397,7 @@ >>> >>> Value = DAG.getLoad(VT, dl, Chain, >>> getMemBasePlusOffset(Src, SrcOff, DAG), >>> - SrcSV, SrcSVOff + SrcOff, isVol, false, SrcAlign); >>> + SrcSV, SrcSVOff + SrcOff, false, false, SrcAlign); >>> LoadValues.push_back(Value); >>> LoadChains.push_back(Value.getValue(1)); >>> SrcOff += VTSize; >>> @@ -3414,7 +3412,7 @@ >>> >>> Store = DAG.getStore(Chain, dl, LoadValues[i], >>> getMemBasePlusOffset(Dst, DstOff, DAG), >>> - DstSV, DstSVOff + DstOff, isVol, false, Align); >>> + DstSV, DstSVOff + DstOff, false, false, Align); >>> OutChains.push_back(Store); >>> DstOff += VTSize; >>> } >>> @@ -3426,7 +3424,7 @@ >>> static SDValue getMemsetStores(SelectionDAG &DAG, DebugLoc dl, >>> SDValue Chain, SDValue Dst, >>> SDValue Src, uint64_t Size, >>> - unsigned Align, bool isVol, >>> + unsigned Align, >>> const Value *DstSV, uint64_t DstSVOff) { >>> const TargetLowering &TLI = DAG.getTargetLoweringInfo(); >>> >>> @@ -3465,7 +3463,7 @@ >>> SDValue Value = getMemsetValue(Src, VT, DAG, dl); >>> SDValue Store = DAG.getStore(Chain, dl, Value, >>> getMemBasePlusOffset(Dst, DstOff, DAG), >>> - DstSV, DstSVOff + DstOff, isVol, false, 0); >>> + DstSV, DstSVOff + DstOff, false, false, 0); >>> OutChains.push_back(Store); >>> DstOff += VTSize; >>> } >>> @@ -3476,7 +3474,7 @@ >>> >>> SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst, >>> SDValue Src, SDValue Size, >>> - unsigned Align, bool isVol, bool AlwaysInline, >>> + unsigned Align, bool AlwaysInline, >>> const Value *DstSV, uint64_t DstSVOff, >>> const Value *SrcSV, uint64_t SrcSVOff) { >>> >>> @@ -3490,7 +3488,7 @@ >>> >>> SDValue Result = getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >>> ConstantSize->getZExtValue(),Align, >>> - isVol, false, DstSV, DstSVOff, SrcSV, SrcSVOff); >>> + false, DstSV, DstSVOff, SrcSV, SrcSVOff); >>> if (Result.getNode()) >>> return Result; >>> } >>> @@ -3499,7 +3497,7 @@ >>> // code. If the target chooses to do this, this is the next best. >>> SDValue Result = >>> TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, >>> - isVol, AlwaysInline, >>> + AlwaysInline, >>> DstSV, DstSVOff, SrcSV, SrcSVOff); >>> if (Result.getNode()) >>> return Result; >>> @@ -3509,12 +3507,11 @@ >>> if (AlwaysInline) { >>> assert(ConstantSize && "AlwaysInline requires a constant size!"); >>> return getMemcpyLoadsAndStores(*this, dl, Chain, Dst, Src, >>> - ConstantSize->getZExtValue(), Align, isVol, >>> - true, DstSV, DstSVOff, SrcSV, SrcSVOff); >>> + ConstantSize->getZExtValue(), Align, true, >>> + DstSV, DstSVOff, SrcSV, SrcSVOff); >>> } >>> >>> // Emit a library call. >>> - assert(!isVol && "library memcpy does not support volatile"); >>> TargetLowering::ArgListTy Args; >>> TargetLowering::ArgListEntry Entry; >>> Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); >>> @@ -3535,7 +3532,7 @@ >>> >>> SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst, >>> SDValue Src, SDValue Size, >>> - unsigned Align, bool isVol, >>> + unsigned Align, >>> const Value *DstSV, uint64_t DstSVOff, >>> const Value *SrcSV, uint64_t SrcSVOff) { >>> >>> @@ -3549,8 +3546,8 @@ >>> >>> SDValue Result = >>> getMemmoveLoadsAndStores(*this, dl, Chain, Dst, Src, >>> - ConstantSize->getZExtValue(), Align, isVol, >>> - false, DstSV, DstSVOff, SrcSV, SrcSVOff); >>> + ConstantSize->getZExtValue(), >>> + Align, false, DstSV, DstSVOff, SrcSV, SrcSVOff); >>> if (Result.getNode()) >>> return Result; >>> } >>> @@ -3558,13 +3555,12 @@ >>> // Then check to see if we should lower the memmove with target-specific >>> // code. If the target chooses to do this, this is the next best. >>> SDValue Result = >>> - TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, >>> + TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, >>> DstSV, DstSVOff, SrcSV, SrcSVOff); >>> if (Result.getNode()) >>> return Result; >>> >>> // Emit a library call. >>> - assert(!isVol && "library memmove does not support volatile"); >>> TargetLowering::ArgListTy Args; >>> TargetLowering::ArgListEntry Entry; >>> Entry.Ty = TLI.getTargetData()->getIntPtrType(*getContext()); >>> @@ -3585,7 +3581,7 @@ >>> >>> SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst, >>> SDValue Src, SDValue Size, >>> - unsigned Align, bool isVol, >>> + unsigned Align, >>> const Val
Run OrderStart Time End Time  
%s%s %s View Results