From gaeke at cs.uiuc.edu Mon Jul 12 01:22:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Jul 12 01:22:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407120621.BAA25681@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.96 -> 1.97 --- Log message: Wrap long lines. No functional changes. --- Diffs of the changes: (+29 -20) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.96 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.97 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.96 Sun Jul 11 19:33:26 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Mon Jul 12 01:21:33 2004 @@ -134,7 +134,9 @@ DEBUG(std::cerr << "findRegsToSave: RegsToSave (size " << RegsToSave.size () << ") contains: ("; for (std::set::iterator i = RegsToSave.begin (), - e = RegsToSave.end (); i != e; ++i) { std::cerr << RegStr (*i) << " "; } + e = RegsToSave.end (); i != e; ++i) { + std::cerr << RegStr (*i) << " "; + } std::cerr << " )\n"); } @@ -148,7 +150,8 @@ const SparcV9RegInfo &TRI = *TM->getRegInfo (); unsigned RegType = TRI.getRegType (R); const char *RegName = TRI.getUnifiedRegName (R); - return std::string("reg#") + utostr(R) + "(" + RegTypeStrings[RegType] + ")=%" + RegName; + return std::string("reg#") + utostr(R) + "(" + RegTypeStrings[RegType] + + ")=%" + RegName; } void UnpackTraceFunction::PrintAI (const AllocInfo &AI) const { @@ -156,7 +159,8 @@ case AllocInfo::Allocated: std::cerr << "allocated to " << RegStr (AI.Placement); return; case AllocInfo::Spilled: - std::cerr << "spilled at 0x" << std::hex << AI.Placement << std::dec; return; + std::cerr << "spilled at 0x" << std::hex << AI.Placement << std::dec; + return; case AllocInfo::NotAllocated: std::cerr << "not allocated"; return; } @@ -202,7 +206,8 @@ mvec.clear (); unsigned R = *i; DEBUG (std::cerr << "rewriteProlog: Saving " << RegStr (R) << "\n"); - TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (R), TRI.getRegType (R), g2); + TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (R), TRI.getRegType (R), + g2); for (std::vector::iterator vi = mvec.begin (), ve = mvec.end (); vi != ve; ++vi) E.push_back (*vi); @@ -263,12 +268,14 @@ } } -static void regAllocConstORi (std::vector &mvec, unsigned DestReg, unsigned SpareReg) { +static void regAllocConstORi (std::vector &mvec, + unsigned DestReg, unsigned SpareReg) { MachineInstr &theInst = *mvec.back(); assert (theInst.getOpcode () == V9::ORi && theInst.getNumOperands () == 3 && theInst.getOperand (2).isDef () - && theInst.getOperand (2).getType () == MachineOperand::MO_VirtualRegister + && theInst.getOperand (2).getType () + == MachineOperand::MO_VirtualRegister && "wrong machineInstr passed to regAllocConstORi"); theInst.SetRegForOperand (2, DestReg); } @@ -290,7 +297,7 @@ for (std::vector::iterator i = mvec.begin (), e = mvec.end(); i != e; ++i) { MachineInstr &MInst = **i; - for (unsigned opNum=0, nOps=MInst.getNumOperands (); opNum != nOps; + for (unsigned opNum = 0, nOps = MInst.getNumOperands (); opNum != nOps; ++opNum) { MachineOperand &Op = MInst.getOperand (opNum); if (Op.getType() == MachineOperand::MO_VirtualRegister) { @@ -307,21 +314,23 @@ } } -void UnpackTraceFunction::copyConstantToRegister (MachineFunction &MF, - Constant *C, unsigned Reg, - unsigned SpareReg, - std::vector &mvec) { +void +UnpackTraceFunction::copyConstantToRegister (MachineFunction &MF, Constant *C, + unsigned Reg, unsigned SpareReg, + std::vector &mvec){ const TargetInstrInfo &TII = *TM->getInstrInfo (); TmpInstruction *tmp = new TmpInstruction (C); MachineCodeForInstruction throwaway; - TII.CreateCodeToLoadConst (*TM, const_cast (MF.getFunction ()), C, tmp, mvec, throwaway); + TII.CreateCodeToLoadConst (*TM, const_cast (MF.getFunction ()), + C, tmp, mvec, throwaway); - DEBUG (for (std::vector::iterator i = mvec.begin (), e = mvec.end (); - i != e; ++i) - std::cerr << "copyConstantToRegister Input: " << **i << "\n"); + DEBUG (for (std::vector::iterator i = mvec.begin (), + e = mvec.end (); i != e; ++i) + std::cerr << "copyConstantToRegister Input: " << **i << "\n"); - // note: this is pretty seriously hardwired for now. the problem is that in full - // generality, this is a little tiny episode of register allocation + // note: this is pretty seriously hardwired for now. the problem is + // that in full generality, this is a little tiny episode of register + // allocation if (mvec.size() == 1 && mvec.back()->getOpcode() == V9::ORi) { regAllocConstORi (mvec,Reg,SpareReg); } else if (mvec.size() == 7 && mvec.back()->getOpcode() == V9::LDDFi) { @@ -330,9 +339,9 @@ assert (0 && "unknown sequence coming out of CreateCodeToLoadConst"); } - DEBUG (for (std::vector::iterator i = mvec.begin (), e = mvec.end (); - i != e; ++i) - std::cerr << "copyConstantToRegister Output: " << **i << "\n"); + DEBUG (for (std::vector::iterator i = mvec.begin (), + e = mvec.end (); i != e; ++i) + std::cerr << "copyConstantToRegister Output: " << **i << "\n"); } /// addLiveOutCopy - Add a copy of the Value which is liveOutValue in the From ghost at cs.msu.su Mon Jul 12 01:40:03 2004 From: ghost at cs.msu.su (Vladimir Prus) Date: Mon Jul 12 01:40:03 2004 Subject: [llvm-commits] Re: Dynamically loadable targets In-Reply-To: References: Message-ID: <200407121034.21421.ghost@cs.msu.su> Hi Chris, > I just checked in support for auto-registrating targets. This is cool. I though I'd try to do it myself, but you was faster ;-) > I think that > this should make your lives substantially easier by not having to have > hacky code in llc.cpp, the allocate*TargetMachine business is now all > gone, and you can even dynamically load your targets as plugins to avoid > having to rebuild llc all of the time. ...... > 4. You must register your target with RegisterTarget. That's actually the only thing I needed. > 6. You can choose to either statically link your TargetMachine into > llc/lli or to dynamically load it with -load. Well, actually, I'm already use Boost.Build, so I do dynamic linking to all targets without -load, and don't have to rebuild llc already ;-) The change is still good, because it eliminates the need to declare all targets in one place and besides, using -load is good sometimes. - Volodya From gaeke at cs.uiuc.edu Mon Jul 12 05:02:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Mon Jul 12 05:02:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407121001.FAA26866@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.97 -> 1.98 --- Log message: Just checking in unrelated cosmetic changes which I've accumulated as I rip apart rewriteEpilog(). --- Diffs of the changes: (+12 -11) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.97 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.98 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.97 Mon Jul 12 01:21:33 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Mon Jul 12 05:01:24 2004 @@ -399,11 +399,12 @@ // MatrixFn's stack, so MatrixFn's frame pointer will be the base // register. But first we need to load it from the stack (FIXME: we // should only do this once!) - TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), g3, TRI.getRegType(g3), - g2); + static const unsigned matrixFP = SparcV9::g3; + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), matrixFP, + TRI.getRegType(matrixFP), g2); DEBUG (std::cerr << "addLiveOutCopy: loading matrixFn's frame pointer; " << "value is spilled at offset = " << Target.Placement << "\n"); - BaseReg = g3; + BaseReg = matrixFP; Offset = Target.Placement; } TRI.cpReg2MemMI (mvec, R, BaseReg, Offset, RegType, g2); @@ -468,17 +469,16 @@ static const unsigned fp = SparcV9::i6, sp = SparcV9::o6, g1 = SparcV9::g1, g2 = SparcV9::g2; - // UTF epilog: start out by clearing everything out of the exit basic block - // (FIXME: may not work once we start doing optimizations!!! We will probably - // have to use a separate MBB) - MBB.clear (); - // This is just an educated guess... + // We start out each trace-exit MBB with %fp holding the TraceFn frame + // pointer. fpIsTraceFP = true; - - // Insert stores from each live-out variable's reg. in the trace + + // Replace the contents of the trace-exit MBB with live-out stores followed + // by a branch back to the matrix function's basic block. First, clear the + // MBB, then insert stores from each live-out variable's reg. in the trace // to its stack slot in the trace function, from which it will be // reloaded below into a register. - std::vector mvec; + MBB.clear (); LiveVariableVector &So = TF->LiveOutVector; for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) { @@ -511,6 +511,7 @@ // Restore MatrixFn's FP. Warning! After this point, addLiveOutCopy won't work // anymore, because it depends on being able to access TraceFn's frame // pointer in %fp. + std::vector mvec; mvec.clear (); TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), fp, TRI.getRegType(fp), g2); From brukman at cs.uiuc.edu Mon Jul 12 11:56:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon Jul 12 11:56:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407121655.LAA01570@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.213 -> 1.214 --- Log message: * Clarify Sparc as SparcV9 * Add link to bugzilla bug with list of miscompiled SparcV9 programs * Wrap long lines --- Diffs of the changes: (+6 -5) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.213 llvm/docs/ReleaseNotes.html:1.214 --- llvm/docs/ReleaseNotes.html:1.213 Fri Jul 9 01:58:43 2004 +++ llvm/docs/ReleaseNotes.html Mon Jul 12 11:55:41 2004 @@ -22,7 +22,7 @@
  • Known problems with the C Front-end
  • Known problems with the C++ Front-end
  • Known problems with the X86 Back-end -
  • Known problems with the Sparc Back-end +
  • Known problems with the SparcV9 Back-end
  • Known problems with the C back-end
  • Additional Information
  • @@ -278,7 +278,7 @@ asssertion
  • [adce] Crash handling unreachable code that unwinds
  • -
  • [sparc] LLC can't emit 2 functions +
  • [sparcv9] LLC can't emit 2 functions of the same name, both having constant pools
  • [livevar] Live variables missed physical register use of aliased definition
  • @@ -682,13 +682,14 @@
    @@ -750,7 +751,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/09 06:58:43 $ + Last modified: $Date: 2004/07/12 16:55:41 $ From lattner at cs.uiuc.edu Mon Jul 12 12:10:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jul 12 12:10:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407121709.MAA08213@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.214 -> 1.215 --- Log message: new feature --- Diffs of the changes: (+3 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.214 llvm/docs/ReleaseNotes.html:1.215 --- llvm/docs/ReleaseNotes.html:1.214 Mon Jul 12 11:55:41 2004 +++ llvm/docs/ReleaseNotes.html Mon Jul 12 12:09:23 2004 @@ -138,6 +138,8 @@ names.
  • We now generate HTML documentation and man pages for the tools from a single source (perl-style POD files).
  • +
  • The LLVM code generator can now dynamically load targets from shared +objects.
  • @@ -751,7 +753,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/12 16:55:41 $ + Last modified: $Date: 2004/07/12 17:09:23 $ From lattner at cs.uiuc.edu Mon Jul 12 12:38:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jul 12 12:38:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Regression/C/callargs.c Message-ID: <200407121737.MAA08504@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Regression/C: callargs.c updated: 1.1 -> 1.2 --- Log message: Fix bogus printf formats. Patch contributed by Vladimir Prus --- Diffs of the changes: (+6 -6) Index: llvm/test/Programs/SingleSource/Regression/C/callargs.c diff -u llvm/test/Programs/SingleSource/Regression/C/callargs.c:1.1 llvm/test/Programs/SingleSource/Regression/C/callargs.c:1.2 --- llvm/test/Programs/SingleSource/Regression/C/callargs.c:1.1 Wed Jul 10 16:54:03 2002 +++ llvm/test/Programs/SingleSource/Regression/C/callargs.c Mon Jul 12 12:37:14 2004 @@ -79,9 +79,9 @@ a15 = va_arg(ap, char*); printf("\nprintVarArgs with 15 arguments:\n"); - printf("\tArgs 1-5 : %d %f %c %lf %c\n", a1, a2, a3, a4, *a5); - printf("\tArgs 6-10 : %d %f %c %lf %c\n", a6, a7, a8, a9, *a10); - printf("\tArgs 11-14: %d %f %c %lf %c\n", a11, a12, a13, a14, *a15); + printf("\tArgs 1-5 : %d %f %c %f %c\n", a1, a2, a3, a4, *a5); + printf("\tArgs 6-10 : %d %f %c %f %c\n", a6, a7, a8, a9, *a10); + printf("\tArgs 11-14: %d %f %c %f %c\n", a11, a12, a13, a14, *a15); printf("\n"); return; } @@ -94,9 +94,9 @@ int a11, float a12, char a13, double a14, char* a15) { printf("\nprintArgsNoRet with 15 arguments:\n"); - printf("\tArgs 1-5 : %d %f %c %lf %c\n", a1, a2, a3, a4, *a5); - printf("\tArgs 6-10 : %d %f %c %lf %c\n", a6, a7, a8, a9, *a10); - printf("\tArgs 11-14: %d %f %c %lf %c\n", a11, a12, a13, a14, *a15); + printf("\tArgs 1-5 : %d %f %c %f %c\n", a1, a2, a3, a4, *a5); + printf("\tArgs 6-10 : %d %f %c %f %c\n", a6, a7, a8, a9, *a10); + printf("\tArgs 11-14: %d %f %c %f %c\n", a11, a12, a13, a14, *a15); printf("\n"); return; } From lattner at cs.uiuc.edu Mon Jul 12 15:25:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:25:14 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/StringExtras.h Message-ID: <200407122025.PAA03980@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: StringExtras.h updated: 1.16 -> 1.17 --- Log message: Fix warning compiling with VC++ --- Diffs of the changes: (+2 -2) Index: llvm/include/Support/StringExtras.h diff -u llvm/include/Support/StringExtras.h:1.16 llvm/include/Support/StringExtras.h:1.17 --- llvm/include/Support/StringExtras.h:1.16 Thu Jun 24 19:18:02 2004 +++ llvm/include/Support/StringExtras.h Mon Jul 12 15:25:04 2004 @@ -97,11 +97,11 @@ return Buffer; } -static inline std::string LowercaseString (const std::string &S) { +static inline std::string LowercaseString(const std::string &S) { std::string result (S); for (unsigned i = 0; i < S.length(); ++i) if (isupper (result[i])) - result[i] = tolower(result[i]); + result[i] = (char)tolower(result[i]); return result; } From lattner at cs.uiuc.edu Mon Jul 12 15:25:43 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:25:43 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407122025.PAA04031@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.55 -> 1.56 --- Log message: Add a missing #include --- Diffs of the changes: (+1 -0) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.55 llvm/include/llvm/Value.h:1.56 --- llvm/include/llvm/Value.h:1.55 Mon Jul 5 20:30:36 2004 +++ llvm/include/llvm/Value.h Mon Jul 12 15:25:33 2004 @@ -20,6 +20,7 @@ #include "llvm/AbstractTypeUser.h" #include "llvm/Use.h" #include "Support/Casting.h" +#include namespace llvm { From lattner at cs.uiuc.edu Mon Jul 12 15:27:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:27:41 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Message-ID: <200407122027.PAA04066@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.74 -> 1.75 --- Log message: Fix a really nasty logic error that VC noticed. Reid, this might matter to you :) --- Diffs of the changes: (+2 -2) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.74 llvm/lib/VMCore/Function.cpp:1.75 --- llvm/lib/VMCore/Function.cpp:1.74 Sun Jul 11 20:17:34 2004 +++ llvm/lib/VMCore/Function.cpp Mon Jul 12 15:27:31 2004 @@ -84,8 +84,8 @@ static bool removeDeadConstantUsers(Constant *C) { while (!C->use_empty()) { - if (Constant *C = dyn_cast(C->use_back())) { - if (!removeDeadConstantUsers(C)) + if (Constant *CU = dyn_cast(C->use_back())) { + if (!removeDeadConstantUsers(CU)) return false; // Constant wasn't dead. } else { return false; // Nonconstant user of the global. From lattner at cs.uiuc.edu Mon Jul 12 15:30:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:30:02 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Message-ID: <200407122030.PAA04137@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.58 -> 1.59 --- Log message: Fix unused var warning --- Diffs of the changes: (+2 -3) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.58 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.59 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.58 Sun Jul 4 06:42:49 2004 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Mon Jul 12 15:29:52 2004 @@ -773,9 +773,8 @@ // If we haven't seen this sub type before, add it to our type table! if (getSlot(SubTy) == -1) { SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); - int Slot = doInsertType(SubTy); - SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << - " slot=" << Slot << "\n"); + doInsertType(SubTy); + SC_DEBUG(" Inserted subtype: " << SubTy->getDescription()); } } } From lattner at cs.uiuc.edu Mon Jul 12 15:35:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:35:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200407122035.PAA04191@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.93 -> 1.94 --- Log message: implement new helper method --- Diffs of the changes: (+8 -0) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.93 llvm/lib/VMCore/Constants.cpp:1.94 --- llvm/lib/VMCore/Constants.cpp:1.93 Sun Jul 4 06:51:24 2004 +++ llvm/lib/VMCore/Constants.cpp Mon Jul 12 15:35:11 2004 @@ -997,6 +997,14 @@ return ConstantAggregateZero::get(Ty); } +Constant *ConstantStruct::get(const std::vector &V) { + std::vector StructEls; + StructEls.reserve(V.size()); + for (unsigned i = 0, e = V.size(); i != e; ++i) + StructEls.push_back(V[i]->getType()); + return get(StructType::get(StructEls), V); +} + // destroyConstant - Remove the constant from the constant table... // void ConstantStruct::destroyConstant() { From lattner at cs.uiuc.edu Mon Jul 12 15:36:18 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 15:36:18 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200407122036.PAA04242@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.48 -> 1.49 --- Log message: Add a helper method. The StructType element is completely redundant in most cases --- Diffs of the changes: (+3 -0) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.48 llvm/include/llvm/Constants.h:1.49 --- llvm/include/llvm/Constants.h:1.48 Mon Jun 21 07:11:01 2004 +++ llvm/include/llvm/Constants.h Mon Jul 12 15:36:08 2004 @@ -402,9 +402,12 @@ ConstantStruct(const StructType *T, const std::vector &Val); public: /// get() - Static factory methods - Return objects of the specified value + /// static Constant *get(const StructType *T, const std::vector &V); + static Constant *get(const std::vector &V); /// getType() specialization - Reduce amount of casting... + /// inline const StructType *getType() const { return reinterpret_cast(Value::getType()); } From brukman at cs.uiuc.edu Mon Jul 12 16:10:58 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 12 Jul 2004 16:10:58 -0500 Subject: [llvm-commits] CVS: llvm/docs/OpenProjects.html Message-ID: <200407122110.QAA04694@zion.cs.uiuc.edu> Changes in directory llvm/docs: OpenProjects.html updated: 1.32 -> 1.33 --- Log message: New open proj: C/C++ compiler in C++, with link to Ed Willink's C++ yacc grammar --- Diffs of the changes: (+7 -2) Index: llvm/docs/OpenProjects.html diff -u llvm/docs/OpenProjects.html:1.32 llvm/docs/OpenProjects.html:1.33 --- llvm/docs/OpenProjects.html:1.32 Fri Jul 2 01:27:12 2004 +++ llvm/docs/OpenProjects.html Mon Jul 12 16:10:47 2004 @@ -319,11 +319,16 @@
      -
    1. Port the Bigloo +
    2. Port the Bigloo Scheme compiler, from Manuel Serrano at INRIA Sophia-Antipolis, to output LLVM bytecode. It seems that it can already output .NET bytecode, JVM bytecode, and C, so LLVM would ostensibly be another good candidate.
    3. +
    4. Write a new frontend for C/C++ in C++, giving us the ability to +directly use LLVM C++ classes from within a compiler rather than use +C-based wrapper functions a la llvm-gcc. One possible starting point is the C++ +yacc grammar by Ed Willink.
    5. Write a new frontend for some other language (Java? OCaml? Forth?)
    6. Write a new backend for a target (IA64? MIPS? MMIX?)
    7. Write a disassembler for machine code that would use TableGen to output @@ -348,7 +353,7 @@ Chris Lattner
      LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/02 06:27:12 $ + Last modified: $Date: 2004/07/12 21:10:47 $ From lattner at cs.uiuc.edu Mon Jul 12 17:44:43 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 17:44:43 -0500 Subject: [llvm-commits] CVS: llvm-www/header.incl Message-ID: <200407122244.RAA09059@apoc.cs.uiuc.edu> Changes in directory llvm-www: header.incl updated: 1.22 -> 1.23 --- Log message: Add new status update --- Diffs of the changes: (+1 -0) Index: llvm-www/header.incl diff -u llvm-www/header.incl:1.22 llvm-www/header.incl:1.23 --- llvm-www/header.incl:1.22 Thu Jul 1 13:33:54 2004 +++ llvm-www/header.incl Mon Jul 12 17:44:33 2004 @@ -50,6 +50,7 @@ Status Updates
      + July 12, 2004
      June 9, 2004
      May 6, 2004
      March 19, 2004
      From brukman at cs.uiuc.edu Mon Jul 12 17:58:17 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 12 Jul 2004 17:58:17 -0500 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200407122258.RAA05406@zion.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.99 -> 1.100 --- Log message: * Tabs to spaces * Delete extra blank lines --- Diffs of the changes: (+5 -7) Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.99 llvm/tools/llc/llc.cpp:1.100 --- llvm/tools/llc/llc.cpp:1.99 Sat Jul 10 23:03:24 2004 +++ llvm/tools/llc/llc.cpp Mon Jul 12 17:58:07 2004 @@ -41,7 +41,6 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); - static cl::opt MArch("march", cl::desc("Architecture to generate assembly for:")); @@ -97,7 +96,6 @@ // Build up all of the passes that we want to do to the module... PassManager Passes; - Passes.add(new TargetData("llc", TD.isLittleEndian(), TD.getPointerSize(), TD.getPointerAlignment(), TD.getDoubleAlignment())); @@ -107,11 +105,11 @@ if (OutputFilename != "-") { // Specified an output filename? if (!Force && std::ifstream(OutputFilename.c_str())) { - // If force is not specified, make sure not to overwrite a file! - std::cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; - return 1; + // If force is not specified, make sure not to overwrite a file! + std::cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; + return 1; } Out = new std::ofstream(OutputFilename.c_str()); From brukman at cs.uiuc.edu Mon Jul 12 18:37:28 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Mon, 12 Jul 2004 18:37:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407122337.SAA06154@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.187 -> 1.188 --- Log message: Apple's MacOS X is another OS which does not provide alloca() via --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.187 llvm/lib/Target/CBackend/Writer.cpp:1.188 --- llvm/lib/Target/CBackend/Writer.cpp:1.187 Sat Jul 10 23:16:31 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Mon Jul 12 18:37:18 2004 @@ -664,7 +664,7 @@ static void generateCompilerSpecificCode(std::ostream& Out) { // Alloca is hard to get, and we don't want to include stdlib.h here... Out << "/* get a declaration for alloca */\n" - << "#if defined(sun) || defined(__CYGWIN__)\n" + << "#if defined(sun) || defined(__CYGWIN__) || defined(__APPLE__)\n" << "extern void *__builtin_alloca(unsigned long);\n" << "#define alloca(x) __builtin_alloca(x)\n" << "#else\n" From lattner at cs.uiuc.edu Mon Jul 12 20:49:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon, 12 Jul 2004 20:49:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407130149.UAA13748@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.221 -> 1.222 --- Log message: Factor some code to handle "load (constantexpr cast foo)" just like "load (cast foo)". This allows us to compile C++ code like this: class Bclass { public: virtual int operator()() { return 666; } }; class Dclass: public Bclass { public: virtual int operator()() { return 667; } } ; int main(int argc, char** argv) { Dclass x; return x(); } Into this: int %main(int %argc, sbyte** %argv) { entry: call void %__main( ) ret int 667 } Instead of this: int %main(int %argc, sbyte** %argv) { entry: %x = alloca "struct.std::bad_typeid" ; <"struct.std::bad_typeid"*> [#uses=3] call void %__main( ) %tmp.1.i.i = getelementptr "struct.std::bad_typeid"* %x, uint 0, uint 0, uint 0 ; [#uses=1] store int (...)** getelementptr ([3 x int (...)*]* %vtable for Bclass, int 0, long 2), int (...)*** %tmp.1.i.i %tmp.3.i = getelementptr "struct.std::bad_typeid"* %x, int 0, uint 0, uint 0 ; [#uses=1] store int (...)** getelementptr ([3 x int (...)*]* %vtable for Dclass, int 0, long 2), int (...)*** %tmp.3.i %tmp.5 = load int ("struct.std::bad_typeid"*)** cast (int (...)** getelementptr ([3 x int (...)*]* %vtable for Dclass, int 0, long 2) to int ("struct.std::bad_typeid"*)**) ; [#uses=1] %tmp.6 = call int %tmp.5( "struct.std::bad_typeid"* %x ) ; [#uses=1] ret int %tmp.6 ret int 0 } In order words, we now resolve the virtual function call. --- Diffs of the changes: (+32 -20) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.221 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.222 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.221 Tue Jul 6 14:28:42 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Jul 12 20:49:43 2004 @@ -2947,6 +2947,30 @@ return C; } +static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI) { + User *CI = cast(LI.getOperand(0)); + + const Type *DestPTy = cast(CI->getType())->getElementType(); + if (const PointerType *SrcTy = + dyn_cast(CI->getOperand(0)->getType())) { + const Type *SrcPTy = SrcTy->getElementType(); + if (SrcPTy->isSized() && DestPTy->isSized() && + IC.getTargetData().getTypeSize(SrcPTy) == + IC.getTargetData().getTypeSize(DestPTy) && + (SrcPTy->isInteger() || isa(SrcPTy)) && + (DestPTy->isInteger() || isa(DestPTy))) { + // Okay, we are casting from one integer or pointer type to another of + // the same size. Instead of casting the pointer before the load, cast + // the result of the loaded value. + Value *NewLoad = IC.InsertNewInstBefore(new LoadInst(CI->getOperand(0), + CI->getName()), LI); + // Now cast the result of the load. + return new CastInst(NewLoad, LI.getType()); + } + } + return 0; +} + Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { Value *Op = LI.getOperand(0); if (LI.isVolatile()) return 0; @@ -2964,33 +2988,21 @@ // Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded... if (ConstantExpr *CE = dyn_cast(Op)) - if (CE->getOpcode() == Instruction::GetElementPtr) + if (CE->getOpcode() == Instruction::GetElementPtr) { if (ConstantPointerRef *G=dyn_cast(CE->getOperand(0))) if (GlobalVariable *GV = dyn_cast(G->getValue())) if (GV->isConstant() && !GV->isExternal()) if (Constant *V = GetGEPGlobalInitializer(GV->getInitializer(), CE)) return ReplaceInstUsesWith(LI, V); + } else if (CE->getOpcode() == Instruction::Cast) { + if (Instruction *Res = InstCombineLoadCast(*this, LI)) + return Res; + } // load (cast X) --> cast (load X) iff safe - if (CastInst *CI = dyn_cast(Op)) { - const Type *DestPTy = cast(CI->getType())->getElementType(); - if (const PointerType *SrcTy = - dyn_cast(CI->getOperand(0)->getType())) { - const Type *SrcPTy = SrcTy->getElementType(); - if (SrcPTy->isSized() && DestPTy->isSized() && - TD->getTypeSize(SrcPTy) == TD->getTypeSize(DestPTy) && - (SrcPTy->isInteger() || isa(SrcPTy)) && - (DestPTy->isInteger() || isa(DestPTy))) { - // Okay, we are casting from one integer or pointer type to another of - // the same size. Instead of casting the pointer before the load, cast - // the result of the loaded value. - Value *NewLoad = InsertNewInstBefore(new LoadInst(CI->getOperand(0), - CI->getName()), LI); - // Now cast the result of the load. - return new CastInst(NewLoad, LI.getType()); - } - } - } + if (CastInst *CI = dyn_cast(Op)) + if (Instruction *Res = InstCombineLoadCast(*this, LI)) + return Res; return 0; } From lattner at cs.uiuc.edu Tue Jul 13 01:11:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 01:11:58 -0500 Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp Message-ID: <200407130611.BAA18906@apoc.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: TableGen.cpp updated: 1.27 -> 1.28 --- Log message: Make tblgen not try to be smart. This is better handled in makefiles if at all. Patch contributed by Vladimir Prus! --- Diffs of the changes: (+3 -14) Index: llvm/utils/TableGen/TableGen.cpp diff -u llvm/utils/TableGen/TableGen.cpp:1.27 llvm/utils/TableGen/TableGen.cpp:1.28 --- llvm/utils/TableGen/TableGen.cpp:1.27 Thu May 27 00:36:52 2004 +++ llvm/utils/TableGen/TableGen.cpp Tue Jul 13 01:11:46 2004 @@ -421,18 +421,15 @@ std::ostream *Out = &std::cout; if (OutputFilename != "-") { - // Output to a .tmp file, because we don't actually want to overwrite the - // output file unless the generated file is different or the specified file - // does not exist. - Out = new std::ofstream((OutputFilename+".tmp").c_str()); + Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { - std::cerr << argv[0] << ": error opening " << OutputFilename << ".tmp!\n"; + std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } // Make sure the file gets removed if *gasp* tablegen crashes... - RemoveFileOnSignal(OutputFilename+".tmp"); + RemoveFileOnSignal(OutputFilename); } try { @@ -492,14 +489,6 @@ if (Out != &std::cout) { delete Out; // Close the file - - // Now that we have generated the result, check to see if we either don't - // have the requested file, or if the requested file is different than the - // file we generated. If so, move the generated file over the requested - // file. Otherwise, just remove the file we just generated, so 'make' - // doesn't try to regenerate tons of dependencies. - // - MoveFileOverIfUpdated(OutputFilename+".tmp", OutputFilename); } return 0; } From lattner at cs.uiuc.edu Tue Jul 13 01:58:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 01:58:17 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407130658.BAA24787@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.172 -> 1.173 --- Log message: Replace a bunch of complex ConstantPointerRef referring code with simple code. --- Diffs of the changes: (+3 -11) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.172 llvm/lib/AsmParser/llvmAsmParser.y:1.173 --- llvm/lib/AsmParser/llvmAsmParser.y:1.172 Fri Jul 9 11:43:55 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 01:58:07 2004 @@ -118,17 +118,9 @@ if (I != GlobalRefs.end()) { GlobalValue *OldGV = I->second; // Get the placeholder... I->first.second.destroy(); // Free string memory if necessary - - // Loop over all of the uses of the GlobalValue. The only thing they are - // allowed to be is ConstantPointerRef's. - assert(OldGV->hasOneUse() && "Only one reference should exist!"); - User *U = OldGV->use_back(); // Must be a ConstantPointerRef... - ConstantPointerRef *CPR = cast(U); - - // Change the const pool reference to point to the real global variable - // now. This should drop a use from the OldGV. - CPR->replaceUsesOfWithOnConstant(OldGV, GV); - assert(OldGV->use_empty() && "All uses should be gone now!"); + + // Replace all uses of the placeholder with the new GV + OldGV->replaceAllUsesWith(GV); // Remove OldGV from the module... if (GlobalVariable *GVar = dyn_cast(OldGV)) From gaeke at cs.uiuc.edu Tue Jul 13 02:37:54 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue, 13 Jul 2004 02:37:54 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407130737.CAA11246@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.113 -> 1.114 --- Log message: Fix warning on SparcV9, where sizeof (int) != sizeof (void *). --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.113 llvm/lib/Bytecode/Reader/Reader.cpp:1.114 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.113 Sun Jul 11 12:28:43 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Jul 13 02:37:43 2004 @@ -410,7 +410,7 @@ error("Corrupt compaction table entry!" + utostr(TyID) + ", " + utostr(SlotNo) + ": " + utostr(ModuleValues.size()) + ", " - + utohexstr(int((void*)ModuleValues[TyID])) + ", " + + utohexstr(intptr_t((void*)ModuleValues[TyID])) + ", " + utostr(ModuleValues[TyID]->size())); } return ModuleValues[TyID]->getOperand(SlotNo); From lattner at cs.uiuc.edu Tue Jul 13 02:59:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 02:59:37 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407130759.CAA27787@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.173 -> 1.174 --- Log message: A couple of substantial cleanup fixes: 1. Split setValueName into two separate functions, one that is only used at function scope and doesn't have to deal with duplicates, and one that can be used either at global or function scope but that does deal with conflicts. Conflicts were only in there because of the crappy old CFE and probably should be entirely eliminated. 2. Insert BasicBlock's into the parent functions when they are created instead of when they are complete. This effects name lookup (for the better), which will be exploited in the next patch. --- Diffs of the changes: (+72 -47) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.173 llvm/lib/AsmParser/llvmAsmParser.y:1.174 --- llvm/lib/AsmParser/llvmAsmParser.y:1.173 Tue Jul 13 01:58:07 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 02:59:27 2004 @@ -479,36 +479,77 @@ } +static void setValueNameInternal(Value *V, const std::string &Name, + SymbolTable &ST) { + if (V->getType() == Type::VoidTy) + ThrowException("Can't assign name '" + Name + "' to value with void type!"); + + // Set the name + V->setName(Name, &ST); + + // If we're in function scope + if (inFunctionScope()) { + // Look up the symbol in the Function's local symboltable + Value *Existing = CurFun.LocalSymtab.lookup(V->getType(),Name); + + // If it already exists, bail out. We have to recheck this, because there + // may be entries inserted into the current basic block (which has not yet + // been inserted into the function) which collide. + if (Existing) { + ThrowException("Redefinition of value named '" + Name + "' in the '" + + V->getType()->getDescription() + "' type plane!"); + } else { + // otherwise, since it doesn't exist, insert it. + CurFun.LocalSymtab.insert(V); + } + } +} + // setValueName - Set the specified value to the name given. The name may be // null potentially, in which case this is a noop. The string passed in is -// assumed to be a malloc'd string buffer, and is freed by this function. +// assumed to be a malloc'd string buffer, and is free'd by this function. +// +static void setValueName(Value *V, char *NameStr) { + if (NameStr) { + std::string Name(NameStr); // Copy string + free(NameStr); // Free old string + + assert(inFunctionScope() && "Must be in function scope!"); + SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); + if (ST.lookup(V->getType(), Name)) + ThrowException("Redefinition of value named '" + Name + "' in the '" + + V->getType()->getDescription() + "' type plane!"); + + setValueNameInternal(V, Name, ST); + } +} + +// setValueNameMergingDuplicates - Set the specified value to the name given. +// The name may be null potentially, in which case this is a noop. The string +// passed in is assumed to be a malloc'd string buffer, and is free'd by this +// function. // // This function returns true if the value has already been defined, but is // allowed to be redefined in the specified context. If the name is a new name // for the typeplane, false is returned. // -static bool setValueName(Value *V, char *NameStr) { +static bool setValueNameMergingDuplicates(Value *V, char *NameStr) { if (NameStr == 0) return false; - + std::string Name(NameStr); // Copy string free(NameStr); // Free old string - if (V->getType() == Type::VoidTy) - ThrowException("Can't assign name '" + Name + - "' to a null valued instruction!"); - + // FIXME: If we eliminated the function constant pool (which we should), this + // would just unconditionally look at the module symtab. SymbolTable &ST = inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : CurModule.CurrentModule->getSymbolTable(); Value *Existing = ST.lookup(V->getType(), Name); - if (Existing) { // Inserting a name that is already defined??? - // We are a simple redefinition of a value, check to see if it - // is defined the same as the old one... - if (const Constant *C = dyn_cast(Existing)) { - if (C == V) return true; // Constants are equal to themselves - } else if (GlobalVariable *EGV = dyn_cast(Existing)) { + // We are a simple redefinition of a value, check to see if it is defined + // the same as the old one... + if (GlobalVariable *EGV = dyn_cast(Existing)) { // We are allowed to redefine a global variable in two circumstances: // 1. If at least one of the globals is uninitialized or // 2. If both initializers have the same value. @@ -529,35 +570,20 @@ return true; // They are equivalent! } } + } else if (const Constant *C = dyn_cast(Existing)) { + if (C == V) return true; // Constants are equal to themselves } ThrowException("Redefinition of value named '" + Name + "' in the '" + V->getType()->getDescription() + "' type plane!"); } - - // Set the name - V->setName(Name, &ST); - - // If we're in function scope - if (inFunctionScope()) { - // Look up the symbol in the function's local symboltable - Existing = CurFun.LocalSymtab.lookup(V->getType(),Name); - - // If it already exists - if (Existing) { - // Bail - ThrowException("Redefinition of value named '" + Name + "' in the '" + - V->getType()->getDescription() + "' type plane!"); - - // otherwise, since it doesn't exist - } else { - // Insert it. - CurFun.LocalSymtab.insert(V); - } - } + + setValueNameInternal(V, Name, ST); return false; } + + // setTypeName - Set the specified type to the name given. The name may be // null potentially, in which case this is a noop. The string passed in is // assumed to be a malloc'd string buffer, and is freed by this function. @@ -1368,7 +1394,8 @@ // ConstPool - Constants with optional names assigned to them. ConstPool : ConstPool OptAssign CONST ConstVal { - if (!setValueName($4, $2)) + // FIXME: THIS SHOULD REALLY BE ELIMINATED. It is totally unneeded. + if (!setValueNameMergingDuplicates($4, $2)) InsertValue($4); } | ConstPool OptAssign TYPE TypesV { // Types can be defined in the const pool @@ -1404,7 +1431,7 @@ ThrowException("Global value initializer is not a constant!"); GlobalVariable *GV = new GlobalVariable(Ty, $4, $3, Initializer); - if (!setValueName(GV, $2)) { // If not redefining... + if (!setValueNameMergingDuplicates(GV, $2)) { // If not redefining... CurModule.CurrentModule->getGlobalList().push_back(GV); int Slot = InsertValue(GV, CurModule.Values); @@ -1420,7 +1447,7 @@ const Type *Ty = *$5; // Global declarations appear in Constant Pool GlobalVariable *GV = new GlobalVariable(Ty,$4,GlobalValue::ExternalLinkage); - if (!setValueName(GV, $2)) { // If not redefining... + if (!setValueNameMergingDuplicates(GV, $2)) { // If not redefining... CurModule.CurrentModule->getGlobalList().push_back(GV); int Slot = InsertValue(GV, CurModule.Values); @@ -1553,9 +1580,7 @@ I != $4->end(); ++I, ++ArgIt) { delete I->first; // Delete the typeholder... - if (setValueName(ArgIt, I->second)) // Insert arg into symtab... - assert(0 && "No arg redef allowed!"); - + setValueName(ArgIt, I->second); // Insert arg into symtab... InsertValue(ArgIt); } @@ -1635,10 +1660,10 @@ }; BasicBlockList : BasicBlockList BasicBlock { - ($$ = $1)->getBasicBlockList().push_back($2); + $$ = $1; } | FunctionHeader BasicBlock { // Do not allow functions with 0 basic blocks - ($$ = $1)->getBasicBlockList().push_back($2); + $$ = $1; }; @@ -1646,7 +1671,7 @@ // br, br/cc, switch, ret // BasicBlock : InstructionList OptAssign BBTerminatorInst { - if (setValueName($3, $2)) { assert(0 && "No redefn allowed!"); } + setValueName($3, $2); InsertValue($3); $1->getInstList().push_back($3); @@ -1654,11 +1679,11 @@ $$ = $1; } | LABELSTR InstructionList OptAssign BBTerminatorInst { - if (setValueName($4, $3)) { assert(0 && "No redefn allowed!"); } + setValueName($4, $3); InsertValue($4); $2->getInstList().push_back($4); - if (setValueName($2, $1)) { assert(0 && "No label redef allowed!"); } + setValueName($2, $1); InsertValue($2); $$ = $2; @@ -1669,7 +1694,7 @@ $$ = $1; } | /* empty */ { - $$ = CurBB = new BasicBlock(); + $$ = CurBB = new BasicBlock("", CurFun.CurrentFunction); }; BBTerminatorInst : RET ResolvedVal { // Return with a result... @@ -1782,7 +1807,7 @@ Inst : OptAssign InstVal { // Is this definition named?? if so, assign the name... - if (setValueName($2, $1)) { assert(0 && "No redefin allowed!"); } + setValueName($2, $1); InsertValue($2); $$ = $2; }; From lattner at cs.uiuc.edu Tue Jul 13 03:10:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:10:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407130810.DAA28608@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.174 -> 1.175 --- Log message: Now that basic blocks are eagerly inserted into the Function, we can use the funciton symbol table to check for conflicts instead of having to keep a shadow named LocalSymtab. Totally eliminate LocalSymtab. Verified that this did not cause a regression on the testcase for PR107: http://llvm.cs.uiuc.edu/PR107 . --- Diffs of the changes: (+11 -59) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.174 llvm/lib/AsmParser/llvmAsmParser.y:1.175 --- llvm/lib/AsmParser/llvmAsmParser.y:1.174 Tue Jul 13 02:59:27 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 03:10:10 2004 @@ -142,7 +142,6 @@ std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; - SymbolTable LocalSymtab; bool isDeclare; // Is this function a forward declararation? inline PerFunctionInfo() { @@ -179,7 +178,6 @@ Values.clear(); // Clear out function local definitions Types.clear(); // Clear out function local types - LocalSymtab.clear(); // Clear out function local symbol table CurrentFunction = 0; isDeclare = false; } @@ -486,23 +484,6 @@ // Set the name V->setName(Name, &ST); - - // If we're in function scope - if (inFunctionScope()) { - // Look up the symbol in the Function's local symboltable - Value *Existing = CurFun.LocalSymtab.lookup(V->getType(),Name); - - // If it already exists, bail out. We have to recheck this, because there - // may be entries inserted into the current basic block (which has not yet - // been inserted into the function) which collide. - if (Existing) { - ThrowException("Redefinition of value named '" + Name + "' in the '" + - V->getType()->getDescription() + "' type plane!"); - } else { - // otherwise, since it doesn't exist, insert it. - CurFun.LocalSymtab.insert(V); - } - } } // setValueName - Set the specified value to the name given. The name may be @@ -591,7 +572,7 @@ // This function returns true if the type has already been defined, but is // allowed to be redefined in the specified context. If the name is a new name // for the type plane, it is inserted and false is returned. -static bool setTypeName(Type *T, char *NameStr) { +static bool setTypeName(const Type *T, char *NameStr) { if (NameStr == 0) return false; std::string Name(NameStr); // Copy string @@ -599,20 +580,19 @@ // We don't allow assigning names to void type if (T == Type::VoidTy) - ThrowException("Can't assign name '" + Name + "' to the null type!"); + ThrowException("Can't assign name '" + Name + "' to the void type!"); SymbolTable &ST = inFunctionScope() ? CurFun.CurrentFunction->getSymbolTable() : CurModule.CurrentModule->getSymbolTable(); - Type *Existing = ST.lookupType(Name); - - if (Existing) { // Inserting a name that is already defined??? + // Inserting a name that is already defined??? + if (Type *Existing = ST.lookupType(Name)) { // There is only one case where this is allowed: when we are refining an // opaque type. In this case, Existing will be an opaque type. if (const OpaqueType *OpTy = dyn_cast(Existing)) { // We ARE replacing an opaque type! - ((OpaqueType*)OpTy)->refineAbstractTypeTo(T); + const_cast(OpTy)->refineAbstractTypeTo(T); return true; } @@ -630,23 +610,6 @@ // Okay, its a newly named type. Set its name. if (!Name.empty()) ST.insert(Name, T); - // If we're in function scope - if (inFunctionScope()) { - // Look up the symbol in the function's local symboltable - Existing = CurFun.LocalSymtab.lookupType(Name); - - // If it already exists - if (Existing) { - // Bail - ThrowException("Redefinition of type named '" + Name + "' in the '" + - T->getDescription() + "' type plane in function scope!"); - - // otherwise, since it doesn't exist - } else { - // Insert it. - CurFun.LocalSymtab.insert(Name,T); - } - } return false; } @@ -752,14 +715,7 @@ // Allocate a new module to read CurModule.CurrentModule = new Module(Filename); - try { - yyparse(); // Parse the file. - } catch (...) { - // Clear the symbol table so it doesn't complain when it - // gets destructed - CurFun.LocalSymtab.clear(); - throw; - } + yyparse(); // Parse the file, potentially throwing exception Module *Result = ParserResult; @@ -772,7 +728,6 @@ ObsoleteVarArgs = true; } - if (ObsoleteVarArgs) { // If the user is making use of obsolete varargs intrinsics, adjust them for // the user. @@ -1408,15 +1363,12 @@ // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - ResolveTypeTo($2, $4->get()); + ResolveTypeTo($2, *$4); - // TODO: FIXME when Type are not const - if (!setTypeName(const_cast($4->get()), $2)) { - // If this is not a redefinition of a type... - if (!$2) { - InsertType($4->get(), - inFunctionScope() ? CurFun.Types : CurModule.Types); - } + if (!setTypeName(*$4, $2) && !$2) { + // If this is a named type that is not a redefinition, add it to the slot + // table. + InsertType(*$4, inFunctionScope() ? CurFun.Types : CurModule.Types); } delete $4; From lattner at cs.uiuc.edu Tue Jul 13 03:12:50 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:12:50 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407130812.DAA28799@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.175 -> 1.176 --- Log message: Inline the now trivial setValueNameInternal function into both callers --- Diffs of the changes: (+10 -13) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.175 llvm/lib/AsmParser/llvmAsmParser.y:1.176 --- llvm/lib/AsmParser/llvmAsmParser.y:1.175 Tue Jul 13 03:10:10 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 03:12:39 2004 @@ -476,16 +476,6 @@ } } - -static void setValueNameInternal(Value *V, const std::string &Name, - SymbolTable &ST) { - if (V->getType() == Type::VoidTy) - ThrowException("Can't assign name '" + Name + "' to value with void type!"); - - // Set the name - V->setName(Name, &ST); -} - // setValueName - Set the specified value to the name given. The name may be // null potentially, in which case this is a noop. The string passed in is // assumed to be a malloc'd string buffer, and is free'd by this function. @@ -494,6 +484,9 @@ if (NameStr) { std::string Name(NameStr); // Copy string free(NameStr); // Free old string + + if (V->getType() == Type::VoidTy) + ThrowException("Can't assign name '" + Name+"' to value with void type!"); assert(inFunctionScope() && "Must be in function scope!"); SymbolTable &ST = CurFun.CurrentFunction->getSymbolTable(); @@ -501,7 +494,8 @@ ThrowException("Redefinition of value named '" + Name + "' in the '" + V->getType()->getDescription() + "' type plane!"); - setValueNameInternal(V, Name, ST); + // Set the name. + V->setName(Name, &ST); } } @@ -515,6 +509,8 @@ // for the typeplane, false is returned. // static bool setValueNameMergingDuplicates(Value *V, char *NameStr) { + assert(V->getType() != Type::VoidTy && "Global or constant of type void?"); + if (NameStr == 0) return false; std::string Name(NameStr); // Copy string @@ -558,8 +554,9 @@ ThrowException("Redefinition of value named '" + Name + "' in the '" + V->getType()->getDescription() + "' type plane!"); } - - setValueNameInternal(V, Name, ST); + + // Set the name. + V->setName(Name, &ST); return false; } From lattner at cs.uiuc.edu Tue Jul 13 03:28:36 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:28:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/ParserInternals.h llvmAsmParser.y Message-ID: <200407130828.DAA29345@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: ParserInternals.h updated: 1.35 -> 1.36 llvmAsmParser.y updated: 1.176 -> 1.177 --- Log message: Eliminate some mega-cruft here. There is no reason to DERIVE FROM IR CLASSES just to keep track of some per-object state! Gaah! Whoever wrote this stuff... oh wait, that would be me. Never mind. --- Diffs of the changes: (+26 -67) Index: llvm/lib/AsmParser/ParserInternals.h diff -u llvm/lib/AsmParser/ParserInternals.h:1.35 llvm/lib/AsmParser/ParserInternals.h:1.36 --- llvm/lib/AsmParser/ParserInternals.h:1.35 Thu Jun 17 13:18:08 2004 +++ llvm/lib/AsmParser/ParserInternals.h Tue Jul 13 03:28:21 2004 @@ -158,60 +158,6 @@ } }; - - -template -class PlaceholderValue : public SuperType { - ValID D; - int LineNum; -public: - PlaceholderValue(const Type *Ty, const ValID &d) : SuperType(Ty), D(d) { - LineNum = llvmAsmlineno; - } - ValID &getDef() { return D; } - int getLineNum() const { return LineNum; } -}; - -struct InstPlaceHolderHelper : public Instruction { - InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {} - - virtual Instruction *clone() const { abort(); return 0; } - virtual const char *getOpcodeName() const { return "placeholder"; } -}; - -struct BBPlaceHolderHelper : public BasicBlock { - BBPlaceHolderHelper(const Type *Ty) : BasicBlock() { - assert(Ty == Type::LabelTy); - } -}; - -typedef PlaceholderValue ValuePlaceHolder; -typedef PlaceholderValue BBPlaceHolder; - -static inline ValID &getValIDFromPlaceHolder(const Value *Val) { - const Type *Ty = Val->getType(); - if (isa(Ty) && - isa(cast(Ty)->getElementType())) - Ty = cast(Ty)->getElementType(); - - switch (Ty->getTypeID()) { - case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getDef(); - default: return ((ValuePlaceHolder*)Val)->getDef(); - } -} - -static inline int getLineNumFromPlaceHolder(const Value *Val) { - const Type *Ty = Val->getType(); - if (isa(Ty) && - isa(cast(Ty)->getElementType())) - Ty = cast(Ty)->getElementType(); - - switch (Ty->getTypeID()) { - case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getLineNum(); - default: return ((ValuePlaceHolder*)Val)->getLineNum(); - } -} - } // End llvm namespace #endif Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.176 llvm/lib/AsmParser/llvmAsmParser.y:1.177 --- llvm/lib/AsmParser/llvmAsmParser.y:1.176 Tue Jul 13 03:12:39 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 03:28:21 2004 @@ -69,6 +69,11 @@ std::vector Types; std::map LateResolveTypes; + /// PlaceHolderInfo - When temporary placeholder objects are created, remember + /// how they were referenced and one which line of the input they came from so + /// that we can resolve them alter and print error messages as appropriate. + std::map > PlaceHolderInfo; + // GlobalRefs - This maintains a mapping between 's and forward // references to global values. Global values may be referenced before they // are defined, and if so, the temporary object that they represent is held @@ -356,7 +361,6 @@ return 0; } - // getVal - This function is identical to getValNonImprovising, except that if a // value is not already defined, it "improvises" by creating a placeholder var // that looks and acts just like the requested variable. When the value is @@ -373,18 +377,21 @@ // or an id number that hasn't been read yet. We may be referencing something // forward, so just create an entry to be resolved later and get to it... // - Value *d = 0; - switch (Ty->getTypeID()) { - case Type::LabelTyID: d = new BBPlaceHolder(Ty, D); break; - default: d = new ValuePlaceHolder(Ty, D); break; - } + if (Ty == Type::LabelTy) + V = new BasicBlock(); + else + V = new Argument(Ty); + + // Remember where this forward reference came from. FIXME, shouldn't we try + // to recycle these things?? + CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(D, + llvmAsmlineno))); - assert(d != 0 && "How did we not make something?"); if (inFunctionScope()) - InsertValue(d, CurFun.LateResolveValues); + InsertValue(V, CurFun.LateResolveValues); else - InsertValue(d, CurModule.LateResolveValues); - return d; + InsertValue(V, CurModule.LateResolveValues); + return V; } @@ -413,12 +420,18 @@ while (!List.empty()) { Value *V = List.back(); List.pop_back(); - ValID &DID = getValIDFromPlaceHolder(V); + + std::map >::iterator PHI = + CurModule.PlaceHolderInfo.find(V); + assert(PHI != CurModule.PlaceHolderInfo.end() && "Placeholder error!"); + + ValID &DID = PHI->second.first; Value *TheRealValue = getValNonImprovising(LRI->first, DID); if (TheRealValue) { V->replaceAllUsesWith(TheRealValue); delete V; + CurModule.PlaceHolderInfo.erase(PHI); } else if (FutureLateResolvers) { // Functions have their unresolved items forwarded to the module late // resolver table @@ -427,12 +440,12 @@ if (DID.Type == ValID::NameVal) ThrowException("Reference to an invalid definition: '" +DID.getName()+ "' of type '" + V->getType()->getDescription() + "'", - getLineNumFromPlaceHolder(V)); + PHI->second.second); else ThrowException("Reference to an invalid definition: #" + itostr(DID.Num) + " of type '" + V->getType()->getDescription() + "'", - getLineNumFromPlaceHolder(V)); + PHI->second.second); } } } From lattner at cs.uiuc.edu Tue Jul 13 03:39:25 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:39:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407130839.DAA30374@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.177 -> 1.178 --- Log message: Fix typeo and refactor bb productions to make it possible for us to reuse any forward reference blocks if they have been created (instead of creating a new block, replaceAllUsesOfWith, then nuking the placeholder). This is not yet implemented. --- Diffs of the changes: (+12 -11) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.177 llvm/lib/AsmParser/llvmAsmParser.y:1.178 --- llvm/lib/AsmParser/llvmAsmParser.y:1.177 Tue Jul 13 03:28:21 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 03:39:15 2004 @@ -71,7 +71,7 @@ /// PlaceHolderInfo - When temporary placeholder objects are created, remember /// how they were referenced and one which line of the input they came from so - /// that we can resolve them alter and print error messages as appropriate. + /// that we can resolve them later and print error messages as appropriate. std::map > PlaceHolderInfo; // GlobalRefs - This maintains a mapping between 's and forward @@ -1639,16 +1639,6 @@ $1->getInstList().push_back($3); InsertValue($1); $$ = $1; - } - | LABELSTR InstructionList OptAssign BBTerminatorInst { - setValueName($4, $3); - InsertValue($4); - - $2->getInstList().push_back($4); - setValueName($2, $1); - - InsertValue($2); - $$ = $2; }; InstructionList : InstructionList Inst { @@ -1656,7 +1646,18 @@ $$ = $1; } | /* empty */ { + // FIXME: Should check to see if there is a forward ref'd basic block that + // we can use and reuse it as appropriate. It doesn't make sense just to + // make forward ref'd blocks then discard them. + $$ = CurBB = new BasicBlock("", CurFun.CurrentFunction); + } + | LABELSTR { + // FIXME: Should check to see if there is a forward ref'd basic block that + // we can use and reuse it as appropriate. It doesn't make sense just to + // make forward ref'd blocks then discard them. $$ = CurBB = new BasicBlock("", CurFun.CurrentFunction); + setValueName($$, $1); + InsertValue($$); }; BBTerminatorInst : RET ResolvedVal { // Return with a result... From lattner at cs.uiuc.edu Tue Jul 13 03:42:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:42:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Parser.cpp Message-ID: <200407130842.DAA30749@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Parser.cpp updated: 1.13 -> 1.14 --- Log message: Fine-grainify namespacification, prune #include --- Diffs of the changes: (+2 -6) Index: llvm/lib/AsmParser/Parser.cpp diff -u llvm/lib/AsmParser/Parser.cpp:1.13 llvm/lib/AsmParser/Parser.cpp:1.14 --- llvm/lib/AsmParser/Parser.cpp:1.13 Tue Nov 11 16:41:32 2003 +++ llvm/lib/AsmParser/Parser.cpp Tue Jul 13 03:42:12 2004 @@ -13,14 +13,12 @@ #include "ParserInternals.h" #include "llvm/Module.h" -#include "llvm/Analysis/Verifier.h" - -namespace llvm { +using namespace llvm; // The useful interface defined by this file... Parse an ASCII file, and return // the internal representation in a nice slice'n'dice'able representation. // -Module *ParseAssemblyFile(const std::string &Filename) { +Module *llvm::ParseAssemblyFile(const std::string &Filename) { FILE *F = stdin; if (Filename != "-") { @@ -84,5 +82,3 @@ return Result + ": " + Message; } - -} // End llvm namespace From lattner at cs.uiuc.edu Tue Jul 13 03:45:51 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:45:51 -0500 Subject: [llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp Message-ID: <200407130845.DAA31447@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-as: llvm-as.cpp updated: 1.30 -> 1.31 --- Log message: There is no reason to abort and print a stack trace if there is a verification error. Just print the message like a good little tool. --- Diffs of the changes: (+1 -1) Index: llvm/tools/llvm-as/llvm-as.cpp diff -u llvm/tools/llvm-as/llvm-as.cpp:1.30 llvm/tools/llvm-as/llvm-as.cpp:1.31 --- llvm/tools/llvm-as/llvm-as.cpp:1.30 Sun Jul 11 18:20:54 2004 +++ llvm/tools/llvm-as/llvm-as.cpp Tue Jul 13 03:45:41 2004 @@ -57,7 +57,7 @@ return 1; } - if (!DisableVerify && verifyModule(*M.get())) { + if (!DisableVerify && verifyModule(*M.get(), PrintMessageAction)) { std::cerr << argv[0] << ": assembly parsed, but does not verify as correct!\n"; return 1; From lattner at cs.uiuc.edu Tue Jul 13 03:48:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 03:48:14 -0500 Subject: [llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp Message-ID: <200407130848.DAA31664@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-as: llvm-as.cpp updated: 1.31 -> 1.32 --- Log message: Actually, use an exception to stop verification. This gives us much better error messages because verification stops at the first error. --- Diffs of the changes: (+5 -1) Index: llvm/tools/llvm-as/llvm-as.cpp diff -u llvm/tools/llvm-as/llvm-as.cpp:1.31 llvm/tools/llvm-as/llvm-as.cpp:1.32 --- llvm/tools/llvm-as/llvm-as.cpp:1.31 Tue Jul 13 03:45:41 2004 +++ llvm/tools/llvm-as/llvm-as.cpp Tue Jul 13 03:48:04 2004 @@ -57,9 +57,13 @@ return 1; } - if (!DisableVerify && verifyModule(*M.get(), PrintMessageAction)) { + try { + if (!DisableVerify) + verifyModule(*M.get(), ThrowExceptionAction); + } catch (const std::string &Err) { std::cerr << argv[0] << ": assembly parsed, but does not verify as correct!\n"; + std::cerr << Err; return 1; } From alkis at cs.uiuc.edu Tue Jul 13 03:57:19 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 03:57:19 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407130857.DAA17182@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.14 -> 1.15 --- Log message: If the catchType index of the exception is 0, then this is a catch all block. --- Diffs of the changes: (+13 -6) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.14 llvm-java/lib/ClassFile/ClassFile.cpp:1.15 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.14 Thu Jul 8 19:00:26 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Tue Jul 13 03:57:09 2004 @@ -660,20 +660,27 @@ CodeAttribute::Exception::Exception(const ConstantPool& cp, std::istream& is) + : catchType_(NULL) { startPc_ = readU2(is); endPc_ = readU2(is); handlerPc_ = readU2(is); - catchType_ = dynamic_cast(cp[readU2(is)]); - if (!catchType_) - throw ClassFileSemanticError( - "Representation of catch type is not of type ConstantClass"); + uint16_t idx = readU2(is); + if (idx) { + catchType_ = dynamic_cast(cp[idx]); + if (!catchType_) + throw ClassFileSemanticError + ("Representation of catch type is not of type ConstantClass"); + } } std::ostream& CodeAttribute::Exception::dump(std::ostream& os) const { - return os << *getCatchType() << '\n' - << "Start PC: " << startPc_ << '\n' + if (getCatchType()) + os << *getCatchType() << '\n'; + else + os << "catch-all\n"; + return os << "Start PC: " << startPc_ << '\n' << "End PC: " << endPc_ << '\n' << "Handler PC: " << handlerPc_; } From alkis at cs.uiuc.edu Tue Jul 13 05:47:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 05:47:01 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407131047.FAA02772@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.53 -> 1.54 --- Log message: Simplify inceamental method compilation. --- Diffs of the changes: (+23 -25) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.53 llvm-java/lib/Compiler/Compiler.cpp:1.54 --- llvm-java/lib/Compiler/Compiler.cpp:1.53 Fri Jul 9 05:48:38 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jul 13 05:46:51 2004 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -215,31 +216,29 @@ } void compileMethodOnly(Module& module, - const ClassFile& cf, - const Method& method) { - - DEBUG(std::cerr << "Compiling method: " - << method.getName()->str() << '\n'); + const std::string& classMethodDesc) { + DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); module_ = &module; - cf_ = &cf; + const Method* method; + tie(cf_, method) = findClassAndMethod(classMethodDesc); std::string name = cf_->getThisClass()->getName()->str(); name += '/'; - name += method.getName()->str(); - name += method.getDescriptor()->str(); + name += method->getName()->str(); + name += method->getDescriptor()->str(); Function* function = new Function( - cast(getType(method.getDescriptor())), - (method.isPrivate() ? + cast(getType(method->getDescriptor())), + (method->isPrivate() ? Function::InternalLinkage : Function::ExternalLinkage), name, &module); const Java::CodeAttribute* codeAttr = - Java::getCodeAttribute(method.getAttributes()); + Java::getCodeAttribute(method->getAttributes()); while (!opStack_.empty()) opStack_.pop(); @@ -264,19 +263,8 @@ } } - public: - void compileMethod(Module& module, - const ClassFile& cf, - const Method& method) { - compileMethodOnly(module, cf, method); - - for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { - Function* f = toCompileFunctions_[i]; - compileMethod(module, f->getName()); - } - } - - void compileMethod(Module& module, const std::string& classMethodDesc) { + std::pair + findClassAndMethod(const std::string& classMethodDesc) { unsigned slash = classMethodDesc.find('/'); std::string className = classMethodDesc.substr(0, slash); std::string methodNameAndDescr = classMethodDesc.substr(slash+1); @@ -288,7 +276,17 @@ "Method " + methodNameAndDescr + " not found in class " + className); - compileMethod(module, *classfile, *method); + + return std::make_pair(classfile, method); + } + + public: + void compileMethod(Module& module, const std::string& classMethodDesc) { + compileMethodOnly(module, classMethodDesc); + for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { + Function* f = toCompileFunctions_[i]; + compileMethodOnly(module, f->getName()); + } } void do_aconst_null(unsigned bcI) { From alkis at cs.uiuc.edu Tue Jul 13 07:31:28 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 07:31:28 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407131231.HAA13627@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.54 -> 1.55 --- Log message: Use fields to build the type struct of objects. Currently the vtable is missing :-| --- Diffs of the changes: (+73 -17) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.54 llvm-java/lib/Compiler/Compiler.cpp:1.55 --- llvm-java/lib/Compiler/Compiler.cpp:1.54 Tue Jul 13 05:46:51 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jul 13 07:31:15 2004 @@ -126,6 +126,8 @@ BasicBlock* prologue_; typedef SetVector FunctionSet; FunctionSet toCompileFunctions_; + typedef std::map Class2TypeMap; + Class2TypeMap c2tMap_; private: BasicBlock* getBBAt(unsigned bcI) { return bc2bbMap_[bcI]; } @@ -133,9 +135,8 @@ private: const Type* getType(JType type) { switch (type) { - // FIXME: this should really be a pointer to an Object - // type when the object model is finalized - case REFERENCE: return PointerType::get(Type::SByteTy); + case REFERENCE: + return PointerType::get(getTypeForClass("java/lang/Object")); case BOOLEAN: return Type::BoolTy; case CHAR: return Type::UShortTy; case FLOAT: return Type::FloatTy; @@ -184,9 +185,7 @@ unsigned e = descr.find(';', i); std::string className = descr.substr(i, e - i); i = e + 1; - // FIXME: this should really be a pointer to an object - // of type className - return PointerType::get(Type::SByteTy); + return PointerType::get(getTypeForClass(className)); } case '[': // FIXME: this should really be a new class @@ -205,6 +204,40 @@ } } + const Type* getTypeForClass(const std::string& className) { + Class2TypeMap::iterator it = c2tMap_.lower_bound(className); + if (it == c2tMap_.end() || it->first != className) { + const ClassFile* cf = ClassFile::getClassFile(className); + OpaqueType* newType = OpaqueType::get(); + it = c2tMap_.insert(it, std::make_pair(className, newType)); + std::vector elements; + if (const ConstantClass* super = cf->getSuperClass()) + elements.push_back + (getTypeForClass(super->getName()->str())); + const Fields& fields = cf->getFields(); + for (unsigned i = 0, e = fields.size(); i != e; ++i) { + const Field* field = fields[i]; + if (field->isStatic()) + new GlobalVariable(getType(field->getDescriptor()), + field->isFinal(), + (field->isPrivate() ? + GlobalVariable::InternalLinkage : + GlobalVariable::ExternalLinkage), + NULL, + className + '/' + field->getName()->str(), + module_); + else + elements.push_back(getType(field->getDescriptor())); + } + PATypeHolder holder = newType; + newType->refineAbstractTypeTo(StructType::get(elements)); + it->second = holder.get(); + DEBUG(std::cerr << "Adding " << className << " = " + << *it->second << " to type map\n"); + } + return it->second; + } + Value* getOrCreateLocal(unsigned index, const Type* type) { if (!locals_[index] || cast(locals_[index]->getType())->getElementType() != type) { @@ -228,14 +261,11 @@ name += method->getName()->str(); name += method->getDescriptor()->str(); - Function* function = - new Function( - cast(getType(method->getDescriptor())), - (method->isPrivate() ? - Function::InternalLinkage : - Function::ExternalLinkage), - name, - &module); + Function* function = module.getOrInsertFunction + (name, cast(getType(method->getDescriptor()))); + function->setLinkage(method->isPrivate() ? + Function::InternalLinkage : + Function::ExternalLinkage); const Java::CodeAttribute* codeAttr = Java::getCodeAttribute(method->getAttributes()); @@ -281,6 +311,11 @@ } public: + CompilerImpl() { + c2tMap_.insert(std::make_pair("java/lang/Object", + OpaqueType::get())); + } + void compileMethod(Module& module, const std::string& classMethodDesc) { compileMethodOnly(module, classMethodDesc); for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { @@ -290,8 +325,7 @@ } void do_aconst_null(unsigned bcI) { - opStack_.push(llvm::Constant::getNullValue( - PointerType::get(getType(REFERENCE)))); + opStack_.push(llvm::Constant::getNullValue(getType(REFERENCE))); } void do_iconst(unsigned bcI, int value) { @@ -678,7 +712,29 @@ } void do_invokestatic(unsigned bcI, unsigned index) { - assert(0 && "not implemented"); + const ConstantMethodRef* methodRef = + (ConstantMethodRef*)(cf_->getConstantPool()[index]); + const ConstantNameAndType* nameAndType = + methodRef->getNameAndType(); + + std::string funcName = + methodRef->getClass()->getName()->str() + '/' + + nameAndType->getName()->str() + + nameAndType->getDescriptor()->str(); + + const FunctionType* funcType = + cast(getType(nameAndType->getDescriptor())); + std::vector params(funcType->getNumParams(), NULL); + for (unsigned i = funcType->getNumParams(); i > 0; ) { + Value* p = opStack_.top(); opStack_.pop(); + params[--i] = p; + } + + Function* function = + module_->getOrInsertFunction(funcName, funcType); + toCompileFunctions_.insert(function); + Value* r = new CallInst(function, params, TMP, getBBAt(bcI)); + opStack_.push(r); } void do_invokeinterface(unsigned bcI, unsigned index) { From alkis at cs.uiuc.edu Tue Jul 13 07:43:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 07:43:02 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407131243.HAA15268@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.55 -> 1.56 --- Log message: Add typenames to generated types. --- Diffs of the changes: (+3 -4) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.55 llvm-java/lib/Compiler/Compiler.cpp:1.56 --- llvm-java/lib/Compiler/Compiler.cpp:1.55 Tue Jul 13 07:31:15 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jul 13 07:42:52 2004 @@ -234,6 +234,7 @@ it->second = holder.get(); DEBUG(std::cerr << "Adding " << className << " = " << *it->second << " to type map\n"); + module_->addTypeName(className, it->second); } return it->second; } @@ -311,12 +312,10 @@ } public: - CompilerImpl() { + void compileMethod(Module& module, const std::string& classMethodDesc) { c2tMap_.insert(std::make_pair("java/lang/Object", OpaqueType::get())); - } - - void compileMethod(Module& module, const std::string& classMethodDesc) { + module.addTypeName("java/lang/Object", c2tMap_["java/lang/Object"]); compileMethodOnly(module, classMethodDesc); for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { Function* f = toCompileFunctions_[i]; From lattner at cs.uiuc.edu Tue Jul 13 15:10:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 15:10:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407132010.PAA00390@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.110 -> 1.111 --- Log message: Catch aggregates passed by value sooner rather than later. --- Diffs of the changes: (+3 -0) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.110 llvm/lib/VMCore/Type.cpp:1.111 --- llvm/lib/VMCore/Type.cpp:1.110 Fri Jul 9 11:47:54 2004 +++ llvm/lib/VMCore/Type.cpp Tue Jul 13 15:09:51 2004 @@ -364,6 +364,9 @@ ContainedTys.push_back(PATypeHandle(Result, this)); for (unsigned i = 0; i != Params.size(); ++i) { + assert((Params[i]->isFirstClassType() || isa(Params[i])) && + "Function arguments must be value types!"); + ContainedTys.push_back(PATypeHandle(Params[i], this)); isAbstract |= Params[i]->isAbstract(); } From lattner at cs.uiuc.edu Tue Jul 13 18:14:50 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 18:14:50 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407132314.SAA18711@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.145 -> 1.146 --- Log message: Make Argument::print more resilient to non-verifiable IR --- Diffs of the changes: (+2 -1) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.145 llvm/lib/VMCore/AsmWriter.cpp:1.146 --- llvm/lib/VMCore/AsmWriter.cpp:1.145 Sun Jul 4 06:50:43 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Tue Jul 13 18:14:34 2004 @@ -1182,7 +1182,8 @@ } void Argument::print(std::ostream &o) const { - WriteAsOperand(o, this, true, true, getParent()->getParent()); + WriteAsOperand(o, this, true, true, + getParent() ? getParent()->getParent() : 0); } // Value::dump - allow easy printing of Values from the debugger. From alkis at cs.uiuc.edu Tue Jul 13 18:21:44 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 18:21:44 -0500 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Makefile Message-ID: <200407132321.SAA18849@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.10 -> 1.11 Makefile updated: 1.1 -> 1.2 --- Log message: Make tool output llvm bytecode instead of writing out assembly. --- Diffs of the changes: (+3 -3) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.10 llvm-java/tools/class2llvm/class2llvm.cpp:1.11 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.10 Thu Jul 8 19:06:30 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Tue Jul 13 18:21:34 2004 @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -40,7 +40,7 @@ compiler.compile(module, InputClass); PassManager passes; - passes.add(new PrintModulePass(&std::cout)); + passes.add(new WriteBytecodePass(&std::cout)); passes.run(module); } catch (std::exception& e) { Index: llvm-java/tools/class2llvm/Makefile diff -u llvm-java/tools/class2llvm/Makefile:1.1 llvm-java/tools/class2llvm/Makefile:1.2 --- llvm-java/tools/class2llvm/Makefile:1.1 Sat May 22 02:08:31 2004 +++ llvm-java/tools/class2llvm/Makefile Tue Jul 13 18:21:34 2004 @@ -11,6 +11,6 @@ TOOLNAME := class2llvm USEDLIBS := classfile compiler -LLVMLIBS := support vmcore +LLVMLIBS := support vmcore bcwriter include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Tue Jul 13 19:29:25 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 19:29:25 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407140029.TAA19463@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.2 -> 1.3 --- Log message: Add variable pointing to the class2llvm executable. --- Diffs of the changes: (+2 -0) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.2 llvm-java/Makefile.rules:1.3 --- llvm-java/Makefile.rules:1.2 Tue May 18 14:24:48 2004 +++ llvm-java/Makefile.rules Tue Jul 13 19:29:15 2004 @@ -13,3 +13,5 @@ $(JAVAC) $? touch .class-stamp endif + +CLASS2LLVM := $(LEVEL)/tools/Debug/class2llvm$(EXEEXT) From alkis at cs.uiuc.edu Tue Jul 13 19:31:50 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue, 13 Jul 2004 19:31:50 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile Message-ID: <200407140031.TAA19549@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile updated: 1.1 -> 1.2 --- Log message: Fix path in first line comment. --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Makefile diff -u llvm-java/test/Makefile:1.1 llvm-java/test/Makefile:1.2 --- llvm-java/test/Makefile:1.1 Sat May 22 02:21:16 2004 +++ llvm-java/test/Makefile Tue Jul 13 19:31:40 2004 @@ -1,4 +1,4 @@ -##===- tests/Makefile --------------------------------------*- Makefile -*-===## +##===- test/Makefile ---------------------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # From lattner at cs.uiuc.edu Tue Jul 13 20:34:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue, 13 Jul 2004 20:34:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407140134.UAA03567@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.178 -> 1.179 --- Log message: Split the basic block handling case out of getVal into getBBVal. --- Diffs of the changes: (+40 -34) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.178 llvm/lib/AsmParser/llvmAsmParser.y:1.179 --- llvm/lib/AsmParser/llvmAsmParser.y:1.178 Tue Jul 13 03:39:15 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Tue Jul 13 20:33:11 2004 @@ -205,11 +205,6 @@ return List.size()-1; } -// TODO: FIXME when Type are not const -static void InsertType(const Type *Ty, std::vector &Types) { - Types.push_back(Ty); -} - static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { switch (D.Type) { case ValID::NumberVal: { // Is it a numbered definition? @@ -367,24 +362,23 @@ // defined later, all uses of the placeholder variable are replaced with the // real thing. // -static Value *getVal(const Type *Ty, const ValID &D) { +static Value *getVal(const Type *Ty, const ValID &ID) { + if (Ty == Type::LabelTy) + ThrowException("Cannot use a basic block here"); - // See if the value has already been defined... - Value *V = getValNonImprovising(Ty, D); + // See if the value has already been defined. + Value *V = getValNonImprovising(Ty, ID); if (V) return V; // If we reached here, we referenced either a symbol that we don't know about // or an id number that hasn't been read yet. We may be referencing something // forward, so just create an entry to be resolved later and get to it... // - if (Ty == Type::LabelTy) - V = new BasicBlock(); - else - V = new Argument(Ty); + V = new Argument(Ty); // Remember where this forward reference came from. FIXME, shouldn't we try // to recycle these things?? - CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(D, + CurModule.PlaceHolderInfo.insert(std::make_pair(V, std::make_pair(ID, llvmAsmlineno))); if (inFunctionScope()) @@ -394,6 +388,23 @@ return V; } +static BasicBlock *getBBVal(const ValID &ID) { + assert(inFunctionScope() && "Can't get basic block at global scope!"); + + // See if the value has already been defined. + Value *V = getValNonImprovising(Type::LabelTy, ID); + if (V) return cast(V); + + BasicBlock *BB = new BasicBlock(); + // Remember where this forward reference came from. FIXME, shouldn't we try + // to recycle these things?? + CurModule.PlaceHolderInfo.insert(std::make_pair(BB, std::make_pair(ID, + llvmAsmlineno))); + + InsertValue(BB, CurFun.LateResolveValues); + return BB; +} + //===----------------------------------------------------------------------===// // Code to handle forward references in instructions @@ -1378,7 +1389,10 @@ if (!setTypeName(*$4, $2) && !$2) { // If this is a named type that is not a redefinition, add it to the slot // table. - InsertType(*$4, inFunctionScope() ? CurFun.Types : CurModule.Types); + if (inFunctionScope()) + CurFun.Types.push_back(*$4); + else + CurModule.Types.push_back(*$4); } delete $4; @@ -1667,16 +1681,13 @@ $$ = new ReturnInst(); } | BR LABEL ValueRef { // Unconditional Branch... - $$ = new BranchInst(cast(getVal(Type::LabelTy, $3))); + $$ = new BranchInst(getBBVal($3)); } // Conditional Branch... | BR BOOL ValueRef ',' LABEL ValueRef ',' LABEL ValueRef { - $$ = new BranchInst(cast(getVal(Type::LabelTy, $6)), - cast(getVal(Type::LabelTy, $9)), - getVal(Type::BoolTy, $3)); + $$ = new BranchInst(getBBVal($6), getBBVal($9), getVal(Type::BoolTy, $3)); } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' JumpTable ']' { - SwitchInst *S = new SwitchInst(getVal($2, $3), - cast(getVal(Type::LabelTy, $6))); + SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6)); $$ = S; std::vector >::iterator I = $8->begin(), @@ -1686,12 +1697,11 @@ delete $8; } | SWITCH IntType ValueRef ',' LABEL ValueRef '[' ']' { - SwitchInst *S = new SwitchInst(getVal($2, $3), - cast(getVal(Type::LabelTy, $6))); + SwitchInst *S = new SwitchInst(getVal($2, $3), getBBVal($6)); $$ = S; } - | INVOKE TypesV ValueRef '(' ValueRefListE ')' TO ResolvedVal - UNWIND ResolvedVal { + | INVOKE TypesV ValueRef '(' ValueRefListE ')' TO LABEL ValueRef + UNWIND LABEL ValueRef { const PointerType *PFTy; const FunctionType *Ty; @@ -1714,11 +1724,8 @@ Value *V = getVal(PFTy, $3); // Get the function we're calling... - BasicBlock *Normal = dyn_cast($8); - BasicBlock *Except = dyn_cast($10); - - if (Normal == 0 || Except == 0) - ThrowException("Invoke instruction without label destinations!"); + BasicBlock *Normal = getBBVal($9); + BasicBlock *Except = getBBVal($12); // Create the call node... if (!$5) { // Has no arguments? @@ -1756,7 +1763,7 @@ if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(std::make_pair(V, cast(getVal($5, $6)))); + $$->push_back(std::make_pair(V, getBBVal($6))); } | IntType ConstValueRef ',' LABEL ValueRef { $$ = new std::vector >(); @@ -1765,7 +1772,7 @@ if (V == 0) ThrowException("May only switch on a constant pool value!"); - $$->push_back(std::make_pair(V, cast(getVal($4, $5)))); + $$->push_back(std::make_pair(V, getBBVal($5))); }; Inst : OptAssign InstVal { @@ -1777,14 +1784,13 @@ PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes $$ = new std::list >(); - $$->push_back(std::make_pair(getVal(*$1, $3), - cast(getVal(Type::LabelTy, $5)))); + $$->push_back(std::make_pair(getVal(*$1, $3), getBBVal($5))); delete $1; } | PHIList ',' '[' ValueRef ',' ValueRef ']' { $$ = $1; $1->push_back(std::make_pair(getVal($1->front().first->getType(), $4), - cast(getVal(Type::LabelTy, $6)))); + getBBVal($6))); }; From gaeke at cs.uiuc.edu Wed Jul 14 00:41:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 14 Jul 2004 00:41:01 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Message-ID: <200407140541.AAA09878@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrSelection.cpp updated: 1.81 -> 1.82 --- Log message: Add Machine-CFG edges to SparcV9 MachineBasicBlocks. --- Diffs of the changes: (+20 -6) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.81 llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.82 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.81 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Wed Jul 14 00:40:50 2004 @@ -24,6 +24,7 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Support/CFG.h" #include "../SparcV9RegInfo.h" #include "Support/CommandLine.h" #include "Support/LeakDetector.h" @@ -185,17 +186,30 @@ SelectInstructionsForTree(basicNode, /*goalnt*/1); } - // Create the MachineBasicBlock records and add all of the MachineInstrs - // defined in the MachineCodeForInstruction objects to also live in the - // MachineBasicBlock objects. + // Create the MachineBasicBlocks and add all of the MachineInstrs + // defined in the MachineCodeForInstruction objects to the MachineBasicBlocks. MachineFunction &MF = MachineFunction::get(&F); + std::map MBBMap; for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; ++BI) { - MachineBasicBlock *MCBB = new MachineBasicBlock(BI); - MF.getBasicBlockList().push_back(MCBB); + MachineBasicBlock *MBB = new MachineBasicBlock(BI); + MF.getBasicBlockList().push_back(MBB); + MBBMap[BI] = MBB; for (BasicBlock::iterator II = BI->begin(); II != BI->end(); ++II) { MachineCodeForInstruction &mvec = MachineCodeForInstruction::get(II); - MCBB->insert(MCBB->end(), mvec.begin(), mvec.end()); + MBB->insert(MBB->end(), mvec.begin(), mvec.end()); + } + } + + // Initialize Machine-CFG for the function. + for (MachineFunction::iterator i = MF.begin (), e = MF.end (); i != e; ++i) { + MachineBasicBlock &MBB = *i; + const BasicBlock *BB = MBB.getBasicBlock (); + // for each successor S of BB, add MBBMap[S] as a successor of MBB. + for (succ_const_iterator si = succ_begin(BB), se = succ_end(BB); si != se; ++si) { + MachineBasicBlock *succMBB = MBBMap[*si]; + assert (succMBB && "Can't find MachineBasicBlock for this successor"); + MBB.addSuccessor (succMBB); } } From gaeke at cs.uiuc.edu Wed Jul 14 01:12:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 14 Jul 2004 01:12:04 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/ValueAllocState.cpp Message-ID: <200407140612.BAA11148@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: ValueAllocState.cpp (r1.6) removed --- Log message: ValueAllocState is just another piece of mapping info, although it does depend on the existence of a TraceFunction. So move it to the Mapping library. --- Diffs of the changes: (+0 -0) From gaeke at cs.uiuc.edu Wed Jul 14 01:12:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 14 Jul 2004 01:12:05 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/Mapping/ValueAllocState.cpp Message-ID: <200407140612.BAA11156@seraph.cs.uiuc.edu> Changes in directory reopt/lib/Mapping: ValueAllocState.cpp added (r1.1) --- Log message: ValueAllocState is just another piece of mapping info, although it does depend on the existence of a TraceFunction. So move it to the Mapping library. --- Diffs of the changes: (+203 -0) Index: reopt/lib/Mapping/ValueAllocState.cpp diff -c /dev/null reopt/lib/Mapping/ValueAllocState.cpp:1.1 *** /dev/null Wed Jul 14 01:12:05 2004 --- reopt/lib/Mapping/ValueAllocState.cpp Wed Jul 14 01:11:55 2004 *************** *** 0 **** --- 1,203 ---- + //===- ValueAllocState.cpp - Access saved state of PhyRegAlloc ----*- C++ -*-=// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // Routines for accessing the global mapping between registers and LLVM Values + // created by the traditional SparcV9 graph-coloring register allocator. The + // main entry point for this code is the GetValueAllocState() global function. + // + //===----------------------------------------------------------------------===// + + #include "reopt/TraceToFunction.h" + #include "reopt/MappingInfo.h" + #include "llvm/Module.h" + #include "llvm/Argument.h" + #include "llvm/iPHINode.h" + #include "llvm/Support/InstIterator.h" + #include "Support/Debug.h" + #include "../../../../lib/Target/SparcV9/RegAlloc/AllocInfo.h" + #include "../../../../lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h" + #include + + namespace llvm { + + /// Data structures describing the register allocator state + /// that gets saved by -save-ra-state. + /// + extern "C" { + struct OperandAllocState { + int Instruction; + int Operand; + unsigned AllocState; + int Placement; + }; + struct FunctionAllocState { + unsigned numTuples; + struct OperandAllocState tuples[0]; // variable length + }; + struct ModuleAllocState { + unsigned numFunctions; + struct FunctionAllocState *functions[0]; // variable length + }; + /// This global is filled in by PhyRegAlloc's -save-ra-state option + /// in LLC output: + /// + extern struct ModuleAllocState _llvm_regAllocState; + }; + + /// This global is filled in by PhyRegAlloc's -save-ra-state option in JIT + /// output: + /// + extern PhyRegAlloc::SavedStateMapTy ExportedFnAllocState; + + /// Returns the index of the given Instruction in the given Function. + /// + static int getSavedStateIndexOfInstruction (const Function *F, + const Instruction *I) { + unsigned Key = 0; + for (const_inst_iterator II=inst_begin (F), IE=inst_end (F); II!=IE; ++II) { + if (&*II == I) + return Key; + ++Key; + } + DEBUG (std::cerr << "getSavedStateIndexOfInstruction: Warning: Cannot find " + << "index of value " << I->getName() << " in its parent function " + << F->getName () << "()\n"); + return -1; + } + + /// Returns the index of the given Argument in the given Function's + /// argument list. + /// + static int getNumberOfFunctionArg (const Function *F, const Argument *Arg) + { + int ArgNum = 0; + for (Function::const_aiterator i = F->abegin (), e = F->aend (); i != e; ++i){ + if (Arg == &*i) return ArgNum; + ++ArgNum; + } + std::cerr << "ERROR: getNumberOfFunctionArg couldn't find arg\n"; + abort (); + } + + static std::set TraceBoundaryBlocks; + static TraceFunction *lastTraceFunction; + + static void findTraceBoundaryBlocks (TraceFunction *TF) { + TraceBoundaryBlocks.clear (); + TraceBoundaryBlocks.insert (TF->T.getEntryBasicBlock ()); + for (ReturnBlockMap::iterator i = TF->ReturnBlockForTraceExit.begin (), + e = TF->ReturnBlockForTraceExit.end (); i != e; ++i) { + TraceBoundaryBlocks.insert (i->second); + } + } + + /// getValueAllocStateKeys - Fill in InstructionKey and OperandKey with the + /// indices used to look up saved register allocation state for V in F. + /// + static void getValueAllocStateKeys (Function *F, Value *V, int &InstructionKey, + int &OperandKey, bool preferLiveIn) { + InstructionKey = -1; OperandKey = -1; + if (Argument *Arg = dyn_cast (V)) { + OperandKey = getNumberOfFunctionArg (F, Arg); + } else if (Instruction *Inst = dyn_cast (V)) { + InstructionKey = getSavedStateIndexOfInstruction (F, Inst); + if (isa (Inst) && preferLiveIn + && TraceBoundaryBlocks.find (Inst->getParent ()) + != TraceBoundaryBlocks.end ()) + OperandKey = -2; // look for PhiCpRes instead. + } else { + DEBUG (std::cerr << "getValueAllocStateKeys: keys not known for " + << F->getName () << ":" << *V << "\n"); + } + } + + /// Returns the register number or stack position where V can be found in the + /// machine code for the function F, which it finds by searching the global + /// variable _llvm_regAllocState written out by PhyRegAlloc.cpp during a + /// previous invocation of llc. + /// + static AllocInfo getValueAllocStateFromModule (Function *F, Value *V, + bool preferLiveIn) { + int InstructionKey = -1, OperandKey = -1; + getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn); + if (InstructionKey == -1 && OperandKey == -1) + return AllocInfo(); + + unsigned FI = getLLVMFunctionPositionInfo (F); + FunctionAllocState *FAllocState = _llvm_regAllocState.functions[FI]; + assert (FAllocState->numTuples > 0 + && "Reg. alloc state for function is empty"); + // Reconstruct the AllocInfo for V by searching + // _llvm_regAllocState.functions[FI] for a tuple that starts with + // (InstructionKey, OperandKey, ...): + for (unsigned i = 0; i < FAllocState->numTuples; ++i) { + OperandAllocState &T = FAllocState->tuples[i]; + if (T.Instruction == InstructionKey && T.Operand == OperandKey) { + AllocInfo AI (T.Instruction, T.Operand, + (AllocInfo::AllocStateTy) T.AllocState, T.Placement); + DEBUG (std::cerr << "Alloc state saved in module for " << F->getName () + << ":" << V->getName () << " (key = " << InstructionKey << "," + << OperandKey << ") is " << AI << "\n"); + return AI; + } + } + DEBUG (std::cerr << "Alloc state saved in module for " << F->getName () + << ":" << V->getName () << " (key = " << InstructionKey << "," + << OperandKey << ") NOT FOUND\n"); + return AllocInfo(); + } + + /// Returns the register number or stack position where V can be found in the + /// machine code for the function F, which it finds by searching the global + /// variable ExportedFnAllocState exported by PhyRegAlloc.cpp. + /// + static AllocInfo getValueAllocStateFromGlobal (Function *F, Value *V, + bool preferLiveIn) { + int InstructionKey = -1, OperandKey = -1; + getValueAllocStateKeys (F, V, InstructionKey, OperandKey, preferLiveIn); + if (InstructionKey == -1 && OperandKey == -1) + return AllocInfo(); + + // Get the saved PhyRegAlloc state for F out of ExportedFnAllocState: + std::vector &FState = ExportedFnAllocState[F]; + assert (FState.size () > 0 && "Reg. alloc state for function is empty"); + // Reconstruct the AllocInfo for V by searching + // FState for a tuple that starts with (InstructionKey, OperandKey, ...): + for (unsigned i = 0, s = FState.size (); i < s; ++i) { + AllocInfo &T = FState[i]; + if (T.Instruction == InstructionKey && T.Operand == OperandKey) { + DEBUG (std::cerr << "Alloc state saved in global for " << F->getName () + << ":" << V->getName () << " (key = " << InstructionKey << "," + << OperandKey << ") is " << T << "\n"); + return T; + } + } + DEBUG (std::cerr << "Alloc state saved in global for " << F->getName () + << ":" << V->getName () << " (key = " << InstructionKey << "," + << OperandKey << ") NOT FOUND\n"); + return AllocInfo(); + } + + /// GetValueAllocState - Returns a pair containing the + /// saved register allocator state for a value. + /// + std::pair + GetValueAllocState (TraceFunction *TF, Value *V, bool preferLiveIn) { + if (lastTraceFunction != TF) { + findTraceBoundaryBlocks (TF); + lastTraceFunction = TF; + } + return std::make_pair + (getValueAllocStateFromModule (TF->MatrixFn, V, preferLiveIn), + getValueAllocStateFromGlobal (TF->TraceFn, + TF->getCorrespondingValue (V, preferLiveIn), + preferLiveIn)); + } + + } // end namespace llvm From lattner at cs.uiuc.edu Wed Jul 14 01:29:25 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 01:29:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407140629.BAA11292@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.179 -> 1.180 --- Log message: Revamp handling of labels. In particular, if we create a forward reference for a basic block, use it when the block is defined instead of deleting it and creating a new one. Also, only create at most ONE forward reference for any block, instead of one for each forward reference. --- Diffs of the changes: (+71 -22) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.179 llvm/lib/AsmParser/llvmAsmParser.y:1.180 --- llvm/lib/AsmParser/llvmAsmParser.y:1.179 Tue Jul 13 20:33:11 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 01:28:35 2004 @@ -149,6 +149,12 @@ std::map LateResolveTypes; bool isDeclare; // Is this function a forward declararation? + /// BBForwardRefs - When we see forward references to basic blocks, keep + /// track of them here. + std::map > BBForwardRefs; + std::vector NumberedBlocks; + unsigned NextBBNum; + inline PerFunctionInfo() { CurrentFunction = 0; isDeclare = false; @@ -156,11 +162,18 @@ inline void FunctionStart(Function *M) { CurrentFunction = M; + NextBBNum = 0; } void FunctionDone() { - // If we could not resolve some blocks at parsing time (forward branches) - // resolve the branches now... + NumberedBlocks.clear(); + + // Any forward referenced blocks left? + if (!BBForwardRefs.empty()) + ThrowException("Undefined reference to label " + + BBForwardRefs.begin()->second.first.getName()); + + // Resolve all forward references now. ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); // Make sure to resolve any constant expr references that might exist within @@ -388,20 +401,64 @@ return V; } -static BasicBlock *getBBVal(const ValID &ID) { +/// getBBVal - This is used for two purposes: +/// * If isDefinition is true, a new basic block with the specified ID is being +/// defined. +/// * If isDefinition is true, this is a reference to a basic block, which may +/// or may not be a forward reference. +/// +static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) { assert(inFunctionScope() && "Can't get basic block at global scope!"); - // See if the value has already been defined. - Value *V = getValNonImprovising(Type::LabelTy, ID); - if (V) return cast(V); + std::string Name; + BasicBlock *BB = 0; + switch (ID.Type) { + default: ThrowException("Illegal label reference " + ID.getName()); + case ValID::NumberVal: // Is it a numbered definition? + if (unsigned(ID.Num) >= CurFun.NumberedBlocks.size()) + CurFun.NumberedBlocks.resize(ID.Num+1); + BB = CurFun.NumberedBlocks[ID.Num]; + break; + case ValID::NameVal: // Is it a named definition? + Name = ID.Name; + if (Value *N = lookupInSymbolTable(Type::LabelTy, Name)) + BB = cast(N); + break; + } - BasicBlock *BB = new BasicBlock(); - // Remember where this forward reference came from. FIXME, shouldn't we try - // to recycle these things?? - CurModule.PlaceHolderInfo.insert(std::make_pair(BB, std::make_pair(ID, - llvmAsmlineno))); + // See if the block has already been defined. + if (BB) { + // If this is the definition of the block, make sure the existing value was + // just a forward reference. If it was a forward reference, there will be + // an entry for it in the PlaceHolderInfo map. + if (isDefinition && !CurFun.BBForwardRefs.erase(BB)) + // The existing value was a definition, not a forward reference. + ThrowException("Redefinition of label " + ID.getName()); + + ID.destroy(); // Free strdup'd memory. + return BB; + } + + // Otherwise this block has not been seen before. + BB = new BasicBlock("", CurFun.CurrentFunction); + if (ID.Type == ValID::NameVal) { + BB->setName(ID.Name); + } else { + CurFun.NumberedBlocks[ID.Num] = BB; + } + + // If this is not a definition, keep track of it so we can use it as a forward + // reference. + if (!isDefinition) { + // Remember where this forward reference came from. + CurFun.BBForwardRefs[BB] = std::make_pair(ID, llvmAsmlineno); + } else { + // The forward declaration could have been inserted anywhere in the + // function: insert it into the correct place now. + CurFun.CurrentFunction->getBasicBlockList().remove(BB); + CurFun.CurrentFunction->getBasicBlockList().push_back(BB); + } - InsertValue(BB, CurFun.LateResolveValues); return BB; } @@ -1660,18 +1717,10 @@ $$ = $1; } | /* empty */ { - // FIXME: Should check to see if there is a forward ref'd basic block that - // we can use and reuse it as appropriate. It doesn't make sense just to - // make forward ref'd blocks then discard them. - $$ = CurBB = new BasicBlock("", CurFun.CurrentFunction); + $$ = CurBB = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); } | LABELSTR { - // FIXME: Should check to see if there is a forward ref'd basic block that - // we can use and reuse it as appropriate. It doesn't make sense just to - // make forward ref'd blocks then discard them. - $$ = CurBB = new BasicBlock("", CurFun.CurrentFunction); - setValueName($$, $1); - InsertValue($$); + $$ = CurBB = getBBVal(ValID::create($1), true); }; BBTerminatorInst : RET ResolvedVal { // Return with a result... From lattner at cs.uiuc.edu Wed Jul 14 01:39:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 01:39:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407140639.BAA11637@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.180 -> 1.181 --- Log message: Finegrainify namespacification --- Diffs of the changes: (+4 -6) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.180 llvm/lib/AsmParser/llvmAsmParser.y:1.181 --- llvm/lib/AsmParser/llvmAsmParser.y:1.180 Wed Jul 14 01:28:35 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 01:39:48 2004 @@ -31,9 +31,11 @@ int yyparse(); namespace llvm { + std::string CurFilename; +} +using namespace llvm; static Module *ParserResult; -std::string CurFilename; // DEBUG_UPREFS - Define this symbol if you want to enable debugging output // relating to upreferences in the input stream. @@ -784,7 +786,7 @@ // RunVMAsmParser - Define an interface to this parser //===----------------------------------------------------------------------===// // -Module *RunVMAsmParser(const std::string &Filename, FILE *F) { +Module *llvm::RunVMAsmParser(const std::string &Filename, FILE *F) { llvmAsmin = F; CurFilename = Filename; llvmAsmlineno = 1; // Reset the current line number... @@ -864,10 +866,6 @@ return Result; } -} // End llvm namespace - -using namespace llvm; - %} %union { From lattner at cs.uiuc.edu Wed Jul 14 01:45:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 01:45:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/Lexer.l llvmAsmParser.y Message-ID: <200407140645.BAA12142@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: Lexer.l updated: 1.50 -> 1.51 llvmAsmParser.y updated: 1.181 -> 1.182 --- Log message: Remove a gross and crufty "feature" that was never documented and doesn't work. --- Diffs of the changes: (+1 -7) Index: llvm/lib/AsmParser/Lexer.l diff -u llvm/lib/AsmParser/Lexer.l:1.50 llvm/lib/AsmParser/Lexer.l:1.51 --- llvm/lib/AsmParser/Lexer.l:1.50 Sun Jul 4 07:17:44 2004 +++ llvm/lib/AsmParser/Lexer.l Wed Jul 14 01:44:56 2004 @@ -179,7 +179,6 @@ declare { return DECLARE; } global { return GLOBAL; } constant { return CONSTANT; } -const { return CONST; } internal { return INTERNAL; } linkonce { return LINKONCE; } weak { return WEAK; } Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.181 llvm/lib/AsmParser/llvmAsmParser.y:1.182 --- llvm/lib/AsmParser/llvmAsmParser.y:1.181 Wed Jul 14 01:39:48 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 01:44:56 2004 @@ -1424,12 +1424,7 @@ }; // ConstPool - Constants with optional names assigned to them. -ConstPool : ConstPool OptAssign CONST ConstVal { - // FIXME: THIS SHOULD REALLY BE ELIMINATED. It is totally unneeded. - if (!setValueNameMergingDuplicates($4, $2)) - InsertValue($4); - } - | ConstPool OptAssign TYPE TypesV { // Types can be defined in the const pool +ConstPool : ConstPool OptAssign TYPE TypesV { // Types can be defined in the const pool // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: // From lattner at cs.uiuc.edu Wed Jul 14 02:12:59 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 02:12:59 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407140712.CAA15088@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.182 -> 1.183 --- Log message: Simplify code. Do not allow functions to be redefined more than once. Since the stupid '%X = const int 4' thing is gone, we can now simplify setValueNameMergingDuplicates a bit more. --- Diffs of the changes: (+10 -27) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.182 llvm/lib/AsmParser/llvmAsmParser.y:1.183 --- llvm/lib/AsmParser/llvmAsmParser.y:1.182 Wed Jul 14 01:44:56 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 02:12:48 2004 @@ -591,22 +591,17 @@ // allowed to be redefined in the specified context. If the name is a new name // for the typeplane, false is returned. // -static bool setValueNameMergingDuplicates(Value *V, char *NameStr) { - assert(V->getType() != Type::VoidTy && "Global or constant of type void?"); - +static bool setValueNameMergingDuplicates(GlobalValue *V, char *NameStr) { if (NameStr == 0) return false; std::string Name(NameStr); // Copy string free(NameStr); // Free old string - // FIXME: If we eliminated the function constant pool (which we should), this - // would just unconditionally look at the module symtab. - SymbolTable &ST = inFunctionScope() ? - CurFun.CurrentFunction->getSymbolTable() : - CurModule.CurrentModule->getSymbolTable(); + SymbolTable &ST = CurModule.CurrentModule->getSymbolTable(); Value *Existing = ST.lookup(V->getType(), Name); if (Existing) { // Inserting a name that is already defined??? + // We are a simple redefinition of a value, check to see if it is defined // the same as the old one... if (GlobalVariable *EGV = dyn_cast(Existing)) { @@ -630,8 +625,6 @@ return true; // They are equivalent! } } - } else if (const Constant *C = dyn_cast(Existing)) { - if (C == V) return true; // Constants are equal to themselves } ThrowException("Redefinition of value named '" + Name + "' in the '" + @@ -1571,24 +1564,14 @@ const PointerType *PFT = PointerType::get(FT); delete $1; - Function *Fn = 0; // Is the function already in symtab? - if ((Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { - // Yes it is. If this is the case, either we need to be a forward decl, - // or it needs to be. - if (!CurFun.isDeclare && !Fn->isExternal()) - ThrowException("Redefinition of function '" + FunctionName + "'!"); - - // Make sure to strip off any argument names so we can't get conflicts... - for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI) - AI->setName(""); - - } else { // Not already defined? - Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, - CurModule.CurrentModule); - InsertValue(Fn, CurModule.Values); - CurModule.DeclareNewGlobalValue(Fn, ValID::create($2)); - } + if (CurModule.CurrentModule->getFunction(FunctionName, FT)) + ThrowException("Redefinition of function '" + FunctionName + "'!"); + + Function *Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, + CurModule.CurrentModule); + InsertValue(Fn, CurModule.Values); + CurModule.DeclareNewGlobalValue(Fn, ValID::create($2)); free($2); // Free strdup'd memory! CurFun.FunctionStart(Fn); From lattner at cs.uiuc.edu Wed Jul 14 03:24:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 03:24:02 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407140824.DAA16735@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.183 -> 1.184 --- Log message: Pull out code shared between GV forward-decl and definition processing. This gives us only a single call site for setValueNameMergingDuplicates. The next stage is the start merging them together. --- Diffs of the changes: (+37 -50) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.183 llvm/lib/AsmParser/llvmAsmParser.y:1.184 --- llvm/lib/AsmParser/llvmAsmParser.y:1.183 Wed Jul 14 02:12:48 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 03:23:52 2004 @@ -591,7 +591,7 @@ // allowed to be redefined in the specified context. If the name is a new name // for the typeplane, false is returned. // -static bool setValueNameMergingDuplicates(GlobalValue *V, char *NameStr) { +static bool setValueNameMergingDuplicates(GlobalVariable *V, char *NameStr) { if (NameStr == 0) return false; std::string Name(NameStr); // Copy string @@ -609,21 +609,19 @@ // 1. If at least one of the globals is uninitialized or // 2. If both initializers have the same value. // - if (GlobalVariable *GV = dyn_cast(V)) { - if (!EGV->hasInitializer() || !GV->hasInitializer() || - EGV->getInitializer() == GV->getInitializer()) { - - // Make sure the existing global version gets the initializer! Make - // sure that it also gets marked const if the new version is. - if (GV->hasInitializer() && !EGV->hasInitializer()) - EGV->setInitializer(GV->getInitializer()); - if (GV->isConstant()) - EGV->setConstant(true); - EGV->setLinkage(GV->getLinkage()); - - delete GV; // Destroy the duplicate! - return true; // They are equivalent! - } + if (!EGV->hasInitializer() || !V->hasInitializer() || + EGV->getInitializer() == V->getInitializer()) { + + // Make sure the existing global version gets the initializer! Make + // sure that it also gets marked const if the new version is. + if (V->hasInitializer() && !EGV->hasInitializer()) + EGV->setInitializer(V->getInitializer()); + if (V->isConstant()) + EGV->setConstant(true); + EGV->setLinkage(V->getLinkage()); + + delete V; // Destroy the duplicate! + return true; // They are equivalent! } } @@ -636,7 +634,26 @@ return false; } - +/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, +/// this is a declaration, otherwise it is a definition. +static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, + bool isConstantGlobal, const Type *Ty, + Constant *Initializer) { + // Global declarations appear in Constant Pool + GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage, + Initializer); + if (!setValueNameMergingDuplicates(GV, NameStr)) { // If not redefining... + CurModule.CurrentModule->getGlobalList().push_back(GV); + int Slot = InsertValue(GV, CurModule.Values); + + if (Slot != -1) { + CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); + } else { + CurModule.DeclareNewGlobalValue(GV, + ValID::create((char*)GV->getName().c_str())); + } + } +} // setTypeName - Set the specified type to the name given. The name may be // null potentially, in which case this is a noop. The string passed in is @@ -1443,41 +1460,11 @@ | ConstPool FunctionProto { // Function prototypes can be in const pool } | ConstPool OptAssign OptLinkage GlobalType ConstVal { - const Type *Ty = $5->getType(); - // Global declarations appear in Constant Pool - Constant *Initializer = $5; - if (Initializer == 0) - ThrowException("Global value initializer is not a constant!"); - - GlobalVariable *GV = new GlobalVariable(Ty, $4, $3, Initializer); - if (!setValueNameMergingDuplicates(GV, $2)) { // If not redefining... - CurModule.CurrentModule->getGlobalList().push_back(GV); - int Slot = InsertValue(GV, CurModule.Values); - - if (Slot != -1) { - CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); - } else { - CurModule.DeclareNewGlobalValue(GV, ValID::create( - (char*)GV->getName().c_str())); - } - } + if ($5 == 0) ThrowException("Global value initializer is not a constant!"); + ParseGlobalVariable($2, $3, $4, $5->getType(), $5); } | ConstPool OptAssign EXTERNAL GlobalType Types { - const Type *Ty = *$5; - // Global declarations appear in Constant Pool - GlobalVariable *GV = new GlobalVariable(Ty,$4,GlobalValue::ExternalLinkage); - if (!setValueNameMergingDuplicates(GV, $2)) { // If not redefining... - CurModule.CurrentModule->getGlobalList().push_back(GV); - int Slot = InsertValue(GV, CurModule.Values); - - if (Slot != -1) { - CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); - } else { - assert(GV->hasName() && "Not named and not numbered!?"); - CurModule.DeclareNewGlobalValue(GV, ValID::create( - (char*)GV->getName().c_str())); - } - } + ParseGlobalVariable($2, GlobalValue::ExternalLinkage, $4, *$5, 0); delete $5; } | ConstPool TARGET TargetDefinition { From alkis at cs.uiuc.edu Wed Jul 14 03:30:45 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 03:30:45 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407140830.DAA27962@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test added (r1.1) --- Log message: Add makefiles for automatically getting bytecode and llvm assmbly out of classfiles. --- Diffs of the changes: (+17 -0) Index: llvm-java/test/Makefile.test diff -c /dev/null llvm-java/test/Makefile.test:1.1 *** /dev/null Wed Jul 14 03:30:45 2004 --- llvm-java/test/Makefile.test Wed Jul 14 03:30:35 2004 *************** *** 0 **** --- 1,17 ---- + ##==-- test/Makefile.test - Common make rules Java tests -*- makefile -*--====## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + + # rule to build raw bytecode from a classfile + Output/%.rbc: %.class Output/.dir + $(CLASS2LLVM) $* | $(LLVMTOOLCURRENT)/opt$(EXEEXT) -mem2reg > $@ + + %.ll: %.rbc + $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) < $< > $@ + + include $(LEVEL)/Makefile.common From alkis at cs.uiuc.edu Wed Jul 14 03:30:45 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 03:30:45 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Compiler/Makefile Message-ID: <200407140830.DAA27957@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Compiler: Makefile added (r1.1) --- Log message: Add makefiles for automatically getting bytecode and llvm assmbly out of classfiles. --- Diffs of the changes: (+15 -0) Index: llvm-java/test/Compiler/Makefile diff -c /dev/null llvm-java/test/Compiler/Makefile:1.1 *** /dev/null Wed Jul 14 03:30:45 2004 --- llvm-java/test/Compiler/Makefile Wed Jul 14 03:30:35 2004 *************** *** 0 **** --- 1,15 ---- + ##===- tests/Compiler/Makefile -----------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := ../.. + + CLASSFILES := $(wildcard *.class) + + all:: $(foreach ext,rbc ll,$(CLASSFILES:%.class=Output/%.$(ext))) + + include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Wed Jul 14 04:15:11 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:15:11 -0500 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200407140915.EAA02161@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.14 -> 1.15 --- Log message: Add convinience methods for getting specific field or method Attributes. --- Diffs of the changes: (+5 -0) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.14 llvm-java/include/llvm/Java/ClassFile.h:1.15 --- llvm-java/include/llvm/Java/ClassFile.h:1.14 Thu Jul 8 19:00:26 2004 +++ llvm-java/include/llvm/Java/ClassFile.h Wed Jul 14 04:15:01 2004 @@ -26,7 +26,9 @@ // Forward declarations class Attribute; + class ConstantValueAttribute; class CodeAttribute; + class ExceptionsAttribute; class Constant; class ConstantClass; class ConstantNameAndType; @@ -290,6 +292,7 @@ ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } + const ConstantValueAttribute* getConstantValueAttribute() const; std::ostream& dump(std::ostream& os) const; }; @@ -326,6 +329,8 @@ ConstantUtf8* getName() const { return name_; } ConstantUtf8* getDescriptor() const { return descriptor_; } const Attributes& getAttributes() const { return attributes_; } + const CodeAttribute* getCodeAttribute() const; + const ExceptionsAttribute* getExceptionsAttribute() const; std::ostream& dump(std::ostream& os) const; }; From alkis at cs.uiuc.edu Wed Jul 14 04:15:11 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:15:11 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407140915.EAA02158@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.15 -> 1.16 --- Log message: Add convinience methods for getting specific field or method Attributes. --- Diffs of the changes: (+28 -0) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.15 llvm-java/lib/ClassFile/ClassFile.cpp:1.16 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.15 Tue Jul 13 03:57:09 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Wed Jul 14 04:15:01 2004 @@ -137,6 +137,14 @@ return os; } + const Attribute* getAttribute(const Attributes& attributes, + const std::string& name) { + for (unsigned i = 0, e = attributes.size(); i != e; ++i) + if (attributes[i]->getName()->str() == name) + return attributes[i]; + + return NULL; + } } //===----------------------------------------------------------------------===// @@ -509,6 +517,15 @@ return os; } +const ConstantValueAttribute* Field::getConstantValueAttribute() const +{ + if (!isStatic()) + return NULL; + + return (ConstantValueAttribute*) getAttribute(attributes_, + Attribute::CONSTANT_VALUE); +} + //===----------------------------------------------------------------------===// // Method implementation Method::Method(const ConstantPool& cp, std::istream& is) @@ -548,6 +565,17 @@ return os; } +const CodeAttribute* Method::getCodeAttribute() const +{ + return (CodeAttribute*) getAttribute(attributes_, Attribute::CODE); +} + +const ExceptionsAttribute* Method::getExceptionsAttribute() const +{ + return (ExceptionsAttribute*) getAttribute(attributes_, + Attribute::EXCEPTIONS); +} + //===----------------------------------------------------------------------===// // Attribute implementation const std::string Attribute::CONSTANT_VALUE = "ConstantValue"; From alkis at cs.uiuc.edu Wed Jul 14 04:16:51 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:16:51 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407140916.EAA04334@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.56 -> 1.57 --- Log message: Use newly added convinience method. --- Diffs of the changes: (+1 -2) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.56 llvm-java/lib/Compiler/Compiler.cpp:1.57 --- llvm-java/lib/Compiler/Compiler.cpp:1.56 Tue Jul 13 07:42:52 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Wed Jul 14 04:16:41 2004 @@ -268,8 +268,7 @@ Function::InternalLinkage : Function::ExternalLinkage); - const Java::CodeAttribute* codeAttr = - Java::getCodeAttribute(method->getAttributes()); + const Java::CodeAttribute* codeAttr = method->getCodeAttribute(); while (!opStack_.empty()) opStack_.pop(); From alkis at cs.uiuc.edu Wed Jul 14 04:22:03 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:22:03 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407140922.EAA04837@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.16 -> 1.17 --- Log message: Remove duplicate functionality. --- Diffs of the changes: (+3 -20) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.16 llvm-java/lib/ClassFile/ClassFile.cpp:1.17 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.16 Wed Jul 14 04:15:01 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Wed Jul 14 04:21:53 2004 @@ -137,14 +137,6 @@ return os; } - const Attribute* getAttribute(const Attributes& attributes, - const std::string& name) { - for (unsigned i = 0, e = attributes.size(); i != e; ++i) - if (attributes[i]->getName()->str() == name) - return attributes[i]; - - return NULL; - } } //===----------------------------------------------------------------------===// @@ -278,22 +270,13 @@ const Attribute* llvm::Java::getAttribute(const Attributes& attrs, const std::string& name) { - for (Attributes::const_iterator - i = attrs.begin(), e = attrs.end(); i != e; ++i) { - const Attribute* attr = *i; - if (attr->getName()->str() == name) - return attr; - } + for (unsigned i = 0, e = attrs.size(); i != e; ++i) + if (attrs[i]->getName()->str() == name) + return attrs[i]; return NULL; } -const CodeAttribute* llvm::Java::getCodeAttribute(const Attributes& attrs) -{ - return static_cast( - getAttribute(attrs, Attribute::CODE)); -} - //===----------------------------------------------------------------------===// // ClassFileParseError implementation ClassFileParseError::~ClassFileParseError() throw() From alkis at cs.uiuc.edu Wed Jul 14 04:22:03 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:22:03 -0500 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200407140922.EAA04844@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.15 -> 1.16 --- Log message: Remove duplicate functionality. --- Diffs of the changes: (+0 -1) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.15 llvm-java/include/llvm/Java/ClassFile.h:1.16 --- llvm-java/include/llvm/Java/ClassFile.h:1.15 Wed Jul 14 04:15:01 2004 +++ llvm-java/include/llvm/Java/ClassFile.h Wed Jul 14 04:21:53 2004 @@ -61,7 +61,6 @@ const Attribute* getAttribute(const Attributes& attrs, const std::string& name); - const CodeAttribute* getCodeAttribute(const Attributes& attrs); class ClassFile { static const ClassFile* readClassFile(std::istream& is); From alkis at cs.uiuc.edu Wed Jul 14 04:44:53 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:44:53 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407140944.EAA11035@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.57 -> 1.58 --- Log message: Move llvm::Java::Constant -> llvm::Constant conversion out of do_ldc. --- Diffs of the changes: (+19 -16) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.57 llvm-java/lib/Compiler/Compiler.cpp:1.58 --- llvm-java/lib/Compiler/Compiler.cpp:1.57 Wed Jul 14 04:16:41 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Wed Jul 14 04:44:43 2004 @@ -49,6 +49,23 @@ return !isTwoSlotValue(v); } + llvm::Constant* getConstant(const Constant* c) { + if (dynamic_cast(c)) + assert(0 && "not implemented"); + else if (const ConstantInteger* i = + dynamic_cast(c)) + return ConstantSInt::get(Type::IntTy, i->getValue()); + else if (const ConstantFloat* f = dynamic_cast(c)) + return ConstantFP::get(Type::FloatTy, f->getValue()); + else if (const ConstantLong* l = dynamic_cast(c)) + return ConstantSInt::get(Type::LongTy, l->getValue()); + else if (const ConstantDouble* d = + dynamic_cast(c)) + return ConstantFP::get(Type::DoubleTy, d->getValue()); + else + return NULL; // FIXME: throw something + } + struct Bytecode2BasicBlockMapper : public BytecodeParser { public: @@ -344,22 +361,8 @@ void do_ldc(unsigned bcI, unsigned index) { const Constant* c = cf_->getConstantPool()[index]; - if (dynamic_cast(c)) - assert(0 && "not implemented"); - else if (const ConstantInteger* i = - dynamic_cast(c)) - opStack_.push(ConstantSInt::get(Type::IntTy, i->getValue())); - else if (const ConstantFloat* f = - dynamic_cast(c)) - opStack_.push(ConstantFP::get(Type::FloatTy, f->getValue())); - else if (const ConstantLong* l = - dynamic_cast(c)) - opStack_.push(ConstantSInt::get(Type::LongTy, l->getValue())); - else if (const ConstantDouble* d = - dynamic_cast(c)) - opStack_.push(ConstantFP::get(Type::DoubleTy, d->getValue())); - else - ; // FIXME: throw something + assert(getConstant(c) && "Java constant not handled!"); + opStack_.push(getConstant(c)); } void do_load(unsigned bcI, JType type, unsigned index) { From alkis at cs.uiuc.edu Wed Jul 14 04:54:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed, 14 Jul 2004 04:54:04 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407140954.EAA13499@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.58 -> 1.59 --- Log message: Use internal linkage for private globals with a constant initializer. --- Diffs of the changes: (+9 -3) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.58 llvm-java/lib/Compiler/Compiler.cpp:1.59 --- llvm-java/lib/Compiler/Compiler.cpp:1.58 Wed Jul 14 04:44:43 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Wed Jul 14 04:53:54 2004 @@ -234,15 +234,21 @@ const Fields& fields = cf->getFields(); for (unsigned i = 0, e = fields.size(); i != e; ++i) { const Field* field = fields[i]; - if (field->isStatic()) + if (field->isStatic()) { + llvm::Constant* init = NULL; + if (const ConstantValueAttribute* cv = + field->getConstantValueAttribute()) + init = getConstant(cv->getValue()); + new GlobalVariable(getType(field->getDescriptor()), field->isFinal(), - (field->isPrivate() ? + (field->isPrivate() & bool(init) ? GlobalVariable::InternalLinkage : GlobalVariable::ExternalLinkage), - NULL, + init, className + '/' + field->getName()->str(), module_); + } else elements.push_back(getType(field->getDescriptor())); } From lattner at cs.uiuc.edu Wed Jul 14 13:14:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 13:14:04 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/iMemory.h Message-ID: <200407141814.NAA27055@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: iMemory.h updated: 1.47 -> 1.48 --- Log message: * Change code to use a static_cast instead of reinterpret_cast * Add comments * Add two new gep ctors for the very common case of creating a two operand GEP instruction. --- Diffs of the changes: (+17 -2) Index: llvm/include/llvm/iMemory.h diff -u llvm/include/llvm/iMemory.h:1.47 llvm/include/llvm/iMemory.h:1.48 --- llvm/include/llvm/iMemory.h:1.47 Thu Jul 1 15:22:31 2004 +++ llvm/include/llvm/iMemory.h Wed Jul 14 13:13:54 2004 @@ -273,18 +273,31 @@ /// class GetElementPtrInst : public Instruction { GetElementPtrInst(const GetElementPtrInst &EPI) - : Instruction(reinterpret_cast(EPI.getType()), GetElementPtr) { + : Instruction((static_cast(&EPI)->getType()), + GetElementPtr) { Operands.reserve(EPI.Operands.size()); for (unsigned i = 0, E = EPI.Operands.size(); i != E; ++i) Operands.push_back(Use(EPI.Operands[i], this)); } void init(Value *Ptr, const std::vector &Idx); - + void init(Value *Ptr, Value *Idx0, Value *Idx1); public: + /// Constructors - Create a getelementptr instruction with a base pointer an + /// list of indices. The first ctor can optionally insert before an existing + /// instruction, the second appends the new instruction to the specified + /// BasicBlock. GetElementPtrInst(Value *Ptr, const std::vector &Idx, const std::string &Name = "", Instruction *InsertBefore =0); GetElementPtrInst(Value *Ptr, const std::vector &Idx, const std::string &Name, BasicBlock *InsertAtEnd); + + /// Constructors - These two constructors are convenience methods because two + /// index getelementptr instructions are so common. + GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, + const std::string &Name = "", Instruction *InsertBefore =0); + GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, + const std::string &Name, BasicBlock *InsertAtEnd); + virtual Instruction *clone() const { return new GetElementPtrInst(*this); } // getType - Overload to return most specific pointer type... @@ -300,6 +313,8 @@ /// static const Type *getIndexedType(const Type *Ptr, const std::vector &Indices, + bool AllowStructLeaf = false); + static const Type *getIndexedType(const Type *Ptr, Value *Idx0, Value *Idx1, bool AllowStructLeaf = false); inline op_iterator idx_begin() { return op_begin()+1; } From lattner at cs.uiuc.edu Wed Jul 14 13:14:43 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 13:14:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iMemory.cpp Message-ID: <200407141814.NAA27143@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iMemory.cpp updated: 1.41 -> 1.42 --- Log message: Implement new helper methods for creating two-index GEP instructions --- Diffs of the changes: (+42 -2) Index: llvm/lib/VMCore/iMemory.cpp diff -u llvm/lib/VMCore/iMemory.cpp:1.41 llvm/lib/VMCore/iMemory.cpp:1.42 --- llvm/lib/VMCore/iMemory.cpp:1.41 Thu Jul 1 15:23:52 2004 +++ llvm/lib/VMCore/iMemory.cpp Wed Jul 14 13:14:33 2004 @@ -16,8 +16,7 @@ #include "llvm/DerivedTypes.h" using namespace llvm; -void AllocationInst::init(const Type *Ty, Value *ArraySize, unsigned iTy) -{ +void AllocationInst::init(const Type *Ty, Value *ArraySize, unsigned iTy) { // ArraySize defaults to 1. if (!ArraySize) ArraySize = ConstantUInt::get(Type::UIntTy, 1); @@ -177,6 +176,13 @@ Operands.push_back(Use(Idx[i], this)); } +void GetElementPtrInst::init(Value *Ptr, Value *Idx0, Value *Idx1) { + Operands.reserve(3); + Operands.push_back(Use(Ptr, this)); + Operands.push_back(Use(Idx0, this)); + Operands.push_back(Use(Idx1, this)); +} + GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, const std::string &Name, Instruction *InBe) : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), @@ -193,6 +199,22 @@ init(Ptr, Idx); } +GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, + const std::string &Name, Instruction *InBe) + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx0, Idx1, true))), + GetElementPtr, Name, InBe) { + init(Ptr, Idx0, Idx1); +} + +GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx0, Value *Idx1, + const std::string &Name, BasicBlock *IAE) + : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx0, Idx1, true))), + GetElementPtr, Name, IAE) { + init(Ptr, Idx0, Idx1); +} + // getIndexedType - Returns the type of the element that would be loaded with // a load instruction with the specified parameters. // @@ -234,4 +256,22 @@ } } return CurIdx == Idx.size() ? Ptr : 0; +} + +const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, + Value *Idx0, Value *Idx1, + bool AllowCompositeLeaf) { + const PointerType *PTy = dyn_cast(Ptr); + if (!PTy) return 0; // Type isn't a pointer type! + + // Check the pointer index. + if (!PTy->indexValid(Idx0)) return 0; + + const CompositeType *CT = dyn_cast(PTy->getElementType()); + if (!CT || !CT->indexValid(Idx1)) return 0; + + const Type *ElTy = CT->getTypeAtIndex(Idx1); + if (AllowCompositeLeaf || ElTy->isFirstClassType()) + return ElTy; + return 0; } From lattner at cs.uiuc.edu Wed Jul 14 14:33:57 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 14:33:57 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407141933.OAA18497@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.184 -> 1.185 --- Log message: Fix a regression from last night. Apparently the CFE is broken and outputs functions multiple times, expecting them to be merged. This should be fixed in the CFE, then here. --- Diffs of the changes: (+17 -7) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.184 llvm/lib/AsmParser/llvmAsmParser.y:1.185 --- llvm/lib/AsmParser/llvmAsmParser.y:1.184 Wed Jul 14 03:23:52 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 14:33:47 2004 @@ -1551,14 +1551,24 @@ const PointerType *PFT = PointerType::get(FT); delete $1; + Function *Fn = 0; // Is the function already in symtab? - if (CurModule.CurrentModule->getFunction(FunctionName, FT)) - ThrowException("Redefinition of function '" + FunctionName + "'!"); - - Function *Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, - CurModule.CurrentModule); - InsertValue(Fn, CurModule.Values); - CurModule.DeclareNewGlobalValue(Fn, ValID::create($2)); + if ((Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { + // Yes it is. If this is the case, either we need to be a forward decl, + // or it needs to be. + if (!CurFun.isDeclare && !Fn->isExternal()) + ThrowException("Redefinition of function '" + FunctionName + "'!"); + + // Make sure to strip off any argument names so we can't get conflicts... + for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI) + AI->setName(""); + + } else { // Not already defined? + Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, + CurModule.CurrentModule); + InsertValue(Fn, CurModule.Values); + CurModule.DeclareNewGlobalValue(Fn, ValID::create($2)); + } free($2); // Free strdup'd memory! CurFun.FunctionStart(Fn); From lattner at cs.uiuc.edu Wed Jul 14 15:10:36 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 15:10:36 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h AbstractTypeUser.h Message-ID: <200407142010.PAA28027@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.53 -> 1.54 AbstractTypeUser.h updated: 1.20 -> 1.21 --- Log message: Make PATypeHolder and friends return non-const pointers to the types they hold. Because types are basically immutable anyway, they should not be referenced as "const Type*" everywhere. Just "Type*" should suffice! --- Diffs of the changes: (+11 -11) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.53 llvm/include/llvm/Type.h:1.54 --- llvm/include/llvm/Type.h:1.53 Fri Jul 9 12:02:57 2004 +++ llvm/include/llvm/Type.h Wed Jul 14 15:10:26 2004 @@ -347,9 +347,9 @@ /// type we are pointing to is forwarding to a new type. If so, we drop our /// reference to the type. /// -inline const Type* PATypeHolder::get() const { +inline Type* PATypeHolder::get() const { const Type *NewTy = Ty->getForwardedType(); - if (!NewTy) return Ty; + if (!NewTy) return const_cast(Ty); return *const_cast(this) = NewTy; } Index: llvm/include/llvm/AbstractTypeUser.h diff -u llvm/include/llvm/AbstractTypeUser.h:1.20 llvm/include/llvm/AbstractTypeUser.h:1.21 --- llvm/include/llvm/AbstractTypeUser.h:1.20 Tue Jun 8 12:44:21 2004 +++ llvm/include/llvm/AbstractTypeUser.h Wed Jul 14 15:10:26 2004 @@ -93,17 +93,17 @@ inline ~PATypeHandle() { removeUser(); } // Automatic casting operator so that the handle may be used naturally - inline operator const Type *() const { return Ty; } - inline const Type *get() const { return Ty; } + inline operator Type *() const { return const_cast(Ty); } + inline Type *get() const { return const_cast(Ty); } // operator= - Allow assignment to handle - inline const Type *operator=(const Type *ty) { + inline Type *operator=(const Type *ty) { if (Ty != ty) { // Ensure we don't accidentally drop last ref to Ty removeUser(); Ty = ty; addUser(); } - return Ty; + return get(); } // operator= - Allow assignment to handle @@ -145,14 +145,14 @@ ~PATypeHolder() { dropRef(); } - operator const Type *() const { return get(); } - const Type *get() const; + operator Type *() const { return get(); } + Type *get() const; // operator-> - Allow user to dereference handle naturally... - const Type *operator->() const { return get(); } + Type *operator->() const { return get(); } // operator= - Allow assignment to handle - const Type *operator=(const Type *ty) { + Type *operator=(const Type *ty) { if (Ty != ty) { // Don't accidentally drop last ref to Ty. dropRef(); Ty = ty; @@ -160,7 +160,7 @@ } return get(); } - const Type *operator=(const PATypeHolder &H) { + Type *operator=(const PATypeHolder &H) { return operator=(H.Ty); } From lattner at cs.uiuc.edu Wed Jul 14 15:27:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 15:27:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp Message-ID: <200407142027.PAA11201@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: BasicAliasAnalysis.cpp updated: 1.44 -> 1.45 --- Log message: Simplify logic. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.44 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.45 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.44 Sat Jun 19 03:05:58 2004 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Wed Jul 14 15:27:12 2004 @@ -516,13 +516,13 @@ // Is there anything to check? if (GEP1Ops.size() > MinOperands) { for (unsigned i = FirstConstantOper; i != MaxOperands; ++i) - if (isa(GEP1Ops[i]) && !isa(GEP1Ops[i]) && + if (isa(GEP1Ops[i]) && !cast(GEP1Ops[i])->isNullValue()) { // Yup, there's a constant in the tail. Set all variables to // constants in the GEP instruction to make it suiteable for // TargetData::getIndexedOffset. for (i = 0; i != MaxOperands; ++i) - if (!isa(GEP1Ops[i]) || isa(GEP1Ops[i])) + if (!isa(GEP1Ops[i])) GEP1Ops[i] = Constant::getNullValue(GEP1Ops[i]->getType()); // Okay, now get the offset. This is the relative offset for the full // instruction. From gaeke at cs.uiuc.edu Wed Jul 14 15:33:24 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed, 14 Jul 2004 15:33:24 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407142033.PAA16781@seraph.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.114 -> 1.115 --- Log message: Actually set the endian/pointersize flags on the module being read in! --- Diffs of the changes: (+3 -0) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.114 llvm/lib/Bytecode/Reader/Reader.cpp:1.115 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.114 Tue Jul 13 02:37:43 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Jul 14 15:33:13 2004 @@ -1860,6 +1860,9 @@ if (hasNoEndianness) Endianness = Module::AnyEndianness; if (hasNoPointerSize) PointerSize = Module::AnyPointerSize; + TheModule->setEndianness(Endianness); + TheModule->setPointerSize(PointerSize); + if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize); } From lattner at cs.uiuc.edu Wed Jul 14 15:43:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 15:43:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407142043.PAA19976@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.185 -> 1.186 --- Log message: Fold setValueNameMergingDuplicates into ParseGlobalVariable, allowing us to substantially simplify the result. In particular, we no longer create GlobalVariables and then immediately destroy them when they are duplciate definitions. The real point of this patch though is that it gets us closer to the DeclareNewGlobalValue calls... --- Diffs of the changes: (+39 -56) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.185 llvm/lib/AsmParser/llvmAsmParser.y:1.186 --- llvm/lib/AsmParser/llvmAsmParser.y:1.185 Wed Jul 14 14:33:47 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 15:42:57 2004 @@ -582,76 +582,59 @@ } } -// setValueNameMergingDuplicates - Set the specified value to the name given. -// The name may be null potentially, in which case this is a noop. The string -// passed in is assumed to be a malloc'd string buffer, and is free'd by this -// function. -// -// This function returns true if the value has already been defined, but is -// allowed to be redefined in the specified context. If the name is a new name -// for the typeplane, false is returned. -// -static bool setValueNameMergingDuplicates(GlobalVariable *V, char *NameStr) { - if (NameStr == 0) return false; - - std::string Name(NameStr); // Copy string - free(NameStr); // Free old string - - SymbolTable &ST = CurModule.CurrentModule->getSymbolTable(); +/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, +/// this is a declaration, otherwise it is a definition. +static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, + bool isConstantGlobal, const Type *Ty, + Constant *Initializer) { + if (isa(Ty)) + ThrowException("Cannot declare global vars of function type!"); - Value *Existing = ST.lookup(V->getType(), Name); - if (Existing) { // Inserting a name that is already defined??? + // If this global has a name, check to see if there is already a definition + // of this global in the module. If so, merge as appropriate. Note that + // this is really just a hack around problems in the CFE. :( + std::string Name; + if (NameStr) { + Name = NameStr; // Copy string + free(NameStr); // Free old string + + SymbolTable &ST = CurModule.CurrentModule->getSymbolTable(); + if (Value *Existing = ST.lookup(Ty, Name)) { + // We are a simple redefinition of a value, check to see if it is defined + // the same as the old one... + GlobalVariable *EGV = cast(Existing); - // We are a simple redefinition of a value, check to see if it is defined - // the same as the old one... - if (GlobalVariable *EGV = dyn_cast(Existing)) { // We are allowed to redefine a global variable in two circumstances: // 1. If at least one of the globals is uninitialized or // 2. If both initializers have the same value. // - if (!EGV->hasInitializer() || !V->hasInitializer() || - EGV->getInitializer() == V->getInitializer()) { - + if (!EGV->hasInitializer() || !Initializer || + EGV->getInitializer() == Initializer) { + // Make sure the existing global version gets the initializer! Make // sure that it also gets marked const if the new version is. - if (V->hasInitializer() && !EGV->hasInitializer()) - EGV->setInitializer(V->getInitializer()); - if (V->isConstant()) + if (Initializer && !EGV->hasInitializer()) + EGV->setInitializer(Initializer); + if (isConstantGlobal) EGV->setConstant(true); - EGV->setLinkage(V->getLinkage()); - - delete V; // Destroy the duplicate! - return true; // They are equivalent! + EGV->setLinkage(Linkage); + return; } - } - ThrowException("Redefinition of value named '" + Name + "' in the '" + - V->getType()->getDescription() + "' type plane!"); + ThrowException("Redefinition of value named '" + Name + "' in the '" + + Ty->getDescription() + "' type plane!"); + } } - // Set the name. - V->setName(Name, &ST); - return false; -} - -/// ParseGlobalVariable - Handle parsing of a global. If Initializer is null, -/// this is a declaration, otherwise it is a definition. -static void ParseGlobalVariable(char *NameStr,GlobalValue::LinkageTypes Linkage, - bool isConstantGlobal, const Type *Ty, - Constant *Initializer) { - // Global declarations appear in Constant Pool GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage, - Initializer); - if (!setValueNameMergingDuplicates(GV, NameStr)) { // If not redefining... - CurModule.CurrentModule->getGlobalList().push_back(GV); - int Slot = InsertValue(GV, CurModule.Values); - - if (Slot != -1) { - CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); - } else { - CurModule.DeclareNewGlobalValue(GV, - ValID::create((char*)GV->getName().c_str())); - } + Initializer, Name, + CurModule.CurrentModule); + int Slot = InsertValue(GV, CurModule.Values); + + if (Slot != -1) { + CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); + } else { + CurModule.DeclareNewGlobalValue(GV, ValID::create((char*)Name.c_str())); } } From lattner at cs.uiuc.edu Wed Jul 14 16:44:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 16:44:11 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407142144.QAA29352@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.186 -> 1.187 --- Log message: * Fairly substantial change. Instead of creating new globalvariables, then replaceAllUsesWith'ing any forward references, just use the forward reference if it exists. This introduces GetForwardRefForGlobal, which will eventually completely replace the horrible DeclareNewGlobalValue function. --- Diffs of the changes: (+49 -14) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.186 llvm/lib/AsmParser/llvmAsmParser.y:1.187 --- llvm/lib/AsmParser/llvmAsmParser.y:1.186 Wed Jul 14 15:42:57 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 16:44:00 2004 @@ -112,6 +112,21 @@ } + // GetForwardRefForGlobal - Check to see if there is a forward reference + // for this global. If so, remove it from the GlobalRefs map and return it. + // If not, just return null. + GlobalValue *GetForwardRefForGlobal(const PointerType *PTy, ValID ID) { + // Check to see if there is a forward reference to this global variable... + // if there is, eliminate it and patch the reference to use the new def'n. + GlobalRefsType::iterator I = GlobalRefs.find(std::make_pair(PTy, ID)); + GlobalValue *Ret = 0; + if (I != GlobalRefs.end()) { + Ret = I->second; + GlobalRefs.erase(I); + } + return Ret; + } + // DeclareNewGlobalValue - Called every time a new GV has been defined. This // is used to remove things from the forward declaration map, resolving them // to the correct thing as needed. @@ -626,15 +641,30 @@ } } - GlobalVariable *GV = new GlobalVariable(Ty, isConstantGlobal, Linkage, - Initializer, Name, - CurModule.CurrentModule); - int Slot = InsertValue(GV, CurModule.Values); - - if (Slot != -1) { - CurModule.DeclareNewGlobalValue(GV, ValID::create(Slot)); + const PointerType *PTy = PointerType::get(Ty); + + // See if this global value was forward referenced. If so, recycle the + // object. + ValID ID; + if (!Name.empty()) { + ID = ValID::create((char*)Name.c_str()); + } else { + ID = ValID::create((int)CurModule.Values[PTy].size()); + } + + if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { + // Move the global to the end of the list, from whereever it was + // previously inserted. + GlobalVariable *GV = cast(FWGV); + CurModule.CurrentModule->getGlobalList().remove(GV); + CurModule.CurrentModule->getGlobalList().push_back(GV); + GV->setInitializer(Initializer); + GV->setLinkage(Linkage); + GV->setConstant(isConstantGlobal); } else { - CurModule.DeclareNewGlobalValue(GV, ValID::create((char*)Name.c_str())); + // Otherwise there is no existing GV to use, create one now. + new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, + CurModule.CurrentModule); } } @@ -1261,15 +1291,20 @@ V = I->second; // Placeholder already exists, use it... $2.destroy(); } else { + std::string Name; + + /// FIXME: We shouldn't be creating global vars as forward refs for + /// functions at all here! + if (!isa(PT->getElementType())) + if ($2.Type == ValID::NameVal) Name = $2.Name; + // Create a placeholder for the global variable reference... - GlobalVariable *GV = new GlobalVariable(PT->getElementType(), - false, - GlobalValue::ExternalLinkage); + GlobalVariable *GV = new GlobalVariable(PT->getElementType(), false, + GlobalValue::ExternalLinkage,0, + Name, CurModule.CurrentModule); + // Keep track of the fact that we have a forward ref to recycle it CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV)); - - // Must temporarily push this value into the module table... - CurModule.CurrentModule->getGlobalList().push_back(GV); V = GV; } } From lattner at cs.uiuc.edu Wed Jul 14 17:59:57 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 17:59:57 -0500 Subject: [llvm-commits] CVS: llvm/test/Feature/globalredefinition.ll Message-ID: <200407142259.RAA31421@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: globalredefinition.ll added (r1.1) --- Log message: New, horrible, testcase --- Diffs of the changes: (+18 -0) Index: llvm/test/Feature/globalredefinition.ll diff -c /dev/null llvm/test/Feature/globalredefinition.ll:1.1 *** /dev/null Wed Jul 14 17:59:57 2004 --- llvm/test/Feature/globalredefinition.ll Wed Jul 14 17:59:47 2004 *************** *** 0 **** --- 1,18 ---- + ; Test forward references and redefinitions of globals + + %Y = global void()* %X + + %A = global int* %B + %B = global int 7 + %B = global int 7 + + + declare void %X() + + declare void %X() + + void %X() { + ret void + } + + declare void %X() From lattner at cs.uiuc.edu Wed Jul 14 18:03:57 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 18:03:57 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407142303.SAA31441@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.187 -> 1.188 --- Log message: ** Finally DeclareNewGlobalValue is dead! * Simplify a lot of code because type's cannot be in function symbol tables * Fix memory leaks in handling of redefined function prototypes * Don't use SymbolTable directly for stuff that we can go through the Module for. * Fix some minor bugs on obscure testcases like: test/Feature/globalredefinition.ll * Do not create GlobalVariable objects for forward referenced Functions! * When forward referencing a function in a constant expression, do not create a placeholder, add a bunch of references to it, then turn around and replaceAllUsesOfWith on it with a new global, deleting the placeholder. Instead, when we find the real definition of the global, just use the placeholder instead of creating a new object. This substantially simplifies the asmwriter and should even speed it up on cases heavy in constantexprs (like C++, Java, MSIL)... --- Diffs of the changes: (+89 -124) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.187 llvm/lib/AsmParser/llvmAsmParser.y:1.188 --- llvm/lib/AsmParser/llvmAsmParser.y:1.187 Wed Jul 14 16:44:00 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 18:03:46 2004 @@ -126,35 +126,6 @@ } return Ret; } - - // DeclareNewGlobalValue - Called every time a new GV has been defined. This - // is used to remove things from the forward declaration map, resolving them - // to the correct thing as needed. - // - void DeclareNewGlobalValue(GlobalValue *GV, ValID D) { - // Check to see if there is a forward reference to this global variable... - // if there is, eliminate it and patch the reference to use the new def'n. - GlobalRefsType::iterator I = - GlobalRefs.find(std::make_pair(GV->getType(), D)); - - if (I != GlobalRefs.end()) { - GlobalValue *OldGV = I->second; // Get the placeholder... - I->first.second.destroy(); // Free string memory if necessary - - // Replace all uses of the placeholder with the new GV - OldGV->replaceAllUsesWith(GV); - - // Remove OldGV from the module... - if (GlobalVariable *GVar = dyn_cast(OldGV)) - CurrentModule->getGlobalList().erase(GVar); - else - CurrentModule->getFunctionList().erase(cast(OldGV)); - - // Remove the map entry for the global now that it has been created... - GlobalRefs.erase(I); - } - } - } CurModule; static struct PerFunctionInfo { @@ -209,7 +180,6 @@ } } } - CurModule.DeclareNewGlobalValue(CurrentFunction, FID); Values.clear(); // Clear out function local definitions Types.clear(); // Clear out function local types @@ -237,41 +207,17 @@ static const Type *getTypeVal(const ValID &D, bool DoNotImprovise = false) { switch (D.Type) { - case ValID::NumberVal: { // Is it a numbered definition? - unsigned Num = (unsigned)D.Num; - + case ValID::NumberVal: // Is it a numbered definition? // Module constants occupy the lowest numbered slots... - if (Num < CurModule.Types.size()) - return CurModule.Types[Num]; - - Num -= CurModule.Types.size(); - - // Check that the number is within bounds... - if (Num <= CurFun.Types.size()) - return CurFun.Types[Num]; + if ((unsigned)D.Num < CurModule.Types.size()) + return CurModule.Types[(unsigned)D.Num]; break; - } - case ValID::NameVal: { // Is it a named definition? - std::string Name(D.Name); - SymbolTable *SymTab = 0; - Type *N = 0; - if (inFunctionScope()) { - SymTab = &CurFun.CurrentFunction->getSymbolTable(); - N = SymTab->lookupType(Name); + case ValID::NameVal: // Is it a named definition? + if (const Type *N = CurModule.CurrentModule->getTypeByName(D.Name)) { + D.destroy(); // Free old strdup'd memory... + return N; } - - if (N == 0) { - // Symbol table doesn't automatically chain yet... because the function - // hasn't been added to the module... - // - SymTab = &CurModule.CurrentModule->getSymbolTable(); - N = SymTab->lookupType(Name); - if (N == 0) break; - } - - D.destroy(); // Free old strdup'd memory... - return cast(N); - } + break; default: ThrowException("Internal parser error: Invalid symbol type reference!"); } @@ -438,7 +384,8 @@ break; case ValID::NameVal: // Is it a named definition? Name = ID.Name; - if (Value *N = lookupInSymbolTable(Type::LabelTy, Name)) + if (Value *N = CurFun.CurrentFunction-> + getSymbolTable().lookup(Type::LabelTy, Name)) BB = cast(N); break; } @@ -605,20 +552,43 @@ if (isa(Ty)) ThrowException("Cannot declare global vars of function type!"); - // If this global has a name, check to see if there is already a definition - // of this global in the module. If so, merge as appropriate. Note that - // this is really just a hack around problems in the CFE. :( + const PointerType *PTy = PointerType::get(Ty); + std::string Name; if (NameStr) { Name = NameStr; // Copy string free(NameStr); // Free old string + } - SymbolTable &ST = CurModule.CurrentModule->getSymbolTable(); - if (Value *Existing = ST.lookup(Ty, Name)) { - // We are a simple redefinition of a value, check to see if it is defined - // the same as the old one... - GlobalVariable *EGV = cast(Existing); + // See if this global value was forward referenced. If so, recycle the + // object. + ValID ID; + if (!Name.empty()) { + ID = ValID::create((char*)Name.c_str()); + } else { + ID = ValID::create((int)CurModule.Values[PTy].size()); + } + + if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { + // Move the global to the end of the list, from whereever it was + // previously inserted. + GlobalVariable *GV = cast(FWGV); + CurModule.CurrentModule->getGlobalList().remove(GV); + CurModule.CurrentModule->getGlobalList().push_back(GV); + GV->setInitializer(Initializer); + GV->setLinkage(Linkage); + GV->setConstant(isConstantGlobal); + return; + } + // If this global has a name, check to see if there is already a definition + // of this global in the module. If so, merge as appropriate. Note that + // this is really just a hack around problems in the CFE. :( + if (!Name.empty()) { + // We are a simple redefinition of a value, check to see if it is defined + // the same as the old one. + if (GlobalVariable *EGV = + CurModule.CurrentModule->getGlobalVariable(Name, Ty)) { // We are allowed to redefine a global variable in two circumstances: // 1. If at least one of the globals is uninitialized or // 2. If both initializers have the same value. @@ -636,36 +606,14 @@ return; } - ThrowException("Redefinition of value named '" + Name + "' in the '" + - Ty->getDescription() + "' type plane!"); + ThrowException("Redefinition of global variable named '" + Name + + "' in the '" + Ty->getDescription() + "' type plane!"); } } - const PointerType *PTy = PointerType::get(Ty); - - // See if this global value was forward referenced. If so, recycle the - // object. - ValID ID; - if (!Name.empty()) { - ID = ValID::create((char*)Name.c_str()); - } else { - ID = ValID::create((int)CurModule.Values[PTy].size()); - } - - if (GlobalValue *FWGV = CurModule.GetForwardRefForGlobal(PTy, ID)) { - // Move the global to the end of the list, from whereever it was - // previously inserted. - GlobalVariable *GV = cast(FWGV); - CurModule.CurrentModule->getGlobalList().remove(GV); - CurModule.CurrentModule->getGlobalList().push_back(GV); - GV->setInitializer(Initializer); - GV->setLinkage(Linkage); - GV->setConstant(isConstantGlobal); - } else { - // Otherwise there is no existing GV to use, create one now. - new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, - CurModule.CurrentModule); - } + // Otherwise there is no existing GV to use, create one now. + new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, + CurModule.CurrentModule); } // setTypeName - Set the specified type to the name given. The name may be @@ -676,6 +624,7 @@ // allowed to be redefined in the specified context. If the name is a new name // for the type plane, it is inserted and false is returned. static bool setTypeName(const Type *T, char *NameStr) { + assert(!inFunctionScope() && "Can't give types function-local names!"); if (NameStr == 0) return false; std::string Name(NameStr); // Copy string @@ -685,12 +634,13 @@ if (T == Type::VoidTy) ThrowException("Can't assign name '" + Name + "' to the void type!"); - SymbolTable &ST = inFunctionScope() ? - CurFun.CurrentFunction->getSymbolTable() : - CurModule.CurrentModule->getSymbolTable(); + // Set the type name, checking for conflicts as we do so. + bool AlreadyExists = CurModule.CurrentModule->addTypeName(Name, T); + + if (AlreadyExists) { // Inserting a name that is already defined??? + const Type *Existing = CurModule.CurrentModule->getTypeByName(Name); + assert(Existing && "Conflict but no matching type?"); - // Inserting a name that is already defined??? - if (Type *Existing = ST.lookupType(Name)) { // There is only one case where this is allowed: when we are refining an // opaque type. In this case, Existing will be an opaque type. if (const OpaqueType *OpTy = dyn_cast(Existing)) { @@ -710,9 +660,6 @@ T->getDescription() + "' type plane!"); } - // Okay, its a newly named type. Set its name. - if (!Name.empty()) ST.insert(Name, T); - return false; } @@ -1292,16 +1239,19 @@ $2.destroy(); } else { std::string Name; + if ($2.Type == ValID::NameVal) Name = $2.Name; - /// FIXME: We shouldn't be creating global vars as forward refs for - /// functions at all here! - if (!isa(PT->getElementType())) - if ($2.Type == ValID::NameVal) Name = $2.Name; - - // Create a placeholder for the global variable reference... - GlobalVariable *GV = new GlobalVariable(PT->getElementType(), false, - GlobalValue::ExternalLinkage,0, - Name, CurModule.CurrentModule); + // Create the forward referenced global. + GlobalValue *GV; + if (const FunctionType *FTy = + dyn_cast(PT->getElementType())) { + GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, + CurModule.CurrentModule); + } else { + GV = new GlobalVariable(PT->getElementType(), false, + GlobalValue::ExternalLinkage, 0, + Name, CurModule.CurrentModule); + } // Keep track of the fact that we have a forward ref to recycle it CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV)); @@ -1551,6 +1501,7 @@ FunctionHeaderH : TypesV Name '(' ArgList ')' { UnEscapeLexed($2); std::string FunctionName($2); + free($2); // Free strdup'd memory! if (!(*$1)->isFirstClassType() && *$1 != Type::VoidTy) ThrowException("LLVM functions cannot return aggregate types!"); @@ -1569,25 +1520,39 @@ const PointerType *PFT = PointerType::get(FT); delete $1; + ValID ID; + if (!FunctionName.empty()) { + ID = ValID::create((char*)FunctionName.c_str()); + } else { + ID = ValID::create((int)CurModule.Values[PFT].size()); + } + Function *Fn = 0; - // Is the function already in symtab? - if ((Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { - // Yes it is. If this is the case, either we need to be a forward decl, - // or it needs to be. + // See if this function was forward referenced. If so, recycle the object. + if (GlobalValue *FWRef = CurModule.GetForwardRefForGlobal(PFT, ID)) { + // Move the function to the end of the list, from whereever it was + // previously inserted. + Fn = cast(FWRef); + CurModule.CurrentModule->getFunctionList().remove(Fn); + CurModule.CurrentModule->getFunctionList().push_back(Fn); + } else if (!FunctionName.empty() && // Merge with an earlier prototype? + (Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) { + // If this is the case, either we need to be a forward decl, or it needs + // to be. if (!CurFun.isDeclare && !Fn->isExternal()) ThrowException("Redefinition of function '" + FunctionName + "'!"); - // Make sure to strip off any argument names so we can't get conflicts... - for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); AI != AE; ++AI) - AI->setName(""); + // Make sure to strip off any argument names so we can't get conflicts. + if (Fn->isExternal()) + for (Function::aiterator AI = Fn->abegin(), AE = Fn->aend(); + AI != AE; ++AI) + AI->setName(""); } else { // Not already defined? Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName, CurModule.CurrentModule); InsertValue(Fn, CurModule.Values); - CurModule.DeclareNewGlobalValue(Fn, ValID::create($2)); } - free($2); // Free strdup'd memory! CurFun.FunctionStart(Fn); From lattner at cs.uiuc.edu Wed Jul 14 18:07:23 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 18:07:23 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407142307.SAA00993@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.188 -> 1.189 --- Log message: This is logically part of the last patch. Just more really horrible code that is made unnecessary by it. --- Diffs of the changes: (+0 -17) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.188 llvm/lib/AsmParser/llvmAsmParser.y:1.189 --- llvm/lib/AsmParser/llvmAsmParser.y:1.188 Wed Jul 14 18:03:46 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Wed Jul 14 18:07:13 2004 @@ -164,23 +164,6 @@ // Resolve all forward references now. ResolveDefinitions(LateResolveValues, &CurModule.LateResolveValues); - // Make sure to resolve any constant expr references that might exist within - // the function we just declared itself. - ValID FID; - if (CurrentFunction->hasName()) { - FID = ValID::create((char*)CurrentFunction->getName().c_str()); - } else { - // Figure out which slot number if is... - ValueList &List = CurModule.Values[CurrentFunction->getType()]; - for (unsigned i = 0; ; ++i) { - assert(i < List.size() && "Function not found!"); - if (List[i] == CurrentFunction) { - FID = ValID::create((int)i); - break; - } - } - } - Values.clear(); // Clear out function local definitions Types.clear(); // Clear out function local types CurrentFunction = 0; From lattner at cs.uiuc.edu Wed Jul 14 18:12:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 18:12:20 -0500 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/2003-03-03-DuplicateConstant.ll Message-ID: <200407142312.SAA01261@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: 2003-03-03-DuplicateConstant.ll (r1.1) removed --- Log message: this "feature" is gone --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Wed Jul 14 18:14:17 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 18:14:17 -0500 Subject: [llvm-commits] CVS: llvm/test/Feature/forwardreftest.ll Message-ID: <200407142314.SAA01398@apoc.cs.uiuc.edu> Changes in directory llvm/test/Feature: forwardreftest.ll updated: 1.5 -> 1.6 --- Log message: You cannot pass functions by value, what does that even mean?? --- Diffs of the changes: (+2 -2) Index: llvm/test/Feature/forwardreftest.ll diff -u llvm/test/Feature/forwardreftest.ll:1.5 llvm/test/Feature/forwardreftest.ll:1.6 --- llvm/test/Feature/forwardreftest.ll:1.5 Sun Oct 6 17:43:49 2002 +++ llvm/test/Feature/forwardreftest.ll Wed Jul 14 18:14:07 2004 @@ -1,8 +1,8 @@ %myty = type int %myfn = type float (int,double,uint,short) - type int(%myfn) + type int(%myfn*) type int(int) - type int(int(int)) + type int(int(int)*) %thisfuncty = type int (int) * implementation From lattner at cs.uiuc.edu Wed Jul 14 18:23:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 18:23:45 -0500 Subject: [llvm-commits] CVS: llvm-www/CurrentWork.html Message-ID: <200407142323.SAA01579@apoc.cs.uiuc.edu> Changes in directory llvm-www: CurrentWork.html updated: 1.3 -> 1.4 --- Log message: Mention new stuff being worked on --- Diffs of the changes: (+6 -0) Index: llvm-www/CurrentWork.html diff -u llvm-www/CurrentWork.html:1.3 llvm-www/CurrentWork.html:1.4 --- llvm-www/CurrentWork.html:1.3 Wed Jun 2 01:47:00 2004 +++ llvm-www/CurrentWork.html Wed Jul 14 18:23:35 2004 @@ -14,6 +14,12 @@ mailing list or filing an enhancment request bug in bugzilla.

      +

      +In addition to continuing work on the LLVM core, a new Java and MSIL front-end +are both being developed, a new PowerPC backend is in the works, as well as a +lot of other miscellaneous projects. +

      +
      Near-term LLVM Research
      The LLVM infrastructure underlies many ongoing From lattner at cs.uiuc.edu Wed Jul 14 19:59:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 19:59:03 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Message-ID: <200407150059.TAA02755@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.269 -> 1.270 --- Log message: Improve codegen for the LLVM offsetof/sizeof "operator". Before we compiled this LLVM function: int %foo() { ret int cast (int** getelementptr (int** null, int 1) to int) } into: foo: mov %EAX, 0 lea %EAX, DWORD PTR [%EAX + 4] ret now we compile it into: foo: mov %EAX, 4 ret This sequence is frequently generated by the MSIL front-end, and soon the malloc lowering pass and Java front-ends as well.. -Chris --- Diffs of the changes: (+15 -0) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.269 llvm/lib/Target/X86/InstSelectSimple.cpp:1.270 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.269 Mon Jun 28 19:14:38 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jul 14 19:58:53 2004 @@ -3663,6 +3663,21 @@ if (ConstantPointerRef *CPR = dyn_cast(Src)) Src = CPR->getValue(); + // If this is a getelementptr null, with all constant integer indices, just + // replace it with TargetReg = 42. + if (isa(Src)) { + User::op_iterator I = IdxBegin; + for (; I != IdxEnd; ++I) + if (!isa(*I)) + break; + if (I == IdxEnd) { // All constant indices + unsigned Offset = TD.getIndexedOffset(Src->getType(), + std::vector(IdxBegin, IdxEnd)); + BuildMI(*MBB, IP, X86::MOV32ri, 1, TargetReg).addImm(Offset); + return; + } + } + std::vector GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); GEPOps[0] = Src; From lattner at cs.uiuc.edu Wed Jul 14 20:08:19 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 20:08:19 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerAllocations.cpp Message-ID: <200407150108.UAA03288@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerAllocations.cpp updated: 1.46 -> 1.47 --- Log message: Now that we codegen the portable "sizeof" efficiently, we can use it for malloc lowering. This means that lowerallocations doesn't need targetdata anymore. yaay. --- Diffs of the changes: (+22 -18) Index: llvm/lib/Transforms/Scalar/LowerAllocations.cpp diff -u llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.46 llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.47 --- llvm/lib/Transforms/Scalar/LowerAllocations.cpp:1.46 Tue Mar 2 19:40:53 2004 +++ llvm/lib/Transforms/Scalar/LowerAllocations.cpp Wed Jul 14 20:08:08 2004 @@ -19,7 +19,6 @@ #include "llvm/iOther.h" #include "llvm/Constants.h" #include "llvm/Pass.h" -#include "llvm/Target/TargetData.h" #include "Support/Statistic.h" using namespace llvm; @@ -35,10 +34,6 @@ public: LowerAllocations() : MallocFunc(0), FreeFunc(0) {} - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); - } - /// doPassInitialization - For the lower allocations pass, this ensures that /// a module contains a declaration for a malloc and a free function. /// @@ -78,6 +73,14 @@ return true; } +static Constant *getSizeof(const Type *Ty) { + Constant *Ret = ConstantPointerNull::get(PointerType::get(Ty)); + std::vector Idx; + Idx.push_back(ConstantUInt::get(Type::UIntTy, 1)); + Ret = ConstantExpr::getGetElementPtr(Ret, Idx); + return ConstantExpr::getCast(Ret, Type::UIntTy); +} + // runOnBasicBlock - This method does the actual work of converting // instructions over, assuming that the pass has already been initialized. // @@ -86,25 +89,26 @@ assert(MallocFunc && FreeFunc && "Pass not initialized!"); BasicBlock::InstListType &BBIL = BB.getInstList(); - TargetData &DataLayout = getAnalysis(); // Loop over all of the instructions, looking for malloc or free instructions for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) { if (MallocInst *MI = dyn_cast(I)) { const Type *AllocTy = MI->getType()->getElementType(); - // Get the number of bytes to be allocated for one element of the - // requested type... - unsigned Size = DataLayout.getTypeSize(AllocTy); - - // malloc(type) becomes sbyte *malloc(constint) - Value *MallocArg = ConstantUInt::get(Type::UIntTy, Size); - if (MI->getNumOperands() && Size == 1) { - MallocArg = MI->getOperand(0); // Operand * 1 = Operand - } else if (MI->isArrayAllocation()) { - // Multiply it by the array size if necessary... - MallocArg = BinaryOperator::create(Instruction::Mul, MI->getOperand(0), - MallocArg, "", I); + // malloc(type) becomes sbyte *malloc(size) + Value *MallocArg = getSizeof(AllocTy); + if (MI->isArrayAllocation()) { + if (isa(MallocArg) && + cast(MallocArg)->getValue() == 1) { + MallocArg = MI->getOperand(0); // Operand * 1 = Operand + } else if (Constant *CO = dyn_cast(MI->getOperand(0))) { + MallocArg = ConstantExpr::getMul(CO, cast(MallocArg)); + } else { + // Multiply it by the array size if necessary... + MallocArg = BinaryOperator::create(Instruction::Mul, + MI->getOperand(0), + MallocArg, "", I); + } } const FunctionType *MallocFTy = MallocFunc->getFunctionType(); From lattner at cs.uiuc.edu Wed Jul 14 20:16:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 20:16:03 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407150116.UAA05498@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.54 -> 1.55 --- Log message: Yeah, how about those 'primative' types huh? --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.54 llvm/include/llvm/Type.h:1.55 --- llvm/include/llvm/Type.h:1.54 Wed Jul 14 15:10:26 2004 +++ llvm/include/llvm/Type.h Wed Jul 14 20:15:53 2004 @@ -201,7 +201,7 @@ isSizedDerivedType(); } - /// getPrimitiveSize - Return the basic size of this type if it is a primative + /// getPrimitiveSize - Return the basic size of this type if it is a primitive /// type. These are fixed by LLVM and are not target dependent. This will /// return zero if the type does not have a size or is not a primitive type. /// From lattner at cs.uiuc.edu Wed Jul 14 20:17:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 20:17:09 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200407150117.UAA05507@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.60 -> 1.61 --- Log message: Implement folding of expressions like 'uint cast (int* getelementptr (int* null, uint 1) to uint)' to a constant integer. We can only do this with primitive LLVM types, because other types have target-specific sizes. --- Diffs of the changes: (+12 -0) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.60 llvm/lib/VMCore/ConstantFolding.cpp:1.61 --- llvm/lib/VMCore/ConstantFolding.cpp:1.60 Tue Jul 6 23:45:13 2004 +++ llvm/lib/VMCore/ConstantFolding.cpp Wed Jul 14 20:16:59 2004 @@ -971,6 +971,18 @@ assert(Ty != 0 && "Invalid indices for GEP!"); return ConstantPointerNull::get(PointerType::get(Ty)); } + + if (IdxList.size() == 1) { + const Type *ElTy = cast(C->getType())->getElementType(); + if (unsigned ElSize = ElTy->getPrimitiveSize()) { + // gep null, C is equal to C*sizeof(nullty). If nullty is a known llvm + // type, we can statically fold this. + Constant *R = ConstantUInt::get(Type::UIntTy, ElSize); + R = ConstantExpr::getCast(R, IdxList[0]->getType()); + R = ConstantExpr::getMul(R, IdxList[0]); + return ConstantExpr::getCast(R, C->getType()); + } + } } if (ConstantExpr *CE = dyn_cast(const_cast(C))) { From lattner at cs.uiuc.edu Wed Jul 14 20:29:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 20:29:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp LeakDetector.cpp Message-ID: <200407150129.UAA07256@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: ConstantRange.cpp updated: 1.12 -> 1.13 LeakDetector.cpp updated: 1.9 -> 1.10 --- Log message: Bug fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+19 -5) Index: llvm/lib/Support/ConstantRange.cpp diff -u llvm/lib/Support/ConstantRange.cpp:1.12 llvm/lib/Support/ConstantRange.cpp:1.13 --- llvm/lib/Support/ConstantRange.cpp:1.12 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Support/ConstantRange.cpp Wed Jul 14 20:29:12 2004 @@ -322,7 +322,7 @@ /// print - Print out the bounds to a stream... /// void ConstantRange::print(std::ostream &OS) const { - OS << "[" << Lower << "," << Upper << " )"; + OS << "[" << *Lower << "," << *Upper << " )"; } /// dump - Allow printing from a debugger easily... Index: llvm/lib/Support/LeakDetector.cpp diff -u llvm/lib/Support/LeakDetector.cpp:1.9 llvm/lib/Support/LeakDetector.cpp:1.10 --- llvm/lib/Support/LeakDetector.cpp:1.9 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Support/LeakDetector.cpp Wed Jul 14 20:29:12 2004 @@ -18,6 +18,16 @@ using namespace llvm; namespace { + template + struct PrinterTrait { + static void print(const T* P) { std::cerr << P; } + }; + + template<> + struct PrinterTrait { + static void print(const Value* P) { std::cerr << *P; } + }; + template struct LeakDetectorImpl { LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } @@ -39,7 +49,7 @@ if (o == Cache) Cache = 0; // Cache hit else - Ts.erase(o); + Ts.erase(o); } bool hasGarbage(const std::string& Message) { @@ -49,9 +59,13 @@ if (!Ts.empty()) { std::cerr - << "Leaked " << Name << " objects found: " << Message << ":\n\t"; - std::copy(Ts.begin(), Ts.end(), - std::ostream_iterator(std::cerr, " ")); + << "Leaked " << Name << " objects found: " << Message << ":\n"; + for (typename std::set::iterator I = Ts.begin(), + E = Ts.end(); I != E; ++I) { + std::cerr << "\t"; + PrinterTrait::print(*I); + std::cerr << "\n"; + } std::cerr << '\n'; // Clear out results so we don't get duplicate warnings on From lattner at cs.uiuc.edu Wed Jul 14 20:50:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 20:50:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/ADCE.cpp CorrelatedExprs.cpp PRE.cpp Reassociate.cpp SCCP.cpp ScalarReplAggregates.cpp Message-ID: <200407150150.UAA25541@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: ADCE.cpp updated: 1.77 -> 1.78 CorrelatedExprs.cpp updated: 1.21 -> 1.22 PRE.cpp updated: 1.8 -> 1.9 Reassociate.cpp updated: 1.31 -> 1.32 SCCP.cpp updated: 1.94 -> 1.95 ScalarReplAggregates.cpp updated: 1.22 -> 1.23 --- Log message: Fixes working towards PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+23 -22) Index: llvm/lib/Transforms/Scalar/ADCE.cpp diff -u llvm/lib/Transforms/Scalar/ADCE.cpp:1.77 llvm/lib/Transforms/Scalar/ADCE.cpp:1.78 --- llvm/lib/Transforms/Scalar/ADCE.cpp:1.77 Tue May 4 12:00:46 2004 +++ llvm/lib/Transforms/Scalar/ADCE.cpp Wed Jul 14 20:50:47 2004 @@ -92,13 +92,13 @@ inline void markInstructionLive(Instruction *I) { if (LiveSet.count(I)) return; - DEBUG(std::cerr << "Insn Live: " << I); + DEBUG(std::cerr << "Insn Live: " << *I); LiveSet.insert(I); WorkList.push_back(I); } inline void markTerminatorLive(const BasicBlock *BB) { - DEBUG(std::cerr << "Terminator Live: " << BB->getTerminator()); + DEBUG(std::cerr << "Terminator Live: " << *BB->getTerminator()); markInstructionLive(const_cast(BB->getTerminator())); } }; Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.21 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.22 --- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.21 Mon Jan 12 13:12:50 2004 +++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Wed Jul 14 20:50:47 2004 @@ -1011,7 +1011,7 @@ Relation::KnownResult Result = getSetCCResult(SCI, RI); if (Result != Relation::Unknown) { DEBUG(std::cerr << "Replacing setcc with " << Result - << " constant: " << SCI); + << " constant: " << *SCI); SCI->replaceAllUsesWith(ConstantBool::get((bool)Result)); // The instruction is now dead, remove it from the program. @@ -1038,8 +1038,8 @@ if (Value *Repl = VI->getReplacement()) { // If we know if a replacement with lower rank than Op0, make the // replacement now. - DEBUG(std::cerr << "In Inst: " << I << " Replacing operand #" << i - << " with " << Repl << "\n"); + DEBUG(std::cerr << "In Inst: " << *I << " Replacing operand #" << i + << " with " << *Repl << "\n"); I->setOperand(i, Repl); Changed = true; ++NumOperandsCann; @@ -1067,7 +1067,7 @@ if (isa(Op1)) { if (Constant *Result = ConstantFoldInstruction(SCI)) { // Wow, this is easy, directly eliminate the SetCondInst. - DEBUG(std::cerr << "Replacing setcc with constant fold: " << SCI); + DEBUG(std::cerr << "Replacing setcc with constant fold: " << *SCI); return cast(Result)->getValue() ? Relation::KnownTrue : Relation::KnownFalse; } Index: llvm/lib/Transforms/Scalar/PRE.cpp diff -u llvm/lib/Transforms/Scalar/PRE.cpp:1.8 llvm/lib/Transforms/Scalar/PRE.cpp:1.9 --- llvm/lib/Transforms/Scalar/PRE.cpp:1.8 Fri Jan 9 00:02:20 2004 +++ llvm/lib/Transforms/Scalar/PRE.cpp Wed Jul 14 20:50:47 2004 @@ -390,7 +390,7 @@ return Changed; } #endif - DEBUG(std::cerr << "\n====--- Expression: " << Expr); + DEBUG(std::cerr << "\n====--- Expression: " << *Expr); const Type *ExprType = Expr->getType(); // AnticipatibleBlocks - Blocks where the current expression is anticipatible. @@ -425,7 +425,7 @@ BasicBlock *BB = Occurrence->getParent(); Definitions.erase(Definitions.begin()); - DEBUG(std::cerr << "PROCESSING Occurrence: " << Occurrence); + DEBUG(std::cerr << "PROCESSING Occurrence: " << *Occurrence); // Check to see if there is already an incoming value for this block... AvailableBlocksTy::iterator LBI = AvailableBlocks.find(BB); @@ -433,7 +433,7 @@ // Yes, there is a dominating definition for this block. Replace this // occurrence with the incoming value. if (LBI->second != Occurrence) { - DEBUG(std::cerr << " replacing with: " << LBI->second); + DEBUG(std::cerr << " replacing with: " << *LBI->second); Occurrence->replaceAllUsesWith(LBI->second); BB->getInstList().erase(Occurrence); // Delete instruction ++NumRedundant; @@ -489,7 +489,7 @@ DFBlock->begin()); ProcessedExpressions.insert(PN); - DEBUG(std::cerr << " INSERTING PHI on frontier: " << PN); + DEBUG(std::cerr << " INSERTING PHI on frontier: " << *PN); // Add the incoming blocks for the PHI node for (pred_iterator PI = pred_begin(DFBlock), @@ -501,7 +501,8 @@ Instruction *&BlockOcc = Definitions[DFBlockID]; if (BlockOcc) { - DEBUG(std::cerr <<" PHI superceeds occurrence: "<replaceAllUsesWith(PN); BlockOcc->getParent()->getInstList().erase(BlockOcc); ++NumRedundant; @@ -528,7 +529,7 @@ // PHINode *PN = new PHINode(ExprType, Expr->getName()+".PRE", AFBlock->begin()); - DEBUG(std::cerr << "INSERTING PHI for PR: " << PN); + DEBUG(std::cerr << "INSERTING PHI for PR: " << *PN); // If there is a pending occurrence in this block, make sure to replace it // with the PHI node... @@ -538,7 +539,7 @@ // There is already an occurrence in this block. Replace it with PN and // remove it. Instruction *OldOcc = EDFI->second; - DEBUG(std::cerr << " Replaces occurrence: " << OldOcc); + DEBUG(std::cerr << " Replaces occurrence: " << *OldOcc); OldOcc->replaceAllUsesWith(PN); AFBlock->getInstList().erase(OldOcc); Definitions.erase(EDFI); @@ -567,7 +568,7 @@ New->setName(NonPHIOccurrence->getName() + ".PRE-inserted"); ProcessedExpressions.insert(New); - DEBUG(std::cerr << " INSERTING OCCURRRENCE: " << New); + DEBUG(std::cerr << " INSERTING OCCURRRENCE: " << *New); // Insert it into the bottom of the predecessor, right before the // terminator instruction... Index: llvm/lib/Transforms/Scalar/Reassociate.cpp diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.31 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.32 --- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.31 Thu Jul 1 14:27:10 2004 +++ llvm/lib/Transforms/Scalar/Reassociate.cpp Wed Jul 14 20:50:47 2004 @@ -127,7 +127,7 @@ std::swap(LHSRank, RHSRank); Changed = true; ++NumSwapped; - DEBUG(std::cerr << "Transposed: " << I + DEBUG(std::cerr << "Transposed: " << *I /* << " Result BB: " << I->getParent()*/); } @@ -156,7 +156,7 @@ I->getParent()->getInstList().insert(I, LHSI); ++NumChanged; - DEBUG(std::cerr << "Reassociated: " << I/* << " Result BB: " + DEBUG(std::cerr << "Reassociated: " << *I/* << " Result BB: " << I->getParent()*/); // Since we modified the RHS instruction, make sure that we recheck it. @@ -235,7 +235,7 @@ New->setOperand(1, NegateValue(New->getOperand(1), BI)); Changed = true; - DEBUG(std::cerr << "Negated: " << New /*<< " Result BB: " << BB*/); + DEBUG(std::cerr << "Negated: " << *New /*<< " Result BB: " << BB*/); } // If this instruction is a commutative binary operator, and the ranks of @@ -265,7 +265,7 @@ I = Tmp; ++NumLinear; Changed = true; - DEBUG(std::cerr << "Linearized: " << I/* << " Result BB: " << BB*/); + DEBUG(std::cerr << "Linearized: " << *I/* << " Result BB: " << BB*/); } // Make sure that this expression is correctly reassociated with respect Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.94 llvm/lib/Transforms/Scalar/SCCP.cpp:1.95 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.94 Tue Apr 13 14:43:54 2004 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Wed Jul 14 20:50:47 2004 @@ -289,7 +289,7 @@ Instruction *I = InstWorkList.back(); InstWorkList.pop_back(); - DEBUG(std::cerr << "\nPopped off I-WL: " << I); + DEBUG(std::cerr << "\nPopped off I-WL: " << *I); // "I" got into the work list because it either made the transition from // bottom to constant, or to Overdefined. @@ -305,7 +305,7 @@ BasicBlock *BB = BBWorkList.back(); BBWorkList.pop_back(); - DEBUG(std::cerr << "\nPopped off BBWL: " << BB); + DEBUG(std::cerr << "\nPopped off BBWL: " << *BB); // Notify all instructions in this basic block that they are newly // executable. @@ -329,7 +329,7 @@ InstVal &IV = ValueState[&Inst]; if (IV.isConstant()) { Constant *Const = IV.getConstant(); - DEBUG(std::cerr << "Constant: " << Const << " = " << Inst); + DEBUG(std::cerr << "Constant: " << *Const << " = " << Inst); // Replaces all of the uses of a variable with uses of the constant. Inst.replaceAllUsesWith(Const); Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.22 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.23 --- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.22 Fri Jun 18 21:02:22 2004 +++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Wed Jul 14 20:50:47 2004 @@ -294,7 +294,7 @@ I != E; ++I) if (!isSafeUseOfAllocation(cast(*I))) { DEBUG(std::cerr << "Cannot transform: " << *AI << " due to user: " - << *I); + << **I); return false; } return true; From lattner at cs.uiuc.edu Wed Jul 14 21:06:16 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:06:16 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/ExprTypeConvert.cpp LevelRaise.cpp Message-ID: <200407150206.VAA30743@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: ExprTypeConvert.cpp updated: 1.93 -> 1.94 LevelRaise.cpp updated: 1.97 -> 1.98 --- Log message: Progress on PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+27 -26) Index: llvm/lib/Transforms/ExprTypeConvert.cpp diff -u llvm/lib/Transforms/ExprTypeConvert.cpp:1.93 llvm/lib/Transforms/ExprTypeConvert.cpp:1.94 --- llvm/lib/Transforms/ExprTypeConvert.cpp:1.93 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/ExprTypeConvert.cpp Wed Jul 14 21:06:06 2004 @@ -348,7 +348,7 @@ return VMCI->second; } - DEBUG(std::cerr << "CETT: " << (void*)V << " " << V); + DEBUG(std::cerr << "CETT: " << (void*)V << " " << *V); Instruction *I = dyn_cast(V); if (I == 0) { @@ -553,8 +553,8 @@ if (NumUses == OldSize) ++It; } - DEBUG(std::cerr << "ExpIn: " << (void*)I << " " << I - << "ExpOut: " << (void*)Res << " " << Res); + DEBUG(std::cerr << "ExpIn: " << (void*)I << " " << *I + << "ExpOut: " << (void*)Res << " " << *Res); return Res; } @@ -1232,9 +1232,9 @@ assert(It != BB->end() && "Instruction not in own basic block??"); BB->getInstList().insert(It, Res); // Keep It pointing to old instruction - DEBUG(std::cerr << "COT CREATED: " << (void*)Res << " " << Res - << "In: " << (void*)I << " " << I << "Out: " << (void*)Res - << " " << Res); + DEBUG(std::cerr << "COT CREATED: " << (void*)Res << " " << *Res + << "In: " << (void*)I << " " << *I << "Out: " << (void*)Res + << " " << *Res); // Add the instruction to the expression map VMC.ExprMap[I] = Res; Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.97 llvm/lib/Transforms/LevelRaise.cpp:1.98 --- llvm/lib/Transforms/LevelRaise.cpp:1.97 Thu Jul 1 14:26:38 2004 +++ llvm/lib/Transforms/LevelRaise.cpp Wed Jul 14 21:06:06 2004 @@ -137,7 +137,7 @@ // Cannot handle subtracts if there is more than one index required... if (HasSubUse && Indices.size() != 1) return false; - PRINT_PEEPHOLE2("cast-add-to-gep:in", Src, CI); + PRINT_PEEPHOLE2("cast-add-to-gep:in", *Src, CI); // If we have a getelementptr capability... transform all of the // add instruction uses into getelementptr's. @@ -151,7 +151,7 @@ Value *OtherPtr = I->getOperand((I->getOperand(0) == &CI) ? 1 : 0); Instruction *GEP = new GetElementPtrInst(OtherPtr, Indices, I->getName()); - PRINT_PEEPHOLE1("cast-add-to-gep:i", I); + PRINT_PEEPHOLE1("cast-add-to-gep:i", *I); // If the instruction is actually a subtract, we are guaranteed to only have // one index (from code above), so we just need to negate the pointer index @@ -173,14 +173,14 @@ // Insert the GEP instruction before the old add instruction... I->getParent()->getInstList().insert(I, GEP); - PRINT_PEEPHOLE1("cast-add-to-gep:o", GEP); + PRINT_PEEPHOLE1("cast-add-to-gep:o", *GEP); GEP = new CastInst(GEP, I->getType()); // Replace the old add instruction with the shiny new GEP inst ReplaceInstWithInst(I, GEP); } - PRINT_PEEPHOLE1("cast-add-to-gep:o", GEP); + PRINT_PEEPHOLE1("cast-add-to-gep:o", *GEP); } return true; } @@ -220,9 +220,9 @@ return false; // Not convertible... perhaps next time if (getPointedToComposite(AddOp1->getType())) { // case 1 - PRINT_PEEPHOLE2("add-to-gep1:in", AddOp2, *BI); + PRINT_PEEPHOLE2("add-to-gep1:in", *AddOp2, *BI); } else { - PRINT_PEEPHOLE3("add-to-gep2:in", AddOp1, AddOp2, *BI); + PRINT_PEEPHOLE3("add-to-gep2:in", *AddOp1, *AddOp2, *BI); } GetElementPtrInst *GEP = new GetElementPtrInst(SrcPtr, Indices, @@ -230,7 +230,7 @@ Instruction *NCI = new CastInst(GEP, AddOp1->getType()); ReplaceInstWithInst(BB->getInstList(), BI, NCI); - PRINT_PEEPHOLE2("add-to-gep:out", GEP, NCI); + PRINT_PEEPHOLE2("add-to-gep:out", *GEP, *NCI); return true; } @@ -249,7 +249,7 @@ // Into: // if (DestTy == Src->getType()) { // Check for a cast to same type as src!! - PRINT_PEEPHOLE1("cast-of-self-ty", CI); + PRINT_PEEPHOLE1("cast-of-self-ty", *CI); CI->replaceAllUsesWith(Src); if (!Src->hasName() && CI->hasName()) { std::string Name = CI->getName(); @@ -276,7 +276,7 @@ // ConvertedTypes[CI] = CI->getType(); // Make sure the cast doesn't change if (ExpressionConvertibleToType(Src, DestTy, ConvertedTypes, TD)) { - PRINT_PEEPHOLE3("CAST-SRC-EXPR-CONV:in ", Src, CI, BB->getParent()); + PRINT_PEEPHOLE3("CAST-SRC-EXPR-CONV:in ", *Src, *CI, *BB->getParent()); DEBUG(std::cerr << "\nCONVERTING SRC EXPR TYPE:\n"); { // ValueMap must be destroyed before function verified! @@ -286,9 +286,9 @@ if (Constant *CPV = dyn_cast(E)) CI->replaceAllUsesWith(CPV); - PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", E); + PRINT_PEEPHOLE1("CAST-SRC-EXPR-CONV:out", *E); DEBUG(std::cerr << "DONE CONVERTING SRC EXPR TYPE: \n" - << BB->getParent()); + << *BB->getParent()); } BI = BB->begin(); // Rescan basic block. BI might be invalidated. @@ -303,7 +303,7 @@ // Make sure the source doesn't change type ConvertedTypes[Src] = Src->getType(); if (ValueConvertibleToType(CI, Src->getType(), ConvertedTypes, TD)) { - PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", Src, CI, BB->getParent()); + PRINT_PEEPHOLE3("CAST-DEST-EXPR-CONV:in ", *Src, *CI, *BB->getParent()); DEBUG(std::cerr << "\nCONVERTING EXPR TYPE:\n"); { // ValueMap must be destroyed before function verified! @@ -311,8 +311,9 @@ ConvertValueToNewType(CI, Src, ValueMap, TD); // This will delete CI! } - PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", Src); - DEBUG(std::cerr << "DONE CONVERTING EXPR TYPE: \n\n" << BB->getParent()); + PRINT_PEEPHOLE1("CAST-DEST-EXPR-CONV:out", *Src); + DEBUG(std::cerr << "DONE CONVERTING EXPR TYPE: \n\n" << + *BB->getParent()); BI = BB->begin(); // Rescan basic block. BI might be invalidated. ++NumExprTreesConv; @@ -398,7 +399,7 @@ // Did we find what we were looking for? If so, do the transformation if (ElTy) { - PRINT_PEEPHOLE1("cast-for-first:in", CI); + PRINT_PEEPHOLE1("cast-for-first:in", *CI); std::string Name = CI->getName(); CI->setName(""); @@ -411,7 +412,7 @@ // CI->setOperand(0, GEP); - PRINT_PEEPHOLE2("cast-for-first:out", GEP, CI); + PRINT_PEEPHOLE2("cast-for-first:out", *GEP, *CI); ++NumGEPInstFormed; return true; } @@ -440,7 +441,7 @@ if (const PointerType *CSPT = dyn_cast(CastSrc->getType())) // convertible types? if (Val->getType()->isLosslesslyConvertibleTo(CSPT->getElementType())) { - PRINT_PEEPHOLE3("st-src-cast:in ", Pointer, Val, SI); + PRINT_PEEPHOLE3("st-src-cast:in ", *Pointer, *Val, *SI); // Insert the new T cast instruction... stealing old T's name std::string Name(CI->getName()); CI->setName(""); @@ -450,7 +451,7 @@ // Replace the old store with a new one! ReplaceInstWithInst(BB->getInstList(), BI, SI = new StoreInst(NCI, CastSrc)); - PRINT_PEEPHOLE3("st-src-cast:out", NCI, CastSrc, SI); + PRINT_PEEPHOLE3("st-src-cast:out", *NCI, *CastSrc, *SI); ++NumLoadStorePeepholes; return true; } @@ -478,7 +479,7 @@ if (const PointerType *CSPT = dyn_cast(CastSrc->getType())) // convertible types? if (PtrElType->isLosslesslyConvertibleTo(CSPT->getElementType())) { - PRINT_PEEPHOLE2("load-src-cast:in ", Pointer, LI); + PRINT_PEEPHOLE2("load-src-cast:in ", *Pointer, *LI); // Create the new load instruction... loading the pre-casted value LoadInst *NewLI = new LoadInst(CastSrc, LI->getName(), BI); @@ -488,7 +489,7 @@ // Replace the old store with a new one! ReplaceInstWithInst(BB->getInstList(), BI, NCI); - PRINT_PEEPHOLE3("load-src-cast:out", NCI, CastSrc, NewLI); + PRINT_PEEPHOLE3("load-src-cast:out", *NCI, *CastSrc, *NewLI); ++NumLoadStorePeepholes; return true; } From lattner at cs.uiuc.edu Wed Jul 14 21:06:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:06:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/CodeExtractor.cpp SimplifyCFG.cpp ValueMapper.cpp Message-ID: <200407150206.VAA30754@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: CodeExtractor.cpp updated: 1.25 -> 1.26 SimplifyCFG.cpp updated: 1.45 -> 1.46 ValueMapper.cpp updated: 1.13 -> 1.14 --- Log message: Progress on PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+9 -9) Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp diff -u llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.25 llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.26 --- llvm/lib/Transforms/Utils/CodeExtractor.cpp:1.25 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Utils/CodeExtractor.cpp Wed Jul 14 21:06:11 2004 @@ -262,23 +262,23 @@ for (Values::const_iterator i = inputs.begin(), e = inputs.end(); i != e; ++i) { const Value *value = *i; - DEBUG(std::cerr << "value used in func: " << value << "\n"); + DEBUG(std::cerr << "value used in func: " << *value << "\n"); paramTy.push_back(value->getType()); } // Add the types of the output values to the function's argument list. for (Values::const_iterator I = outputs.begin(), E = outputs.end(); I != E; ++I) { - DEBUG(std::cerr << "instr used in func: " << *I << "\n"); + DEBUG(std::cerr << "instr used in func: " << **I << "\n"); if (AggregateArgs) paramTy.push_back((*I)->getType()); else paramTy.push_back(PointerType::get((*I)->getType())); } - DEBUG(std::cerr << "Function type: " << RetTy << " f("); + DEBUG(std::cerr << "Function type: " << *RetTy << " f("); DEBUG(for (std::vector::iterator i = paramTy.begin(), - e = paramTy.end(); i != e; ++i) std::cerr << *i << ", "); + e = paramTy.end(); i != e; ++i) std::cerr << **i << ", "); DEBUG(std::cerr << ")\n"); if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.45 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.46 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.45 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Wed Jul 14 21:06:12 2004 @@ -567,7 +567,7 @@ // Remove basic blocks that have no predecessors... which are unreachable. if (pred_begin(BB) == pred_end(BB) || *pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB)) { - DEBUG(std::cerr << "Removing BB: \n" << BB); + DEBUG(std::cerr << "Removing BB: \n" << *BB); // Loop through all of our successors and make sure they know that one // of their predecessors is going away. @@ -615,7 +615,7 @@ // we cannot do this transformation! // if (!PropagatePredecessorsForPHIs(BB, Succ)) { - DEBUG(std::cerr << "Killing Trivial BB: \n" << BB); + DEBUG(std::cerr << "Killing Trivial BB: \n" << *BB); std::string OldName = BB->getName(); std::vector @@ -921,7 +921,7 @@ } if (OnlySucc) { - DEBUG(std::cerr << "Merging: " << BB << "into: " << OnlyPred); + DEBUG(std::cerr << "Merging: " << *BB << "into: " << *OnlyPred); TerminatorInst *Term = OnlyPred->getTerminator(); // Resolve any PHI nodes at the start of the block. They are all Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.13 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.14 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.13 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Wed Jul 14 21:06:12 2004 @@ -112,8 +112,8 @@ Value *V = MapValue(Op, ValueMap); #ifndef NDEBUG if (!V) { - std::cerr << "Val = \n" << Op << "Addr = " << (void*)Op; - std::cerr << "\nInst = " << I; + std::cerr << "Val = \n" << *Op << "Addr = " << (void*)Op; + std::cerr << "\nInst = " << *I; } #endif assert(V && "Referenced value not in value map!"); From lattner at cs.uiuc.edu Wed Jul 14 21:14:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:14:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp X86SimpInstrSelector.cpp Message-ID: <200407150214.VAA05159@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.270 -> 1.271 X86SimpInstrSelector.cpp updated: 1.5 -> 1.6 --- Log message: Patches towards fixing PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+4 -4) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.270 llvm/lib/Target/X86/InstSelectSimple.cpp:1.271 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.270 Wed Jul 14 19:58:53 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Wed Jul 14 21:14:23 2004 @@ -507,7 +507,7 @@ return; default: - std::cerr << "Offending expr: " << C << "\n"; + std::cerr << "Offending expr: " << *C << "\n"; assert(0 && "Constant expression not yet handled!\n"); } } @@ -557,7 +557,7 @@ } else if (ConstantPointerRef *CPR = dyn_cast(C)) { BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); } else { - std::cerr << "Offending constant: " << C << "\n"; + std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); } } Index: llvm/lib/Target/X86/X86SimpInstrSelector.cpp diff -u llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.5 llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.6 --- llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.5 Sun Jun 20 02:47:25 2004 +++ llvm/lib/Target/X86/X86SimpInstrSelector.cpp Wed Jul 14 21:14:24 2004 @@ -433,7 +433,7 @@ return; default: - std::cerr << "Offending expr: " << C << "\n"; + std::cerr << "Offending expr: " << *C << "\n"; assert(0 && "Constant expression not yet handled!\n"); } } @@ -483,7 +483,7 @@ } else if (ConstantPointerRef *CPR = dyn_cast(C)) { BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); } else { - std::cerr << "Offending constant: " << C << "\n"; + std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); } } From lattner at cs.uiuc.edu Wed Jul 14 21:14:39 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:14:39 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp Message-ID: <200407150214.VAA05330@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrForest.cpp updated: 1.54 -> 1.55 --- Log message: Patches towards fixing PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.54 llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.55 --- llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.54 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp Wed Jul 14 21:14:29 2004 @@ -124,21 +124,21 @@ VRegNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) std::cerr << " "; - std::cerr << "VReg " << getValue() << "\n"; + std::cerr << "VReg " << *getValue() << "\n"; } void ConstantNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) std::cerr << " "; - std::cerr << "Constant " << getValue() << "\n"; + std::cerr << "Constant " << *getValue() << "\n"; } void LabelNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) std::cerr << " "; - std::cerr << "Label " << getValue() << "\n"; + std::cerr << "Label " << *getValue() << "\n"; } //------------------------------------------------------------------------ From lattner at cs.uiuc.edu Wed Jul 14 21:14:39 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:14:39 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407150214.VAA05337@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.188 -> 1.189 --- Log message: Patches towards fixing PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+3 -3) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.188 llvm/lib/Target/CBackend/Writer.cpp:1.189 --- llvm/lib/Target/CBackend/Writer.cpp:1.188 Mon Jul 12 18:37:18 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Wed Jul 14 21:14:29 2004 @@ -273,7 +273,7 @@ case Type::FloatTyID: return Out << "float " << NameSoFar; case Type::DoubleTyID: return Out << "double " << NameSoFar; default : - std::cerr << "Unknown primitive type: " << Ty << "\n"; + std::cerr << "Unknown primitive type: " << *Ty << "\n"; abort(); } @@ -517,7 +517,7 @@ default: std::cerr << "CWriter Error: Unhandled constant expression: " - << CE << "\n"; + << *CE << "\n"; abort(); } } @@ -626,7 +626,7 @@ } // FALL THROUGH default: - std::cerr << "Unknown constant type: " << CPV << "\n"; + std::cerr << "Unknown constant type: " << *CPV << "\n"; abort(); } } From lattner at cs.uiuc.edu Wed Jul 14 21:26:59 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:26:59 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/IPModRef.cpp Message-ID: <200407150226.VAA10409@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: IPModRef.cpp updated: 1.23 -> 1.24 --- Log message: Fix for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+1 -1) Index: llvm/lib/Analysis/DataStructure/IPModRef.cpp diff -u llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.23 llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.24 --- llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.23 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/IPModRef.cpp Wed Jul 14 21:26:49 2004 @@ -333,7 +333,7 @@ CI = callSiteModRefInfo.begin(), CE = callSiteModRefInfo.end(); CI != CE; ++CI) { - O << " ----Mod/Ref information for call site\n" << CI->first; + O << " ----Mod/Ref information for call site\n" << *CI->first; O << " --Objects modified at call site:\n"; DPH.printValuesInBitVec(O, CI->second->getModSet()); From lattner at cs.uiuc.edu Wed Jul 14 21:31:52 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:31:52 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/Interval.cpp Message-ID: <200407150231.VAA13402@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: Interval.cpp updated: 1.15 -> 1.16 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+10 -7) Index: llvm/lib/Analysis/Interval.cpp diff -u llvm/lib/Analysis/Interval.cpp:1.15 llvm/lib/Analysis/Interval.cpp:1.16 --- llvm/lib/Analysis/Interval.cpp:1.15 Tue Nov 11 16:41:31 2003 +++ llvm/lib/Analysis/Interval.cpp Wed Jul 14 21:31:42 2004 @@ -41,14 +41,17 @@ << "Interval Contents:\n"; // Print out all of the basic blocks in the interval... - std::copy(Nodes.begin(), Nodes.end(), - std::ostream_iterator(o, "\n")); + for (std::vector::const_iterator I = Nodes.begin(), + E = Nodes.end(); I != E; ++I) + o << **I << "\n"; o << "Interval Predecessors:\n"; - std::copy(Predecessors.begin(), Predecessors.end(), - std::ostream_iterator(o, "\n")); - + for (std::vector::const_iterator I = Predecessors.begin(), + E = Predecessors.end(); I != E; ++I) + o << **I << "\n"; + o << "Interval Successors:\n"; - std::copy(Successors.begin(), Successors.end(), - std::ostream_iterator(o, "\n")); + for (std::vector::const_iterator I = Successors.begin(), + E = Successors.end(); I != E; ++I) + o << **I << "\n"; } From lattner at cs.uiuc.edu Wed Jul 14 21:31:56 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:31:56 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp FindUsedTypes.cpp Message-ID: <200407150231.VAA13535@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: FindUnsafePointerTypes.cpp updated: 1.24 -> 1.25 FindUsedTypes.cpp updated: 1.27 -> 1.28 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+6 -8) Index: llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.24 llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.25 --- llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp:1.24 Fri Jun 4 15:25:55 2004 +++ llvm/lib/Analysis/IPA/FindUnsafePointerTypes.cpp Wed Jul 14 21:31:46 2004 @@ -25,12 +25,11 @@ #include "llvm/Analysis/FindUnsafePointerTypes.h" #include "llvm/Assembly/CachedWriter.h" -#include "llvm/Type.h" +#include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" - -namespace llvm { +using namespace llvm; static RegisterAnalysis X("unsafepointertypes", "Find Unsafe Pointer Types"); @@ -72,7 +71,7 @@ if (PrintFailures) { CachedWriter CW(F->getParent(), std::cerr); std::cerr << "FindUnsafePointerTypes: Type '"; - CW << ITy; + CW << *ITy; std::cerr << "' marked unsafe in '" << F->getName() << "' by:\n"; CW << *I; } @@ -101,8 +100,7 @@ E = getUnsafeTypes().end(); I != E; ++I, ++Counter) { o << " #" << Counter << ". "; - CW << (Type*)*I << "\n"; + CW << **I << "\n"; } } -} // End llvm namespace Index: llvm/lib/Analysis/IPA/FindUsedTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.27 llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.28 --- llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.27 Fri May 28 00:36:49 2004 +++ llvm/lib/Analysis/IPA/FindUsedTypes.cpp Wed Jul 14 21:31:46 2004 @@ -98,9 +98,9 @@ CachedWriter CW(M, o); for (std::set::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) - CW << " " << *I << "\n"; + CW << " " << **I << "\n"; } else for (std::set::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) - o << " " << *I << "\n"; + o << " " << **I << "\n"; } From lattner at cs.uiuc.edu Wed Jul 14 21:38:42 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:38:42 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/ConstantWriter.cpp Message-ID: <200407150238.VAA26249@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: ConstantWriter.cpp updated: 1.39 -> 1.40 --- Log message: Fix for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Writer/ConstantWriter.cpp diff -u llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.39 llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.40 --- llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.39 Sun Jul 11 12:22:07 2004 +++ llvm/lib/Bytecode/Writer/ConstantWriter.cpp Wed Jul 14 21:38:32 2004 @@ -189,7 +189,7 @@ case Type::LabelTyID: default: std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " type '" << CPV->getType() << "'\n"; + << " type '" << *CPV->getType() << "'\n"; break; } return; From lattner at cs.uiuc.edu Wed Jul 14 21:40:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:40:14 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Message-ID: <200407150240.VAA28817@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: SchedGraph.cpp updated: 1.62 -> 1.63 --- Log message: Fix for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+2 -2) Index: llvm/lib/CodeGen/InstrSched/SchedGraph.cpp diff -u llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.62 llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.63 --- llvm/lib/CodeGen/InstrSched/SchedGraph.cpp:1.62 Sun Jul 4 07:19:56 2004 +++ llvm/lib/CodeGen/InstrSched/SchedGraph.cpp Wed Jul 14 21:40:04 2004 @@ -107,7 +107,7 @@ void SchedGraph::dump() const { std::cerr << " Sched Graph for Basic Block: " << MBB.getBasicBlock()->getName() - << " (" << MBB.getBasicBlock() << ")" + << " (" << *MBB.getBasicBlock() << ")" << "\n\n Actual Root nodes: "; for (SchedGraphNodeCommon::const_iterator I = graphRoot->beginOutEdges(), E = graphRoot->endOutEdges(); @@ -694,7 +694,7 @@ os<< "Control Dep"; break; case SchedGraphEdge::ValueDep: - os<< "Reg Value " << val; + os<< "Reg Value " << *val; break; case SchedGraphEdge::MemoryDep: os<< "Memory Dep"; From lattner at cs.uiuc.edu Wed Jul 14 21:44:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:44:14 -0500 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Message-ID: <200407150244.VAA04218@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.129 -> 1.130 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+2 -2) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.129 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.130 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.129 Sun Jun 20 02:46:33 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Wed Jul 14 21:44:03 2004 @@ -146,7 +146,7 @@ getOperandValue(CE->getOperand(1), SF), getOperandValue(CE->getOperand(2), SF)); default: - std::cerr << "Unhandled ConstantExpr: " << CE << "\n"; + std::cerr << "Unhandled ConstantExpr: " << *CE << "\n"; abort(); return GenericValue(); } @@ -236,7 +236,7 @@ IMPLEMENT_BINARY_OPERATOR(*, Float); IMPLEMENT_BINARY_OPERATOR(*, Double); default: - std::cout << "Unhandled type for Mul instruction: " << Ty << "\n"; + std::cout << "Unhandled type for Mul instruction: " << *Ty << "\n"; abort(); } return Dest; From lattner at cs.uiuc.edu Wed Jul 14 21:47:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:47:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <200407150247.VAA10255@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine: ExecutionEngine.cpp updated: 1.54 -> 1.55 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+4 -4) Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.54 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.55 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.54 Sun Jul 11 03:01:11 2004 +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Wed Jul 14 21:47:47 2004 @@ -278,7 +278,7 @@ } break; default: - std::cout << "ERROR: Constant unimp for type: " << C->getType() << "\n"; + std::cout << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; abort(); } return Result; @@ -319,7 +319,7 @@ Ptr->Untyped[7] = (Val.ULongVal >> 56) & 255; break; default: - std::cout << "Cannot store value of type " << Ty << "!\n"; + std::cout << "Cannot store value of type " << *Ty << "!\n"; } } else { switch (Ty->getTypeID()) { @@ -352,7 +352,7 @@ Ptr->Untyped[0] = (Val.ULongVal >> 56) & 255; break; default: - std::cout << "Cannot store value of type " << Ty << "!\n"; + std::cout << "Cannot store value of type " << *Ty << "!\n"; } } } @@ -471,7 +471,7 @@ } default: - std::cerr << "Bad Type: " << Init->getType() << "\n"; + std::cerr << "Bad Type: " << *Init->getType() << "\n"; assert(0 && "Unknown constant type to initialize memory with!"); } } From lattner at cs.uiuc.edu Wed Jul 14 21:48:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:48:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Message-ID: <200407150248.VAA10388@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/Interpreter: Execution.cpp updated: 1.130 -> 1.131 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+2 -2) Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.130 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.131 --- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.130 Wed Jul 14 21:44:03 2004 +++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp Wed Jul 14 21:47:51 2004 @@ -421,7 +421,7 @@ IMPLEMENT_SETCC(<=, Double); IMPLEMENT_POINTERSETCC(<=); default: - std::cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; + std::cout << "Unhandled type for SetLE instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -941,7 +941,7 @@ IMPLEMENT_CAST(DESTTY, DESTCTY, Double) #define IMPLEMENT_CAST_CASE_END() \ - default: std::cout << "Unhandled cast: " << SrcTy << " to " << Ty << "\n"; \ + default: std::cout << "Unhandled cast: " << *SrcTy << " to " << *Ty << "\n"; \ abort(); \ } \ break From lattner at cs.uiuc.edu Wed Jul 14 21:50:48 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:50:48 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/InstForest.h Message-ID: <200407150250.VAA13298@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: InstForest.h updated: 1.24 -> 1.25 --- Log message: Fix for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Analysis/InstForest.h diff -u llvm/include/llvm/Analysis/InstForest.h:1.24 llvm/include/llvm/Analysis/InstForest.h:1.25 --- llvm/include/llvm/Analysis/InstForest.h:1.24 Sat Nov 29 13:55:12 2003 +++ llvm/include/llvm/Analysis/InstForest.h Wed Jul 14 21:50:38 2004 @@ -123,7 +123,7 @@ default: o << "UNKNOWN NODE TYPE: " << getNodeType() << "\n"; abort(); } - o << getValue(); + o << *getValue(); if (!isa(getValue())) o << "\n"; for (unsigned i = 0; i < this->getNumChildren(); ++i) From lattner at cs.uiuc.edu Wed Jul 14 21:51:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:51:29 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Assembly/CachedWriter.h Message-ID: <200407150251.VAA13733@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Assembly: CachedWriter.h updated: 1.18 -> 1.19 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+3 -11) Index: llvm/include/llvm/Assembly/CachedWriter.h diff -u llvm/include/llvm/Assembly/CachedWriter.h:1.18 llvm/include/llvm/Assembly/CachedWriter.h:1.19 --- llvm/include/llvm/Assembly/CachedWriter.h:1.18 Fri Jun 4 16:10:35 2004 +++ llvm/include/llvm/Assembly/CachedWriter.h Wed Jul 14 21:51:18 2004 @@ -20,15 +20,12 @@ #include "llvm/Value.h" #include -namespace { -class SlotMachine; // Internal private class -} - namespace llvm { class Module; class PointerType; class AssemblyWriter; // Internal private class +class SlotMachine; class CachedWriter { AssemblyWriter *AW; @@ -53,14 +50,9 @@ // setModule - Invalidate internal state, use the new module instead. void setModule(const Module *M); - CachedWriter &operator<<(const Value *V); - - inline CachedWriter &operator<<(const Value &X) { - return *this << &X; - } + CachedWriter &operator<<(const Value &V); - CachedWriter &operator<<(const Type *X); - inline CachedWriter &operator<<(const PointerType *X); + CachedWriter &operator<<(const Type &X); inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) { Out << Manip; return *this; From lattner at cs.uiuc.edu Wed Jul 14 21:51:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:51:41 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407150251.VAA14040@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.146 -> 1.147 --- Log message: Fixes for PR341: http://llvm.cs.uiuc.edu/PR341 --- Diffs of the changes: (+11 -11) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.146 llvm/lib/VMCore/AsmWriter.cpp:1.147 --- llvm/lib/VMCore/AsmWriter.cpp:1.146 Tue Jul 13 18:14:34 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Wed Jul 14 21:51:31 2004 @@ -34,7 +34,7 @@ #include using namespace llvm; -namespace { +namespace llvm { /// This class provides computation of slot numbers for LLVM Assembly writing. /// @brief LLVM Assembly Writing Slot Computation. @@ -154,7 +154,7 @@ }; -} +} // end namespace llvm static RegisterPass X("printm", "Print module to stderr",PassInfo::Analysis|PassInfo::Optimization); @@ -1213,27 +1213,27 @@ delete SC; } -CachedWriter &CachedWriter::operator<<(const Value *V) { +CachedWriter &CachedWriter::operator<<(const Value &V) { assert(AW && SC && "CachedWriter does not have a current module!"); - if (const Instruction *I = dyn_cast(V)) + if (const Instruction *I = dyn_cast(&V)) AW->write(I); - else if (const BasicBlock *BB = dyn_cast(V)) + else if (const BasicBlock *BB = dyn_cast(&V)) AW->write(BB); - else if (const Function *F = dyn_cast(V)) + else if (const Function *F = dyn_cast(&V)) AW->write(F); - else if (const GlobalVariable *GV = dyn_cast(V)) + else if (const GlobalVariable *GV = dyn_cast(&V)) AW->write(GV); else - AW->writeOperand(V, true, true); + AW->writeOperand(&V, true, true); return *this; } -CachedWriter& CachedWriter::operator<<(const Type *Ty) { +CachedWriter& CachedWriter::operator<<(const Type &Ty) { if (SymbolicTypes) { const Module *M = AW->getModule(); - if (M) WriteTypeSymbolic(Out, Ty, M); + if (M) WriteTypeSymbolic(Out, &Ty, M); } else { - AW->write(Ty); + AW->write(&Ty); } return *this; } From lattner at cs.uiuc.edu Wed Jul 14 21:54:46 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:54:46 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Type.h Message-ID: <200407150254.VAA16099@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.56 -> 1.57 Type.h updated: 1.55 -> 1.56 --- Log message: Final fix for PR341: http://llvm.cs.uiuc.edu/PR341 : eliminate operator<<(ostream, Value*). Clients should now send references to ostreams instead of pointers. Sending pointers to ostreams will print their addresses. --- Diffs of the changes: (+0 -9) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.56 llvm/include/llvm/Value.h:1.57 --- llvm/include/llvm/Value.h:1.56 Mon Jul 12 15:25:33 2004 +++ llvm/include/llvm/Value.h Wed Jul 14 21:54:36 2004 @@ -139,14 +139,6 @@ friend class Instruction; }; -inline std::ostream &operator<<(std::ostream &OS, const Value *V) { - if (V == 0) - OS << " value!\n"; - else - V->print(OS); - return OS; -} - inline std::ostream &operator<<(std::ostream &OS, const Value &V) { V.print(OS); return OS; Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.55 llvm/include/llvm/Type.h:1.56 --- llvm/include/llvm/Type.h:1.55 Wed Jul 14 20:15:53 2004 +++ llvm/include/llvm/Type.h Wed Jul 14 21:54:36 2004 @@ -389,7 +389,6 @@ return Ty.getTypeID() == Type::PointerTyID; } -std::ostream &operator<<(std::ostream &OS, const Type *T); std::ostream &operator<<(std::ostream &OS, const Type &T); } // End llvm namespace From lattner at cs.uiuc.edu Wed Jul 14 21:59:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 21:59:34 -0500 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407150259.VAA23935@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.215 -> 1.216 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.215 llvm/docs/ReleaseNotes.html:1.216 --- llvm/docs/ReleaseNotes.html:1.215 Mon Jul 12 12:09:23 2004 +++ llvm/docs/ReleaseNotes.html Wed Jul 14 21:59:24 2004 @@ -183,6 +183,7 @@ produced when linking C++ programs has been fixed.
    8. lli Doesn't Handle Exceptions From Bytecode Reader
    9. +
    10. operator<< on a Value* now prints the address of the object instead of its contents.
    @@ -753,7 +754,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/12 17:09:23 $ + Last modified: $Date: 2004/07/15 02:59:24 $ From lattner at cs.uiuc.edu Wed Jul 14 23:27:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 23:27:15 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200407150427.XAA05195@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.44 -> 1.45 --- Log message: Fix PR404: http://llvm.cs.uiuc.edu/PR404 : Loop simplify is really slow on 252.eon This eliminates an N*N*logN algorithm from the loop simplify pass, replacing it with a much simpler and faster alternative. In a debug build, this reduces gccas time on eon from 85s to 42s. --- Diffs of the changes: (+12 -12) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.44 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.45 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.44 Sun Apr 18 17:27:10 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Wed Jul 14 23:27:04 2004 @@ -147,6 +147,9 @@ Changed = true; } + + DominatorSet &DS = getAnalysis(); // Update dominator info + // Next, check to make sure that all exit nodes of the loop only have // predecessors that are inside of the loop. This check guarantees that the // loop preheader/header will dominate the exit blocks. If the exit block has @@ -155,19 +158,16 @@ L->getExitBlocks(ExitBlocks); for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { BasicBlock *ExitBlock = ExitBlocks[i]; - for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock); - PI != PE; ++PI) - if (!L->contains(*PI)) { - BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); - for (unsigned j = i; j != ExitBlocks.size(); ++j) - if (ExitBlocks[j] == ExitBlock) - ExitBlocks[j] = NewBB; - - NumInserted++; - Changed = true; - break; - } + if (!DS.dominates(L->getHeader(), ExitBlock)) { + BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); + for (unsigned j = i; j != ExitBlocks.size(); ++j) + if (ExitBlocks[j] == ExitBlock) + ExitBlocks[j] = NewBB; + + NumInserted++; + Changed = true; } + } // If the header has more than two predecessors at this point (from the // preheader and from multiple backedges), we must adjust the loop. From lattner at cs.uiuc.edu Wed Jul 14 23:30:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed, 14 Jul 2004 23:30:45 -0500 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407150430.XAA05262@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.216 -> 1.217 --- Log message: QOI issue fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.216 llvm/docs/ReleaseNotes.html:1.217 --- llvm/docs/ReleaseNotes.html:1.216 Wed Jul 14 21:59:24 2004 +++ llvm/docs/ReleaseNotes.html Wed Jul 14 23:30:35 2004 @@ -184,6 +184,7 @@
  • lli Doesn't Handle Exceptions From Bytecode Reader
  • operator<< on a Value* now prints the address of the object instead of its contents.
  • +
  • [loopsimplify] Loop simplify is really slow on 252.eon
  • @@ -754,7 +755,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/15 02:59:24 $ + Last modified: $Date: 2004/07/15 04:30:35 $ From lattner at cs.uiuc.edu Thu Jul 15 00:36:41 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 00:36:41 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200407150536.AAA07978@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.45 -> 1.46 --- Log message: Revert previous patch until I get a bug fixed --- Diffs of the changes: (+12 -12) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.45 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.46 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.45 Wed Jul 14 23:27:04 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Jul 15 00:36:31 2004 @@ -147,9 +147,6 @@ Changed = true; } - - DominatorSet &DS = getAnalysis(); // Update dominator info - // Next, check to make sure that all exit nodes of the loop only have // predecessors that are inside of the loop. This check guarantees that the // loop preheader/header will dominate the exit blocks. If the exit block has @@ -158,16 +155,19 @@ L->getExitBlocks(ExitBlocks); for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { BasicBlock *ExitBlock = ExitBlocks[i]; - if (!DS.dominates(L->getHeader(), ExitBlock)) { - BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); - for (unsigned j = i; j != ExitBlocks.size(); ++j) - if (ExitBlocks[j] == ExitBlock) - ExitBlocks[j] = NewBB; - - NumInserted++; - Changed = true; + for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock); + PI != PE; ++PI) + if (!L->contains(*PI)) { + BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); + for (unsigned j = i; j != ExitBlocks.size(); ++j) + if (ExitBlocks[j] == ExitBlock) + ExitBlocks[j] = NewBB; + + NumInserted++; + Changed = true; + break; + } } - } // If the header has more than two predecessors at this point (from the // preheader and from multiple backedges), we must adjust the loop. From lattner at cs.uiuc.edu Thu Jul 15 02:44:44 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 02:44:44 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetData.cpp Message-ID: <200407150744.CAA11132@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetData.cpp updated: 1.48 -> 1.49 --- Log message: Nuke a clearly bogus assertion --- Diffs of the changes: (+0 -2) Index: llvm/lib/Target/TargetData.cpp diff -u llvm/lib/Target/TargetData.cpp:1.48 llvm/lib/Target/TargetData.cpp:1.49 --- llvm/lib/Target/TargetData.cpp:1.48 Fri Jul 2 02:01:31 2004 +++ llvm/lib/Target/TargetData.cpp Thu Jul 15 02:44:34 2004 @@ -92,8 +92,6 @@ PointerSize = PtrSize; PointerAlignment = PtrAl; DoubleAlignment = DoubleAl; - assert(DoubleAlignment == PtrAl && - "Double alignment and pointer alignment agree for now!"); FloatAlignment = FloatAl; LongAlignment = LongAl; IntAlignment = IntAl; From lattner at cs.uiuc.edu Thu Jul 15 03:18:44 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 03:18:44 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/SetVector.h Message-ID: <200407150818.DAA12659@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: SetVector.h updated: 1.2 -> 1.3 --- Log message: Give SetVector range support --- Diffs of the changes: (+17 -1) Index: llvm/include/Support/SetVector.h diff -u llvm/include/Support/SetVector.h:1.2 llvm/include/Support/SetVector.h:1.3 --- llvm/include/Support/SetVector.h:1.2 Thu Jul 8 16:50:33 2004 +++ llvm/include/Support/SetVector.h Thu Jul 15 03:18:31 2004 @@ -28,7 +28,6 @@ /// @breif A vector that has set insertion semantics. template class SetVector { - public: typedef T value_type; typedef T key_type; @@ -40,6 +39,15 @@ typedef typename vector_type::const_iterator const_iterator; typedef typename vector_type::size_type size_type; + /// @brief Construct an empty SetVector + SetVector() {} + + /// @brief Initialize a SetVector with a range of elements + template + SetVector( It Start, It End ) { + insert(Start, End); + } + /// @brief Completely clear the SetVector void clear() { set_.clear(); @@ -91,6 +99,14 @@ return result; } + /// @brief Insert a range of elements into the SetVector. + template + void insert( It Start, It End ) { + for (; Start != End; ++Start) + if ( set_.insert(*Start).second ) + vector_.push_back(*Start); + } + /// @returns 0 if the element is not in the SetVector, 1 if it is. /// @brief Count the number of elements of a given key in the SetVector. size_type count( const key_type& key ) const { From lattner at cs.uiuc.edu Thu Jul 15 03:20:33 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 03:20:33 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopSimplify.cpp Message-ID: <200407150820.DAA12940@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LoopSimplify.cpp updated: 1.46 -> 1.47 --- Log message: Fix PR404: http://llvm.cs.uiuc.edu/PR404 try #2 This version takes about 1s longer than the previous one (down to 2.35s), but on the positive side, it actually works :) --- Diffs of the changes: (+8 -8) Index: llvm/lib/Transforms/Scalar/LoopSimplify.cpp diff -u llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.46 llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.47 --- llvm/lib/Transforms/Scalar/LoopSimplify.cpp:1.46 Thu Jul 15 00:36:31 2004 +++ llvm/lib/Transforms/Scalar/LoopSimplify.cpp Thu Jul 15 03:20:22 2004 @@ -43,6 +43,7 @@ #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/Local.h" #include "Support/SetOperations.h" +#include "Support/SetVector.h" #include "Support/Statistic.h" #include "Support/DepthFirstIterator.h" using namespace llvm; @@ -153,21 +154,20 @@ // predecessors from outside of the loop, split the edge now. std::vector ExitBlocks; L->getExitBlocks(ExitBlocks); - for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) { - BasicBlock *ExitBlock = ExitBlocks[i]; + + SetVector ExitBlockSet(ExitBlocks.begin(), ExitBlocks.end()); + for (SetVector::iterator I = ExitBlockSet.begin(), + E = ExitBlockSet.end(); I != E; ++I) { + BasicBlock *ExitBlock = *I; for (pred_iterator PI = pred_begin(ExitBlock), PE = pred_end(ExitBlock); PI != PE; ++PI) if (!L->contains(*PI)) { - BasicBlock *NewBB = RewriteLoopExitBlock(L, ExitBlock); - for (unsigned j = i; j != ExitBlocks.size(); ++j) - if (ExitBlocks[j] == ExitBlock) - ExitBlocks[j] = NewBB; - + RewriteLoopExitBlock(L, ExitBlock); NumInserted++; Changed = true; break; } - } + } // If the header has more than two predecessors at this point (from the // preheader and from multiple backedges), we must adjust the loop. From alkis at cs.uiuc.edu Thu Jul 15 06:26:31 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 15 Jul 2004 06:26:31 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/ Message-ID: <200407151126.GAA29037@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm-java/runtime added to the repository --- Diffs of the changes: (+0 -0) From alkis at cs.uiuc.edu Thu Jul 15 06:28:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 15 Jul 2004 06:28:54 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Compiler/Makefile Message-ID: <200407151128.GAA29289@zion.cs.uiuc.edu> Changes in directory llvm-java/test/Compiler: Makefile updated: 1.1 -> 1.2 --- Log message: Add runtime and move some rules to Makefile.rules. Now we link to the runtime (which is currently almost empty :-)). --- Diffs of the changes: (+1 -1) Index: llvm-java/test/Compiler/Makefile diff -u llvm-java/test/Compiler/Makefile:1.1 llvm-java/test/Compiler/Makefile:1.2 --- llvm-java/test/Compiler/Makefile:1.1 Wed Jul 14 03:30:35 2004 +++ llvm-java/test/Compiler/Makefile Thu Jul 15 06:28:44 2004 @@ -10,6 +10,6 @@ CLASSFILES := $(wildcard *.class) -all:: $(foreach ext,rbc ll,$(CLASSFILES:%.class=Output/%.$(ext))) +all:: $(foreach ext,linked.dis-ll,$(CLASSFILES:%.class=Output/%.$(ext))) include $(LEVEL)/test/Makefile.test From alkis at cs.uiuc.edu Thu Jul 15 06:28:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 15 Jul 2004 06:28:54 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407151128.GAA29296@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.1 -> 1.2 --- Log message: Add runtime and move some rules to Makefile.rules. Now we link to the runtime (which is currently almost empty :-)). --- Diffs of the changes: (+17 -6) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.1 llvm-java/test/Makefile.test:1.2 --- llvm-java/test/Makefile.test:1.1 Wed Jul 14 03:30:35 2004 +++ llvm-java/test/Makefile.test Thu Jul 15 06:28:44 2004 @@ -7,11 +7,22 @@ # ##===----------------------------------------------------------------------===## -# rule to build raw bytecode from a classfile -Output/%.rbc: %.class Output/.dir - $(CLASS2LLVM) $* | $(LLVMTOOLCURRENT)/opt$(EXEEXT) -mem2reg > $@ +include $(LEVEL)/Makefile.common -%.ll: %.rbc - $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) < $< > $@ +.PHONY: clean -include $(LEVEL)/Makefile.common +clean:: + $(RM) -f a.out core + $(RM) -rf Output/ + +# we don't want these files to be deleted by make, even if they are +# intermediate results +.PRECIOUS: Output/.dir Output/%.bc Output/%.ll Output/%.llvm.bc Output/%.llvm + +# rule to build raw bytecode from a classfile +Output/%.raw.bc: %.class Output/.dir + $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ + +#rule to link in runtime to raw bytecode +Output/%.linked.bc: Output/%.raw.bc + $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $< $(BUILD_SRC_ROOT)/runtime/runtime.bc -o $@ From alkis at cs.uiuc.edu Thu Jul 15 06:28:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 15 Jul 2004 06:28:54 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.ll Makefile Message-ID: <200407151128.GAA29305@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.ll added (r1.1) Makefile added (r1.1) --- Log message: Add runtime and move some rules to Makefile.rules. Now we link to the runtime (which is currently almost empty :-)). --- Diffs of the changes: (+16 -0) Index: llvm-java/runtime/runtime.ll diff -c /dev/null llvm-java/runtime/runtime.ll:1.1 *** /dev/null Thu Jul 15 06:28:54 2004 --- llvm-java/runtime/runtime.ll Thu Jul 15 06:28:44 2004 *************** *** 0 **** --- 1,3 ---- + "java/lang/Object" = type opaque + + "java/lang/Object" = type { "java/lang/Object" } Index: llvm-java/runtime/Makefile diff -c /dev/null llvm-java/runtime/Makefile:1.1 *** /dev/null Thu Jul 15 06:28:54 2004 --- llvm-java/runtime/Makefile Thu Jul 15 06:28:44 2004 *************** *** 0 **** --- 1,13 ---- + ##==-- runtime/Makefile ----------------------------- -*- makefile -*--====## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL := .. + + include $(LEVEL)/Makefile.common + + all:: runtime.bc From alkis at cs.uiuc.edu Thu Jul 15 06:28:54 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu, 15 Jul 2004 06:28:54 -0500 Subject: [llvm-commits] CVS: llvm-java/Makefile.rules Message-ID: <200407151128.GAA29312@zion.cs.uiuc.edu> Changes in directory llvm-java: Makefile.rules updated: 1.3 -> 1.4 --- Log message: Add runtime and move some rules to Makefile.rules. Now we link to the runtime (which is currently almost empty :-)). --- Diffs of the changes: (+12 -0) Index: llvm-java/Makefile.rules diff -u llvm-java/Makefile.rules:1.3 llvm-java/Makefile.rules:1.4 --- llvm-java/Makefile.rules:1.3 Tue Jul 13 19:29:15 2004 +++ llvm-java/Makefile.rules Thu Jul 15 06:28:44 2004 @@ -15,3 +15,15 @@ endif CLASS2LLVM := $(LEVEL)/tools/Debug/class2llvm$(EXEEXT) +LDIS := $(LLVMTOOLCURRENT)/llvm-dis$(EXEEXT) +LAS := $(LLVMTOOLCURRENT)/llvm-as$(EXEEXT) +LLINK := $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) +LOPT := $(LLVMTOOLCURRENT)/opt$(EXEEXT) + +# rule to make assembly from bytecode +%.dis-ll: %.bc + $(LDIS) < $< > $@ + +# rule to make bytecode from assembly +%.bc: %.ll + $(LAS) < $< > $@ From gaeke at cs.uiuc.edu Thu Jul 15 16:21:00 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:21:00 -0500 Subject: [llvm-commits] CVS: llvm-tv/tools/llvm-tv/GraphPrinters.cpp Message-ID: <200407152121.QAA09830@zion.cs.uiuc.edu> Changes in directory llvm-tv/tools/llvm-tv: GraphPrinters.cpp updated: 1.4 -> 1.5 --- Log message: Fix location of header files that have moved. --- Diffs of the changes: (+2 -2) Index: llvm-tv/tools/llvm-tv/GraphPrinters.cpp diff -u llvm-tv/tools/llvm-tv/GraphPrinters.cpp:1.4 llvm-tv/tools/llvm-tv/GraphPrinters.cpp:1.5 --- llvm-tv/tools/llvm-tv/GraphPrinters.cpp:1.4 Thu Apr 29 11:12:02 2004 +++ llvm-tv/tools/llvm-tv/GraphPrinters.cpp Thu Jul 15 16:20:50 2004 @@ -18,8 +18,8 @@ #include "llvm/Pass.h" #include "llvm/Value.h" #include "llvm/Analysis/CallGraph.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/GraphWriter.h" #include using namespace llvm; From gaeke at cs.uiuc.edu Thu Jul 15 16:21:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:21:11 -0500 Subject: [llvm-commits] CVS: llvm-tv/tools/llvm-tv/TVApplication.cpp Message-ID: <200407152121.QAA09871@zion.cs.uiuc.edu> Changes in directory llvm-tv/tools/llvm-tv: TVApplication.cpp updated: 1.26 -> 1.27 --- Log message: Include for std::cerr. --- Diffs of the changes: (+1 -0) Index: llvm-tv/tools/llvm-tv/TVApplication.cpp diff -u llvm-tv/tools/llvm-tv/TVApplication.cpp:1.26 llvm-tv/tools/llvm-tv/TVApplication.cpp:1.27 --- llvm-tv/tools/llvm-tv/TVApplication.cpp:1.26 Sat May 15 00:48:55 2004 +++ llvm-tv/tools/llvm-tv/TVApplication.cpp Thu Jul 15 16:21:01 2004 @@ -11,6 +11,7 @@ #include "llvm-tv/Config.h" #include #include +#include #include #include #include From gaeke at cs.uiuc.edu Thu Jul 15 16:27:18 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:27:18 -0500 Subject: [llvm-commits] CVS: llvm-tv/tools/llvm-tv/Makefile Message-ID: <200407152127.QAA10022@zion.cs.uiuc.edu> Changes in directory llvm-tv/tools/llvm-tv: Makefile updated: 1.16 -> 1.17 --- Log message: Apparently we now need transformutils.a to link, for DemoteRegToStack(). (I don't see where that dependency comes from.) Add it. --- Diffs of the changes: (+1 -1) Index: llvm-tv/tools/llvm-tv/Makefile diff -u llvm-tv/tools/llvm-tv/Makefile:1.16 llvm-tv/tools/llvm-tv/Makefile:1.17 --- llvm-tv/tools/llvm-tv/Makefile:1.16 Thu Jun 10 08:21:25 2004 +++ llvm-tv/tools/llvm-tv/Makefile Thu Jul 15 16:27:08 2004 @@ -1,7 +1,7 @@ LEVEL = ../.. TOOLNAME = llvm-tv LLVMLIBS = analysis.a bcreader bcwriter datastructure ipa.a support.a \ - target.a vmcore + target.a vmcore transformutils.a # note: delete when FileUtils is assimilated into libsupport USEDLIBS = snapshot From gaeke at cs.uiuc.edu Thu Jul 15 16:53:31 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:53:31 -0500 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407152153.QAA10352@zion.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.20 -> 1.21 --- Log message: Rename TraceFunction::get --> BuildTraceFunction. Now it takes a ModuleProvider. Add ArgToLiveOutMap for the benefit of the new epilog rewriter. --- Diffs of the changes: (+13 -7) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.20 reopt/include/reopt/TraceToFunction.h:1.21 --- reopt/include/reopt/TraceToFunction.h:1.20 Fri Jul 9 14:41:27 2004 +++ reopt/include/reopt/TraceToFunction.h Thu Jul 15 16:53:21 2004 @@ -16,6 +16,7 @@ namespace llvm { class ReturnInst; +class ModuleProvider; typedef std::set LiveVariableSet; typedef std::vector LiveVariableVector; @@ -49,16 +50,12 @@ /// Constructor - you can't have a TraceFunction without a Trace. /// This gives you a "blank" TraceFunction without a TraceFn or any - /// live variable sets. If you want those, use TraceFunction::get () - /// instead, which performs all the expensive transformations. + /// live variable sets. If you want those, use BuildTraceFunction() + /// instead, which performs all the expensive transformations + /// using a TraceFunctionBuilder object. /// TraceFunction (Trace &T_) : MatrixFn (T_.getFunction ()), T (T_) { } - /// Returns a filled-in TraceFunction object with a TraceFn for T, - /// along with its Live-In and Live-Out variable sets. - /// - static TraceFunction *get (Trace &T); - /// Map of return instructions in TraceFn --> /// basic blocks that they are supposed to return to in MatrixFn. /// @@ -73,6 +70,7 @@ /// ValueMap LiveInToArgMap; ValueMap LiveOutToArgMap; + ValueMap ArgToLiveOutMap; Value *getCorrespondingValue (const Value *V, bool preferLiveIn = true) { if (isa(V)) return const_cast (V); @@ -90,6 +88,14 @@ } }; +/// BuildTraceFunction - Returns a new TraceFunction containing the code +/// in the basic blocks of T, along with live-in and live-out sets, +/// return block maps, and all the other goodies you would expect to find +/// in a TraceFunction. This does not modify T's original parent function +/// (the "matrix function"). +/// +TraceFunction *BuildTraceFunction (Trace &T, ModuleProvider *MP); + } // end namespace llvm #endif // REOPT_TRACETOFUNCTION_H From gaeke at cs.uiuc.edu Thu Jul 15 16:53:42 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:53:42 -0500 Subject: [llvm-commits] CVS: reopt/include/reopt/UnpackTraceFunction.h Message-ID: <200407152153.QAA10419@zion.cs.uiuc.edu> Changes in directory reopt/include/reopt: UnpackTraceFunction.h updated: 1.12 -> 1.13 --- Log message: Add g3IsMatrixFP flag. Add the new epilog rewriter (rewriteEpilogInstr()). --- Diffs of the changes: (+3 -0) Index: reopt/include/reopt/UnpackTraceFunction.h diff -u reopt/include/reopt/UnpackTraceFunction.h:1.12 reopt/include/reopt/UnpackTraceFunction.h:1.13 --- reopt/include/reopt/UnpackTraceFunction.h:1.12 Sun Jul 11 05:02:55 2004 +++ reopt/include/reopt/UnpackTraceFunction.h Thu Jul 15 16:53:32 2004 @@ -50,6 +50,7 @@ /// the traceFn's frame pointer (as opposed to matrixFn's.) /// Only used in assertions. bool fpIsTraceFP; + bool g3IsMatrixFP; unsigned getStaticStackSize (MachineFunction &MF); unsigned stackOffsetForReg (const unsigned R) const; @@ -70,6 +71,8 @@ Value *liveOutValue, Value *liveOutTraceValue); void eliminatePhiAtTraceExit (MachineFunction &MF, MachineBasicBlock &MBB, const PHINode *PN); + bool rewriteEpilogInstr (MachineBasicBlock &MBB, + MachineBasicBlock::iterator iter); void rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB); public: From gaeke at cs.uiuc.edu Thu Jul 15 16:53:53 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:53:53 -0500 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200407152153.QAA10459@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.47 -> 1.48 --- Log message: Rename TraceFunction::get --> BuildTraceFunction. Now it takes a ModuleProvider. --- Diffs of the changes: (+1 -1) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.47 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.48 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.47 Sun Jul 11 19:33:25 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Thu Jul 15 16:53:43 2004 @@ -86,7 +86,7 @@ // a TraceFunction. Trace T (vBB); DEBUG (WriteTraceToFile (&T)); - TraceFunction *TF = TraceFunction::get (T); + TraceFunction *TF = BuildTraceFunction (T, MP); // Compile the TraceFunction to machine code using the optimizing trace JIT // compiler, and unpack the resulting optimized trace back into its matrix From gaeke at cs.uiuc.edu Thu Jul 15 16:54:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:54:05 -0500 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407152154.QAA10499@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.98 -> 1.99 --- Log message: Squash a bogus 'may be used uninitialized' warning for R in rewriteProlog(). Add the new epilog rewriter (rewriteEpilogInstr()). --- Diffs of the changes: (+113 -24) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.98 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.99 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.98 Mon Jul 12 05:01:24 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Thu Jul 15 16:53:55 2004 @@ -222,7 +222,7 @@ std::pair &ai = AllocStates[V]; AllocInfo &Source = ai.first, &Target = ai.second; mvec.clear (); - unsigned R; + unsigned R = (unsigned) -1; assert ((Target.AllocState == AllocInfo::Allocated || Target.AllocState == AllocInfo::Spilled) && (Source.AllocState == AllocInfo::Allocated @@ -463,35 +463,123 @@ } } -void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, - MachineBasicBlock &MBB) { +bool UnpackTraceFunction::rewriteEpilogInstr (MachineBasicBlock &MBB, + MachineBasicBlock::iterator iter){ + static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, + g2 = SparcV9::g2, g3 = SparcV9::g3, matrixFP = SparcV9::g3; + const TargetInstrInfo &TII = *TM->getInstrInfo (); const SparcV9RegInfo &TRI = *TM->getRegInfo (); - static const unsigned fp = SparcV9::i6, sp = SparcV9::o6, g1 = SparcV9::g1, - g2 = SparcV9::g2; + MachineInstr &inst = *iter; + + DEBUG (std::cerr << "rewriteEpilogInstr: examining instr = " << inst << "\n"); + if (TII.isStore (inst.getOpcode ())) { + // It's a store, take it apart... + MachineOperand &targetBaseReg = inst.getOperand (1); + if (Value *storeBasePtrV = targetBaseReg.getVRegValueOrNull()) { + ValueMap::iterator i = TF->ArgToLiveOutMap.find(storeBasePtrV); + if (i != TF->ArgToLiveOutMap.end ()) { + // We're storing a live-out value into a live-out pseudo-arg. + assert (isa (storeBasePtrV) && "Expecting an Argument"); + Value *V = i->second; + assert (std::find (TF->LiveOutVector.begin (), TF->LiveOutVector.end (), + V) != TF->LiveOutVector.end () + && "Expecting a live-out value"); + + // Currently we can't handle offsets which are not zero. + assert (inst.getOperand (2).isImmediate() + && "Can only handle stores with immediate offsets"); + assert (inst.getOperand (2).getImmedValue() == 0 + && "Can only handle stores @ offset 0 of live-out pseudo-args"); + + // Change the target of the store to point either onto the + // TraceFn's stack (for arguments which are in registers in + // MatrixFn) or onto MatrixFn's stack (for arguments which are + // spilled onto the stack in MatrixFn). + int newImmedOffset = 9999; + int newBaseReg = 9999; + + std::pair ai = GetValueAllocState (TF, V, false); + AllocInfo &MatrixAI = ai.first; + if (MatrixAI.AllocState == AllocInfo::Allocated) { + assert (fpIsTraceFP + && "Need TraceFn frame pointer to store live-out registers"); + // MatrixAI.Placement is the register allocated to V in MatrixFn. + unsigned MatrixReg = MatrixAI.Placement; + // Store V onto TraceFn's stack, from which it will be reloaded into a + // MatrixFn register. + newBaseReg = sp; + newImmedOffset = stackOffsetForReg (MatrixReg); + // Add it to the RegsToSave set if it's not already there + if (RegsToSave.find (MatrixReg) == RegsToSave.end ()) + RegsToSave.insert (MatrixReg); + } else if (MatrixAI.AllocState == AllocInfo::Spilled) { + // MatrixAI.Placement is the stack slot allocated to V in MatrixFn. + // Make sure we have MatrixFn's frame pointer in a register: + if (!g3IsMatrixFP) { + // Insert a load instruction before this one to load matrixFP off + // the TraceFn stack. + std::vector mvec; + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), matrixFP, + TRI.getRegType(matrixFP), g2); + for (std::vector::iterator i = mvec.begin (), + e = mvec.end (); i != e; ++i) { + DEBUG (std::cerr << "rewriteEpilogInstr: inserting " << *i << "\n"); + MBB.insert (iter, *i); + } + g3IsMatrixFP = true; + } + // Store it into its stack slot on MatrixFn's stack. + newBaseReg = matrixFP; + newImmedOffset = MatrixAI.Placement; + } else { + assert (0 && "Live-outs must be allocated or spilled in MatrixFn"); + } + // Change the store instruction to have the new base register and + // offset. + assert (newImmedOffset != 9999 && newBaseReg != 9999 + && "Failed to compute new immed. offset or base reg."); + inst.SetMachineOperandReg (1, newBaseReg); + inst.SetMachineOperandConst (2, MachineOperand::MO_SignExtendedImmed, + newImmedOffset); + } + } + // Widen integer stores - all stack slots are 64 bits wide. + if (inst.getOpcode() == V9::STBi || inst.getOpcode () == V9::STHi + || inst.getOpcode () == V9::STWi) + inst.setOpcode (V9::STXi); + DEBUG (std::cerr << "rewriteEpilogInstr: rewrote instr = " << inst << "\n"); + } else if (((inst.getOpcode () == V9::ADDi || inst.getOpcode () == V9::ORi) + && (inst.getOperand (2).isDef () + && inst.getOperand (2).hasAllocatedReg () + && inst.getOperand (2).getReg () == SparcV9::i0)) + || (inst.getOpcode () == V9::JMPLRETi + || inst.getOpcode () == V9::RESTOREr + || inst.getOpcode () == V9::RESTOREi)) { + // This is old epilog code, or part of a 'ret int ...' instruction. Nuke it. + return true; + } + return false; // Don't delete the instr. +} +void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, + MachineBasicBlock &MBB) { // We start out each trace-exit MBB with %fp holding the TraceFn frame // pointer. fpIsTraceFP = true; - // Replace the contents of the trace-exit MBB with live-out stores followed - // by a branch back to the matrix function's basic block. First, clear the - // MBB, then insert stores from each live-out variable's reg. in the trace - // to its stack slot in the trace function, from which it will be - // reloaded below into a register. - MBB.clear (); - LiveVariableVector &So = TF->LiveOutVector; - for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); - SI != SE; ++SI) { - Value *V = *SI; - std::pair ai = GetValueAllocState (TF, V, false); - // Source is traceFn's register, Target is matrixFn's register - AllocInfo &Target = ai.first, &Source = ai.second; - DEBUG (std::cerr << "rewriteEpilog: copying live-out value: "; - PrintValueAIs(V->getName(), Target, Source)); - addLiveOutCopy (MF, MBB, Source, Target, V, - TF->getCorrespondingValue (V, false)); + // Rewrite any stores into live-out pseudo-arguments to store into stack + // slots instead. Delete old epilog leftovers in the process. + for (MachineBasicBlock::iterator i = MBB.begin (), e = MBB.end (); i != e; ) { + if (rewriteEpilogInstr (MBB, i)) { + MachineBasicBlock::iterator goner = i; + DEBUG (std::cerr << "rewriteEpilog: deleting " << *goner << "\n"); + ++i; + MBB.erase (goner); + } else { + ++i; + } } - + // Find the BasicBlock in MatrixFn that this block's return instr. // would have returned to, by consulting the mapping information // generated by TraceFunctionBuilder. @@ -511,8 +599,9 @@ // Restore MatrixFn's FP. Warning! After this point, addLiveOutCopy won't work // anymore, because it depends on being able to access TraceFn's frame // pointer in %fp. + const SparcV9RegInfo &TRI = *TM->getRegInfo (); + static const unsigned fp = SparcV9::i6, sp = SparcV9::o6, g2 = SparcV9::g2; std::vector mvec; - mvec.clear (); TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), fp, TRI.getRegType(fp), g2); for (std::vector::iterator vi = mvec.begin (), From gaeke at cs.uiuc.edu Thu Jul 15 16:55:16 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:55:16 -0500 Subject: [llvm-commits] CVS: reopt/tools/ttftest/ttftest.cpp Message-ID: <200407152155.QAA10602@zion.cs.uiuc.edu> Changes in directory reopt/tools/ttftest: ttftest.cpp updated: 1.7 -> 1.8 --- Log message: Rename TraceFunction::get --> BuildTraceFunction. Now it takes a ModuleProvider. --- Diffs of the changes: (+3 -1) Index: reopt/tools/ttftest/ttftest.cpp diff -u reopt/tools/ttftest/ttftest.cpp:1.7 reopt/tools/ttftest/ttftest.cpp:1.8 --- reopt/tools/ttftest/ttftest.cpp:1.7 Wed Jul 7 14:11:26 2004 +++ reopt/tools/ttftest/ttftest.cpp Thu Jul 15 16:55:06 2004 @@ -20,6 +20,7 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" +#include "llvm/ModuleProvider.h" #include "reopt/TraceIO.h" #include "reopt/TraceToFunction.h" #include @@ -92,7 +93,8 @@ } // Run TraceToFunction on the Trace. - TraceFunction *TF = TraceFunction::get (*T); + ModuleProvider *MP = new ExistingModuleProvider (M); + TraceFunction *TF = BuildTraceFunction (*T, MP); if (!Quiet) { std::cerr << *TF->TraceFn << "\n\n"; } // Run the LLVM Verifier on the resulting TraceFunction. From gaeke at cs.uiuc.edu Thu Jul 15 16:57:11 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 16:57:11 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407152157.QAA23494@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.75 -> 1.76 --- Log message: Include llvm/PassManager.h and llvm/Analysis/Dominators.h --- Diffs of the changes: (+2 -0) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.75 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.76 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.75 Fri Jul 9 14:41:27 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Thu Jul 15 16:57:00 2004 @@ -23,6 +23,7 @@ #include "reopt/TraceToFunction.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Pass.h" +#include "llvm/PassManager.h" #include "llvm/Module.h" #include "llvm/Argument.h" #include "llvm/DerivedTypes.h" @@ -32,6 +33,7 @@ #include "llvm/iOther.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" +#include "llvm/Analysis/Dominators.h" #include "llvm/Support/CFG.h" // for succ_iterator, etc. #include "Support/StringExtras.h" // for utostr() #define DEBUG_TYPE "tracetofunction" From gaeke at cs.uiuc.edu Thu Jul 15 17:05:25 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu, 15 Jul 2004 17:05:25 -0500 (CDT) Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407152205.RAA23531@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.76 -> 1.77 --- Log message: Make TraceFunctionBuilder into a FunctionPass, so that it can use real, honest-to-goodness DominatorSet analysis results. Note that it's a FunctionPass that runs on the *matrix* function! Rename buildTraceFunction method --> runOnFunction. Restructure data members and add some comments. Rename getTraceLive{In,Out}Set methods --> buildTraceLive{In,Out}Set, to clarify what they are doing. Add hasUseDominatedByEdge() (disabled for now, because it's buggy!) Nuke cloneMapDump(); no one uses it anymore. Fill in the ArgToLiveOutMap along with LiveOutToArgMap, for the benefit of the new epilog rewriter. --- Diffs of the changes: (+89 -51) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.76 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.77 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.76 Thu Jul 15 16:57:00 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Thu Jul 15 17:05:15 2004 @@ -52,25 +52,36 @@ /// TraceFunctionBuilder - a Method Object which encapsulates the algorithm /// for building TraceFunctions given Traces. /// -class TraceFunctionBuilder { +class TraceFunctionBuilder : public FunctionPass { + // Inputs + Trace &T; + Module *Mod; + DominatorSet *DS; + + // Assorted temporary data structures BranchNumberMap BranchNumber; - TraceFunction *TF; std::vector AlternateEntryPointsV; + // Output + TraceFunction *TF; + + // Live-variable sets and their builder methods LiveVariableSet LiveInSet; + void buildTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, + Trace &T); LiveVariableSet LiveOutSet; + void buildTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, + Trace &T); - void getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, - Trace &T); - void getTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, - Trace &T); - + // Map showing which blocks contain first-level instrumentation (FLI), + // with builder and accessor methods FLIMapTy FLIMap; BasicBlock *getFLIEdgeSource (BasicBlock *BB) const; BasicBlock *getFLIEdgeTarget (BasicBlock *BB) const; void threadFLIEdges (Function *F); void buildFLIMap (Trace &T, FLIMapTy &FLIMap); + // Main methods of TraceFunctionBuilder transformation TypeVector createFunctionArgTypeVector (const LiveVariableVector &LiveIns, const LiveVariableVector &LiveOuts); void giveNamesToFunctionArgs (const LiveVariableVector &LiveIns, @@ -78,20 +89,32 @@ Function *F); void fillInFunctionBody (Trace &T, Function *F, LiveVariableVector &So); int findOffTracePhiSource (const PHINode *newPN); + bool hasUseDominatedByEdge (Instruction *defInst, BasicBlock *source, + BasicBlock *target); void fixupFunctionBodyBB (Trace &T, Function *F, BasicBlock *srcB, BasicBlock *dstB, ValueMap &O2CMap, LiveVariableVector &So); - - void cloneMapDump (); public: - TraceFunctionBuilder () { } + TraceFunctionBuilder (Trace &Tr) : T (Tr) { } virtual ~TraceFunctionBuilder () { } + TraceFunction *getTraceFunction () { return TF; } - /// buildTraceFunction - Given a Trace object, returns a pointer to a new - /// TraceFunction containing the same code as the Trace, along with some. + bool doInitialization (Module &M) { + Mod = &M; + return false; + } + + virtual void getAnalysisUsage (AnalysisUsage &AU) const { + AU.setPreservesAll (); + AU.addRequired (); + } + + /// runOnFunction - Given a Trace object, and dominator information + /// about the Trace's parent function, returns a pointer to a new + /// TraceFunction containing the same code as the Trace, along with some /// auxiliary data structures. /// - virtual TraceFunction *buildTraceFunction (Trace &T); + virtual bool runOnFunction (Function &F); }; static bool dominates (Trace &T, const BasicBlock *B1, @@ -152,8 +175,7 @@ if (BlockInst == UInst) { DEBUG (std::cerr << "TLV: " << V->getName () << " Found User" << UInst->getName () << " before Def!\n"); return false; - } - else if (BlockInst == Inst) { + } else if (BlockInst == Inst) { DEBUG (std::cerr << "TLV: " << V->getName () << " Found Def before User: " << UInst->getName () << "\n"); break; } @@ -167,8 +189,7 @@ } else { DEBUG (std::cerr << "TLV: " << V->getName () << "'s User " << UInst->getName () << " is off-trace, but we don't care\n"); } - } - else { + } else { // If UBlock appears BEFORE Block on some path from the first // basic block of the trace to an exit BB of the trace, return // false. @@ -189,8 +210,8 @@ Vector.push_back (V); } -/// addTraceLiveInsToSet - helper fn. for getTraceLiveInSet and -/// getTraceLiveOutSet. Adds the live-ins of T to S, assuming that +/// addTraceLiveInsToSet - helper fn. for buildTraceLiveInSet and +/// buildTraceLiveOutSet. Adds the live-ins of T to S, assuming that /// the trace starts at StartingFrom and ends at T.end(). static void addTraceLiveInsToSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T, Trace::iterator StartingFrom) { @@ -230,23 +251,23 @@ } } -/// getTraceLiveInSet - Initialize LiveInSet with the live-in set of the +/// buildTraceLiveInSet - Initialize LiveInSet with the live-in set of the /// trace. Any variable which is used in the trace is potentially live-in, /// EXCEPT if it's a constant or a global, OR it is defined before being used /// in the trace. /// -void TraceFunctionBuilder::getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { +void TraceFunctionBuilder::buildTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { addTraceLiveInsToSet (S, LVV, T, T.begin ()); } -/// getTraceLiveOutSet - Initializes S with the live-out set of trace T. +/// buildTraceLiveOutSet - Initializes S with the live-out set of trace T. /// Any variable defined within the trace is /// potentially live-out, EXCEPT if its only uses are in the trace AND /// come after the def. This method must also take into account side entrances /// to the NON-traced version of the code caused by early exits that end up /// taking back-edge branches. /// -void TraceFunctionBuilder::getTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { +void TraceFunctionBuilder::buildTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { // Iterate over the instructions in the trace, adding live-out values to S. for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) for (BasicBlock::iterator Inst = (*TI)->begin (), BE = (*TI)->end (); @@ -341,6 +362,7 @@ TF->MatrixFn->getParent ()); std::cerr << " is argument # " << argPosition << " (%"); TF->LiveOutToArgMap[V] = &*argIterator; + TF->ArgToLiveOutMap[&*argIterator] = V; std::string name (V->getName ()); if (name == "") name = "arg" + utostr (argPosition); @@ -630,6 +652,26 @@ return -1; } +bool +TraceFunctionBuilder::hasUseDominatedByEdge (Instruction *defInst, + BasicBlock *source, + BasicBlock *target) { + for (Value::use_iterator UI = defInst->use_begin (), UE = + defInst->use_end (); UI != UE; ++UI) { + if (Instruction *useInst = dyn_cast (*UI)) { + if (DS->dominates (&target->front(), useInst)) + return true; + } else { + // Gack, it's not an Instruction. + assert (0 && "Found non-Instruction User, don't know dominator info"); + } + } + DEBUG (std::cerr << "hasUseDominatedByEdge: found no dominated use" + << " starting from " << target->getName () << " for:\n" + << *defInst); + return false; +} + /// fixupFunctionBodyBB - Given srcB in T and its clone dstB in F, and /// the map O2CMap detailing the correspondences between values in T /// and values in F, fix up dstB so that its contents are internally @@ -723,7 +765,13 @@ for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) if (dominates (T, cast ((*SI))->getParent (), +#if 0 // WARNING: hasUseDominatedByEdge isn't working right yet! + BI->getParent ()) + && hasUseDominatedByEdge (cast (*SI), srcB, + successor)) +#else BI->getParent ())) +#endif FB->getInstList ().push_back (new StoreInst (O2CMap[*SI], TF->LiveOutToArgMap[*SI])); // Make FB contain a return instruction that returns the @@ -793,28 +841,14 @@ } } -/// cloneMapDump - Dump out the O2CMap for the given TraceFunction to stderr. -/// You can call this from the debugger if you want to see the gory details, -/// because it takes a really long time on big modules. -/// -/// FIXME: This method should probably be a method of TraceFunction, -/// not TraceFunctionBuilder. -/// -void TraceFunctionBuilder::cloneMapDump () { - std::cerr << "\n; TraceFunctionBuilder Original-->Clone map follows:\n"; - for (ValueMap::const_iterator i = TF->O2CMap.begin(), e = TF->O2CMap.end(); - i != e; ++i) { - const std::pair &elem = *i; - std::cerr << "(original-value \""; - WriteAsOperand (std::cerr, i->first, true, true, TF->MatrixFn->getParent()); - std::cerr << "\" maps-to \""; - WriteAsOperand (std::cerr, i->second, true, true, TF->TraceFn->getParent()); - std::cerr << "\")\n"; - } - std::cerr << "\n"; -} +bool TraceFunctionBuilder::runOnFunction (Function &F) { + if (T.getFunction () != &F) { return false; } + + DS = &getAnalysis(); + DEBUG (std::cerr << "Dominator set information:\n"; + DS->print (std::cerr); + std::cerr << "End dominator set information.\n"); -TraceFunction *TraceFunctionBuilder::buildTraceFunction (Trace &T) { // Create a TraceFunction object to hold the trace function along with // its auxiliary data structures. TF = new TraceFunction (T); @@ -828,8 +862,8 @@ // Get some information about the trace's relationship to its parent // function. - getTraceLiveInSet (LiveInSet, TF->LiveInVector, T); - getTraceLiveOutSet (LiveOutSet, TF->LiveOutVector, T); + buildTraceLiveInSet (LiveInSet, TF->LiveInVector, T); + buildTraceLiveOutSet (LiveOutSet, TF->LiveOutVector, T); TypeVector P = createFunctionArgTypeVector (TF->LiveInVector, TF->LiveOutVector); @@ -841,16 +875,20 @@ T.getModule ()); giveNamesToFunctionArgs (TF->LiveInVector, TF->LiveOutVector, TF->TraceFn); fillInFunctionBody (T, TF->TraceFn, TF->LiveOutVector); - return TF; + + return false; } -/// TraceFunction::get - Given a Trace, returns a TraceFunction, which is +/// BuildTraceFunction - Given a Trace, returns a TraceFunction, which is /// a Function containing the code from the Trace along with some supporting /// data structures. /// -TraceFunction *TraceFunction::get (Trace &T) { - TraceFunctionBuilder TTF; - return TTF.buildTraceFunction (T); +TraceFunction *BuildTraceFunction (Trace &T, ModuleProvider *MP) { + TraceFunctionBuilder *TTF = new TraceFunctionBuilder (T); + FunctionPassManager FPM (MP); + FPM.add (TTF); + FPM.run (*T.getFunction()); + return TTF->getTraceFunction(); } } // end namespace llvm From lattner at cs.uiuc.edu Thu Jul 15 18:15:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 18:15:14 -0500 Subject: [llvm-commits] CVS: llvm-www/www-index.html Message-ID: <200407152315.SAA12317@apoc.cs.uiuc.edu> Changes in directory llvm-www: www-index.html updated: 1.106 -> 1.107 --- Log message: Add link to the current release notes --- Diffs of the changes: (+7 -5) Index: llvm-www/www-index.html diff -u llvm-www/www-index.html:1.106 llvm-www/www-index.html:1.107 --- llvm-www/www-index.html:1.106 Thu Jun 17 15:58:35 2004 +++ llvm-www/www-index.html Thu Jul 15 18:15:04 2004 @@ -90,14 +90,16 @@ -
    Public LLVM Release!
    +
    Latest LLVM Release!

    Mar 19, 2004: LLVM 1.2 is now available - for download! LLVM is publicly available under the OSI-certified University of Illinois Open-Source - License. See answers to common - licensing questions.

    + for download! LLVM is publicly available under an open source License. Also, you might want to + check out the new + features in CVS that will appear in the next LLVM release. If + you want them early, download LLVM through + anonymous CVS.



    From lattner at cs.uiuc.edu Thu Jul 15 18:18:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 18:18:58 -0500 Subject: [llvm-commits] CVS: llvm-www/releases/index.html Message-ID: <200407152318.SAA12349@apoc.cs.uiuc.edu> Changes in directory llvm-www/releases: index.html updated: 1.18 -> 1.19 --- Log message: Add note about CVS access --- Diffs of the changes: (+3 -0) Index: llvm-www/releases/index.html diff -u llvm-www/releases/index.html:1.18 llvm-www/releases/index.html:1.19 --- llvm-www/releases/index.html:1.18 Tue May 11 21:51:02 2004 +++ llvm-www/releases/index.html Thu Jul 15 18:18:48 2004 @@ -40,6 +40,9 @@
      +
    • Always - Anonymous CVS access; release notes.
    • +
    • 19 Mar 2004 - 1.2 release download; release notes.
    • From lattner at cs.uiuc.edu Thu Jul 15 18:36:53 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 18:36:53 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200407152336.SAA12899@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: SCCP.cpp updated: 1.95 -> 1.96 --- Log message: This patch was contributed by Daniel Berlin! Speed up SCCP substantially by processing overdefined values quickly. This patch speeds up SCCP by about 30-40% on large testcases. --- Diffs of the changes: (+47 -13) Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.95 llvm/lib/Transforms/Scalar/SCCP.cpp:1.96 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.95 Wed Jul 14 20:50:47 2004 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Thu Jul 15 18:36:43 2004 @@ -31,6 +31,7 @@ #include "llvm/Support/InstVisitor.h" #include "llvm/Transforms/Utils/Local.h" #include "Support/Debug.h" +#include "Support/hash_map" #include "Support/Statistic.h" #include "Support/STLExtras.h" #include @@ -95,9 +96,19 @@ namespace { class SCCP : public FunctionPass, public InstVisitor { std::set BBExecutable;// The basic blocks that are executable - std::map ValueState; // The state each value is in... + hash_map ValueState; // The state each value is in... + // The reason for two worklists is that overdefined is the lowest state + // on the lattice, and moving things to overdefined as fast as possible + // makes SCCP converge much faster. + // By having a separate worklist, we accomplish this because everything + // possibly overdefined will become overdefined at the soonest possible + // point. + std::vector OverdefinedInstWorkList;// The overdefined + // instruction work list std::vector InstWorkList;// The instruction work list + + std::vector BBWorkList; // The BasicBlock work list /// UsersOfOverdefinedPHIs - Keep track of any users of PHI nodes that are not @@ -126,7 +137,7 @@ private: friend class InstVisitor; // Allow callbacks from visitor - // markValueOverdefined - Make a value be marked as "constant". If the value + // markConstant - Make a value be marked as "constant". If the value // is not already a constant, add it to the instruction work list so that // the users of the instruction are updated later. // @@ -140,14 +151,14 @@ markConstant(ValueState[I], I, C); } - // markValueOverdefined - Make a value be marked as "overdefined". If the - // value is not already overdefined, add it to the instruction work list so - // that the users of the instruction are updated later. - // + // markOverdefined - Make a value be marked as "overdefined". If the + // value is not already overdefined, add it to the overdefined instruction + // work list so that the users of the instruction are updated later. + inline void markOverdefined(InstVal &IV, Instruction *I) { if (IV.markOverdefined()) { DEBUG(std::cerr << "markOverdefined: " << *I); - InstWorkList.push_back(I); // Only instructions go on the work list + OverdefinedInstWorkList.push_back(I); // Only instructions go on the work list } } inline void markOverdefined(Instruction *I) { @@ -161,7 +172,7 @@ // Instruction object, then use this accessor to get its value from the map. // inline InstVal &getValueState(Value *V) { - std::map::iterator I = ValueState.find(V); + hash_map::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map if (Constant *CPV = dyn_cast(V)) { // Constants are constant @@ -282,8 +293,26 @@ BBExecutable.insert(F.begin()); // Basic block is executable! BBWorkList.push_back(F.begin()); // Add the block to the work list! - // Process the work lists until their are empty! - while (!BBWorkList.empty() || !InstWorkList.empty()) { + // Process the work lists until they are empty! + while (!BBWorkList.empty() || !InstWorkList.empty() || + !OverdefinedInstWorkList.empty()) { + // Process the instruction work list... + while (!OverdefinedInstWorkList.empty()) { + Instruction *I = OverdefinedInstWorkList.back(); + OverdefinedInstWorkList.pop_back(); + + DEBUG(std::cerr << "\nPopped off OI-WL: " << I); + + // "I" got into the work list because it either made the transition from + // bottom to constant + // + // Anything on this worklist that is overdefined need not be visited + // since all of its users will have already been marked as overdefined + // Update all of the users of this instruction's value... + // + for_each(I->use_begin(), I->use_end(), + bind_obj(this, &SCCP::OperandChangedState)); + } // Process the instruction work list... while (!InstWorkList.empty()) { Instruction *I = InstWorkList.back(); @@ -292,12 +321,16 @@ DEBUG(std::cerr << "\nPopped off I-WL: " << *I); // "I" got into the work list because it either made the transition from - // bottom to constant, or to Overdefined. + // bottom to constant // + // Anything on this worklist that is overdefined need not be visited + // since all of its users will have already been marked as overdefined. // Update all of the users of this instruction's value... // - for_each(I->use_begin(), I->use_end(), - bind_obj(this, &SCCP::OperandChangedState)); + InstVal &Ival = getValueState (I); + if (!Ival.isOverdefined()) + for_each(I->use_begin(), I->use_end(), + bind_obj(this, &SCCP::OperandChangedState)); } // Process the basic block work list... @@ -348,6 +381,7 @@ // Reset state so that the next invocation will have empty data structures BBExecutable.clear(); ValueState.clear(); + std::vector().swap(OverdefinedInstWorkList); std::vector().swap(InstWorkList); std::vector().swap(BBWorkList); From lattner at cs.uiuc.edu Thu Jul 15 19:01:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:01:15 -0500 Subject: [llvm-commits] CVS: llvm/include/Support/CommandLine.h Message-ID: <200407160001.TAA12972@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: CommandLine.h updated: 1.33 -> 1.34 --- Log message: Add a new macro to be used for the end of enum lists. --- Diffs of the changes: (+1 -0) Index: llvm/include/Support/CommandLine.h diff -u llvm/include/Support/CommandLine.h:1.33 llvm/include/Support/CommandLine.h:1.34 --- llvm/include/Support/CommandLine.h:1.33 Sat Jul 10 22:18:30 2004 +++ llvm/include/Support/CommandLine.h Thu Jul 15 19:01:05 2004 @@ -292,6 +292,7 @@ // #define clEnumVal(ENUMVAL, DESC) #ENUMVAL, (int)ENUMVAL, DESC #define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, (int)ENUMVAL, DESC +#define clEnumValEnd ((void*)0) // values - For custom data types, allow specifying a group of values together // as the values that go into the mapping that the option handler uses. Note From lattner at cs.uiuc.edu Thu Jul 15 19:02:31 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:02:31 -0500 Subject: [llvm-commits] CVS: llvm/utils/TableGen/TableGen.cpp Message-ID: <200407160002.TAA13377@apoc.cs.uiuc.edu> Changes in directory llvm/utils/TableGen: TableGen.cpp updated: 1.28 -> 1.29 --- Log message: Passing integer 0 in for a pointer value doesn't work on IA64. Fix this by using a new macro. --- Diffs of the changes: (+1 -1) Index: llvm/utils/TableGen/TableGen.cpp diff -u llvm/utils/TableGen/TableGen.cpp:1.28 llvm/utils/TableGen/TableGen.cpp:1.29 --- llvm/utils/TableGen/TableGen.cpp:1.28 Tue Jul 13 01:11:46 2004 +++ llvm/utils/TableGen/TableGen.cpp Thu Jul 15 19:02:21 2004 @@ -64,7 +64,7 @@ "Print enum values for a class"), clEnumValN(Parse, "parse", "Interpret machine code (testing only)"), - 0)); + clEnumValEnd)); cl::opt Class("class", cl::desc("Print Enum list for this class"), From lattner at cs.uiuc.edu Thu Jul 15 19:04:23 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:04:23 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/GraphChecker.cpp Message-ID: <200407160004.TAA15237@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: GraphChecker.cpp updated: 1.14 -> 1.15 --- Log message: Be compatible with IA64 --- Diffs of the changes: (+2 -1) Index: llvm/lib/Analysis/DataStructure/GraphChecker.cpp diff -u llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.14 llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.15 --- llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.14 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/GraphChecker.cpp Thu Jul 15 19:04:13 2004 @@ -39,7 +39,8 @@ cl::desc("Specify which DSA pass the -datastructure-gc pass should use"), cl::values(clEnumVal(local, "Local pass"), clEnumVal(bu, "Bottom-up pass"), - clEnumVal(td, "Top-down pass"), 0), cl::init(local)); + clEnumVal(td, "Top-down pass"), + clEnumValEnd), cl::init(local)); cl::opt AbortIfAnyCollapsed("dsgc-abort-if-any-collapsed", cl::Hidden, From lattner at cs.uiuc.edu Thu Jul 15 19:05:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:05:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Message-ID: <200407160005.TAA15408@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen/InstrSched: InstrScheduling.cpp updated: 1.72 -> 1.73 --- Log message: Use new macro --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp diff -u llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.72 llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.73 --- llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp:1.72 Sun Jul 4 07:19:56 2004 +++ llvm/lib/CodeGen/InstrSched/InstrScheduling.cpp Thu Jul 15 19:04:54 2004 @@ -38,7 +38,7 @@ clEnumValN(Sched_PrintMachineCode, "y", "print machine code after scheduling"), clEnumValN(Sched_PrintSchedTrace, "t", "print trace of scheduling actions"), clEnumValN(Sched_PrintSchedGraphs, "g", "print scheduling graphs"), - 0)); + clEnumValEnd)); //************************* Internal Data Types *****************************/ From lattner at cs.uiuc.edu Thu Jul 15 19:06:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:06:12 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/VirtRegMap.cpp Passes.cpp Message-ID: <200407160006.TAA15924@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: VirtRegMap.cpp updated: 1.14 -> 1.15 Passes.cpp updated: 1.6 -> 1.7 --- Log message: Fix IA64 compatibility --- Diffs of the changes: (+2 -2) Index: llvm/lib/CodeGen/VirtRegMap.cpp diff -u llvm/lib/CodeGen/VirtRegMap.cpp:1.14 llvm/lib/CodeGen/VirtRegMap.cpp:1.15 --- llvm/lib/CodeGen/VirtRegMap.cpp:1.14 Thu Jun 24 19:13:11 2004 +++ llvm/lib/CodeGen/VirtRegMap.cpp Thu Jul 15 19:06:01 2004 @@ -44,7 +44,7 @@ cl::Prefix, cl::values(clEnumVal(simple, " simple spiller"), clEnumVal(local, " local spiller"), - 0), + clEnumValEnd), cl::init(local)); } Index: llvm/lib/CodeGen/Passes.cpp diff -u llvm/lib/CodeGen/Passes.cpp:1.6 llvm/lib/CodeGen/Passes.cpp:1.7 --- llvm/lib/CodeGen/Passes.cpp:1.6 Mon Mar 1 17:18:15 2004 +++ llvm/lib/CodeGen/Passes.cpp Thu Jul 15 19:06:01 2004 @@ -27,7 +27,7 @@ cl::values(clEnumVal(simple, " simple register allocator"), clEnumVal(local, " local register allocator"), clEnumVal(linearscan, " linear scan register allocator (experimental)"), - 0), + clEnumValEnd), cl::init(local)); } From lattner at cs.uiuc.edu Thu Jul 15 19:06:36 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:06:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Message-ID: <200407160006.TAA15936@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrSelection.cpp updated: 1.82 -> 1.83 --- Log message: IA64 compat --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.82 llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.83 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp:1.82 Wed Jul 14 00:40:50 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp Thu Jul 15 19:06:26 2004 @@ -57,7 +57,7 @@ clEnumValN(Select_DebugInstTrees, "i", "print debugging info for instruction selection"), clEnumValN(Select_DebugBurgTrees, "b", "print burg trees"), - 0)); + clEnumValEnd)); //===--------------------------------------------------------------------===// From lattner at cs.uiuc.edu Thu Jul 15 19:07:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:07:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp Message-ID: <200407160007.TAA15948@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/LiveVar: FunctionLiveVarInfo.cpp updated: 1.56 -> 1.57 --- Log message: IA64 compat --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp diff -u llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.56 llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.57 --- llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp:1.56 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp Thu Jul 15 19:06:54 2004 @@ -40,7 +40,7 @@ clEnumValN(LV_DEBUG_Instr, "i", "print live-var sets before/after " "every machine instrn"), clEnumValN(LV_DEBUG_Verbose, "v", "print def, use sets for every instrn also"), - 0)); + clEnumValEnd)); From lattner at cs.uiuc.edu Thu Jul 15 19:07:31 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:07:31 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Message-ID: <200407160007.TAA15961@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/RegAlloc: PhyRegAlloc.cpp updated: 1.152 -> 1.153 --- Log message: IA64 compat --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.152 llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.153 --- llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.152 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Thu Jul 15 19:07:21 2004 @@ -63,7 +63,7 @@ clEnumValN(RA_DEBUG_Interference,"ig","debug output for interference graphs"), clEnumValN(RA_DEBUG_LiveRanges , "lr","debug output for live ranges"), clEnumValN(RA_DEBUG_Verbose, "v", "extra debug output"), - 0)); + clEnumValEnd)); /// The reoptimizer wants to be able to grovel through the register /// allocator's state after it has done its job. This is a hack. From lattner at cs.uiuc.edu Thu Jul 15 19:07:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:07:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/PassManagerT.h Message-ID: <200407160007.TAA15974@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: PassManagerT.h updated: 1.49 -> 1.50 --- Log message: IA64 compat --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/PassManagerT.h diff -u llvm/lib/VMCore/PassManagerT.h:1.49 llvm/lib/VMCore/PassManagerT.h:1.50 --- llvm/lib/VMCore/PassManagerT.h:1.49 Fri Jun 4 15:48:51 2004 +++ llvm/lib/VMCore/PassManagerT.h Thu Jul 15 19:07:44 2004 @@ -52,7 +52,7 @@ clEnumVal(Structure , "print pass structure before run()"), clEnumVal(Executions, "print pass name before it is executed"), clEnumVal(Details , "print pass details when it is executed"), - 0)); + clEnumValEnd)); //===----------------------------------------------------------------------===// // PMDebug class - a set of debugging functions, that are not to be From lattner at cs.uiuc.edu Thu Jul 15 19:08:14 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:08:14 -0500 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/ExecutionDriver.cpp Message-ID: <200407160008.TAA15986@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: ExecutionDriver.cpp updated: 1.43 -> 1.44 --- Log message: IA64 compat --- Diffs of the changes: (+1 -1) Index: llvm/tools/bugpoint/ExecutionDriver.cpp diff -u llvm/tools/bugpoint/ExecutionDriver.cpp:1.43 llvm/tools/bugpoint/ExecutionDriver.cpp:1.44 --- llvm/tools/bugpoint/ExecutionDriver.cpp:1.43 Thu May 6 17:05:35 2004 +++ llvm/tools/bugpoint/ExecutionDriver.cpp Thu Jul 15 19:08:04 2004 @@ -38,7 +38,7 @@ clEnumValN(RunJIT, "run-jit", "Execute with JIT"), clEnumValN(RunLLC, "run-llc", "Compile with LLC"), clEnumValN(RunCBE, "run-cbe", "Compile with CBE"), - 0), + clEnumValEnd), cl::init(AutoPick)); cl::opt From lattner at cs.uiuc.edu Thu Jul 15 19:08:38 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:08:38 -0500 Subject: [llvm-commits] CVS: llvm/tools/llvm-nm/llvm-nm.cpp Message-ID: <200407160008.TAA15997@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-nm: llvm-nm.cpp updated: 1.15 -> 1.16 --- Log message: IA64 compat --- Diffs of the changes: (+2 -1) Index: llvm/tools/llvm-nm/llvm-nm.cpp diff -u llvm/tools/llvm-nm/llvm-nm.cpp:1.15 llvm/tools/llvm-nm/llvm-nm.cpp:1.16 --- llvm/tools/llvm-nm/llvm-nm.cpp:1.15 Sun Jul 4 07:20:55 2004 +++ llvm/tools/llvm-nm/llvm-nm.cpp Thu Jul 15 19:08:28 2004 @@ -35,7 +35,8 @@ cl::desc("Specify output format"), cl::values(clEnumVal(bsd, "BSD format"), clEnumVal(sysv, "System V format"), - clEnumVal(posix, "POSIX.2 format"), 0), cl::init(bsd)); + clEnumVal(posix, "POSIX.2 format"), + clEnumValEnd), cl::init(bsd)); cl::alias OutputFormat2("f", cl::desc("Alias for --format"), cl::aliasopt(OutputFormat)); From lattner at cs.uiuc.edu Thu Jul 15 19:09:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:09:20 -0500 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200407160009.TAA16013@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.70 -> 1.71 --- Log message: IA64 support --- Diffs of the changes: (+1 -1) Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.70 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.71 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.70 Wed Jul 7 01:22:54 2004 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Thu Jul 15 19:09:10 2004 @@ -68,7 +68,7 @@ clEnumVal(CyclicNodes, " Pool allocate nodes with cycles"), clEnumVal(SmartCoallesceNodes, " Use the smart node merging heuristic"), clEnumVal(NoNodes, " Do not pool allocate anything"), - 0), + clEnumValEnd), cl::init(SmartCoallesceNodes)); cl::opt From lattner at cs.uiuc.edu Thu Jul 15 19:11:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 19:11:04 -0500 Subject: [llvm-commits] CVS: llvm/docs/CommandLine.html Message-ID: <200407160011.TAA16040@apoc.cs.uiuc.edu> Changes in directory llvm/docs: CommandLine.html updated: 1.22 -> 1.23 --- Log message: For 64-bit platform support, we now use the clEnumValEnd macro to terminate cl::values lists --- Diffs of the changes: (+9 -7) Index: llvm/docs/CommandLine.html diff -u llvm/docs/CommandLine.html:1.22 llvm/docs/CommandLine.html:1.23 --- llvm/docs/CommandLine.html:1.22 Sun May 23 16:07:26 2004 +++ llvm/docs/CommandLine.html Thu Jul 15 19:10:54 2004 @@ -493,7 +493,7 @@ clEnumVal(O1, "Enable trivial optimizations"), clEnumVal(O2, "Enable default optimizations"), clEnumVal(O3, "Enable expensive optimizations"), - 0)); + clEnumValEnd)); ... if (OptimizationLevel >= O2) doPartialRedundancyElimination(...); @@ -503,7 +503,8 @@

      This declaration defines a variable "OptimizationLevel" of the "OptLevel" enum type. This variable can be assigned any of the values that are listed in the declaration (Note that the declaration list must be -terminated with the "0" argument!). The CommandLine library enforces +terminated with the "clEnumValEnd" argument!). The CommandLine +library enforces that the user can only specify one of the options, and it ensure that only valid enum values can be specified. The "clEnumVal" macros ensure that the command line arguments matched the enum values. With this option added, our @@ -540,7 +541,7 @@ clEnumVal(O1 , "Enable trivial optimizations"), clEnumVal(O2 , "Enable default optimizations"), clEnumVal(O3 , "Enable expensive optimizations"), - 0)); + clEnumValEnd)); ... if (OptimizationLevel == Debug) outputDebugInfo(...); @@ -581,7 +582,7 @@ clEnumValN(nodebuginfo, "none", "disable debug information"), clEnumVal(quick, "enable quick debug information"), clEnumVal(detailed, "enable detailed debug information"), - 0)); + clEnumValEnd));

      This definition defines an enumerated command line variable of type "enum @@ -648,7 +649,7 @@ clEnumVal(constprop , "Constant Propagation"), clEnumValN(inlining, "inline", "Procedure Integration"), clEnumVal(strip , "Strip Symbols"), - 0)); + clEnumValEnd));

      This defines a variable that is conceptually of the type @@ -998,7 +999,8 @@

    • The cl::values attribute specifies the string-to-value mapping to be used by the generic parser. It takes a -null terminated list of (option, value, description) triplets that +clEnumValEnd terminated list of (option, value, description) triplets +that specify the option name, the value mapped to, and the description shown in the --help for the tool. Because the generic parser is used most frequently with enum values, two macros are often useful: @@ -1707,7 +1709,7 @@ Chris Lattner
      LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/05/23 21:07:26 $ + Last modified: $Date: 2004/07/16 00:10:54 $ From lattner at cs.uiuc.edu Thu Jul 15 20:18:20 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu, 15 Jul 2004 20:18:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407160118.UAA31550@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.189 -> 1.190 --- Log message: Fix the regressions handling unnamed global variables --- Diffs of the changes: (+5 -2) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.189 llvm/lib/AsmParser/llvmAsmParser.y:1.190 --- llvm/lib/AsmParser/llvmAsmParser.y:1.189 Wed Jul 14 18:07:13 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Jul 15 20:18:09 2004 @@ -561,6 +561,7 @@ GV->setInitializer(Initializer); GV->setLinkage(Linkage); GV->setConstant(isConstantGlobal); + InsertValue(GV, CurModule.Values); return; } @@ -595,8 +596,10 @@ } // Otherwise there is no existing GV to use, create one now. - new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, - CurModule.CurrentModule); + GlobalVariable *GV = + new GlobalVariable(Ty, isConstantGlobal, Linkage, Initializer, Name, + CurModule.CurrentModule); + InsertValue(GV, CurModule.Values); } // setTypeName - Set the specified type to the name given. The name may be From lattner at cs.uiuc.edu Fri Jul 16 01:12:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:12:15 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Skeleton/ Message-ID: <200407160612.BAA01525@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Skeleton: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/lib/Target/Skeleton added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Jul 16 01:12:38 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:12:38 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Skeleton/README.txt Message-ID: <200407160612.BAA01538@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Skeleton: README.txt added (r1.1) --- Log message: Initial readme --- Diffs of the changes: (+19 -0) Index: llvm/lib/Target/Skeleton/README.txt diff -c /dev/null llvm/lib/Target/Skeleton/README.txt:1.1 *** /dev/null Fri Jul 16 01:12:38 2004 --- llvm/lib/Target/Skeleton/README.txt Fri Jul 16 01:12:28 2004 *************** *** 0 **** --- 1,19 ---- + LLVM Target Skeleton + -------------------- + + This directory contains a very simple skeleton that can be used as the + starting point for new LLVM targets. Basically you can take this code + and start filling stuff in. + + This directory contains mainly stubs and placeholders; there is no binary + machine code emitter, no assembly writer, and no instruction selector + here. Most of the functions in these files call abort() or fail assertions + on purpose, just to reinforce the fact that they don't work. + + The things that are implemented are stubbed out in a pseudo-PowerPC target. + This should give you an idea of what to do, but anything implemented should + be replaced with your target details. + + As always, if you're starting a new port, please mention it on the llvmdev + list, and if you have questions, that is a great place to ask. + From lattner at cs.uiuc.edu Fri Jul 16 01:21:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:21:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Skeleton/Makefile Message-ID: <200407160621.BAA01841@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Skeleton: Makefile added (r1.1) --- Log message: Add skeleton makefile --- Diffs of the changes: (+44 -0) Index: llvm/lib/Target/Skeleton/Makefile diff -c /dev/null llvm/lib/Target/Skeleton/Makefile:1.1 *** /dev/null Fri Jul 16 01:21:06 2004 --- llvm/lib/Target/Skeleton/Makefile Fri Jul 16 01:20:55 2004 *************** *** 0 **** --- 1,44 ---- + ##===- lib/Target/Skeleton/Makefile ------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by the LLVM research group and is distributed under + # the University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + + LEVEL = ../../.. + LIBRARYNAME = skeleton + include $(LEVEL)/Makefile.common + + TARGET = Skeleton + TDFILES = $(wildcard $(SourceDir)/*.td) $(SourceDir)/../Target.td + + + # Make sure that tblgen is run, first thing. + $(SourceDepend): $(TARGET)GenRegisterInfo.h.inc $(TARGET)GenRegisterNames.inc \ + $(TARGET)GenRegisterInfo.inc $(TARGET)GenInstrNames.inc \ + $(TARGET)GenInstrInfo.inc + + $(TARGET)GenRegisterNames.inc:: $(TDFILES) $(TBLGEN) + @echo "Building $(TARGET).td register names with tblgen" + $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-register-enums -o $@ + + $(TARGET)GenRegisterInfo.h.inc:: $(TDFILES) $(TBLGEN) + @echo "Building $(TARGET).td register information header with tblgen" + $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-register-desc-header -o $@ + + $(TARGET)GenRegisterInfo.inc:: $(TDFILES) $(TBLGEN) + @echo "Building $(TARGET).td register information implementation with tblgen" + $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-register-desc -o $@ + + $(TARGET)GenInstrNames.inc:: $(TDFILES) $(TBLGEN) + @echo "Building $(TARGET).td instruction names with tblgen" + $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-instr-enums -o $@ + + $(TARGET)GenInstrInfo.inc:: $(TDFILES) $(TBLGEN) + @echo "Building $(TARGET).td instruction information with tblgen" + $(VERB) $(TBLGEN) -I $(BUILD_SRC_DIR) $< -gen-instr-desc -o $@ + + clean:: + $(VERB) rm -f *.inc From lattner at cs.uiuc.edu Fri Jul 16 01:29:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:29:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Skeleton/SkeletonInstrInfo.td SkeletonRegisterInfo.td Skeleton.td Message-ID: <200407160629.BAA02092@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Skeleton: SkeletonInstrInfo.td added (r1.1) SkeletonRegisterInfo.td added (r1.1) Skeleton.td added (r1.1) --- Log message: Initial skeleton tablegen files --- Diffs of the changes: (+165 -0) Index: llvm/lib/Target/Skeleton/SkeletonInstrInfo.td diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonInstrInfo.td:1.1 *** /dev/null Fri Jul 16 01:29:29 2004 --- llvm/lib/Target/Skeleton/SkeletonInstrInfo.td Fri Jul 16 01:29:19 2004 *************** *** 0 **** --- 1,39 ---- + //===- SkeletonInstrInfo.td - Describe the Instruction Set ------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // Skeleton instruction information. Fill in stuff here. + // + //===----------------------------------------------------------------------===// + + class Format val> { + bits<4> Value = val; + } + + // All of the PowerPC instruction formats, plus a pseudo-instruction format: + def Pseudo : Format<0>; + def IForm : Format<1>; + def BForm : Format<2>; + + // Look at how other targets factor commonality between instructions. + class SkelInst opcd, Format f> : Instruction { + let Namespace = "Skeleton"; + + let Name = nm; + bits<6> Opcode = opcd; + Format Form = f; + bits<4> FormBits = Form.Value; + } + + // Pseudo-instructions: + def PHI : SkelInst<"PHI", 0, Pseudo>; // PHI node... + def NOP : SkelInst<"NOP", 0, Pseudo>; // No-op + def ADJCALLSTACKDOWN : SkelInst<"ADJCALLSTACKDOWN", 0, Pseudo>; + def ADJCALLSTACKUP : SkelInst<"ADJCALLSTACKUP", 0, Pseudo>; + + Index: llvm/lib/Target/Skeleton/SkeletonRegisterInfo.td diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonRegisterInfo.td:1.1 *** /dev/null Fri Jul 16 01:29:29 2004 --- llvm/lib/Target/Skeleton/SkeletonRegisterInfo.td Fri Jul 16 01:29:19 2004 *************** *** 0 **** --- 1,86 ---- + //===- SkeletonRegisterInfo.td - Describe the Register File -----*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file defines the target's register file in Tablegen format. + // + //===----------------------------------------------------------------------===// + + class SkelReg : Register { + let Namespace = "Skeleton"; + } + + // This is roughly the PPC register file. You should replace all of this with + // whatever your target needs. + + + // GPR - One of the 32 32-bit general-purpose registers + class GPR num> : SkelReg { + field bits<5> Num = num; + } + + // SPR - One of the 32-bit special-purpose registers + class SPR num> : SkelReg { + field bits<5> Num = num; + } + + // FPR - One of the 32 64-bit floating-point registers + class FPR num> : SkelReg { + field bits<5> Num = num; + } + + // CR - One of the 8 4-bit condition registers + class CR num> : SkelReg { + field bits<5> Num = num; + } + + // General-purpose registers + def R0 : GPR< 0>; def R1 : GPR< 1>; def R2 : GPR< 2>; def R3 : GPR< 3>; + def R4 : GPR< 4>; def R5 : GPR< 5>; def R6 : GPR< 6>; def R7 : GPR< 7>; + def R8 : GPR< 8>; def R9 : GPR< 9>; def R10 : GPR<10>; def R11 : GPR<11>; + def R12 : GPR<12>; def R13 : GPR<13>; def R14 : GPR<14>; def R15 : GPR<15>; + def R16 : GPR<16>; def R17 : GPR<17>; def R18 : GPR<18>; def R19 : GPR<19>; + def R20 : GPR<20>; def R21 : GPR<21>; def R22 : GPR<22>; def R23 : GPR<23>; + def R24 : GPR<24>; def R25 : GPR<25>; def R26 : GPR<26>; def R27 : GPR<27>; + def R28 : GPR<28>; def R29 : GPR<29>; def R30 : GPR<30>; def R31 : GPR<31>; + + // Floating-point registers + def F0 : FPR< 0>; def F1 : FPR< 1>; def F2 : FPR< 2>; def F3 : FPR< 3>; + def F4 : FPR< 4>; def F5 : FPR< 5>; def F6 : FPR< 6>; def F7 : FPR< 7>; + def F8 : FPR< 8>; def F9 : FPR< 9>; def F10 : FPR<10>; def F11 : FPR<11>; + def F12 : FPR<12>; def F13 : FPR<13>; def F14 : FPR<14>; def F15 : FPR<15>; + def F16 : FPR<16>; def F17 : FPR<17>; def F18 : FPR<18>; def F19 : FPR<19>; + def F20 : FPR<20>; def F21 : FPR<21>; def F22 : FPR<22>; def F23 : FPR<23>; + def F24 : FPR<24>; def F25 : FPR<25>; def F26 : FPR<26>; def F27 : FPR<27>; + def F28 : FPR<28>; def F29 : FPR<29>; def F30 : FPR<30>; def F31 : FPR<31>; + + // Condition registers + def CR0 : CR<0>; def CR1 : CR<1>; def CR2 : CR<2>; def CR3 : CR<3>; + def CR4 : CR<4>; def CR5 : CR<5>; def CR6 : CR<6>; def CR7 : CR<7>; + + // Floating-point status and control register + def FPSCR : SPR<0>; + // fiXed-point Exception Register? :-) + def XER : SPR<1>; + // Link register + def LR : SPR<2>; + // Count register + def CTR : SPR<3>; + // These are the "time base" registers which are read-only in user mode. + def TBL : SPR<4>; + def TBU : SPR<5>; + + /// Register classes: one for floats and another for non-floats. + /// + def GPRC : RegisterClass; + def FPRC : RegisterClass; + Index: llvm/lib/Target/Skeleton/Skeleton.td diff -c /dev/null llvm/lib/Target/Skeleton/Skeleton.td:1.1 *** /dev/null Fri Jul 16 01:29:29 2004 --- llvm/lib/Target/Skeleton/Skeleton.td Fri Jul 16 01:29:19 2004 *************** *** 0 **** --- 1,40 ---- + //===- PowerPC.td - Describe the PowerPC Target Machine ---------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // + //===----------------------------------------------------------------------===// + + // Get the target-independent interfaces which we are implementing... + // + include "../Target.td" + + //===----------------------------------------------------------------------===// + // Register File Description + //===----------------------------------------------------------------------===// + + include "SkeletonRegisterInfo.td" + include "SkeletonInstrInfo.td" + + def SkeletonInstrInfo : InstrInfo { + let PHIInst = PHI; + } + + def PowerPC : Target { + // Pointers are 32-bits in size. + let PointerType = i32; + + // Registers that must be saved by a function call go here. + let CalleeSavedRegisters = [R1, R13, R14, R15, R16, R17, R18, R19, + R20, R21, R22, R23, R24, R25, R26, R27, R28, R29, R30, R31, F14, F15, + F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, + F30, F31, CR2, CR3, CR4]; + + // Pull in Instruction Info: + let InstructionSet = SkeletonInstrInfo; + } From lattner at cs.uiuc.edu Fri Jul 16 01:44:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:44:21 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/config/ia64/t-ia64 Message-ID: <200407160644.BAA02695@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/config/ia64: t-ia64 updated: 1.1.1.1 -> 1.2 --- Log message: First attempt at ia64 support --- Diffs of the changes: (+24 -24) Index: llvm-gcc/gcc/config/ia64/t-ia64 diff -u llvm-gcc/gcc/config/ia64/t-ia64:1.1.1.1 llvm-gcc/gcc/config/ia64/t-ia64:1.2 --- llvm-gcc/gcc/config/ia64/t-ia64:1.1.1.1 Thu Jan 8 15:58:50 2004 +++ llvm-gcc/gcc/config/ia64/t-ia64 Fri Jul 16 01:44:11 2004 @@ -1,14 +1,14 @@ -LIB1ASMSRC = ia64/lib1funcs.asm +#LIB1ASMSRC = ia64/lib1funcs.asm # We use different names for the DImode div/mod files so that they won't # conflict with libgcc2.c files. We used to use __ia64 as a prefix, now # we use __ as the prefix. Note that L_divdi3 in libgcc2.c actually defines # a TImode divide function, so there is no actual overlap here between # libgcc2.c and lib1funcs.asm. -LIB1ASMFUNCS = __divtf3 __divdf3 __divsf3 \ - __divdi3 __moddi3 __udivdi3 __umoddi3 \ - __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \ - __nonlocal_goto __restore_stack_nonlocal __trampoline +#LIB1ASMFUNCS = __divtf3 __divdf3 __divsf3 \ +# __divdi3 __moddi3 __udivdi3 __umoddi3 \ +# __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \ +# __nonlocal_goto __restore_stack_nonlocal __trampoline # ??? Hack to get -P option used when compiling lib1funcs.asm, because Intel # assembler does not accept # line number as a comment. @@ -17,31 +17,31 @@ # to support the Intel assembler. #LIBGCC2_DEBUG_CFLAGS = -g1 -P -SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64.ver +#SHLIB_MAPFILES += $(srcdir)/config/ia64/libgcc-ia64.ver # Effectively disable the crtbegin/end rules using crtstuff.c T = disable # Assemble startup files. -crtbegin.o: $(srcdir)/config/ia64/crtbegin.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -I. -c -o crtbegin.o -x assembler-with-cpp \ - $(srcdir)/config/ia64/crtbegin.asm -crtend.o: $(srcdir)/config/ia64/crtend.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -I. -c -o crtend.o -x assembler-with-cpp \ - $(srcdir)/config/ia64/crtend.asm -crtbeginS.o: $(srcdir)/config/ia64/crtbegin.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -I. -DSHARED -c -o crtbeginS.o \ - -x assembler-with-cpp \ - $(srcdir)/config/ia64/crtbegin.asm -crtendS.o: $(srcdir)/config/ia64/crtend.asm $(GCC_PASSES) - $(GCC_FOR_TARGET) -I. -DSHARED -c -o crtendS.o -x assembler-with-cpp \ - $(srcdir)/config/ia64/crtend.asm -crtfastmath.o: $(srcdir)/config/ia64/crtfastmath.c $(GCC_PASSES) - $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -c -o crtfastmath.o \ - $(srcdir)/config/ia64/crtfastmath.c +#crtbegin.o: $(srcdir)/config/ia64/crtbegin.asm $(GCC_PASSES) +# $(GCC_FOR_TARGET) -I. -c -o crtbegin.o -x assembler-with-cpp \ +# $(srcdir)/config/ia64/crtbegin.asm +#crtend.o: $(srcdir)/config/ia64/crtend.asm $(GCC_PASSES) +# $(GCC_FOR_TARGET) -I. -c -o crtend.o -x assembler-with-cpp \ +# $(srcdir)/config/ia64/crtend.asm +#crtbeginS.o: $(srcdir)/config/ia64/crtbegin.asm $(GCC_PASSES) +# $(GCC_FOR_TARGET) -I. -DSHARED -c -o crtbeginS.o \ +# -x assembler-with-cpp \ +# $(srcdir)/config/ia64/crtbegin.asm +#crtendS.o: $(srcdir)/config/ia64/crtend.asm $(GCC_PASSES) +# $(GCC_FOR_TARGET) -I. -DSHARED -c -o crtendS.o -x assembler-with-cpp \ +# $(srcdir)/config/ia64/crtend.asm +#crtfastmath.o: $(srcdir)/config/ia64/crtfastmath.c $(GCC_PASSES) +# $(GCC_FOR_TARGET) $(LIBGCC2_CFLAGS) -c -o crtfastmath.o \ +# $(srcdir)/config/ia64/crtfastmath.c -LIB2ADDEH = $(srcdir)/config/ia64/unwind-ia64.c $(srcdir)/unwind-sjlj.c \ - $(srcdir)/unwind-c.c +#LIB2ADDEH = $(srcdir)/config/ia64/unwind-ia64.c $(srcdir)/unwind-sjlj.c \ +# $(srcdir)/unwind-c.c ia64-c.o: $(srcdir)/config/ia64/ia64-c.c $(CONFIG_H) $(SYSTEM_H) \ coretypes.h $(TM_H) $(TREE_H) $(CPPLIB_H) $(C_COMMON_H) c-pragma.h toplev.h From lattner at cs.uiuc.edu Fri Jul 16 01:49:35 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 01:49:35 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/config/ia64/linux.h Message-ID: <200407160649.BAA02725@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/config/ia64: linux.h updated: 1.1.1.1 -> 1.2 --- Log message: Hack out more stuff --- Diffs of the changes: (+10 -4) Index: llvm-gcc/gcc/config/ia64/linux.h diff -u llvm-gcc/gcc/config/ia64/linux.h:1.1.1.1 llvm-gcc/gcc/config/ia64/linux.h:1.2 --- llvm-gcc/gcc/config/ia64/linux.h:1.1.1.1 Thu Jan 8 15:58:50 2004 +++ llvm-gcc/gcc/config/ia64/linux.h Fri Jul 16 01:49:25 2004 @@ -6,8 +6,10 @@ #define TARGET_VERSION fprintf (stderr, " (IA-64) Linux"); /* This is for -profile to use -lc_p instead of -lc. */ +/* #undef CC1_SPEC #define CC1_SPEC "%{profile:-p} %{G*}" +*/ /* Target OS builtins. */ #define TARGET_OS_CPP_BUILTINS() \ @@ -20,6 +22,7 @@ } while (0) /* Need to override linux.h STARTFILE_SPEC, since it has crtbeginT.o in. */ +/* #undef STARTFILE_SPEC #ifdef HAVE_LD_PIE #define STARTFILE_SPEC \ @@ -30,16 +33,18 @@ "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}}\ crti.o%s %{shared|pie:crtbeginS.o%s;:crtbegin.o%s}" #endif - +*/ /* Similar to standard Linux, but adding -ffast-math support. */ +/* #undef ENDFILE_SPEC #define ENDFILE_SPEC \ "%{ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \ %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" +*/ /* Define this for shared library support because it isn't in the main linux.h file. */ - +/* #undef LINK_SPEC #define LINK_SPEC "\ %{shared:-shared} \ @@ -48,7 +53,7 @@ %{rdynamic:-export-dynamic} \ %{!dynamic-linker:-dynamic-linker /lib/ld-linux-ia64.so.2}} \ %{static:-static}}" - +*/ #define JMP_BUF_SIZE 76 @@ -60,7 +65,7 @@ /* Do code reading to identify a signal frame, and set the frame state data appropriately. See unwind-dw2.c for the structs. */ - +#if 0 #ifdef IN_LIBGCC2 #include #include @@ -124,3 +129,4 @@ goto SUCCESS; \ } #endif /* IN_LIBGCC2 */ +#endif From lattner at cs.uiuc.edu Fri Jul 16 02:11:28 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:11:28 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Skeleton/Skeleton.h SkeletonInstrInfo.cpp SkeletonInstrInfo.h SkeletonJITInfo.cpp SkeletonJITInfo.h SkeletonRegisterInfo.cpp SkeletonRegisterInfo.h SkeletonTargetMachine.cpp SkeletonTargetMachine.h Makefile Skeleton.td SkeletonInstrInfo.td Message-ID: <200407160711.CAA04404@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/Skeleton: Skeleton.h added (r1.1) SkeletonInstrInfo.cpp added (r1.1) SkeletonInstrInfo.h added (r1.1) SkeletonJITInfo.cpp added (r1.1) SkeletonJITInfo.h added (r1.1) SkeletonRegisterInfo.cpp added (r1.1) SkeletonRegisterInfo.h added (r1.1) SkeletonTargetMachine.cpp added (r1.1) SkeletonTargetMachine.h added (r1.1) Makefile updated: 1.1 -> 1.2 Skeleton.td updated: 1.1 -> 1.2 SkeletonInstrInfo.td updated: 1.1 -> 1.2 --- Log message: Initial checkin of the rest of the skeleton target --- Diffs of the changes: (+440 -4) Index: llvm/lib/Target/Skeleton/Skeleton.h diff -c /dev/null llvm/lib/Target/Skeleton/Skeleton.h:1.1 *** /dev/null Fri Jul 16 02:11:25 2004 --- llvm/lib/Target/Skeleton/Skeleton.h Fri Jul 16 02:11:08 2004 *************** *** 0 **** --- 1,33 ---- + //===-- Skeleton.h - Target private header file -----------------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the definitions shared among the various components of the + // Skeleton backend. + // + //===----------------------------------------------------------------------===// + + #ifndef TARGET_SKELETON_H + #define TARGET_SKELETON_H + + #include + + /// Put prototypes here for functions used to create various passes. + + + // Defines symbolic enum names for target registers. This defines a mapping + // from register name to register number. These are generated by tblgen from + // your target file. + // + #include "SkeletonGenRegisterNames.inc" + + // Defines symbolic enum names for the target instructions. + // + #include "SkeletonGenInstrNames.inc" + + #endif Index: llvm/lib/Target/Skeleton/SkeletonInstrInfo.cpp diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonInstrInfo.cpp:1.1 *** /dev/null Fri Jul 16 02:11:26 2004 --- llvm/lib/Target/Skeleton/SkeletonInstrInfo.cpp Fri Jul 16 02:11:09 2004 *************** *** 0 **** --- 1,22 ---- + //===- SkeletonInstrInfo.cpp - Instruction Information ----------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This is where you implement methods for the TargetInstrInfo class. + // + //===----------------------------------------------------------------------===// + + #include "SkeletonInstrInfo.h" + #include "llvm/CodeGen/MachineInstrBuilder.h" + #include "SkeletonGenInstrInfo.inc" // Get info from Tablegen + using namespace llvm; + + SkeletonInstrInfo::SkeletonInstrInfo() + : TargetInstrInfo(SkeletonInsts, + sizeof(SkeletonInsts)/sizeof(SkeletonInsts[0])){ + } Index: llvm/lib/Target/Skeleton/SkeletonInstrInfo.h diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonInstrInfo.h:1.1 *** /dev/null Fri Jul 16 02:11:26 2004 --- llvm/lib/Target/Skeleton/SkeletonInstrInfo.h Fri Jul 16 02:11:10 2004 *************** *** 0 **** --- 1,36 ---- + //===- SkeletonInstrInfo.h - Instruction Information ------------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file is where the target-specific implementation of the TargetInstrInfo + // class goes. + // + //===----------------------------------------------------------------------===// + + #ifndef SKELETON_INSTRUCTIONINFO_H + #define SKELETON_INSTRUCTIONINFO_H + + #include "llvm/Target/TargetInstrInfo.h" + #include "SkeletonRegisterInfo.h" + + namespace llvm { + + class SkeletonInstrInfo : public TargetInstrInfo { + const SkeletonRegisterInfo RI; + public: + SkeletonInstrInfo(); + + /// getRegisterInfo - TargetInstrInfo is a superset of MRegister info. As + /// such, whenever a client has an instance of instruction info, it should + /// always be able to get register info as well (through this method). + /// + virtual const MRegisterInfo &getRegisterInfo() const { return RI; } + }; + } + + #endif Index: llvm/lib/Target/Skeleton/SkeletonJITInfo.cpp diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonJITInfo.cpp:1.1 *** /dev/null Fri Jul 16 02:11:26 2004 --- llvm/lib/Target/Skeleton/SkeletonJITInfo.cpp Fri Jul 16 02:11:11 2004 *************** *** 0 **** --- 1,37 ---- + //===-- SkeletonCodeEmitter.cpp - JIT Code Emitter --------------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This is a stub for a JIT code generator, which is obviously not implemented. + // + //===----------------------------------------------------------------------===// + + #include "SkeletonTargetMachine.h" + using namespace llvm; + + /// addPassesToEmitMachineCode - Add passes to the specified pass manager to get + /// machine code emitted. This uses a MachineCodeEmitter object to handle + /// actually outputting the machine code and resolving things like the address + /// of functions. This method should returns true if machine code emission is + /// not supported. + /// + bool SkeletonTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, + MachineCodeEmitter &MCE){ + return true; // Not implemented yet! + } + + void *SkeletonJITInfo::getJITStubForFunction(Function *F, + MachineCodeEmitter &MCE) { + assert (0 && "getJITStubForFunction not implemented"); + return 0; + } + + void SkeletonJITInfo::replaceMachineCodeForFunction (void *Old, void *New) { + assert (0 && "replaceMachineCodeForFunction not implemented"); + } + Index: llvm/lib/Target/Skeleton/SkeletonJITInfo.h diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonJITInfo.h:1.1 *** /dev/null Fri Jul 16 02:11:27 2004 --- llvm/lib/Target/Skeleton/SkeletonJITInfo.h Fri Jul 16 02:11:11 2004 *************** *** 0 **** --- 1,49 ---- + //===- SkeletonJITInfo.h - Skeleton impl of JIT interface -------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the skeleton implementation of the TargetJITInfo class. + // + //===----------------------------------------------------------------------===// + + #ifndef SKELETONJITINFO_H + #define SKELETONJITINFO_H + + #include "llvm/Target/TargetJITInfo.h" + + namespace llvm { + class TargetMachine; + class IntrinsicLowering; + + class SkeletonJITInfo : public TargetJITInfo { + TargetMachine &TM; + public: + SkeletonJITInfo(TargetMachine &tm) : TM(tm) {} + + /// addPassesToJITCompile - Add passes to the specified pass manager to + /// implement a fast dynamic compiler for this target. Return true if this + /// is not supported for this target. + /// + virtual void addPassesToJITCompile(FunctionPassManager &PM); + + /// replaceMachineCodeForFunction - Make it so that calling the function + /// whose machine code is at OLD turns into a call to NEW, perhaps by + /// overwriting OLD with a branch to NEW. This is used for self-modifying + /// code. + /// + virtual void replaceMachineCodeForFunction(void *Old, void *New); + + /// getJITStubForFunction - Create or return a stub for the specified + /// function. This stub acts just like the specified function, except that + /// it allows the "address" of the function to be taken without having to + /// generate code for it. + virtual void *getJITStubForFunction(Function *F, MachineCodeEmitter &MCE); + }; + } + + #endif Index: llvm/lib/Target/Skeleton/SkeletonRegisterInfo.cpp diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonRegisterInfo.cpp:1.1 *** /dev/null Fri Jul 16 02:11:27 2004 --- llvm/lib/Target/Skeleton/SkeletonRegisterInfo.cpp Fri Jul 16 02:11:12 2004 *************** *** 0 **** --- 1,94 ---- + //===- SkeletonRegisterInfo.cpp - Skeleton Register Information -*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the Skeleton implementation of the MRegisterInfo class. + // + //===----------------------------------------------------------------------===// + + #include "Skeleton.h" + #include "SkeletonRegisterInfo.h" + #include "llvm/Type.h" + using namespace llvm; + + SkeletonRegisterInfo::SkeletonRegisterInfo() + : SkeletonGenRegisterInfo(Skeleton::ADJCALLSTACKDOWN, + Skeleton::ADJCALLSTACKUP) {} + + int SkeletonRegisterInfo::storeRegToStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + unsigned SrcReg, int FrameIdx, + const TargetRegisterClass *RC) const { + abort(); + return -1; + } + + int SkeletonRegisterInfo::loadRegFromStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + unsigned DestReg, int FrameIdx, + const TargetRegisterClass *RC) const { + abort(); + return -1; + } + + int SkeletonRegisterInfo::copyRegToReg(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *RC) const { + abort(); + return -1; + } + + void SkeletonRegisterInfo:: + eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const { + abort(); + } + + void SkeletonRegisterInfo::eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator II) const { + abort(); + } + + void SkeletonRegisterInfo:: + processFunctionBeforeFrameFinalized(MachineFunction &MF) const { + abort(); + } + + void SkeletonRegisterInfo::emitPrologue(MachineFunction &MF) const { + abort(); + } + + void SkeletonRegisterInfo::emitEpilogue(MachineFunction &MF, + MachineBasicBlock &MBB) const { + abort(); + } + + + #include "SkeletonGenRegisterInfo.inc" + + const TargetRegisterClass* + SkeletonRegisterInfo::getRegClassForType(const Type* Ty) const { + switch (Ty->getTypeID()) { + case Type::LongTyID: + case Type::ULongTyID: assert(0 && "Long values can't fit in registers!"); + default: assert(0 && "Invalid type to getClass!"); + case Type::BoolTyID: + case Type::SByteTyID: + case Type::UByteTyID: + case Type::ShortTyID: + case Type::UShortTyID: + case Type::IntTyID: + case Type::UIntTyID: + case Type::PointerTyID: return &GPRCInstance; + + case Type::FloatTyID: + case Type::DoubleTyID: return &FPRCInstance; + } + } + Index: llvm/lib/Target/Skeleton/SkeletonRegisterInfo.h diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonRegisterInfo.h:1.1 *** /dev/null Fri Jul 16 02:11:27 2004 --- llvm/lib/Target/Skeleton/SkeletonRegisterInfo.h Fri Jul 16 02:11:13 2004 *************** *** 0 **** --- 1,56 ---- + //===- SkeletonRegisterInfo.h - Skeleton Register Information Impl -*- C++ -*-==// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file contains the Skeleton implementation of the MRegisterInfo class. + // + //===----------------------------------------------------------------------===// + + #ifndef SKELETON_REGISTERINFO_H + #define SKELETON_REGISTERINFO_H + + #include "llvm/Target/MRegisterInfo.h" + #include "SkeletonGenRegisterInfo.h.inc" + + namespace llvm { + class Type; + + struct SkeletonRegisterInfo : public SkeletonGenRegisterInfo { + SkeletonRegisterInfo(); + const TargetRegisterClass* getRegClassForType(const Type* Ty) const; + + // See MRegisterInfo.h for information on these methods. + int storeRegToStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + unsigned SrcReg, int FrameIndex, + const TargetRegisterClass *RC) const; + + int loadRegFromStackSlot(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + unsigned DestReg, int FrameIndex, + const TargetRegisterClass *RC) const; + + int copyRegToReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + unsigned DestReg, unsigned SrcReg, + const TargetRegisterClass *RC) const; + + void eliminateCallFramePseudoInstr(MachineFunction &MF, + MachineBasicBlock &MBB, + MachineBasicBlock::iterator I) const; + + void eliminateFrameIndex(MachineFunction &MF, + MachineBasicBlock::iterator II) const; + + void processFunctionBeforeFrameFinalized(MachineFunction &MF) const; + + void emitPrologue(MachineFunction &MF) const; + void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; + }; + } // end namespace llvm + + #endif Index: llvm/lib/Target/Skeleton/SkeletonTargetMachine.cpp diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonTargetMachine.cpp:1.1 *** /dev/null Fri Jul 16 02:11:27 2004 --- llvm/lib/Target/Skeleton/SkeletonTargetMachine.cpp Fri Jul 16 02:11:14 2004 *************** *** 0 **** --- 1,58 ---- + //===-- SkeletonTargetMachine.cpp - Define TargetMachine for Skeleton -----===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // + //===----------------------------------------------------------------------===// + + #include "SkeletonTargetMachine.h" + #include "Skeleton.h" + #include "llvm/Module.h" + #include "llvm/PassManager.h" + #include "llvm/Target/TargetOptions.h" + #include "llvm/Target/TargetMachineRegistry.h" + #include "llvm/CodeGen/MachineFunction.h" + #include "llvm/CodeGen/Passes.h" + using namespace llvm; + + namespace { + // Register the target. + RegisterTarget X("skeleton", + " Target Skeleton (unusable)"); + } + + /// SkeletonTargetMachine ctor - Create an ILP32 architecture model + /// + SkeletonTargetMachine::SkeletonTargetMachine(const Module &M, + IntrinsicLowering *IL) + : TargetMachine("Skeleton", IL, true, 4, 4, 4, 4, 4), + FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -4), JITInfo(*this) { + } + + /// addPassesToEmitAssembly - Add passes to the specified pass manager + /// to implement a static compiler for this target. + /// + bool SkeletonTargetMachine::addPassesToEmitAssembly(PassManager &PM, + std::ostream &Out) { + // + PM.add(createRegisterAllocator()); + PM.add(createPrologEpilogCodeInserter()); + // + PM.add(createMachineCodeDeleter()); + return true; // change to `return false' when this actually works. + } + + /// addPassesToJITCompile - Add passes to the specified pass manager to + /// implement a fast dynamic compiler for this target. + /// + void SkeletonJITInfo::addPassesToJITCompile(FunctionPassManager &PM) { + // + PM.add(createRegisterAllocator()); + PM.add(createPrologEpilogCodeInserter()); + } + Index: llvm/lib/Target/Skeleton/SkeletonTargetMachine.h diff -c /dev/null llvm/lib/Target/Skeleton/SkeletonTargetMachine.h:1.1 *** /dev/null Fri Jul 16 02:11:27 2004 --- llvm/lib/Target/Skeleton/SkeletonTargetMachine.h Fri Jul 16 02:11:15 2004 *************** *** 0 **** --- 1,50 ---- + //===-- SkeletonTargetMachine.h - TargetMachine for Skeleton ----*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file declares the Skeleton specific subclass of TargetMachine. + // + //===----------------------------------------------------------------------===// + + #ifndef SKELETONTARGETMACHINE_H + #define SKELETONTARGETMACHINE_H + + #include "llvm/Target/TargetMachine.h" + #include "llvm/Target/TargetFrameInfo.h" + #include "llvm/PassManager.h" + #include "SkeletonInstrInfo.h" + #include "SkeletonJITInfo.h" + + namespace llvm { + class IntrinsicLowering; + + class SkeletonTargetMachine : public TargetMachine { + SkeletonInstrInfo InstrInfo; + TargetFrameInfo FrameInfo; + SkeletonJITInfo JITInfo; + public: + SkeletonTargetMachine(const Module &M, IntrinsicLowering *IL); + + virtual const SkeletonInstrInfo *getInstrInfo() const { return &InstrInfo; } + virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } + virtual const MRegisterInfo *getRegisterInfo() const { + return &InstrInfo.getRegisterInfo(); + } + virtual TargetJITInfo *getJITInfo() { + return &JITInfo; + } + + virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, + MachineCodeEmitter &MCE); + + virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); + }; + + } // end namespace llvm + + #endif Index: llvm/lib/Target/Skeleton/Makefile diff -u llvm/lib/Target/Skeleton/Makefile:1.1 llvm/lib/Target/Skeleton/Makefile:1.2 --- llvm/lib/Target/Skeleton/Makefile:1.1 Fri Jul 16 01:20:55 2004 +++ llvm/lib/Target/Skeleton/Makefile Fri Jul 16 02:11:07 2004 @@ -12,7 +12,8 @@ include $(LEVEL)/Makefile.common TARGET = Skeleton -TDFILES = $(wildcard $(SourceDir)/*.td) $(SourceDir)/../Target.td +TDFILES = $(SourceDir)/$(TARGET).td $(wildcard $(SourceDir)/*.td) \ + $(SourceDir)/../Target.td # Make sure that tblgen is run, first thing. Index: llvm/lib/Target/Skeleton/Skeleton.td diff -u llvm/lib/Target/Skeleton/Skeleton.td:1.1 llvm/lib/Target/Skeleton/Skeleton.td:1.2 --- llvm/lib/Target/Skeleton/Skeleton.td:1.1 Fri Jul 16 01:29:19 2004 +++ llvm/lib/Target/Skeleton/Skeleton.td Fri Jul 16 02:11:08 2004 @@ -1,4 +1,4 @@ -//===- PowerPC.td - Describe the PowerPC Target Machine ---------*- C++ -*-===// +//===- Skeleton.td - Describe the Skeleton Target Machine -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -25,7 +25,7 @@ let PHIInst = PHI; } -def PowerPC : Target { +def Skeleton : Target { // Pointers are 32-bits in size. let PointerType = i32; Index: llvm/lib/Target/Skeleton/SkeletonInstrInfo.td diff -u llvm/lib/Target/Skeleton/SkeletonInstrInfo.td:1.1 llvm/lib/Target/Skeleton/SkeletonInstrInfo.td:1.2 --- llvm/lib/Target/Skeleton/SkeletonInstrInfo.td:1.1 Fri Jul 16 01:29:19 2004 +++ llvm/lib/Target/Skeleton/SkeletonInstrInfo.td Fri Jul 16 02:11:10 2004 @@ -15,7 +15,7 @@ bits<4> Value = val; } -// All of the PowerPC instruction formats, plus a pseudo-instruction format: +// Some of the powerpc instruction formats, plus a pseudo-instruction format: def Pseudo : Format<0>; def IForm : Format<1>; def BForm : Format<2>; From lattner at cs.uiuc.edu Fri Jul 16 02:12:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:12:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/Makefile Message-ID: <200407160712.CAA04417@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: Makefile updated: 1.14 -> 1.15 --- Log message: Build the skeleton target --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/Makefile diff -u llvm/lib/Target/Makefile:1.14 llvm/lib/Target/Makefile:1.15 --- llvm/lib/Target/Makefile:1.14 Wed Mar 10 22:42:41 2004 +++ llvm/lib/Target/Makefile Fri Jul 16 02:11:53 2004 @@ -7,7 +7,7 @@ # ##===----------------------------------------------------------------------===## LEVEL = ../.. -DIRS = CBackend X86 SparcV9 PowerPC +DIRS = CBackend X86 SparcV9 Skeleton LIBRARYNAME = target BUILD_ARCHIVE = 1 From lattner at cs.uiuc.edu Fri Jul 16 02:12:56 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:12:56 -0500 Subject: [llvm-commits] CVS: llvm/tools/llc/Makefile Message-ID: <200407160712.CAA04432@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: Makefile updated: 1.52 -> 1.53 --- Log message: Build skeleton target --- Diffs of the changes: (+3 -2) Index: llvm/tools/llc/Makefile diff -u llvm/tools/llc/Makefile:1.52 llvm/tools/llc/Makefile:1.53 --- llvm/tools/llc/Makefile:1.52 Thu May 27 00:44:22 2004 +++ llvm/tools/llc/Makefile Fri Jul 16 02:12:46 2004 @@ -1,4 +1,4 @@ -#===- tools/llc/Makefile ------------------------------*- Makefile -*-===## +#===- tools/llc/Makefile -----------------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # @@ -6,12 +6,13 @@ # the University of Illinois Open Source License. See LICENSE.TXT for details. # ##===----------------------------------------------------------------------===## + LEVEL = ../.. TOOLNAME = llc USEDLIBS = cwriter \ sparcv9 \ x86 \ - powerpc \ + skeleton \ selectiondag \ sparcv9regalloc \ sched \ From lattner at cs.uiuc.edu Fri Jul 16 02:14:46 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:14:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/Makefile PowerPC.h PowerPC.td PowerPCCodeEmitter.cpp PowerPCInstrInfo.cpp PowerPCInstrInfo.h PowerPCInstrs.td PowerPCJITInfo.h PowerPCReg.td PowerPCRegisterInfo.cpp PowerPCRegisterInfo.h PowerPCTargetMachine.cpp PowerPCTargetMachine.h README.txt Message-ID: <200407160714.CAA04465@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: Makefile (r1.1) removed PowerPC.h (r1.2) removed PowerPC.td (r1.1) removed PowerPCCodeEmitter.cpp (r1.1) removed PowerPCInstrInfo.cpp (r1.3) removed PowerPCInstrInfo.h (r1.2) removed PowerPCInstrs.td (r1.1) removed PowerPCJITInfo.h (r1.1) removed PowerPCReg.td (r1.2) removed PowerPCRegisterInfo.cpp (r1.5) removed PowerPCRegisterInfo.h (r1.4) removed PowerPCTargetMachine.cpp (r1.11) removed PowerPCTargetMachine.h (r1.5) removed README.txt (r1.2) removed --- Log message: The powerpc is now gone. However it is now just known as the Skeleton target. --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Jul 16 02:17:19 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:17:19 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/config/ia64/elf.h Message-ID: <200407160717.CAA04503@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/config/ia64: elf.h updated: 1.1.1.1 -> 1.2 --- Log message: *shred* --- Diffs of the changes: (+3 -1) Index: llvm-gcc/gcc/config/ia64/elf.h diff -u llvm-gcc/gcc/config/ia64/elf.h:1.1.1.1 llvm-gcc/gcc/config/ia64/elf.h:1.2 --- llvm-gcc/gcc/config/ia64/elf.h:1.1.1.1 Thu Jan 8 15:58:50 2004 +++ llvm-gcc/gcc/config/ia64/elf.h Fri Jul 16 02:17:09 2004 @@ -5,6 +5,8 @@ #define TARGET_VERSION fprintf (stderr, " (IA-64) ELF"); +#if 0 + /* A C string constant that tells the GNU CC driver program options to pass to the assembler. It can also specify how to translate options you give to GNU CC into options for GNU CC to pass to the assembler. */ @@ -46,5 +48,5 @@ %{!symbolic: \ %{pg:gcrt0.o%s}%{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}\ crti.o%s crtbegin.o%s" - +#endif /* End of elf.h */ From lattner at cs.uiuc.edu Fri Jul 16 02:20:38 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 02:20:38 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/config.gcc Message-ID: <200407160720.CAA04528@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: config.gcc updated: 1.1.1.2 -> 1.2 --- Log message: llvmgcc wants no extraparts --- Diffs of the changes: (+2 -0) Index: llvm-gcc/gcc/config.gcc diff -u llvm-gcc/gcc/config.gcc:1.1.1.2 llvm-gcc/gcc/config.gcc:1.2 --- llvm-gcc/gcc/config.gcc:1.1.1.2 Tue Jan 13 10:49:00 2004 +++ llvm-gcc/gcc/config.gcc Fri Jul 16 02:20:28 2004 @@ -2205,6 +2205,8 @@ ;; esac + +extra_parts="" # Support for --with-cpu and related options (and a few unrelated options, # too). case "x$with_cpu" in From alkis at cs.uiuc.edu Fri Jul 16 05:18:20 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 05:18:20 -0500 Subject: [llvm-commits] CVS: llvm-java/test/Makefile.test Message-ID: <200407161018.FAA02174@zion.cs.uiuc.edu> Changes in directory llvm-java/test: Makefile.test updated: 1.2 -> 1.3 --- Log message: Make linking step depend on runtime.ll. --- Diffs of the changes: (+2 -2) Index: llvm-java/test/Makefile.test diff -u llvm-java/test/Makefile.test:1.2 llvm-java/test/Makefile.test:1.3 --- llvm-java/test/Makefile.test:1.2 Thu Jul 15 06:28:44 2004 +++ llvm-java/test/Makefile.test Fri Jul 16 05:18:10 2004 @@ -24,5 +24,5 @@ $(CLASS2LLVM) $* | $(LOPT) -mem2reg > $@ #rule to link in runtime to raw bytecode -Output/%.linked.bc: Output/%.raw.bc - $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $< $(BUILD_SRC_ROOT)/runtime/runtime.bc -o $@ +Output/%.linked.bc: Output/%.raw.bc $(BUILD_SRC_ROOT)/runtime/runtime.bc + $(LLVMTOOLCURRENT)/llvm-link$(EXEEXT) $^ -o $@ From alkis at cs.uiuc.edu Fri Jul 16 05:19:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 05:19:01 -0500 Subject: [llvm-commits] CVS: llvm-java/runtime/runtime.ll Message-ID: <200407161019.FAA02194@zion.cs.uiuc.edu> Changes in directory llvm-java/runtime: runtime.ll updated: 1.1 -> 1.2 --- Log message: Add hooks for llvm_java_main and llvm_java_static_init. --- Diffs of the changes: (+12 -2) Index: llvm-java/runtime/runtime.ll diff -u llvm-java/runtime/runtime.ll:1.1 llvm-java/runtime/runtime.ll:1.2 --- llvm-java/runtime/runtime.ll:1.1 Thu Jul 15 06:28:44 2004 +++ llvm-java/runtime/runtime.ll Fri Jul 16 05:18:51 2004 @@ -1,3 +1,13 @@ -"java/lang/Object" = type opaque +"java/lang/Object" = type { } -"java/lang/Object" = type { "java/lang/Object" } +implementation + +declare void %llvm_java_static_init() +declare int %llvm_java_main(int, sbyte**) + +int %main(int %argc, sbyte** %argv) { +entry: + call void %llvm_java_static_init() + %result = call int %llvm_java_main(int %argc, sbyte** %argv) + ret int %result +} From alkis at cs.uiuc.edu Fri Jul 16 07:04:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 07:04:38 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iCall.cpp Message-ID: <200407161204.HAA15647@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iCall.cpp updated: 1.25 -> 1.26 --- Log message: Add convinience constructor for function calls with two args. --- Diffs of the changes: (+31 -0) Index: llvm/lib/VMCore/iCall.cpp diff -u llvm/lib/VMCore/iCall.cpp:1.25 llvm/lib/VMCore/iCall.cpp:1.26 --- llvm/lib/VMCore/iCall.cpp:1.25 Wed May 26 19:15:23 2004 +++ llvm/lib/VMCore/iCall.cpp Fri Jul 16 07:04:28 2004 @@ -38,6 +38,21 @@ Operands.push_back(Use(Params[i], this)); } +void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) +{ + Operands.reserve(3); + Operands.push_back(Use(Func, this)); + + const FunctionType *MTy = + cast(cast(Func->getType())->getElementType()); + + assert((MTy->getNumParams() == 2 || + (MTy->isVarArg() && MTy->getNumParams() == 0)) && + "Calling a function with bad signature"); + Operands.push_back(Use(Actual1, this)); + Operands.push_back(Use(Actual2, this)); +} + void CallInst::init(Value *Func, Value *Actual) { Operands.reserve(2); @@ -79,6 +94,22 @@ init(Func, Params); } +CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2, + const std::string &Name, Instruction *InsertBefore) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, Name, InsertBefore) { + init(Func, Actual1, Actual2); +} + +CallInst::CallInst(Value *Func, Value *Actual1, Value *Actual2, + const std::string &Name, BasicBlock *InsertAtEnd) + : Instruction(cast(cast(Func->getType()) + ->getElementType())->getReturnType(), + Instruction::Call, Name, InsertAtEnd) { + init(Func, Actual1, Actual2); +} + CallInst::CallInst(Value *Func, Value* Actual, const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) From alkis at cs.uiuc.edu Fri Jul 16 07:04:38 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 07:04:38 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/iOther.h Message-ID: <200407161204.HAA15654@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: iOther.h updated: 1.46 -> 1.47 --- Log message: Add convinience constructor for function calls with two args. --- Diffs of the changes: (+7 -1) Index: llvm/include/llvm/iOther.h diff -u llvm/include/llvm/iOther.h:1.46 llvm/include/llvm/iOther.h:1.47 --- llvm/include/llvm/iOther.h:1.46 Wed May 26 19:15:23 2004 +++ llvm/include/llvm/iOther.h Fri Jul 16 07:04:28 2004 @@ -70,6 +70,7 @@ class CallInst : public Instruction { CallInst(const CallInst &CI); void init(Value *Func, const std::vector &Params); + void init(Value *Func, Value *Actual1, Value *Actual2); void init(Value *Func, Value *Actual); void init(Value *Func); @@ -79,7 +80,12 @@ CallInst(Value *F, const std::vector &Par, const std::string &Name, BasicBlock *InsertAtEnd); - // Alternate CallInst ctors w/ one actual & no actuals, respectively. + // Alternate CallInst ctors w/ two actuals, w/ one actual and no + // actuals, respectively. + CallInst(Value *F, Value *Actual1, Value *Actual2, + const std::string& Name = "", Instruction *InsertBefore = 0); + CallInst(Value *F, Value *Actual1, Value *Actual2, + const std::string& Name, BasicBlock *InsertAtEnd); CallInst(Value *F, Value *Actual, const std::string& Name = "", Instruction *InsertBefore = 0); CallInst(Value *F, Value *Actual, const std::string& Name, From alkis at cs.uiuc.edu Fri Jul 16 07:05:14 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 07:05:14 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407161205.HAA15870@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.59 -> 1.60 --- Log message: Use newly added convinience constructor. --- Diffs of the changes: (+1 -4) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.59 llvm-java/lib/Compiler/Compiler.cpp:1.60 --- llvm-java/lib/Compiler/Compiler.cpp:1.59 Wed Jul 14 04:53:54 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Jul 16 07:05:04 2004 @@ -633,13 +633,10 @@ c = BinaryOperator::createSetLT(v1, v2, TMP, getBBAt(bcI)); r = new SelectInst(c, ConstantSInt::get(Type::IntTy, -1), r, TMP, getBBAt(bcI)); - std::vector params; - params.push_back(v1); - params.push_back(v2); c = new CallInst(module_->getOrInsertFunction ("llvm.isunordered", Type::BoolTy, v1->getType(), v2->getType(), 0), - params, TMP, getBBAt(bcI)); + v1, v2, TMP, getBBAt(bcI)); r = new SelectInst(c, ConstantSInt::get(Type::IntTy, valueIfUnordered), r, TMP, getBBAt(bcI)); From alkis at cs.uiuc.edu Fri Jul 16 07:17:42 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri, 16 Jul 2004 07:17:42 -0500 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407161217.HAA16415@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.60 -> 1.61 --- Log message: Use llvm_java_main hooks to call the compiled class' main method. --- Diffs of the changes: (+24 -4) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.60 llvm-java/lib/Compiler/Compiler.cpp:1.61 --- llvm-java/lib/Compiler/Compiler.cpp:1.60 Fri Jul 16 07:05:04 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Jul 16 07:17:32 2004 @@ -272,7 +272,7 @@ return locals_[index]; } - void compileMethodOnly(Module& module, + Function* compileMethodOnly(Module& module, const std::string& classMethodDesc) { DEBUG(std::cerr << "Compiling method: " << classMethodDesc << '\n'); @@ -314,6 +314,8 @@ function->getBasicBlockList().push_front(prologue_); new BranchInst(prologue_->getNext(), prologue_); } + + return function; } std::pair @@ -334,15 +336,18 @@ } public: - void compileMethod(Module& module, const std::string& classMethodDesc) { + Function* compileMethod(Module& module, + const std::string& classMethodDesc) { c2tMap_.insert(std::make_pair("java/lang/Object", OpaqueType::get())); module.addTypeName("java/lang/Object", c2tMap_["java/lang/Object"]); - compileMethodOnly(module, classMethodDesc); + Function* function = compileMethodOnly(module, classMethodDesc); for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { Function* f = toCompileFunctions_[i]; compileMethodOnly(module, f->getName()); } + + return function; } void do_aconst_null(unsigned bcI) { @@ -805,5 +810,20 @@ { DEBUG(std::cerr << "Compiling class: " << className << '\n'); - compilerImpl_->compileMethod(m, className + "/main([Ljava/lang/String;)I"); + Function* main = + compilerImpl_->compileMethod(m, + className + "/main([Ljava/lang/String;)I"); + Function* javaMain = m.getOrInsertFunction + ("llvm_java_main", Type::IntTy, + Type::IntTy, PointerType::get(PointerType::get(Type::SByteTy)), NULL); + + BasicBlock* bb = new BasicBlock("entry", javaMain); + const FunctionType* mainTy = main->getFunctionType(); + new ReturnInst( + new CallInst(main, + // FIXME: Forward correct params from llvm_java_main + llvm::Constant::getNullValue(mainTy->getParamType(0)), + TMP, + bb), + bb); } From criswell at cs.uiuc.edu Fri Jul 16 09:20:31 2004 From: criswell at cs.uiuc.edu (John Criswell) Date: Fri, 16 Jul 2004 09:20:31 -0500 Subject: [llvm-commits] CVS: llvm/test/QMTest/expectations.darwin.qmr expectations.linux.qmr expectations.sunos.qmr expectations.unknown.qmr Message-ID: <200407161420.JAA08775@choi.cs.uiuc.edu> Changes in directory llvm/test/QMTest: expectations.darwin.qmr updated: 1.3 -> 1.4 expectations.linux.qmr updated: 1.10 -> 1.11 expectations.sunos.qmr updated: 1.10 -> 1.11 expectations.unknown.qmr updated: 1.5 -> 1.6 --- Log message: Regression.Assembler.2004-03-07-FunctionAddressAlignment is now expected to pass. --- Diffs of the changes: (+4 -4) Index: llvm/test/QMTest/expectations.darwin.qmr diff -u llvm/test/QMTest/expectations.darwin.qmr:1.3 llvm/test/QMTest/expectations.darwin.qmr:1.4 --- llvm/test/QMTest/expectations.darwin.qmr:1.3 Mon Jun 21 10:05:48 2004 +++ llvm/test/QMTest/expectations.darwin.qmr Fri Jul 16 09:20:20 2004 @@ -3,13 +3,13 @@ qoq}q(U _Result__kindqUtestqU_Result__outcomeqUPASSqU_Result__annotationsq}U _Result__idq U0Regression.Assembler.2002-08-16-ConstExprInlinedq U_Result__contextq (cqm.test.context Context -q o}q (U_Context__propertiesq}U_Context__temporariesq}ubub.(hoq}q(hhhhh}h U(Regression.Transforms.PruneEH.simpletestqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h U/Regression.CBackend.2002-08-19-HardConstantExprqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h URegression.Jello.test-shiftqh (h o}q(h}h}ubub.(hoq}q(hhhUFAILqh}h U.Regression.Transforms.CorrelatedExprs.looptestqh (h o}q (h}h}ubub.(hoq!}q"(hhhhh}h U-Regression.Linker.2003-08-23-GlobalVarLinkingq#h (h o}q$(h}h}ubub.(hoq%}q&(hhhhh}h U?Regression.Transforms.Inline.2003-09-22-PHINodesInExceptionDestq'h (h o}q((h}h}ubub.(hoq)}q*(hhhhh}h U,Regression.CFrontend.2003-02-12-NonlocalGotoq+h (h o}q,(h}h}ubub.(hoq-}q.(hhhhh}h U2Regression.Transforms.FunctionResolve.retmismatch1q/h (h o}q0(h}h}ubub.(hoq1}q2(hhhhh}h U>Regression.Transforms.LevelRaise.2002-05-02-BadCastEliminationq3h (h o}q4(h}h}ubub.(hoq5}q6(hhhhh}h U8Regression.Transforms.ADCE.2003-01-22-! PredecessorProblemq7h (h o}q8(h}h}ubub.(hoq9}q:(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-VarArgCallInfLoopq;h (h o}q<(h}h}ubub.(hoq=}q>(hhhhh}h U5Regression.CFrontend.2003-07-22-ArrayAccessTypeSafetyq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U"Regression.Jello.2003-06-05-PHIBugqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhUPASSqSh}h U$Regression.BugPoint.misopt-basictestqTh (h o}qU(h}h}ubub.(hoqV}qW(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqXh (h o}qY(h}h}ubub.(hoqZ}q[(hhhhh}h U)Regression.Transforms.Reassociate.subtestq\h (h o}q](h}h}ubub.(hoq^}q_(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq`h (h o}qa(h}h}ubub.(h! oqb}qc(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-Agr essiveSubMoveqdh (h o}qe(h}h}ubub.(hoqf}qg(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemqhh (h o}qi(h}h}ubub.(hoqj}qk(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqlh (h o}qm(h}h}ubub.(hoqn}qo(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqph (h o}qq(h}h}ubub.(hoqr}qs(hhhhh}h U$Regression.Jello.2003-01-04-LoopTestqth (h o}qu(h}h}ubub.(hoqv}qw(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qxh (h o}qy(h}h}ubub.(hoqz}q{(hhhhh}h U)Regression.CFrontend.2002-07-14-MiscTestsq|h (h o}q}(h}h}ubub.(hoq~}q(hhhhh}h U(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-VarArgCallInfLoopq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U5Regression.CFrontend.2003-07-22-ArrayAccessTypeSafetyqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Transforms.Reassociate.subtestqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSub! Moveq_h (h o}q`(h}h}ubub.(hoqa}qb(hhhhh}h UARegression.Transfo rms.CorrelatedExprs.2002-10-07-DominatorProblemqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U-Regression.CFrontend.2002-02-18-64bitConstantqoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U(Regression.Reoptimizer.BinInterface.testqwh (h o}qx(h}h}ubub.(hoqy}qz(hhhhh}h URegression.Transforms.CorrelatedExprs.2002-10-08-DominatorTestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h URegression.Linker! .testlink2q?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Regression.Transforms.GCSE.RLE-Eliminateq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U4Regression.C++Frontend.2003-09-30-NestedFunctionDeclq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U=Regression.Transforms.CorrelatedExprs.2002-09-23-PHIUpdateBugq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U7Regression.Transforms.LowerSwitch.2003-05-01-PHIProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U2Regression.Transforms.ADCE.2003-09-15-InfLoopCrashq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U*Regression.Transforms.DSAnalysis.recursionq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U)Regression.Jello.2003-01-15-AlignmentTestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhUFAILq?h}h UFeature.mc.simplecalltestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U*Regression.CFrontend.2002-04-07-SwitchStmtq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U!Regression.Jello.2003-01-10-FUCOMq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Reg! ression.CFrontend.2003-08-21-StmtExprq?h (h o}q?(h}h}ubub.(hoq?}q?( hhhUPASSq?h}h U*Regression.Transforms.ScalarRepl.basictestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhh"h}h U6Regression.Transforms.LevelRaise.2002-02-11-ArrayShapeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U1Regression.Assembler.2003-03-03-DuplicateConstantq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U.Regression.Transforms.ModuloSched.arith-simpleq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U%Regression.Transforms.InstCombine.andq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U)Regression.Other.2002-08-02-DomSetProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Assembler.2002-07-25-ParserAssertionFailureq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Transforms.LevelRaise.2002-03-20-BadCodegenq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U%Regression.Transforms.ADCE.basictest1q?h (h o}q?(h}h}ubub.(hoq?}q?(hhhUFAILq?h}h UFeature.mc.recursivetypeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U$Regression.Transforms.InstCombine.orq?h (h o! }q?(h}h}ubub.(hoq?}q?(hhhhh}h U Regression.Verifier.AmbiguousPhiq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U'Regression.Analysis.DSGraph.constantizeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Transforms.GlobalDCE.2002-08-17-FunctionDGEq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U4Regression.Transforms.SimplifyCFG.2002-06-24-PHINodeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Regression.Linker.2003-05-15-TypeProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U#Regression.Transforms.SCCP.sccptestq?h (h o}q?(h}h}ubub.(hor+++++++++ \ No newline at end of file Index: llvm/test/QMTest/expectations.linux.qmr diff -u llvm/test/QMTest/expectations.linux.qmr:1.10 llvm/test/QMTest/expectations.linux.qmr:1.11 --- llvm/test/QMTest/expectations.linux.qmr:1.10 Mon Jun 21 10:05:48 2004 +++ llvm/test/QMTest/expectations.linux.qmr Fri Jul 16 09:20:20 2004 @@ -3,13 +3,13 @@ qoq}q(U _Result__kindqUtestqU_Result__outcomeqUPASSqU_Result__annotationsq}U _Result__idq U0Regression.Assembler.2002-08-16-ConstExprInlinedq U_Result__contextq (cqm.test.context Context -q o}q (U_Context__propertiesq}U_Context__temporariesq}ubub.(hoq}q(hhhhh}h U(Regression.Transforms.PruneEH.simpletestqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h U/Regression.CBackend.2002-08-19-HardConstantExprqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h URegression.Jello.test-shiftqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h U9Regression.Transforms.Mem2Reg.2003-10-05-DeadPHIInsertionqh (h o}q(h}h}ubub.(hoq }q!(hhhUFAILq"h}h U.Regression.Transforms.CorrelatedExprs.looptestq#h (h o}q$(h}h}ubub.(hoq%}q&(hhhhh}h U-Regression.Linker.2003-08-23-GlobalVarLinkingq'h (h o}q((h}h}ubub.(hoq)}q*(hhhhh}h U?Regression.Transforms.Inline.2003-09-22-PHINodesInExceptionDestq+h (h o}q,(h}h}ubub.(hoq-}q.(hhhh"h}h U,Regression.CFrontend.2003-02-12-NonlocalGotoq/h (h o}q0(h}h}ubub.(hoq1}q2(hhhhh}h U2Regression.Transforms.FunctionResolve.retmismatch1q3h (h o}q4(h}h}ubub.(hoq5}q6(hhhhh}h U8Regression.Transforms.ADCE.2003-01-22-Prede! cessorProblemq7h (h o}q8(h}h}ubub.(hoq9}q:(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-VarArgCallInfLoopq;h (h o}q<(h}h}ubub.(hoq=}q>(hhhhh}h U Regression.Reoptimizer.ticm.ticmq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U)Regression.Transforms.Reassociate.subtestqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemq_! h (h o}q`(h}h}ubub.(hoqa}qb(hhhhh}h U3Regression.Transforms.Pi NodeInserter.substitutetestqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U-Regression.CFrontend.2002-02-18-64bitConstantqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U(Regression.Reoptimizer.BinInterface.testqsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U-Regression.C++Frontend.2003-08-28-SaveExprBugqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U"Regression.Jello.2003-06-05-PHIBugqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Transforms.Reassociate.subtestqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq_h (h o}q`(h}h}ubub.(! hoqa}qb(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10- 07-DominatorProblemqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U>Regression.Transforms.InstCombine.2003-06-22-ConstantExprCrashqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U$Regression.Jello.2003-01-04-LoopTestqsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qwh (h o}qx(h}h}ubub.(hoqy}qz(hhhhh}h U)Regression.CFrontend.2002-07-14-MiscTestsq{h (h o}q|(h}h}ubub.(hoq}}q~(hhhhh}h U(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U-Regression.C++Frontend.2003-08-28-SaveExprBugqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U"Regression.Jello.2003-06-05-PHIBugqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Transforms.Reassociate.subtestqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq_h (h o}q`(h}h}ubub.(! hoqa}qb(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10- 07-DominatorProblemqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U>Regression.Transforms.InstCombine.2003-06-22-ConstantExprCrashqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U$Regression.Jello.2003-01-04-LoopTestqsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qwh (h o}qx(h}h}ubub.(hoqy}qz(hhhhh}h U)Regression.CFrontend.2002-07-14-MiscTestsq{h (h o}q|(h}h}ubub.(hoq}}q~(hhhhh}h U(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-VarArgCallInfLoopq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U5Regression.CFrontend.2003-07-22-ArrayAccessTypeSafetyqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Transforms.Reassociate.subtestqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-Ag! ressiveSubMoveq_h (h o}q`(h}h}ubub.(hoqa}qb(hhhhh}h UARegressi on.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U-Regression.CFrontend.2002-02-18-64bitConstantqoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h U(Regression.Reoptimizer.BinInterface.testqwh (h o}qx(h}h}ubub.(hoqy}qz(hhhhh}h U(hhhhh}h U Regression.Reoptimizer.ticm.ticmq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhhh}h U)Regression.Transforms.Reassociate.subtestqSh (h o}qT(h}h}ubub.(hoqU}qV(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprqWh (h o}qX(h}h}ubub.(hoqY}qZ(hhhhh}h U=Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveq[h (h o}q\(h}h}ubub.(hoq]}q^(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemq_! h (h o}q`(h}h}ubub.(hoqa}qb(hhhhh}h U3Regression.Transforms.Pi NodeInserter.substitutetestqch (h o}qd(h}h}ubub.(hoqe}qf(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqgh (h o}qh(h}h}ubub.(hoqi}qj(hhhhh}h U-Regression.CFrontend.2002-02-18-64bitConstantqkh (h o}ql(h}h}ubub.(hoqm}qn(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qoh (h o}qp(h}h}ubub.(hoqq}qr(hhhhh}h U(Regression.Reoptimizer.BinInterface.testqsh (h o}qt(h}h}ubub.(hoqu}qv(hhhhh}h URegression.Transforms.CorrelatedExprs.2002-10-08-DominatorTestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h URegression.Linker.testlink2q?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Regression.Transforms.GCSE.RLE-Eliminateq?h (h o}q?(h}h}ubu! b.(hoq?}q?(hhhhh}h U4Regression.C++Frontend.2003-09-30-NestedFunctionDeclq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U=Regression.Transforms.CorrelatedExprs.2002-09-23-PHIUpdateBugq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U7Regression.Transforms.LowerSwitch.2003-05-01-PHIProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U2Regression.Transforms.ADCE.2003-09-15-InfLoopCrashq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U*Regression.Transforms.DSAnalysis.recursionq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U)Regression.Jello.2003-01-15-AlignmentTestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhUFAILq?h}h UFeature.mc.simplecalltestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U*Regression.CFrontend.2002-04-07-SwitchStmtq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U!Regression.Jello.2003-01-10-FUCOMq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Regression.CFrontend.2003-08-21-StmtExprq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhUPASSq?h}h U*Regression.Transforms.Scalar! Repl.basictestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhh"h}h U6Regressi on.Transforms.LevelRaise.2002-02-11-ArrayShapeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U1Regression.Assembler.2003-03-03-DuplicateConstantq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U.Regression.Transforms.ModuloSched.arith-simpleq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U%Regression.Transforms.InstCombine.andq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U)Regression.Other.2002-08-02-DomSetProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Assembler.2002-07-25-ParserAssertionFailureq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Transforms.LevelRaise.2002-03-20-BadCodegenq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Transforms.ADCE.2002-07-17-AssertionFailureq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhUFAILq?h}h UFeature.mc.recursivetypeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U$Regression.Transforms.InstCombine.orq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U Regression.Verifier.AmbiguousPhiq?h (h o}q?(h}h}ubub.(hoq?}! q?(hhhhh}h U'Regression.Analysis.DSGraph.constantizeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U6Regression.Transforms.GlobalDCE.2002-08-17-FunctionDGEq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U4Regression.Transforms.SimplifyCFG.2002-06-24-PHINodeq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U(Regression.Linker.2003-05-15-TypeProblemq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U#Regression.Transforms.SCCP.sccptestq?h (h o}q?(h}h}ubub.(hoq?}q?(hhhhh}h U2Regression.Transforms.FunctionResolve.retmismatch3q?h (h o}q?(h}h}ubub.(hor--------- \ No newline at end of file +q o}q (U_Context__propertiesq}U_Context__temporariesq}ubub.(hoq}q(hhhhh}h U(Regression.Transforms.PruneEH.simpletestqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h U/Regression.CBackend.2002-08-19-HardConstantExprqh (h o}q(h}h}ubub.(hoq}q(hhhhh}h URegression.Jello.test-shiftqh (h o}q(h}h}ubub.(hoq}q(hhhUFAILqh}h U.Regression.Transforms.CorrelatedExprs.looptestqh (h o}q (h}h}ubub.(hoq!}q"(hhhhh}h U-Regression.Linker.2003-08-23-GlobalVarLinkingq#h (h o}q$(h}h}ubub.(hoq%}q&(hhhhh}h U?Regression.Transforms.Inline.2003-09-22-PHINodesInExceptionDestq'h (h o}q((h}h}ubub.(hoq)}q*(hhhhh}h U,Regression.CFrontend.2003-02-12-NonlocalGotoq+h (h o}q,(h}h}ubub.(hoq-}q.(hhhhh}h U2Regression.Transforms.FunctionResolve.retmismatch1q/h (h o}q0(h}h}ubub.(hoq1}q2(hhhhh}h U>Regression.Transforms.LevelRaise.2002-05-02-BadCastEliminationq3h (h o}q4(h}h}ubub.(hoq5}q6(hhhhh}h U8Regression.Transforms.ADCE.2003-01-22-! PredecessorProblemq7h (h o}q8(h}h}ubub.(hoq9}q:(hhhhh}h U=Regression.Transforms.LevelRaise.2002-10-08-VarArgCallInfLoopq;h (h o}q<(h}h}ubub.(hoq=}q>(hhhhh}h U Regression.Reoptimizer.ticm.ticmq?h (h o}q@(h}h}ubub.(hoqA}qB(hhhhh}h U8Regression.C++Frontend.2003-09-29-ArgumentNumberMismatchqCh (h o}qD(h}h}ubub.(hoqE}qF(hhhhh}h U+Regression.CFrontend.2002-09-19-StarInLabelqGh (h o}qH(h}h}ubub.(hoqI}qJ(hhhhh}h U.Regression.CFrontend.2003-08-23-LocalUnionTestqKh (h o}qL(h}h}ubub.(hoqM}qN(hhhhh}h U"Regression.Jello.2003-06-05-PHIBugqOh (h o}qP(h}h}ubub.(hoqQ}qR(hhhUPASSqSh}h U$Regression.BugPoint.misopt-basictestqTh (h o}qU(h}h}ubub.(hoqV}qW(hhhhh}h U/Regression.Linker.2003-04-26-NullPtrLinkProblemqXh (h o}qY(h}h}ubub.(hoqZ}q[(hhhhh}h U)Regression.Transforms.Reassociate.subtestq\h (h o}q](h}h}ubub.(hoq^}q_(hhhhh}h U)Regression.Linker.2002-08-20-ConstantExprq`h (h o}qa(h}h}ubub.(hoqb}qc(hhhhh}h U! =Regression.Transforms.Reassociate.2002-05-15-AgressiveSubMoveqdh (h o }qe(h}h}ubub.(hoqf}qg(hhhhh}h UARegression.Transforms.CorrelatedExprs.2002-10-07-DominatorProblemqhh (h o}qi(h}h}ubub.(hoqj}qk(hhhhh}h U3Regression.Transforms.PiNodeInserter.substitutetestqlh (h o}qm(h}h}ubub.(hoqn}qo(hhhhh}h U4Regression.Transforms.SCCP.2003-08-26-InvokeHandlingqph (h o}qq(h}h}ubub.(hoqr}qs(hhhhh}h U$Regression.Jello.2003-01-04-LoopTestqth (h o}qu(h}h}ubub.(hoqv}qw(hhhhh}h U1Regression.Assembler.2002-04-04-PureVirtMethCall2qxh (h o}qy(h}h}ubub.(hoqz}q{(hhhhh}h U)Regression.CFrontend.2002-07-14-MiscTestsq|h (h o}q}(h}h}ubub.(hoq~}q(hhhhh}h U Changes in directory llvm/lib/Target/Skeleton: README.txt updated: 1.1 -> 1.2 --- Log message: Fix grammar. --- Diffs of the changes: (+1 -2) Index: llvm/lib/Target/Skeleton/README.txt diff -u llvm/lib/Target/Skeleton/README.txt:1.1 llvm/lib/Target/Skeleton/README.txt:1.2 --- llvm/lib/Target/Skeleton/README.txt:1.1 Fri Jul 16 01:12:28 2004 +++ llvm/lib/Target/Skeleton/README.txt Fri Jul 16 12:40:28 2004 @@ -2,7 +2,7 @@ -------------------- This directory contains a very simple skeleton that can be used as the -starting point for new LLVM targets. Basically you can take this code +starting point for new LLVM targets. Basically, you can take this code and start filling stuff in. This directory contains mainly stubs and placeholders; there is no binary @@ -16,4 +16,3 @@ As always, if you're starting a new port, please mention it on the llvmdev list, and if you have questions, that is a great place to ask. - From brukman at cs.uiuc.edu Fri Jul 16 13:11:17 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri, 16 Jul 2004 13:11:17 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c Message-ID: <200407161811.NAA27106@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/Benchmarks/Shootout: ary3.c updated: 1.3 -> 1.4 --- Log message: Remove unneeded tag from comments. --- Diffs of the changes: (+2 -2) Index: llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c diff -u llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c:1.3 llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c:1.4 --- llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c:1.3 Tue Jun 8 12:21:42 2004 +++ llvm/test/Programs/SingleSource/Benchmarks/Shootout/ary3.c Fri Jul 16 13:11:07 2004 @@ -1,11 +1,11 @@ /* -*- mode: c -*- - * $Id: ary3.c,v 1.3 2004/06/08 17:21:42 lattner Exp $ + * $Id: ary3.c,v 1.4 2004/07/16 18:11:07 brukman Exp $ * http://www.bagley.org/~doug/shootout/ * * this program is modified from: * http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html * Timing Trials, or, the Trials of Timing: Experiments with Scripting - * and User-Interface Languages by Brian W. Kernighan and + * and User-Interface Languages by Brian W. Kernighan and * Christopher J. Van Wyk. * * I added free() to deallocate memory. From brukman at cs.uiuc.edu Fri Jul 16 14:45:56 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri, 16 Jul 2004 14:45:56 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/ToolRunner.cpp Message-ID: <200407161945.OAA27876@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: ToolRunner.cpp updated: 1.24 -> 1.25 --- Log message: Correctly build shared objects on MacOS X for debugging code generators --- Diffs of the changes: (+5 -1) Index: llvm/lib/Support/ToolRunner.cpp diff -u llvm/lib/Support/ToolRunner.cpp:1.24 llvm/lib/Support/ToolRunner.cpp:1.25 --- llvm/lib/Support/ToolRunner.cpp:1.24 Tue May 4 17:02:41 2004 +++ llvm/lib/Support/ToolRunner.cpp Fri Jul 16 14:45:45 2004 @@ -403,7 +403,11 @@ InputFile.c_str(), // Specify the input filename... #if defined(sparc) || defined(__sparc__) || defined(__sparcv9) "-G", // Compile a shared library, `-G' for Sparc -#else +#elif (defined(__POWERPC__) || defined(__ppc__)) && defined(__APPLE__) + "-dynamiclib", // `-dynamiclib' for MacOS X/PowerPC + "-fno-common", // allow global vars w/o initializers to live + // in data segment, rather than generating blocks +#else "-shared", // `-shared' for Linux/X86, maybe others #endif "-o", OutputFile.c_str(), // Output to the right filename... From gaeke at cs.uiuc.edu Fri Jul 16 16:40:43 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri, 16 Jul 2004 16:40:43 -0500 (CDT) Subject: [llvm-commits] CVS: llvm/runtime/GC/SemiSpace/semispace.c Message-ID: <200407162140.QAA20267@kain.cs.uiuc.edu> Changes in directory llvm/runtime/GC/SemiSpace: semispace.c updated: 1.3 -> 1.4 --- Log message: Fix warning on 64-bit machines --- Diffs of the changes: (+1 -1) Index: llvm/runtime/GC/SemiSpace/semispace.c diff -u llvm/runtime/GC/SemiSpace/semispace.c:1.3 llvm/runtime/GC/SemiSpace/semispace.c:1.4 --- llvm/runtime/GC/SemiSpace/semispace.c:1.3 Thu May 27 00:51:31 2004 +++ llvm/runtime/GC/SemiSpace/semispace.c Fri Jul 16 16:40:32 2004 @@ -75,7 +75,7 @@ static void process_pointer(void **Root, void *Meta) { - printf("process_root[0x%X] = 0x%X\n", (unsigned) Root, (unsigned) *Root); + printf("process_root[0x%p] = 0x%p\n", (void*) Root, (void*) *Root); } void llvm_gc_collect() { From lattner at cs.uiuc.edu Fri Jul 16 20:57:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 20:57:37 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/config/ia64/ia64.h Message-ID: <200407170157.UAA15515@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc/config/ia64: ia64.h updated: 1.1.1.1 -> 1.2 --- Log message: Hack to get vtables working with LLVM. This breaks ABI compliance with the standard C++ compilers, but it should work for now. --- Diffs of the changes: (+2 -0) Index: llvm-gcc/gcc/config/ia64/ia64.h diff -u llvm-gcc/gcc/config/ia64/ia64.h:1.1.1.1 llvm-gcc/gcc/config/ia64/ia64.h:1.2 --- llvm-gcc/gcc/config/ia64/ia64.h:1.1.1.1 Thu Jan 8 15:58:50 2004 +++ llvm-gcc/gcc/config/ia64/ia64.h Fri Jul 16 20:57:26 2004 @@ -390,6 +390,7 @@ For reasons known only to HP, the vtable entries (as opposed to normal function descriptors) are 16 bytes wide in 32-bit mode as well, even though the 3rd and 4th words are unused. */ +#if 0 /* FIXME: DISABLED BY LLVM */ #define TARGET_VTABLE_USES_DESCRIPTORS (TARGET_ILP32 ? 4 : 2) /* Due to silliness in the HPUX linker, vtable entries must be @@ -400,6 +401,7 @@ /* Due to the above, we need extra padding for the data entries below 0 to retain the alignment of the descriptors. */ #define TARGET_VTABLE_DATA_ENTRY_DISTANCE (TARGET_ILP32 ? 2 : 1) +#endif /* end of fixme */ /* Layout of Source Language Data Types */ From lattner at cs.uiuc.edu Fri Jul 16 21:04:51 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 21:04:51 -0500 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407170204.VAA15553@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.217 -> 1.218 --- Log message: Add note about IA64 C++ --- Diffs of the changes: (+8 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.217 llvm/docs/ReleaseNotes.html:1.218 --- llvm/docs/ReleaseNotes.html:1.217 Wed Jul 14 23:30:35 2004 +++ llvm/docs/ReleaseNotes.html Fri Jul 16 21:04:41 2004 @@ -628,6 +628,13 @@
    • The C++ front-end inherits all problems afflicting the C front-end.
    + +

    IA64 note: The C++ front-end does not use IA64 ABI compliant layout of vtables. +In particular, it just stores function pointers instead of function +descriptors in the vtable. This bug prevents mixing C++ code compiled with +LLVM with C++ objects compiled by other C++ compilers.

    +
    @@ -755,7 +762,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/15 04:30:35 $ + Last modified: $Date: 2004/07/17 02:04:41 $ From lattner at cs.uiuc.edu Fri Jul 16 21:19:55 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 21:19:55 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200407170219.VAA17560@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.48 -> 1.49 --- Log message: Add more debug output --- Diffs of the changes: (+5 -1) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.48 llvm-gcc/gcc/llvm-expand.c:1.49 --- llvm-gcc/gcc/llvm-expand.c:1.48 Tue Jul 6 22:34:17 2004 +++ llvm-gcc/gcc/llvm-expand.c Fri Jul 16 21:19:45 2004 @@ -4392,7 +4392,11 @@ enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); llvm_type *DestTy = llvm_type_get_from_tree(TREE_TYPE(exp)); - assert(DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD); + if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD) { + fprintf(stderr, "UNKNOWN BUILTIN TYPE: \n"); + debug_tree(fndecl); + abort(); + } /* Generate library calls for functions that we can do so for. */ switch (fcode) { From lattner at cs.uiuc.edu Fri Jul 16 21:30:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 21:30:15 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200407170230.VAA17604@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.49 -> 1.50 --- Log message: Fix previous patch --- Diffs of the changes: (+1 -1) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.49 llvm-gcc/gcc/llvm-expand.c:1.50 --- llvm-gcc/gcc/llvm-expand.c:1.49 Fri Jul 16 21:19:45 2004 +++ llvm-gcc/gcc/llvm-expand.c Fri Jul 16 21:30:05 2004 @@ -4392,7 +4392,7 @@ enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); llvm_type *DestTy = llvm_type_get_from_tree(TREE_TYPE(exp)); - if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_MD) { + if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD) { fprintf(stderr, "UNKNOWN BUILTIN TYPE: \n"); debug_tree(fndecl); abort(); From lattner at cs.uiuc.edu Fri Jul 16 21:39:51 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 21:39:51 -0500 Subject: [llvm-commits] CVS: llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h Message-ID: <200407170239.VAA17647@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/libstdc++-v3/config/cpu/ia64: atomicity.h updated: 1.1.1.1 -> 1.2 --- Log message: ia64 support for LLVM --- Diffs of the changes: (+11 -0) Index: llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h diff -u llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h:1.1.1.1 llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h:1.2 --- llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h:1.1.1.1 Thu Jan 8 15:59:29 2004 +++ llvm-gcc/libstdc++-v3/config/cpu/ia64/atomicity.h Fri Jul 16 21:39:41 2004 @@ -38,14 +38,25 @@ __attribute__ ((__unused__)) __exchange_and_add (volatile _Atomic_word *__mem, int __val) { +#ifdef __llvm__ + register _Atomic_word __result; + __result = *__mem; + *__mem += __val; + return __result; +#else return __sync_fetch_and_add (__mem, __val); +#endif } static inline void __attribute__ ((__unused__)) __atomic_add (volatile _Atomic_word* __mem, int __val) { +#ifdef __llvm__ + __exchange_and_add(__mem, __val); +#else __sync_fetch_and_add (__mem, __val); +#endif } #endif /* atomicity.h */ From lattner at cs.uiuc.edu Fri Jul 16 21:56:58 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 21:56:58 -0500 Subject: [llvm-commits] CVS: llvm/include/Config/link.h Message-ID: <200407170256.VAA19552@apoc.cs.uiuc.edu> Changes in directory llvm/include/Config: link.h (r1.3) removed --- Log message: Remove dead file --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Fri Jul 16 22:09:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 22:09:22 -0500 Subject: [llvm-commits] CVS: llvm/include/Config/dlfcn.h Message-ID: <200407170309.WAA21624@apoc.cs.uiuc.edu> Changes in directory llvm/include/Config: dlfcn.h updated: 1.3 -> 1.4 --- Log message: link.h causes problems on some platforms and is not needed on solaris, where the comment came from. --- Diffs of the changes: (+0 -9) Index: llvm/include/Config/dlfcn.h diff -u llvm/include/Config/dlfcn.h:1.3 llvm/include/Config/dlfcn.h:1.4 --- llvm/include/Config/dlfcn.h:1.3 Mon Oct 20 15:11:34 2003 +++ llvm/include/Config/dlfcn.h Fri Jul 16 22:09:12 2004 @@ -16,17 +16,8 @@ #include "Config/config.h" -/* - * According to the man pages on dlopen(), we sometimes need link.h. So, - * go grab it just in case. - */ #ifdef HAVE_DLFCN_H #include - -#ifdef HAVE_LINK_H -#include -#endif - #endif #endif From lattner at cs.uiuc.edu Fri Jul 16 23:23:42 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri, 16 Jul 2004 23:23:42 -0500 Subject: [llvm-commits] CVS: llvm-www/www-index.html Message-ID: <200407170423.XAA21847@apoc.cs.uiuc.edu> Changes in directory llvm-www: www-index.html updated: 1.107 -> 1.108 --- Log message: Attempt to address the most prominant misunderstanding of LLVM --- Diffs of the changes: (+6 -0) Index: llvm-www/www-index.html diff -u llvm-www/www-index.html:1.107 llvm-www/www-index.html:1.108 --- llvm-www/www-index.html:1.107 Thu Jul 15 18:15:04 2004 +++ llvm-www/www-index.html Fri Jul 16 23:23:31 2004 @@ -40,6 +40,12 @@ href="CurrentWork.html">Current Projects" for information about other components under development.

    +
  • LLVM does not imply things that you would expect from a +high-level virtual machine. It does not require garbage collection or +run-time code generation (In fact, LLVM makes a great static compiler!). +Note that optional LLVM components can be used to build high-level +virtual machines and other systems that need these services.

  • +

    LLVM is a robust system, particularly well suited for developing new From lattner at cs.uiuc.edu Sat Jul 17 01:28:59 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 01:28:59 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Message-ID: <200407170628.BAA25208@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysisEvaluator.cpp updated: 1.14 -> 1.15 --- Log message: Cleanups: fold two loops into one New features: -print-all-alias-modref-info option, print more info --- Diffs of the changes: (+9 -3) Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.14 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.15 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.14 Sun Jul 4 07:19:55 2004 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Sat Jul 17 01:28:49 2004 @@ -32,6 +32,8 @@ using namespace llvm; namespace { + cl::opt PrintAll("print-all-alias-modref-info", cl::ReallyHidden); + cl::opt PrintNoAlias("print-no-aliases", cl::ReallyHidden); cl::opt PrintMayAlias("print-may-aliases", cl::ReallyHidden); cl::opt PrintMustAlias("print-must-aliases", cl::ReallyHidden); @@ -54,6 +56,11 @@ bool doInitialization(Module &M) { NoAlias = MayAlias = MustAlias = 0; NoModRef = Mod = Ref = ModRef = 0; + + if (PrintAll) { + PrintNoAlias = PrintMayAlias = PrintMustAlias = true; + PrintNoModRef = PrintMod = PrintRef = PrintModRef = true; + } return false; } @@ -90,16 +97,15 @@ for (User::op_iterator OI = (*I).op_begin(); OI != (*I).op_end(); ++OI) if (isa((*OI)->getType())) Pointers.insert(*OI); - } - for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { CallSite CS = CallSite::get(&*I); if (CS.getInstruction()) CallSites.insert(CS); } if (PrintNoAlias || PrintMayAlias || PrintMustAlias || PrintNoModRef || PrintMod || PrintRef || PrintModRef) - std::cerr << "Function: " << F.getName() << "\n"; + std::cerr << "Function: " << F.getName() << ": " << Pointers.size() + << " pointers, " << CallSites.size() << " call sites\n"; // iterate over the worklist, and run the full (n^2)/2 disambiguations for (std::set::iterator I1 = Pointers.begin(), E = Pointers.end(); From lattner at cs.uiuc.edu Sat Jul 17 01:43:31 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 01:43:31 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Message-ID: <200407170643.BAA27626@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysisEvaluator.cpp updated: 1.15 -> 1.16 --- Log message: Print modref information in a useful way. --- Diffs of the changes: (+14 -4) Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.15 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.16 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.15 Sat Jul 17 01:28:49 2004 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Sat Jul 17 01:43:20 2004 @@ -81,6 +81,16 @@ } } +static inline void +PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, + Module *M) { + if (P) { + std::cerr << " " << Msg << ": Ptr: "; + WriteAsOperand(std::cerr, Ptr, true, true, M); + std::cerr << "\t<->" << *I; + } +} + bool AAEval::runOnFunction(Function &F) { AliasAnalysis &AA = getAnalysis(); @@ -133,16 +143,16 @@ Instruction *I = C->getInstruction(); switch (AA.getModRefInfo(*C, *V, (*V)->getType()->getPrimitiveSize())) { case AliasAnalysis::NoModRef: - PrintResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); + PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); ++NoModRef; break; case AliasAnalysis::Mod: - PrintResults("Mod", PrintMod, I, *V, F.getParent()); + PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent()); ++Mod; break; case AliasAnalysis::Ref: - PrintResults("Ref", PrintRef, I, *V, F.getParent()); + PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent()); ++Ref; break; case AliasAnalysis::ModRef: - PrintResults("ModRef", PrintModRef, I, *V, F.getParent()); + PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); ++ModRef; break; default: std::cerr << "Unknown alias query result!\n"; From lattner at cs.uiuc.edu Sat Jul 17 02:40:44 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 02:40:44 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Message-ID: <200407170740.CAA31518@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: AliasAnalysisEvaluator.cpp updated: 1.16 -> 1.17 --- Log message: Fix incorrect computation of mod/ref sets. Do not ask for mod/ref information for objects of size 0. --- Diffs of the changes: (+29 -21) Index: llvm/lib/Analysis/AliasAnalysisEvaluator.cpp diff -u llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.16 llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.17 --- llvm/lib/Analysis/AliasAnalysisEvaluator.cpp:1.16 Sat Jul 17 01:43:20 2004 +++ llvm/lib/Analysis/AliasAnalysisEvaluator.cpp Sat Jul 17 02:40:34 2004 @@ -21,7 +21,7 @@ #include "llvm/iOther.h" #include "llvm/iTerminators.h" #include "llvm/Pass.h" -#include "llvm/Type.h" +#include "llvm/DerivedTypes.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" @@ -137,27 +137,35 @@ // Mod/ref alias analysis: compare all pairs of calls and values for (std::set::iterator V = Pointers.begin(), Ve = Pointers.end(); - V != Ve; ++V) - for (std::set::iterator C = CallSites.begin(), - Ce = CallSites.end(); C != Ce; ++C) { - Instruction *I = C->getInstruction(); - switch (AA.getModRefInfo(*C, *V, (*V)->getType()->getPrimitiveSize())) { - case AliasAnalysis::NoModRef: - PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); - ++NoModRef; break; - case AliasAnalysis::Mod: - PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent()); - ++Mod; break; - case AliasAnalysis::Ref: - PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent()); - ++Ref; break; - case AliasAnalysis::ModRef: - PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); - ++ModRef; break; - default: - std::cerr << "Unknown alias query result!\n"; + V != Ve; ++V) { + unsigned Size = 0; + if (const PointerType *PTy = dyn_cast((*V)->getType())) + if (!(Size = PTy->getElementType()->getPrimitiveSize())) + if (isa(PTy->getElementType())) + Size = 4; // This is a hack, but it's good enough for eval. + + if (Size) + for (std::set::iterator C = CallSites.begin(), + Ce = CallSites.end(); C != Ce; ++C) { + Instruction *I = C->getInstruction(); + switch (AA.getModRefInfo(*C, *V, Size)) { + case AliasAnalysis::NoModRef: + PrintModRefResults("NoModRef", PrintNoModRef, I, *V, F.getParent()); + ++NoModRef; break; + case AliasAnalysis::Mod: + PrintModRefResults(" Mod", PrintMod, I, *V, F.getParent()); + ++Mod; break; + case AliasAnalysis::Ref: + PrintModRefResults(" Ref", PrintRef, I, *V, F.getParent()); + ++Ref; break; + case AliasAnalysis::ModRef: + PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); + ++ModRef; break; + default: + std::cerr << "Unknown alias query result!\n"; + } } - } + } return false; } From llvm at cs.uiuc.edu Sat Jul 17 03:40:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 03:40:04 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/System/README.txt Message-ID: <200407170840.DAA05758@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/System: README.txt added (r1.1) --- Log message: Added a README to point users to the documentation on the design of this library which is a prerequisite for maintaining the library. --- Diffs of the changes: (+14 -0) Index: llvm/include/llvm/System/README.txt diff -c /dev/null llvm/include/llvm/System/README.txt:1.1 *** /dev/null Sat Jul 17 03:40:04 2004 --- llvm/include/llvm/System/README.txt Sat Jul 17 03:39:53 2004 *************** *** 0 **** --- 1,14 ---- + System Utilities Interface + ========================== + + The design of this library has several key constraints aimed at shielding LLVM + from the vagaries of operating system differences. The goal here is to provide + interfaces to operating system concepts (files, memory maps, sockets, signals, + locking, etc) efficiently and in such a way that the remainder of LLVM is + completely operating system agnostic. + + PLEASE READ AND COMPREHEND FULLY THE DOCUMENTATION in + + llvm/docs/SystemLibrary.html + + before making changes to this library. From llvm at cs.uiuc.edu Sat Jul 17 05:04:59 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 05:04:59 -0500 Subject: [llvm-commits] CVS: llvm/docs/SystemLibrary.html Message-ID: <200407171004.FAA15668@zion.cs.uiuc.edu> Changes in directory llvm/docs: SystemLibrary.html added (r1.1) --- Log message: Initial (outline only) draft of the System Library requirements, design and details documentation. --- Diffs of the changes: (+201 -0) Index: llvm/docs/SystemLibrary.html diff -c /dev/null llvm/docs/SystemLibrary.html:1.1 *** /dev/null Sat Jul 17 05:04:59 2004 --- llvm/docs/SystemLibrary.html Sat Jul 17 05:04:49 2004 *************** *** 0 **** --- 1,201 ---- + + + + System Library + + + + +

    System Library
    + +
    Warning: This document is a work in progress.
    + + + +
    +

    Written by the Reid Spencer

    +
    + + + + +
    +

    This document describes the requirements, design, and implementation + details of LLVM's System Library. The library is composed of the header files + in llvm/include/llvm/System and the source files in + llvm/lib/System. The goal of this library is to completely shield + LLVM from the variations in operating system interfaces. By centralizing + LLVM's use of operating system interfaces, we make it possible for the LLVM + tool chain and runtime libraries to be more easily ported to new platforms. + The library also unclutters the rest of LLVM from #ifdef use and special + cases for specific operating systems.

    +

    The System Library was donated to LLVM by Reid Spencer who formulated the + original design as part of the eXtensible Programming System (XPS) which is + based, in part, on LLVM.

    +
    + + + +
    +

    The System library's requirements are aimed at shielding LLVM from the + variations in operating system interfaces. The following sections define the + requirements needed to fulfill this objective.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    In order to fulfill the requirements of the system library, strict design + objectives must be maintained in the library as it evolves. The goal here + is to provide interfaces to operating system concepts (files, memory maps, + sockets, signals, locking, etc) efficiently and in such a way that the + remainder of LLVM is completely operating system agnostic.

    +
    + + + +
    +

    no public data

    +

    onlyprimitive typed private/protected data

    +

    data size is "right" for platform, not max of all platforms

    +

    each class corresponds to O/S concept

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    To be written.

    +
    + + + +
    +

    See bug 351 + for further details on the progress of this work

    +
    + + + +
    +

    The linux implementation of the system library will always be the + reference implementation. This means that (a) the concepts defined by the + linux must be identically replicated in the other implementations and (b) the + linux implementation must always be complete (provide implementations for all + concepts).

    +
    + + + +
    +
    + Valid CSS! + Valid HTML 4.01! + + Reid Spencer
    + LLVM Compiler Infrastructure
    + Last modified: $Date: 2004/07/17 10:04:49 $ +
    + + From lattner at cs.uiuc.edu Sat Jul 17 13:50:29 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 13:50:29 -0500 Subject: [llvm-commits] CVS: llvm/docs/SystemLibrary.html Message-ID: <200407171850.NAA12356@apoc.cs.uiuc.edu> Changes in directory llvm/docs: SystemLibrary.html updated: 1.1 -> 1.2 --- Log message: Hrm, I think we need a "Reid is buggy" bug ;-) --- Diffs of the changes: (+3 -3) Index: llvm/docs/SystemLibrary.html diff -u llvm/docs/SystemLibrary.html:1.1 llvm/docs/SystemLibrary.html:1.2 --- llvm/docs/SystemLibrary.html:1.1 Sat Jul 17 05:04:49 2004 +++ llvm/docs/SystemLibrary.html Sat Jul 17 13:50:19 2004 @@ -166,9 +166,9 @@ - +
    -

    See bug 351 +

    See bug 351 for further details on the progress of this work

    @@ -195,7 +195,7 @@ Reid Spencer
    LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/17 10:04:49 $ + Last modified: $Date: 2004/07/17 18:50:19 $ From lattner at cs.uiuc.edu Sat Jul 17 15:24:16 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 15:24:16 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp Message-ID: <200407172024.PAA21990@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.87 -> 1.88 --- Log message: Reserve the correct amt of space. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.87 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.88 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.87 Sat Jul 10 23:17:04 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Jul 17 15:24:05 2004 @@ -100,7 +100,7 @@ static MachineInstr *MakeMRIInst(unsigned Opcode, unsigned FrameIndex, MachineInstr *MI) { - return addFrameReference(BuildMI(Opcode, 5), FrameIndex) + return addFrameReference(BuildMI(Opcode, 6), FrameIndex) .addReg(MI->getOperand(1).getReg()) .addZImm(MI->getOperand(2).getImmedValue()); } @@ -127,7 +127,7 @@ static MachineInstr *MakeRMIInst(unsigned Opcode, unsigned FrameIndex, MachineInstr *MI) { const MachineOperand& op = MI->getOperand(0); - return addFrameReference(BuildMI(Opcode, 5, op.getReg(), op.getUseType()), + return addFrameReference(BuildMI(Opcode, 6, op.getReg(), op.getUseType()), FrameIndex).addZImm(MI->getOperand(2).getImmedValue()); } From lattner at cs.uiuc.edu Sat Jul 17 15:26:25 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 15:26:25 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86CodeEmitter.cpp Message-ID: <200407172026.PAA22413@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86CodeEmitter.cpp updated: 1.61 -> 1.62 --- Log message: Make sure to emit the immediate byte for instructions like: shrd [mem], reg, imm This fixes the jit-ls failure on 186.crafty. --- Diffs of the changes: (+2 -0) Index: llvm/lib/Target/X86/X86CodeEmitter.cpp diff -u llvm/lib/Target/X86/X86CodeEmitter.cpp:1.61 llvm/lib/Target/X86/X86CodeEmitter.cpp:1.62 --- llvm/lib/Target/X86/X86CodeEmitter.cpp:1.61 Wed Jun 2 00:55:25 2004 +++ llvm/lib/Target/X86/X86CodeEmitter.cpp Sat Jul 17 15:26:14 2004 @@ -577,6 +577,8 @@ case X86II::MRMDestMem: MCE.emitByte(BaseOpcode); emitMemModRMByte(MI, 0, getX86RegNum(MI.getOperand(4).getReg())); + if (MI.getNumOperands() == 6) + emitConstant(MI.getOperand(5).getImmedValue(), sizeOfImm(Desc)); break; case X86II::MRMSrcReg: From llvm at cs.uiuc.edu Sat Jul 17 16:26:10 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 16:26:10 -0500 Subject: [llvm-commits] CVS: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c Message-ID: <200407172126.QAA08523@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl: doio.c updated: 1.2 -> 1.3 --- Log message: get rid of incorrect declaration of shmat(). If it isn't in sys/shm.h then "oh well.." --- Diffs of the changes: (+6 -5) Index: llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c diff -u llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c:1.2 llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c:1.3 --- llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c:1.2 Fri Jun 25 03:07:12 2004 +++ llvm/test/Programs/MultiSource/Benchmarks/MallocBench/perl/doio.c Sat Jul 17 16:26:00 2004 @@ -1,4 +1,4 @@ -/* $RCSfile: doio.c,v $$Revision: 1.2 $$Date: 2004/06/25 08:07:12 $ +/* $RCSfile: doio.c,v $$Revision: 1.3 $$Date: 2004/07/17 21:26:00 $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,10 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: doio.c,v $ + * Revision 1.3 2004/07/17 21:26:00 reid + * get rid of incorrect declaration of shmat(). If it isn't in sys/shm.h then + * "oh well.." + * * Revision 1.2 2004/06/25 08:07:12 lattner * fix the test on FreeBSD, contributed by Vladimir Merzliakov * @@ -2680,7 +2684,7 @@ #endif } -int +int do_shmio(optype, arglast) int optype; int *arglast; @@ -2692,9 +2696,6 @@ char *mbuf, *shm; int id, mpos, msize; struct shmid_ds shmds; -#if !defined(__FreeBSD__) - extern char *shmat(); -#endif id = (int)str_gnum(st[++sp]); mstr = st[++sp]; From lattner at cs.uiuc.edu Sat Jul 17 16:51:35 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 16:51:35 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407172151.QAA31297@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.88 -> 1.89 --- Log message: It looks like physref->virtreg joining is working fine. Enable it by default but make virtreg->virtreg joining stay off by default --- Diffs of the changes: (+19 -10) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.88 llvm/lib/CodeGen/LiveIntervals.cpp:1.89 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.88 Fri Jul 9 06:25:27 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Sat Jul 17 16:51:25 2004 @@ -57,9 +57,13 @@ ("liveintervals", "Number of loads/stores folded into instructions"); cl::opt - join("join-liveintervals", - cl::desc("Join compatible live intervals"), - cl::init(false)); + EnableJoining("join-liveintervals", + cl::desc("Join compatible live intervals"), + cl::init(true)); + cl::opt + EnableVirtVirtJoining("join-liveintervals-virtvirtjoining", + cl::desc("Join live intervals for virtreg pairs (buggy)"), + cl::init(false)); }; void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const @@ -115,7 +119,7 @@ numIntervals += intervals_.size(); // join intervals if requested - if (join) joinIntervals(); + if (EnableJoining) joinIntervals(); numIntervalsAfter += intervals_.size(); @@ -494,15 +498,21 @@ continue; Reg2IntervalMap::iterator r2iA = r2iMap_.find(regA); - assert(r2iA != r2iMap_.end()); + assert(r2iA != r2iMap_.end() && + "Found unknown vreg in 'isMoveInstr' instruction"); Reg2IntervalMap::iterator r2iB = r2iMap_.find(regB); - assert(r2iB != r2iMap_.end()); + assert(r2iB != r2iMap_.end() && + "Found unknown vreg in 'isMoveInstr' instruction"); Intervals::iterator intA = r2iA->second; Intervals::iterator intB = r2iB->second; // both A and B are virtual registers - if (MRegisterInfo::isVirtualRegister(intA->reg) && + + // FIXME: coallescing two virtual registers together is + // apparently broken. + if (EnableVirtVirtJoining && + MRegisterInfo::isVirtualRegister(intA->reg) && MRegisterInfo::isVirtualRegister(intB->reg)) { const TargetRegisterClass *rcA, *rcB; @@ -519,9 +529,8 @@ r2rMap_.insert(std::make_pair(intB->reg, intA->reg)); intervals_.erase(intB); } - } - else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^ - MRegisterInfo::isPhysicalRegister(intB->reg)) { + } else if (MRegisterInfo::isPhysicalRegister(intA->reg) ^ + MRegisterInfo::isPhysicalRegister(intB->reg)) { if (MRegisterInfo::isPhysicalRegister(intB->reg)) { std::swap(regA, regB); std::swap(intA, intB); From lattner at cs.uiuc.edu Sat Jul 17 18:17:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat, 17 Jul 2004 18:17:05 -0500 Subject: [llvm-commits] CVS: llvm-www/ProjectsWithLLVM/index.html Message-ID: <200407172317.SAA01532@apoc.cs.uiuc.edu> Changes in directory llvm-www/ProjectsWithLLVM: index.html updated: 1.14 -> 1.15 --- Log message: Add scheme front-end link Cleanup the page a lot to make it not look really bad and emphasize that which is important. The use of doc_subsubsection leaves something to be desired though. --- Diffs of the changes: (+76 -32) Index: llvm-www/ProjectsWithLLVM/index.html diff -u llvm-www/ProjectsWithLLVM/index.html:1.14 llvm-www/ProjectsWithLLVM/index.html:1.15 --- llvm-www/ProjectsWithLLVM/index.html:1.14 Thu May 13 16:50:00 2004 +++ llvm-www/ProjectsWithLLVM/index.html Sat Jul 17 18:16:54 2004 @@ -1,6 +1,8 @@
    Projects built with LLVM
    +
    +

    This page is an incomplete list of the projects built with LLVM, sorted in reverse chronological order. The idea of this list is to show some of the things that have been done with LLVM for various course projects or for other purposes, @@ -20,20 +22,47 @@ would like to put up the "polished results" of your work, including reports, papers, presentations, posters, or anything else you have.

    +
    + + + + + +
    By: Tobias Nurmiranta
    + +
    +

    +This is a small scheme +compiler for LLVM, written in scheme. It is good enough to compile itself +and work.

    + +

    The code is quite similar to the code in the book SICP (Structure and +Interpretation of Computer Programs), chapter five, with the difference that it +implements the extra functionality that SICP assumes that the explicit control +evaluator (virtual machine) already have. Much functionality of the compiler is +implemented in a subset of scheme, llvm-defines, which are compiled to llvm +functions.

    +
    + + -
    -CS497rej: Object-Oriented Programming and Design (Spring 2004) + + + +

    The LLVM Visualization Tool (LLVM-TV) can be used to visualize the effects of transformations written in the LLVM framework. Our visualizations @@ -59,18 +88,21 @@ page with overview; design doc, user manual & download on the LLVM-TV website

    +
    + -
    -CS426: Advanced Compilers (Fall 2003) + +

    Linear scan register allocation is a fast global register allocation first presented in Linear Scan Register Allocation as an alternative to the more widely used graph @@ -82,11 +114,16 @@

    Project report: PS, PDF

    +
    + -
    XPS - eXtensible Programming System - eXtensible -Systems, Inc.
    +
    XPS - eXtensible Programming System
    +
    By: eXtensible Systems, Inc.
    + +
    +

    The XPS project's purpose is to provide a comprehensive application programming platform that will make development of high-quality Internet-aware applications easier and accessible to the non-programmer. This project also @@ -124,18 +161,20 @@ This information is somewhat dated but may provide an overview. XPS is getting a new home on the Internet soon. We'll update this link when its available.

    +
    + -
    CS497YYZ: Hot Topics in Operating Systems (Fall -2003)
    + + +

    "Traditional architectures use the hardware instruction set for dual purposes: first, as a language in which to express the semantics of software programs, and second, as a means for controlling the hardware. The thesis of @@ -167,12 +206,19 @@ PDF

    - +
    + + +
    +SPEDI: Static Patch Extraction and Dynamic Insertion +
    + +
    -SPEDI: Static Patch Extraction and Dynamic Insertion
    -Brian Fahs +By: Brian Fahs
    +

    "As every modern computer user has experienced, software updates and upgrades frequently require programs and sometimes the entire operating system to be restarted. This can be a painful and annoying experience. What if this @@ -190,28 +236,22 @@

    Project report: PS, PDF

    +
    - - - - - + - -
    CS426: Advanced Compilers (Fall 2002)
    - +
    -An LLVM Implementation of SSAPRE
    Tanya Brethour, Joel Stanley, Bill Wendling
    +

    "In this report we present implementation details, empirical performance data, and notable modifications to an algorithm for PRE based on [the 1999 TOPLAS SSAPRE paper]. In [the 1999 TOPLAS SSAPRE paper], a particular @@ -224,21 +264,24 @@

    Project report: PS, PDF

    +
    -
    CS497CZ: Dynamic Translation and Optimization -(Spring 2002)
    +
    +Jello: a retargetable Just-In-Time compiler + for LLVM bytecode
    + +
    -Jello: a retargetable Just-In-Time compiler - for LLVM bytecode
    Chris Lattner, Misha Brukman, Brian Gaeke
    +

    "We present the design and implementation of Jello, a retargetable Just-In-Time (JIT) compiler for the Intel IA32 architecture. The input to Jello is a C program statically compiled to Low-Level Virtual Machine (LLVM) bytecode. @@ -258,5 +301,6 @@

    Project report: PS, PDF

    +
    From llvm at cs.uiuc.edu Sat Jul 17 18:23:40 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:23:40 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Bytecode/BytecodeHandler.h Message-ID: <200407172323.SAA08969@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Bytecode: BytecodeHandler.h updated: 1.3 -> 1.4 --- Log message: Constant value not needed after CPR's disappear. --- Diffs of the changes: (+1 -2) Index: llvm/include/llvm/Bytecode/BytecodeHandler.h diff -u llvm/include/llvm/Bytecode/BytecodeHandler.h:1.3 llvm/include/llvm/Bytecode/BytecodeHandler.h:1.4 --- llvm/include/llvm/Bytecode/BytecodeHandler.h:1.3 Sun Jul 4 06:29:56 2004 +++ llvm/include/llvm/Bytecode/BytecodeHandler.h Sat Jul 17 18:23:30 2004 @@ -255,8 +255,7 @@ virtual void handleConstantPointer( const PointerType* PT, ///< Type of the pointer unsigned Slot, ///< Slot num of initializer value - GlobalValue* GV, ///< Referenced global value - Constant* Val ///< Value of constant + GlobalValue* GV ///< Referenced global value ) {} /// @brief Handle a constant strings (array special case) From llvm at cs.uiuc.edu Sat Jul 17 18:26:23 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:26:23 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constant.h Message-ID: <200407172326.SAA08997@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constant.h updated: 1.13 -> 1.14 --- Log message: Extend constructor so that it can support GlobalValue's (with names). Make GlobalValue a "classof" Constant Fix the classof(Value*) to include GlobalValue's --- Diffs of the changes: (+7 -9) Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.13 llvm/include/llvm/Constant.h:1.14 --- llvm/include/llvm/Constant.h:1.13 Mon Mar 8 00:10:32 2004 +++ llvm/include/llvm/Constant.h Sat Jul 17 18:26:12 2004 @@ -20,7 +20,9 @@ class Constant : public User { protected: - inline Constant(const Type *Ty) : User(Ty, Value::ConstantVal) {} + inline Constant(const Type *Ty, ValueTy vty = Value::ConstantVal, + const std::string& Name = "" ) + : User(Ty, vty, Name) {} ~Constant() {} void destroyConstantImpl(); @@ -50,20 +52,16 @@ /// available cached constants. Implementations should call /// destroyConstantImpl as the last thing they do, to destroy all users and /// delete this. - /// - /// Note that this call is only valid on non-primitive constants: You cannot - /// destroy an integer constant for example. This API is used to delete - /// constants that have ConstantPointerRef's embeded in them when the module - /// is deleted, and it is used by GlobalDCE to remove ConstantPointerRefs that - /// are unneeded, allowing globals to be DCE'd. - /// virtual void destroyConstant() { assert(0 && "Not reached!"); } //// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Constant *) { return true; } + static inline bool classof(const GlobalValue *) { return true; } static inline bool classof(const Value *V) { - return V->getValueType() == Value::ConstantVal; + return V->getValueType() == Value::ConstantVal || + V->getValueType() == Value::FunctionVal || + V->getValueType() == Value::GlobalVariableVal; } /// replaceUsesOfWithOnConstant - This method is a special form of From llvm at cs.uiuc.edu Sat Jul 17 18:27:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:27:07 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200407172327.SAA09011@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.49 -> 1.50 --- Log message: ****** ABOLISH ConstantPointerRef ***** --- Diffs of the changes: (+0 -38) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.49 llvm/include/llvm/Constants.h:1.50 --- llvm/include/llvm/Constants.h:1.49 Mon Jul 12 15:36:08 2004 +++ llvm/include/llvm/Constants.h Sat Jul 17 18:26:57 2004 @@ -465,44 +465,6 @@ }; -//===--------------------------------------------------------------------------- -/// ConstantPointerRef - a constant pointer value that is initialized to -/// point to a global value, which lies at a constant, fixed address. -/// -class ConstantPointerRef : public Constant { - friend class Module; // Modules maintain these references - ConstantPointerRef(const ConstantPointerRef &); // DNI! - -protected: - ConstantPointerRef(GlobalValue *GV); -public: - /// get() - Static factory methods - Return objects of the specified value - static ConstantPointerRef *get(GlobalValue *GV); - - const GlobalValue *getValue() const { - return cast(Operands[0].get()); - } - - GlobalValue *getValue() { - return cast(Operands[0].get()); - } - - /// isNullValue - Return true if this is the value that would be returned by - /// getNullValue. - virtual bool isNullValue() const { return false; } - - virtual void destroyConstant(); - virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking = false); - - /// Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const ConstantPointerRef *) { return true; } - static bool classof(const Constant *CPV); - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); - } -}; - // ConstantExpr - a constant value that is initialized with an expression using // other constant values. This is only used to represent values that cannot be // evaluated at compile-time (e.g., something derived from an address) because From llvm at cs.uiuc.edu Sat Jul 17 18:28:38 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:28:38 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalValue.h Message-ID: <200407172328.SAA09027@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalValue.h updated: 1.15 -> 1.16 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - derive from Constant - declare needed overrides from Constant class --- Diffs of the changes: (+18 -4) Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.15 llvm/include/llvm/GlobalValue.h:1.16 --- llvm/include/llvm/GlobalValue.h:1.15 Sun Jul 11 20:17:52 2004 +++ llvm/include/llvm/GlobalValue.h Sat Jul 17 18:28:28 2004 @@ -17,14 +17,14 @@ #ifndef LLVM_GLOBALVALUE_H #define LLVM_GLOBALVALUE_H -#include "llvm/User.h" +#include "llvm/Constant.h" namespace llvm { class PointerType; class Module; -class GlobalValue : public User { +class GlobalValue : public Constant { GlobalValue(const GlobalValue &); // do not implement public: enum LinkageTypes { @@ -37,12 +37,19 @@ protected: GlobalValue(const Type *Ty, ValueTy vty, LinkageTypes linkage, const std::string &name = "") - : User(Ty, vty, name), Linkage(linkage), Parent(0) {} + : Constant(Ty, vty, name), Linkage(linkage), Parent(0) { } LinkageTypes Linkage; // The linkage of this global Module *Parent; public: - ~GlobalValue() {} + virtual ~GlobalValue(); + + /// If the usage is empty (except transitively dead constants), then this + /// global value can can be safely deleted since the destructor wll + /// delete the dead constants as well. + /// @brief Determine if theusage of this global value is empty except + /// for transitively dead constants. + bool use_empty_except_constants(); /// getType - Global values are always pointers. inline const PointerType *getType() const { @@ -56,6 +63,13 @@ bool hasInternalLinkage() const { return Linkage == InternalLinkage; } void setLinkage(LinkageTypes LT) { Linkage = LT; } LinkageTypes getLinkage() const { return Linkage; } + + /// Override from Constant class. No GlobalValue's have null values so + /// this always returns false. + virtual bool isNullValue() const { return false; } + + /// Override from Constant class. + virtual void destroyConstant(); /// isExternal - Return true if the primary definition of this global value is /// outside of the current translation unit... From llvm at cs.uiuc.edu Sat Jul 17 18:29:56 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:29:56 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalVariable.h Message-ID: <200407172329.SAA09049@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalVariable.h updated: 1.27 -> 1.28 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : Now that GlobalVariable is a constant (via derivation from GlobalValue), override the replaceUsesOfWithOnConstant method. --- Diffs of the changes: (+5 -0) Index: llvm/include/llvm/GlobalVariable.h diff -u llvm/include/llvm/GlobalVariable.h:1.27 llvm/include/llvm/GlobalVariable.h:1.28 --- llvm/include/llvm/GlobalVariable.h:1.27 Fri Jul 2 13:41:18 2004 +++ llvm/include/llvm/GlobalVariable.h Sat Jul 17 18:29:46 2004 @@ -98,6 +98,11 @@ bool isConstant() const { return isConstantGlobal; } void setConstant(bool Value) { isConstantGlobal = Value; } + /// Override Constant's implementation of this method so we can + /// replace constant initializers. + virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking = false); + virtual void print(std::ostream &OS) const; // Methods for support type inquiry through isa, cast, and dyn_cast: From llvm at cs.uiuc.edu Sat Jul 17 18:30:21 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:30:21 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Module.h Message-ID: <200407172330.SAA09083@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Module.h updated: 1.45 -> 1.46 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : We don't need to keep track of CPRs any more. --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/Module.h diff -u llvm/include/llvm/Module.h:1.45 llvm/include/llvm/Module.h:1.46 --- llvm/include/llvm/Module.h:1.45 Tue Jun 8 12:44:21 2004 +++ llvm/include/llvm/Module.h Sat Jul 17 18:30:11 2004 @@ -66,7 +66,6 @@ private: GlobalListType GlobalList; // The Global Variables in the module FunctionListType FunctionList; // The Functions in the module - GlobalValueRefMap *GVRefMap; // Keep track of GlobalValueRef's SymbolTable *SymTab; // Symbol Table for the module std::string ModuleID; // Human readable identifier for the module From llvm at cs.uiuc.edu Sat Jul 17 18:30:55 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:30:55 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/SymbolTable.h Message-ID: <200407172330.SAA09095@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: SymbolTable.h updated: 1.36 -> 1.37 --- Log message: Fix a comment. --- Diffs of the changes: (+2 -3) Index: llvm/include/llvm/SymbolTable.h diff -u llvm/include/llvm/SymbolTable.h:1.36 llvm/include/llvm/SymbolTable.h:1.37 --- llvm/include/llvm/SymbolTable.h:1.36 Sun Jul 4 05:49:41 2004 +++ llvm/include/llvm/SymbolTable.h Sat Jul 17 18:30:45 2004 @@ -159,9 +159,8 @@ insertEntry(Val->getName(), Val->getType(), Val); } - /// Inserts a constant or type into the symbol table with the specified - /// name. There can be a many to one mapping between names and constants - /// or types. + /// Inserts a constant into the symbol table with the specified + /// name. There can be a many to one mapping between names and constants. /// @brief Insert a constant or type. inline void insert(const std::string &Name, Value *Val) { assert(Val && "Can't insert null type into symbol table!"); From llvm at cs.uiuc.edu Sat Jul 17 18:32:21 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:32:21 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/User.h Message-ID: <200407172332.SAA09116@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: User.h updated: 1.30 -> 1.31 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : Remove redundancy in User::classof(Value*); GlobalValue isa Constant now. --- Diffs of the changes: (+1 -2) Index: llvm/include/llvm/User.h diff -u llvm/include/llvm/User.h:1.30 llvm/include/llvm/User.h:1.31 --- llvm/include/llvm/User.h:1.30 Sun Jun 27 13:01:15 2004 +++ llvm/include/llvm/User.h Sat Jul 17 18:32:11 2004 @@ -87,8 +87,7 @@ // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const User *) { return true; } static inline bool classof(const Value *V) { - return isa(V) || isa(V) || - isa(V); + return isa(V) || isa(V); } }; From llvm at cs.uiuc.edu Sat Jul 17 18:34:57 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:34:57 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407172334.SAA09139@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.57 -> 1.58 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Add ValueListTy to TypeTy so that the bcreader can have its own User category that won't get factored into any optimizations or cleanup. - Correct an isa_impl to correctly include GlobalValue now that it isa Constant. --- Diffs of the changes: (+4 -1) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.57 llvm/include/llvm/Value.h:1.58 --- llvm/include/llvm/Value.h:1.57 Wed Jul 14 21:54:36 2004 +++ llvm/include/llvm/Value.h Sat Jul 17 18:34:47 2004 @@ -128,6 +128,7 @@ GlobalVariableVal, // This is an instance of GlobalVariable ConstantVal, // This is an instance of Constant InstructionVal, // This is an instance of Instruction + ValueListVal // This is for bcreader, a special ValTy }; unsigned getValueType() const { return SubclassID; @@ -177,7 +178,9 @@ // the subtype header files to test to see if the value is a subclass... // template <> inline bool isa_impl(const Value &Val) { - return Val.getValueType() == Value::ConstantVal; + return Val.getValueType() == Value::ConstantVal || + Val.getValueType() == Value::FunctionVal || + Val.getValueType() == Value::GlobalVariableVal; } template <> inline bool isa_impl(const Value &Val) { return Val.getValueType() == Value::ArgumentVal; From llvm at cs.uiuc.edu Sat Jul 17 18:37:08 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:37:08 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/InstForest.h Message-ID: <200407172337.SAA09155@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: InstForest.h updated: 1.25 -> 1.26 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : remove redundant isa ensure isa case is processed before is --- Diffs of the changes: (+9 -7) Index: llvm/include/llvm/Analysis/InstForest.h diff -u llvm/include/llvm/Analysis/InstForest.h:1.25 llvm/include/llvm/Analysis/InstForest.h:1.26 --- llvm/include/llvm/Analysis/InstForest.h:1.25 Wed Jul 14 21:50:38 2004 +++ llvm/include/llvm/Analysis/InstForest.h Sat Jul 17 18:36:58 2004 @@ -163,8 +163,8 @@ void removeInstFromRootList(Instruction *I) { for (unsigned i = this->size(); i > 0; --i) if ((*this)[i-1]->getValue() == I) { - this->erase(this->begin()+i-1); - return; + this->erase(this->begin()+i-1); + return; } } @@ -238,15 +238,17 @@ // template InstTreeNode::InstTreeNode(InstForest &IF, Value *V, - InstTreeNode *Parent) : super(Parent) { + InstTreeNode *Parent) : super(Parent) { this->getTreeData().first.first = V; // Save tree node if (!isa(V)) { - assert((isa(V) || isa(V) || - isa(V) || isa(V)) && - "Unrecognized value type for InstForest Partition!"); + assert(isa(V) || isa(V) || isa(V) && + "Unrecognized value type for InstForest Partition!"); if (isa(V)) - this->getTreeData().first.second = ConstNode; + if (isa(V)) + this->getTreeData().first.second = TemporaryNode; + else + this->getTreeData().first.second = ConstNode; else if (isa(V)) this->getTreeData().first.second = BasicBlockNode; else From llvm at cs.uiuc.edu Sat Jul 17 18:45:33 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:45:33 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407172345.SAA09211@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.147 -> 1.148 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+19 -23) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.147 llvm/lib/VMCore/AsmWriter.cpp:1.148 --- llvm/lib/VMCore/AsmWriter.cpp:1.147 Wed Jul 14 21:51:31 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sat Jul 17 18:45:23 2004 @@ -381,6 +381,7 @@ } } +/// @brief Internal constant writer. static void WriteConstantInt(std::ostream &Out, const Constant *CV, bool PrintName, std::map &TypeTable, @@ -493,9 +494,6 @@ } else if (isa(CV)) { Out << "null"; - } else if (const ConstantPointerRef *PR = dyn_cast(CV)) { - WriteAsOperandInternal(Out, PR->getValue(), true, TypeTable, Machine); - } else if (const ConstantExpr *CE = dyn_cast(CV)) { Out << CE->getOpcodeName() << " ("; @@ -527,12 +525,13 @@ std::map &TypeTable, SlotMachine *Machine) { Out << ' '; - if (PrintName && V->hasName()) { + if ((PrintName || isa(V)) && V->hasName()) Out << getLLVMName(V->getName()); - } else { - if (const Constant *CV = dyn_cast(V)) { + else { + const Constant *CV = dyn_cast(V); + if (CV && !isa(CV)) WriteConstantInt(Out, CV, PrintName, TypeTable, Machine); - } else { + else { int Slot; if (Machine) { Slot = Machine->getSlot(V); @@ -764,8 +763,14 @@ Out << (GV->isConstant() ? "constant " : "global "); printType(GV->getType()->getElementType()); - if (GV->hasInitializer()) - writeOperand(GV->getInitializer(), false, false); + if (GV->hasInitializer()) { + Constant* C = cast(GV->getInitializer()); + assert(C && "GlobalVar initializer isn't constant?"); + if (isa(C)) + writeOperand(GV->getInitializer(), false, true); + else + writeOperand(GV->getInitializer(), false, false); + } printInfoComment(*GV); Out << "\n"; @@ -794,8 +799,9 @@ SymbolTable::value_const_iterator VE = ST.value_end(PI->first); for (; VI != VE; ++VI) { - const Value *V = VI->second; - if (const Constant *CPV = dyn_cast(V)) { + const Value* V = VI->second; + const Constant *CPV = dyn_cast(V) ; + if (CPV && !isa(V)) { printConstant(CPV); } } @@ -1162,12 +1168,6 @@ void Constant::print(std::ostream &o) const { if (this == 0) { o << " constant value\n"; return; } - // Handle CPR's special, because they have context information... - if (const ConstantPointerRef *CPR = dyn_cast(this)) { - CPR->getValue()->print(o); // Print as a global value, with context info. - return; - } - o << ' ' << getType()->getDescription() << ' '; std::map TypeTable; @@ -1347,10 +1347,6 @@ // Check for uninitialized state and do lazy initialization this->initialize(); - // Do not number CPR's at all. They are an abomination - if ( const ConstantPointerRef* CPR = dyn_cast(V) ) - V = CPR->getValue() ; - // Get the type of the value const Type* VTy = V->getType(); @@ -1593,8 +1589,8 @@ SC_DEBUG(" Inserting value [" << VTy << "] = " << V << " slot=" << DestSlot << " ["); // G = Global, C = Constant, T = Type, F = Function, o = other - SC_DEBUG((isa(V) ? 'G' : (isa(V) ? 'C' : - (isa(V) ? 'F' : 'o')))); + SC_DEBUG((isa(V) ? 'G' : (isa(V) ? 'F' : + (isa(V) ? 'C' : 'o')))); SC_DEBUG("]\n"); return DestSlot; } From llvm at cs.uiuc.edu Sat Jul 17 18:47:11 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:47:11 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200407172347.SAA09227@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.61 -> 1.62 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+20 -23) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.61 llvm/lib/VMCore/ConstantFolding.cpp:1.62 --- llvm/lib/VMCore/ConstantFolding.cpp:1.61 Wed Jul 14 20:16:59 2004 +++ llvm/lib/VMCore/ConstantFolding.cpp Sat Jul 17 18:47:01 2004 @@ -486,7 +486,7 @@ static DirectFPRules DoubleR; if (isa(V1) || isa(V2) || - isa(V1) || isa(V2)) + isa(V1) || isa(V2)) return EmptyR; switch (V1->getType()->getTypeID()) { @@ -525,12 +525,12 @@ if (V->getType() == DestTy) return (Constant*)V; // Cast of a global address to boolean is always true. - if (const ConstantPointerRef *CPR = dyn_cast(V)) + if (const GlobalValue *GV = dyn_cast(V)) if (DestTy == Type::BoolTy) // FIXME: When we support 'external weak' references, we have to prevent // this transformation from happening. In the meantime we avoid folding // any cast of an external symbol. - if (!CPR->getValue()->isExternal()) + if (!GV->isExternal()) return ConstantBool::True; if (const ConstantExpr *CE = dyn_cast(V)) @@ -624,15 +624,15 @@ /// evaluateRelation - This function determines if there is anything we can /// decide about the two constants provided. This doesn't need to handle simple -/// things like integer comparisons, but should instead handle ConstantExpr's -/// and ConstantPointerRef's. If we can determine that the two constants have a +/// things like integer comparisons, but should instead handle ConstantExprs +/// and GlobalValuess. If we can determine that the two constants have a /// particular relation to each other, we should return the corresponding SetCC /// code, otherwise return Instruction::BinaryOpsEnd. /// /// To simplify this code we canonicalize the relation so that the first /// operand is always the most "complex" of the two. We consider simple /// constants (like ConstantInt) to be the simplest, followed by -/// ConstantPointerRef's, followed by ConstantExpr's (the most complex). +/// GlobalValues, followed by ConstantExpr's (the most complex). /// static Instruction::BinaryOps evaluateRelation(const Constant *V1, const Constant *V2) { @@ -640,15 +640,15 @@ "Cannot compare different types of values!"); if (V1 == V2) return Instruction::SetEQ; - if (!isa(V1) && !isa(V1)) { + if (!isa(V1) && !isa(V1)) { // If the first operand is simple, swap operands. - assert((isa(V2) || isa(V2)) && + assert((isa(V2) || isa(V2)) && "Simple cases should have been handled by caller!"); Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1); if (SwappedRelation != Instruction::BinaryOpsEnd) return SetCondInst::getSwappedCondition(SwappedRelation); - } else if (const ConstantPointerRef *CPR1 = dyn_cast(V1)){ + } else if (const GlobalValue *CPR1 = dyn_cast(V1)){ if (isa(V2)) { // Swap as necessary. Instruction::BinaryOps SwappedRelation = evaluateRelation(V2, V1); if (SwappedRelation != Instruction::BinaryOpsEnd) @@ -657,11 +657,11 @@ return Instruction::BinaryOpsEnd; } - // Now we know that the RHS is a ConstantPointerRef or simple constant, + // Now we know that the RHS is a GlobalValue or simple constant, // which (since the types must match) means that it's a ConstantPointerNull. - if (const ConstantPointerRef *CPR2 = dyn_cast(V2)) { - assert(CPR1->getValue() != CPR2->getValue() && - "CPRs for the same value exist at different addresses??"); + if (const GlobalValue *CPR2 = dyn_cast(V2)) { + assert(CPR1 != CPR2 && + "GVs for the same value exist at different addresses??"); // FIXME: If both globals are external weak, they might both be null! return Instruction::SetNE; } else { @@ -693,7 +693,7 @@ if (isa(V2)) { // If we are comparing a GEP to a null pointer, check to see if the base // of the GEP equals the null pointer. - if (isa(CE1Op0)) { + if (isa(CE1Op0)) { // FIXME: this is not true when we have external weak references! // No offset can go from a global to a null pointer. return Instruction::SetGT; @@ -708,13 +708,11 @@ return Instruction::SetEQ; } // Otherwise, we can't really say if the first operand is null or not. - } else if (const ConstantPointerRef *CPR2 = - dyn_cast(V2)) { + } else if (const GlobalValue *CPR2 = dyn_cast(V2)) { if (isa(CE1Op0)) { // FIXME: This is not true with external weak references. return Instruction::SetLT; - } else if (const ConstantPointerRef *CPR1 = - dyn_cast(CE1Op0)) { + } else if (const GlobalValue *CPR1 = dyn_cast(CE1Op0)) { if (CPR1 == CPR2) { // If this is a getelementptr of the same global, then it must be // different. Because the types must match, the getelementptr could @@ -741,8 +739,7 @@ case Instruction::GetElementPtr: // By far the most common case to handle is when the base pointers are // obviously to the same or different globals. - if (isa(CE1Op0) && - isa(CE2Op0)) { + if (isa(CE1Op0) && isa(CE2Op0)) { if (CE1Op0 != CE2Op0) // Don't know relative ordering, but not equal return Instruction::SetNE; // Ok, we know that both getelementptr instructions are based on the @@ -896,13 +893,13 @@ return const_cast(V1); // X & -1 == X if (V2->isNullValue()) return const_cast(V2); // X & 0 == 0 if (CE1->getOpcode() == Instruction::Cast && - isa(CE1->getOperand(0))) { - ConstantPointerRef *CPR =cast(CE1->getOperand(0)); + isa(CE1->getOperand(0))) { + GlobalValue *CPR =cast(CE1->getOperand(0)); // Functions are at least 4-byte aligned. If and'ing the address of a // function with a constant < 4, fold it to zero. if (const ConstantInt *CI = dyn_cast(V2)) - if (CI->getRawValue() < 4 && isa(CPR->getValue())) + if (CI->getRawValue() < 4 && isa(CPR)) return Constant::getNullValue(CI->getType()); } break; From llvm at cs.uiuc.edu Sat Jul 17 18:48:43 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:48:43 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200407172348.SAA09253@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.94 -> 1.95 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass - Delete ConstantPointerRef member function implementations --- Diffs of the changes: (+5 -57) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.94 llvm/lib/VMCore/Constants.cpp:1.95 --- llvm/lib/VMCore/Constants.cpp:1.94 Mon Jul 12 15:35:11 2004 +++ llvm/lib/VMCore/Constants.cpp Sat Jul 17 18:48:33 2004 @@ -14,6 +14,7 @@ #include "llvm/Constants.h" #include "ConstantFolding.h" #include "llvm/DerivedTypes.h" +#include "llvm/GlobalValue.h" #include "llvm/iMemory.h" #include "llvm/SymbolTable.h" #include "llvm/Module.h" @@ -54,8 +55,8 @@ << *V << "\n\n"; #endif assert(isa(V) && "References remain to Constant being destroyed"); - Constant *CPV = cast(V); - CPV->destroyConstant(); + Constant *CV = cast(V); + CV->destroyConstant(); // The constant should remove itself from our use list... assert((use_empty() || use_back() != V) && "Constant not removed!"); @@ -267,12 +268,6 @@ } } -ConstantPointerRef::ConstantPointerRef(GlobalValue *GV) - : Constant(GV->getType()) { - Operands.reserve(1); - Operands.push_back(Use(GV, this)); -} - ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) : Constant(Ty), iType(Opcode) { Operands.reserve(1); @@ -420,16 +415,10 @@ } bool ConstantPointerNull::classof(const Constant *CPV) { - return isa(CPV->getType()) && !isa(CPV) && + return !isa(CPV) && isa(CPV->getType()) && !isa(CPV) && CPV->getNumOperands() == 0; } -bool ConstantPointerRef::classof(const Constant *CPV) { - return isa(CPV->getType()) && !isa(CPV) && - CPV->getNumOperands() == 1; -} - - //===----------------------------------------------------------------------===// // isValueValidForType implementations @@ -532,31 +521,6 @@ destroyConstant(); } -void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To, - bool DisableChecking) { - if (isa(To)) { - assert(From == getOperand(0) && "Doesn't contain from!"); - ConstantPointerRef *Replacement = - ConstantPointerRef::get(cast(To)); - - // Everyone using this now uses the replacement... - if (DisableChecking) - uncheckedReplaceAllUsesWith(Replacement); - else - replaceAllUsesWith(Replacement); - - } else { - // Just replace ourselves with the To value specified. - if (DisableChecking) - uncheckedReplaceAllUsesWith(To); - else - replaceAllUsesWith(To); - } - - // Delete the old constant! - destroyConstant(); -} - void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, bool DisableChecking) { assert(isa(ToV) && "Cannot make Constant refer to non-constant!"); @@ -1050,23 +1014,6 @@ } -//---- ConstantPointerRef::get() implementation... -// -ConstantPointerRef *ConstantPointerRef::get(GlobalValue *GV) { - assert(GV->getParent() && "Global Value must be attached to a module!"); - - // The Module handles the pointer reference sharing... - return GV->getParent()->getConstantPointerRef(GV); -} - -// destroyConstant - Remove the constant from the constant table... -// -void ConstantPointerRef::destroyConstant() { - getValue()->getParent()->destroyConstantPointerRef(this); - destroyConstantImpl(); -} - - //---- ConstantExpr::get() implementations... // typedef std::pair > ExprMapKeyType; @@ -1259,3 +1206,4 @@ const char *ConstantExpr::getOpcodeName() const { return Instruction::getOpcodeName(getOpcode()); } + From llvm at cs.uiuc.edu Sat Jul 17 18:50:29 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:50:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Message-ID: <200407172350.SAA09341@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.75 -> 1.76 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Move GlobalValue and GlobalVariable implementations to Globals.cpp --- Diffs of the changes: (+3 -72) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.75 llvm/lib/VMCore/Function.cpp:1.76 --- llvm/lib/VMCore/Function.cpp:1.75 Mon Jul 12 15:27:31 2004 +++ llvm/lib/VMCore/Function.cpp Sat Jul 17 18:50:19 2004 @@ -68,7 +68,7 @@ void Argument::setName(const std::string &name, SymbolTable *ST) { Function *P; assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); + "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); @@ -82,42 +82,6 @@ LeakDetector::removeGarbageObject(this); } -static bool removeDeadConstantUsers(Constant *C) { - while (!C->use_empty()) { - if (Constant *CU = dyn_cast(C->use_back())) { - if (!removeDeadConstantUsers(CU)) - return false; // Constant wasn't dead. - } else { - return false; // Nonconstant user of the global. - } - } - - C->destroyConstant(); - return true; -} - - -/// removeDeadConstantUsers - If there are any dead constant users dangling -/// off of this global value, remove them. This method is useful for clients -/// that want to check to see if a global is unused, but don't want to deal -/// with potentially dead constants hanging off of the globals. -/// -/// This function returns true if the global value is now dead. If all -/// users of this global are not dead, this method may return false and -/// leave some of them around. -bool GlobalValue::removeDeadConstantUsers() { - while (!use_empty()) { - if (Constant *C = dyn_cast(use_back())) { - if (!::removeDeadConstantUsers(C)) - return false; // Constant wasn't dead. - } else { - return false; // Nonconstant user of the global. - } - } - return true; -} - - //===----------------------------------------------------------------------===// // Function Implementation //===----------------------------------------------------------------------===// @@ -161,7 +125,7 @@ void Function::setName(const std::string &name, SymbolTable *ST) { Module *P; assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); + "Invalid symtab argument!"); if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); Value::setName(name); if (P && hasName()) P->getSymbolTable().insert(this); @@ -294,37 +258,4 @@ } -//===----------------------------------------------------------------------===// -// GlobalVariable Implementation -//===----------------------------------------------------------------------===// - -GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, - Constant *Initializer, - const std::string &Name, Module *ParentModule) - : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name), - isConstantGlobal(constant) { - if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); - - LeakDetector::addGarbageObject(this); - - if (ParentModule) - ParentModule->getGlobalList().push_back(this); -} - -void GlobalVariable::setParent(Module *parent) { - if (getParent()) - LeakDetector::addGarbageObject(this); - Parent = parent; - if (getParent()) - LeakDetector::removeGarbageObject(this); -} - -// Specialize setName to take care of symbol table majik -void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { - Module *P; - assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && - "Invalid symtab argument!"); - if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); - Value::setName(name); - if (P && hasName()) P->getSymbolTable().insert(this); -} +// vim: sw=2 ai From llvm at cs.uiuc.edu Sat Jul 17 18:51:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:51:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Linker.cpp Message-ID: <200407172351.SAA09353@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Linker.cpp updated: 1.73 -> 1.74 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+4 -7) Index: llvm/lib/VMCore/Linker.cpp diff -u llvm/lib/VMCore/Linker.cpp:1.73 llvm/lib/VMCore/Linker.cpp:1.74 --- llvm/lib/VMCore/Linker.cpp:1.73 Sun Jul 4 06:52:49 2004 +++ llvm/lib/VMCore/Linker.cpp Sat Jul 17 18:50:57 2004 @@ -307,10 +307,8 @@ Result = ConstantStruct::get(cast(CPS->getType()), Operands); } else if (isa(CPV)) { Result = const_cast(CPV); - } else if (const ConstantPointerRef *CPR = - dyn_cast(CPV)) { - Value *V = RemapOperand(CPR->getValue(), LocalMap, GlobalMap); - Result = ConstantPointerRef::get(cast(V)); + } else if (isa(CPV)) { + Result = cast(RemapOperand(CPV, LocalMap, GlobalMap)); } else if (const ConstantExpr *CE = dyn_cast(CPV)) { if (CE->getOpcode() == Instruction::GetElementPtr) { Value *Ptr = RemapOperand(CE->getOperand(0), LocalMap, GlobalMap); @@ -834,9 +832,8 @@ // FIXME: This should rewrite simple/straight-forward uses such as // getelementptr instructions to not use the Cast! - ConstantPointerRef *NGCP = ConstantPointerRef::get(NG); - G1->replaceAllUsesWith(ConstantExpr::getCast(NGCP, G1->getType())); - G2->replaceAllUsesWith(ConstantExpr::getCast(NGCP, G2->getType())); + G1->replaceAllUsesWith(ConstantExpr::getCast(NG, G1->getType())); + G2->replaceAllUsesWith(ConstantExpr::getCast(NG, G2->getType())); // Remove the two globals from the module now... M->getGlobalList().erase(G1); From llvm at cs.uiuc.edu Sat Jul 17 18:53:33 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:53:33 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Module.cpp Message-ID: <200407172353.SAA09373@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Module.cpp updated: 1.52 -> 1.53 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Module doesn't need to manage ConstantPointerRefs any more. --- Diffs of the changes: (+1 -46) Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.52 llvm/lib/VMCore/Module.cpp:1.53 --- llvm/lib/VMCore/Module.cpp:1.52 Sat Jul 10 11:37:42 2004 +++ llvm/lib/VMCore/Module.cpp Sat Jul 17 18:53:23 2004 @@ -56,17 +56,6 @@ template class SymbolTableListTraits; template class SymbolTableListTraits; -// Define the GlobalValueRefMap as a struct that wraps a map so that we don't -// have Module.h depend on -// -namespace llvm { - struct GlobalValueRefMap { - typedef std::map MapTy; - typedef MapTy::iterator iterator; - std::map Map; - }; -} - //===----------------------------------------------------------------------===// // Primitive Module methods. // @@ -77,7 +66,6 @@ FunctionList.setParent(this); GlobalList.setItemParent(this); GlobalList.setParent(this); - GVRefMap = 0; SymTab = new SymbolTable(); } @@ -300,38 +288,5 @@ for(Module::giterator I = gbegin(), E = gend(); I != E; ++I) I->dropAllReferences(); - - // If there are any GlobalVariable references still out there, nuke them now. - // Since all references are hereby dropped, nothing could possibly reference - // them still. Note that destroying all of the constant pointer refs will - // eventually cause the GVRefMap field to be set to null (by - // destroyConstantPointerRef, below). - // - while (GVRefMap) - // Delete the ConstantPointerRef node... - GVRefMap->Map.begin()->second->destroyConstant(); -} - -// Accessor for the underlying GlobalValRefMap... -ConstantPointerRef *Module::getConstantPointerRef(GlobalValue *V){ - // Create ref map lazily on demand... - if (GVRefMap == 0) GVRefMap = new GlobalValueRefMap(); - - GlobalValueRefMap::iterator I = GVRefMap->Map.find(V); - if (I != GVRefMap->Map.end()) return I->second; - - ConstantPointerRef *Ref = new ConstantPointerRef(V); - GVRefMap->Map[V] = Ref; - return Ref; -} - -void Module::destroyConstantPointerRef(ConstantPointerRef *CPR) { - assert(GVRefMap && "No map allocated, but we have a CPR?"); - if (!GVRefMap->Map.erase(CPR->getValue())) // Remove it from the map... - assert(0 && "ConstantPointerRef not found in module CPR map!"); - - if (GVRefMap->Map.empty()) { // If the map is empty, delete it. - delete GVRefMap; - GVRefMap = 0; - } } + From llvm at cs.uiuc.edu Sat Jul 17 18:57:46 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 18:57:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/SymbolTable.cpp Message-ID: <200407172357.SAA09408@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: SymbolTable.cpp updated: 1.46 -> 1.47 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Correct isa for GlobalValue subclass - Fix some tabs and indentation. --- Diffs of the changes: (+11 -13) Index: llvm/lib/VMCore/SymbolTable.cpp diff -u llvm/lib/VMCore/SymbolTable.cpp:1.46 llvm/lib/VMCore/SymbolTable.cpp:1.47 --- llvm/lib/VMCore/SymbolTable.cpp:1.46 Sun Jul 4 06:55:08 2004 +++ llvm/lib/VMCore/SymbolTable.cpp Sat Jul 17 18:57:36 2004 @@ -39,10 +39,10 @@ for (plane_iterator PI = pmap.begin(); PI != pmap.end(); ++PI) { for (value_iterator VI = PI->second.begin(); VI != PI->second.end(); ++VI) if (!isa(VI->second) ) { - std::cerr << "Value still in symbol table! Type = '" + std::cerr << "Value still in symbol table! Type = '" << PI->first->getDescription() << "' Name = '" << VI->first << "'\n"; - LeftoverValues = false; + LeftoverValues = false; } } @@ -300,15 +300,13 @@ value_iterator B = Plane.begin(), Bend = Plane.end(); while (B != Bend) { // Found nonempty type plane! Value *V = B->second; - if (isa(V)) { - remove(V); + if (!isa(V) || cast(V)->hasInternalLinkage()){ + // Set name to "", removing from symbol table! + V->setName("", this); + RemovedSymbol = true; + } else if (isa(V) ) { + remove(V); RemovedSymbol = true; - } else { - if (!isa(V) || cast(V)->hasInternalLinkage()){ - // Set name to "", removing from symbol table! - V->setName("", this); - RemovedSymbol = true; - } } ++B; } @@ -326,7 +324,7 @@ // This function is called when one of the types in the type plane are refined void SymbolTable::refineAbstractType(const DerivedType *OldType, - const Type *NewType) { + const Type *NewType) { // Search to see if we have any values of the type Oldtype. If so, we need to // move them into the newtype plane... @@ -441,9 +439,9 @@ I->second = (Type*)NewType; // TODO FIXME when types aren't const if (NewType->isAbstract()) { #if DEBUG_ABSTYPE - std::cerr << "Added type " << NewType->getDescription() << "\n"; + std::cerr << "Added type " << NewType->getDescription() << "\n"; #endif - cast(NewType)->addAbstractTypeUser(this); + cast(NewType)->addAbstractTypeUser(this); } } } From llvm at cs.uiuc.edu Sat Jul 17 19:02:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:02:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Value.cpp Message-ID: <200407180002.TAA09483@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Value.cpp updated: 1.46 -> 1.47 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Correct isa for GlobalValue subclass --- Diffs of the changes: (+7 -2) Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.46 llvm/lib/VMCore/Value.cpp:1.47 --- llvm/lib/VMCore/Value.cpp:1.46 Wed Jul 7 13:07:46 2004 +++ llvm/lib/VMCore/Value.cpp Sat Jul 17 19:01:50 2004 @@ -15,6 +15,7 @@ #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" #include "llvm/Constant.h" +#include "llvm/GlobalValue.h" #include "Support/LeakDetector.h" #include #include @@ -71,7 +72,10 @@ // Must handle Constants specially, we cannot call replaceUsesOfWith on a // constant! if (Constant *C = dyn_cast(U.getUser())) { - C->replaceUsesOfWithOnConstant(this, New, true); + if (!isa(C)) + C->replaceUsesOfWithOnConstant(this, New, true); + else + U.set(New); } else { U.set(New); } @@ -97,7 +101,7 @@ void User::replaceUsesOfWith(Value *From, Value *To) { if (From == To) return; // Duh what? - assert(!isa(this) && + assert(!isa(this) || isa(this) && "Cannot call User::replaceUsesofWith on a constant!"); for (unsigned i = 0, E = getNumOperands(); i != E; ++i) @@ -108,3 +112,4 @@ setOperand(i, To); // Fix it now... } } + From llvm at cs.uiuc.edu Sat Jul 17 19:02:51 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:02:51 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Verifier.cpp Message-ID: <200407180002.TAA09496@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Verifier.cpp updated: 1.114 -> 1.115 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Correct an assert to not have redundant isa --- Diffs of the changes: (+1 -4) Index: llvm/lib/VMCore/Verifier.cpp diff -u llvm/lib/VMCore/Verifier.cpp:1.114 llvm/lib/VMCore/Verifier.cpp:1.115 --- llvm/lib/VMCore/Verifier.cpp:1.114 Sun Jul 4 06:53:53 2004 +++ llvm/lib/VMCore/Verifier.cpp Sat Jul 17 19:02:41 2004 @@ -123,8 +123,6 @@ for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) visitGlobalValue(*I); - - // If the module is broken, abort at this time. abortIfBroken(); return false; @@ -709,8 +707,7 @@ case Intrinsic::gcroot: Assert1(FT->getNumParams() == 2, "Illegal # arguments for intrinsic function!", IF); - Assert1(isa(CI.getOperand(2)) || - isa(CI.getOperand(2)), + Assert1(isa(CI.getOperand(2)), "Second argument to llvm.gcroot must be a constant!", &CI); NumArgs = 2; break; From llvm at cs.uiuc.edu Sat Jul 17 19:03:59 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:03:59 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/iCall.cpp Message-ID: <200407180003.TAA09514@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: iCall.cpp updated: 1.26 -> 1.27 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Replace tabs. --- Diffs of the changes: (+17 -27) Index: llvm/lib/VMCore/iCall.cpp diff -u llvm/lib/VMCore/iCall.cpp:1.26 llvm/lib/VMCore/iCall.cpp:1.27 --- llvm/lib/VMCore/iCall.cpp:1.26 Fri Jul 16 07:04:28 2004 +++ llvm/lib/VMCore/iCall.cpp Sat Jul 17 19:03:48 2004 @@ -33,7 +33,7 @@ assert((Params.size() == FTy->getNumParams() || (FTy->isVarArg() && Params.size() > FTy->getNumParams())) && - "Calling a function with bad signature"); + "Calling a function with bad signature"); for (unsigned i = 0; i != Params.size(); i++) Operands.push_back(Use(Params[i], this)); } @@ -48,7 +48,7 @@ assert((MTy->getNumParams() == 2 || (MTy->isVarArg() && MTy->getNumParams() == 0)) && - "Calling a function with bad signature"); + "Calling a function with bad signature"); Operands.push_back(Use(Actual1, this)); Operands.push_back(Use(Actual2, this)); } @@ -63,7 +63,7 @@ assert((MTy->getNumParams() == 1 || (MTy->isVarArg() && MTy->getNumParams() == 0)) && - "Calling a function with bad signature"); + "Calling a function with bad signature"); Operands.push_back(Use(Actual, this)); } @@ -81,16 +81,16 @@ CallInst::CallInst(Value *Func, const std::vector &Params, const std::string &Name, Instruction *InsertBefore) : Instruction(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertBefore) { + ->getElementType())->getReturnType(), + Instruction::Call, Name, InsertBefore) { init(Func, Params); } CallInst::CallInst(Value *Func, const std::vector &Params, const std::string &Name, BasicBlock *InsertAtEnd) : Instruction(cast(cast(Func->getType()) - ->getElementType())->getReturnType(), - Instruction::Call, Name, InsertAtEnd) { + ->getElementType())->getReturnType(), + Instruction::Call, Name, InsertAtEnd) { init(Func, Params); } @@ -152,15 +152,11 @@ const Function *CallInst::getCalledFunction() const { if (const Function *F = dyn_cast(Operands[0])) return F; - if (const ConstantPointerRef *CPR = dyn_cast(Operands[0])) - return cast(CPR->getValue()); return 0; } Function *CallInst::getCalledFunction() { if (Function *F = dyn_cast(Operands[0])) return F; - if (ConstantPointerRef *CPR = dyn_cast(Operands[0])) - return cast(CPR->getValue()); return 0; } @@ -180,30 +176,30 @@ cast(cast(Fn->getType())->getElementType()); assert((Params.size() == MTy->getNumParams()) || - (MTy->isVarArg() && Params.size() > MTy->getNumParams()) && - "Calling a function with bad signature"); + (MTy->isVarArg() && Params.size() > MTy->getNumParams()) && + "Calling a function with bad signature"); for (unsigned i = 0; i < Params.size(); i++) Operands.push_back(Use(Params[i], this)); } InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal, - BasicBlock *IfException, + BasicBlock *IfException, const std::vector &Params, - const std::string &Name, Instruction *InsertBefore) + const std::string &Name, Instruction *InsertBefore) : TerminatorInst(cast(cast(Fn->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, Name, InsertBefore) { + ->getElementType())->getReturnType(), + Instruction::Invoke, Name, InsertBefore) { init(Fn, IfNormal, IfException, Params); } InvokeInst::InvokeInst(Value *Fn, BasicBlock *IfNormal, - BasicBlock *IfException, + BasicBlock *IfException, const std::vector &Params, - const std::string &Name, BasicBlock *InsertAtEnd) + const std::string &Name, BasicBlock *InsertAtEnd) : TerminatorInst(cast(cast(Fn->getType()) - ->getElementType())->getReturnType(), - Instruction::Invoke, Name, InsertAtEnd) { + ->getElementType())->getReturnType(), + Instruction::Invoke, Name, InsertAtEnd) { init(Fn, IfNormal, IfException, Params); } @@ -217,15 +213,11 @@ const Function *InvokeInst::getCalledFunction() const { if (const Function *F = dyn_cast(Operands[0])) return F; - if (const ConstantPointerRef *CPR = dyn_cast(Operands[0])) - return cast(CPR->getValue()); return 0; } Function *InvokeInst::getCalledFunction() { if (Function *F = dyn_cast(Operands[0])) return F; - if (ConstantPointerRef *CPR = dyn_cast(Operands[0])) - return cast(CPR->getValue()); return 0; } @@ -233,7 +225,5 @@ Value *Callee = getCalledValue(); if (Function *F = dyn_cast(Callee)) return F; - if (ConstantPointerRef *CPR = dyn_cast(Callee)) - return cast(CPR->getValue()); return 0; } From llvm at cs.uiuc.edu Sat Jul 17 19:06:36 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:06:36 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200407180006.TAA09538@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp added (r1.1) --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Move these functions from other places - Provide implementations of Constant class overrides in GlobalValue --- Diffs of the changes: (+139 -0) Index: llvm/lib/VMCore/Globals.cpp diff -c /dev/null llvm/lib/VMCore/Globals.cpp:1.1 *** /dev/null Sat Jul 17 19:06:36 2004 --- llvm/lib/VMCore/Globals.cpp Sat Jul 17 19:06:26 2004 *************** *** 0 **** --- 1,139 ---- + //===-- Globals.cpp - Implement the Global object classes -----------------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements the GlobalValue & GlobalVariable classes for the VMCore + // library. + // + //===----------------------------------------------------------------------===// + + #include "llvm/DerivedTypes.h" + #include "llvm/GlobalVariable.h" + #include "llvm/Module.h" + #include "llvm/SymbolTable.h" + #include "Support/LeakDetector.h" + + using namespace llvm; + + //===----------------------------------------------------------------------===// + // GlobalValue Class + //===----------------------------------------------------------------------===// + + /// This could be named "SafeToDestroyGlobalValue". It just makes sure that + /// there are no non-constant uses of this GlobalValue. If there aren't then + /// this and the transitive closure of the constants can be deleted. See the + /// destructor for details. + namespace { + bool removeDeadConstantUsers(Constant* C) { + while (!C->use_empty()) { + if (Constant *User = dyn_cast(C->use_back())) { + if (!removeDeadConstantUsers(User)) + return false; // Constant wasn't dead + } else { + return false; // Non-constant usage; + } + } + if (!isa(C)) + C->destroyConstant(); + return true; + } + } + + /// removeDeadConstantUsers - If there are any dead constant users dangling + /// off of this global value, remove them. This method is useful for clients + /// that want to check to see if a global is unused, but don't want to deal + /// with potentially dead constants hanging off of the globals. + /// + /// This function returns true if the global value is now dead. If all + /// users of this global are not dead, this method may return false and + /// leave some of them around. + bool GlobalValue::removeDeadConstantUsers() { + while(!use_empty()) { + if (Constant* User = dyn_cast(use_back())) { + if (!::removeDeadConstantUsers(User)) + return false; // Constant wasn't dead + } else { + return false; // Non-constant usage; + } + } + return true; + } + + /// This virtual destructor is responsible for deleting any transitively dead + /// Constants that are using the GlobalValue. + GlobalValue::~GlobalValue() { + // Its an error to attempt destruction with non-constant uses remaining. + bool okay_to_destruct = removeDeadConstantUsers(); + assert(okay_to_destruct && + "Can't destroy GlobalValue with non-constant uses."); + } + + /// Override destroyConstant to make sure it doesn't get called on + /// GlobalValue's because they shouldn't be treated like other constants. + void GlobalValue::destroyConstant() { + assert(0 && "You can't GV->destroyConstant()!"); + abort(); + } + //===----------------------------------------------------------------------===// + // GlobalVariable Implementation + //===----------------------------------------------------------------------===// + + GlobalVariable::GlobalVariable(const Type *Ty, bool constant, LinkageTypes Link, + Constant *Initializer, + const std::string &Name, Module *ParentModule) + : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, Link, Name), + isConstantGlobal(constant) { + if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); + + LeakDetector::addGarbageObject(this); + + if (ParentModule) + ParentModule->getGlobalList().push_back(this); + } + + void GlobalVariable::setParent(Module *parent) { + if (getParent()) + LeakDetector::addGarbageObject(this); + Parent = parent; + if (getParent()) + LeakDetector::removeGarbageObject(this); + } + + // Specialize setName to take care of symbol table majik + void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { + Module *P; + assert((ST == 0 || (!getParent() || ST == &getParent()->getSymbolTable())) && + "Invalid symtab argument!"); + if ((P = getParent()) && hasName()) P->getSymbolTable().remove(this); + Value::setName(name); + if (P && hasName()) P->getSymbolTable().insert(this); + } + + void GlobalVariable::replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking ) + { + // If you call this, then you better know this GVar has a constant + // initializer worth replacing. Enforce that here. + assert(getNumOperands() == 1 && + "Attempt to replace uses of Constants on a GVar with no initializer"); + + // And, since you know it has an initializer, the From value better be + // the initializer :) + assert(getOperand(0) == From && + "Attempt to replace wrong constant initializer in GVar"); + + // And, you better have a constant for the replacement value + assert(isa(To) && + "Attempt to replace GVar initializer with non-constant"); + + // Okay, preconditions out of the way, replace the constant initializer. + this->setOperand(0,To); + } + + // vim: sw=2 ai + From llvm at cs.uiuc.edu Sat Jul 17 19:08:21 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:08:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407180008.TAA09559@zion.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.190 -> 1.191 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass - Remove tabs - Fix coments refering to ConstantPointerRef --- Diffs of the changes: (+47 -48) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.190 llvm/lib/AsmParser/llvmAsmParser.y:1.191 --- llvm/lib/AsmParser/llvmAsmParser.y:1.190 Thu Jul 15 20:18:09 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Sat Jul 17 19:08:11 2004 @@ -79,7 +79,7 @@ // GlobalRefs - This maintains a mapping between 's and forward // references to global values. Global values may be referenced before they // are defined, and if so, the temporary object that they represent is held - // here. This is used for forward references of ConstantPointerRefs. + // here. This is used for forward references of GlobalValues. // typedef std::map, GlobalValue*> GlobalRefsType; @@ -282,10 +282,10 @@ case ValID::ConstUIntVal: // Is it an unsigned const pool reference? if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) { if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) { - ThrowException("Integral constant '" + utostr(D.UConstPool64) + + ThrowException("Integral constant '" + utostr(D.UConstPool64) + "' is invalid or out of range!"); } else { // This is really a signed reference. Transmogrify. - return ConstantSInt::get(Ty, D.ConstPool64); + return ConstantSInt::get(Ty, D.ConstPool64); } } else { return ConstantUInt::get(Ty, D.UConstPool64); @@ -452,15 +452,15 @@ // resolver table InsertValue(V, *FutureLateResolvers); } else { - if (DID.Type == ValID::NameVal) - ThrowException("Reference to an invalid definition: '" +DID.getName()+ - "' of type '" + V->getType()->getDescription() + "'", - PHI->second.second); - else - ThrowException("Reference to an invalid definition: #" + - itostr(DID.Num) + " of type '" + - V->getType()->getDescription() + "'", - PHI->second.second); + if (DID.Type == ValID::NameVal) + ThrowException("Reference to an invalid definition: '" +DID.getName()+ + "' of type '" + V->getType()->getDescription() + "'", + PHI->second.second); + else + ThrowException("Reference to an invalid definition: #" + + itostr(DID.Num) + " of type '" + + V->getType()->getDescription() + "'", + PHI->second.second); } } } @@ -643,7 +643,7 @@ // Any other kind of (non-equivalent) redefinition is an error. ThrowException("Redefinition of type named '" + Name + "' in the '" + - T->getDescription() + "' type plane!"); + T->getDescription() + "' type plane!"); } return false; @@ -703,8 +703,8 @@ for (unsigned i = 0; i != UpRefs.size(); ++i) { UR_OUT(" UR#" << i << " - TypeContains(" << Ty->getDescription() << ", " - << UpRefs[i].second->getDescription() << ") = " - << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); + << UpRefs[i].second->getDescription() << ") = " + << (TypeContains(Ty, UpRefs[i].second) ? "true" : "false") << "\n"); if (TypeContains(Ty, UpRefs[i].LastContainedTy)) { // Decrement level of upreference unsigned Level = --UpRefs[i].NestingLevel; @@ -721,7 +721,7 @@ UR_OUT(" * Type '" << OldName << "' refined upreference to: " << (const void*)Ty << ", " << Ty->getDescription() << "\n"); } - UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... + UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list... --i; // Do not skip the next element... } } @@ -1025,7 +1025,7 @@ | UpRTypesV '(' ArgTypeListI ')' { // Function derived type? std::vector Params; mapto($3->begin(), $3->end(), std::back_inserter(Params), - std::mem_fun_ref(&PATypeHolder::get)); + std::mem_fun_ref(&PATypeHolder::get)); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); @@ -1040,7 +1040,7 @@ | '{' TypeListI '}' { // Structure type? std::vector Elements; mapto($2->begin(), $2->end(), std::back_inserter(Elements), - std::mem_fun_ref(&PATypeHolder::get)); + std::mem_fun_ref(&PATypeHolder::get)); $$ = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); delete $2; @@ -1093,15 +1093,15 @@ // Verify that we have the correct size... if (NumElements != -1 && NumElements != (int)$3->size()) ThrowException("Type mismatch: constant sized array initialized with " + - utostr($3->size()) + " arguments, but has size of " + - itostr(NumElements) + "!"); + utostr($3->size()) + " arguments, but has size of " + + itostr(NumElements) + "!"); // Verify all elements are correct type! for (unsigned i = 0; i < $3->size(); i++) { if (ETy != (*$3)[i]->getType()) - ThrowException("Element #" + utostr(i) + " is not of type '" + - ETy->getDescription() +"' as required!\nIt is of type '"+ - (*$3)[i]->getType()->getDescription() + "'."); + ThrowException("Element #" + utostr(i) + " is not of type '" + + ETy->getDescription() +"' as required!\nIt is of type '"+ + (*$3)[i]->getType()->getDescription() + "'."); } $$ = ConstantArray::get(ATy, *$3); @@ -1116,7 +1116,7 @@ int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) ThrowException("Type mismatch: constant sized array initialized with 0" - " arguments, but has size of " + itostr(NumElements) +"!"); + " arguments, but has size of " + itostr(NumElements) +"!"); $$ = ConstantArray::get(ATy, std::vector()); delete $1; } @@ -1131,15 +1131,15 @@ char *EndStr = UnEscapeLexed($3, true); if (NumElements != -1 && NumElements != (EndStr-$3)) ThrowException("Can't build string constant of size " + - itostr((int)(EndStr-$3)) + - " when array has size " + itostr(NumElements) + "!"); + itostr((int)(EndStr-$3)) + + " when array has size " + itostr(NumElements) + "!"); std::vector Vals; if (ETy == Type::SByteTy) { for (char *C = $3; C != EndStr; ++C) - Vals.push_back(ConstantSInt::get(ETy, *C)); + Vals.push_back(ConstantSInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { for (char *C = $3; C != EndStr; ++C) - Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C)); + Vals.push_back(ConstantUInt::get(ETy, (unsigned char)*C)); } else { free($3); ThrowException("Cannot build string arrays of non byte sized elements!"); @@ -1195,7 +1195,7 @@ ThrowException("Global const reference must be a pointer type!"); // ConstExprs can exist in the body of a function, thus creating - // ConstantPointerRefs whenever they refer to a variable. Because we are in + // GlobalValues whenever they refer to a variable. Because we are in // the context of a function, getValNonImprovising will search the functions // symbol table instead of the module symbol table for the global symbol, // which throws things all off. To get around this, we just tell @@ -1218,35 +1218,34 @@ // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(std::make_pair(PT, $2)); + CurModule.GlobalRefs.find(std::make_pair(PT, $2)); if (I != CurModule.GlobalRefs.end()) { - V = I->second; // Placeholder already exists, use it... + V = I->second; // Placeholder already exists, use it... $2.destroy(); } else { std::string Name; if ($2.Type == ValID::NameVal) Name = $2.Name; - // Create the forward referenced global. + // Create the forward referenced global. GlobalValue *GV; if (const FunctionType *FTy = dyn_cast(PT->getElementType())) { GV = new Function(FTy, GlobalValue::ExternalLinkage, Name, CurModule.CurrentModule); } else { - GV = new GlobalVariable(PT->getElementType(), false, + GV = new GlobalVariable(PT->getElementType(), false, GlobalValue::ExternalLinkage, 0, Name, CurModule.CurrentModule); } - // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV)); - V = GV; + // Keep track of the fact that we have a forward ref to recycle it + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, $2), GV)); + V = GV; } } - GlobalValue *GV = cast(V); - $$ = ConstantPointerRef::get(GV); + $$ = cast(V); delete $1; // Free the type handle } | Types ConstExpr { @@ -1730,12 +1729,12 @@ std::vector::iterator ArgI = $5->begin(), ArgE = $5->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) - if ((*ArgI)->getType() != *I) - ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + - (*I)->getDescription() + "'!"); + if ((*ArgI)->getType() != *I) + ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + + (*I)->getDescription() + "'!"); if (I != E || (ArgI != ArgE && !Ty->isVarArg())) - ThrowException("Invalid number of parameters detected!"); + ThrowException("Invalid number of parameters detected!"); $$ = new InvokeInst(V, Normal, Except, *$5); } @@ -1891,7 +1890,7 @@ $$->op_reserve($2->size()*2); while ($2->begin() != $2->end()) { if ($2->front().first->getType() != Ty) - ThrowException("All elements of a PHI node must be of the same type!"); + ThrowException("All elements of a PHI node must be of the same type!"); cast($$)->addIncoming($2->front().first, $2->front().second); $2->pop_front(); } @@ -1937,12 +1936,12 @@ std::vector::iterator ArgI = $5->begin(), ArgE = $5->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) - if ((*ArgI)->getType() != *I) - ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + - (*I)->getDescription() + "'!"); + if ((*ArgI)->getType() != *I) + ThrowException("Parameter " +(*ArgI)->getName()+ " is not of type '" + + (*I)->getDescription() + "'!"); if (I != E || (ArgI != ArgE && !Ty->isVarArg())) - ThrowException("Invalid number of parameters detected!"); + ThrowException("Invalid number of parameters detected!"); $$ = new CallInst(V, *$5); } @@ -1995,7 +1994,7 @@ | OptVolatile LOAD Types ValueRef { if (!isa($3->get())) ThrowException("Can't load from nonpointer type: " + - (*$3)->getDescription()); + (*$3)->getDescription()); $$ = new LoadInst(getVal(*$3, $4), "", $1); delete $3; } From llvm at cs.uiuc.edu Sat Jul 17 19:10:46 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:10:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Message-ID: <200407180010.TAA09593@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.10 -> 1.11 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Update for BytecodeHandler interface change resuing from CPRs going away --- Diffs of the changes: (+1 -3) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.10 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.11 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.10 Sat Jul 10 03:04:13 2004 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Sat Jul 17 19:10:36 2004 @@ -392,12 +392,10 @@ } virtual void handleConstantPointer( const PointerType* PT, - unsigned Slot, GlobalValue* GV, Constant* PtrVal) { + unsigned Slot, GlobalValue* GV ) { dump << " PNTR: " << PT->getDescription() << " Slot=" << Slot << " GlobalValue="; GV->print(dump); - dump << "\n Value="; - PtrVal->print(dump); dump << "\n"; bca.numConstants++; bca.numValues++; From llvm at cs.uiuc.edu Sat Jul 17 19:12:13 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:12:13 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407180012.TAA09612@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.115 -> 1.116 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+5 -9) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.115 llvm/lib/Bytecode/Reader/Reader.cpp:1.116 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.115 Wed Jul 14 15:33:13 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sat Jul 17 19:12:03 2004 @@ -425,12 +425,9 @@ if (Value *V = getValue(TypeSlot, Slot, false)) if (Constant *C = dyn_cast(V)) return C; // If we already have the value parsed, just return it - else if (GlobalValue *GV = dyn_cast(V)) - // ConstantPointerRef's are an abomination, but at least they don't have - // to infest bytecode files. - return ConstantPointerRef::get(GV); else - error("Reference of a value is expected to be a constant!"); + error("Value for slot " + utostr(Slot) + + " is expected to be a constant!"); const Type *Ty = getType(TypeSlot); std::pair Key(Ty, Slot); @@ -1356,14 +1353,13 @@ GlobalValue *GV; if (Val) { if (!(GV = dyn_cast(Val))) - error("Value of ConstantPointerRef not in ValueTable!"); + error("GlobalValue not in ValueTable!"); } else { error("Forward references are not allowed here."); } - Constant* Result = ConstantPointerRef::get(GV); - if (Handler) Handler->handleConstantPointer(PT, Slot, GV, Result); - return Result; + if (Handler) Handler->handleConstantPointer(PT, Slot, GV ); + return GV; } default: From llvm at cs.uiuc.edu Sat Jul 17 19:13:22 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:13:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200407180013.TAA09624@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.6 -> 1.7 --- Log message: User ValueListTy as the type of the ValueList. This avoides the ValueList from being treated like a Function which can cause the contents of the list to be come invalidated. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.6 llvm/lib/Bytecode/Reader/Reader.h:1.7 --- llvm/lib/Bytecode/Reader/Reader.h:1.6 Sun Jul 11 12:24:05 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sat Jul 17 19:13:12 2004 @@ -72,7 +72,7 @@ /// globals section. /// @brief A list of values as a User of those Values. struct ValueList : public User { - ValueList() : User(Type::VoidTy, Value::FunctionVal) {} + ValueList() : User(Type::VoidTy, Value::ValueListVal) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } From llvm at cs.uiuc.edu Sat Jul 17 19:16:31 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:16:31 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp Message-ID: <200407180016.TAA09658@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: Writer.cpp updated: 1.69 -> 1.70 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Correct ordering of tests because for GlobalValue isa Constant --- Diffs of the changes: (+8 -8) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.69 llvm/lib/Bytecode/Writer/Writer.cpp:1.70 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.69 Sun Jul 4 06:46:15 2004 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sat Jul 17 19:16:21 2004 @@ -135,8 +135,8 @@ for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; - if (const Constant *CPV = dyn_cast(V)) { - outputConstant(CPV); + if (const Constant *C = dyn_cast(V)) { + outputConstant(C); } } } @@ -151,13 +151,11 @@ unsigned NumPlanes = Table.getNumPlanes(); - // Output the type plane before any constants! - if (isFunction) { + if (isFunction) + // Output the type plane before any constants! outputTypes( Table.getModuleTypeLevel() ); - } - - // Output module-level string constants before any other constants.x - if (!isFunction) + else + // Output module-level string constants before any other constants.x outputConstantStrings(); for (unsigned pno = 0; pno != NumPlanes; pno++) { @@ -397,3 +395,5 @@ } Out.flush(); } + +// vim: sw=2 ai From llvm at cs.uiuc.edu Sat Jul 17 19:17:20 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:17:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Message-ID: <200407180017.TAA09675@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.59 -> 1.60 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+16 -30) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.59 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.60 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.59 Mon Jul 12 15:29:52 2004 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Sat Jul 17 19:17:10 2004 @@ -77,8 +77,6 @@ unsigned SlotCalculator::getGlobalSlot(const Value *V) const { assert(!CompactionTable.empty() && "This method can only be used when compaction is enabled!"); - if (const ConstantPointerRef *CPR = dyn_cast(V)) - V = CPR->getValue(); std::map::const_iterator I = NodeMap.find(V); assert(I != NodeMap.end() && "Didn't find global slot entry!"); return I->second; @@ -169,17 +167,14 @@ } } - // If we are emitting a bytecode file, scan all of the functions for their - // constants, which allows us to emit more compact modules. This is optional, - // and is just used to compactify the constants used by different functions - // together. - // - // This functionality is completely optional for the bytecode writer, but - // tends to produce smaller bytecode files. This should not be used in the - // future by clients that want to, for example, build and emit functions on - // the fly. For now, however, it is unconditionally enabled when building - // bytecode information. + // Scan all of the functions for their constants, which allows us to emit + // more compact modules. This is optional, and is just used to compactify + // the constants used by different functions together. // + // This functionality tends to produce smaller bytecode files. This should + // not be used in the future by clients that want to, for example, build and + // emit functions on the fly. For now, however, it is unconditionally + // enabled. ModuleContainsAllFunctionConstants = true; SC_DEBUG("Inserting function constants:\n"); @@ -187,7 +182,8 @@ F != E; ++F) { for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I){ for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) - if (isa(I->getOperand(op))) + if (isa(I->getOperand(op)) && + !isa(I->getOperand(op))) getOrCreateSlot(I->getOperand(op)); getOrCreateSlot(I->getType()); if (const VANextInst *VAN = dyn_cast(&*I)) @@ -265,7 +261,8 @@ PE = ST->plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), VE = PI->second.end(); VI != VE; ++VI) - if (isa(VI->second)) + if (isa(VI->second) && + !isa(VI->second)) getOrCreateSlot(VI->second); } @@ -397,8 +394,6 @@ /// getOrCreateCompactionTableSlot - This method is used to build up the initial /// approximation of the compaction table. unsigned SlotCalculator::getOrCreateCompactionTableSlot(const Value *V) { - if (const ConstantPointerRef *CPR = dyn_cast(V)) - V = CPR->getValue(); std::map::iterator I = CompactionNodeMap.lower_bound(V); if (I != CompactionNodeMap.end() && I->first == V) @@ -473,8 +468,7 @@ for (const_inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) { getOrCreateCompactionTableSlot(I->getType()); for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) - if (isa(I->getOperand(op)) || - isa(I->getOperand(op))) + if (isa(I->getOperand(op))) getOrCreateCompactionTableSlot(I->getOperand(op)); if (const VANextInst *VAN = dyn_cast(&*I)) getOrCreateCompactionTableSlot(VAN->getArgType()); @@ -491,7 +485,7 @@ PE = ST.plane_end(); PI != PE; ++PI) for (SymbolTable::value_const_iterator VI = PI->second.begin(), VE = PI->second.end(); VI != VE; ++VI) - if (isa(VI->second) || isa(VI->second)) + if (isa(VI->second) && !isa(VI->second)) getOrCreateCompactionTableSlot(VI->second); // Now that we have all of the values in the table, and know what types are @@ -643,10 +637,6 @@ if (I != NodeMap.end()) return (int)I->second; - // Do not number ConstantPointerRef's at all. They are an abomination. - if (const ConstantPointerRef *CPR = dyn_cast(V)) - return getSlot(CPR->getValue()); - return -1; } @@ -674,10 +664,6 @@ int SlotNo = getSlot(V); // Check to see if it's already in! if (SlotNo != -1) return SlotNo; - // Do not number ConstantPointerRef's at all. They are an abomination. - if (const ConstantPointerRef *CPR = dyn_cast(V)) - return getOrCreateSlot(CPR->getValue()); - if (!isa(V)) // Initializers for globals are handled explicitly if (const Constant *C = dyn_cast(V)) { assert(CompactionNodeMap.empty() && @@ -720,8 +706,8 @@ // insert the value into the compaction map, not into the global map. if (!CompactionNodeMap.empty()) { if (D->getType() == Type::VoidTy) return -1; // Do not insert void values - assert(!isa(D) && !isa(D) && - "Types, constants, and globals should be in global SymTab!"); + assert(!isa(D) && + "Types, constants, and globals should be in global table!"); int Plane = getSlot(D->getType()); assert(Plane != -1 && CompactionTable.size() > (unsigned)Plane && @@ -774,7 +760,7 @@ if (getSlot(SubTy) == -1) { SC_DEBUG(" Inserting subtype: " << SubTy->getDescription() << "\n"); doInsertType(SubTy); - SC_DEBUG(" Inserted subtype: " << SubTy->getDescription()); + SC_DEBUG(" Inserted subtype: " << SubTy->getDescription() << "\n"); } } } From llvm at cs.uiuc.edu Sat Jul 17 19:18:40 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:18:40 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/IPA/Andersens.cpp CallGraph.cpp FindUsedTypes.cpp GlobalsModRef.cpp Message-ID: <200407180018.TAA09720@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/IPA: Andersens.cpp updated: 1.4 -> 1.5 CallGraph.cpp updated: 1.37 -> 1.38 FindUsedTypes.cpp updated: 1.28 -> 1.29 GlobalsModRef.cpp updated: 1.1 -> 1.2 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+12 -15) Index: llvm/lib/Analysis/IPA/Andersens.cpp diff -u llvm/lib/Analysis/IPA/Andersens.cpp:1.4 llvm/lib/Analysis/IPA/Andersens.cpp:1.5 --- llvm/lib/Analysis/IPA/Andersens.cpp:1.4 Thu Jun 24 23:24:22 2004 +++ llvm/lib/Analysis/IPA/Andersens.cpp Sat Jul 17 19:18:30 2004 @@ -479,8 +479,8 @@ if (isa(C)) return &GraphNodes[NullPtr]; - else if (ConstantPointerRef *CPR = dyn_cast(C)) - return getNode(CPR->getValue()); + else if (GlobalValue *GV = dyn_cast(C)) + return getNode(GV); else if (ConstantExpr *CE = dyn_cast(C)) { switch (CE->getOpcode()) { case Instruction::GetElementPtr: @@ -507,8 +507,8 @@ if (isa(C)) return &GraphNodes[NullObject]; - else if (ConstantPointerRef *CPR = dyn_cast(C)) - return getObject(CPR->getValue()); + else if (GlobalValue *GV = dyn_cast(C)) + return getObject(GV); else if (ConstantExpr *CE = dyn_cast(C)) { switch (CE->getOpcode()) { case Instruction::GetElementPtr: Index: llvm/lib/Analysis/IPA/CallGraph.cpp diff -u llvm/lib/Analysis/IPA/CallGraph.cpp:1.37 llvm/lib/Analysis/IPA/CallGraph.cpp:1.38 --- llvm/lib/Analysis/IPA/CallGraph.cpp:1.37 Sun May 2 11:06:18 2004 +++ llvm/lib/Analysis/IPA/CallGraph.cpp Sat Jul 17 19:18:30 2004 @@ -73,10 +73,8 @@ getNodeFor(Inst->getParent()->getParent())->addCalledFunction(Node); else isUsedExternally = true; - } else if (ConstantPointerRef *CPR = dyn_cast(*I)) { - // THIS IS A DISGUSTING HACK. Brought to you by the power of - // ConstantPointerRefs! - for (Value::use_iterator I = CPR->use_begin(), E = CPR->use_end(); + } else if (GlobalValue *GV = dyn_cast(*I)) { + for (Value::use_iterator I = GV->use_begin(), E = GV->use_end(); I != E; ++I) if (Instruction *Inst = dyn_cast(*I)) { if (isOnlyADirectCall(F, CallSite::get(Inst))) Index: llvm/lib/Analysis/IPA/FindUsedTypes.cpp diff -u llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.28 llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.29 --- llvm/lib/Analysis/IPA/FindUsedTypes.cpp:1.28 Wed Jul 14 21:31:46 2004 +++ llvm/lib/Analysis/IPA/FindUsedTypes.cpp Sat Jul 17 19:18:30 2004 @@ -48,9 +48,10 @@ // If this is a constant, it could be using other types... if (const Constant *C = dyn_cast(V)) { - for (User::const_op_iterator OI = C->op_begin(), OE = C->op_end(); - OI != OE; ++OI) - IncorporateValue(*OI); + if (!isa(C)) + for (User::const_op_iterator OI = C->op_begin(), OE = C->op_end(); + OI != OE; ++OI) + IncorporateValue(*OI); } } Index: llvm/lib/Analysis/IPA/GlobalsModRef.cpp diff -u llvm/lib/Analysis/IPA/GlobalsModRef.cpp:1.1 llvm/lib/Analysis/IPA/GlobalsModRef.cpp:1.2 --- llvm/lib/Analysis/IPA/GlobalsModRef.cpp:1.1 Mon Jun 28 01:33:13 2004 +++ llvm/lib/Analysis/IPA/GlobalsModRef.cpp Sat Jul 17 19:18:30 2004 @@ -165,8 +165,8 @@ } else { return true; } - } else if (ConstantPointerRef *CPR = dyn_cast(*UI)) { - if (AnalyzeUsesOfGlobal(CPR, Readers, Writers)) return true; + } else if (GlobalValue *GV = dyn_cast(*UI)) { + if (AnalyzeUsesOfGlobal(GV, Readers, Writers)) return true; } else { return true; } @@ -257,8 +257,6 @@ if (CE->getOpcode() == Instruction::Cast || CE->getOpcode() == Instruction::GetElementPtr) return getUnderlyingObject(CE->getOperand(0)); - } else if (const ConstantPointerRef *CPR = dyn_cast(V)) { - return CPR->getValue(); } return 0; } From llvm at cs.uiuc.edu Sat Jul 17 19:18:40 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:18:40 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Local.cpp Printer.cpp Message-ID: <200407180018.TAA09708@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructureStats.cpp updated: 1.11 -> 1.12 Local.cpp updated: 1.107 -> 1.108 Printer.cpp updated: 1.70 -> 1.71 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+10 -15) Index: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.11 llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.12 --- llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.11 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Sat Jul 17 19:18:30 2004 @@ -102,7 +102,7 @@ DSNode *DSGraphStats::getNodeForValue(Value *V) { const DSGraph *G = TDGraph; - if (isa(V) || isa(V)) + if (isa(V)) G = TDGraph->getGlobalsGraph(); const DSGraph::ScalarMapTy &ScalarMap = G->getScalarMap(); Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.107 llvm/lib/Analysis/DataStructure/Local.cpp:1.108 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.107 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Sat Jul 17 19:18:30 2004 @@ -220,10 +220,13 @@ // Otherwise we need to create a new node to point to. // Check first for constant expressions that must be traversed to // extract the actual value. - if (Constant *C = dyn_cast(V)) - if (ConstantPointerRef *CPR = dyn_cast(C)) { - return NH = getValueDest(*CPR->getValue()); - } else if (ConstantExpr *CE = dyn_cast(C)) { + DSNode* N; + if (GlobalValue* GV = dyn_cast(V)) { + // Create a new global node for this global variable... + N = createNode(GV->getType()->getElementType()); + N->addGlobal(GV); + } else if (Constant *C = dyn_cast(V)) { + if (ConstantExpr *CE = dyn_cast(C)) { if (CE->getOpcode() == Instruction::Cast) NH = getValueDest(*CE->getOperand(0)); else if (CE->getOpcode() == Instruction::GetElementPtr) { @@ -247,13 +250,7 @@ } else { assert(0 && "Unknown constant type!"); } - - // Otherwise we need to create a new node to point to... - DSNode *N; - if (GlobalValue *GV = dyn_cast(V)) { - // Create a new global node for this global variable... - N = createNode(GV->getType()->getElementType()); - N->addGlobal(GV); + N = createNode(); // just create a shadow node } else { // Otherwise just create a shadow node N = createNode(); @@ -491,8 +488,6 @@ void GraphBuilder::visitCallSite(CallSite CS) { Value *Callee = CS.getCalledValue(); - if (ConstantPointerRef *CPR = dyn_cast(Callee)) - Callee = CPR->getValue(); // Special case handling of certain libc allocation functions here. if (Function *F = dyn_cast(Callee)) Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.70 llvm/lib/Analysis/DataStructure/Printer.cpp:1.71 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.70 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Sat Jul 17 19:18:30 2004 @@ -138,7 +138,7 @@ // Add scalar nodes to the graph... const DSGraph::ScalarMapTy &VM = G->getScalarMap(); for (DSGraph::ScalarMapTy::const_iterator I = VM.begin(); I != VM.end();++I) - if (!isa(I->first) && !isa(I->first)) { + if (!isa(I->first)) { std::stringstream OS; WriteAsOperand(OS, I->first, false, true, CurMod); GW.emitSimpleNode(I->first, "", OS.str()); From llvm at cs.uiuc.edu Sat Jul 17 19:18:40 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:18:40 -0500 Subject: [llvm-commits] CVS: llvm/lib/Analysis/BasicAliasAnalysis.cpp ScalarEvolution.cpp Message-ID: <200407180018.TAA09696@zion.cs.uiuc.edu> Changes in directory llvm/lib/Analysis: BasicAliasAnalysis.cpp updated: 1.45 -> 1.46 ScalarEvolution.cpp updated: 1.22 -> 1.23 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+10 -18) Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.45 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.46 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.45 Wed Jul 14 15:27:12 2004 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Sat Jul 17 19:18:30 2004 @@ -143,8 +143,8 @@ if (CE->getOpcode() == Instruction::Cast || CE->getOpcode() == Instruction::GetElementPtr) return getUnderlyingObject(CE->getOperand(0)); - } else if (const ConstantPointerRef *CPR = dyn_cast(V)) { - return CPR->getValue(); + } else if (const GlobalValue *GV = dyn_cast(V)) { + return GV; } return 0; } @@ -166,7 +166,7 @@ V = cast(V)->getOperand(0); while (const User *G = isGEP(V)) { - if (!isa(GEPOps[0]) || + if (!isa(GEPOps[0]) || isa(GEPOps[0]) || !cast(GEPOps[0])->isNullValue()) break; // Don't handle folding arbitrary pointer offsets yet... GEPOps.erase(GEPOps.begin()); // Drop the zero index @@ -217,7 +217,7 @@ // AliasAnalysis::ModRefResult BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) { - if (!isa(P) && !isa(P)) + if (!isa(P)) if (const AllocationInst *AI = dyn_cast_or_null(getUnderlyingObject(P))) { // Okay, the pointer is to a stack allocated object. If we can prove that @@ -246,12 +246,6 @@ if (CE->getOpcode() == Instruction::Cast) V2 = CE->getOperand(0); - // Strip off constant pointer refs if they exist - if (const ConstantPointerRef *CPR = dyn_cast(V1)) - V1 = CPR->getValue(); - if (const ConstantPointerRef *CPR = dyn_cast(V2)) - V2 = CPR->getValue(); - // Are we checking for alias of the same value? if (V1 == V2) return MustAlias; @@ -380,7 +374,7 @@ // the arguments provided, except substitute 0's for any variable // indexes we find... for (unsigned i = 0; i != GEPOperands.size(); ++i) - if (!isa(GEPOperands[i]) || + if (!isa(GEPOperands[i]) || isa(GEPOperands[i]) || isa(GEPOperands[i])) GEPOperands[i] =Constant::getNullValue(GEPOperands[i]->getType()); int64_t Offset = getTargetData().getIndexedOffset(BasePtr->getType(), @@ -453,7 +447,7 @@ bool AllAreZeros = true; for (unsigned i = UnequalOper; i != MaxOperands; ++i) - if (!isa(GEP1Ops[i]) || + if (!isa(GEP1Ops[i]) || !cast(GEP1Ops[i])->isNullValue()) { AllAreZeros = false; break; Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.22 llvm/lib/Analysis/ScalarEvolution.cpp:1.23 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.22 Thu Jun 24 01:51:27 2004 +++ llvm/lib/Analysis/ScalarEvolution.cpp Sat Jul 17 19:18:30 2004 @@ -1498,9 +1498,9 @@ case Instruction::Select: return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]); case Instruction::Call: - if (ConstantPointerRef *CPR = dyn_cast(Operands[0])) { + if (Function *GV = dyn_cast(Operands[0])) { Operands.erase(Operands.begin()); - return ConstantFoldCall(cast(CPR->getValue()), Operands); + return ConstantFoldCall(cast(GV), Operands); } return 0; @@ -1560,9 +1560,9 @@ /// reason, return null. static Constant *EvaluateExpression(Value *V, Constant *PHIVal) { if (isa(V)) return PHIVal; - if (Constant *C = dyn_cast(V)) return C; if (GlobalValue *GV = dyn_cast(V)) - return ConstantPointerRef::get(GV); + return GV; + if (Constant *C = dyn_cast(V)) return C; Instruction *I = cast(V); std::vector Operands; @@ -1718,8 +1718,6 @@ Value *Op = I->getOperand(i); if (Constant *C = dyn_cast(Op)) { Operands.push_back(C); - } else if (GlobalValue *GV = dyn_cast(Op)) { - Operands.push_back(ConstantPointerRef::get(GV)); } else { SCEVHandle OpV = getSCEVAtScope(getSCEV(Op), L); if (SCEVConstant *SC = dyn_cast(OpV)) From llvm at cs.uiuc.edu Sat Jul 17 19:19:55 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:19:55 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/LevelRaise.cpp Message-ID: <200407180019.TAA09735@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms: LevelRaise.cpp updated: 1.98 -> 1.99 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Correct test ordering for GlobalValue subclass --- Diffs of the changes: (+0 -6) Index: llvm/lib/Transforms/LevelRaise.cpp diff -u llvm/lib/Transforms/LevelRaise.cpp:1.98 llvm/lib/Transforms/LevelRaise.cpp:1.99 --- llvm/lib/Transforms/LevelRaise.cpp:1.98 Wed Jul 14 21:06:06 2004 +++ llvm/lib/Transforms/LevelRaise.cpp Sat Jul 17 19:19:45 2004 @@ -528,18 +528,12 @@ Constant *ConstantCallSrc = 0; if (Constant *CS = dyn_cast(CI->getCalledValue())) ConstantCallSrc = CS; - else if (GlobalValue *GV = dyn_cast(CI->getCalledValue())) - ConstantCallSrc = ConstantPointerRef::get(GV); if (ConstantCallSrc) NewCast = ConstantExpr::getCast(ConstantCallSrc, NewPFunTy); else NewCast = new CastInst(CI->getCalledValue(), NewPFunTy, CI->getCalledValue()->getName()+"_c",CI); - - // Strip off unneeded CPR's. - if (ConstantPointerRef *CPR = dyn_cast(NewCast)) - NewCast = CPR->getValue(); // Create a new call instruction... CallInst *NewCall = new CallInst(NewCast, From llvm at cs.uiuc.edu Sat Jul 17 19:21:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:21:24 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp EdgeProfiling.cpp EmitFunctions.cpp ProfilingUtils.cpp ProfilingUtils.h TraceValues.cpp Message-ID: <200407180021.TAA09771@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Instrumentation: BlockProfiling.cpp updated: 1.8 -> 1.9 EdgeProfiling.cpp updated: 1.2 -> 1.3 EmitFunctions.cpp updated: 1.17 -> 1.18 ProfilingUtils.cpp updated: 1.3 -> 1.4 ProfilingUtils.h updated: 1.2 -> 1.3 TraceValues.cpp updated: 1.66 -> 1.67 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+9 -16) Index: llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.8 llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.9 --- llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp:1.8 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/BlockProfiling.cpp Sat Jul 17 19:21:14 2004 @@ -55,14 +55,12 @@ new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "FuncProfCounters", &M); - ConstantPointerRef *CounterCPR = ConstantPointerRef::get(Counters); - // Instrument all of the functions... unsigned i = 0; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) if (!I->isExternal()) // Insert counter at the start of the function - IncrementCounterInBlock(I->begin(), i++, CounterCPR); + IncrementCounterInBlock(I->begin(), i++, Counters); // Add the initialization call to main. InsertProfilingInitCall(Main, "llvm_start_func_profiling", Counters); @@ -96,14 +94,12 @@ new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "BlockProfCounters", &M); - ConstantPointerRef *CounterCPR = ConstantPointerRef::get(Counters); - // Instrument all of the blocks... unsigned i = 0; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB) // Insert counter at the start of the block - IncrementCounterInBlock(BB, i++, CounterCPR); + IncrementCounterInBlock(BB, i++, Counters); // Add the initialization call to main. InsertProfilingInitCall(Main, "llvm_start_block_profiling", Counters); Index: llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp diff -u llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.2 llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.3 --- llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp:1.2 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Transforms/Instrumentation/EdgeProfiling.cpp Sat Jul 17 19:21:14 2004 @@ -60,8 +60,6 @@ new GlobalVariable(ATy, false, GlobalValue::InternalLinkage, Constant::getNullValue(ATy), "EdgeProfCounters", &M); - ConstantPointerRef *CounterCPR = ConstantPointerRef::get(Counters); - // Instrument all of the edges... unsigned i = 0; for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) @@ -80,10 +78,10 @@ // otherwise insert it in the successor block. if (TI->getNumSuccessors() == 0) { // Insert counter at the start of the block - IncrementCounterInBlock(BB, i++, CounterCPR); + IncrementCounterInBlock(BB, i++, Counters); } else { // Insert counter at the start of the block - IncrementCounterInBlock(TI->getSuccessor(s), i++, CounterCPR); + IncrementCounterInBlock(TI->getSuccessor(s), i++, Counters); } } } Index: llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp diff -u llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.17 llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.18 --- llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp:1.17 Mon Mar 8 10:45:53 2004 +++ llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp Sat Jul 17 19:21:14 2004 @@ -77,7 +77,7 @@ //std::cerr< GEPIndices(2, Constant::getNullValue(Type::IntTy)); unsigned NumElements = 0; if (Array) { - ConstantPointerRef *ArrayCPR = ConstantPointerRef::get(Array); - Args[2] = ConstantExpr::getGetElementPtr(ArrayCPR, GEPIndices); + Args[2] = ConstantExpr::getGetElementPtr(Array, GEPIndices); NumElements = cast(Array->getType()->getElementType())->getNumElements(); } else { @@ -87,7 +86,7 @@ } void llvm::IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, - ConstantPointerRef *CounterArray) { + GlobalValue *CounterArray) { // Insert the increment after any alloca or PHI instructions... BasicBlock::iterator InsertPos = BB->begin(); while (isa(InsertPos) || isa(InsertPos)) Index: llvm/lib/Transforms/Instrumentation/ProfilingUtils.h diff -u llvm/lib/Transforms/Instrumentation/ProfilingUtils.h:1.2 llvm/lib/Transforms/Instrumentation/ProfilingUtils.h:1.3 --- llvm/lib/Transforms/Instrumentation/ProfilingUtils.h:1.2 Mon May 3 17:06:33 2004 +++ llvm/lib/Transforms/Instrumentation/ProfilingUtils.h Sat Jul 17 19:21:14 2004 @@ -26,7 +26,7 @@ void InsertProfilingInitCall(Function *MainFn, const char *FnName, GlobalValue *Arr = 0); void IncrementCounterInBlock(BasicBlock *BB, unsigned CounterNum, - ConstantPointerRef *CounterArray); + GlobalValue *CounterArray); } #endif Index: llvm/lib/Transforms/Instrumentation/TraceValues.cpp diff -u llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.66 llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.67 --- llvm/lib/Transforms/Instrumentation/TraceValues.cpp:1.66 Fri Jan 9 00:11:50 2004 +++ llvm/lib/Transforms/Instrumentation/TraceValues.cpp Sat Jul 17 19:21:14 2004 @@ -243,7 +243,7 @@ GlobalVariable *fmtVal = getStringRef(Mod, Message+getPrintfCodeFor(V)+"\n"); // Turn the format string into an sbyte * - Constant *GEP =ConstantExpr::getGetElementPtr(ConstantPointerRef::get(fmtVal), + Constant *GEP=ConstantExpr::getGetElementPtr(fmtVal, std::vector(2,Constant::getNullValue(Type::LongTy))); // Insert a call to the hash function if this is a pointer value From llvm at cs.uiuc.edu Sat Jul 17 19:22:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:22:24 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/RaiseAllocations.cpp Message-ID: <200407180022.TAA09788@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: RaiseAllocations.cpp updated: 1.22 -> 1.23 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+6 -6) Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.22 llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.23 --- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.22 Sat Dec 6 19:42:08 2003 +++ llvm/lib/Transforms/IPO/RaiseAllocations.cpp Sat Jul 17 19:22:14 2004 @@ -158,9 +158,9 @@ Changed = true; ++NumRaised; } - } else if (ConstantPointerRef *CPR = dyn_cast(U)) { - Users.insert(Users.end(), CPR->use_begin(), CPR->use_end()); - EqPointers.push_back(CPR); + } else if (GlobalValue *GV = dyn_cast(U)) { + Users.insert(Users.end(), GV->use_begin(), GV->use_end()); + EqPointers.push_back(GV); } else if (ConstantExpr *CE = dyn_cast(U)) { if (CE->getOpcode() == Instruction::Cast) { Users.insert(Users.end(), CE->use_begin(), CE->use_end()); @@ -207,9 +207,9 @@ Changed = true; ++NumRaised; } - } else if (ConstantPointerRef *CPR = dyn_cast(U)) { - Users.insert(Users.end(), CPR->use_begin(), CPR->use_end()); - EqPointers.push_back(CPR); + } else if (GlobalValue *GV = dyn_cast(U)) { + Users.insert(Users.end(), GV->use_begin(), GV->use_end()); + EqPointers.push_back(GV); } else if (ConstantExpr *CE = dyn_cast(U)) { if (CE->getOpcode() == Instruction::Cast) { Users.insert(Users.end(), CE->use_begin(), CE->use_end()); From llvm at cs.uiuc.edu Sat Jul 17 19:23:08 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:23:08 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200407180023.TAA09802@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.16 -> 1.17 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+3 -4) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.16 llvm/lib/Transforms/IPO/Inliner.cpp:1.17 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.16 Sat Jun 19 23:11:48 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Sat Jul 17 19:22:58 2004 @@ -14,7 +14,6 @@ //===----------------------------------------------------------------------===// #include "Inliner.h" -#include "llvm/Constants.h" // ConstantPointerRef should die #include "llvm/Module.h" #include "llvm/iOther.h" #include "llvm/iTerminators.h" @@ -174,9 +173,9 @@ // If the only remaining use of the function is a dead constant // pointer ref, remove it. if (F && F->hasOneUse()) - if (ConstantPointerRef *CPR = dyn_cast(F->use_back())) - if (CPR->use_empty()) { - CPR->destroyConstant(); + if (Function *GV = dyn_cast(F->use_back())) + if (GV->removeDeadConstantUsers()) { + delete GV; if (F->hasInternalLinkage()) { // There *MAY* be an edge from the external call node to this // function. If so, remove it. From llvm at cs.uiuc.edu Sat Jul 17 19:24:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:24:01 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp Message-ID: <200407180024.TAA09814@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: ArgumentPromotion.cpp updated: 1.7 -> 1.8 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Excise dead CPR procesing. --- Diffs of the changes: (+1 -30) Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp diff -u llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.7 llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.8 --- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:1.7 Sun Jun 20 19:07:58 2004 +++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp Sat Jul 17 19:23:51 2004 @@ -86,37 +86,8 @@ bool ArgPromotion::run(Module &M) { bool Changed = false; for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->hasInternalLinkage()) { + if (I->hasInternalLinkage()) WorkList.insert(I); - - // If there are any constant pointer refs pointing to this function, - // eliminate them now if possible. - ConstantPointerRef *CPR = 0; - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; - ++UI) - if ((CPR = dyn_cast(*UI))) - break; // Found one! - if (CPR) { - // See if we can transform all users to use the function directly. - while (!CPR->use_empty()) { - User *TheUser = CPR->use_back(); - if (!isa(TheUser) && !isa(TheUser)) { - Changed = true; - TheUser->replaceUsesOfWith(CPR, I); - } else { - // We won't be able to eliminate all users. :( - WorkList.erase(I); // Minor efficiency win. - break; - } - } - - // If we nuked all users of the CPR, kill the CPR now! - if (CPR->use_empty()) { - CPR->destroyConstant(); - Changed = true; - } - } - } while (!WorkList.empty()) { Function *F = *WorkList.begin(); From llvm at cs.uiuc.edu Sat Jul 17 19:24:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:24:24 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/FunctionResolution.cpp Message-ID: <200407180024.TAA09826@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: FunctionResolution.cpp updated: 1.48 -> 1.49 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+4 -6) Index: llvm/lib/Transforms/IPO/FunctionResolution.cpp diff -u llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.48 llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.49 --- llvm/lib/Transforms/IPO/FunctionResolution.cpp:1.48 Fri Jun 18 00:50:48 2004 +++ llvm/lib/Transforms/IPO/FunctionResolution.cpp Sat Jul 17 19:24:14 2004 @@ -101,8 +101,7 @@ if (!Old->use_empty()) { // Avoid making the CPR unless we really need it Value *Replacement = Concrete; if (Concrete->getType() != Old->getType()) - Replacement = ConstantExpr::getCast(ConstantPointerRef::get(Concrete), - Old->getType()); + Replacement = ConstantExpr::getCast(Concrete,Old->getType()); NumResolved += Old->use_size(); Old->replaceAllUsesWith(Replacement); } @@ -118,11 +117,10 @@ std::vector &Globals, GlobalVariable *Concrete) { bool Changed = false; - Constant *CCPR = ConstantPointerRef::get(Concrete); for (unsigned i = 0; i != Globals.size(); ++i) if (Globals[i] != Concrete) { - Constant *Cast = ConstantExpr::getCast(CCPR, Globals[i]->getType()); + Constant *Cast = ConstantExpr::getCast(Concrete, Globals[i]->getType()); Globals[i]->replaceAllUsesWith(Cast); // Since there are no uses of Old anymore, remove it from the module. @@ -138,8 +136,8 @@ static bool CallersAllIgnoreReturnValue(Function &F) { if (F.getReturnType() == Type::VoidTy) return true; for (Value::use_iterator I = F.use_begin(), E = F.use_end(); I != E; ++I) { - if (ConstantPointerRef *CPR = dyn_cast(*I)) { - for (Value::use_iterator I = CPR->use_begin(), E = CPR->use_end(); + if (GlobalValue *GV = dyn_cast(*I)) { + for (Value::use_iterator I = GV->use_begin(), E = GV->use_end(); I != E; ++I) { CallSite CS = CallSite::get(*I); if (!CS.getInstruction() || !CS.getInstruction()->use_empty()) From llvm at cs.uiuc.edu Sat Jul 17 19:25:14 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:25:14 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalDCE.cpp Message-ID: <200407180025.TAA09846@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalDCE.cpp updated: 1.31 -> 1.32 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Rename methods to get ride of ConstantPointerRef usage --- Diffs of the changes: (+17 -22) Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.31 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.32 --- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.31 Fri Nov 21 15:54:22 2003 +++ llvm/lib/Transforms/IPO/GlobalDCE.cpp Sat Jul 17 19:25:04 2004 @@ -26,7 +26,7 @@ namespace { Statistic<> NumFunctions("globaldce","Number of functions removed"); Statistic<> NumVariables("globaldce","Number of global variables removed"); - Statistic<> NumCPRs("globaldce", "Number of const pointer refs removed"); + Statistic<> NumGVs("globaldce", "Number of global values removed"); struct GlobalDCE : public Pass { // run - Do the GlobalDCE pass on the specified module, optionally updating @@ -42,8 +42,8 @@ void GlobalIsNeeded(GlobalValue *GV); void MarkUsedGlobalsAsNeeded(Constant *C); - bool RemoveUnusedConstantPointerRef(GlobalValue &GV); - bool SafeToDestroyConstant(Constant *C); + bool SafeToDestroyConstant(Constant* C); + bool RemoveUnusedGlobalValue(GlobalValue &GV); }; RegisterOpt X("globaldce", "Dead Global Elimination"); } @@ -54,7 +54,7 @@ bool Changed = false; // Loop over the module, adding globals which are obviously necessary. for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { - Changed |= RemoveUnusedConstantPointerRef(*I); + Changed |= RemoveUnusedGlobalValue(*I); // Functions with external linkage are needed if they have a body if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) && !I->isExternal()) @@ -62,7 +62,7 @@ } for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) { - Changed |= RemoveUnusedConstantPointerRef(*I); + Changed |= RemoveUnusedGlobalValue(*I); // Externally visible & appending globals are needed, if they have an // initializer. if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) && @@ -97,7 +97,7 @@ // Now that all interreferences have been dropped, delete the actual objects // themselves. for (unsigned i = 0, e = DeadFunctions.size(); i != e; ++i) { - RemoveUnusedConstantPointerRef(*DeadFunctions[i]); + RemoveUnusedGlobalValue(*DeadFunctions[i]); M.getFunctionList().erase(DeadFunctions[i]); } NumFunctions += DeadFunctions.size(); @@ -106,7 +106,7 @@ if (!DeadGlobalVars.empty()) { for (unsigned i = 0, e = DeadGlobalVars.size(); i != e; ++i) { - RemoveUnusedConstantPointerRef(*DeadGlobalVars[i]); + RemoveUnusedGlobalValue(*DeadGlobalVars[i]); M.getGlobalList().erase(DeadGlobalVars[i]); } NumVariables += DeadGlobalVars.size(); @@ -154,8 +154,8 @@ } void GlobalDCE::MarkUsedGlobalsAsNeeded(Constant *C) { - if (ConstantPointerRef *CPR = dyn_cast(C)) - GlobalIsNeeded(CPR->getValue()); + if (GlobalValue *GV = dyn_cast(C)) + GlobalIsNeeded(GV); else { // Loop over all of the operands of the constant, adding any globals they // use to the list of needed globals. @@ -164,24 +164,21 @@ } } -// RemoveUnusedConstantPointerRef - Loop over all of the uses of the specified +// RemoveUnusedGlobalValue - Loop over all of the uses of the specified // GlobalValue, looking for the constant pointer ref that may be pointing to it. // If found, check to see if the constant pointer ref is safe to destroy, and if // so, nuke it. This will reduce the reference count on the global value, which // might make it deader. // -bool GlobalDCE::RemoveUnusedConstantPointerRef(GlobalValue &GV) { +bool GlobalDCE::RemoveUnusedGlobalValue(GlobalValue &GV) { for (Value::use_iterator I = GV.use_begin(), E = GV.use_end(); I != E; ++I) - if (ConstantPointerRef *CPR = dyn_cast(*I)) - if (SafeToDestroyConstant(CPR)) { // Only if unreferenced... - CPR->destroyConstant(); - ++NumCPRs; - return true; + if (GlobalValue* User = dyn_cast(*I)) + if (User->removeDeadConstantUsers()) { // Only if unreferenced... + ++NumGVs; } - - return false; -} - + return false; + } + // SafeToDestroyConstant - It is safe to destroy a constant iff it is only used // by constants itself. Note that constants cannot be cyclic, so this test is // pretty easy to implement recursively. @@ -193,7 +190,5 @@ } else { return false; } - return true; } - From llvm at cs.uiuc.edu Sat Jul 17 19:26:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:26:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalConstifier.cpp Message-ID: <200407180026.TAA09860@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalConstifier.cpp updated: 1.2 -> 1.3 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+2 -2) Index: llvm/lib/Transforms/IPO/GlobalConstifier.cpp diff -u llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.2 llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.3 --- llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.2 Fri Feb 27 12:09:25 2004 +++ llvm/lib/Transforms/IPO/GlobalConstifier.cpp Sat Jul 17 19:25:57 2004 @@ -48,8 +48,8 @@ if (ConstantExpr *CE = dyn_cast(C)) { if (isStoredThrough(CE)) return true; - } else if (ConstantPointerRef *CPR = dyn_cast(C)) { - if (isStoredThrough(CPR)) return true; + } else if (GlobalValue *GV = dyn_cast(C)) { + if (isStoredThrough(GV)) return true; } else { // Must be an element of a constant array or something. return true; From llvm at cs.uiuc.edu Sat Jul 17 19:26:47 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:26:47 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp Message-ID: <200407180026.TAA09874@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: IPConstantPropagation.cpp updated: 1.5 -> 1.6 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage --- Diffs of the changes: (+1 -5) Index: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp diff -u llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.5 llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.6 --- llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.5 Fri Nov 21 15:54:22 2003 +++ llvm/lib/Transforms/IPO/IPConstantPropagation.cpp Sat Jul 17 19:26:34 2004 @@ -82,9 +82,8 @@ if (*AI == &F) return false; // Passes the function into itself if (!ArgumentConstants[i].second) { - if (isa(*AI) || isa(*AI)) { + if (isa(*AI)) { Constant *C = dyn_cast(*AI); - if (!C) C = ConstantPointerRef::get(cast(*AI)); if (!ArgumentConstants[i].first) ArgumentConstants[i].first = C; @@ -114,9 +113,6 @@ if (!ArgumentConstants[i].second && !AI->use_empty()) { assert(ArgumentConstants[i].first && "Unknown constant value!"); Value *V = ArgumentConstants[i].first; - if (ConstantPointerRef *CPR = dyn_cast(V)) - V = CPR->getValue(); - AI->replaceAllUsesWith(V); ++NumArgumentsProped; MadeChange = true; From llvm at cs.uiuc.edu Sat Jul 17 19:27:16 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:27:16 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/InlineSimple.cpp Message-ID: <200407180027.TAA09889@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: InlineSimple.cpp updated: 1.62 -> 1.63 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage --- Diffs of the changes: (+2 -3) Index: llvm/lib/Transforms/IPO/InlineSimple.cpp diff -u llvm/lib/Transforms/IPO/InlineSimple.cpp:1.62 llvm/lib/Transforms/IPO/InlineSimple.cpp:1.63 --- llvm/lib/Transforms/IPO/InlineSimple.cpp:1.62 Thu Apr 8 01:34:31 2004 +++ llvm/lib/Transforms/IPO/InlineSimple.cpp Sat Jul 17 19:27:06 2004 @@ -78,8 +78,7 @@ Instruction &Inst = cast(**UI); bool AllOperandsConstant = true; for (unsigned i = 0, e = Inst.getNumOperands(); i != e; ++i) - if (!isa(Inst.getOperand(i)) && - !isa(Inst.getOperand(i)) && Inst.getOperand(i) != V) { + if (!isa(Inst.getOperand(i)) && Inst.getOperand(i) != V) { AllOperandsConstant = false; break; } @@ -205,7 +204,7 @@ // If this is a constant being passed into the function, use the argument // weights calculated for the callee to determine how much will be folded // away with this information. - } else if (isa(I) || isa(I)) { + } else if (isa(I)) { if (ArgNo < CalleeFI.ArgumentWeights.size()) InlineCost -= CalleeFI.ArgumentWeights[ArgNo].ConstantWeight; } From llvm at cs.uiuc.edu Sat Jul 17 19:28:29 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:28:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Message-ID: <200407180028.TAA09904@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: CorrelatedExprs.cpp updated: 1.22 -> 1.23 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+3 -2) Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.22 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.23 --- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.22 Wed Jul 14 20:50:47 2004 +++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp Sat Jul 17 19:28:19 2004 @@ -243,7 +243,7 @@ void BuildRankMap(Function &F); unsigned getRank(Value *V) const { - if (isa(V) || isa(V)) return 0; + if (isa(V)) return 0; std::map::const_iterator I = RankMap.find(V); if (I != RankMap.end()) return I->second; return 0; // Must be some other global thing @@ -476,7 +476,8 @@ ValueInfo &PredicateVI = NewRI.getValueInfo(BI->getCondition()); if (PredicateVI.getReplacement() && - isa(PredicateVI.getReplacement())) { + isa(PredicateVI.getReplacement()) && + !isa(PredicateVI.getReplacement())) { ConstantBool *CB = cast(PredicateVI.getReplacement()); // Forward to the successor that corresponds to the branch we will take. From llvm at cs.uiuc.edu Sat Jul 17 19:28:57 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:28:57 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/GCSE.cpp Message-ID: <200407180028.TAA09918@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: GCSE.cpp updated: 1.40 -> 1.41 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage --- Diffs of the changes: (+2 -3) Index: llvm/lib/Transforms/Scalar/GCSE.cpp diff -u llvm/lib/Transforms/Scalar/GCSE.cpp:1.40 llvm/lib/Transforms/Scalar/GCSE.cpp:1.41 --- llvm/lib/Transforms/Scalar/GCSE.cpp:1.40 Sun May 23 16:19:55 2004 +++ llvm/lib/Transforms/Scalar/GCSE.cpp Sat Jul 17 19:28:47 2004 @@ -78,8 +78,7 @@ VN.getEqualNumberNodes(AI, EqualValues); if (!EqualValues.empty()) { for (unsigned i = 0, e = EqualValues.size(); i != e; ++i) - if (isa(EqualValues[i]) || - isa(EqualValues[i])) { + if (isa(EqualValues[i])) { AI->replaceAllUsesWith(EqualValues[i]); ++NumArgsRepl; Changed = true; @@ -186,7 +185,7 @@ // If we are not replacing the instruction with a constant, we cannot do // anything special. - if (!isa(V)) { + if (!isa(V) || isa(V)) { I->replaceAllUsesWith(V); if (InvokeInst *II = dyn_cast(I)) { From llvm at cs.uiuc.edu Sat Jul 17 19:29:35 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:29:35 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407180029.TAA09930@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.222 -> 1.223 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+13 -16) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.222 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.223 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.222 Mon Jul 12 20:49:43 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sat Jul 17 19:29:25 2004 @@ -2457,11 +2457,10 @@ if (!isa(CS.getCalledValue())) return false; ConstantExpr *CE = cast(CS.getCalledValue()); if (CE->getOpcode() != Instruction::Cast || - !isa(CE->getOperand(0))) + !isa(CE->getOperand(0))) return false; - ConstantPointerRef *CPR = cast(CE->getOperand(0)); - if (!isa(CPR->getValue())) return false; - Function *Callee = cast(CPR->getValue()); + if (!isa(CE->getOperand(0))) return false; + Function *Callee = cast(CE->getOperand(0)); Instruction *Caller = CS.getInstruction(); // Okay, this is a cast from a function to a different type. Unless doing so @@ -2811,7 +2810,7 @@ if (I == E) { // If they are all constants... Constant *CE = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(GV), Indices); + ConstantExpr::getGetElementPtr(GV, Indices); // Replace all uses of the GEP with the new constexpr... return ReplaceInstUsesWith(GEP, CE); @@ -2978,8 +2977,8 @@ if (Constant *C = dyn_cast(Op)) if (C->isNullValue()) // load null -> 0 return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); - else if (ConstantPointerRef *CPR = dyn_cast(C)) - Op = CPR->getValue(); + else if (isa(C)) + Op = C; // Instcombine load (constant global) into the value loaded... if (GlobalVariable *GV = dyn_cast(Op)) @@ -2989,11 +2988,10 @@ // Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded... if (ConstantExpr *CE = dyn_cast(Op)) if (CE->getOpcode() == Instruction::GetElementPtr) { - if (ConstantPointerRef *G=dyn_cast(CE->getOperand(0))) - if (GlobalVariable *GV = dyn_cast(G->getValue())) - if (GV->isConstant() && !GV->isExternal()) - if (Constant *V = GetGEPGlobalInitializer(GV->getInitializer(), CE)) - return ReplaceInstUsesWith(LI, V); + if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) + if (GV->isConstant() && !GV->isExternal()) + if (Constant *V = GetGEPGlobalInitializer(GV->getInitializer(), CE)) + return ReplaceInstUsesWith(LI, V); } else if (CE->getOpcode() == Instruction::Cast) { if (Instruction *Res = InstCombineLoadCast(*this, LI)) return Res; @@ -3106,12 +3104,11 @@ } // Check to see if any of the operands of this instruction are a - // ConstantPointerRef. Since they sneak in all over the place and inhibit + // GlobalValue. Since they sneak in all over the place and inhibit // optimization, we want to strip them out unconditionally! for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (ConstantPointerRef *CPR = - dyn_cast(I->getOperand(i))) { - I->setOperand(i, CPR->getValue()); + if (isa(I->getOperand(i))) { + I->setOperand(i, I->getOperand(i)); Changed = true; } From llvm at cs.uiuc.edu Sat Jul 17 19:30:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:30:07 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerGC.cpp Message-ID: <200407180030.TAA09957@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerGC.cpp updated: 1.2 -> 1.3 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+3 -3) Index: llvm/lib/Transforms/Scalar/LowerGC.cpp diff -u llvm/lib/Transforms/Scalar/LowerGC.cpp:1.2 llvm/lib/Transforms/Scalar/LowerGC.cpp:1.3 --- llvm/lib/Transforms/Scalar/LowerGC.cpp:1.2 Sun May 23 16:27:29 2004 +++ llvm/lib/Transforms/Scalar/LowerGC.cpp Sat Jul 17 19:29:57 2004 @@ -140,7 +140,8 @@ /// not have the specified type, insert a cast. static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) { if (I->getOperand(OpNum)->getType() != Ty) { - if (Constant *C = dyn_cast(I->getOperand(OpNum))) + Constant *C = dyn_cast(I->getOperand(OpNum)); + if (C && !isa(I->getOperand(OpNum))) I->setOperand(OpNum, ConstantExpr::getCast(C, Ty)); else { CastInst *C = new CastInst(I->getOperand(OpNum), Ty, "", I); @@ -252,8 +253,7 @@ Par[2] = ConstantUInt::get(Type::UIntTy, i); Par[3] = One; Value *MetaDataPtr = new GetElementPtrInst(AI, Par, "MetaDataPtr", IP); - assert(isa(GCRoots[i]->getOperand(2)) || - isa(GCRoots[i]->getOperand(2))); + assert(isa(GCRoots[i]->getOperand(2)) && "Must be a constant"); new StoreInst(GCRoots[i]->getOperand(2), MetaDataPtr, IP); // Initialize the root pointer to null on entry to the function. From llvm at cs.uiuc.edu Sat Jul 17 19:30:35 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:30:35 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerInvoke.cpp Message-ID: <200407180030.TAA09970@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerInvoke.cpp updated: 1.16 -> 1.17 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+3 -3) Index: llvm/lib/Transforms/Scalar/LowerInvoke.cpp diff -u llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.16 llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.17 --- llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.16 Fri May 28 00:02:13 2004 +++ llvm/lib/Transforms/Scalar/LowerInvoke.cpp Sat Jul 17 19:30:25 2004 @@ -135,7 +135,7 @@ if (MsgGV) { std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); AbortMessage = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + ConstantExpr::getGetElementPtr(MsgGV, GEPIdx); } } else { @@ -154,7 +154,7 @@ if (MsgGV) { std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); AbortMessage = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + ConstantExpr::getGetElementPtr(MsgGV, GEPIdx); } } @@ -191,7 +191,7 @@ WriteFn->getParent()); std::vector GEPIdx(2, Constant::getNullValue(Type::LongTy)); AbortMessage = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(MsgGV), GEPIdx); + ConstantExpr::getGetElementPtr(MsgGV, GEPIdx); } // These are the arguments we WANT... From llvm at cs.uiuc.edu Sat Jul 17 19:31:15 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:31:15 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200407180031.TAA09982@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: SCCP.cpp updated: 1.96 -> 1.97 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+11 -16) Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.96 llvm/lib/Transforms/Scalar/SCCP.cpp:1.97 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.96 Thu Jul 15 18:36:43 2004 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Sat Jul 17 19:31:05 2004 @@ -175,13 +175,13 @@ hash_map::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map - if (Constant *CPV = dyn_cast(V)) { // Constants are constant + if (GlobalValue *GV = dyn_cast(V)) { + // The address of a global is a constant... + ValueState[V].markConstant(GV); + } else if (Constant *CPV = dyn_cast(V)) { // Constants are constant ValueState[CPV].markConstant(CPV); } else if (isa(V)) { // Arguments are overdefined ValueState[V].markOverdefined(); - } else if (GlobalValue *GV = dyn_cast(V)) { - // The address of a global is a constant... - ValueState[V].markConstant(ConstantPointerRef::get(GV)); } // All others are underdefined by default... return ValueState[V]; @@ -784,9 +784,6 @@ return; } - if (ConstantPointerRef *CPR = dyn_cast(Ptr)) - Ptr = CPR->getValue(); - // Transform load (constant global) into the value loaded. if (GlobalVariable *GV = dyn_cast(Ptr)) if (GV->isConstant() && !GV->isExternal()) { @@ -797,15 +794,13 @@ // Transform load (constantexpr_GEP global, 0, ...) into the value loaded. if (ConstantExpr *CE = dyn_cast(Ptr)) if (CE->getOpcode() == Instruction::GetElementPtr) - if (ConstantPointerRef *G - = dyn_cast(CE->getOperand(0))) - if (GlobalVariable *GV = dyn_cast(G->getValue())) - if (GV->isConstant() && !GV->isExternal()) - if (Constant *V = - GetGEPGlobalInitializer(GV->getInitializer(), CE)) { - markConstant(IV, &I, V); - return; - } + if (GlobalVariable *GV = dyn_cast(CE->getOperand(0))) + if (GV->isConstant() && !GV->isExternal()) + if (Constant *V = + GetGEPGlobalInitializer(GV->getInitializer(), CE)) { + markConstant(IV, &I, V); + return; + } } // Otherwise we cannot say for certain what value this load will produce. From llvm at cs.uiuc.edu Sat Jul 17 19:32:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:32:24 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp Message-ID: <200407180032.TAA10001@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: SimplifyCFG.cpp updated: 1.46 -> 1.47 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage --- Diffs of the changes: (+1 -2) Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.46 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.47 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.46 Wed Jul 14 21:06:12 2004 +++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sat Jul 17 19:32:14 2004 @@ -211,8 +211,7 @@ if (cast(I)->isVolatile()) return false; if (!isa(I->getOperand(0)) && - !isa(I->getOperand(0)) && - !isa(I->getOperand(0))) + !isa(I->getOperand(0))) return false; // Finally, we have to check to make sure there are no instructions From llvm at cs.uiuc.edu Sat Jul 17 19:32:49 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:32:49 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/ValueMapper.cpp Message-ID: <200407180032.TAA10013@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: ValueMapper.cpp updated: 1.14 -> 1.15 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+3 -3) Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.14 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.15 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.14 Wed Jul 14 21:06:12 2004 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Sat Jul 17 19:32:39 2004 @@ -14,6 +14,7 @@ #include "ValueMapper.h" #include "llvm/Constants.h" +#include "llvm/GlobalValue.h" #include "llvm/Instruction.h" #include @@ -32,9 +33,8 @@ if (isa(C) || isa(C) || isa(C) || isa(C)) return VMSlot = C; // Primitive constants map directly - else if (ConstantPointerRef *CPR = dyn_cast(C)) { - GlobalValue *MV = cast(MapValue((Value*)CPR->getValue(),VM)); - return VMSlot = ConstantPointerRef::get(MV); + else if (GlobalValue *GV = dyn_cast(C)) { + return VMSlot = GV; } else if (ConstantArray *CA = dyn_cast(C)) { const std::vector &Vals = CA->getValues(); for (unsigned i = 0, e = Vals.size(); i != e; ++i) { From llvm at cs.uiuc.edu Sat Jul 17 19:33:48 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:33:48 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/InstSelectSimple.cpp Printer.cpp X86SimpInstrSelector.cpp Message-ID: <200407180033.TAA10042@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: InstSelectSimple.cpp updated: 1.271 -> 1.272 Printer.cpp updated: 1.103 -> 1.104 X86SimpInstrSelector.cpp updated: 1.6 -> 1.7 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+12 -28) Index: llvm/lib/Target/X86/InstSelectSimple.cpp diff -u llvm/lib/Target/X86/InstSelectSimple.cpp:1.271 llvm/lib/Target/X86/InstSelectSimple.cpp:1.272 --- llvm/lib/Target/X86/InstSelectSimple.cpp:1.271 Wed Jul 14 21:14:23 2004 +++ llvm/lib/Target/X86/InstSelectSimple.cpp Sat Jul 17 19:33:38 2004 @@ -394,16 +394,10 @@ MachineBasicBlock::iterator IPt) { // If this operand is a constant, emit the code to copy the constant into // the register here... - // if (Constant *C = dyn_cast(V)) { unsigned Reg = makeAnotherReg(V->getType()); copyConstantToRegister(MBB, IPt, C, Reg); return Reg; - } else if (GlobalValue *GV = dyn_cast(V)) { - unsigned Reg = makeAnotherReg(V->getType()); - // Move the address of the global into the register - BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); - return Reg; } else if (CastInst *CI = dyn_cast(V)) { // Do not emit noop casts at all, unless it's a double -> float cast. if (getClassB(CI->getType()) == getClassB(CI->getOperand(0)->getType()) && @@ -554,8 +548,8 @@ } else if (isa(C)) { // Copy zero (null pointer) to the register. BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0); - } else if (ConstantPointerRef *CPR = dyn_cast(C)) { - BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast(C)) { + BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV); } else { std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); @@ -688,8 +682,7 @@ // If this is a constant or GlobalValue, we may have to insert code // into the basic block to compute it into a virtual register. - if ((isa(Val) && !isa(Val)) || - isa(Val)) { + if ((isa(Val) && !isa(Val))) { // Simple constants get emitted at the end of the basic block, // before any terminator instructions. We "know" that the code to // move a constant into a register will never clobber any flags. @@ -3635,8 +3628,6 @@ Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned &BaseReg, unsigned &Scale, unsigned &IndexReg, unsigned &Disp) { - if (ConstantPointerRef *CPR = dyn_cast(Src)) - Src = CPR->getValue(); std::vector GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); @@ -3660,8 +3651,6 @@ Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg) { const TargetData &TD = TM.getTargetData(); - if (ConstantPointerRef *CPR = dyn_cast(Src)) - Src = CPR->getValue(); // If this is a getelementptr null, with all constant integer indices, just // replace it with TargetReg = 42. Index: llvm/lib/Target/X86/Printer.cpp diff -u llvm/lib/Target/X86/Printer.cpp:1.103 llvm/lib/Target/X86/Printer.cpp:1.104 --- llvm/lib/Target/X86/Printer.cpp:1.103 Tue Jun 29 14:43:20 2004 +++ llvm/lib/Target/X86/Printer.cpp Sat Jul 17 19:33:38 2004 @@ -178,10 +178,10 @@ O << (unsigned long long)CI->getValue(); else if (const ConstantUInt *CI = dyn_cast(CV)) O << CI->getValue(); - else if (const ConstantPointerRef *CPR = dyn_cast(CV)) + else if (const GlobalValue *GV = dyn_cast(CV)) // This is a constant address for a global variable or function. Use the // name of the variable or function as the address value. - O << Mang->getValueName(CPR->getValue()); + O << Mang->getValueName(GV); else if (const ConstantExpr *CE = dyn_cast(CV)) { const TargetData &TD = TM.getTargetData(); switch(CE->getOpcode()) { Index: llvm/lib/Target/X86/X86SimpInstrSelector.cpp diff -u llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.6 llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.7 --- llvm/lib/Target/X86/X86SimpInstrSelector.cpp:1.6 Wed Jul 14 21:14:24 2004 +++ llvm/lib/Target/X86/X86SimpInstrSelector.cpp Sat Jul 17 19:33:38 2004 @@ -316,13 +316,13 @@ // If this operand is a constant, emit the code to copy the constant into // the register here... // - if (Constant *C = dyn_cast(V)) { - copyConstantToRegister(MBB, IPt, C, Reg); - RegMap.erase(V); // Assign a new name to this constant if ref'd again - } else if (GlobalValue *GV = dyn_cast(V)) { + if (GlobalValue *GV = dyn_cast(V)) { // Move the address of the global into the register BuildMI(*MBB, IPt, X86::MOV32ri, 1, Reg).addGlobalAddress(GV); RegMap.erase(V); // Assign a new name to this address if ref'd again + } else if (Constant *C = dyn_cast(V)) { + copyConstantToRegister(MBB, IPt, C, Reg); + RegMap.erase(V); // Assign a new name to this constant if ref'd again } return Reg; @@ -480,8 +480,8 @@ } else if (isa(C)) { // Copy zero (null pointer) to the register. BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addImm(0); - } else if (ConstantPointerRef *CPR = dyn_cast(C)) { - BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast(C)) { + BuildMI(*MBB, IP, X86::MOV32ri, 1, R).addGlobalAddress(GV); } else { std::cerr << "Offending constant: " << *C << "\n"; assert(0 && "Type not handled yet!"); @@ -602,7 +602,7 @@ // If this is a constant or GlobalValue, we may have to insert code // into the basic block to compute it into a virtual register. - if (isa(Val) || isa(Val)) { + if (isa(Val)) { // Because we don't want to clobber any values which might be in // physical registers with the computation of this constant (which // might be arbitrarily complex if it is a constant expression), @@ -2589,9 +2589,6 @@ Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned &BaseReg, unsigned &Scale, unsigned &IndexReg, unsigned &Disp) { - if (ConstantPointerRef *CPR = dyn_cast(Src)) - Src = CPR->getValue(); - std::vector GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); GEPOps[0] = Src; @@ -2614,8 +2611,6 @@ Value *Src, User::op_iterator IdxBegin, User::op_iterator IdxEnd, unsigned TargetReg) { const TargetData &TD = TM.getTargetData(); - if (ConstantPointerRef *CPR = dyn_cast(Src)) - Src = CPR->getValue(); std::vector GEPOps; GEPOps.resize(IdxEnd-IdxBegin+1); From llvm at cs.uiuc.edu Sat Jul 17 19:36:54 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:36:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp SparcV9AsmPrinter.cpp Message-ID: <200407180036.TAA10077@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: InternalGlobalMapper.cpp updated: 1.2 -> 1.3 SparcV9AsmPrinter.cpp updated: 1.115 -> 1.116 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+6 -11) Index: llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp diff -u llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp:1.2 llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp:1.3 --- llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp:1.2 Tue Jun 8 15:08:30 2004 +++ llvm/lib/Target/SparcV9/InternalGlobalMapper.cpp Sat Jul 17 19:36:44 2004 @@ -42,7 +42,7 @@ // add a null. if (GV.hasInternalLinkage () && GV.hasName ()) Vector.push_back (ConstantExpr::getCast - (ConstantPointerRef::get (&GV), PointerType::get (Type::SByteTy))); + (&GV, PointerType::get (Type::SByteTy))); else Vector.push_back (ConstantPointerNull::get (PointerType::get (Type::SByteTy))); Index: llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp diff -u llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.115 llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.116 --- llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp:1.115 Thu Jun 17 13:17:08 2004 +++ llvm/lib/Target/SparcV9/SparcV9AsmPrinter.cpp Sat Jul 17 19:36:44 2004 @@ -317,11 +317,8 @@ toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t"; - if (const ConstantPointerRef* CPR = dyn_cast(CV)) { - // This is a constant address for a global variable or method. - // Use the name of the variable or method as the address value. - assert(isa(CPR->getValue()) && "Unexpected non-global"); - toAsm << getID(CPR->getValue()) << "\n"; + if (const GlobalValue* GV = dyn_cast(CV)) { + toAsm << getID(GV) << "\n"; } else if (isa(CV)) { // Null pointer value toAsm << "0\n"; @@ -480,7 +477,9 @@ const TargetMachine& target) { std::string S; bool failed = false; - if (const Constant* CV = dyn_cast(V)) { // symbolic or known + if (const GlobalValue* GV = dyn_cast(V)) { + S += getID(GV); + } else if (const Constant* CV = dyn_cast(V)) { // symbolic or known if (const ConstantBool *CB = dyn_cast(CV)) S += std::string(CB == ConstantBool::True ? "1" : "0"); else if (const ConstantSInt *CI = dyn_cast(CV)) @@ -491,14 +490,10 @@ S += ftostr(CFP->getValue()); else if (isa(CV)) S += "0"; - else if (const ConstantPointerRef *CPR = dyn_cast(CV)) - S += valToExprString(CPR->getValue(), target); else if (const ConstantExpr *CE = dyn_cast(CV)) S += ConstantExprToString(CE, target); else failed = true; - } else if (const GlobalValue* GV = dyn_cast(V)) { - S += getID(GV); } else failed = true; From llvm at cs.uiuc.edu Sat Jul 17 19:36:54 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:36:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Message-ID: <200407180036.TAA10084@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/RegAlloc: PhyRegAlloc.cpp updated: 1.153 -> 1.154 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp diff -u llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.153 llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.154 --- llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp:1.153 Thu Jul 15 19:07:21 2004 +++ llvm/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp Sat Jul 17 19:36:44 2004 @@ -1289,7 +1289,7 @@ // Have: { uint, [Size x { uint, int, uint, int }] } * // Cast it to: { uint, [0 x { uint, int, uint, int }] } * - Constant *CE = ConstantExpr::getCast (ConstantPointerRef::get (GV), PT); + Constant *CE = ConstantExpr::getCast (GV, PT); allstate.push_back (CE); } } From llvm at cs.uiuc.edu Sat Jul 17 19:37:45 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:37:45 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp Message-ID: <200407180037.TAA10096@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/LiveVar: ValueSet.cpp updated: 1.16 -> 1.17 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Correct isa for GlobalValue subclass --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp diff -u llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp:1.16 llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp:1.17 --- llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp:1.16 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Target/SparcV9/LiveVar/ValueSet.cpp Sat Jul 17 19:37:35 2004 @@ -17,7 +17,7 @@ const Value &v = V.V; if (v.hasName()) return O << (void*)&v << "(" << v.getName() << ") "; - else if (isa(v)) + else if (isa(v) && !isa(v)) return O << (void*)&v << "(" << v << ") "; else return O << (void*)&v << " "; From llvm at cs.uiuc.edu Sat Jul 17 19:38:42 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:38:42 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp SparcV9PreSelection.cpp Message-ID: <200407180038.TAA10112@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9InstrInfo.cpp updated: 1.66 -> 1.67 SparcV9PreSelection.cpp updated: 1.35 -> 1.36 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+10 -18) Index: llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp diff -u llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.66 llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.67 --- llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp:1.66 Thu Jun 10 21:03:48 2004 +++ llvm/lib/Target/SparcV9/SparcV9InstrInfo.cpp Sat Jul 17 19:38:32 2004 @@ -56,16 +56,14 @@ if (! destType->isIntegral() && ! isa(destType)) return C; - if (! isa(V)) + if (! isa(V) || isa(V)) return C; - // ConstantPointerRef: no conversions needed: get value and return it - if (const ConstantPointerRef* CPR = dyn_cast(V)) { - // A ConstantPointerRef is just a reference to GlobalValue. + // GlobalValue: no conversions needed: get value and return it + if (const GlobalValue* GV = dyn_cast(V)) { isValidConstant = true; // may be overwritten by recursive call - return (CPR->isNullValue()? 0 - : ConvertConstantToIntType(target, CPR->getValue(), destType, - isValidConstant)); + return GV->isNullValue() ? 0 : + ConvertConstantToIntType(target, GV, destType, isValidConstant); } // ConstantBool: no conversions needed: get value and return it @@ -284,7 +282,7 @@ Value* val, Instruction* tmpReg, Instruction* dest, std::vector& mvec) { - assert(isa(val) || isa(val) && + assert(isa(val) && "I only know about constant values and global addresses"); MachineInstr* MI; @@ -467,7 +465,7 @@ std::vector& mvec, MachineCodeForInstruction& mcfi) const { - assert(isa(val) || isa(val) && + assert(isa(val) && "I only know about constant values and global addresses"); // Use a "set" instruction for known constants or symbolic constants (labels) @@ -477,10 +475,6 @@ // const Type* valType = val->getType(); - // A ConstantPointerRef is just a reference to GlobalValue. - while (isa(val)) - val = cast(val)->getValue(); - if (isa(val)) { TmpInstruction* tmpReg = new TmpInstruction(mcfi, PointerType::get(val->getType()), val); @@ -688,7 +682,9 @@ // a global variable (i.e., a constant address), generate a load // instruction instead of an add // - if (isa(src)) { + if (isa(src)) + loadConstantToReg = true; + else if (isa(src)) { unsigned int machineRegNum; int64_t immedValue; MachineOperand::MachineOperandType opType = @@ -698,8 +694,6 @@ if (opType == MachineOperand::MO_VirtualRegister) loadConstantToReg = true; } - else if (isa(src)) - loadConstantToReg = true; if (loadConstantToReg) { // `src' is constant and cannot fit in immed field for the ADD Index: llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp diff -u llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.35 llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.36 --- llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp:1.35 Wed Jun 23 16:41:32 2004 +++ llvm/lib/Target/SparcV9/SparcV9PreSelection.cpp Sat Jul 17 19:38:32 2004 @@ -85,8 +85,6 @@ // getGlobalAddr(): Put address of a global into a v. register. static GetElementPtrInst* getGlobalAddr(Value* ptr, Instruction& insertBefore) { - if (isa(ptr)) - ptr = cast(ptr)->getValue(); return (isa(ptr)) ? new GetElementPtrInst(ptr, From llvm at cs.uiuc.edu Sat Jul 17 19:38:42 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:38:42 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp InstrSelectionSupport.cpp Message-ID: <200407180038.TAA10121@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9/InstrSelection: InstrForest.cpp updated: 1.55 -> 1.56 InstrSelectionSupport.cpp updated: 1.68 -> 1.69 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Minimize redundant isa usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+16 -13) Index: llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.55 llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.56 --- llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp:1.55 Wed Jul 14 21:14:29 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrForest.cpp Sat Jul 17 19:38:32 2004 @@ -244,8 +244,7 @@ && !instr->isTerminator(); if (includeAddressOperand || isa(operand) || - isa(operand) || isa(operand) || - isa(operand)) + isa(operand) || isa(operand)) { // This operand is a data value @@ -273,8 +272,11 @@ // Recursively create a treeNode for it. opTreeNode = buildTreeForInstruction((Instruction*)operand); } else if (Constant *CPV = dyn_cast(operand)) { - // Create a leaf node for a constant - opTreeNode = new ConstantNode(CPV); + if (isa(CPV)) + opTreeNode = new VRegNode(operand); + else + // Create a leaf node for a constant + opTreeNode = new ConstantNode(CPV); } else { // Create a leaf node for the virtual register opTreeNode = new VRegNode(operand); Index: llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp diff -u llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.68 llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.69 --- llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp:1.68 Wed Jun 2 00:54:49 2004 +++ llvm/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp Sat Jul 17 19:38:32 2004 @@ -22,6 +22,7 @@ #include "llvm/Constants.h" #include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" +#include "llvm/GlobalValue.h" #include "../SparcV9InstrSelectionSupport.h" namespace llvm { @@ -159,13 +160,14 @@ if (mop.getType() == MachineOperand::MO_VirtualRegister) { assert(mop.getVRegValue() != NULL); opValue = mop.getVRegValue(); - if (Constant *opConst = dyn_cast(opValue)) { - opType = ChooseRegOrImmed(opConst, opCode, target, - (immedPos == (int)op), machineRegNum, - immedValue); - if (opType == MachineOperand::MO_VirtualRegister) - constantThatMustBeLoaded = true; - } + if (Constant *opConst = dyn_cast(opValue)) + if (!isa(opConst)) { + opType = ChooseRegOrImmed(opConst, opCode, target, + (immedPos == (int)op), machineRegNum, + immedValue); + if (opType == MachineOperand::MO_VirtualRegister) + constantThatMustBeLoaded = true; + } } else { // // If the operand is from the constant pool, don't try to change it. @@ -242,8 +244,7 @@ argDesc = CallArgsDescriptor::get(minstr); for (unsigned i=0, N=minstr->getNumImplicitRefs(); i < N; ++i) - if (isa(minstr->getImplicitRef(i)) || - isa(minstr->getImplicitRef(i))) + if (isa(minstr->getImplicitRef(i))) { Value* oldVal = minstr->getImplicitRef(i); TmpInstruction* tmpReg = From llvm at cs.uiuc.edu Sat Jul 17 19:39:58 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:39:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407180039.TAA10141@zion.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.189 -> 1.190 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+4 -6) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.189 llvm/lib/Target/CBackend/Writer.cpp:1.190 --- llvm/lib/Target/CBackend/Writer.cpp:1.189 Wed Jul 14 21:14:29 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Jul 17 19:39:48 2004 @@ -620,8 +620,8 @@ printType(Out, CPV->getType()); Out << ")/*NULL*/0)"; break; - } else if (ConstantPointerRef *CPR = dyn_cast(CPV)) { - writeOperand(CPR->getValue()); + } else if (GlobalValue *GV = dyn_cast(CPV)) { + writeOperand(GV); break; } // FALL THROUGH @@ -641,7 +641,8 @@ return; } - if (Constant *CPV = dyn_cast(Operand)) { + Constant* CPV = dyn_cast(Operand); + if (CPV && !isa(CPV)) { printConstant(CPV); } else { Out << Mang->getValueName(Operand); @@ -1412,9 +1413,6 @@ // If accessing a global value with no indexing, avoid *(&GV) syndrome if (GlobalValue *V = dyn_cast(Ptr)) { HasImplicitAddress = true; - } else if (ConstantPointerRef *CPR = dyn_cast(Ptr)) { - HasImplicitAddress = true; - Ptr = CPR->getValue(); // Get to the global... } else if (isDirectAlloca(Ptr)) { HasImplicitAddress = true; } From llvm at cs.uiuc.edu Sat Jul 17 19:41:37 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:41:37 -0500 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <200407180041.TAA10168@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine: ExecutionEngine.cpp updated: 1.55 -> 1.56 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage - Correct isa for GlobalValue subclass --- Diffs of the changes: (+6 -11) Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.55 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.56 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.55 Wed Jul 14 21:47:47 2004 +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Sat Jul 17 19:41:27 2004 @@ -263,19 +263,14 @@ GET_CONST_VAL(Double , ConstantFP); #undef GET_CONST_VAL case Type::PointerTyID: - if (isa(C)) { + if (isa(C)) Result.PointerVal = 0; - } else if (const ConstantPointerRef *CPR = dyn_cast(C)){ - if (Function *F = - const_cast(dyn_cast(CPR->getValue()))) - Result = PTOGV(getPointerToFunctionOrStub(F)); - else - Result = PTOGV(getOrEmitGlobalVariable( - cast(CPR->getValue()))); - - } else { + else if (const Function *F = dyn_cast(C)) + Result = PTOGV(getPointerToFunctionOrStub(const_cast(F))); + else if (const GlobalVariable* GV = dyn_cast(C)) + Result = PTOGV(getOrEmitGlobalVariable(const_cast(GV))); + else assert(0 && "Unknown constant pointer type!"); - } break; default: std::cout << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; From llvm at cs.uiuc.edu Sat Jul 17 19:42:22 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:42:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/Debugger/ProgramInfo.cpp Message-ID: <200407180042.TAA10187@zion.cs.uiuc.edu> Changes in directory llvm/lib/Debugger: ProgramInfo.cpp updated: 1.3 -> 1.4 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+8 -12) Index: llvm/lib/Debugger/ProgramInfo.cpp diff -u llvm/lib/Debugger/ProgramInfo.cpp:1.3 llvm/lib/Debugger/ProgramInfo.cpp:1.4 --- llvm/lib/Debugger/ProgramInfo.cpp:1.3 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Debugger/ProgramInfo.cpp Sat Jul 17 19:42:12 2004 @@ -61,8 +61,8 @@ } } } else if (Constant *C = dyn_cast(V)) { - if (ConstantPointerRef *CPR = dyn_cast(C)) - return getStringValue(CPR->getValue(), Offset); + if (GlobalValue *GV = dyn_cast(C)) + return getStringValue(GV, Offset); else if (ConstantExpr *CE = dyn_cast(C)) { if (CE->getOpcode() == Instruction::GetElementPtr) { // Turn a gep into the specified offset. @@ -108,8 +108,6 @@ if (const ConstantInt *C = dyn_cast(CI->getOperand(3))) CurColNo = C->getRawValue(); const Value *Op = CI->getOperand(4); - if (const ConstantPointerRef *CPR = dyn_cast(Op)) - Op = CPR->getValue(); if ((CurDesc = dyn_cast(Op)) && (LineNo < LastLineNo || @@ -192,11 +190,9 @@ if (ConstantStruct *CS = dyn_cast(Desc->getInitializer())) if (CS->getNumOperands() > 2) { // Entry #1 is the file descriptor. - if (const ConstantPointerRef *CPR = - dyn_cast(CS->getOperand(1))) - if (const GlobalVariable *GV = - dyn_cast(CPR->getValue())) - SourceFile = &PI.getSourceFile(GV); + if (const GlobalVariable *GV = + dyn_cast(CS->getOperand(1))) + SourceFile = &PI.getSourceFile(GV); // Entry #2 is the function name. Name = getStringValue(CS->getOperand(2)); @@ -366,9 +362,9 @@ if (Desc && Desc->hasInitializer()) if (ConstantStruct *CS = dyn_cast(Desc->getInitializer())) if (CS->getNumOperands() > 0) - if (const ConstantPointerRef *CPR = - dyn_cast(CS->getOperand(1))) - SourceFileDesc = dyn_cast(CPR->getValue()); + if (const GlobalVariable *GV = + dyn_cast(CS->getOperand(1))) + SourceFileDesc = GV; const SourceLanguage &Lang = getSourceFile(SourceFileDesc).getLanguage(); return *(Result = Lang.createSourceFunctionInfo(Desc, *this)); From llvm at cs.uiuc.edu Sat Jul 17 19:44:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:44:24 -0500 Subject: [llvm-commits] CVS: llvm/tools/analyze/AnalysisWrappers.cpp Message-ID: <200407180044.TAA10208@zion.cs.uiuc.edu> Changes in directory llvm/tools/analyze: AnalysisWrappers.cpp updated: 1.12 -> 1.13 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Minimize redundant isa usage --- Diffs of the changes: (+1 -1) Index: llvm/tools/analyze/AnalysisWrappers.cpp diff -u llvm/tools/analyze/AnalysisWrappers.cpp:1.12 llvm/tools/analyze/AnalysisWrappers.cpp:1.13 --- llvm/tools/analyze/AnalysisWrappers.cpp:1.12 Sun Jul 4 07:20:55 2004 +++ llvm/tools/analyze/AnalysisWrappers.cpp Sat Jul 17 19:44:14 2004 @@ -59,7 +59,7 @@ if (CS.getInstruction()) { for (CallSite::arg_iterator AI = CS.arg_begin(), E = CS.arg_end(); AI != E; ++AI) - if (isa(*AI) || isa(*AI)) { + if (isa(*AI)) { if (!PrintedFn) { std::cerr << "Function '" << I->getName() << "':\n"; PrintedFn = true; From llvm at cs.uiuc.edu Sat Jul 17 19:44:47 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:44:47 -0500 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/Miscompilation.cpp Message-ID: <200407180044.TAA10223@zion.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: Miscompilation.cpp updated: 1.49 -> 1.50 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : - Replace ConstantPointerRef usage with GlobalValue usage --- Diffs of the changes: (+1 -2) Index: llvm/tools/bugpoint/Miscompilation.cpp diff -u llvm/tools/bugpoint/Miscompilation.cpp:1.49 llvm/tools/bugpoint/Miscompilation.cpp:1.50 --- llvm/tools/bugpoint/Miscompilation.cpp:1.49 Wed Jun 23 12:31:13 2004 +++ llvm/tools/bugpoint/Miscompilation.cpp Sat Jul 17 19:44:37 2004 @@ -654,8 +654,7 @@ // GetElementPtr *funcName, ulong 0, ulong 0 std::vector GEPargs(2,Constant::getNullValue(Type::IntTy)); Value *GEP = - ConstantExpr::getGetElementPtr(ConstantPointerRef::get(funcName), - GEPargs); + ConstantExpr::getGetElementPtr(funcName, GEPargs); std::vector ResolverArgs; ResolverArgs.push_back(GEP); From reid at x10sys.com Sat Jul 17 19:51:49 2004 From: reid at x10sys.com (Reid Spencer) Date: Sat, 17 Jul 2004 20:51:49 -0400 Subject: [llvm-commits] ConstantPointerRef Changes Message-ID: LLVMers, The long awaited conclusion of bug 122 (VMCore cleanups) is very near. I have just committed all the changes to rid LLVM of the ConstantPointerRef abomination. This class no longer exists. Just use GlobalValue, GlobalVariable or Function directly. The changes pass 100% of Feature and Regression tests. Two minor discrepancies against the Programs tests were detected but these were attributed to either the test program (changes committed) or the test machine. What hasn't been tested: SparcV9 BE (thanks, Brian! :) Hopefully you won't get any grief from these changes, but if you do, please contact either Chris or I. I must also give at least 50% credit for these changes to Chris Lattner. Without his almost constant expertise at hand (on the IRC channel), I would not have been able to complete these changes this past week. Best Regards, Reid. From llvm at cs.uiuc.edu Sat Jul 17 19:55:59 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:55:59 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalValue.h Message-ID: <200407180055.TAA10281@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalValue.h updated: 1.16 -> 1.17 --- Log message: Fix typeos in comments. --- Diffs of the changes: (+2 -2) Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.16 llvm/include/llvm/GlobalValue.h:1.17 --- llvm/include/llvm/GlobalValue.h:1.16 Sat Jul 17 18:28:28 2004 +++ llvm/include/llvm/GlobalValue.h Sat Jul 17 19:55:49 2004 @@ -45,9 +45,9 @@ virtual ~GlobalValue(); /// If the usage is empty (except transitively dead constants), then this - /// global value can can be safely deleted since the destructor wll + /// global value can can be safely deleted since the destructor will /// delete the dead constants as well. - /// @brief Determine if theusage of this global value is empty except + /// @brief Determine if the usage of this global value is empty except /// for transitively dead constants. bool use_empty_except_constants(); From llvm at cs.uiuc.edu Sat Jul 17 19:57:08 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 19:57:08 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407180057.TAA10299@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.58 -> 1.59 --- Log message: Add a missing space to align comments. --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.58 llvm/include/llvm/Value.h:1.59 --- llvm/include/llvm/Value.h:1.58 Sat Jul 17 18:34:47 2004 +++ llvm/include/llvm/Value.h Sat Jul 17 19:56:58 2004 @@ -128,7 +128,7 @@ GlobalVariableVal, // This is an instance of GlobalVariable ConstantVal, // This is an instance of Constant InstructionVal, // This is an instance of Instruction - ValueListVal // This is for bcreader, a special ValTy + ValueListVal // This is for bcreader, a special ValTy }; unsigned getValueType() const { return SubclassID; From llvm at cs.uiuc.edu Sat Jul 17 20:04:29 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat, 17 Jul 2004 20:04:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp Message-ID: <200407180104.UAA10368@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: AsmWriter.cpp updated: 1.148 -> 1.149 --- Log message: Shrink some code. --- Diffs of the changes: (+1 -4) Index: llvm/lib/VMCore/AsmWriter.cpp diff -u llvm/lib/VMCore/AsmWriter.cpp:1.148 llvm/lib/VMCore/AsmWriter.cpp:1.149 --- llvm/lib/VMCore/AsmWriter.cpp:1.148 Sat Jul 17 18:45:23 2004 +++ llvm/lib/VMCore/AsmWriter.cpp Sat Jul 17 20:04:19 2004 @@ -766,10 +766,7 @@ if (GV->hasInitializer()) { Constant* C = cast(GV->getInitializer()); assert(C && "GlobalVar initializer isn't constant?"); - if (isa(C)) - writeOperand(GV->getInitializer(), false, true); - else - writeOperand(GV->getInitializer(), false, false); + writeOperand(GV->getInitializer(), false, isa(C)); } printInfoComment(*GV); From lattner at cs.uiuc.edu Sun Jul 18 01:57:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 01:57:08 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200407180657.BAA03444@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.17 -> 1.18 --- Log message: Fix a rather serious bug in previous checkin --- Diffs of the changes: (+0 -1) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.17 llvm/lib/Transforms/IPO/Inliner.cpp:1.18 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.17 Sat Jul 17 19:22:58 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Sun Jul 18 01:56:58 2004 @@ -175,7 +175,6 @@ if (F && F->hasOneUse()) if (Function *GV = dyn_cast(F->use_back())) if (GV->removeDeadConstantUsers()) { - delete GV; if (F->hasInternalLinkage()) { // There *MAY* be an edge from the external call node to this // function. If so, remove it. From lattner at cs.uiuc.edu Sun Jul 18 02:23:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 02:23:08 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalDCE.cpp Message-ID: <200407180723.CAA31248@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalDCE.cpp updated: 1.32 -> 1.33 --- Log message: Remove useless statistic, fix some slightly broken logic --- Diffs of the changes: (+4 -8) Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.32 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.33 --- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.32 Sat Jul 17 19:25:04 2004 +++ llvm/lib/Transforms/IPO/GlobalDCE.cpp Sun Jul 18 02:22:58 2004 @@ -26,7 +26,6 @@ namespace { Statistic<> NumFunctions("globaldce","Number of functions removed"); Statistic<> NumVariables("globaldce","Number of global variables removed"); - Statistic<> NumGVs("globaldce", "Number of global values removed"); struct GlobalDCE : public Pass { // run - Do the GlobalDCE pass on the specified module, optionally updating @@ -171,13 +170,10 @@ // might make it deader. // bool GlobalDCE::RemoveUnusedGlobalValue(GlobalValue &GV) { - for (Value::use_iterator I = GV.use_begin(), E = GV.use_end(); I != E; ++I) - if (GlobalValue* User = dyn_cast(*I)) - if (User->removeDeadConstantUsers()) { // Only if unreferenced... - ++NumGVs; - } - return false; - } + if (GV.use_empty()) return false; + GV.removeDeadConstantUsers(); + return GV.use_empty(); +} // SafeToDestroyConstant - It is safe to destroy a constant iff it is only used // by constants itself. Note that constants cannot be cyclic, so this test is From llvm at cs.uiuc.edu Sun Jul 18 02:25:24 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 02:25:24 -0500 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407180725.CAA12070@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.218 -> 1.219 --- Log message: Bug 122: http://llvm.cs.uiuc.edu/PR122 fixed. --- Diffs of the changes: (+4 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.218 llvm/docs/ReleaseNotes.html:1.219 --- llvm/docs/ReleaseNotes.html:1.218 Fri Jul 16 21:04:41 2004 +++ llvm/docs/ReleaseNotes.html Sun Jul 18 02:25:14 2004 @@ -257,6 +257,9 @@
  • Fixed: [sparcv9] null often spilled to constant pool.
  • +
  • Fixed: [code-cleanup] SymbolTable + class cleanup, Type should not derive from Value, eliminate + ConstantPointerRef class. All three changes have been made.
  • @@ -762,7 +765,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/17 02:04:41 $ + Last modified: $Date: 2004/07/18 07:25:14 $ From lattner at cs.uiuc.edu Sun Jul 18 03:13:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 03:13:08 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200407180813.DAA07421@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp updated: 1.1 -> 1.2 --- Log message: Fix infinite loop gccld'ing povray --- Diffs of the changes: (+6 -8) Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.1 llvm/lib/VMCore/Globals.cpp:1.2 --- llvm/lib/VMCore/Globals.cpp:1.1 Sat Jul 17 19:06:26 2004 +++ llvm/lib/VMCore/Globals.cpp Sun Jul 18 03:12:57 2004 @@ -17,7 +17,6 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "Support/LeakDetector.h" - using namespace llvm; //===----------------------------------------------------------------------===// @@ -28,21 +27,20 @@ /// there are no non-constant uses of this GlobalValue. If there aren't then /// this and the transitive closure of the constants can be deleted. See the /// destructor for details. -namespace { -bool removeDeadConstantUsers(Constant* C) { - while (!C->use_empty()) { +static bool removeDeadConstantUsers(Constant* C) { + if (isa(C)) return false; // Cannot remove this + + while (!C->use_empty()) if (Constant *User = dyn_cast(C->use_back())) { if (!removeDeadConstantUsers(User)) return false; // Constant wasn't dead } else { return false; // Non-constant usage; } - } - if (!isa(C)) - C->destroyConstant(); + + C->destroyConstant(); return true; } -} /// removeDeadConstantUsers - If there are any dead constant users dangling /// off of this global value, remove them. This method is useful for clients From llvm at cs.uiuc.edu Sun Jul 18 03:31:30 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:31:30 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp Message-ID: <200407180831.DAA11129@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: IPConstantPropagation.cpp updated: 1.6 -> 1.7 --- Log message: Avoid an unnecessary isa. --- Diffs of the changes: (+1 -3) Index: llvm/lib/Transforms/IPO/IPConstantPropagation.cpp diff -u llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.6 llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.7 --- llvm/lib/Transforms/IPO/IPConstantPropagation.cpp:1.6 Sat Jul 17 19:26:34 2004 +++ llvm/lib/Transforms/IPO/IPConstantPropagation.cpp Sun Jul 18 03:31:18 2004 @@ -82,9 +82,7 @@ if (*AI == &F) return false; // Passes the function into itself if (!ArgumentConstants[i].second) { - if (isa(*AI)) { - Constant *C = dyn_cast(*AI); - + if (Constant *C = dyn_cast(*AI)) { if (!ArgumentConstants[i].first) ArgumentConstants[i].first = C; else if (ArgumentConstants[i].first != C) { From llvm at cs.uiuc.edu Sun Jul 18 03:32:20 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:32:20 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/GCSE.cpp Message-ID: <200407180832.DAA11294@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: GCSE.cpp updated: 1.41 -> 1.42 --- Log message: Expand the scope to include global values because they are now constants too. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Transforms/Scalar/GCSE.cpp diff -u llvm/lib/Transforms/Scalar/GCSE.cpp:1.41 llvm/lib/Transforms/Scalar/GCSE.cpp:1.42 --- llvm/lib/Transforms/Scalar/GCSE.cpp:1.41 Sat Jul 17 19:28:47 2004 +++ llvm/lib/Transforms/Scalar/GCSE.cpp Sun Jul 18 03:32:10 2004 @@ -185,7 +185,7 @@ // If we are not replacing the instruction with a constant, we cannot do // anything special. - if (!isa(V) || isa(V)) { + if (!isa(V)) { I->replaceAllUsesWith(V); if (InvokeInst *II = dyn_cast(I)) { From llvm at cs.uiuc.edu Sun Jul 18 03:32:53 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:32:53 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407180832.DAA11397@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.223 -> 1.224 --- Log message: Delete a no-op loop. --- Diffs of the changes: (+0 -9) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.223 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.224 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.223 Sat Jul 17 19:29:25 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Jul 18 03:32:43 2004 @@ -3103,15 +3103,6 @@ continue; } - // Check to see if any of the operands of this instruction are a - // GlobalValue. Since they sneak in all over the place and inhibit - // optimization, we want to strip them out unconditionally! - for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) - if (isa(I->getOperand(i))) { - I->setOperand(i, I->getOperand(i)); - Changed = true; - } - // Now that we have an instruction, try combining it to simplify it... if (Instruction *Result = visit(*I)) { ++NumCombined; From llvm at cs.uiuc.edu Sun Jul 18 03:34:29 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:34:29 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerGC.cpp Message-ID: <200407180834.DAA11698@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: LowerGC.cpp updated: 1.3 -> 1.4 --- Log message: Expand the coercion of constants to include the newly constant Globals. --- Diffs of the changes: (+1 -2) Index: llvm/lib/Transforms/Scalar/LowerGC.cpp diff -u llvm/lib/Transforms/Scalar/LowerGC.cpp:1.3 llvm/lib/Transforms/Scalar/LowerGC.cpp:1.4 --- llvm/lib/Transforms/Scalar/LowerGC.cpp:1.3 Sat Jul 17 19:29:57 2004 +++ llvm/lib/Transforms/Scalar/LowerGC.cpp Sun Jul 18 03:34:19 2004 @@ -140,8 +140,7 @@ /// not have the specified type, insert a cast. static void Coerce(Instruction *I, unsigned OpNum, Type *Ty) { if (I->getOperand(OpNum)->getType() != Ty) { - Constant *C = dyn_cast(I->getOperand(OpNum)); - if (C && !isa(I->getOperand(OpNum))) + if (Constant *C = dyn_cast(I->getOperand(OpNum))) I->setOperand(OpNum, ConstantExpr::getCast(C, Ty)); else { CastInst *C = new CastInst(I->getOperand(OpNum), Ty, "", I); From llvm at cs.uiuc.edu Sun Jul 18 03:35:03 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:35:03 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/SCCP.cpp Message-ID: <200407180835.DAA11810@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: SCCP.cpp updated: 1.97 -> 1.98 --- Log message: Delete a redundant if branch. --- Diffs of the changes: (+1 -4) Index: llvm/lib/Transforms/Scalar/SCCP.cpp diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.97 llvm/lib/Transforms/Scalar/SCCP.cpp:1.98 --- llvm/lib/Transforms/Scalar/SCCP.cpp:1.97 Sat Jul 17 19:31:05 2004 +++ llvm/lib/Transforms/Scalar/SCCP.cpp Sun Jul 18 03:34:52 2004 @@ -175,10 +175,7 @@ hash_map::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map - if (GlobalValue *GV = dyn_cast(V)) { - // The address of a global is a constant... - ValueState[V].markConstant(GV); - } else if (Constant *CPV = dyn_cast(V)) { // Constants are constant + if (Constant *CPV = dyn_cast(V)) { // Constants are constant ValueState[CPV].markConstant(CPV); } else if (isa(V)) { // Arguments are overdefined ValueState[V].markOverdefined(); From llvm at cs.uiuc.edu Sun Jul 18 03:41:57 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 03:41:57 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Utils/ValueMapper.cpp Message-ID: <200407180841.DAA18401@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Utils: ValueMapper.cpp updated: 1.15 -> 1.16 --- Log message: Remove an if statement that would never be reached. --- Diffs of the changes: (+1 -3) Index: llvm/lib/Transforms/Utils/ValueMapper.cpp diff -u llvm/lib/Transforms/Utils/ValueMapper.cpp:1.15 llvm/lib/Transforms/Utils/ValueMapper.cpp:1.16 --- llvm/lib/Transforms/Utils/ValueMapper.cpp:1.15 Sat Jul 17 19:32:39 2004 +++ llvm/lib/Transforms/Utils/ValueMapper.cpp Sun Jul 18 03:41:47 2004 @@ -33,9 +33,7 @@ if (isa(C) || isa(C) || isa(C) || isa(C)) return VMSlot = C; // Primitive constants map directly - else if (GlobalValue *GV = dyn_cast(C)) { - return VMSlot = GV; - } else if (ConstantArray *CA = dyn_cast(C)) { + else if (ConstantArray *CA = dyn_cast(C)) { const std::vector &Vals = CA->getValues(); for (unsigned i = 0, e = Vals.size(); i != e; ++i) { Value *MV = MapValue(Vals[i], VM); From llvm at cs.uiuc.edu Sun Jul 18 08:10:41 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 08:10:41 -0500 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200407181310.IAA28717@zion.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.65 -> 1.66 --- Log message: bug 122: http://llvm.cs.uiuc.edu/PR122 : Updated to remove references to ConstantPointerRef and reflect the change in the inheritance hierarchy: GlobalValue now derives from Constant. --- Diffs of the changes: (+19 -18) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.65 llvm/docs/ProgrammersManual.html:1.66 --- llvm/docs/ProgrammersManual.html:1.65 Thu Jul 8 12:49:37 2004 +++ llvm/docs/ProgrammersManual.html Sun Jul 18 08:10:31 2004 @@ -89,15 +89,18 @@
  • The GetElementPtrInst class
  • -
  • The GlobalValue class -
  • The Module class
  • -
  • The Constant class
  • +
  • The Constant class + +
  • The Type class
  • The Argument class
  • @@ -1258,7 +1261,7 @@ other globals defined in different translation units. To control the linking process, GlobalValues know their linkage rules. Specifically, GlobalValues know whether they have internal or external linkage, as -defined by the LinkageTypes enumerator.

    +defined by the LinkageTypes enumeration.

    If a GlobalValue has internal linkage (equivalent to being static in C), it is not visible to code outside the current translation @@ -1353,6 +1356,9 @@ href="#BasicBlock">BasicBlocks, or Arguments in the function body.

    +

    Note that Function is a GlobalValue +and therefore also a Constant. The value of the function +is its address (after linking) which is guaranteed to be constant.

    @@ -1698,18 +1704,13 @@ Returns a Vecotr of component constants that makeup this array. -
  • ConstantPointerRef : This represents a constant pointer value -that is initialized to point to a global value, which lies at a -constant fixed address. -
      -
    • GlobalValue *getValue(): Returns the global -value to which this pointer is pointing to.
    • -
    +
  • GlobalValue : This represents either a global variable or a + function. In either case, the value is a constant fixed address + (after linking).
  • - @@ -2045,7 +2046,7 @@ Dinakar Dhurjati and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/08 17:49:37 $ + Last modified: $Date: 2004/07/18 13:10:31 $ From lattner at cs.uiuc.edu Sun Jul 18 13:20:37 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 13:20:37 -0500 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/PoolAllocate.cpp Message-ID: <200407181820.NAA25053@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: PoolAllocate.cpp updated: 1.71 -> 1.72 --- Log message: CPR is dead!! --- Diffs of the changes: (+1 -2) Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.71 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.72 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.71 Thu Jul 15 19:09:10 2004 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Sun Jul 18 13:20:27 2004 @@ -133,8 +133,7 @@ Function *origF = fmI->first; Function *cloneF = fmI->second; - ConstantPointerRef *Ref = ConstantPointerRef::get(cloneF); - Constant *expr = ConstantExpr::getCast(Ref, origF->getType()); + Constant *expr = ConstantExpr::getCast(cloneF, origF->getType()); origF->replaceAllUsesWith(expr); } return true; From lattner at cs.uiuc.edu Sun Jul 18 13:59:54 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 13:59:54 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407181859.NAA28089@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.224 -> 1.225 --- Log message: Minor cleanup, no functionality change --- Diffs of the changes: (+2 -7) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.224 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.225 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.224 Sun Jul 18 03:32:43 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Sun Jul 18 13:59:44 2004 @@ -2456,10 +2456,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { if (!isa(CS.getCalledValue())) return false; ConstantExpr *CE = cast(CS.getCalledValue()); - if (CE->getOpcode() != Instruction::Cast || - !isa(CE->getOperand(0))) + if (CE->getOpcode() != Instruction::Cast || !isa(CE->getOperand(0))) return false; - if (!isa(CE->getOperand(0))) return false; Function *Callee = cast(CE->getOperand(0)); Instruction *Caller = CS.getInstruction(); @@ -2809,8 +2807,7 @@ Indices.push_back(cast(*I)); if (I == E) { // If they are all constants... - Constant *CE = - ConstantExpr::getGetElementPtr(GV, Indices); + Constant *CE = ConstantExpr::getGetElementPtr(GV, Indices); // Replace all uses of the GEP with the new constexpr... return ReplaceInstUsesWith(GEP, CE); @@ -2977,8 +2974,6 @@ if (Constant *C = dyn_cast(Op)) if (C->isNullValue()) // load null -> 0 return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); - else if (isa(C)) - Op = C; // Instcombine load (constant global) into the value loaded... if (GlobalVariable *GV = dyn_cast(Op)) From lattner at cs.uiuc.edu Sun Jul 18 14:56:30 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 14:56:30 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalConstifier.cpp Message-ID: <200407181956.OAA00858@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: GlobalConstifier.cpp updated: 1.3 -> 1.4 --- Log message: Strip out and simplify some code. This also fixes the regression last night compiling cfrac. It did not realize that code like this: int G; int *H = &G; takes the address of G. --- Diffs of the changes: (+2 -9) Index: llvm/lib/Transforms/IPO/GlobalConstifier.cpp diff -u llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.3 llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.4 --- llvm/lib/Transforms/IPO/GlobalConstifier.cpp:1.3 Sat Jul 17 19:25:57 2004 +++ llvm/lib/Transforms/IPO/GlobalConstifier.cpp Sun Jul 18 14:56:20 2004 @@ -44,16 +44,9 @@ /// static bool isStoredThrough(Value *V) { for (Value::use_iterator UI = V->use_begin(), E = V->use_end(); UI != E; ++UI) - if (Constant *C = dyn_cast(*UI)) { - if (ConstantExpr *CE = dyn_cast(C)) { - if (isStoredThrough(CE)) - return true; - } else if (GlobalValue *GV = dyn_cast(C)) { - if (isStoredThrough(GV)) return true; - } else { - // Must be an element of a constant array or something. + if (ConstantExpr *CE = dyn_cast(*UI)) { + if (isStoredThrough(CE)) return true; - } } else if (Instruction *I = dyn_cast(*UI)) { if (I->getOpcode() == Instruction::GetElementPtr) { if (isStoredThrough(I)) return true; From llvm at cs.uiuc.edu Sun Jul 18 15:15:22 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:15:22 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/ Message-ID: <200407182015.PAA31504@zion.cs.uiuc.edu> Changes in directory llvm/lib/System: --- Log message: Directory /var/cvs/llvm/llvm/lib/System added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 18 15:25:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:25:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/Cygwin/ Message-ID: <200407182025.PAA31767@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/Cygwin: --- Log message: Directory /var/cvs/llvm/llvm/lib/System/Cygwin added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 18 15:25:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:25:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/Darwin/ Message-ID: <200407182025.PAA31772@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/Darwin: --- Log message: Directory /var/cvs/llvm/llvm/lib/System/Darwin added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 18 15:25:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:25:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/SunOS/ Message-ID: <200407182025.PAA31782@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/SunOS: --- Log message: Directory /var/cvs/llvm/llvm/lib/System/SunOS added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 18 15:25:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:25:04 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/Linux/ Message-ID: <200407182025.PAA31777@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/Linux: --- Log message: Directory /var/cvs/llvm/llvm/lib/System/Linux added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 18 15:25:58 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 15:25:58 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/APR/ Message-ID: <200407182025.PAA31820@zion.cs.uiuc.edu> Changes in directory llvm/lib/System/APR: --- Log message: Directory /var/cvs/llvm/llvm/lib/System/APR added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Sun Jul 18 16:18:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 16:18:13 -0500 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-types.c Message-ID: <200407182118.QAA20820@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-types.c updated: 1.10 -> 1.11 --- Log message: robustify code and unbreak llvmgcc build on several targets --- Diffs of the changes: (+1 -7) Index: llvm-gcc/gcc/llvm-types.c diff -u llvm-gcc/gcc/llvm-types.c:1.10 llvm-gcc/gcc/llvm-types.c:1.11 --- llvm-gcc/gcc/llvm-types.c:1.10 Tue Jul 6 22:13:44 2004 +++ llvm-gcc/gcc/llvm-types.c Sun Jul 18 16:18:03 2004 @@ -60,13 +60,7 @@ case ArrayTyID: return llvm_type_get_size(Ty->Elements[0])*Ty->x.Array.Size; case StructTyID: return Ty->x.Struct.Size; case PointerTyID: /* Target dependant pointer size */ - switch (ptr_mode) { - case SImode: case PSImode: return 4; - case DImode: case PDImode: return 8; - default: - assert(0 && "Unknown mode for pointer type!"); - } - return (TREE_INT_CST_LOW(TYPE_SIZE(ptr_type_node))+7)/8; + return POINTER_SIZE/BITS_PER_UNIT; default: fprintf(stderr, "ERROR: Type doesn't have size: "); llvm_type_dump(Ty); From lattner at cs.uiuc.edu Sun Jul 18 16:34:27 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 16:34:27 -0500 Subject: [llvm-commits] CVS: llvm/lib/Transforms/IPO/Inliner.cpp Message-ID: <200407182134.QAA25881@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/IPO: Inliner.cpp updated: 1.18 -> 1.19 --- Log message: Fix a performance regression from the CPR patch, simplify code --- Diffs of the changes: (+6 -14) Index: llvm/lib/Transforms/IPO/Inliner.cpp diff -u llvm/lib/Transforms/IPO/Inliner.cpp:1.18 llvm/lib/Transforms/IPO/Inliner.cpp:1.19 --- llvm/lib/Transforms/IPO/Inliner.cpp:1.18 Sun Jul 18 01:56:58 2004 +++ llvm/lib/Transforms/IPO/Inliner.cpp Sun Jul 18 16:34:16 2004 @@ -170,28 +170,20 @@ CallGraphNode *CGN = I->second; Function *F = CGN ? CGN->getFunction() : 0; - // If the only remaining use of the function is a dead constant - // pointer ref, remove it. - if (F && F->hasOneUse()) - if (Function *GV = dyn_cast(F->use_back())) - if (GV->removeDeadConstantUsers()) { - if (F->hasInternalLinkage()) { - // There *MAY* be an edge from the external call node to this - // function. If so, remove it. - CallGraphNode *EN = CG.getExternalCallingNode(); - CallGraphNode::iterator I = std::find(EN->begin(), EN->end(), CGN); - if (I != EN->end()) EN->removeCallEdgeTo(CGN); - } - } + // If the only remaining users of the function are dead constants, + // remove them. + if (F) F->removeDeadConstantUsers(); if (F && (F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && F->use_empty()) { + // Remove any call graph edges from the function to its callees. while (CGN->begin() != CGN->end()) CGN->removeCallEdgeTo(*(CGN->end()-1)); // If the function has external linkage (basically if it's a linkonce - // function) remove the edge from the external node to the callee node. + // function) remove the edge from the external node to the callee + // node. if (!F->hasInternalLinkage()) CG.getExternalCallingNode()->removeCallEdgeTo(CGN); From lattner at cs.uiuc.edu Sun Jul 18 16:44:24 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 16:44:24 -0500 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200407182144.QAA01820@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.66 -> 1.67 --- Log message: Doesn't exist --- Diffs of the changes: (+1 -3) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.66 llvm/docs/ProgrammersManual.html:1.67 --- llvm/docs/ProgrammersManual.html:1.66 Sun Jul 18 08:10:31 2004 +++ llvm/docs/ProgrammersManual.html Sun Jul 18 16:44:13 2004 @@ -1662,8 +1662,6 @@
      -
    • bool isConstantExpr(): Returns true if it is a -ConstantExpr
      Important Subclasses of Constant

        @@ -2046,7 +2044,7 @@ Dinakar Dhurjati and Chris Lattner
        The LLVM Compiler Infrastructure
        - Last modified: $Date: 2004/07/18 13:10:31 $ + Last modified: $Date: 2004/07/18 21:44:13 $ From lattner at cs.uiuc.edu Sun Jul 18 16:56:34 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 16:56:34 -0500 Subject: [llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp Message-ID: <200407182156.QAA21016@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: CommandLine.cpp updated: 1.45 -> 1.46 --- Log message: Add a workaround for a GCC 3.3.2 bug --- Diffs of the changes: (+6 -1) Index: llvm/lib/Support/CommandLine.cpp diff -u llvm/lib/Support/CommandLine.cpp:1.45 llvm/lib/Support/CommandLine.cpp:1.46 --- llvm/lib/Support/CommandLine.cpp:1.45 Fri Jul 2 20:21:05 2004 +++ llvm/lib/Support/CommandLine.cpp Sun Jul 18 16:56:20 2004 @@ -69,7 +69,12 @@ // static void RemoveArgument(const char *ArgName, Option *Opt) { if (CommandLineOptions == 0) return; - assert(getOption(ArgName) == Opt && "Arg not in map!"); +#ifndef NDEBUG + // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's + // If we pass ArgName directly into getOption here. + std::string Tmp = ArgName; + assert(getOption(Tmp) == Opt && "Arg not in map!"); +#endif CommandLineOptions->erase(ArgName); if (CommandLineOptions->empty()) { delete CommandLineOptions; From llvm at cs.uiuc.edu Sun Jul 18 17:31:38 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 17:31:38 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/Makefile Message-ID: <200407182231.RAA03407@zion.cs.uiuc.edu> Changes in directory llvm/lib/System: Makefile added (r1.1) --- Log message: Initiali Makefile for this library. --- Diffs of the changes: (+13 -0) Index: llvm/lib/System/Makefile diff -c /dev/null llvm/lib/System/Makefile:1.1 *** /dev/null Sun Jul 18 17:31:38 2004 --- llvm/lib/System/Makefile Sun Jul 18 17:31:28 2004 *************** *** 0 **** --- 1,13 ---- + ##===- lib/System/Makefile ---------------------------------*- Makefile -*-===## + # + # The LLVM Compiler Infrastructure + # + # This file was developed by Reid Spencer and is distributed under the + # University of Illinois Open Source License. See LICENSE.TXT for details. + # + ##===----------------------------------------------------------------------===## + LEVEL = ../.. + LIBRARYNAME = system + BUILD_ARCHIVE = 1 + + include $(LEVEL)/Makefile.common From lattner at cs.uiuc.edu Sun Jul 18 17:32:32 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 17:32:32 -0500 Subject: [llvm-commits] CVS: llvm/docs/GettingStarted.html Message-ID: <200407182232.RAA21166@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GettingStarted.html updated: 1.62 -> 1.63 --- Log message: Add note about GCC 3.3.2 being completely broken --- Diffs of the changes: (+51 -15) Index: llvm/docs/GettingStarted.html diff -u llvm/docs/GettingStarted.html:1.62 llvm/docs/GettingStarted.html:1.63 --- llvm/docs/GettingStarted.html:1.62 Mon Jun 28 12:14:01 2004 +++ llvm/docs/GettingStarted.html Sun Jul 18 17:32:22 2004 @@ -18,6 +18,7 @@
        1. Hardware
        2. Software +
        3. Broken versions of GCC
      • Getting Started with LLVM @@ -144,9 +145,10 @@
      • Build the LLVM Suite:
          -
        1. Set your LLVM_LIB_SEARCH_PATH environment variable. -
        2. gmake -k |& tee gnumake.out -    # this is csh or tcsh syntax +
        3. Set your LLVM_LIB_SEARCH_PATH environment variable.
        4. +
        5. gmake -k |& tee gnumake.out +    # this is csh or tcsh syntax
        6. +
        7. If you get an "internal compiler error (ICE)" see below.
        @@ -255,7 +257,7 @@ +
    -

    The remainder of this guide is meant to get you up and running with -LLVM and to give you some basic information about the LLVM environment. -A complete guide to installation is provided in the -next section.

    + + -

    The later sections of this guide describe the general layout of the the LLVM source tree, a simple example using the LLVM tool chain, and links to find more information about LLVM or to get -help via e-mail.

    +
    + +

    LLVM is very demanding of the host C++ compiler, and as such tends to expose +bugs in the compiler. In particular, several versions of GCC crash when trying +to compile LLVM. We routinely use GCC 3.3.3 and GCC 3.4.0 and have had success +with them. Other versions of GCC will probably work as well. GCC versions listed +here are known to not work. If you are using one of these versions, please try +to upgrade your GCC to something more recent. If you run into a problem with a +version of GCC not listed here, please let +us know. Please use the "gcc -v" command to find out which version +of GCC you are using. +

    + +

    GCC versions prior to 3.0: GCC 2.96.x and before had several +problems in the STL that effectively prevent it from compiling LLVM. +

    + +

    GCC 3.3.2: This version of GCC suffered from a serious bug which causes it to crash in +the "convert_from_eh_region_ranges_1" GCC function.

    + + +
    + +

    The remainder of this guide is meant to get you up and running with +LLVM and to give you some basic information about the LLVM environment.

    + +

    The later sections of this guide describe the general layout of the the LLVM source tree, a simple example using the LLVM tool chain, and links to find more information about LLVM or to get +help via e-mail.

    +
    +
    Terminology and Notation @@ -671,7 +703,11 @@

    gmake

    -

    If you have multiple processors in your machine, you may wish to use some of +

    If the build fails, please check here to see if you +are using a known broken version of GCC to compile LLVM with.

    + +

    +If you have multiple processors in your machine, you may wish to use some of the parallel build options provided by GNU Make. For example, you could use the command:

    @@ -1231,7 +1267,7 @@ Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/28 17:14:01 $ + Last modified: $Date: 2004/07/18 22:32:22 $ From llvm at cs.uiuc.edu Sun Jul 18 17:33:18 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun, 18 Jul 2004 17:33:18 -0500 Subject: [llvm-commits] CVS: llvm/lib/System/README.txt Message-ID: <200407182233.RAA03473@zion.cs.uiuc.edu> Changes in directory llvm/lib/System: README.txt added (r1.1) --- Log message: A description of what this library is about, reference to the documentation and a list of don'ts for the library. All so future maintainers don't break the important contract this library has with its user: LLVM. --- Diffs of the changes: (+23 -0) Index: llvm/lib/System/README.txt diff -c /dev/null llvm/lib/System/README.txt:1.1 *** /dev/null Sun Jul 18 17:33:18 2004 --- llvm/lib/System/README.txt Sun Jul 18 17:33:08 2004 *************** *** 0 **** --- 1,23 ---- + System Utilities Interface + ========================== + + The design of this library has several key constraints aimed at shielding LLVM + from the vagaries of operating system differences. The goal here is to provide + interfaces to operating system concepts (files, memory maps, sockets, signals, + locking, etc) efficiently and in such a way that the remainder of LLVM is + completely operating system agnostic. + + PLEASE READ AND COMPREHEND FULLY THE DOCUMENTATION in + + llvm/docs/SystemLibrary.html + + before making changes to this library. + + Briefly, the rules are: + + 1. This library may not expose no system-specific header files (STL excepted). + 2. This library may not allocate memory (directly). + 3. This library may not throw exceptions. + 4. This library may not use virtual methods in its classes. + 5. This library may not expose system specific types, data or functions through + its interface From lattner at cs.uiuc.edu Sun Jul 18 18:43:44 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 18:43:44 -0500 Subject: [llvm-commits] CVS: llvm/tools/analyze/AnalysisWrappers.cpp Message-ID: <200407182343.SAA32171@apoc.cs.uiuc.edu> Changes in directory llvm/tools/analyze: AnalysisWrappers.cpp updated: 1.13 -> 1.14 --- Log message: Remove this printer --- Diffs of the changes: (+0 -19) Index: llvm/tools/analyze/AnalysisWrappers.cpp diff -u llvm/tools/analyze/AnalysisWrappers.cpp:1.13 llvm/tools/analyze/AnalysisWrappers.cpp:1.14 --- llvm/tools/analyze/AnalysisWrappers.cpp:1.13 Sat Jul 17 19:44:14 2004 +++ llvm/tools/analyze/AnalysisWrappers.cpp Sun Jul 18 18:43:34 2004 @@ -19,30 +19,11 @@ #include "llvm/Module.h" #include "llvm/Pass.h" -#include "llvm/Analysis/InstForest.h" #include "llvm/Support/CallSite.h" #include - using namespace llvm; namespace { - struct InstForestHelper : public FunctionPass { - Function *F; - virtual bool runOnFunction(Function &Func) { F = &Func; return false; } - - void print(std::ostream &OS) const { - std::cout << InstForest(F); - } - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesAll(); - } - }; - - RegisterAnalysis P1("instforest", "InstForest Printer"); -} - -namespace { /// ExternalFunctionsPassedConstants - This pass prints out call sites to /// external functions that are called with constant arguments. This can be /// useful when looking for standard library functions we should constant fold From lattner at cs.uiuc.edu Sun Jul 18 18:44:25 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 18:44:25 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/InstForest.h Message-ID: <200407182344.SAA01058@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: InstForest.h (r1.26) removed --- Log message: Remove dead file --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Sun Jul 18 19:55:30 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:55:30 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalValue.h Message-ID: <200407190055.TAA22263@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalValue.h updated: 1.17 -> 1.18 --- Log message: Change method to return void. Inline dtor --- Diffs of the changes: (+7 -5) Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.17 llvm/include/llvm/GlobalValue.h:1.18 --- llvm/include/llvm/GlobalValue.h:1.17 Sat Jul 17 19:55:49 2004 +++ llvm/include/llvm/GlobalValue.h Sun Jul 18 19:55:19 2004 @@ -42,7 +42,9 @@ LinkageTypes Linkage; // The linkage of this global Module *Parent; public: - virtual ~GlobalValue(); + ~GlobalValue() { + removeDeadConstantUsers(); // remove any dead constants using this. + } /// If the usage is empty (except transitively dead constants), then this /// global value can can be safely deleted since the destructor will @@ -85,10 +87,10 @@ /// that want to check to see if a global is unused, but don't want to deal /// with potentially dead constants hanging off of the globals. /// - /// This function returns true if the global value is now dead. If all - /// users of this global are not dead, this method may return false and - /// leave some of them around. - bool removeDeadConstantUsers(); + /// This method tries to make the global dead. If it detects a user that + /// would prevent it from becoming completely dead, it gives up early, + /// potentially leaving some dead constant users around. + void removeDeadConstantUsers(); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GlobalValue *T) { return true; } From lattner at cs.uiuc.edu Sun Jul 18 19:55:45 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:55:45 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Globals.cpp Message-ID: <200407190055.TAA22431@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Globals.cpp updated: 1.2 -> 1.3 --- Log message: Method now returns null, dtor is inlined --- Diffs of the changes: (+3 -13) Index: llvm/lib/VMCore/Globals.cpp diff -u llvm/lib/VMCore/Globals.cpp:1.2 llvm/lib/VMCore/Globals.cpp:1.3 --- llvm/lib/VMCore/Globals.cpp:1.2 Sun Jul 18 03:12:57 2004 +++ llvm/lib/VMCore/Globals.cpp Sun Jul 18 19:55:35 2004 @@ -50,25 +50,15 @@ /// This function returns true if the global value is now dead. If all /// users of this global are not dead, this method may return false and /// leave some of them around. -bool GlobalValue::removeDeadConstantUsers() { +void GlobalValue::removeDeadConstantUsers() { while(!use_empty()) { if (Constant* User = dyn_cast(use_back())) { if (!::removeDeadConstantUsers(User)) - return false; // Constant wasn't dead + return; // Constant wasn't dead } else { - return false; // Non-constant usage; + return; // Non-constant usage; } } - return true; -} - -/// This virtual destructor is responsible for deleting any transitively dead -/// Constants that are using the GlobalValue. -GlobalValue::~GlobalValue() { - // Its an error to attempt destruction with non-constant uses remaining. - bool okay_to_destruct = removeDeadConstantUsers(); - assert(okay_to_destruct && - "Can't destroy GlobalValue with non-constant uses."); } /// Override destroyConstant to make sure it doesn't get called on From lattner at cs.uiuc.edu Sun Jul 18 19:57:50 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:57:50 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407190057.TAA23191@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.59 -> 1.60 --- Log message: Add new enum entries for ConstantAggregateZeroVal/ConstantExprVal and rename ConstantVal to SimpleConstantVal --- Diffs of the changes: (+12 -8) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.59 llvm/include/llvm/Value.h:1.60 --- llvm/include/llvm/Value.h:1.59 Sat Jul 17 19:56:58 2004 +++ llvm/include/llvm/Value.h Sun Jul 18 19:57:40 2004 @@ -122,13 +122,15 @@ /// (and Instruction must be last). /// enum ValueTy { - ArgumentVal, // This is an instance of Argument - BasicBlockVal, // This is an instance of BasicBlock - FunctionVal, // This is an instance of Function - GlobalVariableVal, // This is an instance of GlobalVariable - ConstantVal, // This is an instance of Constant - InstructionVal, // This is an instance of Instruction - ValueListVal // This is for bcreader, a special ValTy + ArgumentVal, // This is an instance of Argument + BasicBlockVal, // This is an instance of BasicBlock + FunctionVal, // This is an instance of Function + GlobalVariableVal, // This is an instance of GlobalVariable + ConstantExprVal, // This is an instance of ConstantExpr + ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull + SimpleConstantVal, // This is some other type of Constant + InstructionVal, // This is an instance of Instruction + ValueListVal // This is for bcreader, a special ValTy }; unsigned getValueType() const { return SubclassID; @@ -178,7 +180,9 @@ // the subtype header files to test to see if the value is a subclass... // template <> inline bool isa_impl(const Value &Val) { - return Val.getValueType() == Value::ConstantVal || + return Val.getValueType() == Value::ConstantExprVal || + Val.getValueType() == Value::SimpleConstantVal || + Val.getValueType() == Value::ConstantAggregateZeroVal || Val.getValueType() == Value::FunctionVal || Val.getValueType() == Value::GlobalVariableVal; } From lattner at cs.uiuc.edu Sun Jul 18 19:58:12 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:58:12 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constant.h Message-ID: <200407190058.TAA23205@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constant.h updated: 1.14 -> 1.15 --- Log message: eliminate isConstantExpr, changes to isa implementation --- Diffs of the changes: (+4 -7) Index: llvm/include/llvm/Constant.h diff -u llvm/include/llvm/Constant.h:1.14 llvm/include/llvm/Constant.h:1.15 --- llvm/include/llvm/Constant.h:1.14 Sat Jul 17 18:26:12 2004 +++ llvm/include/llvm/Constant.h Sun Jul 18 19:58:02 2004 @@ -20,7 +20,7 @@ class Constant : public User { protected: - inline Constant(const Type *Ty, ValueTy vty = Value::ConstantVal, + inline Constant(const Type *Ty, ValueTy vty = Value::SimpleConstantVal, const std::string& Name = "" ) : User(Ty, vty, Name) {} ~Constant() {} @@ -40,11 +40,6 @@ virtual void print(std::ostream &O) const; - /// isConstantExpr - Return true if this is a ConstantExpr - /// - virtual bool isConstantExpr() const { return false; } - - /// destroyConstant - Called if some element of this constant is no longer /// valid. At this point only other constants may be on the use_list for this /// constant. Any constants on our Use list must also be destroy'd. The @@ -59,7 +54,9 @@ static inline bool classof(const Constant *) { return true; } static inline bool classof(const GlobalValue *) { return true; } static inline bool classof(const Value *V) { - return V->getValueType() == Value::ConstantVal || + return V->getValueType() == Value::SimpleConstantVal || + V->getValueType() == Value::ConstantExprVal || + V->getValueType() == Value::ConstantAggregateZeroVal || V->getValueType() == Value::FunctionVal || V->getValueType() == Value::GlobalVariableVal; } From lattner at cs.uiuc.edu Sun Jul 18 19:58:57 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:58:57 -0500 Subject: [llvm-commits] CVS: llvm/include/llvm/Constants.h Message-ID: <200407190058.TAA23221@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Constants.h updated: 1.50 -> 1.51 --- Log message: inline classof implementations, eliminate use of virtual methods. classof is now MUCH faster than it used to be. --- Diffs of the changes: (+33 -41) Index: llvm/include/llvm/Constants.h diff -u llvm/include/llvm/Constants.h:1.50 llvm/include/llvm/Constants.h:1.51 --- llvm/include/llvm/Constants.h:1.50 Sat Jul 17 18:26:57 2004 +++ llvm/include/llvm/Constants.h Sun Jul 18 19:58:47 2004 @@ -16,6 +16,7 @@ #define LLVM_CONSTANTS_H #include "llvm/Constant.h" +#include "llvm/Type.h" #include "Support/DataTypes.h" namespace llvm { @@ -77,9 +78,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantIntegral *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->isIntegral(); } }; @@ -113,11 +114,8 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantBool *) { return true; } - static bool classof(const Constant *CPV) { - return (CPV == True) | (CPV == False); - } - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return (V == True) | (V == False); } }; @@ -155,9 +153,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantInt *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->isInteger(); } }; @@ -209,9 +207,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: /// static inline bool classof(const ConstantSInt *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->isSigned(); } }; @@ -245,9 +243,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantUInt *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->isUnsigned(); } }; @@ -302,9 +300,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantFP *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->isFloatingPoint(); } }; @@ -315,7 +313,8 @@ friend struct ConstantCreator; ConstantAggregateZero(const ConstantAggregateZero &); // DO NOT IMPLEMENT protected: - ConstantAggregateZero(const Type *Ty) : Constant(Ty) {} + ConstantAggregateZero(const Type *Ty) + : Constant(Ty, ConstantAggregateZeroVal) {} public: /// get() - static factory method for creating a null aggregate. It is /// illegal to call this method with a non-aggregate type. @@ -331,10 +330,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: /// - static inline bool classof(const ConstantAggregateZero *) { return true; } - static bool classof(const Constant *CPV); - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const ConstantAggregateZero *) { return true; } + static bool classof(const Value *V) { + return V->getValueType() == ConstantAggregateZeroVal; } }; @@ -384,9 +382,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantArray *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->getTypeID() == Type::ArrayTyID; } }; @@ -429,9 +427,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantStruct *) { return true; } - static bool classof(const Constant *CPV); // defined in Constants.cpp - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + V->getType()->getTypeID() == Type::StructTyID; } }; @@ -458,9 +456,9 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantPointerNull *) { return true; } - static bool classof(const Constant *CPV); - static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + static bool classof(const Value *V) { + return V->getValueType() == SimpleConstantVal && + isa(V->getType()); } }; @@ -565,9 +563,6 @@ /// getOpcodeName - Return a string representation for an opcode. const char *getOpcodeName() const; - /// isConstantExpr - Return true if this is a ConstantExpr - virtual bool isConstantExpr() const { return true; } - virtual void destroyConstant(); virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, bool DisableChecking = false); @@ -583,11 +578,8 @@ /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const ConstantExpr *) { return true; } - static inline bool classof(const Constant *CPV) { - return CPV->isConstantExpr(); - } static inline bool classof(const Value *V) { - return isa(V) && classof(cast(V)); + return V->getValueType() == ConstantExprVal; } }; From lattner at cs.uiuc.edu Sun Jul 18 19:59:21 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 19:59:21 -0500 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp Message-ID: <200407190059.TAA23258@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Constants.cpp updated: 1.95 -> 1.96 --- Log message: classof implementations are now inlined --- Diffs of the changes: (+5 -42) Index: llvm/lib/VMCore/Constants.cpp diff -u llvm/lib/VMCore/Constants.cpp:1.95 llvm/lib/VMCore/Constants.cpp:1.96 --- llvm/lib/VMCore/Constants.cpp:1.95 Sat Jul 17 18:48:33 2004 +++ llvm/lib/VMCore/Constants.cpp Sun Jul 18 19:59:10 2004 @@ -269,14 +269,14 @@ } ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C, const Type *Ty) - : Constant(Ty), iType(Opcode) { + : Constant(Ty, ConstantExprVal), iType(Opcode) { Operands.reserve(1); Operands.push_back(Use(C, this)); } // Select instruction creation ctor ConstantExpr::ConstantExpr(Constant *C, Constant *V1, Constant *V2) - : Constant(V1->getType()), iType(Instruction::Select) { + : Constant(V1->getType(), ConstantExprVal), iType(Instruction::Select) { Operands.reserve(3); Operands.push_back(Use(C, this)); Operands.push_back(Use(V1, this)); @@ -291,7 +291,8 @@ } ConstantExpr::ConstantExpr(unsigned Opcode, Constant *C1, Constant *C2) - : Constant(isSetCC(Opcode) ? Type::BoolTy : C1->getType()), iType(Opcode) { + : Constant(isSetCC(Opcode) ? Type::BoolTy : C1->getType(), ConstantExprVal), + iType(Opcode) { Operands.reserve(2); Operands.push_back(Use(C1, this)); Operands.push_back(Use(C2, this)); @@ -299,7 +300,7 @@ ConstantExpr::ConstantExpr(Constant *C, const std::vector &IdxList, const Type *DestTy) - : Constant(DestTy), iType(Instruction::GetElementPtr) { + : Constant(DestTy, ConstantExprVal), iType(Instruction::GetElementPtr) { Operands.reserve(1+IdxList.size()); Operands.push_back(Use(C, this)); for (unsigned i = 0, E = IdxList.size(); i != E; ++i) @@ -383,44 +384,6 @@ //===----------------------------------------------------------------------===// -// classof implementations - -bool ConstantIntegral::classof(const Constant *CPV) { - return CPV->getType()->isIntegral() && !isa(CPV); -} - -bool ConstantInt::classof(const Constant *CPV) { - return CPV->getType()->isInteger() && !isa(CPV); -} -bool ConstantSInt::classof(const Constant *CPV) { - return CPV->getType()->isSigned() && !isa(CPV); -} -bool ConstantUInt::classof(const Constant *CPV) { - return CPV->getType()->isUnsigned() && !isa(CPV); -} -bool ConstantFP::classof(const Constant *CPV) { - const Type *Ty = CPV->getType(); - return ((Ty == Type::FloatTy || Ty == Type::DoubleTy) && - !isa(CPV)); -} -bool ConstantAggregateZero::classof(const Constant *CPV) { - return (isa(CPV->getType()) || isa(CPV->getType())) && - CPV->isNullValue(); -} -bool ConstantArray::classof(const Constant *CPV) { - return isa(CPV->getType()) && !CPV->isNullValue(); -} -bool ConstantStruct::classof(const Constant *CPV) { - return isa(CPV->getType()) && !CPV->isNullValue(); -} - -bool ConstantPointerNull::classof(const Constant *CPV) { - return !isa(CPV) && isa(CPV->getType()) && !isa(CPV) && - CPV->getNumOperands() == 0; -} - - -//===----------------------------------------------------------------------===// // isValueValidForType implementations bool ConstantSInt::isValueValidForType(const Type *Ty, int64_t Val) { From lattner at cs.uiuc.edu Sun Jul 18 21:16:06 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 21:16:06 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407190216.VAA30500@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.89 -> 1.90 --- Log message: remove the mbbi2mbbMap_, which was just keeping track of mbb order anyway. Heavily refactor handleVirtualRegisterDef, adding comments and making it more efficient. It is also much easier to follow and convince ones self that it is correct :) Add -debug output to the joine, showing the result of joining the intervals. --- Diffs of the changes: (+72 -53) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.89 llvm/lib/CodeGen/LiveIntervals.cpp:1.90 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.89 Sat Jul 17 16:51:25 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Sun Jul 18 21:15:56 2004 @@ -60,6 +60,7 @@ EnableJoining("join-liveintervals", cl::desc("Join compatible live intervals"), cl::init(true)); + cl::opt EnableVirtVirtJoining("join-liveintervals-virtvirtjoining", cl::desc("Join live intervals for virtreg pairs (buggy)"), @@ -79,7 +80,6 @@ void LiveIntervals::releaseMemory() { - mbbi2mbbMap_.clear(); mi2iMap_.clear(); i2miMap_.clear(); r2iMap_.clear(); @@ -99,20 +99,14 @@ // number MachineInstrs unsigned miIndex = 0; for (MachineFunction::iterator mbb = mf_->begin(), mbbEnd = mf_->end(); - mbb != mbbEnd; ++mbb) { - unsigned mbbIdx = mbb->getNumber(); - bool inserted = mbbi2mbbMap_.insert(std::make_pair(mbbIdx, - mbb)).second; - assert(inserted && "multiple index -> MachineBasicBlock"); - + mbb != mbbEnd; ++mbb) for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); mi != miEnd; ++mi) { - inserted = mi2iMap_.insert(std::make_pair(mi, miIndex)).second; + bool inserted = mi2iMap_.insert(std::make_pair(mi, miIndex)).second; assert(inserted && "multiple MachineInstr -> index mappings"); i2miMap_.push_back(mi); miIndex += InstrSlots::NUM; } - } computeIntervals(); @@ -120,6 +114,7 @@ // join intervals if requested if (EnableJoining) joinIntervals(); + //DEBUG(mf_->viewCFG()); numIntervalsAfter += intervals_.size(); @@ -290,50 +285,74 @@ DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg)); LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg); - // Iterate over all of the blocks that the variable is completely - // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the - // live interval. Obviously we only need to do this once. + // Virtual registers may be defined multiple times (due to phi + // elimination). Much of what we do only has to be done once for the vreg. + // We use an empty interval to detect the first time we see a vreg. if (interval.empty()) { - for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { - if (vi.AliveBlocks[i]) { - MachineBasicBlock* mbb = mf_->getBlockNumbered(i); - if (!mbb->empty()) { - interval.addRange( - getInstructionIndex(&mbb->front()), - getInstructionIndex(&mbb->back()) + InstrSlots::NUM); - } - } - } - } - unsigned baseIndex = getInstructionIndex(mi); + // Get the Idx of the defining instructions. + unsigned defIndex = getDefIndex(getInstructionIndex(mi)); - bool killedInDefiningBasicBlock = false; - for (int i = 0, e = vi.Kills.size(); i != e; ++i) { - MachineBasicBlock* killerBlock = vi.Kills[i].first; - MachineInstr* killerInstr = vi.Kills[i].second; - unsigned start = (mbb == killerBlock ? - getDefIndex(baseIndex) : - getInstructionIndex(&killerBlock->front())); - unsigned end = (killerInstr == mi ? - // dead - start + 1 : - // killed - getUseIndex(getInstructionIndex(killerInstr))+1); - // we do not want to add invalid ranges. these can happen when - // a variable has its latest use and is redefined later on in - // the same basic block (common with variables introduced by - // PHI elimination) - if (start < end) { - killedInDefiningBasicBlock |= mbb == killerBlock; - interval.addRange(start, end); - } + // Loop over all of the blocks that the vreg is defined in. There are + // two cases we have to handle here. The most common case is a vreg + // whose lifetime is contained within a basic block. In this case there + // will be a single kill, in MBB, which comes after the definition. + if (vi.Kills.size() == 1 && vi.Kills[0].first == mbb) { + // FIXME: what about dead vars? + unsigned killIdx; + if (vi.Kills[0].second != mi) + killIdx = getUseIndex(getInstructionIndex(vi.Kills[0].second))+1; + else + killIdx = defIndex+1; + + // If the kill happens after the definition, we have an intra-block + // live range. + if (killIdx > defIndex) { + assert(vi.AliveBlocks.empty() && + "Shouldn't be alive across any blocks!"); + interval.addRange(defIndex, killIdx); + return; + } + } + + // The other case we handle is when a virtual register lives to the end + // of the defining block, potentially live across some blocks, then is + // live into some number of blocks, but gets killed. Start by adding a + // range that goes from this definition to the end of the defining block. + interval.addRange(defIndex, + getInstructionIndex(&mbb->back()) + InstrSlots::NUM); + + // Iterate over all of the blocks that the variable is completely + // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the + // live interval. + for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { + if (vi.AliveBlocks[i]) { + MachineBasicBlock* mbb = mf_->getBlockNumbered(i); + if (!mbb->empty()) { + interval.addRange( + getInstructionIndex(&mbb->front()), + getInstructionIndex(&mbb->back()) + InstrSlots::NUM); + } + } + } + + // Finally, this virtual register is live from the start of any killing + // block to the 'use' slot of the killing instruction. + for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) { + std::pair &Kill = vi.Kills[i]; + interval.addRange(getInstructionIndex(Kill.first->begin()), + getUseIndex(getInstructionIndex(Kill.second))+1); + } + + } else { + // If this is the second time we see a virtual register definition, it + // must be due to phi elimination. In this case, the defined value will + // be live until the end of the basic block it is defined in. + unsigned defIndex = getDefIndex(getInstructionIndex(mi)); + interval.addRange(defIndex, + getInstructionIndex(&mbb->back()) + InstrSlots::NUM); } - if (!killedInDefiningBasicBlock) { - unsigned end = getInstructionIndex(&mbb->back()) + InstrSlots::NUM; - interval.addRange(getDefIndex(baseIndex), end); - } DEBUG(std::cerr << '\n'); } @@ -426,10 +445,9 @@ DEBUG(std::cerr << "********** Function: " << ((Value*)mf_->getFunction())->getName() << '\n'); - for (MbbIndex2MbbMap::iterator - it = mbbi2mbbMap_.begin(), itEnd = mbbi2mbbMap_.end(); - it != itEnd; ++it) { - MachineBasicBlock* mbb = it->second; + for (MachineFunction::iterator I = mf_->begin(), E = mf_->end(); + I != E; ++I) { + MachineBasicBlock* mbb = I; DEBUG(std::cerr << ((Value*)mbb->getBasicBlock())->getName() << ":\n"); for (MachineBasicBlock::iterator mi = mbb->begin(), miEnd = mbb->end(); @@ -688,7 +706,7 @@ void LiveInterval::join(const LiveInterval& other) { - DEBUG(std::cerr << "\t\tjoining " << *this << " with " << other << '\n'); + DEBUG(std::cerr << "\t\tjoining " << *this << " with " << other); Ranges::iterator cur = ranges.begin(); for (Ranges::const_iterator i = other.ranges.begin(), @@ -699,6 +717,7 @@ } weight += other.weight; ++numJoins; + DEBUG(std::cerr << ". Result = " << *this << "\n"); } LiveInterval::Ranges::iterator LiveInterval:: From lattner at cs.uiuc.edu Sun Jul 18 21:16:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 21:16:09 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.h Message-ID: <200407190216.VAA30505@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.h updated: 1.27 -> 1.28 --- Log message: fill comment to 80 cols remove map that is not needed --- Diffs of the changes: (+7 -11) Index: llvm/lib/CodeGen/LiveIntervals.h diff -u llvm/lib/CodeGen/LiveIntervals.h:1.27 llvm/lib/CodeGen/LiveIntervals.h:1.28 --- llvm/lib/CodeGen/LiveIntervals.h:1.27 Mon Jun 21 08:10:56 2004 +++ llvm/lib/CodeGen/LiveIntervals.h Sun Jul 18 21:13:59 2004 @@ -7,14 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file implements the LiveInterval analysis pass. Given some -// numbering of each the machine instructions (in this implemention -// depth-first order) an interval [i, j) is said to be a live interval -// for register v if there is no instruction with number j' > j such -// that v is live at j' abd there is no instruction with number i' < i -// such that v is live at i'. In this implementation intervals can -// have holes, i.e. an interval might look like [1,20), [50,65), -// [1000,1001) +// This file implements the LiveInterval analysis pass. Given some numbering of +// each the machine instructions (in this implemention depth-first order) an +// interval [i, j) is said to be a live interval for register v if there is no +// instruction with number j' > j such that v is live at j' abd there is no +// instruction with number i' < i such that v is live at i'. In this +// implementation intervals can have holes, i.e. an interval might look like +// [1,20), [50,65), [1000,1001). // //===----------------------------------------------------------------------===// @@ -94,9 +93,6 @@ MachineBasicBlock::iterator currentInstr_; LiveVariables* lv_; - typedef std::map MbbIndex2MbbMap; - MbbIndex2MbbMap mbbi2mbbMap_; - typedef std::map Mi2IndexMap; Mi2IndexMap mi2iMap_; From lattner at cs.uiuc.edu Sun Jul 18 23:47:46 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun, 18 Jul 2004 23:47:46 -0500 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <200407190447.XAA02205@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: RegAllocLinearScan.cpp updated: 1.77 -> 1.78 --- Log message: Add some asserts that the list of intervals returned by addIntervalsForSpills is sorted. This is not the case currently, which is causing no end of problems. --- Diffs of the changes: (+30 -6) Index: llvm/lib/CodeGen/RegAllocLinearScan.cpp diff -u llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.77 llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.78 --- llvm/lib/CodeGen/RegAllocLinearScan.cpp:1.77 Sun Jul 4 12:23:35 2004 +++ llvm/lib/CodeGen/RegAllocLinearScan.cpp Sun Jul 18 23:47:36 2004 @@ -386,18 +386,42 @@ int slot = vrm_->assignVirt2StackSlot(cur->reg); std::vector added = li_->addIntervalsForSpills(*cur, *vrm_, slot); - - // merge added with unhandled + if (added.empty()) + return; // Early exit if all spills were folded. +#ifndef NDEBUG + int OldStart = -1; +#endif + + // Merge added with unhandled. Note that we know that + // addIntervalsForSpills returns intervals sorted by their starting + // point. std::vector::iterator addedIt = added.begin(); std::vector::iterator addedItEnd = added.end(); - for (IntervalPtrs::iterator i = unhandled_.begin(), e = unhandled_.end(); + for (IntervalPtrs::iterator i = unhandled_.begin(), e =unhandled_.end(); i != e && addedIt != addedItEnd; ++i) { - if ((*i)->start() > (*addedIt)->start()) + while ((*i)->start() > (*addedIt)->start() && + addedIt != addedItEnd) { +#ifndef NDEBUG + // This code only works if addIntervalsForSpills retursn a + // sorted interval list. Assert this is the case now. + assert(OldStart <= (int)(*addedIt)->start() && + "addIntervalsForSpills didn't return sorted interval list!"); + OldStart = (*addedIt)->start(); +#endif i = unhandled_.insert(i, *(addedIt++)); + } } - while (addedIt != addedItEnd) - unhandled_.push_back(*(addedIt++)); + while (addedIt != addedItEnd) { +#ifndef NDEBUG + // This code only works if addIntervalsForSpills retursn a + // sorted interval list. Assert this is the case now. + assert(OldStart <= (int)(*addedIt)->start() && + "addIntervalsForSpills didn't return sorted interval list!"); + OldStart = (*addedIt)->start(); +#endif + unhandled_.push_back(*(addedIt++)); + } return; }