From isanbard at gmail.com Mon Mar 21 03:31:53 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 21 Mar 2011 08:31:53 -0000 Subject: [llvm-commits] [llvm] r127988 - in /llvm/trunk/utils/TableGen: AsmWriterEmitter.cpp AsmWriterEmitter.h Message-ID: <20110321083153.BA6F12A6C12C@llvm.org> Author: void Date: Mon Mar 21 03:31:53 2011 New Revision: 127988 URL: http://llvm.org/viewvc/llvm-project?rev=127988&view=rev Log: * Add classes that support the "feature" information. * Move the code that emits the reg in reg class matching into its own function. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp llvm/trunk/utils/TableGen/AsmWriterEmitter.h Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=127988&r1=127987&r2=127988&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 03:31:53 2011 @@ -542,12 +542,116 @@ << "}\n\n#endif\n"; } -void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { - CodeGenTarget Target(Records); - Record *AsmWriter = Target.getAsmWriter(); +namespace { - O << "\n#ifdef PRINT_ALIAS_INSTR\n"; - O << "#undef PRINT_ALIAS_INSTR\n\n"; +/// SubtargetFeatureInfo - Helper class for storing information on a subtarget +/// feature which participates in instruction matching. +struct SubtargetFeatureInfo { + /// \brief The predicate record for this feature. + const Record *TheDef; + + /// \brief An unique index assigned to represent this feature. + unsigned Index; + + SubtargetFeatureInfo(const Record *D, unsigned Idx) : TheDef(D), Index(Idx) {} + + /// \brief The name of the enumerated constant identifying this feature. + std::string getEnumName() const { + return "Feature_" + TheDef->getName(); + } +}; + +struct AsmWriterInfo { + /// Map of Predicate records to their subtarget information. + std::map SubtargetFeatures; + + /// getSubtargetFeature - Lookup or create the subtarget feature info for the + /// given operand. + SubtargetFeatureInfo *getSubtargetFeature(const Record *Def) const { + assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!"); + std::map::const_iterator I = + SubtargetFeatures.find(Def); + return I == SubtargetFeatures.end() ? 0 : I->second; + } + + void addReqFeatures(const std::vector &Features) { + for (std::vector::const_iterator + I = Features.begin(), E = Features.end(); I != E; ++I) { + const Record *Pred = *I; + + // Ignore predicates that are not intended for the assembler. + if (!Pred->getValueAsBit("AssemblerMatcherPredicate")) + continue; + + if (Pred->getName().empty()) + throw TGError(Pred->getLoc(), "Predicate has no name!"); + + // Don't add the predicate again. + if (getSubtargetFeature(Pred)) + continue; + + unsigned FeatureNo = SubtargetFeatures.size(); + SubtargetFeatures[Pred] = new SubtargetFeatureInfo(Pred, FeatureNo); + assert(FeatureNo < 32 && "Too many subtarget features!"); + } + } + + const SubtargetFeatureInfo *getFeatureInfo(const Record *R) { + return SubtargetFeatures[R]; + } +}; + +} // end anonymous namespace + +/// EmitSubtargetFeatureFlagEnumeration - Emit the subtarget feature flag +/// definitions. +static void EmitSubtargetFeatureFlagEnumeration(AsmWriterInfo &Info, + raw_ostream &O) { + O << "namespace {\n\n"; + O << "// Flags for subtarget features that participate in " + << "alias instruction matching.\n"; + O << "enum SubtargetFeatureFlag {\n"; + + for (std::map::const_iterator + I = Info.SubtargetFeatures.begin(), + E = Info.SubtargetFeatures.end(); I != E; ++I) { + SubtargetFeatureInfo &SFI = *I->second; + O << " " << SFI.getEnumName() << " = (1 << " << SFI.Index << "),\n"; + } + + O << " Feature_None = 0\n"; + O << "};\n\n"; + O << "} // end anonymous namespace\n"; +} + +/// EmitComputeAvailableFeatures - Emit the function to compute the list of +/// available features given a subtarget. +static void EmitComputeAvailableFeatures(AsmWriterInfo &Info, + Record *AsmWriter, + CodeGenTarget &Target, + raw_ostream &O) { + std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName"); + + O << "unsigned " << Target.getName() << ClassName << "::\n" + << "ComputeAvailableFeatures(const " << Target.getName() + << "Subtarget *Subtarget) const {\n"; + O << " unsigned Features = 0;\n"; + + for (std::map::const_iterator + I = Info.SubtargetFeatures.begin(), + E = Info.SubtargetFeatures.end(); I != E; ++I) { + SubtargetFeatureInfo &SFI = *I->second; + O << " if (" << SFI.TheDef->getValueAsString("CondString") + << ")\n"; + O << " Features |= " << SFI.getEnumName() << ";\n"; + } + + O << " return Features;\n"; + O << "}\n\n"; +} + +void AsmWriterEmitter::EmitRegIsInRegClass(raw_ostream &O) { + CodeGenTarget Target(Records); // Enumerate the register classes. const std::vector &RegisterClasses = @@ -606,6 +710,16 @@ O << " }\n\n"; O << " return false;\n"; O << "}\n\n"; +} + +void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { + CodeGenTarget Target(Records); + Record *AsmWriter = Target.getAsmWriter(); + + O << "\n#ifdef PRINT_ALIAS_INSTR\n"; + O << "#undef PRINT_ALIAS_INSTR\n\n"; + + EmitRegIsInRegClass(O); // Emit the method that prints the alias instruction. std::string ClassName = AsmWriter->getValueAsString("AsmWriterClassName"); Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.h?rev=127988&r1=127987&r2=127988&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.h (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.h Mon Mar 21 03:31:53 2011 @@ -38,6 +38,7 @@ void EmitPrintInstruction(raw_ostream &o); void EmitGetRegisterName(raw_ostream &o); void EmitGetInstructionName(raw_ostream &o); + void EmitRegIsInRegClass(raw_ostream &O); void EmitPrintAliasInstruction(raw_ostream &O); AsmWriterInst *getAsmWriterInstByID(unsigned ID) const { From baldrick at free.fr Mon Mar 21 03:32:19 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 08:32:19 -0000 Subject: [llvm-commits] [dragonegg] r127989 - /dragonegg/trunk/Constants.cpp Message-ID: <20110321083220.079CB2A6C12C@llvm.org> Author: baldrick Date: Mon Mar 21 03:32:19 2011 New Revision: 127989 URL: http://llvm.org/viewvc/llvm-project?rev=127989&view=rev Log: Disable these checks for the moment. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127989&r1=127988&r2=127989&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Mon Mar 21 03:32:19 2011 @@ -1341,12 +1341,15 @@ break; } - assert((!ConvertType(TREE_TYPE(exp))->isSized() || - getTargetData().getTypeAllocSizeInBits(ConvertType(TREE_TYPE(exp))) <= - getTargetData().getTypeAllocSizeInBits(Init->getType())) && - "Constant too small for type!"); - assert(getTargetData().getABITypeAlignment(Init->getType()) * 8 <= - TYPE_ALIGN(TREE_TYPE(exp)) && "Constant over aligned!"); +// FIXME: The call to ConvertType blows up on several objective C testcases, +// also on vtable-layout.cpp. +// assert((!ConvertType(TREE_TYPE(exp))->isSized() || +// getTargetData().getTypeAllocSizeInBits(ConvertType(TREE_TYPE(exp))) <= +// getTargetData().getTypeAllocSizeInBits(Init->getType())) && +// "Constant too small for type!"); +// FIXME: This check fails when building libdecnumber (self-host build). +// assert(getTargetData().getABITypeAlignment(Init->getType()) * 8 <= +// TYPE_ALIGN(TREE_TYPE(exp)) && "Constant over aligned!"); return Init; } From isanbard at gmail.com Mon Mar 21 03:40:31 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 21 Mar 2011 08:40:31 -0000 Subject: [llvm-commits] [llvm] r127990 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <20110321084032.0C1422A6C12C@llvm.org> Author: void Date: Mon Mar 21 03:40:31 2011 New Revision: 127990 URL: http://llvm.org/viewvc/llvm-project?rev=127990&view=rev Log: Add the IAPrinter class. This is a helper class that will make it easier to say which InstAliases can be printed and which cannot (because of ambiguity). Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=127990&r1=127989&r2=127990&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 03:40:31 2011 @@ -601,6 +601,103 @@ } }; +// IAPrinter - Holds information about an InstAlias. Two InstAliases match if +// they both have the same conditionals. In which case, we cannot print out the +// alias for that pattern. +class IAPrinter { + AsmWriterInfo &AWI; + std::vector Conds; + std::map OpMap; + std::string Result; + std::string AsmString; + std::vector ReqFeatures; +public: + IAPrinter(AsmWriterInfo &Info, std::string R, std::string AS) + : AWI(Info), Result(R), AsmString(AS) {} + + void addCond(const std::string &C) { Conds.push_back(C); } + void addReqFeatures(const std::vector &Features) { + AWI.addReqFeatures(Features); + ReqFeatures = Features; + } + + void addOperand(StringRef Op, unsigned Idx) { OpMap[Op] = Idx; } + unsigned getOpIndex(StringRef Op) { return OpMap[Op]; } + bool isOpMapped(StringRef Op) { return OpMap.find(Op) != OpMap.end(); } + + void print(raw_ostream &O, bool IncIndent) { + unsigned Indent = 8 + (IncIndent ? 7 : 0); + + for (std::vector::iterator + I = Conds.begin(), E = Conds.end(); I != E; ++I) { + if (I != Conds.begin()) { + O << " &&\n"; + O.indent(Indent); + } else { + O << "if ("; + } + O << *I; + } + + if (Conds.begin() != Conds.end()) + O << " &&\n"; + else + O << "if ("; + + if (!ReqFeatures.empty()) { + std::string Req; + raw_string_ostream ReqO(Req); + + for (std::vector::iterator + I = ReqFeatures.begin(), E = ReqFeatures.end(); I != E; ++I) { + if (I != ReqFeatures.begin()) ReqO << " | "; + ReqO << AWI.getFeatureInfo(*I)->getEnumName(); + } + + if (Conds.begin() != Conds.end()) O.indent(Indent); + O << "(AvailableFeatures & (" << ReqO.str() << ")) == (" + << ReqO.str() << ')'; + } + + O << ") {\n"; + O.indent(6) << "// " << Result << "\n"; + O.indent(6) << "AsmString = \"" << AsmString << "\";\n"; + + for (std::map::iterator + I = OpMap.begin(), E = OpMap.end(); I != E; ++I) + O.indent(6) << "OpMap[\"" << I->first << "\"] = " + << I->second << ";\n"; + + O.indent(4) << '}'; + } + + bool operator==(const IAPrinter &RHS) { + if (Conds.size() != RHS.Conds.size()) + return false; + + unsigned Idx = 0; + for (std::vector::iterator + I = Conds.begin(), E = Conds.end(); I != E; ++I) + if (*I != RHS.Conds[Idx++]) + return false; + + return true; + } + + bool operator()(const IAPrinter &RHS) { + if (Conds.size() < RHS.Conds.size()) + return true; + + unsigned Idx = 0; + for (std::vector::iterator + I = Conds.begin(), E = Conds.end(); I != E; ++I) + if (*I != RHS.Conds[Idx++]) + return *I < RHS.Conds[Idx++]; + + return false; + } +}; + } // end anonymous namespace /// EmitSubtargetFeatureFlagEnumeration - Emit the subtarget feature flag From baldrick at free.fr Mon Mar 21 03:45:42 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 09:45:42 +0100 Subject: [llvm-commits] [llvm] r127985 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <20110321024228.28FDC2A6C12C@llvm.org> References: <20110321024228.28FDC2A6C12C@llvm.org> Message-ID: <4D871036.8030500@free.fr> Hi Anders, > @@ -2742,6 +2742,13 @@ > if (!CalledFn) > return false; > > + if (unsigned IntrinsicID = CalledFn->getIntrinsicID()) { > + // Ignore debug intrinsics. > + if (IntrinsicID == llvm::Intrinsic::dbg_declare || > + IntrinsicID == llvm::Intrinsic::dbg_value) > + continue; > + } > + if (isa(CalledFn)) continue; would be neater. See IntrinsicInst.h Ciao, Duncan. From fvbommel at gmail.com Mon Mar 21 03:55:31 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Mon, 21 Mar 2011 09:55:31 +0100 Subject: [llvm-commits] [llvm] r127985 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp In-Reply-To: <4D871036.8030500@free.fr> References: <20110321024228.28FDC2A6C12C@llvm.org> <4D871036.8030500@free.fr> Message-ID: On Mon, Mar 21, 2011 at 9:45 AM, Duncan Sands wrote: > Hi Anders, > >> @@ -2742,6 +2742,13 @@ >> ? ? ? ? if (!CalledFn) >> ? ? ? ? ? return false; >> >> + ? ? ?if (unsigned IntrinsicID = CalledFn->getIntrinsicID()) { >> + ? ? ? ?// Ignore debug intrinsics. >> + ? ? ? ?if (IntrinsicID == llvm::Intrinsic::dbg_declare || >> + ? ? ? ? ? ?IntrinsicID == llvm::Intrinsic::dbg_value) >> + ? ? ? ? ?continue; >> + ? ? ?} >> + > > if (isa(CalledFn)) > ? continue; > > would be neater. ?See IntrinsicInst.h Actually, that'd be isa(CI), because a DbgInfoIntrinsic is a call to an intrinsic function instead of the function itself. From isanbard at gmail.com Mon Mar 21 03:59:17 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 21 Mar 2011 08:59:17 -0000 Subject: [llvm-commits] [llvm] r127991 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <20110321085918.0C5DC2A6C12C@llvm.org> Author: void Date: Mon Mar 21 03:59:17 2011 New Revision: 127991 URL: http://llvm.org/viewvc/llvm-project?rev=127991&view=rev Log: A WIP commit of the InstAlias printing cleanup. This code will soon replace the code below it. Even though it looks very similar, it will match more precisely and geneate better functions in the long run. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=127991&r1=127990&r2=127991&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 03:59:17 2011 @@ -625,26 +625,28 @@ unsigned getOpIndex(StringRef Op) { return OpMap[Op]; } bool isOpMapped(StringRef Op) { return OpMap.find(Op) != OpMap.end(); } - void print(raw_ostream &O, bool IncIndent) { - unsigned Indent = 8 + (IncIndent ? 7 : 0); + void print(raw_ostream &O) { + unsigned Indent = 8; + + if (!Conds.empty()) + O << "if ("; for (std::vector::iterator I = Conds.begin(), E = Conds.end(); I != E; ++I) { if (I != Conds.begin()) { O << " &&\n"; O.indent(Indent); - } else { - O << "if ("; } + O << *I; } - if (Conds.begin() != Conds.end()) - O << " &&\n"; - else - O << "if ("; - if (!ReqFeatures.empty()) { + if (Conds.begin() != Conds.end()) + O << " &&\n"; + else + O << "if ("; + std::string Req; raw_string_ostream ReqO(Req); @@ -659,16 +661,23 @@ << ReqO.str() << ')'; } - O << ") {\n"; - O.indent(6) << "// " << Result << "\n"; - O.indent(6) << "AsmString = \"" << AsmString << "\";\n"; + if (!Conds.empty() || !ReqFeatures.empty()) { + O << ") {\n"; + Indent = 6; + } else { + Indent = 4; + } + + O.indent(Indent) << "// " << Result << "\n"; + O.indent(Indent) << "AsmString = \"" << AsmString << "\";\n"; for (std::map::iterator I = OpMap.begin(), E = OpMap.end(); I != E; ++I) - O.indent(6) << "OpMap[\"" << I->first << "\"] = " - << I->second << ";\n"; + O.indent(Indent) << "OpMap[\"" << I->first << "\"] = " + << I->second << ";\n"; - O.indent(4) << '}'; + if (!Conds.empty() || !ReqFeatures.empty()) + O.indent(4) << '}'; } bool operator==(const IAPrinter &RHS) { @@ -824,10 +833,6 @@ bool isMC = AsmWriter->getValueAsBit("isMCAsmWriter"); const char *MachineInstrClassName = isMC ? "MCInst" : "MachineInstr"; - O << "bool " << Target.getName() << ClassName - << "::printAliasInstr(const " << MachineInstrClassName - << " *MI, raw_ostream &OS) {\n"; - std::vector AllInstAliases = Records.getAllDerivedDefinitions("InstAlias"); @@ -842,6 +847,103 @@ AliasMap[getQualifiedName(Op->getDef())].push_back(Alias); } +#if 0 + // A map of which conditions need to be met for each instruction operand + // before it can be matched to the mnemonic. + std::map > IAPrinterMap; + AsmWriterInfo AWI; + + for (std::map >::iterator + I = AliasMap.begin(), E = AliasMap.end(); I != E; ++I) { + std::vector &Aliases = I->second; + + for (std::vector::iterator + II = Aliases.begin(), IE = Aliases.end(); II != IE; ++II) { + const CodeGenInstAlias *CGA = *II; + IAPrinter *IAP = new IAPrinter(AWI, CGA->Result->getAsString(), + CGA->AsmString); + + IAP->addReqFeatures(CGA->TheDef->getValueAsListOfDefs("Predicates")); + + unsigned LastOpNo = CGA->ResultInstOperandIndex.size(); + + std::string Cond; + Cond = std::string("MI->getNumOperands() == ") + llvm::utostr(LastOpNo); + IAP->addCond(Cond); + + std::map OpMap; + bool CantHandle = false; + + for (unsigned i = 0, e = LastOpNo; i != e; ++i) { + const CodeGenInstAlias::ResultOperand &RO = CGA->ResultOperands[i]; + + switch (RO.Kind) { + default: assert(0 && "unexpected InstAlias operand kind"); + case CodeGenInstAlias::ResultOperand::K_Record: { + const Record *Rec = RO.getRecord(); + StringRef ROName = RO.getName(); + + if (Rec->isSubClassOf("RegisterClass")) { + Cond = std::string("MI->getOperand(")+llvm::utostr(i)+").isReg()"; + IAP->addCond(Cond); + + if (!IAP->isOpMapped(ROName)) { + IAP->addOperand(ROName, i); + Cond = std::string("regIsInRegisterClass(RC_") + + CGA->ResultOperands[i].getRecord()->getName() + + ", MI->getOperand(" + llvm::utostr(i) + ").getReg())"; + IAP->addCond(Cond); + } else { + Cond = std::string("MI->getOperand(") + + llvm::utostr(i) + ").getReg() == MI->getOperand(" + + llvm::utostr(IAP->getOpIndex(ROName)) + ").getReg()"; + IAP->addCond(Cond); + } + } else { + assert(Rec->isSubClassOf("Operand") && "Unexpected operand!"); + // FIXME: We need to handle these situations. + delete IAP; + IAP = 0; + CantHandle = true; + break; + } + + break; + } + case CodeGenInstAlias::ResultOperand::K_Imm: + Cond = std::string("MI->getOperand(") + + llvm::utostr(i) + ").getImm() == " + + llvm::utostr(CGA->ResultOperands[i].getImm()); + IAP->addCond(Cond); + break; + case CodeGenInstAlias::ResultOperand::K_Reg: + Cond = std::string("MI->getOperand(") + + llvm::utostr(i) + ").getReg() == " + Target.getName() + + "::" + CGA->ResultOperands[i].getRegister()->getName(); + IAP->addCond(Cond); + break; + } + + if (!IAP) break; + } + + if (CantHandle) continue; + IAPrinterMap[I->first].push_back(IAP); + + O.indent(4) << "// " << I->first << '\n'; + O.indent(4); + IAP->print(O); + } + } + + EmitSubtargetFeatureFlagEnumeration(AWI, O); + EmitComputeAvailableFeatures(AWI, AsmWriter, Target, O); +#endif + + O << "bool " << Target.getName() << ClassName + << "::printAliasInstr(const " << MachineInstrClassName + << " *MI, raw_ostream &OS) {\n"; + if (AliasMap.empty() || !isMC) { // FIXME: Support MachineInstr InstAliases? O << " return true;\n"; From baldrick at free.fr Mon Mar 21 05:43:00 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 10:43:00 -0000 Subject: [llvm-commits] [dragonegg] r127992 - /dragonegg/trunk/Constants.cpp Message-ID: <20110321104300.36BEE2A6C12C@llvm.org> Author: baldrick Date: Mon Mar 21 05:43:00 2011 New Revision: 127992 URL: http://llvm.org/viewvc/llvm-project?rev=127992&view=rev Log: No need to bitcast the returned pointer: AddressOf already guarantees that it has this type. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127992&r1=127991&r2=127992&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Mon Mar 21 05:43:00 2011 @@ -585,6 +585,10 @@ return ConstantStruct::get(Context, Elts, 2, false); } +static Constant *ConvertADDR_EXPR(tree exp) { + return AddressOf(TREE_OPERAND(exp, 0)); +} + static Constant *ConvertNOP_EXPR(tree exp) { Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0)); const Type *Ty = ConvertType(TREE_TYPE(exp)); @@ -1336,8 +1340,7 @@ Init = ConvertPOINTER_PLUS_EXPR(exp); break; case ADDR_EXPR: - Init = TheFolder->CreateBitCast(AddressOf(TREE_OPERAND(exp, 0)), - ConvertType(TREE_TYPE(exp))); + Init = ConvertADDR_EXPR(exp); break; } From baldrick at free.fr Mon Mar 21 06:14:26 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 11:14:26 -0000 Subject: [llvm-commits] [dragonegg] r127993 - /dragonegg/trunk/Constants.cpp Message-ID: <20110321111426.19E662A6C12C@llvm.org> Author: baldrick Date: Mon Mar 21 06:14:25 2011 New Revision: 127993 URL: http://llvm.org/viewvc/llvm-project?rev=127993&view=rev Log: If there is no work to do then don't do any! Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127993&r1=127992&r2=127993&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Mon Mar 21 06:14:25 2011 @@ -322,6 +322,9 @@ /// the first bit stored being 'StartingBit') and then loading out a (constant) /// value of type 'Ty' from the stored to memory location. Constant *InterpretAsType(Constant *C, const Type* Ty, unsigned StartingBit) { + if (C->getType() == Ty) + return C; + switch (Ty->getTypeID()) { default: llvm_unreachable("Unsupported type!"); From andersca at mac.com Mon Mar 21 09:54:40 2011 From: andersca at mac.com (Anders Carlsson) Date: Mon, 21 Mar 2011 14:54:40 -0000 Subject: [llvm-commits] [llvm] r127997 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <20110321145440.9B7782A6C12C@llvm.org> Author: andersca Date: Mon Mar 21 09:54:40 2011 New Revision: 127997 URL: http://llvm.org/viewvc/llvm-project?rev=127997&view=rev Log: More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=127997&r1=127996&r2=127997&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Mar 21 09:54:40 2011 @@ -2737,18 +2737,15 @@ for (BasicBlock::const_iterator I = EntryBlock.begin(), E = EntryBlock.end(); I != E; ++I) { if (const CallInst *CI = dyn_cast(I)) { + // Ignore debug intrinsics. + if (isa(CI)) + continue; + const Function *CalledFn = CI->getCalledFunction(); if (!CalledFn) return false; - if (unsigned IntrinsicID = CalledFn->getIntrinsicID()) { - // Ignore debug intrinsics. - if (IntrinsicID == llvm::Intrinsic::dbg_declare || - IntrinsicID == llvm::Intrinsic::dbg_value) - continue; - } - // Don't treat recursive functions as empty. if (!CalledFunctions.insert(CalledFn)) return false; @@ -2783,18 +2780,15 @@ for (Function::use_iterator I = CXAAtExitFn->use_begin(), E = CXAAtExitFn->use_end(); I != E;) { - CallSite CS(*I++); - if (!CS) - continue; - // We're only interested in calls. Theoretically, we could handle invoke // instructions as well, but neither llvm-gcc nor clang generate invokes // to __cxa_atexit. - if (!CS.isCall()) + CallInst *CI = dyn_cast(*I++); + if (!CI) continue; Function *DtorFn = - dyn_cast(CS.getArgument(0)->stripPointerCasts()); + dyn_cast(CI->getArgOperand(0)->stripPointerCasts()); if (!DtorFn) continue; @@ -2803,8 +2797,8 @@ continue; // Just remove the call. - CS->replaceAllUsesWith(Constant::getNullValue(CS.getType())); - CS->eraseFromParent(); + CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); + CI->eraseFromParent(); ++NumCXXDtorsRemoved; From baldrick at free.fr Mon Mar 21 10:51:29 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 15:51:29 -0000 Subject: [llvm-commits] [dragonegg] r127999 - /dragonegg/trunk/Constants.cpp Message-ID: <20110321155129.43B552A6C12C@llvm.org> Author: baldrick Date: Mon Mar 21 10:51:29 2011 New Revision: 127999 URL: http://llvm.org/viewvc/llvm-project?rev=127999&view=rev Log: The failing testcases fail also if this check is disabled, so may as well turn it back on. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=127999&r1=127998&r2=127999&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Mon Mar 21 10:51:29 2011 @@ -1347,12 +1347,10 @@ break; } -// FIXME: The call to ConvertType blows up on several objective C testcases, -// also on vtable-layout.cpp. -// assert((!ConvertType(TREE_TYPE(exp))->isSized() || -// getTargetData().getTypeAllocSizeInBits(ConvertType(TREE_TYPE(exp))) <= -// getTargetData().getTypeAllocSizeInBits(Init->getType())) && -// "Constant too small for type!"); + assert((!ConvertType(TREE_TYPE(exp))->isSized() || + getTargetData().getTypeAllocSizeInBits(ConvertType(TREE_TYPE(exp))) <= + getTargetData().getTypeAllocSizeInBits(Init->getType())) && + "Constant too small for type!"); // FIXME: This check fails when building libdecnumber (self-host build). // assert(getTargetData().getABITypeAlignment(Init->getType()) * 8 <= // TYPE_ALIGN(TREE_TYPE(exp)) && "Constant over aligned!"); From baldrick at free.fr Mon Mar 21 10:56:04 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 21 Mar 2011 15:56:04 -0000 Subject: [llvm-commits] [dragonegg] r128000 - /dragonegg/trunk/Constants.cpp Message-ID: <20110321155604.5CF082A6C12C@llvm.org> Author: baldrick Date: Mon Mar 21 10:56:04 2011 New Revision: 128000 URL: http://llvm.org/viewvc/llvm-project?rev=128000&view=rev Log: GCC now has a convenient method for turning INTEGER_CST, REAL_CST and friends into the bunch of bytes they represent in memory on the target machine. Use this to simplify and unify the handling of such constants. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128000&r1=127999&r2=128000&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Mon Mar 21 10:56:04 2011 @@ -407,106 +407,18 @@ // ... ConvertInitializer ... //===----------------------------------------------------------------------===// -/// EncodeExpr - Write the given expression into Buffer as it would appear in -/// memory on the target (the buffer is resized to contain exactly the bytes -/// written). Return the number of bytes written; this can also be obtained -/// by querying the buffer's size. -/// The following kinds of expressions are currently supported: INTEGER_CST, -/// REAL_CST, COMPLEX_CST, VECTOR_CST, STRING_CST. -static unsigned EncodeExpr(tree exp, SmallVectorImpl &Buffer) { +/// ConvertCST - Return the given simple constant as an array of bytes. For the +/// moment only INTEGER_CST, REAL_CST, COMPLEX_CST and VECTOR_CST are supported. +static Constant *ConvertCST(tree exp) { const tree type = TREE_TYPE(exp); unsigned SizeInBytes = (TREE_INT_CST_LOW(TYPE_SIZE(type)) + 7) / 8; - Buffer.resize(SizeInBytes); + // Encode the constant in Buffer in target format. + std::vector Buffer(SizeInBytes); unsigned BytesWritten = native_encode_expr(exp, &Buffer[0], SizeInBytes); assert(BytesWritten == SizeInBytes && "Failed to fully encode expression!"); - return BytesWritten; -} - -static Constant *ConvertINTEGER_CST(tree exp) { - const Type *Ty = ConvertType(TREE_TYPE(exp)); - - // Handle i128 specially. - if (const IntegerType *IT = dyn_cast(Ty)) { - if (IT->getBitWidth() == 128) { - // GCC only supports i128 on 64-bit systems. - assert(HOST_BITS_PER_WIDE_INT == 64 && - "i128 only supported on 64-bit system"); - uint64_t Bits[] = { TREE_INT_CST_LOW(exp), TREE_INT_CST_HIGH(exp) }; - return ConstantInt::get(Context, APInt(128, 2, Bits)); - } - } - - // Build the value as a ulong constant, then constant fold it to the right - // type. This handles overflow and other things appropriately. - uint64_t IntValue = getINTEGER_CSTVal(exp); - ConstantInt *C = ConstantInt::get(Type::getInt64Ty(Context), IntValue); - // The destination type can be a pointer, integer or floating point - // so we need a generalized cast here - Instruction::CastOps opcode = CastInst::getCastOpcode(C, false, Ty, - !TYPE_UNSIGNED(TREE_TYPE(exp))); - return TheFolder->CreateCast(opcode, C, Ty); -} - -static Constant *ConvertREAL_CST(tree exp) { - // TODO: Test new implementation on a big-endian machine. - - // Encode the constant in Buffer in target format. - SmallVector Buffer; - EncodeExpr(exp, Buffer); - - // Discard any alignment padding, which we assume comes at the end. - unsigned Precision = TYPE_PRECISION(TREE_TYPE(exp)); - assert((Precision & 7) == 0 && "Unsupported real number precision!"); - Buffer.resize(Precision / 8); - - // We are going to view the buffer as an array of APInt words. Ensure that - // the buffer contains a whole number of words by extending it if necessary. - unsigned Words = (Precision + integerPartWidth - 1) / integerPartWidth; - // On a little-endian machine extend the buffer by adding bytes to the end. - Buffer.resize(Words * (integerPartWidth / 8)); - // On a big-endian machine extend the buffer by adding bytes to the beginning. - if (BYTES_BIG_ENDIAN) - std::copy_backward(Buffer.begin(), Buffer.begin() + Precision / 8, - Buffer.end()); - - // Ensure that the least significant word comes first: we are going to make an - // APInt, and the APInt constructor wants the least significant word first. - integerPart *Parts = (integerPart *)&Buffer[0]; - if (BYTES_BIG_ENDIAN) - std::reverse(Parts, Parts + Words); - - bool isPPC_FP128 = ConvertType(TREE_TYPE(exp))->isPPC_FP128Ty(); - if (isPPC_FP128) { - // This type is actually a pair of doubles in disguise. They turn up the - // wrong way round here, so flip them. - assert(FLOAT_WORDS_BIG_ENDIAN && "PPC not big endian!"); - assert(Words == 2 && Precision == 128 && "Strange size for PPC_FP128!"); - std::swap(Parts[0], Parts[1]); - } - - // Form an APInt from the buffer, an APFloat from the APInt, and the desired - // floating point constant from the APFloat, phew! - const APInt &I = APInt(Precision, Words, Parts); - return ConstantFP::get(Context, APFloat(I, !isPPC_FP128)); -} - -static Constant *ConvertVECTOR_CST(tree exp) { - if (!TREE_VECTOR_CST_ELTS(exp)) - return Constant::getNullValue(ConvertType(TREE_TYPE(exp))); - - std::vector Elts; - for (tree elt = TREE_VECTOR_CST_ELTS(exp); elt; elt = TREE_CHAIN(elt)) - Elts.push_back(ConvertInitializer(TREE_VALUE(elt))); - - // The vector should be zero filled if insufficient elements are provided. - if (Elts.size() < TYPE_VECTOR_SUBPARTS(TREE_TYPE(exp))) { - tree EltType = TREE_TYPE(TREE_TYPE(exp)); - Constant *Zero = Constant::getNullValue(ConvertType(EltType)); - while (Elts.size() < TYPE_VECTOR_SUBPARTS(TREE_TYPE(exp))) - Elts.push_back(Zero); - } - - return ConstantVector::get(Elts); + // Turn it into an LLVM byte array. + return ConstantArray::get(Context, StringRef((char *)&Buffer[0], SizeInBytes), + /*AddNull*/false); } static Constant *ConvertSTRING_CST(tree exp) { @@ -580,14 +492,6 @@ return ConstantArray::get(StrTy, Elts); } -static Constant *ConvertCOMPLEX_CST(tree exp) { - Constant *Elts[2] = { - ConvertInitializer(TREE_REALPART(exp)), - ConvertInitializer(TREE_IMAGPART(exp)) - }; - return ConstantStruct::get(Context, Elts, 2, false); -} - static Constant *ConvertADDR_EXPR(tree exp) { return AddressOf(TREE_OPERAND(exp, 0)); } @@ -1308,21 +1212,15 @@ debug_tree(exp); assert(0 && "Unknown constant to convert!"); abort(); + case COMPLEX_CST: case INTEGER_CST: - Init = ConvertINTEGER_CST(exp); - break; case REAL_CST: - Init = ConvertREAL_CST(exp); - break; case VECTOR_CST: - Init = ConvertVECTOR_CST(exp); + Init = InterpretAsType(ConvertCST(exp), ConvertType(TREE_TYPE(exp)), 0); break; case STRING_CST: Init = ConvertSTRING_CST(exp); break; - case COMPLEX_CST: - Init = ConvertCOMPLEX_CST(exp); - break; case NOP_EXPR: Init = ConvertNOP_EXPR(exp); break; From jay.foad at gmail.com Mon Mar 21 11:38:22 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 21 Mar 2011 16:38:22 -0000 Subject: [llvm-commits] [llvm] r128002 - /llvm/trunk/include/llvm/User.h Message-ID: <20110321163822.E812E2A6C12C@llvm.org> Author: foad Date: Mon Mar 21 11:38:22 2011 New Revision: 128002 URL: http://llvm.org/viewvc/llvm-project?rev=128002&view=rev Log: Fix typos in assert messages. Modified: llvm/trunk/include/llvm/User.h Modified: llvm/trunk/include/llvm/User.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/User.h?rev=128002&r1=128001&r2=128002&view=diff ============================================================================== --- llvm/trunk/include/llvm/User.h (original) +++ llvm/trunk/include/llvm/User.h Mon Mar 21 11:38:22 2011 @@ -95,11 +95,11 @@ OperandList[i] = Val; } const Use &getOperandUse(unsigned i) const { - assert(i < NumOperands && "getOperand() out of range!"); + assert(i < NumOperands && "getOperandUse() out of range!"); return OperandList[i]; } Use &getOperandUse(unsigned i) { - assert(i < NumOperands && "getOperand() out of range!"); + assert(i < NumOperands && "getOperandUse() out of range!"); return OperandList[i]; } From scanon at apple.com Mon Mar 21 12:35:26 2011 From: scanon at apple.com (Stephen Canon) Date: Mon, 21 Mar 2011 17:35:26 -0000 Subject: [llvm-commits] [compiler-rt] r128003 - /compiler-rt/trunk/lib/arm/divmodsi4.S Message-ID: <20110321173527.091682A6C12C@llvm.org> Author: scanon Date: Mon Mar 21 12:35:26 2011 New Revision: 128003 URL: http://llvm.org/viewvc/llvm-project?rev=128003&view=rev Log: slight re-arrangement to maybe pick up one cycle on dual-issue ARM cores Modified: compiler-rt/trunk/lib/arm/divmodsi4.S Modified: compiler-rt/trunk/lib/arm/divmodsi4.S URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/arm/divmodsi4.S?rev=128003&r1=128002&r2=128003&view=diff ============================================================================== --- compiler-rt/trunk/lib/arm/divmodsi4.S (original) +++ compiler-rt/trunk/lib/arm/divmodsi4.S Mon Mar 21 12:35:26 2011 @@ -40,8 +40,8 @@ // Apply the sign of quotient and modulus ldr r1, [r6] eor r0, r0, r4, asr #31 - sub r0, r0, r4, asr #31 eor r1, r1, r5, asr #31 + sub r0, r0, r4, asr #31 sub r1, r1, r5, asr #31 str r1, [r6] CLEAR_FRAME_AND_RETURN From echristo at apple.com Mon Mar 21 13:06:21 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 21 Mar 2011 18:06:21 -0000 Subject: [llvm-commits] [llvm] r128004 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <20110321180621.72D402A6C12C@llvm.org> Author: echristo Date: Mon Mar 21 13:06:21 2011 New Revision: 128004 URL: http://llvm.org/viewvc/llvm-project?rev=128004&view=rev Log: Grammar-o. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=128004&r1=128003&r2=128004&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Mon Mar 21 13:06:21 2011 @@ -544,7 +544,7 @@ // FIXME: Do not modify node height. It may interfere with // backtracking. Instead add a "ready cycle" to SUnit. Before scheduling the - // node it's ready cycle can aid heuristics, and after scheduling it can + // node its ready cycle can aid heuristics, and after scheduling it can // indicate the scheduled cycle. SU->setHeightToAtLeast(CurCycle); From echristo at apple.com Mon Mar 21 13:06:33 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 21 Mar 2011 18:06:33 -0000 Subject: [llvm-commits] [llvm] r128005 - /llvm/trunk/include/llvm/Target/TargetMachine.h Message-ID: <20110321180633.122D92A6C12C@llvm.org> Author: echristo Date: Mon Mar 21 13:06:32 2011 New Revision: 128005 URL: http://llvm.org/viewvc/llvm-project?rev=128005&view=rev Log: Fix unused param warning. Modified: llvm/trunk/include/llvm/Target/TargetMachine.h Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=128005&r1=128004&r2=128005&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Mon Mar 21 13:06:32 2011 @@ -268,7 +268,7 @@ /// virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&, - raw_ostream &OS, + raw_ostream &, CodeGenOpt::Level, bool = true) { return true; From kremenek at apple.com Mon Mar 21 13:37:59 2011 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 21 Mar 2011 18:37:59 -0000 Subject: [llvm-commits] [llvm] r128007 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Message-ID: <20110321183759.C6E442A6C12D@llvm.org> Author: kremenek Date: Mon Mar 21 13:37:59 2011 New Revision: 128007 URL: http://llvm.org/viewvc/llvm-project?rev=128007&view=rev Log: Allow a client to clear an IntrustiveRefCntPtr (deliberately leaking the referenced object). Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=128007&r1=128006&r2=128007&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original) +++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Mon Mar 21 13:37:59 2011 @@ -155,6 +155,10 @@ other.Obj = Obj; Obj = tmp; } + + void resetWithoutRelease() { + Obj = 0; + } private: void retain() { if (Obj) Obj->Retain(); } From kremenek at apple.com Mon Mar 21 13:38:03 2011 From: kremenek at apple.com (Ted Kremenek) Date: Mon, 21 Mar 2011 18:38:03 -0000 Subject: [llvm-commits] [llvm] r128008 - in /llvm/trunk: include/llvm/Support/CrashRecoveryContext.h lib/Support/CrashRecoveryContext.cpp Message-ID: <20110321183803.75B7C2A6C12E@llvm.org> Author: kremenek Date: Mon Mar 21 13:38:03 2011 New Revision: 128008 URL: http://llvm.org/viewvc/llvm-project?rev=128008&view=rev Log: Provide a means for CrashRecovery clients to determine if code is currently running while crash recovery cleanups are being processed. Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h llvm/trunk/lib/Support/CrashRecoveryContext.cpp Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=128008&r1=128007&r2=128008&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original) +++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Mon Mar 21 13:38:03 2011 @@ -63,6 +63,10 @@ /// thread which is in a protected context. static CrashRecoveryContext *GetCurrent(); + /// \brief Return true if the current thread is recovering from a + /// crash. + static bool isRecoveringFromCrash(); + /// \brief Execute the provide callback function (with the given arguments) in /// a protected context. /// Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=128008&r1=128007&r2=128008&view=diff ============================================================================== --- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original) +++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Mon Mar 21 13:38:03 2011 @@ -57,11 +57,15 @@ static sys::Mutex gCrashRecoveryContexMutex; static bool gCrashRecoveryEnabled = false; +static sys::ThreadLocal + tlIsRecoveringFromCrash; + CrashRecoveryContextCleanup::~CrashRecoveryContextCleanup() {} CrashRecoveryContext::~CrashRecoveryContext() { // Reclaim registered resources. CrashRecoveryContextCleanup *i = head; + tlIsRecoveringFromCrash.set(head); while (i) { CrashRecoveryContextCleanup *tmp = i; i = tmp->next; @@ -69,11 +73,16 @@ tmp->recoverResources(); delete tmp; } + tlIsRecoveringFromCrash.erase(); CrashRecoveryContextImpl *CRCI = (CrashRecoveryContextImpl *) Impl; delete CRCI; } +bool CrashRecoveryContext::isRecoveringFromCrash() { + return tlIsRecoveringFromCrash.get() != 0; +} + CrashRecoveryContext *CrashRecoveryContext::GetCurrent() { if (!gCrashRecoveryEnabled) return 0; From nlewycky at google.com Mon Mar 21 13:48:15 2011 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 21 Mar 2011 11:48:15 -0700 Subject: [llvm-commits] [llvm] r127988 - in /llvm/trunk/utils/TableGen: AsmWriterEmitter.cpp AsmWriterEmitter.h In-Reply-To: <20110321083153.BA6F12A6C12C@llvm.org> References: <20110321083153.BA6F12A6C12C@llvm.org> Message-ID: Hi Bill, This broke the build for us because we use -Wunused-function -Werror. llvm/utils/TableGen/AsmWriterEmitter.cpp:714: error: 'void EmitSubtargetFeatureFlagEnumeration(::AsmWriterInfo&, llvm::raw_ostream&)' defined but not used [-Wunused-function] llvm/utils/TableGen/AsmWriterEmitter.cpp:735: error: 'void EmitComputeAvailableFeatures(::AsmWriterInfo&, llvm::Record*, llvm::CodeGenTarget&, llvm::raw_ostream&)' defined but not used [-Wunused-function] Would you be okay with waiting until you have the callers written before submitting? Or at least breaking it up in a different sort of way? Nick On 21 March 2011 01:31, Bill Wendling wrote: > Author: void > Date: Mon Mar 21 03:31:53 2011 > New Revision: 127988 > > URL: http://llvm.org/viewvc/llvm-project?rev=127988&view=rev > Log: > * Add classes that support the "feature" information. > * Move the code that emits the reg in reg class matching into its own > function. > > Modified: > llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp > llvm/trunk/utils/TableGen/AsmWriterEmitter.h > > Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=127988&r1=127987&r2=127988&view=diff > > ============================================================================== > --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 03:31:53 2011 > @@ -542,12 +542,116 @@ > << "}\n\n#endif\n"; > } > > -void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { > - CodeGenTarget Target(Records); > - Record *AsmWriter = Target.getAsmWriter(); > +namespace { > > - O << "\n#ifdef PRINT_ALIAS_INSTR\n"; > - O << "#undef PRINT_ALIAS_INSTR\n\n"; > +/// SubtargetFeatureInfo - Helper class for storing information on a > subtarget > +/// feature which participates in instruction matching. > +struct SubtargetFeatureInfo { > + /// \brief The predicate record for this feature. > + const Record *TheDef; > + > + /// \brief An unique index assigned to represent this feature. > + unsigned Index; > + > + SubtargetFeatureInfo(const Record *D, unsigned Idx) : TheDef(D), > Index(Idx) {} > + > + /// \brief The name of the enumerated constant identifying this feature. > + std::string getEnumName() const { > + return "Feature_" + TheDef->getName(); > + } > +}; > + > +struct AsmWriterInfo { > + /// Map of Predicate records to their subtarget information. > + std::map SubtargetFeatures; > + > + /// getSubtargetFeature - Lookup or create the subtarget feature info > for the > + /// given operand. > + SubtargetFeatureInfo *getSubtargetFeature(const Record *Def) const { > + assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!"); > + std::map::const_iterator I = > + SubtargetFeatures.find(Def); > + return I == SubtargetFeatures.end() ? 0 : I->second; > + } > + > + void addReqFeatures(const std::vector &Features) { > + for (std::vector::const_iterator > + I = Features.begin(), E = Features.end(); I != E; ++I) { > + const Record *Pred = *I; > + > + // Ignore predicates that are not intended for the assembler. > + if (!Pred->getValueAsBit("AssemblerMatcherPredicate")) > + continue; > + > + if (Pred->getName().empty()) > + throw TGError(Pred->getLoc(), "Predicate has no name!"); > + > + // Don't add the predicate again. > + if (getSubtargetFeature(Pred)) > + continue; > + > + unsigned FeatureNo = SubtargetFeatures.size(); > + SubtargetFeatures[Pred] = new SubtargetFeatureInfo(Pred, FeatureNo); > + assert(FeatureNo < 32 && "Too many subtarget features!"); > + } > + } > + > + const SubtargetFeatureInfo *getFeatureInfo(const Record *R) { > + return SubtargetFeatures[R]; > + } > +}; > + > +} // end anonymous namespace > + > +/// EmitSubtargetFeatureFlagEnumeration - Emit the subtarget feature flag > +/// definitions. > +static void EmitSubtargetFeatureFlagEnumeration(AsmWriterInfo &Info, > + raw_ostream &O) { > + O << "namespace {\n\n"; > + O << "// Flags for subtarget features that participate in " > + << "alias instruction matching.\n"; > + O << "enum SubtargetFeatureFlag {\n"; > + > + for (std::map::const_iterator > + I = Info.SubtargetFeatures.begin(), > + E = Info.SubtargetFeatures.end(); I != E; ++I) { > + SubtargetFeatureInfo &SFI = *I->second; > + O << " " << SFI.getEnumName() << " = (1 << " << SFI.Index << "),\n"; > + } > + > + O << " Feature_None = 0\n"; > + O << "};\n\n"; > + O << "} // end anonymous namespace\n"; > +} > + > +/// EmitComputeAvailableFeatures - Emit the function to compute the list > of > +/// available features given a subtarget. > +static void EmitComputeAvailableFeatures(AsmWriterInfo &Info, > + Record *AsmWriter, > + CodeGenTarget &Target, > + raw_ostream &O) { > + std::string ClassName = > AsmWriter->getValueAsString("AsmWriterClassName"); > + > + O << "unsigned " << Target.getName() << ClassName << "::\n" > + << "ComputeAvailableFeatures(const " << Target.getName() > + << "Subtarget *Subtarget) const {\n"; > + O << " unsigned Features = 0;\n"; > + > + for (std::map::const_iterator > + I = Info.SubtargetFeatures.begin(), > + E = Info.SubtargetFeatures.end(); I != E; ++I) { > + SubtargetFeatureInfo &SFI = *I->second; > + O << " if (" << SFI.TheDef->getValueAsString("CondString") > + << ")\n"; > + O << " Features |= " << SFI.getEnumName() << ";\n"; > + } > + > + O << " return Features;\n"; > + O << "}\n\n"; > +} > + > +void AsmWriterEmitter::EmitRegIsInRegClass(raw_ostream &O) { > + CodeGenTarget Target(Records); > > // Enumerate the register classes. > const std::vector &RegisterClasses = > @@ -606,6 +710,16 @@ > O << " }\n\n"; > O << " return false;\n"; > O << "}\n\n"; > +} > + > +void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { > + CodeGenTarget Target(Records); > + Record *AsmWriter = Target.getAsmWriter(); > + > + O << "\n#ifdef PRINT_ALIAS_INSTR\n"; > + O << "#undef PRINT_ALIAS_INSTR\n\n"; > + > + EmitRegIsInRegClass(O); > > // Emit the method that prints the alias instruction. > std::string ClassName = > AsmWriter->getValueAsString("AsmWriterClassName"); > > Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.h > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.h?rev=127988&r1=127987&r2=127988&view=diff > > ============================================================================== > --- llvm/trunk/utils/TableGen/AsmWriterEmitter.h (original) > +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.h Mon Mar 21 03:31:53 2011 > @@ -38,6 +38,7 @@ > void EmitPrintInstruction(raw_ostream &o); > void EmitGetRegisterName(raw_ostream &o); > void EmitGetInstructionName(raw_ostream &o); > + void EmitRegIsInRegClass(raw_ostream &O); > void EmitPrintAliasInstruction(raw_ostream &O); > > AsmWriterInst *getAsmWriterInstByID(unsigned ID) const { > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110321/ebf677aa/attachment.html From dpatel at apple.com Mon Mar 21 15:31:51 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 20:31:51 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r128016 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Message-ID: <20110321203151.16D9C2A6C12C@llvm.org> Author: dpatel Date: Mon Mar 21 15:31:50 2011 New Revision: 128016 URL: http://llvm.org/viewvc/llvm-project?rev=128016&view=rev Log: Simplify. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=128016&r1=128015&r2=128016&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Mar 21 15:31:50 2011 @@ -1565,17 +1565,8 @@ (int) GET_MODE_SIZE(Mode); if (Bytes==8 && Class[0] == X86_64_POINTER_CLASS) return Type::getInt8PtrTy(Context); - switch (Bytes) { - case 8: return Type::getInt64Ty(Context); - case 7: return Type::getIntNTy(Context, 7*8); - case 6: return Type::getIntNTy(Context, 6*8); - case 5: return Type::getIntNTy(Context, 5*8); - case 4: return Type::getInt32Ty(Context); - case 3: return Type::getIntNTy(Context, 3*8); - case 2: return Type::getInt16Ty(Context); - case 1: return Type::getInt8Ty(Context); - default: assert (0 && "Unexpected type!"); - } + assert (Bytes <= 8 && "Unexpected type!"); + return Type::getIntNTy(Context, Bytes*8); } assert(0 && "Unexpected type!"); } From dpatel at apple.com Mon Mar 21 15:32:56 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 20:32:56 -0000 Subject: [llvm-commits] [llvm] r128017 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Message-ID: <20110321203256.D50302A6C12C@llvm.org> Author: dpatel Date: Mon Mar 21 15:32:56 2011 New Revision: 128017 URL: http://llvm.org/viewvc/llvm-project?rev=128017&view=rev Log: Enable this test only for Darwin. Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128017&r1=128016&r2=128017&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Mon Mar 21 15:32:56 2011 @@ -1,5 +1,5 @@ // RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s -// REQUIRES: disabled +// XTARGET: x86_64-apple-darwin // Radar 9156771 typedef struct RGBColor { unsigned short red; From kledzik at apple.com Mon Mar 21 15:49:30 2011 From: kledzik at apple.com (Nick Kledzik) Date: Mon, 21 Mar 2011 20:49:30 -0000 Subject: [llvm-commits] [compiler-rt] r128019 - /compiler-rt/tags/Apple/Libcompiler_rt-14/ Message-ID: <20110321204930.A56102A6C12C@llvm.org> Author: kledzik Date: Mon Mar 21 15:49:30 2011 New Revision: 128019 URL: http://llvm.org/viewvc/llvm-project?rev=128019&view=rev Log: Libcompiler_rt-14 Added: compiler-rt/tags/Apple/Libcompiler_rt-14/ - copied from r128018, compiler-rt/trunk/ From isanbard at gmail.com Mon Mar 21 16:08:27 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 21 Mar 2011 21:08:27 -0000 Subject: [llvm-commits] [llvm] r128020 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Message-ID: <20110321210827.A12562A6C12C@llvm.org> Author: void Date: Mon Mar 21 16:08:27 2011 New Revision: 128020 URL: http://llvm.org/viewvc/llvm-project?rev=128020&view=rev Log: Call static functions so that they aren't left unused. Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=128020&r1=128019&r2=128020&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 16:08:27 2011 @@ -847,7 +847,6 @@ AliasMap[getQualifiedName(Op->getDef())].push_back(Alias); } -#if 0 // A map of which conditions need to be met for each instruction operand // before it can be matched to the mnemonic. std::map > IAPrinterMap; @@ -930,15 +929,18 @@ if (CantHandle) continue; IAPrinterMap[I->first].push_back(IAP); +#if 0 O.indent(4) << "// " << I->first << '\n'; O.indent(4); IAP->print(O); +#endif } } + O << "#if 0\n"; EmitSubtargetFeatureFlagEnumeration(AWI, O); EmitComputeAvailableFeatures(AWI, AsmWriter, Target, O); -#endif + O << "#endif\n\n"; O << "bool " << Target.getName() << ClassName << "::printAliasInstr(const " << MachineInstrClassName From isanbard at gmail.com Mon Mar 21 16:13:11 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 21 Mar 2011 14:13:11 -0700 Subject: [llvm-commits] [llvm] r127988 - in /llvm/trunk/utils/TableGen: AsmWriterEmitter.cpp AsmWriterEmitter.h In-Reply-To: References: <20110321083153.BA6F12A6C12C@llvm.org> Message-ID: On Mar 21, 2011, at 11:48 AM, Nick Lewycky wrote: > Hi Bill, > > This broke the build for us because we use -Wunused-function -Werror. > > llvm/utils/TableGen/AsmWriterEmitter.cpp:714: error: 'void EmitSubtargetFeatureFlagEnumeration(::AsmWriterInfo&, llvm::raw_ostream&)' defined but not used [-Wunused-function] > > llvm/utils/TableGen/AsmWriterEmitter.cpp:735: error: 'void EmitComputeAvailableFeatures(::AsmWriterInfo&, llvm::Record*, llvm::CodeGenTarget&, llvm::raw_ostream&)' defined but not used [-Wunused-function] > > Would you be okay with waiting until you have the callers written before submitting? Or at least breaking it up in a different sort of way? > Hi Nick, You did what I was hoping you wouldn't do. :-) I fixed it with this r128020. I'm sorry about the breakage. -bw From eli.friedman at gmail.com Mon Mar 21 16:26:56 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 21 Mar 2011 14:26:56 -0700 Subject: [llvm-commits] [llvm] r126642 - /llvm/trunk/lib/Analysis/ValueTracking.cpp In-Reply-To: <20110228080221.653662A6C12C@llvm.org> References: <20110228080221.653662A6C12C@llvm.org> Message-ID: On Mon, Feb 28, 2011 at 12:02 AM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Feb 28 02:02:21 2011 > New Revision: 126642 > > URL: http://llvm.org/viewvc/llvm-project?rev=126642&view=rev > Log: > Teach value tracking to make use of flags in more situations. > > Modified: > ? ?llvm/trunk/lib/Analysis/ValueTracking.cpp > > Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=126642&r1=126641&r2=126642&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) > +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Feb 28 02:02:21 2011 > @@ -696,6 +696,15 @@ > ? ? return isPowerOfTwo(SI->getTrueValue(), TD, Depth) && > ? ? ? isPowerOfTwo(SI->getFalseValue(), TD, Depth); > > + ?// An exact divide or right shift can only shift off zero bits, so the result > + ?// is non-zero only if the first operand is non-zero. > + ?if (match(V, m_Shr(m_Value(), m_Value())) || > + ? ? ?match(V, m_IDiv(m_Value(), m_Value()))) { > + ? ?BinaryOperator *BO = cast(V); > + ? ?if (BO->isExact()) > + ? ? ?return isPowerOfTwo(BO->getOperand(0), TD, Depth); > + ?} > + > ? return false; > ?} Please see http://llvm.org/bugs/show_bug.cgi?id=9429; also, this analysis isn't safe for signed divide/ashr (consider the case where the LHS is INT_MIN). -Eli > @@ -732,6 +741,11 @@ > ? // shl X, Y != 0 if X is odd. ?Note that the value of the shift is undefined > ? // if the lowest bit is shifted off the end. > ? if (BitWidth && match(V, m_Shl(m_Value(X), m_Value(Y)))) { > + ? ?// shl nuw can't remove any non-zero bits. > + ? ?BinaryOperator *BO = cast(V); > + ? ?if (BO->hasNoUnsignedWrap()) > + ? ? ?return isKnownNonZero(X, TD, Depth); > + > ? ? APInt KnownZero(BitWidth, 0); > ? ? APInt KnownOne(BitWidth, 0); > ? ? ComputeMaskedBits(X, APInt(BitWidth, 1), KnownZero, KnownOne, TD, Depth); > @@ -741,11 +755,22 @@ > ? // shr X, Y != 0 if X is negative. ?Note that the value of the shift is not > ? // defined if the sign bit is shifted off the end. > ? else if (match(V, m_Shr(m_Value(X), m_Value(Y)))) { > + ? ?// shr exact can only shift out zero bits. > + ? ?BinaryOperator *BO = cast(V); > + ? ?if (BO->isExact()) > + ? ? ?return isKnownNonZero(X, TD, Depth); > + > ? ? bool XKnownNonNegative, XKnownNegative; > ? ? ComputeSignBit(X, XKnownNonNegative, XKnownNegative, TD, Depth); > ? ? if (XKnownNegative) > ? ? ? return true; > ? } > + ?// div exact can only produce a zero if the dividend is zero. > + ?else if (match(V, m_IDiv(m_Value(X), m_Value()))) { > + ? ?BinaryOperator *BO = cast(V); > + ? ?if (BO->isExact()) > + ? ? ?return isKnownNonZero(X, TD, Depth); > + ?} > ? // X + Y. > ? else if (match(V, m_Add(m_Value(X), m_Value(Y)))) { > ? ? bool XKnownNonNegative, XKnownNegative; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Mon Mar 21 16:37:52 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 21:37:52 -0000 Subject: [llvm-commits] [llvm] r128027 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Message-ID: <20110321213752.585042A6C12C@llvm.org> Author: dpatel Date: Mon Mar 21 16:37:52 2011 New Revision: 128027 URL: http://llvm.org/viewvc/llvm-project?rev=128027&view=rev Log: Force x86_64. Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128027&r1=128026&r2=128027&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Mon Mar 21 16:37:52 2011 @@ -1,4 +1,4 @@ -// RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s +// RUN: %llvmgcc %s -m64 -S -O0 -o - | FileCheck %s // XTARGET: x86_64-apple-darwin // Radar 9156771 typedef struct RGBColor { From bob.wilson at apple.com Mon Mar 21 16:42:07 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 21 Mar 2011 14:42:07 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r127940 - /llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp In-Reply-To: <20110319014019.706682A6C130@llvm.org> References: <20110319014019.706682A6C130@llvm.org> Message-ID: <7F3428E0-3C79-4712-BA7C-30024E6A2C3A@apple.com> The default implementation in getLLVMScalarTypeForStructReturn() appears to have the same issue. Aggregate sizes are rounded up to the nearest power of two. I think we should fix that as well but I can't find any targets that use it so we can test it. ARM, PowerPC and i386 all use "sret" for returning aggregates (at least the ones I tried). Does anyone know of a target that uses that default? On Mar 18, 2011, at 6:40 PM, Devang Patel wrote: > Author: dpatel > Date: Fri Mar 18 20:40:19 2011 > New Revision: 127940 > > URL: http://llvm.org/viewvc/llvm-project?rev=127940&view=rev > Log: > Trust gcc tree nodes for struct size. > This fixes radar 9156771. > > Modified: > llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp > > Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=127940&r1=127939&r2=127940&view=diff > ============================================================================== > --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) > +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Fri Mar 18 20:40:19 2011 > @@ -1539,7 +1539,7 @@ > return Type::getInt8Ty(Context); > else if (Size == 2) > return Type::getInt16Ty(Context); > - else if (Size <= 4) > + else if (Size == 4) > return Type::getInt32Ty(Context); > > // Check if Ty should be returned using multiple value return instruction. > @@ -1565,14 +1565,17 @@ > (int) GET_MODE_SIZE(Mode); > if (Bytes==8 && Class[0] == X86_64_POINTER_CLASS) > return Type::getInt8PtrTy(Context); > - if (Bytes>4) > - return Type::getInt64Ty(Context); > - else if (Bytes>2) > - return Type::getInt32Ty(Context); > - else if (Bytes>1) > - return Type::getInt16Ty(Context); > - else > - return Type::getInt8Ty(Context); > + switch (Bytes) { > + case 8: return Type::getInt64Ty(Context); > + case 7: return Type::getIntNTy(Context, 7*8); > + case 6: return Type::getIntNTy(Context, 6*8); > + case 5: return Type::getIntNTy(Context, 5*8); > + case 4: return Type::getInt32Ty(Context); > + case 3: return Type::getIntNTy(Context, 3*8); > + case 2: return Type::getInt16Ty(Context); > + case 1: return Type::getInt8Ty(Context); > + default: assert (0 && "Unexpected type!"); > + } > } > assert(0 && "Unexpected type!"); > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From nicholas at mxc.ca Mon Mar 21 16:40:32 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 21 Mar 2011 21:40:32 -0000 Subject: [llvm-commits] [llvm] r128028 - /llvm/trunk/lib/Analysis/ValueTracking.cpp Message-ID: <20110321214032.EEBFF2A6C12C@llvm.org> Author: nicholas Date: Mon Mar 21 16:40:32 2011 New Revision: 128028 URL: http://llvm.org/viewvc/llvm-project?rev=128028&view=rev Log: Fix INT_MIN gotcha pointed out by Eli Friedman. Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=128028&r1=128027&r2=128028&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ValueTracking.cpp (original) +++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Mar 21 16:40:32 2011 @@ -725,9 +725,10 @@ isPowerOfTwo(SI->getFalseValue(), TD, Depth); // An exact divide or right shift can only shift off zero bits, so the result - // is a power of two only if the first operand is a power of two. - if (match(V, m_Shr(m_Value(), m_Value())) || - match(V, m_IDiv(m_Value(), m_Value()))) { + // is a power of two only if the first operand is a power of two and not + // copying a sign bit (sdiv int_min, 2). + if (match(V, m_LShr(m_Value(), m_Value())) || + match(V, m_UDiv(m_Value(), m_Value()))) { BinaryOperator *BO = cast(V); if (BO->isExact()) return isPowerOfTwo(BO->getOperand(0), TD, Depth); From dpatel at apple.com Mon Mar 21 17:04:45 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 22:04:45 -0000 Subject: [llvm-commits] [llvm] r128030 - /llvm/trunk/lib/Transforms/Utils/Local.cpp Message-ID: <20110321220446.0896A2A6C12C@llvm.org> Author: dpatel Date: Mon Mar 21 17:04:45 2011 New Revision: 128030 URL: http://llvm.org/viewvc/llvm-project?rev=128030&view=rev Log: Simplify. Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=128030&r1=128029&r2=128030&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Mon Mar 21 17:04:45 2011 @@ -216,13 +216,12 @@ if (DbgDeclareInst *DDI = dyn_cast(I)) { if (DDI->getAddress()) return false; - else - return true; - } else if (DbgValueInst *DVI = dyn_cast(I)) { + return true; + } + if (DbgValueInst *DVI = dyn_cast(I)) { if (DVI->getValue()) return false; - else - return true; + return true; } if (!I->mayHaveSideEffects()) return true; From dpatel at apple.com Mon Mar 21 17:09:05 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 15:09:05 -0700 Subject: [llvm-commits] [llvm] r127922 - /llvm/trunk/lib/Transforms/Utils/Local.cpp In-Reply-To: References: <20110318232802.31BA52A6C12C@llvm.org> Message-ID: <50665B53-54C6-46D6-A584-14BD78AFEB9D@apple.com> On Mar 19, 2011, at 12:31 AM, Frits van Bommel wrote: > On Sat, Mar 19, 2011 at 12:28 AM, Devang Patel wrote: >> - // We don't want debug info removed by anything this general. >> + // We don't want debug info removed by anything this general, unless >> + // debug info is empty. >> + if (DbgDeclareInst *DDI = dyn_cast(I)) { >> + if (DDI->getAddress()) >> + return false; >> + else >> + return true; >> + } else if (DbgValueInst *DVI = dyn_cast(I)) { >> + if (DVI->getValue()) >> + return false; >> + else >> + return true; >> + } > > None of those three 'else's are needed, their 'then' cases all end in 'return'. Done! - Devang From echristo at apple.com Mon Mar 21 17:16:31 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 21 Mar 2011 15:16:31 -0700 Subject: [llvm-commits] [llvm] r127988 - in /llvm/trunk/utils/TableGen: AsmWriterEmitter.cpp AsmWriterEmitter.h In-Reply-To: References: <20110321083153.BA6F12A6C12C@llvm.org> Message-ID: On Mar 21, 2011, at 2:13 PM, Bill Wendling wrote: > On Mar 21, 2011, at 11:48 AM, Nick Lewycky wrote: > >> Hi Bill, >> >> This broke the build for us because we use -Wunused-function -Werror. >> >> llvm/utils/TableGen/AsmWriterEmitter.cpp:714: error: 'void EmitSubtargetFeatureFlagEnumeration(::AsmWriterInfo&, llvm::raw_ostream&)' defined but not used [-Wunused-function] >> >> llvm/utils/TableGen/AsmWriterEmitter.cpp:735: error: 'void EmitComputeAvailableFeatures(::AsmWriterInfo&, llvm::Record*, llvm::CodeGenTarget&, llvm::raw_ostream&)' defined but not used [-Wunused-function] >> >> Would you be okay with waiting until you have the callers written before submitting? Or at least breaking it up in a different sort of way? >> > Hi Nick, > > You did what I was hoping you wouldn't do. :-) I fixed it with this r128020. I'm sorry about the breakage. Yeah, clang whines about it too :) -eric From grosbach at apple.com Mon Mar 21 17:15:52 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 21 Mar 2011 22:15:52 -0000 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp Message-ID: <20110321221553.0D84D2A6C12C@llvm.org> Author: grosbach Date: Mon Mar 21 17:15:52 2011 New Revision: 128031 URL: http://llvm.org/viewvc/llvm-project?rev=128031&view=rev Log: Library-ize the dyld components of llvm-rtdyld. Move the dynamic linking functionality of the llvm-rtdyld program into an ExecutionEngine support library. Update llvm-rtdyld to just load an object file into memory, use the library to process it, then run the _main() function, if one is found. Added: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/Makefile llvm/trunk/tools/llvm-rtdyld/Makefile llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Added: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=128031&view=auto ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (added) +++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Mon Mar 21 17:15:52 2011 @@ -0,0 +1,45 @@ +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Interface for the runtime dynamic linker facilities of the MC-JIT. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_RUNTIME_DYLD_H +#define LLVM_RUNTIME_DYLD_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Memory.h" + +namespace llvm { + +class RuntimeDyldImpl; +class MemoryBuffer; + +class RuntimeDyld { + RuntimeDyld(const RuntimeDyld &); // DO NOT IMPLEMENT + void operator=(const RuntimeDyld &); // DO NOT IMPLEMENT + + // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public + // interface. + RuntimeDyldImpl *Dyld; +public: + RuntimeDyld(); + ~RuntimeDyld(); + + bool loadObject(MemoryBuffer *InputBuffer); + void *getSymbolAddress(StringRef Name); + // FIXME: Should be parameterized to get the memory block associated with + // a particular loaded object. + sys::MemoryBlock getMemoryBlock(); +}; + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/ExecutionEngine/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Makefile?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Makefile (original) +++ llvm/trunk/lib/ExecutionEngine/Makefile Mon Mar 21 17:15:52 2011 @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL = ../.. LIBRARYNAME = LLVMExecutionEngine -PARALLEL_DIRS = Interpreter JIT MCJIT +PARALLEL_DIRS = Interpreter JIT MCJIT RuntimeDyld include $(LEVEL)/Makefile.common Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt Mon Mar 21 17:15:52 2011 @@ -0,0 +1,3 @@ +add_llvm_library(LLVMRuntimeDyld + RuntimeDyld.cpp + ) Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile Mon Mar 21 17:15:52 2011 @@ -0,0 +1,13 @@ +##===- lib/ExecutionEngine/MCJIT/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +LIBRARYNAME = LLVMRuntimeDyld + +include $(LEVEL)/Makefile.common Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Mar 21 17:15:52 2011 @@ -0,0 +1,329 @@ +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implementation of the MC-JIT runtime dynamic linker. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" +#include "llvm/ExecutionEngine/RuntimeDyld.h" +#include "llvm/Object/MachOObject.h" +#include "llvm/Support/Memory.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/system_error.h" +using namespace llvm; +using namespace llvm::object; + +namespace llvm { +class RuntimeDyldImpl { + // Master symbol table. As modules are loaded and external symbols are + // resolved, their addresses are stored here. + StringMap SymbolTable; + + // FIXME: Should have multiple data blocks, one for each loaded chunk of + // compiled code. + sys::MemoryBlock Data; + + bool HasError; + std::string ErrorStr; + + // Set the error state and record an error string. + bool Error(const Twine &Msg) { + ErrorStr = Msg.str(); + HasError = true; + return true; + } + + bool loadSegment32(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC); + bool loadSegment64(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC); + +public: + bool loadObject(MemoryBuffer *InputBuffer); + + void *getSymbolAddress(StringRef Name) { + // Use lookup() rather than [] because we don't want to add an entry + // if there isn't one already, which the [] operator does. + return SymbolTable.lookup(Name); + } + + sys::MemoryBlock getMemoryBlock() { return Data; } + + // Is the linker in an error state? + bool hasError() { return HasError; } + + // Mark the error condition as handled and continue. + void clearError() { HasError = false; } + + // Get the error message. + StringRef getErrorString() { return ErrorStr; } +}; + + + +bool RuntimeDyldImpl:: +loadSegment32(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC) { + InMemoryStruct Segment32LC; + Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); + if (!Segment32LC) + return Error("unable to load segment load command"); + + // Map the segment into memory. + std::string ErrorStr; + Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); + if (!Data.base()) + return Error("unable to allocate memory block: '" + ErrorStr + "'"); + memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, + Segment32LC->FileSize).data(), + Segment32LC->FileSize); + memset((char*)Data.base() + Segment32LC->FileSize, 0, + Segment32LC->VMSize - Segment32LC->FileSize); + + // Bind the section indices to address. + void **SectionBases = new void*[Segment32LC->NumSections]; + for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { + InMemoryStruct Sect; + Obj->ReadSection(*SegmentLCI, i, Sect); + if (!Sect) + return Error("unable to load section: '" + Twine(i) + "'"); + + // FIXME: We don't support relocations yet. + if (Sect->NumRelocationTableEntries != 0) + return Error("not yet implemented: relocations!"); + + // FIXME: Improve check. + if (Sect->Flags != 0x80000400) + return Error("unsupported section type!"); + + SectionBases[i] = (char*) Data.base() + Sect->Address; + } + + // Bind all the symbols to address. + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { + InMemoryStruct STE; + Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); + if (!STE) + return Error("unable to read symbol: '" + Twine(i) + "'"); + if (STE->SectionIndex == 0) + return Error("unexpected undefined symbol!"); + + unsigned Index = STE->SectionIndex - 1; + if (Index >= Segment32LC->NumSections) + return Error("invalid section index for symbol: '" + Twine() + "'"); + + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + + // Get the section base address. + void *SectionBase = SectionBases[Index]; + + // Get the symbol address. + void *Address = (char*) SectionBase + STE->Value; + + // FIXME: Check the symbol type and flags. + if (STE->Type != 0xF) + return Error("unexpected symbol type!"); + if (STE->Flags != 0x0) + return Error("unexpected symbol type!"); + + SymbolTable[Name] = Address; + } + + delete SectionBases; + return false; +} + + +bool RuntimeDyldImpl:: +loadSegment64(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC) { + InMemoryStruct Segment64LC; + Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); + if (!Segment64LC) + return Error("unable to load segment load command"); + + // Map the segment into memory. + std::string ErrorStr; + Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); + if (!Data.base()) + return Error("unable to allocate memory block: '" + ErrorStr + "'"); + memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, + Segment64LC->FileSize).data(), + Segment64LC->FileSize); + memset((char*)Data.base() + Segment64LC->FileSize, 0, + Segment64LC->VMSize - Segment64LC->FileSize); + + // Bind the section indices to address. + void **SectionBases = new void*[Segment64LC->NumSections]; + for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { + InMemoryStruct Sect; + Obj->ReadSection64(*SegmentLCI, i, Sect); + if (!Sect) + return Error("unable to load section: '" + Twine(i) + "'"); + + // FIXME: We don't support relocations yet. + if (Sect->NumRelocationTableEntries != 0) + return Error("not yet implemented: relocations!"); + + // FIXME: Improve check. + if (Sect->Flags != 0x80000400) + return Error("unsupported section type!"); + + SectionBases[i] = (char*) Data.base() + Sect->Address; + } + + // Bind all the symbols to address. + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { + InMemoryStruct STE; + Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); + if (!STE) + return Error("unable to read symbol: '" + Twine(i) + "'"); + if (STE->SectionIndex == 0) + return Error("unexpected undefined symbol!"); + + unsigned Index = STE->SectionIndex - 1; + if (Index >= Segment64LC->NumSections) + return Error("invalid section index for symbol: '" + Twine() + "'"); + + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + + // Get the section base address. + void *SectionBase = SectionBases[Index]; + + // Get the symbol address. + void *Address = (char*) SectionBase + STE->Value; + + // FIXME: Check the symbol type and flags. + if (STE->Type != 0xF) + return Error("unexpected symbol type!"); + if (STE->Flags != 0x0) + return Error("unexpected symbol type!"); + + SymbolTable[Name] = Address; + } + + delete SectionBases; + return false; +} + + + +bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) { + // If the linker is in an error state, don't do anything. + if (hasError()) + return true; + // Load the Mach-O wrapper object. + std::string ErrorStr; + OwningPtr Obj( + MachOObject::LoadFromBuffer(InputBuffer, &ErrorStr)); + if (!Obj) + return Error("unable to load object: '" + ErrorStr + "'"); + + // Validate that the load commands match what we expect. + const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, + *DysymtabLCI = 0; + for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { + const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); + switch (LCI.Command.Type) { + case macho::LCT_Segment: + case macho::LCT_Segment64: + if (SegmentLCI) + return Error("unexpected input object (multiple segments)"); + SegmentLCI = &LCI; + break; + case macho::LCT_Symtab: + if (SymtabLCI) + return Error("unexpected input object (multiple symbol tables)"); + SymtabLCI = &LCI; + break; + case macho::LCT_Dysymtab: + if (DysymtabLCI) + return Error("unexpected input object (multiple symbol tables)"); + DysymtabLCI = &LCI; + break; + default: + return Error("unexpected input object (unexpected load command"); + } + } + + if (!SymtabLCI) + return Error("no symbol table found in object"); + if (!SegmentLCI) + return Error("no symbol table found in object"); + + // Read and register the symbol table data. + InMemoryStruct SymtabLC; + Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); + if (!SymtabLC) + return Error("unable to load symbol table load command"); + Obj->RegisterStringTable(*SymtabLC); + + // Read the dynamic link-edit information, if present (not present in static + // objects). + if (DysymtabLCI) { + InMemoryStruct DysymtabLC; + Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); + if (!DysymtabLC) + return Error("unable to load dynamic link-exit load command"); + + // FIXME: We don't support anything interesting yet. + if (DysymtabLC->LocalSymbolsIndex != 0) + return Error("NOT YET IMPLEMENTED: local symbol entries"); + if (DysymtabLC->ExternalSymbolsIndex != 0) + return Error("NOT YET IMPLEMENTED: non-external symbol entries"); + if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) + return Error("NOT YET IMPLEMENTED: undefined symbol entries"); + } + + // Load the segment load command. + if (SegmentLCI->Command.Type == macho::LCT_Segment) { + if (loadSegment32(Obj.get(), SegmentLCI, SymtabLC)) + return true; + } else { + if (loadSegment64(Obj.get(), SegmentLCI, SymtabLC)) + return true; + } + + return false; +} + + +//===----------------------------------------------------------------------===// +// RuntimeDyld class implementation +RuntimeDyld::RuntimeDyld() { + Dyld = new RuntimeDyldImpl; +} + +RuntimeDyld::~RuntimeDyld() { + delete Dyld; +} + +bool RuntimeDyld::loadObject(MemoryBuffer *InputBuffer) { + return Dyld->loadObject(InputBuffer); +} + +void *RuntimeDyld::getSymbolAddress(StringRef Name) { + return Dyld->getSymbolAddress(Name); +} + +sys::MemoryBlock RuntimeDyld::getMemoryBlock() { + return Dyld->getMemoryBlock(); +} + +} // end namespace llvm Modified: llvm/trunk/tools/llvm-rtdyld/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/Makefile?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/Makefile (original) +++ llvm/trunk/tools/llvm-rtdyld/Makefile Mon Mar 21 17:15:52 2011 @@ -18,6 +18,6 @@ # early so we can set up LINK_COMPONENTS before including Makefile.rules include $(LEVEL)/Makefile.config -LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object +LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object RuntimeDyld include $(LLVM_SRC_ROOT)/Makefile.rules Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original) +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Mon Mar 21 17:15:52 2011 @@ -13,6 +13,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/Object/MachOObject.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" @@ -51,157 +52,6 @@ } /* *** */ -static bool -loadSegment32(const MachOObject *Obj, - sys::MemoryBlock &Data, - const MachOObject::LoadCommandInfo *SegmentLCI, - const InMemoryStruct &SymtabLC, - StringMap &SymbolTable) { - InMemoryStruct Segment32LC; - Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); - if (!Segment32LC) - return Error("unable to load segment load command"); - - // Map the segment into memory. - std::string ErrorStr; - Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); - if (!Data.base()) - return Error("unable to allocate memory block: '" + ErrorStr + "'"); - memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, - Segment32LC->FileSize).data(), - Segment32LC->FileSize); - memset((char*)Data.base() + Segment32LC->FileSize, 0, - Segment32LC->VMSize - Segment32LC->FileSize); - - // Bind the section indices to address. - void **SectionBases = new void*[Segment32LC->NumSections]; - for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { - InMemoryStruct Sect; - Obj->ReadSection(*SegmentLCI, i, Sect); - if (!Sect) - return Error("unable to load section: '" + Twine(i) + "'"); - - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); - - // FIXME: Improve check. - if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); - - SectionBases[i] = (char*) Data.base() + Sect->Address; - } - - // Bind all the symbols to address. - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { - InMemoryStruct STE; - Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); - if (!STE) - return Error("unable to read symbol: '" + Twine(i) + "'"); - if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); - - unsigned Index = STE->SectionIndex - 1; - if (Index >= Segment32LC->NumSections) - return Error("invalid section index for symbol: '" + Twine() + "'"); - - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - - // Get the section base address. - void *SectionBase = SectionBases[Index]; - - // Get the symbol address. - void *Address = (char*) SectionBase + STE->Value; - - // FIXME: Check the symbol type and flags. - if (STE->Type != 0xF) - return Error("unexpected symbol type!"); - if (STE->Flags != 0x0) - return Error("unexpected symbol type!"); - - SymbolTable[Name] = Address; - } - - delete SectionBases; - return false; -} - -static bool -loadSegment64(const MachOObject *Obj, - sys::MemoryBlock &Data, - const MachOObject::LoadCommandInfo *SegmentLCI, - const InMemoryStruct &SymtabLC, - StringMap &SymbolTable) { - InMemoryStruct Segment64LC; - Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); - if (!Segment64LC) - return Error("unable to load segment load command"); - - // Map the segment into memory. - std::string ErrorStr; - Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); - if (!Data.base()) - return Error("unable to allocate memory block: '" + ErrorStr + "'"); - memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, - Segment64LC->FileSize).data(), - Segment64LC->FileSize); - memset((char*)Data.base() + Segment64LC->FileSize, 0, - Segment64LC->VMSize - Segment64LC->FileSize); - - // Bind the section indices to address. - void **SectionBases = new void*[Segment64LC->NumSections]; - for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { - InMemoryStruct Sect; - Obj->ReadSection64(*SegmentLCI, i, Sect); - if (!Sect) - return Error("unable to load section: '" + Twine(i) + "'"); - - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); - - // FIXME: Improve check. - if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); - - SectionBases[i] = (char*) Data.base() + Sect->Address; - } - - // Bind all the symbols to address. - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { - InMemoryStruct STE; - Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); - if (!STE) - return Error("unable to read symbol: '" + Twine(i) + "'"); - if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); - - unsigned Index = STE->SectionIndex - 1; - if (Index >= Segment64LC->NumSections) - return Error("invalid section index for symbol: '" + Twine() + "'"); - - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - - // Get the section base address. - void *SectionBase = SectionBases[Index]; - - // Get the symbol address. - void *Address = (char*) SectionBase + STE->Value; - - // FIXME: Check the symbol type and flags. - if (STE->Type != 0xF) - return Error("unexpected symbol type!"); - if (STE->Flags != 0x0) - return Error("unexpected symbol type!"); - - SymbolTable[Name] = Address; - } - - delete SectionBases; - return false; -} static int executeInput() { // Load the input memory buffer. @@ -209,94 +59,28 @@ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFile, InputBuffer)) return Error("unable to read input: '" + ec.message() + "'"); - // Load the Mach-O wrapper object. - std::string ErrorStr; - OwningPtr Obj( - MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); - if (!Obj) - return Error("unable to load object: '" + ErrorStr + "'"); - - // Validate that the load commands match what we expect. - const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, - *DysymtabLCI = 0; - for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { - const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); - switch (LCI.Command.Type) { - case macho::LCT_Segment: - case macho::LCT_Segment64: - if (SegmentLCI) - return Error("unexpected input object (multiple segments)"); - SegmentLCI = &LCI; - break; - case macho::LCT_Symtab: - if (SymtabLCI) - return Error("unexpected input object (multiple symbol tables)"); - SymtabLCI = &LCI; - break; - case macho::LCT_Dysymtab: - if (DysymtabLCI) - return Error("unexpected input object (multiple symbol tables)"); - DysymtabLCI = &LCI; - break; - default: - return Error("unexpected input object (unexpected load command"); - } - } - - if (!SymtabLCI) - return Error("no symbol table found in object"); - if (!SegmentLCI) - return Error("no symbol table found in object"); - - // Read and register the symbol table data. - InMemoryStruct SymtabLC; - Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); - if (!SymtabLC) - return Error("unable to load symbol table load command"); - Obj->RegisterStringTable(*SymtabLC); - - // Read the dynamic link-edit information, if present (not present in static - // objects). - if (DysymtabLCI) { - InMemoryStruct DysymtabLC; - Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); - if (!DysymtabLC) - return Error("unable to load dynamic link-exit load command"); - - // FIXME: We don't support anything interesting yet. - if (DysymtabLC->LocalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: local symbol entries"); - if (DysymtabLC->ExternalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: non-external symbol entries"); - if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) - return Error("NOT YET IMPLEMENTED: undefined symbol entries"); - } + // Instantiate a dynamic linker. + RuntimeDyld Dyld; - // Load the segment load command. - sys::MemoryBlock Data; - StringMap SymbolTable; - if (SegmentLCI->Command.Type == macho::LCT_Segment) { - if (loadSegment32(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) - return true; - } else { - if (loadSegment64(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) - return true; - } + // Load the object file into it. + if (Dyld.loadObject(InputBuffer.take())) + return true; // Get the address of "_main". - StringMap::iterator it = SymbolTable.find("_main"); - if (it == SymbolTable.end()) + void *MainAddress = Dyld.getSymbolAddress("_main"); + if (MainAddress == 0) return Error("no definition for '_main'"); // Invalidate the instruction cache. + sys::MemoryBlock Data = Dyld.getMemoryBlock(); sys::Memory::InvalidateInstructionCache(Data.base(), Data.size()); // Make sure the memory is executable. + std::string ErrorStr; if (!sys::Memory::setExecutable(Data, &ErrorStr)) return Error("unable to mark function executable: '" + ErrorStr + "'"); // Dispatch to _main(). - void *MainAddress = it->second; errs() << "loaded '_main' at: " << MainAddress << "\n"; int (*Main)(int, const char**) = From wendling at apple.com Mon Mar 21 17:53:42 2011 From: wendling at apple.com (Bill Wendling) Date: Mon, 21 Mar 2011 15:53:42 -0700 Subject: [llvm-commits] [llvm] r127780 - in /llvm/trunk: lib/MC/MCELFStreamer.cpp test/MC/ELF/tls-i386.s In-Reply-To: <20110318103255.GC18687@britannica.bec.de> References: <20110317003510.4074D2A6C12C@llvm.org> <20110318103255.GC18687@britannica.bec.de> Message-ID: <5337BDC7-4992-482F-B623-4212080EC70C@apple.com> Okay. Done here r128032. -bw On Mar 18, 2011, at 3:32 AM, Joerg Sonnenberger wrote: > Bill, I think this should be in 2.9. > > Joerg > > On Thu, Mar 17, 2011 at 12:35:10AM -0000, Joerg Sonnenberger wrote: >> Author: joerg >> Date: Wed Mar 16 19:35:10 2011 >> New Revision: 127780 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=127780&view=rev >> Log: >> Fix handling of @IDNTPOFF relocations, they need to get STT_TLS. >> While here, add VK_ARM_TPOFF and VK_ARM_GOTTPOFF, too. >> >> Modified: >> llvm/trunk/lib/MC/MCELFStreamer.cpp >> llvm/trunk/test/MC/ELF/tls-i386.s >> >> Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=127780&r1=127779&r2=127780&view=diff >> ============================================================================== >> --- llvm/trunk/lib/MC/MCELFStreamer.cpp (original) >> +++ llvm/trunk/lib/MC/MCELFStreamer.cpp Wed Mar 16 19:35:10 2011 >> @@ -291,15 +291,18 @@ >> switch (symRef.getKind()) { >> default: >> return; >> + case MCSymbolRefExpr::VK_GOTTPOFF: >> + case MCSymbolRefExpr::VK_INDNTPOFF: >> case MCSymbolRefExpr::VK_NTPOFF: >> case MCSymbolRefExpr::VK_GOTNTPOFF: >> case MCSymbolRefExpr::VK_TLSGD: >> + case MCSymbolRefExpr::VK_TLSLD: >> case MCSymbolRefExpr::VK_TLSLDM: >> case MCSymbolRefExpr::VK_TPOFF: >> case MCSymbolRefExpr::VK_DTPOFF: >> - case MCSymbolRefExpr::VK_GOTTPOFF: >> - case MCSymbolRefExpr::VK_TLSLD: >> case MCSymbolRefExpr::VK_ARM_TLSGD: >> + case MCSymbolRefExpr::VK_ARM_TPOFF: >> + case MCSymbolRefExpr::VK_ARM_GOTTPOFF: >> break; >> } >> MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol()); >> >> Modified: llvm/trunk/test/MC/ELF/tls-i386.s >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/tls-i386.s?rev=127780&r1=127779&r2=127780&view=diff >> ============================================================================== >> --- llvm/trunk/test/MC/ELF/tls-i386.s (original) >> +++ llvm/trunk/test/MC/ELF/tls-i386.s Wed Mar 16 19:35:10 2011 >> @@ -8,6 +8,7 @@ >> movl foo4 at TLSLDM(%eax), %eax >> movl foo5 at TPOFF(%eax), %eax >> movl foo6 at DTPOFF(%eax), %eax >> + movl foo7 at INDNTPOFF, %eax >> >> // CHECK: (('st_name', 0x00000001) # 'foo1' >> // CHECK-NEXT: ('st_value', 0x00000000) >> @@ -62,3 +63,12 @@ >> // CHECK-NEXT: ('st_other', 0x00000000) >> // CHECK-NEXT: ('st_shndx', 0x00000000) >> // CHECK-NEXT: ), >> +// CHECK-NEXT: # Symbol 0x0000000b >> +// CHECK-NEXT: (('st_name', 0x0000001f) # 'foo7' >> +// CHECK-NEXT: ('st_value', 0x00000000) >> +// CHECK-NEXT: ('st_size', 0x00000000) >> +// CHECK-NEXT: ('st_bind', 0x00000001) >> +// CHECK-NEXT: ('st_type', 0x00000006) >> +// CHECK-NEXT: ('st_other', 0x00000000) >> +// CHECK-NEXT: ('st_shndx', 0x00000000) >> +// CHECK-NEXT: ), >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From ofv at wanadoo.es Mon Mar 21 17:53:52 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 21 Mar 2011 22:53:52 -0000 Subject: [llvm-commits] [llvm] r128033 - in /llvm/trunk: CMakeLists.txt cmake/modules/AddLLVM.cmake Message-ID: <20110321225352.0E0BF2A6C12C@llvm.org> Author: ofv Date: Mon Mar 21 17:53:51 2011 New Revision: 128033 URL: http://llvm.org/viewvc/llvm-project?rev=128033&view=rev Log: Removed workaround for unspecified build problem on MinGW. Tested that MinGW/MSYS builds fine without that. Modified: llvm/trunk/CMakeLists.txt llvm/trunk/cmake/modules/AddLLVM.cmake Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=128033&r1=128032&r2=128033&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Mon Mar 21 17:53:51 2011 @@ -185,15 +185,6 @@ include(TableGen) if( MINGW ) - get_system_libs(LLVM_SYSTEM_LIBS_LIST) - foreach(l ${LLVM_SYSTEM_LIBS_LIST}) - set(LLVM_SYSTEM_LIBS "${LLVM_SYSTEM_LIBS} -l${l}") - endforeach() - set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}${LLVM_SYSTEM_LIBS}") - set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES}${LLVM_SYSTEM_LIBS}") -endif() - -if( MINGW ) # People report that -O3 is unreliable on MinGW. The traditional # build also uses -O2 for that reason: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2") Modified: llvm/trunk/cmake/modules/AddLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=128033&r1=128032&r2=128033&view=diff ============================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake (original) +++ llvm/trunk/cmake/modules/AddLLVM.cmake Mon Mar 21 17:53:51 2011 @@ -84,11 +84,9 @@ if( LLVM_COMMON_DEPENDS ) add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) endif( LLVM_COMMON_DEPENDS ) - if( NOT MINGW ) - get_system_libs(llvm_system_libs) - if( llvm_system_libs ) - target_link_libraries(${name} ${llvm_system_libs}) - endif() + get_system_libs(llvm_system_libs) + if( llvm_system_libs ) + target_link_libraries(${name} ${llvm_system_libs}) endif() endmacro(add_llvm_executable name) From ofv at wanadoo.es Mon Mar 21 18:07:53 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 21 Mar 2011 23:07:53 -0000 Subject: [llvm-commits] [llvm] r128035 - in /llvm/trunk: cmake/modules/LLVMLibDeps.cmake lib/ExecutionEngine/CMakeLists.txt tools/llvm-rtdyld/CMakeLists.txt Message-ID: <20110321230753.AA6822A6C12C@llvm.org> Author: ofv Date: Mon Mar 21 18:07:53 2011 New Revision: 128035 URL: http://llvm.org/viewvc/llvm-project?rev=128035&view=rev Log: Build the new RuntimeDyld library. Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake llvm/trunk/lib/ExecutionEngine/CMakeLists.txt llvm/trunk/tools/llvm-rtdyld/CMakeLists.txt Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=128035&r1=128034&r2=128035&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Mon Mar 21 18:07:53 2011 @@ -47,6 +47,7 @@ set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCAsmPrinter LLVMPowerPCInfo LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMMC LLVMSupport) +set(MSVC_LIB_DEPS_LLVMRuntimeDyld LLVMObject LLVMSupport) set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMInstCombine LLVMSupport LLVMTarget LLVMTransformUtils) set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMTransformUtils) set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcInfo LLVMSupport LLVMTarget) Modified: llvm/trunk/lib/ExecutionEngine/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/CMakeLists.txt?rev=128035&r1=128034&r2=128035&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/CMakeLists.txt (original) +++ llvm/trunk/lib/ExecutionEngine/CMakeLists.txt Mon Mar 21 18:07:53 2011 @@ -6,3 +6,4 @@ add_subdirectory(Interpreter) add_subdirectory(JIT) add_subdirectory(MCJIT) +add_subdirectory(RuntimeDyld) Modified: llvm/trunk/tools/llvm-rtdyld/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/CMakeLists.txt?rev=128035&r1=128034&r2=128035&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-rtdyld/CMakeLists.txt Mon Mar 21 18:07:53 2011 @@ -1,4 +1,4 @@ -set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support MC object) +set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} support MC object RuntimeDyld) add_llvm_tool(llvm-rtdyld llvm-rtdyld.cpp From dpatel at apple.com Mon Mar 21 18:11:08 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 21 Mar 2011 23:11:08 -0000 Subject: [llvm-commits] [llvm] r128036 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Message-ID: <20110321231108.C01B42A6C12C@llvm.org> Author: dpatel Date: Mon Mar 21 18:11:08 2011 New Revision: 128036 URL: http://llvm.org/viewvc/llvm-project?rev=128036&view=rev Log: Try again to make this test darwin only. Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128036&r1=128035&r2=128036&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Mon Mar 21 18:11:08 2011 @@ -1,5 +1,6 @@ // RUN: %llvmgcc %s -m64 -S -O0 -o - | FileCheck %s -// XTARGET: x86_64-apple-darwin +// XFAIL: * +// XTARGET: darwin // Radar 9156771 typedef struct RGBColor { unsigned short red; From resistor at mac.com Mon Mar 21 18:13:43 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 21 Mar 2011 23:13:43 -0000 Subject: [llvm-commits] [llvm] r128037 - /llvm/trunk/lib/MC/MCExpr.cpp Message-ID: <20110321231343.443412A6C12C@llvm.org> Author: resistor Date: Mon Mar 21 18:13:43 2011 New Revision: 128037 URL: http://llvm.org/viewvc/llvm-project?rev=128037&view=rev Log: Add support for Thumb interworking addresses for symbol offsets that get constant folded very early. This fixes SPASS with -integrated-as. Modified: llvm/trunk/lib/MC/MCExpr.cpp Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=128037&r1=128036&r2=128037&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Mon Mar 21 18:13:43 2011 @@ -310,6 +310,11 @@ if (AD.getFragment() == BD.getFragment()) { Addend += (AD.getOffset() - BD.getOffset()); + // Pointers to Thumb symbols need to have their low-bit set to allow + // for interworking. + if (Asm->isThumbFunc(&SA)) + Addend |= 1; + // Clear the symbol expr pointers to indicate we have folded these // operands. A = B = 0; From daniel at zuster.org Mon Mar 21 18:30:19 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 21 Mar 2011 23:30:19 -0000 Subject: [llvm-commits] [compiler-rt] r128038 - in /compiler-rt/trunk/lib: adddf3.c addsf3.c subdf3.c subsf3.c Message-ID: <20110321233019.51D112A6C12C@llvm.org> Author: ddunbar Date: Mon Mar 21 18:30:19 2011 New Revision: 128038 URL: http://llvm.org/viewvc/llvm-project?rev=128038&view=rev Log: compiler-rt: Split subdf3 and subsf3 out of add implementations, for consistency. Added: compiler-rt/trunk/lib/subdf3.c compiler-rt/trunk/lib/subsf3.c Modified: compiler-rt/trunk/lib/adddf3.c compiler-rt/trunk/lib/addsf3.c Modified: compiler-rt/trunk/lib/adddf3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/adddf3.c?rev=128038&r1=128037&r2=128038&view=diff ============================================================================== --- compiler-rt/trunk/lib/adddf3.c (original) +++ compiler-rt/trunk/lib/adddf3.c Mon Mar 21 18:30:19 2011 @@ -1,4 +1,4 @@ -//===-- lib/adddf3.c - Double-precision addition and subtraction --*- C -*-===// +//===-- lib/adddf3.c - Double-precision addition ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements double-precision soft-float addition and subtraction -// with the IEEE-754 default rounding (to nearest, ties to even). +// This file implements double-precision soft-float addition with the IEEE-754 +// default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// @@ -147,8 +147,3 @@ if (roundGuardSticky == 0x4) result += result & 1; return fromRep(result); } - -// Subtraction; flip the sign bit of b and add. -fp_t __subdf3(fp_t a, fp_t b) { - return __adddf3(a, fromRep(toRep(b) ^ signBit)); -} Modified: compiler-rt/trunk/lib/addsf3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/addsf3.c?rev=128038&r1=128037&r2=128038&view=diff ============================================================================== --- compiler-rt/trunk/lib/addsf3.c (original) +++ compiler-rt/trunk/lib/addsf3.c Mon Mar 21 18:30:19 2011 @@ -1,4 +1,4 @@ -//===-- lib/addsf3.c - Single-precision addition and subtraction --*- C -*-===// +//===-- lib/addsf3.c - Single-precision addition ------------------*- C -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file implements single-precision soft-float addition and subtraction -// with the IEEE-754 default rounding (to nearest, ties to even). +// This file implements single-precision soft-float addition with the IEEE-754 +// default rounding (to nearest, ties to even). // //===----------------------------------------------------------------------===// @@ -147,18 +147,3 @@ if (roundGuardSticky == 0x4) result += result & 1; return fromRep(result); } - -// Subtraction; flip the sign bit of b and add. -fp_t __subsf3(fp_t a, fp_t b) { - return __addsf3(a, fromRep(toRep(b) ^ signBit)); -} - - - - - - - - - - Added: compiler-rt/trunk/lib/subdf3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/subdf3.c?rev=128038&view=auto ============================================================================== --- compiler-rt/trunk/lib/subdf3.c (added) +++ compiler-rt/trunk/lib/subdf3.c Mon Mar 21 18:30:19 2011 @@ -0,0 +1,23 @@ +//===-- lib/adddf3.c - Double-precision subtraction ---------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements double-precision soft-float subtraction with the +// IEEE-754 default rounding (to nearest, ties to even). +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +fp_t __adddf3(fp_t a, fp_t b); + +// Subtraction; flip the sign bit of b and add. +fp_t __subdf3(fp_t a, fp_t b) { + return __adddf3(a, fromRep(toRep(b) ^ signBit)); +} Added: compiler-rt/trunk/lib/subsf3.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/subsf3.c?rev=128038&view=auto ============================================================================== --- compiler-rt/trunk/lib/subsf3.c (added) +++ compiler-rt/trunk/lib/subsf3.c Mon Mar 21 18:30:19 2011 @@ -0,0 +1,23 @@ +//===-- lib/subsf3.c - Single-precision subtraction ---------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements single-precision soft-float subtraction with the +// IEEE-754 default rounding (to nearest, ties to even). +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +fp_t __addsf3(fp_t a, fp_t b); + +// Subtraction; flip the sign bit of b and add. +fp_t __subsf3(fp_t a, fp_t b) { + return __addsf3(a, fromRep(toRep(b) ^ signBit)); +} From daniel at zuster.org Mon Mar 21 18:31:09 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 21 Mar 2011 23:31:09 -0000 Subject: [llvm-commits] [compiler-rt] r128039 - /compiler-rt/trunk/make/platform/clang_darwin.mk Message-ID: <20110321233109.908DB2A6C12C@llvm.org> Author: ddunbar Date: Mon Mar 21 18:31:09 2011 New Revision: 128039 URL: http://llvm.org/viewvc/llvm-project?rev=128039&view=rev Log: compiler-rt/clang/cc_kext: Update for functions which we have sinced acquired implementations for. Modified: compiler-rt/trunk/make/platform/clang_darwin.mk Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=128039&r1=128038&r2=128039&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Mon Mar 21 18:31:09 2011 @@ -221,11 +221,10 @@ # FIXME: Currently, compiler-rt is missing implementations for a number of the # functions that need to go into libcc_kext.a. Filter them out for now. CCKEXT_MISSING_FUNCTIONS := \ - adddf3 addsf3 cmpdf2 cmpsf2 div0 divdf3 divsf3 \ - extendsfdf2 ffssi2 fixdfsi fixsfsi floatsidf floatsisf \ - floatunsidf floatunsisf gtdf2 gtsf2 ltdf2 ltsf2 \ - muldf3 mulsf3 negdf2 negsf2 subdf3 subsf3 \ - truncdfsf2 udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ + cmpdf2 cmpsf2 div0 \ + ffssi2 \ + gtdf2 gtsf2 ltdf2 ltsf2 \ + udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ bswapsi2 \ gcc_bcmp \ do_global_dtors \ From gohman at apple.com Mon Mar 21 19:04:35 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 22 Mar 2011 00:04:35 -0000 Subject: [llvm-commits] [llvm] r128041 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-gep.ll Message-ID: <20110322000435.779122A6C12C@llvm.org> Author: djg Date: Mon Mar 21 19:04:35 2011 New Revision: 128041 URL: http://llvm.org/viewvc/llvm-project?rev=128041&view=rev Log: Fix fast-isel address mode folding to avoid folding instructions outside of the current basic block. This fixes PR9500, rdar://9156159. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-gep.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=128041&r1=128040&r2=128041&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Mon Mar 21 19:04:35 2011 @@ -399,33 +399,39 @@ Disp += SL->getElementOffset(Idx); } else { uint64_t S = TD.getTypeAllocSize(GTI.getIndexedType()); - SmallVector Worklist; - Worklist.push_back(Op); - do { - Op = Worklist.pop_back_val(); + for (;;) { if (const ConstantInt *CI = dyn_cast(Op)) { // Constant-offset addressing. Disp += CI->getSExtValue() * S; - } else if (isa(Op) && - isa(cast(Op)->getOperand(1))) { - // An add with a constant operand. Fold the constant. + break; + } + if (isa(Op) && + (!isa(Op) || + FuncInfo.MBBMap[cast(Op)->getParent()] + == FuncInfo.MBB) && + isa(cast(Op)->getOperand(1))) { + // An add (in the same block) with a constant operand. Fold the + // constant. ConstantInt *CI = cast(cast(Op)->getOperand(1)); Disp += CI->getSExtValue() * S; - // Add the other operand back to the work list. - Worklist.push_back(cast(Op)->getOperand(0)); - } else if (IndexReg == 0 && - (!AM.GV || !Subtarget->isPICStyleRIPRel()) && - (S == 1 || S == 2 || S == 4 || S == 8)) { + // Iterate on the other operand. + Op = cast(Op)->getOperand(0); + continue; + } + if (IndexReg == 0 && + (!AM.GV || !Subtarget->isPICStyleRIPRel()) && + (S == 1 || S == 2 || S == 4 || S == 8)) { // Scaled-index addressing. Scale = S; IndexReg = getRegForGEPIndex(Op).first; if (IndexReg == 0) return false; - } else - // Unsupported. - goto unsupported_gep; - } while (!Worklist.empty()); + break; + } + // Unsupported. + goto unsupported_gep; + } } } // Check for displacement overflow. Modified: llvm/trunk/test/CodeGen/X86/fast-isel-gep.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-gep.ll?rev=128041&r1=128040&r2=128041&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-gep.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-gep.ll Mon Mar 21 19:04:35 2011 @@ -87,4 +87,23 @@ ; X64-NEXT: ret } +; PR9500, rdar://9156159 - Don't do non-local address mode folding, +; because it may require values which wouldn't otherwise be live out +; of their blocks. +define void @test6() { +if.end: ; preds = %if.then, %invoke.cont + %tmp15 = load i64* undef + %dec = add i64 %tmp15, 13 + store i64 %dec, i64* undef + %call17 = invoke i8* @_ZNK18G__FastAllocString4dataEv() + to label %invoke.cont16 unwind label %lpad +invoke.cont16: ; preds = %if.then14 + %arrayidx18 = getelementptr inbounds i8* %call17, i64 %dec + store i8 0, i8* %arrayidx18 + unreachable + +lpad: ; preds = %if.end19, %if.then14, %if.end, %entry + unreachable +} +declare i8* @_ZNK18G__FastAllocString4dataEv() nounwind From stoklund at 2pi.dk Mon Mar 21 19:21:41 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 22 Mar 2011 00:21:41 -0000 Subject: [llvm-commits] [llvm] r128045 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/LiveDebugVariables.cpp test/CodeGen/X86/dbg-value-range.ll Message-ID: <20110322002141.8F00C2A6C12D@llvm.org> Author: stoklund Date: Mon Mar 21 19:21:41 2011 New Revision: 128045 URL: http://llvm.org/viewvc/llvm-project?rev=128045&view=rev Log: Dont emit 'DBG_VALUE %noreg, ...' to terminate user variable ranges. These ranges get completely jumbled by the post-ra scheduler, and it is not really reasonable to expect it to make sense of them. Instead, teach DwarfDebug to notice when user variables in registers are clobbered, and terminate the ranges there. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128045&r1=128044&r2=128045&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 21 19:21:41 2011 @@ -2424,8 +2424,7 @@ ME = DbgValues.end(); MI != ME; ++MI) { const MDNode *Var = (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); - if (Var == DV && - !PrevMI->isIdenticalTo(*MI)) + if (Var == DV && !PrevMI->isIdenticalTo(*MI)) MultipleValues.push_back(*MI); PrevMI = *MI; } @@ -2448,7 +2447,7 @@ DbgVariableToDbgInstMap[AbsVar] = MInsn; VarToAbstractVarMap[RegVar] = AbsVar; } - if (MultipleValues.size() <= 1) { + if (MultipleValues.size() <= 1 && !RegClobberInsn.count(MInsn)) { DbgVariableToDbgInstMap[RegVar] = MInsn; continue; } @@ -2458,16 +2457,11 @@ RegVar->setDotDebugLocOffset(0); else RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); - const MachineInstr *Begin = NULL; - const MachineInstr *End = NULL; + for (SmallVector::iterator MVI = MultipleValues.begin(), MVE = MultipleValues.end(); MVI != MVE; ++MVI) { - if (!Begin) { - Begin = *MVI; - continue; - } - End = *MVI; + const MachineInstr *Begin = *MVI; MachineLocation MLoc; if (Begin->getNumOperands() == 3) { if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm()) @@ -2475,25 +2469,25 @@ } else MLoc = Asm->getDebugValueLocation(Begin); + if (!MLoc.getReg()) + continue; + + // Compute the range for a register location. const MCSymbol *FLabel = getLabelBeforeInsn(Begin); - const MCSymbol *SLabel = getLabelBeforeInsn(End); - if (MLoc.getReg()) - DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); - - Begin = End; - if (MVI + 1 == MVE) { - // If End is the last instruction then its value is valid + const MCSymbol *SLabel = 0; + + if (const MachineInstr *ClobberMI = RegClobberInsn.lookup(Begin)) + // The register range starting at Begin may be clobbered. + SLabel = getLabelAfterInsn(ClobberMI); + else if (MVI + 1 == MVE) + // If Begin is the last instruction then its value is valid // until the end of the funtion. - MachineLocation EMLoc; - if (End->getNumOperands() == 3) { - if (End->getOperand(0).isReg() && Begin->getOperand(1).isImm()) - EMLoc.set(Begin->getOperand(0).getReg(), Begin->getOperand(1).getImm()); - } else - EMLoc = Asm->getDebugValueLocation(End); - if (EMLoc.getReg()) - DotDebugLocEntries. - push_back(DotDebugLocEntry(SLabel, FunctionEndSym, EMLoc)); - } + SLabel = FunctionEndSym; + else + // The value is valid until the next DBG_VALUE. + SLabel = getLabelBeforeInsn(MVI[1]); + + DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); } DotDebugLocEntries.push_back(DotDebugLocEntry()); } @@ -2568,7 +2562,7 @@ /// endInstruction - Process end of an instruction. void DwarfDebug::endInstruction(const MachineInstr *MI) { - if (InsnsEndScopeSet.count(MI) != 0) { + if (InsnsNeedsLabelAfter.count(MI) != 0) { // Emit a label if this instruction ends a scope. MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(Label); @@ -2833,7 +2827,7 @@ RE = Ranges.end(); RI != RE; ++RI) { assert(RI->first && "DbgRange does not have first instruction!"); assert(RI->second && "DbgRange does not have second instruction!"); - InsnsEndScopeSet.insert(RI->second); + InsnsNeedsLabelAfter.insert(RI->second); } } } @@ -2914,6 +2908,14 @@ /// ProcessedArgs - Collection of arguments already processed. SmallPtrSet ProcessedArgs; + /// LastDbgValue - Refer back to the last DBG_VALUE instruction to mention MD. + DenseMap LastDbgValue; + + const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); + + /// LiveUserVar - Map physreg numbers to the MDNode they contain. + std::vector LiveUserVar(TRI->getNumRegs()); + DebugLoc PrevLoc; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) @@ -2923,7 +2925,15 @@ DebugLoc DL = MI->getDebugLoc(); if (MI->isDebugValue()) { assert (MI->getNumOperands() > 1 && "Invalid machine instruction!"); - DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata()); + + // Keep track of variables in registers. + const MDNode *Var = + MI->getOperand(MI->getNumOperands() - 1).getMetadata(); + LastDbgValue[Var] = MI; + if (isDbgValueInDefinedReg(MI)) + LiveUserVar[MI->getOperand(0).getReg()] = Var; + + DIVariable DV(Var); if (!DV.Verify()) continue; // If DBG_VALUE is for a local variable then it needs a label. if (DV.getTag() != dwarf::DW_TAG_arg_variable) @@ -2944,6 +2954,32 @@ } else if (DL != PrevLoc) // Otherwise, instruction needs a location only if it is new location. InsnNeedsLabel.insert(MI); + + // Check if the instruction clobbers any registers with debug vars. + for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), + MOE = MI->operands_end(); MOI != MOE; ++MOI) { + if (!MOI->isReg() || !MOI->isDef() || !MOI->getReg()) + continue; + for (const unsigned *AI = TRI->getOverlaps(MOI->getReg()); + unsigned Reg = *AI; ++AI) { + const MDNode *Var = LiveUserVar[Reg]; + if (!Var) + continue; + // Reg is now clobbered. + LiveUserVar[Reg] = 0; + + // Was MD last defined by a DBG_VALUE referring to Reg? + const MachineInstr *Last = LastDbgValue.lookup(Var); + if (!Last || Last->getParent() != MI->getParent()) + continue; + if (!isDbgValueInDefinedReg(Last) || + Last->getOperand(0).getReg() != Reg) + continue; + // MD is clobbered. Make sure the next instruction gets a label. + InsnsNeedsLabelAfter.insert(MI); + RegClobberInsn[Last] = MI; + } + } } if (!DL.isUnknown() || UnknownLocations) @@ -3013,7 +3049,7 @@ VarToAbstractVarMap.clear(); DbgVariableToDbgInstMap.clear(); DeleteContainerSeconds(DbgScopeMap); - InsnsEndScopeSet.clear(); + InsnsNeedsLabelAfter.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128045&r1=128044&r2=128045&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Mar 21 19:21:41 2011 @@ -200,8 +200,6 @@ typedef SmallVector ScopeVector; - SmallPtrSet InsnsEndScopeSet; - /// InlineInfo - Keep track of inlined functions and their location. This /// information is used to populate debug_inlined section. typedef std::pair InlineInfoLabels; @@ -224,6 +222,16 @@ /// a debuggging information entity. SmallPtrSet InsnNeedsLabel; + /// InsnsNeedsLabelAfter - Collection of instructions that need a label after + /// the instruction because they end a scope of clobber a register. + SmallPtrSet InsnsNeedsLabelAfter; + + /// RegClobberInsn - For each DBG_VALUE instruction referring to a register + /// that is clobbered before the variable gets a new DBG_VALUE, map the + /// instruction that clobbered the register. This instruction will also be in + /// InsnsNeedsLabelAfter. + DenseMap RegClobberInsn; + SmallVector DebugRangeSymbols; /// Previous instruction's location information. This is used to determine Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=128045&r1=128044&r2=128045&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Mon Mar 21 19:21:41 2011 @@ -101,10 +101,6 @@ void insertDebugValue(MachineBasicBlock *MBB, SlotIndex Idx, unsigned LocNo, LiveIntervals &LIS, const TargetInstrInfo &TII); - /// insertDebugKill - Insert an undef DBG_VALUE into MBB at Idx. - void insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, - LiveIntervals &LIS, const TargetInstrInfo &TII); - public: /// UserValue - Create a new UserValue. UserValue(const MDNode *var, unsigned o, DebugLoc L, @@ -752,13 +748,6 @@ .addOperand(Loc).addImm(offset).addMetadata(variable); } -void UserValue::insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, - LiveIntervals &LIS, const TargetInstrInfo &TII) { - MachineBasicBlock::iterator I = findInsertLocation(MBB, Idx, LIS); - BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE)).addReg(0) - .addImm(offset).addMetadata(variable); -} - void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS, const TargetInstrInfo &TII) { MachineFunction::iterator MFEnd = VRM->getMachineFunction().end(); @@ -790,12 +779,6 @@ break; ++I; - if (Stop == MBBEnd) - continue; - // The current interval ends before MBB. - // Insert a kill if there is a gap. - if (!I.valid() || I.start() > Stop) - insertDebugKill(MBB, Stop, LIS, TII); } } Modified: llvm/trunk/test/CodeGen/X86/dbg-value-range.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-value-range.ll?rev=128045&r1=128044&r2=128045&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-value-range.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Mon Mar 21 19:21:41 2011 @@ -41,15 +41,17 @@ !18 = metadata !{i32 7, i32 2, metadata !12, null} !19 = metadata !{i32 8, i32 2, metadata !12, null} -; check that variable bar:b value range is appropriately trucated in debug info. Here Ltmp5 is end of -; location range. +; Check that variable bar:b value range is appropriately trucated in debug info. +; The variable is in %rdi which is clobbered by 'movl %ebx, %edi' +; Here Ltmp7 is the end of the location range. ;CHECK:Ltmp6 -;CHECK-NEXT: DEBUG_VALUE: bar:b <- undef +;CHECK-NEXT: movl +;CHECK-NEXT: Ltmp7 ;CHECK:Ldebug_loc0: ;CHECK-NEXT: .quad Ltmp -;CHECK-NEXT: .quad Ltmp6 +;CHECK-NEXT: .quad Ltmp7 ;CHECK-NEXT: .short 1 ;CHECK-NEXT: .byte 85 ;CHECK-NEXT: .quad 0 From matthewbg at google.com Mon Mar 21 19:37:28 2011 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Tue, 22 Mar 2011 00:37:28 -0000 Subject: [llvm-commits] [llvm] r128048 - /llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Message-ID: <20110322003728.EB9AF2A6C12C@llvm.org> Author: matthewbg Date: Mon Mar 21 19:37:28 2011 New Revision: 128048 URL: http://llvm.org/viewvc/llvm-project?rev=128048&view=rev Log: Avoid -Wunused-variable in -asserts builds Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128048&r1=128047&r2=128048&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Mon Mar 21 19:37:28 2011 @@ -607,11 +607,6 @@ const TargetOperandInfo *OpInfo = TID.OpInfo; unsigned &OpIdx = NumOpsAdded; - // Table A6-5 16-bit Thumb Load/store instructions - // opA = 0b0101 for STR/LDR (register) and friends. - // Otherwise, we have STR/LDR (immediate) and friends. - bool Imm5 = (opA != 5); - assert(NumOps >= 2 && OpInfo[0].RegClass == ARM::tGPRRegClassID && OpInfo[1].RegClass == ARM::tGPRRegClassID @@ -632,7 +627,10 @@ if (OpInfo[OpIdx].RegClass < 0 && !OpInfo[OpIdx].isPredicate() && !OpInfo[OpIdx].isOptionalDef()) { - assert(Imm5 && "Immediate operand expected for this opcode"); + // Table A6-5 16-bit Thumb Load/store instructions + // opA = 0b0101 for STR/LDR (register) and friends. + // Otherwise, we have STR/LDR (immediate) and friends. + assert(opA != 5 && "Immediate operand expected for this opcode"); MI.addOperand(MCOperand::CreateImm(getT1Imm5(insn))); ++OpIdx; } else { From grosbach at apple.com Mon Mar 21 19:42:20 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 00:42:20 -0000 Subject: [llvm-commits] [llvm] r128049 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110322004220.272A62A6C12C@llvm.org> Author: grosbach Date: Mon Mar 21 19:42:19 2011 New Revision: 128049 URL: http://llvm.org/viewvc/llvm-project?rev=128049&view=rev Log: Initialize HasError. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128049&r1=128048&r2=128049&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Mar 21 19:42:19 2011 @@ -51,6 +51,8 @@ const InMemoryStruct &SymtabLC); public: + RuntimeDyldImpl() : HasError(false) {} + bool loadObject(MemoryBuffer *InputBuffer); void *getSymbolAddress(StringRef Name) { From stoklund at 2pi.dk Mon Mar 21 20:03:24 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 22 Mar 2011 01:03:24 -0000 Subject: [llvm-commits] [llvm] r128051 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110322010324.BA9CA2A6C12C@llvm.org> Author: stoklund Date: Mon Mar 21 20:03:24 2011 New Revision: 128051 URL: http://llvm.org/viewvc/llvm-project?rev=128051&view=rev Log: Clear map after use. This is likely to fix the segfault in llvm-gcc-x86_64-darwin10-cross-mingw32. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128051&r1=128050&r2=128051&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Mar 21 20:03:24 2011 @@ -3050,6 +3050,7 @@ DbgVariableToDbgInstMap.clear(); DeleteContainerSeconds(DbgScopeMap); InsnsNeedsLabelAfter.clear(); + RegClobberInsn.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); From grosbach at apple.com Mon Mar 21 20:06:42 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 01:06:42 -0000 Subject: [llvm-commits] [llvm] r128052 - in /llvm/trunk/lib/ExecutionEngine: MCJIT/MCJIT.cpp MCJIT/MCJIT.h RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110322010642.C264B2A6C12C@llvm.org> Author: grosbach Date: Mon Mar 21 20:06:42 2011 New Revision: 128052 URL: http://llvm.org/viewvc/llvm-project?rev=128052&view=rev Log: Hook up the MCJIT to the RuntimeDyld library. Lots of cleanup to make the interfaces prettier, use the JITMemoryManager, handle multiple functions and modules, etc.. This gets far enough that the MCJIT compiles and runs code, though. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=128052&r1=128051&r2=128052&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Mon Mar 21 20:06:42 2011 @@ -11,8 +11,11 @@ #include "llvm/Function.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/MCJIT.h" +#include "llvm/ExecutionEngine/JITMemoryManager.h" +#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/DynamicLibrary.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Target/TargetData.h" using namespace llvm; @@ -81,6 +84,12 @@ PM.run(*M); // Flush the output buffer so the SmallVector gets its data. OS.flush(); + + // Load the object into the dynamic linker. + // FIXME: It would be nice to avoid making yet another copy. + MemoryBuffer *MB = MemoryBuffer::getMemBufferCopy(StringRef(Buffer.data(), + Buffer.size())); + Dyld.loadObject(MB); } MCJIT::~MCJIT() { @@ -92,7 +101,8 @@ } void *MCJIT::getPointerToFunction(Function *F) { - return 0; + Twine Name = TM->getMCAsmInfo()->getGlobalPrefix() + F->getName(); + return Dyld.getSymbolAddress(Name.str()); } void *MCJIT::recompileAndRelinkFunction(Function *F) { Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=128052&r1=128051&r2=128052&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Mon Mar 21 20:06:42 2011 @@ -12,6 +12,7 @@ #include "llvm/PassManager.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/raw_ostream.h" @@ -37,6 +38,8 @@ SmallVector Buffer; // Working buffer into which we JIT. raw_svector_ostream OS; + RuntimeDyld Dyld; + public: ~MCJIT(); Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128052&r1=128051&r2=128052&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Mar 21 20:06:42 2011 @@ -145,6 +145,10 @@ SymbolTable[Name] = Address; } + // We've loaded the section; now mark the functions in it as executable. + // FIXME: We really should use the JITMemoryManager for this. + sys::Memory::setRangeExecutable(Data.base(), Data.size()); + delete SectionBases; return false; } @@ -220,12 +224,14 @@ SymbolTable[Name] = Address; } + // We've loaded the section; now mark the functions in it as executable. + // FIXME: We really should use the JITMemoryManager for this. + sys::Memory::setRangeExecutable(Data.base(), Data.size()); + delete SectionBases; return false; } - - bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) { // If the linker is in an error state, don't do anything. if (hasError()) From kremenek at apple.com Mon Mar 21 20:15:08 2011 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 22 Mar 2011 01:15:08 -0000 Subject: [llvm-commits] [llvm] r128054 - /llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Message-ID: <20110322011508.2671F2A6C12C@llvm.org> Author: kremenek Date: Mon Mar 21 20:15:07 2011 New Revision: 128054 URL: http://llvm.org/viewvc/llvm-project?rev=128054&view=rev Log: Relax access control on 'Release' method of RefCountedBase. Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Modified: llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h?rev=128054&r1=128053&r2=128054&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h (original) +++ llvm/trunk/include/llvm/ADT/IntrusiveRefCntPtr.h Mon Mar 21 20:15:07 2011 @@ -44,7 +44,7 @@ class RefCountedBase { unsigned ref_cnt; - protected: + public: RefCountedBase() : ref_cnt(0) {} void Retain() { ++ref_cnt; } @@ -52,8 +52,6 @@ assert (ref_cnt > 0 && "Reference count is already zero."); if (--ref_cnt == 0) delete static_cast(this); } - - friend class IntrusiveRefCntPtr; }; //===----------------------------------------------------------------------===// From kremenek at apple.com Mon Mar 21 20:15:10 2011 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 22 Mar 2011 01:15:10 -0000 Subject: [llvm-commits] [llvm] r128055 - /llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Message-ID: <20110322011510.BCEFC2A6C12D@llvm.org> Author: kremenek Date: Mon Mar 21 20:15:10 2011 New Revision: 128055 URL: http://llvm.org/viewvc/llvm-project?rev=128055&view=rev Log: Rework CrashRecoveryContextCleanup to provide a simpler way to create cleanup objects, and provide a new cleanup for decrementing reference counts of objects with intrusive reference counts. Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=128055&r1=128054&r2=128055&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original) +++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Mon Mar 21 20:15:10 2011 @@ -98,89 +98,97 @@ }; class CrashRecoveryContextCleanup { +protected: + CrashRecoveryContext *context; + CrashRecoveryContextCleanup(CrashRecoveryContext *context) + : context(context) {} public: bool cleanupFired; - enum ProvidedCleanups { DeleteCleanup, DestructorCleanup }; CrashRecoveryContextCleanup() : cleanupFired(false) {} virtual ~CrashRecoveryContextCleanup(); virtual void recoverResources() = 0; - - template static CrashRecoveryContextCleanup *create(T *, - ProvidedCleanups cleanupKind = - CrashRecoveryContextCleanup::DeleteCleanup); - + + CrashRecoveryContext *getContext() const { + return context; + } + private: friend class CrashRecoveryContext; CrashRecoveryContextCleanup *prev, *next; }; -template -class CrashRecoveryContextDestructorCleanup - : public CrashRecoveryContextCleanup -{ +template +class CrashRecoveryContextCleanupBase : public CrashRecoveryContextCleanup { +protected: T *resource; + CrashRecoveryContextCleanupBase(CrashRecoveryContext *context, T* resource) + : CrashRecoveryContextCleanup(context), resource(resource) {} public: - CrashRecoveryContextDestructorCleanup(T *resource) : resource(resource) {} - virtual void recoverResources() { - resource->~T(); + static DERIVED *create(T *x) { + if (x) { + if (CrashRecoveryContext *context = CrashRecoveryContext::GetCurrent()) + return new DERIVED(context, x); + } + return 0; } }; template -class CrashRecoveryContextDeleteCleanup - : public CrashRecoveryContextCleanup -{ - T *resource; +class CrashRecoveryContextDestructorCleanup : public + CrashRecoveryContextCleanupBase, T> { public: - CrashRecoveryContextDeleteCleanup(T *resource) : resource(resource) {} + CrashRecoveryContextDestructorCleanup(CrashRecoveryContext *context, + T *resource) + : CrashRecoveryContextCleanupBase< + CrashRecoveryContextDestructorCleanup, T>(context, resource) {} + virtual void recoverResources() { - delete resource; + this->resource->~T(); } }; template -struct CrashRecoveryContextTrait { - static inline CrashRecoveryContextCleanup * - createCleanup(T *resource, - CrashRecoveryContextCleanup::ProvidedCleanups cleanup) { - switch (cleanup) { - case CrashRecoveryContextCleanup::DeleteCleanup: - return new CrashRecoveryContextDeleteCleanup(resource); - case CrashRecoveryContextCleanup::DestructorCleanup: - return new CrashRecoveryContextDestructorCleanup(resource); - } - return 0; - } +class CrashRecoveryContextDeleteCleanup : public + CrashRecoveryContextCleanupBase, T> { +public: + CrashRecoveryContextDeleteCleanup(CrashRecoveryContext *context, T *resource) + : CrashRecoveryContextCleanupBase< + CrashRecoveryContextDeleteCleanup, T>(context, resource) {} + + virtual void recoverResources() { + delete this->resource; + } }; -template -inline CrashRecoveryContextCleanup* -CrashRecoveryContextCleanup::create(T *x, - CrashRecoveryContextCleanup::ProvidedCleanups cleanupKind) { - return CrashRecoveryContext::GetCurrent() ? - CrashRecoveryContextTrait::createCleanup(x, cleanupKind) : - 0; -} +template +class CrashRecoveryContextReleaseRefCleanup : public + CrashRecoveryContextCleanupBase, T> +{ +public: + CrashRecoveryContextReleaseRefCleanup(CrashRecoveryContext *context, + T *resource) + : CrashRecoveryContextCleanupBase, + T>(context, resource) {} + virtual void recoverResources() { + this->resource->Release(); + } +}; + +template > class CrashRecoveryContextCleanupRegistrar { - CrashRecoveryContext *context; CrashRecoveryContextCleanup *cleanup; public: - CrashRecoveryContextCleanupRegistrar(CrashRecoveryContextCleanup *cleanup) - : context(CrashRecoveryContext::GetCurrent()), - cleanup(cleanup) - { - if (context && cleanup) - context->registerCleanup(cleanup); + CrashRecoveryContextCleanupRegistrar(T *x) + : cleanup(Cleanup::create(x)) { + if (cleanup) + cleanup->getContext()->registerCleanup(cleanup); } + ~CrashRecoveryContextCleanupRegistrar() { - if (cleanup && !cleanup->cleanupFired) { - if (context) - context->unregisterCleanup(cleanup); - else - delete cleanup; - } + if (cleanup && !cleanup->cleanupFired) + cleanup->getContext()->unregisterCleanup(cleanup); } }; } From wendling at apple.com Mon Mar 21 17:58:24 2011 From: wendling at apple.com (Bill Wendling) Date: Mon, 21 Mar 2011 15:58:24 -0700 Subject: [llvm-commits] [RC1] Status of llvm and clang for Windows x64 In-Reply-To: References: Message-ID: Anton, Are these changes good enough (approved) for the 2.9 release? -bw On Mar 18, 2011, at 4:51 AM, NAKAMURA Takumi wrote: > Good evening, guys! > > For Windows x64 aka Win64, llvm and clang can be built on RC1 but it > would not work. > > PR9483 is potentially problematic to mingw32 (x86). It does not affect > selfhosting i686-clang for now (w/o +sse) > > [LLVM] > - r127328 Fix Win64 va_arg. > - [PR8778] alloca/chkstk fix > https://github.com/chapuni/LLVM/commit/e0187c66454f4a45172f34501d5eaa060954a8ad > - [PR9483] (working) > > [clang] > - r127238 mingw-w64 should define __MINGW32__, too. > - r127329 declarations of __builtin_ia32_crc32**() > - r127652 Tweak InitHeaderSearch.cpp for mingw-w64-gcc > - r127654 _mm_malloc tweak > - r127655 Tweak __declspec and __attribute__ for mingw > > > * How to build stage2 x86_64-clang with i686-clang selfhost stage1 > > 1. Get appropriate mingw-w64-gcc package. I am using 20101129. > 2. Layout files to copy directories. > C:/mingw/bin-w64 <- x86_64-mingw32/bin > C:/mingw/libexec/gcc/x86_64-w64-mingw32 <- libexec/gcc/x86_64-w64-mingw32 > C:/mingw/x86_64-w64-mingw32 <- x86_64-mingw32 > 3. Set $PATH > PATH=/c/mingw/bin-w64:/c/mingw/x86_64-w64-mingw32/bin:$PATH:/c/Python27 > 4. Run configure, make, test... > /path/to/configure > --build=x86_64-w64-mingw32 > CC="/path/to/stage1/Release+Asserts/bin/clang -m64 -std=gnu89" > CXX="/path/to/stage1/Release+Asserts/bin/clang++ -m64" > --with-optimize-option=-O3 > --enable-optimized --disable-docs --disable-pthreads > > ...Takumi From anton at korobeynikov.info Mon Mar 21 18:59:36 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Tue, 22 Mar 2011 02:59:36 +0300 Subject: [llvm-commits] [RC1] Status of llvm and clang for Windows x64 In-Reply-To: References: Message-ID: Hi Bill > Are these changes good enough (approved) for the 2.9 release? I think yes. Also, I think the patch for PR8778 should also go in; I don't like it and think it can be generalized, but for now it's the best solution available. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From wendling at apple.com Mon Mar 21 19:29:18 2011 From: wendling at apple.com (Bill Wendling) Date: Mon, 21 Mar 2011 17:29:18 -0700 Subject: [llvm-commits] [RC1] Status of llvm and clang for Windows x64 In-Reply-To: References: Message-ID: On Mar 21, 2011, at 4:59 PM, Anton Korobeynikov wrote: > Hi Bill > >> Are these changes good enough (approved) for the 2.9 release? > I think yes. Also, I think the patch for PR8778 should also go in; I > don't like it and think it can be generalized, but for now it's the > best solution available. > Okay. I merged in all of the changes except for PR9483. Please let me know when that's finished and ready to merge in. -bw From kremenek at apple.com Mon Mar 21 21:06:32 2011 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 22 Mar 2011 02:06:32 -0000 Subject: [llvm-commits] [llvm] r128065 - /llvm/trunk/lib/Support/CrashRecoveryContext.cpp Message-ID: <20110322020632.BAD882A6C12C@llvm.org> Author: kremenek Date: Mon Mar 21 21:06:32 2011 New Revision: 128065 URL: http://llvm.org/viewvc/llvm-project?rev=128065&view=rev Log: Temporarily stop recovering resources in CrashRecoveryContext while I investigate further why this works on my machine and not on others. Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=128065&r1=128064&r2=128065&view=diff ============================================================================== --- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original) +++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Mon Mar 21 21:06:32 2011 @@ -70,7 +70,7 @@ CrashRecoveryContextCleanup *tmp = i; i = tmp->next; tmp->cleanupFired = true; - tmp->recoverResources(); + //tmp->recoverResources(); delete tmp; } tlIsRecoveringFromCrash.erase(); From grosbach at apple.com Mon Mar 21 22:10:14 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 03:10:14 -0000 Subject: [llvm-commits] [llvm] r128067 - /llvm/trunk/tools/lli/CMakeLists.txt Message-ID: <20110322031014.5E1602A6C12C@llvm.org> Author: grosbach Date: Mon Mar 21 22:10:14 2011 New Revision: 128067 URL: http://llvm.org/viewvc/llvm-project?rev=128067&view=rev Log: Update link components. Also perform the required dark rituals and sacrifices to placate the buildbot spirits. We shall see if they are appeased... Modified: llvm/trunk/tools/lli/CMakeLists.txt Modified: llvm/trunk/tools/lli/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/CMakeLists.txt?rev=128067&r1=128066&r2=128067&view=diff ============================================================================== --- llvm/trunk/tools/lli/CMakeLists.txt (original) +++ llvm/trunk/tools/lli/CMakeLists.txt Mon Mar 21 22:10:14 2011 @@ -1,4 +1,4 @@ -set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser selectiondag) +set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser selectiondag RuntimeDyld) add_llvm_tool(lli lli.cpp From andersca at mac.com Mon Mar 21 22:21:01 2011 From: andersca at mac.com (Anders Carlsson) Date: Tue, 22 Mar 2011 03:21:01 -0000 Subject: [llvm-commits] [llvm] r128068 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Message-ID: <20110322032101.3E8F52A6C12C@llvm.org> Author: andersca Date: Mon Mar 21 22:21:01 2011 New Revision: 128068 URL: http://llvm.org/viewvc/llvm-project?rev=128068&view=rev Log: Handle another case that Frits suggested. Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=128068&r1=128067&r2=128068&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Mar 21 22:21:01 2011 @@ -2746,11 +2746,13 @@ if (!CalledFn) return false; + SmallPtrSet NewCalledFunctions(CalledFunctions); + // Don't treat recursive functions as empty. - if (!CalledFunctions.insert(CalledFn)) + if (!NewCalledFunctions.insert(CalledFn)) return false; - if (!cxxDtorIsEmpty(*CalledFn, CalledFunctions)) + if (!cxxDtorIsEmpty(*CalledFn, NewCalledFunctions)) return false; } else if (isa(*I)) return true; From ofv at wanadoo.es Mon Mar 21 22:58:55 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 22 Mar 2011 03:58:55 -0000 Subject: [llvm-commits] [llvm] r128069 - in /llvm/trunk: cmake/modules/LLVMLibDeps.cmake tools/lli/CMakeLists.txt Message-ID: <20110322035855.40C7B2A6C12C@llvm.org> Author: ofv Date: Mon Mar 21 22:58:55 2011 New Revision: 128069 URL: http://llvm.org/viewvc/llvm-project?rev=128069&view=rev Log: Updated library dependencies. Now we can remove RuntimeDyld from the LLVM_LINK_COMPONENTS of tools/lli. CMakeLists.txt LLVM_LINK_COMPONENTS shall not differ from its companion Makefile LINK_COMPONENTS. Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake llvm/trunk/tools/lli/CMakeLists.txt Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=128069&r1=128068&r2=128069&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Mon Mar 21 22:58:55 2011 @@ -34,7 +34,7 @@ set(MSVC_LIB_DEPS_LLVMMBlazeInfo LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMCDisassembler LLVMARMAsmParser LLVMARMCodeGen LLVMARMDisassembler LLVMARMInfo LLVMAlphaCodeGen LLVMAlphaInfo LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCBackend LLVMCBackendInfo LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCppBackend LLVMCppBackendInfo LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeDisassembler LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMMSP430CodeGen LLVMMSP430Info LLVMMipsCodeGen LLVMMipsInfo LLVMPTXCodeGen LLVMPTXInfo LLVMPowerPCCodeGen LLVMPowerPCInfo LLVMSparcCodeGen LLVMSparcInfo LLVMSupport LLVMSystemZCodeGen LLVMSystemZInfo LLVMX86AsmParser LLVMX86CodeGen LLVMX86Disassembler LLVMX86Info LLVMXCoreCodeGen LLVMXCoreInfo) -set(MSVC_LIB_DEPS_LLVMMCJIT LLVMCore LLVMExecutionEngine LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMMCJIT LLVMCore LLVMExecutionEngine LLVMRuntimeDyld LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMCParser LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMSP430CodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430AsmPrinter LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMTarget) Modified: llvm/trunk/tools/lli/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/CMakeLists.txt?rev=128069&r1=128068&r2=128069&view=diff ============================================================================== --- llvm/trunk/tools/lli/CMakeLists.txt (original) +++ llvm/trunk/tools/lli/CMakeLists.txt Mon Mar 21 22:58:55 2011 @@ -1,4 +1,4 @@ -set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser selectiondag RuntimeDyld) +set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser selectiondag) add_llvm_tool(lli lli.cpp From ofv at wanadoo.es Mon Mar 21 23:06:28 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Tue, 22 Mar 2011 05:06:28 +0100 Subject: [llvm-commits] [llvm] r128067 - /llvm/trunk/tools/lli/CMakeLists.txt In-Reply-To: <20110322031014.5E1602A6C12C@llvm.org> (Jim Grosbach's message of "Tue, 22 Mar 2011 03:10:14 -0000") References: <20110322031014.5E1602A6C12C@llvm.org> Message-ID: <87tyevyf23.fsf@wanadoo.es> Jim Grosbach writes: > Author: grosbach > Date: Mon Mar 21 22:10:14 2011 > New Revision: 128067 > > URL: http://llvm.org/viewvc/llvm-project?rev=128067&view=rev > Log: > Update link components. > > Also perform the required dark rituals and sacrifices to placate the buildbot > spirits. We shall see if they are appeased... Are there any buildbots building with cmake? From grosbach at apple.com Mon Mar 21 23:12:33 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 21 Mar 2011 21:12:33 -0700 Subject: [llvm-commits] [llvm] r128067 - /llvm/trunk/tools/lli/CMakeLists.txt In-Reply-To: <87tyevyf23.fsf@wanadoo.es> References: <20110322031014.5E1602A6C12C@llvm.org> <87tyevyf23.fsf@wanadoo.es> Message-ID: <11F0518A-CA94-4978-A81D-C890F7E427EA@apple.com> On Mar 21, 2011, at 9:06 PM, ?scar Fuentes wrote: > Jim Grosbach writes: > >> Author: grosbach >> Date: Mon Mar 21 22:10:14 2011 >> New Revision: 128067 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128067&view=rev >> Log: >> Update link components. >> >> Also perform the required dark rituals and sacrifices to placate the buildbot >> spirits. We shall see if they are appeased... > > Are there any buildbots building with cmake? We have an internal bot that was failing with the same symptoms. I don't know for certain that it's CMake based, but it definitely seems so. -Jim From kremenek at apple.com Mon Mar 21 23:33:13 2011 From: kremenek at apple.com (Ted Kremenek) Date: Tue, 22 Mar 2011 04:33:13 -0000 Subject: [llvm-commits] [llvm] r128071 - in /llvm/trunk: include/llvm/Support/CrashRecoveryContext.h lib/Support/CrashRecoveryContext.cpp Message-ID: <20110322043313.4F1132A6C12C@llvm.org> Author: kremenek Date: Mon Mar 21 23:33:13 2011 New Revision: 128071 URL: http://llvm.org/viewvc/llvm-project?rev=128071&view=rev Log: Properly initialize all fields in CrashReporterCleanupContext. This caused the buildbot failure earlier. Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h llvm/trunk/lib/Support/CrashRecoveryContext.cpp Modified: llvm/trunk/include/llvm/Support/CrashRecoveryContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CrashRecoveryContext.h?rev=128071&r1=128070&r2=128071&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CrashRecoveryContext.h (original) +++ llvm/trunk/include/llvm/Support/CrashRecoveryContext.h Mon Mar 21 23:33:13 2011 @@ -101,11 +101,10 @@ protected: CrashRecoveryContext *context; CrashRecoveryContextCleanup(CrashRecoveryContext *context) - : context(context) {} + : context(context), cleanupFired(false) {} public: bool cleanupFired; - CrashRecoveryContextCleanup() : cleanupFired(false) {} virtual ~CrashRecoveryContextCleanup(); virtual void recoverResources() = 0; Modified: llvm/trunk/lib/Support/CrashRecoveryContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CrashRecoveryContext.cpp?rev=128071&r1=128070&r2=128071&view=diff ============================================================================== --- llvm/trunk/lib/Support/CrashRecoveryContext.cpp (original) +++ llvm/trunk/lib/Support/CrashRecoveryContext.cpp Mon Mar 21 23:33:13 2011 @@ -70,7 +70,7 @@ CrashRecoveryContextCleanup *tmp = i; i = tmp->next; tmp->cleanupFired = true; - //tmp->recoverResources(); + tmp->recoverResources(); delete tmp; } tlIsRecoveringFromCrash.erase(); From baldrick at free.fr Tue Mar 22 03:48:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 08:48:10 -0000 Subject: [llvm-commits] [dragonegg] r128076 - /dragonegg/trunk/Constants.cpp Message-ID: <20110322084810.8A55D2A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 03:48:10 2011 New Revision: 128076 URL: http://llvm.org/viewvc/llvm-project?rev=128076&view=rev Log: Unify handling of CONVERT_EXPR and NOP_EXPR. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128076&r1=128075&r2=128076&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Tue Mar 22 03:48:10 2011 @@ -496,23 +496,13 @@ return AddressOf(TREE_OPERAND(exp, 0)); } -static Constant *ConvertNOP_EXPR(tree exp) { - Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0)); - const Type *Ty = ConvertType(TREE_TYPE(exp)); - bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); - bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); - - // If this is a structure-to-structure cast, just return the uncasted value. - if (!Elt->getType()->isSingleValueType() || !Ty->isSingleValueType()) - return Elt; - - // Elt and Ty can be integer, float or pointer here: need generalized cast - Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned, - Ty, TyIsSigned); - return TheFolder->CreateCast(opcode, Elt, Ty); -} - static Constant *ConvertCONVERT_EXPR(tree exp) { + if (AGGREGATE_TYPE_P(TREE_TYPE(exp)) || + AGGREGATE_TYPE_P(TREE_TYPE(TREE_OPERAND(exp, 0)))) { + // A no-op record view conversion. These do not change any of the bits in + // the constant so just ignore them. + return ConvertInitializer(TREE_OPERAND(exp, 0)); + } Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0)); bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); const Type *Ty = ConvertType(TREE_TYPE(exp)); @@ -1221,10 +1211,8 @@ case STRING_CST: Init = ConvertSTRING_CST(exp); break; - case NOP_EXPR: - Init = ConvertNOP_EXPR(exp); - break; case CONVERT_EXPR: + case NOP_EXPR: Init = ConvertCONVERT_EXPR(exp); break; case PLUS_EXPR: From echristo at apple.com Tue Mar 22 03:49:56 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 22 Mar 2011 08:49:56 -0000 Subject: [llvm-commits] [llvm] r128077 - /llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Message-ID: <20110322084956.9B6AF2A6C12C@llvm.org> Author: echristo Date: Tue Mar 22 03:49:56 2011 New Revision: 128077 URL: http://llvm.org/viewvc/llvm-project?rev=128077&view=rev Log: Fix comment in header. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=128077&r1=128076&r2=128077&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Mar 22 03:49:56 2011 @@ -1,4 +1,4 @@ -//===-- JIT.cpp - MC-based Just-in-Time Compiler --------------------------===// +//===-- MCJIT.cpp - MC-based Just-in-Time Compiler --------------------------===// // // The LLVM Compiler Infrastructure // From baldrick at free.fr Tue Mar 22 03:50:38 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 08:50:38 -0000 Subject: [llvm-commits] [dragonegg] r128078 - in /dragonegg/trunk: Constants.cpp Convert.cpp Message-ID: <20110322085038.CFD002A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 03:50:38 2011 New Revision: 128078 URL: http://llvm.org/viewvc/llvm-project?rev=128078&view=rev Log: Eliminate some assumptions that a byte (addressable unit) is 8 bits wide. Modified: dragonegg/trunk/Constants.cpp dragonegg/trunk/Convert.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128078&r1=128077&r2=128078&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Tue Mar 22 03:50:38 2011 @@ -514,10 +514,10 @@ static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { Constant *Ptr = ConvertInitializer(TREE_OPERAND(exp, 0)); // The pointer. - Constant *Idx = ConvertInitializer(TREE_OPERAND(exp, 1)); // Offset in bytes. + Constant *Idx = ConvertInitializer(TREE_OPERAND(exp, 1)); // Offset in units. // Convert the pointer into an i8* and add the offset to it. - Ptr = TheFolder->CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); + Ptr = TheFolder->CreateBitCast(Ptr, GetUnitPointerType(Context)); Constant *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? TheFolder->CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : TheFolder->CreateGetElementPtr(Ptr, &Idx, 1); Modified: dragonegg/trunk/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Convert.cpp?rev=128078&r1=128077&r2=128078&view=diff ============================================================================== --- dragonegg/trunk/Convert.cpp (original) +++ dragonegg/trunk/Convert.cpp Tue Mar 22 03:50:38 2011 @@ -6695,10 +6695,10 @@ Value *TreeToLLVM::EmitReg_POINTER_PLUS_EXPR(tree type, tree op0, tree op1) { Value *Ptr = EmitRegister(op0); // The pointer. - Value *Idx = EmitRegister(op1); // The offset in bytes. + Value *Idx = EmitRegister(op1); // The offset in units. // Convert the pointer into an i8* and add the offset to it. - Ptr = Builder.CreateBitCast(Ptr, Type::getInt8PtrTy(Context)); + Ptr = Builder.CreateBitCast(Ptr, GetUnitPointerType(Context)); Value *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? Builder.CreateInBoundsGEP(Ptr, Idx) : Builder.CreateGEP(Ptr, Idx); From baldrick at free.fr Tue Mar 22 04:26:47 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 09:26:47 -0000 Subject: [llvm-commits] [dragonegg] r128079 - /dragonegg/trunk/Constants.cpp Message-ID: <20110322092647.799E12A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 04:26:47 2011 New Revision: 128079 URL: http://llvm.org/viewvc/llvm-project?rev=128079&view=rev Log: Cosmetic changes. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128079&r1=128078&r2=128079&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Tue Mar 22 04:26:47 2011 @@ -1188,6 +1188,11 @@ } } +static Constant *ConvertVIEW_CONVERT_EXPR(tree exp) { + // Does not change the bits, only the type they are considered to be. + return ConvertInitializer(TREE_OPERAND(exp, 0)); +} + /// ConvertInitializer - Convert the initial value for a global variable to an /// equivalent LLVM constant. Also handles constant constructors. The type of /// the returned value may be pretty much anything. All that is guaranteed is @@ -1206,30 +1211,32 @@ case INTEGER_CST: case REAL_CST: case VECTOR_CST: + // Make the IR easier to read by converting the bunch of bytes returned by + // ConvertCST into a less surprising type. Init = InterpretAsType(ConvertCST(exp), ConvertType(TREE_TYPE(exp)), 0); break; case STRING_CST: Init = ConvertSTRING_CST(exp); break; + case ADDR_EXPR: + Init = ConvertADDR_EXPR(exp); + break; + case CONSTRUCTOR: + Init = ConvertCONSTRUCTOR(exp); + break; case CONVERT_EXPR: case NOP_EXPR: Init = ConvertCONVERT_EXPR(exp); break; - case PLUS_EXPR: case MINUS_EXPR: + case PLUS_EXPR: Init = ConvertBinOp_CST(exp); break; - case CONSTRUCTOR: - Init = ConvertCONSTRUCTOR(exp); - break; - case VIEW_CONVERT_EXPR: - Init = ConvertInitializer(TREE_OPERAND(exp, 0)); - break; case POINTER_PLUS_EXPR: Init = ConvertPOINTER_PLUS_EXPR(exp); break; - case ADDR_EXPR: - Init = ConvertADDR_EXPR(exp); + case VIEW_CONVERT_EXPR: + Init = ConvertVIEW_CONVERT_EXPR(exp); break; } @@ -1416,19 +1423,19 @@ case COMPONENT_REF: Addr = AddressOfCOMPONENT_REF(exp); break; + case COMPOUND_LITERAL_EXPR: // FIXME: not gimple - defined by C front-end + Addr = AddressOf(DECL_EXPR_DECL (TREE_OPERAND (exp, 0))); + break; case CONST_DECL: case FUNCTION_DECL: case VAR_DECL: Addr = AddressOfDecl(exp); break; - case LABEL_DECL: - Addr = AddressOfLABEL_DECL(exp); - break; case INDIRECT_REF: Addr = AddressOfINDIRECT_REF(exp); break; - case COMPOUND_LITERAL_EXPR: // FIXME: not gimple - defined by C front-end - Addr = AddressOf(DECL_EXPR_DECL (TREE_OPERAND (exp, 0))); + case LABEL_DECL: + Addr = AddressOfLABEL_DECL(exp); break; } From baldrick at free.fr Tue Mar 22 04:36:16 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 09:36:16 -0000 Subject: [llvm-commits] [dragonegg] r128080 - /dragonegg/trunk/Constants.cpp Message-ID: <20110322093616.B3BAC2A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 04:36:16 2011 New Revision: 128080 URL: http://llvm.org/viewvc/llvm-project?rev=128080&view=rev Log: Reorder some methods, no functionality change. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128080&r1=128079&r2=128080&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Tue Mar 22 04:36:16 2011 @@ -496,63 +496,6 @@ return AddressOf(TREE_OPERAND(exp, 0)); } -static Constant *ConvertCONVERT_EXPR(tree exp) { - if (AGGREGATE_TYPE_P(TREE_TYPE(exp)) || - AGGREGATE_TYPE_P(TREE_TYPE(TREE_OPERAND(exp, 0)))) { - // A no-op record view conversion. These do not change any of the bits in - // the constant so just ignore them. - return ConvertInitializer(TREE_OPERAND(exp, 0)); - } - Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0)); - bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); - const Type *Ty = ConvertType(TREE_TYPE(exp)); - bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); - Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned, Ty, - TyIsSigned); - return TheFolder->CreateCast(opcode, Elt, Ty); -} - -static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { - Constant *Ptr = ConvertInitializer(TREE_OPERAND(exp, 0)); // The pointer. - Constant *Idx = ConvertInitializer(TREE_OPERAND(exp, 1)); // Offset in units. - - // Convert the pointer into an i8* and add the offset to it. - Ptr = TheFolder->CreateBitCast(Ptr, GetUnitPointerType(Context)); - Constant *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? - TheFolder->CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : - TheFolder->CreateGetElementPtr(Ptr, &Idx, 1); - - // The result may be of a different pointer type. - return TheFolder->CreateBitCast(GEP, ConvertType(TREE_TYPE(exp))); -} - -static Constant *ConvertBinOp_CST(tree exp) { - Constant *LHS = ConvertInitializer(TREE_OPERAND(exp, 0)); - bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,0))); - Constant *RHS = ConvertInitializer(TREE_OPERAND(exp, 1)); - bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,1))); - Instruction::CastOps opcode; - if (LHS->getType()->isPointerTy()) { - const Type *IntPtrTy = getTargetData().getIntPtrType(Context); - opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false); - LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy); - opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, IntPtrTy, false); - RHS = TheFolder->CreateCast(opcode, RHS, IntPtrTy); - } - - Constant *Result; - switch (TREE_CODE(exp)) { - default: assert(0 && "Unexpected case!"); - case PLUS_EXPR: Result = TheFolder->CreateAdd(LHS, RHS); break; - case MINUS_EXPR: Result = TheFolder->CreateSub(LHS, RHS); break; - } - - const Type *Ty = ConvertType(TREE_TYPE(exp)); - bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); - opcode = CastInst::getCastOpcode(Result, LHSIsSigned, Ty, TyIsSigned); - return TheFolder->CreateCast(opcode, Result, Ty); -} - static Constant *ConvertArrayCONSTRUCTOR(tree exp) { // Vectors are like arrays, but the domain is stored via an array // type indirectly. @@ -1188,6 +1131,63 @@ } } +static Constant *ConvertCONVERT_EXPR(tree exp) { + if (AGGREGATE_TYPE_P(TREE_TYPE(exp)) || + AGGREGATE_TYPE_P(TREE_TYPE(TREE_OPERAND(exp, 0)))) { + // A no-op record view conversion. These do not change any of the bits in + // the constant so just ignore them. + return ConvertInitializer(TREE_OPERAND(exp, 0)); + } + Constant *Elt = ConvertInitializer(TREE_OPERAND(exp, 0)); + bool EltIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); + const Type *Ty = ConvertType(TREE_TYPE(exp)); + bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); + Instruction::CastOps opcode = CastInst::getCastOpcode(Elt, EltIsSigned, Ty, + TyIsSigned); + return TheFolder->CreateCast(opcode, Elt, Ty); +} + +static Constant *ConvertBinOp_CST(tree exp) { + Constant *LHS = ConvertInitializer(TREE_OPERAND(exp, 0)); + bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,0))); + Constant *RHS = ConvertInitializer(TREE_OPERAND(exp, 1)); + bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,1))); + Instruction::CastOps opcode; + if (LHS->getType()->isPointerTy()) { + const Type *IntPtrTy = getTargetData().getIntPtrType(Context); + opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false); + LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy); + opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, IntPtrTy, false); + RHS = TheFolder->CreateCast(opcode, RHS, IntPtrTy); + } + + Constant *Result; + switch (TREE_CODE(exp)) { + default: assert(0 && "Unexpected case!"); + case PLUS_EXPR: Result = TheFolder->CreateAdd(LHS, RHS); break; + case MINUS_EXPR: Result = TheFolder->CreateSub(LHS, RHS); break; + } + + const Type *Ty = ConvertType(TREE_TYPE(exp)); + bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); + opcode = CastInst::getCastOpcode(Result, LHSIsSigned, Ty, TyIsSigned); + return TheFolder->CreateCast(opcode, Result, Ty); +} + +static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { + Constant *Ptr = ConvertInitializer(TREE_OPERAND(exp, 0)); // The pointer. + Constant *Idx = ConvertInitializer(TREE_OPERAND(exp, 1)); // Offset in units. + + // Convert the pointer into an i8* and add the offset to it. + Ptr = TheFolder->CreateBitCast(Ptr, GetUnitPointerType(Context)); + Constant *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? + TheFolder->CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : + TheFolder->CreateGetElementPtr(Ptr, &Idx, 1); + + // The result may be of a different pointer type. + return TheFolder->CreateBitCast(GEP, ConvertType(TREE_TYPE(exp))); +} + static Constant *ConvertVIEW_CONVERT_EXPR(tree exp) { // Does not change the bits, only the type they are considered to be. return ConvertInitializer(TREE_OPERAND(exp, 0)); From baldrick at free.fr Tue Mar 22 04:59:27 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 09:59:27 -0000 Subject: [llvm-commits] [dragonegg] r128082 - /dragonegg/trunk/Constants.cpp Message-ID: <20110322095927.CBDCF2A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 04:59:27 2011 New Revision: 128082 URL: http://llvm.org/viewvc/llvm-project?rev=128082&view=rev Log: Do not assume that the size of a host 'char' is 8. Modified: dragonegg/trunk/Constants.cpp Modified: dragonegg/trunk/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Constants.cpp?rev=128082&r1=128081&r2=128082&view=diff ============================================================================== --- dragonegg/trunk/Constants.cpp (original) +++ dragonegg/trunk/Constants.cpp Tue Mar 22 04:59:27 2011 @@ -411,13 +411,14 @@ /// moment only INTEGER_CST, REAL_CST, COMPLEX_CST and VECTOR_CST are supported. static Constant *ConvertCST(tree exp) { const tree type = TREE_TYPE(exp); - unsigned SizeInBytes = (TREE_INT_CST_LOW(TYPE_SIZE(type)) + 7) / 8; + unsigned SizeInChars = (TREE_INT_CST_LOW(TYPE_SIZE(type)) + CHAR_BIT - 1) / + CHAR_BIT; // Encode the constant in Buffer in target format. - std::vector Buffer(SizeInBytes); - unsigned BytesWritten = native_encode_expr(exp, &Buffer[0], SizeInBytes); - assert(BytesWritten == SizeInBytes && "Failed to fully encode expression!"); + std::vector Buffer(SizeInChars); + unsigned CharsWritten = native_encode_expr(exp, &Buffer[0], SizeInChars); + assert(CharsWritten == SizeInChars && "Failed to fully encode expression!"); // Turn it into an LLVM byte array. - return ConstantArray::get(Context, StringRef((char *)&Buffer[0], SizeInBytes), + return ConstantArray::get(Context, StringRef((char *)&Buffer[0], SizeInChars), /*AddNull*/false); } From baldrick at free.fr Tue Mar 22 05:33:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 22 Mar 2011 10:33:10 -0000 Subject: [llvm-commits] [test-suite] r128083 - /test-suite/trunk/MultiSource/Applications/lemon/Makefile Message-ID: <20110322103310.5EA672A6C12C@llvm.org> Author: baldrick Date: Tue Mar 22 05:33:10 2011 New Revision: 128083 URL: http://llvm.org/viewvc/llvm-project?rev=128083&view=rev Log: Increase the timeout in the hope of fixing PR9469. Modified: test-suite/trunk/MultiSource/Applications/lemon/Makefile Modified: test-suite/trunk/MultiSource/Applications/lemon/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/lemon/Makefile?rev=128083&r1=128082&r2=128083&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/lemon/Makefile (original) +++ test-suite/trunk/MultiSource/Applications/lemon/Makefile Tue Mar 22 05:33:10 2011 @@ -6,6 +6,9 @@ RUN_OPTIONS = $(PROJ_SRC_DIR)/parse.y $(PROJ_SRC_DIR)/example1.y $(PROJ_SRC_DIR)/example2.y $(PROJ_SRC_DIR)/example3.y $(PROJ_SRC_DIR)/example4.y $(PROJ_SRC_DIR)/example5.y $(PROJ_SRC_DIR)/lighttpd_configparser.y $(PROJ_SRC_DIR)/lighttpd_mod_ssi_exprparser.y $(PROJ_SRC_DIR)/wireshark_dtd_grammar.lemon $(PROJ_SRC_DIR)/wireshark_grammar.lemon $(PROJ_SRC_DIR)/wireshark_mate_grammar.lemon $(PROJ_SRC_DIR)/xapian_queryparser.lemony $(PROJ_SRC_DIR)/ecmascript.y HASH_PROGRAM_OUTPUT = 1 +# With a Debug+Asserts build may time out if the default limit is used. +RUNTIMELIMIT := 750 + include $(LEVEL)/Makefile.config include ../../Makefile.multisrc From clchiou at gmail.com Tue Mar 22 09:12:00 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Tue, 22 Mar 2011 14:12:00 -0000 Subject: [llvm-commits] [llvm] r128084 - in /llvm/trunk: lib/Target/PTX/PTXInstrInfo.cpp lib/Target/PTX/PTXInstrInfo.h lib/Target/PTX/PTXInstrInfo.td test/CodeGen/PTX/bra.ll Message-ID: <20110322141200.9116B2A6C12C@llvm.org> Author: clchiou Date: Tue Mar 22 09:12:00 2011 New Revision: 128084 URL: http://llvm.org/viewvc/llvm-project?rev=128084&view=rev Log: ptx: add analyze/insert/remove branch Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.h llvm/trunk/lib/Target/PTX/PTXInstrInfo.td llvm/trunk/test/CodeGen/PTX/bra.ll Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp?rev=128084&r1=128083&r2=128084&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.cpp Tue Mar 22 09:12:00 2011 @@ -11,11 +11,15 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "ptx-instrinfo" + #include "PTX.h" #include "PTXInstrInfo.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/CodeGen/SelectionDAGNodes.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; @@ -132,7 +136,6 @@ return false; } - bool PTXInstrInfo:: DefinesPredicate(MachineInstr *MI, std::vector &Pred) const { @@ -165,6 +168,127 @@ } } +// branch support + +bool PTXInstrInfo:: +AnalyzeBranch(MachineBasicBlock &MBB, + MachineBasicBlock *&TBB, + MachineBasicBlock *&FBB, + SmallVectorImpl &Cond, + bool AllowModify) const { + // TODO implement cases when AllowModify is true + + if (MBB.empty()) + return true; + + MachineBasicBlock::const_iterator iter = MBB.end(); + const MachineInstr& instLast1 = *--iter; + const TargetInstrDesc &desc1 = instLast1.getDesc(); + // for special case that MBB has only 1 instruction + const bool IsSizeOne = MBB.size() == 1; + // if IsSizeOne is true, *--iter and instLast2 are invalid + // we put a dummy value in instLast2 and desc2 since they are used + const MachineInstr& instLast2 = IsSizeOne ? instLast1 : *--iter; + const TargetInstrDesc &desc2 = IsSizeOne ? desc1 : instLast2.getDesc(); + + DEBUG(dbgs() << "\n"); + DEBUG(dbgs() << "AnalyzeBranch: opcode: " << instLast1.getOpcode() << "\n"); + DEBUG(dbgs() << "AnalyzeBranch: MBB: " << MBB.getName().str() << "\n"); + DEBUG(dbgs() << "AnalyzeBranch: TBB: " << TBB << "\n"); + DEBUG(dbgs() << "AnalyzeBranch: FBB: " << FBB << "\n"); + + // this block ends with no branches + if (!IsAnyKindOfBranch(instLast1)) { + DEBUG(dbgs() << "AnalyzeBranch: ends with no branch\n"); + return false; + } + + // this block ends with only an unconditional branch + if (desc1.isUnconditionalBranch() && + // when IsSizeOne is true, it "absorbs" the evaluation of instLast2 + (IsSizeOne || !IsAnyKindOfBranch(instLast2))) { + DEBUG(dbgs() << "AnalyzeBranch: ends with only uncond branch\n"); + TBB = GetBranchTarget(instLast1); + return false; + } + + // this block ends with a conditional branch and + // it falls through to a successor block + if (desc1.isConditionalBranch() && + IsAnySuccessorAlsoLayoutSuccessor(MBB)) { + DEBUG(dbgs() << "AnalyzeBranch: ends with cond branch and fall through\n"); + TBB = GetBranchTarget(instLast1); + int i = instLast1.findFirstPredOperandIdx(); + Cond.push_back(instLast1.getOperand(i)); + Cond.push_back(instLast1.getOperand(i+1)); + return false; + } + + // when IsSizeOne is true, we are done + if (IsSizeOne) + return true; + + // this block ends with a conditional branch + // followed by an unconditional branch + if (desc2.isConditionalBranch() && + desc1.isUnconditionalBranch()) { + DEBUG(dbgs() << "AnalyzeBranch: ends with cond and uncond branch\n"); + TBB = GetBranchTarget(instLast2); + FBB = GetBranchTarget(instLast1); + int i = instLast2.findFirstPredOperandIdx(); + Cond.push_back(instLast2.getOperand(i)); + Cond.push_back(instLast2.getOperand(i+1)); + return false; + } + + // branch cannot be understood + DEBUG(dbgs() << "AnalyzeBranch: cannot be understood\n"); + return true; +} + +unsigned PTXInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const { + unsigned count; + for (count = 0; IsAnyKindOfBranch(MBB.back()); ++count) + MBB.pop_back(); + DEBUG(dbgs() << "RemoveBranch: MBB: " << MBB.getName().str() << "\n"); + DEBUG(dbgs() << "RemoveBranch: count: " << count << "\n"); + return count; +} + +unsigned PTXInstrInfo:: +InsertBranch(MachineBasicBlock &MBB, + MachineBasicBlock *TBB, + MachineBasicBlock *FBB, + const SmallVectorImpl &Cond, + DebugLoc DL) const { + DEBUG(dbgs() << "InsertBranch: MBB: " << MBB.getName().str() << "\n"); + DEBUG(if (TBB) dbgs() << "InsertBranch: TBB: " + << TBB->getName().str() << "\n"; + else dbgs() << "InsertBranch: TBB: (NULL)\n"); + DEBUG(if (FBB) dbgs() << "InsertBranch: FBB: " + << FBB->getName().str() << "\n"; + else dbgs() << "InsertBranch: FBB: (NULL)\n"); + DEBUG(dbgs() << "InsertBranch: Cond size: " << Cond.size() << "\n"); + + assert(TBB && "TBB is NULL"); + + if (FBB) { + BuildMI(&MBB, DL, get(PTX::BRAdp)) + .addMBB(TBB).addReg(Cond[0].getReg()).addImm(Cond[1].getImm()); + BuildMI(&MBB, DL, get(PTX::BRAd)) + .addMBB(FBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NORMAL); + return 2; + } else if (Cond.size()) { + BuildMI(&MBB, DL, get(PTX::BRAdp)) + .addMBB(TBB).addReg(Cond[0].getReg()).addImm(Cond[1].getImm()); + return 1; + } else { + BuildMI(&MBB, DL, get(PTX::BRAd)) + .addMBB(TBB).addReg(PTX::NoRegister).addImm(PTX::PRED_NORMAL); + return 1; + } +} + // static helper routines MachineSDNode *PTXInstrInfo:: @@ -187,7 +311,28 @@ void PTXInstrInfo::AddDefaultPredicate(MachineInstr *MI) { if (MI->findFirstPredOperandIdx() == -1) { - MI->addOperand(MachineOperand::CreateReg(0, /*IsDef=*/false)); + MI->addOperand(MachineOperand::CreateReg(PTX::NoRegister, /*IsDef=*/false)); MI->addOperand(MachineOperand::CreateImm(PTX::PRED_NORMAL)); } } + +bool PTXInstrInfo::IsAnyKindOfBranch(const MachineInstr& inst) { + const TargetInstrDesc &desc = inst.getDesc(); + return desc.isTerminator() || desc.isBranch() || desc.isIndirectBranch(); +} + +bool PTXInstrInfo:: +IsAnySuccessorAlsoLayoutSuccessor(const MachineBasicBlock& MBB) { + for (MachineBasicBlock::const_succ_iterator + i = MBB.succ_begin(), e = MBB.succ_end(); i != e; ++i) + if (MBB.isLayoutSuccessor((const MachineBasicBlock*) &*i)) + return true; + return false; +} + +MachineBasicBlock *PTXInstrInfo::GetBranchTarget(const MachineInstr& inst) { + // FIXME So far all branch instructions put destination in 1st operand + const MachineOperand& target = inst.getOperand(0); + assert(target.isMBB() && "FIXME: detect branch target operand"); + return target.getMBB(); +} Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.h?rev=128084&r1=128083&r2=128084&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.h (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.h Tue Mar 22 09:12:00 2011 @@ -70,6 +70,20 @@ // PTX is fully-predicable virtual bool isPredicable(MachineInstr *MI) const { return true; } + // branch support + + virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, + MachineBasicBlock *&FBB, + SmallVectorImpl &Cond, + bool AllowModify = false) const; + + virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const; + + virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, + MachineBasicBlock *FBB, + const SmallVectorImpl &Cond, + DebugLoc DL) const; + // static helper routines static MachineSDNode *GetPTXMachineNode(SelectionDAG *DAG, unsigned Opcode, @@ -81,6 +95,12 @@ SDValue Op1, SDValue Op2); static void AddDefaultPredicate(MachineInstr *MI); + + static bool IsAnyKindOfBranch(const MachineInstr& inst); + + static bool IsAnySuccessorAlsoLayoutSuccessor(const MachineBasicBlock& MBB); + + static MachineBasicBlock *GetBranchTarget(const MachineInstr& inst); }; // class PTXInstrInfo } // namespace llvm Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=128084&r1=128083&r2=128084&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Tue Mar 22 09:12:00 2011 @@ -575,10 +575,12 @@ ///===- Control Flow Instructions -----------------------------------------===// -let isBranch = 1, isTerminator = 1 in { +let isBranch = 1, isTerminator = 1, isBarrier = 1 in { def BRAd : InstPTX<(outs), (ins brtarget:$d), "bra\t$d", [(br bb:$d)]>; +} +let isBranch = 1, isTerminator = 1 in { // FIXME: should be able to write a pattern for brcond, but can't use // a two-value operand where a dag node expects two operands. :( // NOTE: ARM & PowerPC backend also report the same problem Modified: llvm/trunk/test/CodeGen/PTX/bra.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/bra.ll?rev=128084&r1=128083&r2=128084&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/bra.ll (original) +++ llvm/trunk/test/CodeGen/PTX/bra.ll Tue Mar 22 09:12:00 2011 @@ -10,7 +10,10 @@ define ptx_device i32 @test_bra_cond_direct(i32 %x, i32 %y) { entry: +; CHECK: setp.le.u32 p0, r1, r2 %p = icmp ugt i32 %x, %y +; CHECK-NEXT: @p0 bra +; CHECK-NOT: bra br i1 %p, label %clause.if, label %clause.else clause.if: ; CHECK: mov.u32 r0, r1 From jay.foad at gmail.com Tue Mar 22 10:04:15 2011 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 22 Mar 2011 15:04:15 +0000 Subject: [llvm-commits] [PATCH] Constant operands are not Users Message-ID: There seems to be a slight misconception in the code that the operands of a Constant are always Users. This isn't true, since the operand of a BlockAddress constant is a BasicBlock, which isn't a User. This patch removes the anomalous code. Tested with "make check", LLVM and Clang. OK to commit? Thanks, Jay. -------------- next part -------------- A non-text attachment was scrubbed... Name: constant-operand-type.diff Type: text/x-patch Size: 1750 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110322/564f13ee/attachment.bin From bruno.cardoso at gmail.com Tue Mar 22 10:06:24 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 22 Mar 2011 15:06:24 -0000 Subject: [llvm-commits] [llvm] r128085 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <20110322150624.EE38E2A6C12C@llvm.org> Author: bruno Date: Tue Mar 22 10:06:24 2011 New Revision: 128085 URL: http://llvm.org/viewvc/llvm-project?rev=128085&view=rev Log: Change MRC and MRC2 instructions to model the output register properly Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=128085&r1=128084&r2=128085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Mar 22 10:06:24 2011 @@ -3489,10 +3489,9 @@ // Move between coprocessor and ARM core register -- for disassembly only // -class MovRCopro - : ABI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), - NoItinerary, opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", +class MovRCopro + : ABI<0b1110, oops, iops, NoItinerary, opc, + "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", [/* For disassembly only; pattern left blank */]> { let Inst{20} = direction; let Inst{4} = 1; @@ -3512,13 +3511,17 @@ let Inst{19-16} = CRn; } -def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */>; -def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */>; - -class MovRCopro2 - : ABXI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), - NoItinerary, !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), +def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */, + (outs), (ins p_imm:$cop, i32imm:$opc1, + GPR:$Rt, c_imm:$CRn, c_imm:$CRm, + i32imm:$opc2)>; +def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */, + (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, + c_imm:$CRn, c_imm:$CRm, i32imm:$opc2)>; + +class MovRCopro2 + : ABXI<0b1110, oops, iops, NoItinerary, + !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), [/* For disassembly only; pattern left blank */]> { let Inst{31-28} = 0b1111; let Inst{20} = direction; @@ -3539,8 +3542,14 @@ let Inst{19-16} = CRn; } -def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */>; -def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */>; +def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */, + (outs), (ins p_imm:$cop, i32imm:$opc1, + GPR:$Rt, c_imm:$CRn, c_imm:$CRm, + i32imm:$opc2)>; +def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */, + (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, + c_imm:$CRn, c_imm:$CRm, + i32imm:$opc2)>; class MovRRCopro : ABI<0b1100, (outs), (ins p_imm:$cop, i32imm:$opc1, Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=128085&r1=128084&r2=128085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Mar 22 10:06:24 2011 @@ -1322,10 +1322,8 @@ // Move between coprocessor and ARM core register -- for disassembly only // -class tMovRCopro - : T1Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), - !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), +class tMovRCopro + : T1Cop { let Inst{27-24} = 0b1110; let Inst{20} = direction; @@ -1346,8 +1344,12 @@ let Inst{19-16} = CRn; } -def tMCR : tMovRCopro<"mcr", 0 /* from ARM core register to coprocessor */>; -def tMRC : tMovRCopro<"mrc", 1 /* from coprocessor to ARM core register */>; +def tMCR : tMovRCopro<"mcr", 0 /* from ARM core register to coprocessor */, + (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2)>; +def tMRC : tMovRCopro<"mrc", 1 /* from coprocessor to ARM core register */, + (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2)>; class tMovRRCopro : T1Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=128085&r1=128084&r2=128085&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Mar 22 10:06:24 2011 @@ -3330,10 +3330,8 @@ // Move between coprocessor and ARM core register -- for disassembly only // -class t2MovRCopro - : T2Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, - GPR:$Rt, c_imm:$CRn, c_imm:$CRm, i32imm:$opc2), - !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), +class t2MovRCopro + : T2Cop { let Inst{27-24} = 0b1110; let Inst{20} = direction; @@ -3354,8 +3352,12 @@ let Inst{19-16} = CRn; } -def t2MCR2 : t2MovRCopro<"mcr2", 0 /* from ARM core register to coprocessor */>; -def t2MRC2 : t2MovRCopro<"mrc2", 1 /* from coprocessor to ARM core register */>; +def t2MCR2 : t2MovRCopro<"mcr2", 0 /* from ARM core register to coprocessor */, + (outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2)>; +def t2MRC2 : t2MovRCopro<"mrc2", 1 /* from coprocessor to ARM core register */, + (outs GPR:$Rt), (ins p_imm:$cop, i32imm:$opc1, c_imm:$CRn, + c_imm:$CRm, i32imm:$opc2)>; class t2MovRRCopro : T2Cop<(outs), (ins p_imm:$cop, i32imm:$opc1, GPR:$Rt, GPR:$Rt2, c_imm:$CRm), From grosbach at apple.com Tue Mar 22 10:21:58 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 15:21:58 -0000 Subject: [llvm-commits] [llvm] r128086 - in /llvm/trunk/lib/ExecutionEngine/JIT: Intercept.cpp JITDwarfEmitter.cpp JITDwarfEmitter.h OProfileJITEventListener.cpp TargetSelect.cpp Message-ID: <20110322152158.B132B2A6C12C@llvm.org> Author: grosbach Date: Tue Mar 22 10:21:58 2011 New Revision: 128086 URL: http://llvm.org/viewvc/llvm-project?rev=128086&view=rev Log: Trailing whitespace. Modified: llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.h llvm/trunk/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp?rev=128086&r1=128085&r2=128086&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/Intercept.cpp Tue Mar 22 10:21:58 2011 @@ -52,8 +52,8 @@ #include #endif #include -/* stat functions are redirecting to __xstat with a version number. On x86-64 - * linking with libc_nonshared.a and -Wl,--export-dynamic doesn't make 'stat' +/* stat functions are redirecting to __xstat with a version number. On x86-64 + * linking with libc_nonshared.a and -Wl,--export-dynamic doesn't make 'stat' * available as an exported symbol, so we have to add it explicitly. */ namespace { @@ -119,18 +119,18 @@ const char *NameStr = Name.c_str(); // If this is an asm specifier, skip the sentinal. if (NameStr[0] == 1) ++NameStr; - + // If it's an external function, look it up in the process image... void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr); if (Ptr) return Ptr; - + // If it wasn't found and if it starts with an underscore ('_') character, // and has an asm specifier, try again without the underscore. if (Name[0] == 1 && NameStr[0] == '_') { Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1); if (Ptr) return Ptr; } - + // Darwin/PPC adds $LDBLStub suffixes to various symbols like printf. These // are references to hidden visibility symbols that dlsym cannot resolve. // If we have one of these, strip off $LDBLStub and try again. @@ -147,7 +147,7 @@ } #endif } - + /// If a LazyFunctionCreator is installed, use it to get/create the function. if (LazyFunctionCreator) if (void *RP = LazyFunctionCreator(Name)) Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp?rev=128086&r1=128085&r2=128086&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp Tue Mar 22 10:21:58 2011 @@ -34,7 +34,7 @@ JITDwarfEmitter::JITDwarfEmitter(JIT& theJit) : MMI(0), Jit(theJit) {} -unsigned char* JITDwarfEmitter::EmitDwarfTable(MachineFunction& F, +unsigned char* JITDwarfEmitter::EmitDwarfTable(MachineFunction& F, JITCodeEmitter& jce, unsigned char* StartFunction, unsigned char* EndFunction, @@ -47,10 +47,10 @@ RI = TM.getRegisterInfo(); TFI = TM.getFrameLowering(); JCE = &jce; - + unsigned char* ExceptionTable = EmitExceptionTable(&F, StartFunction, EndFunction); - + unsigned char* Result = 0; const std::vector Personalities = MMI->getPersonalities(); @@ -63,7 +63,7 @@ } -void +void JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr, const std::vector &Moves) const { unsigned PointerSize = TD->getPointerSize(); @@ -74,26 +74,26 @@ for (unsigned i = 0, N = Moves.size(); i < N; ++i) { const MachineMove &Move = Moves[i]; MCSymbol *Label = Move.getLabel(); - + // Throw out move if the label is invalid. if (Label && (*JCE->getLabelLocations())[Label] == 0) continue; - + intptr_t LabelPtr = 0; if (Label) LabelPtr = JCE->getLabelAddress(Label); const MachineLocation &Dst = Move.getDestination(); const MachineLocation &Src = Move.getSource(); - + // Advance row if new location. if (BaseLabelPtr && Label && BaseLabel != Label) { JCE->emitByte(dwarf::DW_CFA_advance_loc4); JCE->emitInt32(LabelPtr - BaseLabelPtr); - - BaseLabel = Label; + + BaseLabel = Label; BaseLabelPtr = LabelPtr; } - + // If advancing cfa. if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) { if (!Src.isReg()) { @@ -103,7 +103,7 @@ JCE->emitByte(dwarf::DW_CFA_def_cfa); JCE->emitULEB128Bytes(RI->getDwarfRegNum(Src.getReg(), true)); } - + JCE->emitULEB128Bytes(-Src.getOffset()); } else { llvm_unreachable("Machine move not supported yet."); @@ -119,7 +119,7 @@ } else { unsigned Reg = RI->getDwarfRegNum(Src.getReg(), true); int Offset = Dst.getOffset() / stackGrowth; - + if (Offset < 0) { JCE->emitByte(dwarf::DW_CFA_offset_extended_sf); JCE->emitULEB128Bytes(Reg); @@ -382,7 +382,7 @@ unsigned TypeOffset = sizeof(int8_t) + // Call site format // Call-site table length - MCAsmInfo::getULEB128Size(SizeSites) + + MCAsmInfo::getULEB128Size(SizeSites) + SizeSites + SizeActions + SizeTypes; // Begin the exception table. @@ -452,7 +452,7 @@ // Emit the type ids. for (unsigned M = TypeInfos.size(); M; --M) { const GlobalVariable *GV = TypeInfos[M - 1]; - + if (GV) { if (TD->getPointerSize() == sizeof(int32_t)) JCE->emitInt32((intptr_t)Jit.getOrEmitGlobalVariable(GV)); @@ -484,7 +484,7 @@ unsigned PointerSize = TD->getPointerSize(); int stackGrowth = stackGrowthDirection == TargetFrameLowering::StackGrowsUp ? PointerSize : -PointerSize; - + unsigned char* StartCommonPtr = (unsigned char*)JCE->getCurrentPCValue(); // EH Common Frame header JCE->allocateSpace(4, 0); @@ -499,13 +499,13 @@ if (Personality) { // Augmentation Size: 3 small ULEBs of one byte each, and the personality // function which size is PointerSize. - JCE->emitULEB128Bytes(3 + PointerSize); - + JCE->emitULEB128Bytes(3 + PointerSize); + // We set the encoding of the personality as direct encoding because we use // the function pointer. The encoding is not relative because the current // PC value may be bigger than the personality function pointer. if (PointerSize == 4) { - JCE->emitByte(dwarf::DW_EH_PE_sdata4); + JCE->emitByte(dwarf::DW_EH_PE_sdata4); JCE->emitInt32(((intptr_t)Jit.getPointerToGlobal(Personality))); } else { JCE->emitByte(dwarf::DW_EH_PE_sdata8); @@ -540,11 +540,11 @@ unsigned char* JITDwarfEmitter::EmitEHFrame(const Function* Personality, unsigned char* StartCommonPtr, - unsigned char* StartFunction, + unsigned char* StartFunction, unsigned char* EndFunction, unsigned char* ExceptionTable) const { unsigned PointerSize = TD->getPointerSize(); - + // EH frame header. unsigned char* StartEHPtr = (unsigned char*)JCE->getCurrentPCValue(); JCE->allocateSpace(4, 0); @@ -558,7 +558,7 @@ // specific data area in the exception table. if (Personality) { JCE->emitULEB128Bytes(PointerSize == 4 ? 4 : 8); - + if (PointerSize == 4) { if (!MMI->getLandingPads().empty()) JCE->emitInt32(ExceptionTable-(unsigned char*)JCE->getCurrentPCValue()); @@ -573,7 +573,7 @@ } else { JCE->emitULEB128Bytes(0); } - + // Indicate locations of function specific callee saved registers in // frame. EmitFrameMoves((intptr_t)StartFunction, MMI->getFrameMoves()); @@ -593,6 +593,6 @@ JCE->emitInt32(0); JCE->emitInt32(0); } - + return StartEHPtr; } Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.h?rev=128086&r1=128085&r2=128086&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.h (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.h Tue Mar 22 10:21:58 2011 @@ -35,33 +35,33 @@ MachineModuleInfo* MMI; JIT& Jit; bool stackGrowthDirection; - + unsigned char* EmitExceptionTable(MachineFunction* MF, - unsigned char* StartFunction, + unsigned char* StartFunction, unsigned char* EndFunction) const; - void EmitFrameMoves(intptr_t BaseLabelPtr, + void EmitFrameMoves(intptr_t BaseLabelPtr, const std::vector &Moves) const; - + unsigned char* EmitCommonEHFrame(const Function* Personality) const; - unsigned char* EmitEHFrame(const Function* Personality, + unsigned char* EmitEHFrame(const Function* Personality, unsigned char* StartBufferPtr, - unsigned char* StartFunction, + unsigned char* StartFunction, unsigned char* EndFunction, unsigned char* ExceptionTable) const; - + public: - + JITDwarfEmitter(JIT& jit); - - unsigned char* EmitDwarfTable(MachineFunction& F, + + unsigned char* EmitDwarfTable(MachineFunction& F, JITCodeEmitter& JCE, unsigned char* StartFunction, unsigned char* EndFunction, unsigned char* &EHFramePtr); - - + + void setModuleInfo(MachineModuleInfo* Info) { MMI = Info; } Modified: llvm/trunk/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp?rev=128086&r1=128085&r2=128086&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp Tue Mar 22 10:21:58 2011 @@ -108,8 +108,8 @@ if (op_write_native_code(Agent, F.getName().data(), reinterpret_cast(FnStart), FnStart, FnSize) == -1) { - DEBUG(dbgs() << "Failed to tell OProfile about native function " - << F.getName() << " at [" + DEBUG(dbgs() << "Failed to tell OProfile about native function " + << F.getName() << " at [" << FnStart << "-" << ((char*)FnStart + FnSize) << "]\n"); return; } @@ -153,9 +153,9 @@ if (op_write_debug_line_info(Agent, FnStart, LineInfo.size(), &*LineInfo.begin()) == -1) { - DEBUG(dbgs() + DEBUG(dbgs() << "Failed to tell OProfile about line numbers for native function " - << F.getName() << " at [" + << F.getName() << " at [" << FnStart << "-" << ((char*)FnStart + FnSize) << "]\n"); } } Modified: llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp?rev=128086&r1=128085&r2=128086&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/TargetSelect.cpp Tue Mar 22 10:21:58 2011 @@ -84,7 +84,7 @@ } // Allocate a target... - TargetMachine *Target = + TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(), FeaturesStr); assert(Target && "Could not allocate target machine!"); return Target; From atrick at apple.com Tue Mar 22 12:03:02 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 22 Mar 2011 10:03:02 -0700 Subject: [llvm-commits] [llvm] r128036 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c In-Reply-To: <20110321231108.C01B42A6C12C@llvm.org> References: <20110321231108.C01B42A6C12C@llvm.org> Message-ID: We need to list all the targets that this test will pass. But I'm not sure where it's expected to pass/fail. See http://google1.osuosl.org:8011/builders/llvm-gcc-x86_64-linux-selfhost/builds/982 -Andy On Mar 21, 2011, at 4:11 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Mar 21 18:11:08 2011 > New Revision: 128036 > > URL: http://llvm.org/viewvc/llvm-project?rev=128036&view=rev > Log: > Try again to make this test darwin only. > > Modified: > llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c > > Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128036&r1=128035&r2=128036&view=diff > ============================================================================== > --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) > +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Mon Mar 21 18:11:08 2011 > @@ -1,5 +1,6 @@ > // RUN: %llvmgcc %s -m64 -S -O0 -o - | FileCheck %s > -// XTARGET: x86_64-apple-darwin > +// XFAIL: * > +// XTARGET: darwin > // Radar 9156771 > typedef struct RGBColor { > unsigned short red; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Tue Mar 22 12:44:31 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 22 Mar 2011 10:44:31 -0700 Subject: [llvm-commits] [llvm] r128020 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <20110321210827.A12562A6C12C@llvm.org> References: <20110321210827.A12562A6C12C@llvm.org> Message-ID: <8A710F37-9794-40D1-850E-A2C42B8894C4@apple.com> Why are you using #if 0 #endif? Evan On Mar 21, 2011, at 2:08 PM, Bill Wendling wrote: > Author: void > Date: Mon Mar 21 16:08:27 2011 > New Revision: 128020 > > URL: http://llvm.org/viewvc/llvm-project?rev=128020&view=rev > Log: > Call static functions so that they aren't left unused. > > Modified: > llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp > > Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=128020&r1=128019&r2=128020&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 16:08:27 2011 > @@ -847,7 +847,6 @@ > AliasMap[getQualifiedName(Op->getDef())].push_back(Alias); > } > > -#if 0 > // A map of which conditions need to be met for each instruction operand > // before it can be matched to the mnemonic. > std::map > IAPrinterMap; > @@ -930,15 +929,18 @@ > if (CantHandle) continue; > IAPrinterMap[I->first].push_back(IAP); > > +#if 0 > O.indent(4) << "// " << I->first << '\n'; > O.indent(4); > IAP->print(O); > +#endif > } > } > > + O << "#if 0\n"; > EmitSubtargetFeatureFlagEnumeration(AWI, O); > EmitComputeAvailableFeatures(AWI, AsmWriter, Target, O); > -#endif > + O << "#endif\n\n"; > > O << "bool " << Target.getName() << ClassName > << "::printAliasInstr(const " << MachineInstrClassName > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Tue Mar 22 13:05:27 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 18:05:27 -0000 Subject: [llvm-commits] [llvm] r128090 - in /llvm/trunk/lib/ExecutionEngine/MCJIT: CMakeLists.txt MCJIT.cpp MCJIT.h Message-ID: <20110322180527.65A0A2A6C12C@llvm.org> Author: grosbach Date: Tue Mar 22 13:05:27 2011 New Revision: 128090 URL: http://llvm.org/viewvc/llvm-project?rev=128090&view=rev Log: Add simple arg passing to MC-JIT and support for exit() call. Support argument passing simple, common, prototypes directly. More complicated scenarios will require building up a stub function, which the MC-JIT isn't set up to handle yet. Add Intercept.cpp, which is just a copy from ExecutionEngine/JIT for now, to handle looking looking up external symbol names. This probably more properly belongs as part of RuntimeDyld. It'll migrate there as things flesh out more fully. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt?rev=128090&r1=128089&r2=128090&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/CMakeLists.txt Tue Mar 22 13:05:27 2011 @@ -1,4 +1,5 @@ add_llvm_library(LLVMMCJIT MCJIT.cpp TargetSelect.cpp + Intercept.cpp ) Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=128090&r1=128089&r2=128090&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Tue Mar 22 13:05:27 2011 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "MCJIT.h" +#include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/MCJIT.h" @@ -101,6 +102,13 @@ } void *MCJIT::getPointerToFunction(Function *F) { + if (F->isDeclaration() || F->hasAvailableExternallyLinkage()) { + bool AbortOnFailure = !F->hasExternalWeakLinkage(); + void *Addr = getPointerToNamedFunction(F->getName(), AbortOnFailure); + addGlobalMapping(F, Addr); + return Addr; + } + Twine Name = TM->getMCAsmInfo()->getGlobalPrefix() + F->getName(); return Dyld.getSymbolAddress(Name.str()); } @@ -115,10 +123,102 @@ GenericValue MCJIT::runFunction(Function *F, const std::vector &ArgValues) { - assert(ArgValues.size() == 0 && "JIT arg passing not supported yet"); + assert(F && "Function *F was null at entry to run()"); + void *FPtr = getPointerToFunction(F); - if (!FPtr) - report_fatal_error("Unable to locate function: '" + F->getName() + "'"); - ((void(*)(void))(intptr_t)FPtr)(); + assert(FPtr && "Pointer to fn's code was null after getPointerToFunction"); + const FunctionType *FTy = F->getFunctionType(); + const Type *RetTy = FTy->getReturnType(); + + assert((FTy->getNumParams() == ArgValues.size() || + (FTy->isVarArg() && FTy->getNumParams() <= ArgValues.size())) && + "Wrong number of arguments passed into function!"); + assert(FTy->getNumParams() == ArgValues.size() && + "This doesn't support passing arguments through varargs (yet)!"); + + // Handle some common cases first. These cases correspond to common `main' + // prototypes. + if (RetTy->isIntegerTy(32) || RetTy->isVoidTy()) { + switch (ArgValues.size()) { + case 3: + if (FTy->getParamType(0)->isIntegerTy(32) && + FTy->getParamType(1)->isPointerTy() && + FTy->getParamType(2)->isPointerTy()) { + int (*PF)(int, char **, const char **) = + (int(*)(int, char **, const char **))(intptr_t)FPtr; + + // Call the function. + GenericValue rv; + rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(), + (char **)GVTOP(ArgValues[1]), + (const char **)GVTOP(ArgValues[2]))); + return rv; + } + break; + case 2: + if (FTy->getParamType(0)->isIntegerTy(32) && + FTy->getParamType(1)->isPointerTy()) { + int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr; + + // Call the function. + GenericValue rv; + rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue(), + (char **)GVTOP(ArgValues[1]))); + return rv; + } + break; + case 1: + if (FTy->getNumParams() == 1 && + FTy->getParamType(0)->isIntegerTy(32)) { + GenericValue rv; + int (*PF)(int) = (int(*)(int))(intptr_t)FPtr; + rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue())); + return rv; + } + break; + } + } + + // Handle cases where no arguments are passed first. + if (ArgValues.empty()) { + GenericValue rv; + switch (RetTy->getTypeID()) { + default: llvm_unreachable("Unknown return type for function call!"); + case Type::IntegerTyID: { + unsigned BitWidth = cast(RetTy)->getBitWidth(); + if (BitWidth == 1) + rv.IntVal = APInt(BitWidth, ((bool(*)())(intptr_t)FPtr)()); + else if (BitWidth <= 8) + rv.IntVal = APInt(BitWidth, ((char(*)())(intptr_t)FPtr)()); + else if (BitWidth <= 16) + rv.IntVal = APInt(BitWidth, ((short(*)())(intptr_t)FPtr)()); + else if (BitWidth <= 32) + rv.IntVal = APInt(BitWidth, ((int(*)())(intptr_t)FPtr)()); + else if (BitWidth <= 64) + rv.IntVal = APInt(BitWidth, ((int64_t(*)())(intptr_t)FPtr)()); + else + llvm_unreachable("Integer types > 64 bits not supported"); + return rv; + } + case Type::VoidTyID: + rv.IntVal = APInt(32, ((int(*)())(intptr_t)FPtr)()); + return rv; + case Type::FloatTyID: + rv.FloatVal = ((float(*)())(intptr_t)FPtr)(); + return rv; + case Type::DoubleTyID: + rv.DoubleVal = ((double(*)())(intptr_t)FPtr)(); + return rv; + case Type::X86_FP80TyID: + case Type::FP128TyID: + case Type::PPC_FP128TyID: + llvm_unreachable("long double not supported yet"); + return rv; + case Type::PointerTyID: + return PTOGV(((void*(*)())(intptr_t)FPtr)()); + } + } + + assert("Full-featured argument passing not supported yet!"); return GenericValue(); } Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=128090&r1=128089&r2=128090&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Tue Mar 22 13:05:27 2011 @@ -57,6 +57,16 @@ virtual GenericValue runFunction(Function *F, const std::vector &ArgValues); + /// getPointerToNamedFunction - This method returns the address of the + /// specified function by using the dlsym function call. As such it is only + /// useful for resolving library symbols, not code generated symbols. + /// + /// If AbortOnFailure is false and no function with the given name is + /// found, this function silently returns a null pointer. Otherwise, + /// it prints a message to stderr and aborts. + /// + void *getPointerToNamedFunction(const std::string &Name, + bool AbortOnFailure = true); /// @} /// @name (Private) Registration Interfaces /// @{ From grosbach at apple.com Tue Mar 22 13:19:42 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 18:19:42 -0000 Subject: [llvm-commits] [llvm] r128094 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/llvm-rtdyld.cpp Message-ID: <20110322181942.7B10F2A6C12C@llvm.org> Author: grosbach Date: Tue Mar 22 13:19:42 2011 New Revision: 128094 URL: http://llvm.org/viewvc/llvm-project?rev=128094&view=rev Log: Propogate the error message, not just the error state. Modified: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Modified: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=128094&r1=128093&r2=128094&view=diff ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (original) +++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Tue Mar 22 13:19:42 2011 @@ -38,6 +38,7 @@ // FIXME: Should be parameterized to get the memory block associated with // a particular loaded object. sys::MemoryBlock getMemoryBlock(); + StringRef getErrorString(); }; } // end namespace llvm Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128094&r1=128093&r2=128094&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Mar 22 13:19:42 2011 @@ -334,4 +334,9 @@ return Dyld->getMemoryBlock(); } +StringRef RuntimeDyld::getErrorString() +{ + return Dyld->getErrorString(); +} + } // end namespace llvm Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=128094&r1=128093&r2=128094&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original) +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Tue Mar 22 13:19:42 2011 @@ -63,8 +63,9 @@ RuntimeDyld Dyld; // Load the object file into it. - if (Dyld.loadObject(InputBuffer.take())) - return true; + if (Dyld.loadObject(InputBuffer.take())) { + return Error(Dyld.getErrorString()); + } // Get the address of "_main". void *MainAddress = Dyld.getSymbolAddress("_main"); From grosbach at apple.com Tue Mar 22 13:21:14 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 18:21:14 -0000 Subject: [llvm-commits] [llvm] r128095 - /llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp Message-ID: <20110322182114.7F7392A6C12C@llvm.org> Author: grosbach Date: Tue Mar 22 13:21:14 2011 New Revision: 128095 URL: http://llvm.org/viewvc/llvm-project?rev=128095&view=rev Log: Add missing file from previous commit. Added: llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp Added: llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp?rev=128095&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp (added) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/Intercept.cpp Tue Mar 22 13:21:14 2011 @@ -0,0 +1,161 @@ +//===-- Intercept.cpp - System function interception routines -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// If a function call occurs to an external function, the JIT is designed to use +// the dynamic loader interface to find a function to call. This is useful for +// calling system calls and library functions that are not available in LLVM. +// Some system calls, however, need to be handled specially. For this reason, +// we intercept some of them here and use our own stubs to handle them. +// +//===----------------------------------------------------------------------===// + +#include "MCJIT.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/DynamicLibrary.h" +#include "llvm/Config/config.h" +using namespace llvm; + +// AtExitHandlers - List of functions to call when the program exits, +// registered with the atexit() library function. +static std::vector AtExitHandlers; + +/// runAtExitHandlers - Run any functions registered by the program's +/// calls to atexit(3), which we intercept and store in +/// AtExitHandlers. +/// +static void runAtExitHandlers() { + while (!AtExitHandlers.empty()) { + void (*Fn)() = AtExitHandlers.back(); + AtExitHandlers.pop_back(); + Fn(); + } +} + +//===----------------------------------------------------------------------===// +// Function stubs that are invoked instead of certain library calls +//===----------------------------------------------------------------------===// + +// Force the following functions to be linked in to anything that uses the +// JIT. This is a hack designed to work around the all-too-clever Glibc +// strategy of making these functions work differently when inlined vs. when +// not inlined, and hiding their real definitions in a separate archive file +// that the dynamic linker can't see. For more info, search for +// 'libc_nonshared.a' on Google, or read http://llvm.org/PR274. +#if defined(__linux__) +#if defined(HAVE_SYS_STAT_H) +#include +#endif +#include +/* stat functions are redirecting to __xstat with a version number. On x86-64 + * linking with libc_nonshared.a and -Wl,--export-dynamic doesn't make 'stat' + * available as an exported symbol, so we have to add it explicitly. + */ +namespace { +class StatSymbols { +public: + StatSymbols() { + sys::DynamicLibrary::AddSymbol("stat", (void*)(intptr_t)stat); + sys::DynamicLibrary::AddSymbol("fstat", (void*)(intptr_t)fstat); + sys::DynamicLibrary::AddSymbol("lstat", (void*)(intptr_t)lstat); + sys::DynamicLibrary::AddSymbol("stat64", (void*)(intptr_t)stat64); + sys::DynamicLibrary::AddSymbol("\x1stat64", (void*)(intptr_t)stat64); + sys::DynamicLibrary::AddSymbol("\x1open64", (void*)(intptr_t)open64); + sys::DynamicLibrary::AddSymbol("\x1lseek64", (void*)(intptr_t)lseek64); + sys::DynamicLibrary::AddSymbol("fstat64", (void*)(intptr_t)fstat64); + sys::DynamicLibrary::AddSymbol("lstat64", (void*)(intptr_t)lstat64); + sys::DynamicLibrary::AddSymbol("atexit", (void*)(intptr_t)atexit); + sys::DynamicLibrary::AddSymbol("mknod", (void*)(intptr_t)mknod); + } +}; +} +static StatSymbols initStatSymbols; +#endif // __linux__ + +// jit_exit - Used to intercept the "exit" library call. +static void jit_exit(int Status) { + runAtExitHandlers(); // Run atexit handlers... + exit(Status); +} + +// jit_atexit - Used to intercept the "atexit" library call. +static int jit_atexit(void (*Fn)()) { + AtExitHandlers.push_back(Fn); // Take note of atexit handler... + return 0; // Always successful +} + +static int jit_noop() { + return 0; +} + +//===----------------------------------------------------------------------===// +// +/// getPointerToNamedFunction - This method returns the address of the specified +/// function by using the dynamic loader interface. As such it is only useful +/// for resolving library symbols, not code generated symbols. +/// +void *MCJIT::getPointerToNamedFunction(const std::string &Name, + bool AbortOnFailure) { + if (!isSymbolSearchingDisabled()) { + // Check to see if this is one of the functions we want to intercept. Note, + // we cast to intptr_t here to silence a -pedantic warning that complains + // about casting a function pointer to a normal pointer. + if (Name == "exit") return (void*)(intptr_t)&jit_exit; + if (Name == "atexit") return (void*)(intptr_t)&jit_atexit; + + // We should not invoke parent's ctors/dtors from generated main()! + // On Mingw and Cygwin, the symbol __main is resolved to + // callee's(eg. tools/lli) one, to invoke wrong duplicated ctors + // (and register wrong callee's dtors with atexit(3)). + // We expect ExecutionEngine::runStaticConstructorsDestructors() + // is called before ExecutionEngine::runFunctionAsMain() is called. + if (Name == "__main") return (void*)(intptr_t)&jit_noop; + + const char *NameStr = Name.c_str(); + // If this is an asm specifier, skip the sentinal. + if (NameStr[0] == 1) ++NameStr; + + // If it's an external function, look it up in the process image... + void *Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr); + if (Ptr) return Ptr; + + // If it wasn't found and if it starts with an underscore ('_') character, + // and has an asm specifier, try again without the underscore. + if (Name[0] == 1 && NameStr[0] == '_') { + Ptr = sys::DynamicLibrary::SearchForAddressOfSymbol(NameStr+1); + if (Ptr) return Ptr; + } + + // Darwin/PPC adds $LDBLStub suffixes to various symbols like printf. These + // are references to hidden visibility symbols that dlsym cannot resolve. + // If we have one of these, strip off $LDBLStub and try again. +#if defined(__APPLE__) && defined(__ppc__) + if (Name.size() > 9 && Name[Name.size()-9] == '$' && + memcmp(&Name[Name.size()-8], "LDBLStub", 8) == 0) { + // First try turning $LDBLStub into $LDBL128. If that fails, strip it off. + // This mirrors logic in libSystemStubs.a. + std::string Prefix = std::string(Name.begin(), Name.end()-9); + if (void *Ptr = getPointerToNamedFunction(Prefix+"$LDBL128", false)) + return Ptr; + if (void *Ptr = getPointerToNamedFunction(Prefix, false)) + return Ptr; + } +#endif + } + + /// If a LazyFunctionCreator is installed, use it to get/create the function. + if (LazyFunctionCreator) + if (void *RP = LazyFunctionCreator(Name)) + return RP; + + if (AbortOnFailure) { + report_fatal_error("Program used external function '"+Name+ + "' which could not be resolved!"); + } + return 0; +} From echristo at apple.com Tue Mar 22 13:25:52 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 22 Mar 2011 11:25:52 -0700 Subject: [llvm-commits] [llvm] r128094 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <20110322181942.7B10F2A6C12C@llvm.org> References: <20110322181942.7B10F2A6C12C@llvm.org> Message-ID: <14E42FD1-710B-414A-9A8B-1F08FC8359F7@apple.com> On Mar 22, 2011, at 11:19 AM, Jim Grosbach wrote: > +StringRef RuntimeDyld::getErrorString() > +{ > + return Dyld->getErrorString(); > +} Formatting ;) -eric From grosbach at apple.com Tue Mar 22 13:22:27 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 18:22:27 -0000 Subject: [llvm-commits] [llvm] r128096 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110322182227.E86A62A6C12C@llvm.org> Author: grosbach Date: Tue Mar 22 13:22:27 2011 New Revision: 128096 URL: http://llvm.org/viewvc/llvm-project?rev=128096&view=rev Log: Tidy up. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128096&r1=128095&r2=128096&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Tue Mar 22 13:22:27 2011 @@ -334,8 +334,7 @@ return Dyld->getMemoryBlock(); } -StringRef RuntimeDyld::getErrorString() -{ +StringRef RuntimeDyld::getErrorString() { return Dyld->getErrorString(); } From grosbach at apple.com Tue Mar 22 13:27:00 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 11:27:00 -0700 Subject: [llvm-commits] [llvm] r128094 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <14E42FD1-710B-414A-9A8B-1F08FC8359F7@apple.com> References: <20110322181942.7B10F2A6C12C@llvm.org> <14E42FD1-710B-414A-9A8B-1F08FC8359F7@apple.com> Message-ID: <336B17F9-7966-4306-A98E-5EFA2E2A42AE@apple.com> On Mar 22, 2011, at 11:25 AM, Eric Christopher wrote: > > On Mar 22, 2011, at 11:19 AM, Jim Grosbach wrote: > >> +StringRef RuntimeDyld::getErrorString() >> +{ >> + return Dyld->getErrorString(); >> +} > > Formatting ;) Every now and then old habits creep back in.... Thanks. r128096. From isanbard at gmail.com Tue Mar 22 14:20:17 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 22 Mar 2011 12:20:17 -0700 Subject: [llvm-commits] [llvm] r128020 - /llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp In-Reply-To: <8A710F37-9794-40D1-850E-A2C42B8894C4@apple.com> References: <20110321210827.A12562A6C12C@llvm.org> <8A710F37-9794-40D1-850E-A2C42B8894C4@apple.com> Message-ID: <19361B9D-F10F-4E0B-AD8A-5E7CD05BDBC8@gmail.com> It's not yet ready for prime time? :-) -bw On Mar 22, 2011, at 10:44 AM, Evan Cheng wrote: > Why are you using #if 0 #endif? > > Evan > > On Mar 21, 2011, at 2:08 PM, Bill Wendling wrote: > >> Author: void >> Date: Mon Mar 21 16:08:27 2011 >> New Revision: 128020 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128020&view=rev >> Log: >> Call static functions so that they aren't left unused. >> >> Modified: >> llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp >> >> Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=128020&r1=128019&r2=128020&view=diff >> ============================================================================== >> --- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original) >> +++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Mon Mar 21 16:08:27 2011 >> @@ -847,7 +847,6 @@ >> AliasMap[getQualifiedName(Op->getDef())].push_back(Alias); >> } >> >> -#if 0 >> // A map of which conditions need to be met for each instruction operand >> // before it can be matched to the mnemonic. >> std::map > IAPrinterMap; >> @@ -930,15 +929,18 @@ >> if (CantHandle) continue; >> IAPrinterMap[I->first].push_back(IAP); >> >> +#if 0 >> O.indent(4) << "// " << I->first << '\n'; >> O.indent(4); >> IAP->print(O); >> +#endif >> } >> } >> >> + O << "#if 0\n"; >> EmitSubtargetFeatureFlagEnumeration(AWI, O); >> EmitComputeAvailableFeatures(AWI, AsmWriter, Target, O); >> -#endif >> + O << "#endif\n\n"; >> >> O << "bool " << Target.getName() << ClassName >> << "::printAliasInstr(const " << MachineInstrClassName >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From atrick at apple.com Tue Mar 22 14:18:42 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 22 Mar 2011 19:18:42 -0000 Subject: [llvm-commits] [llvm] r128097 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/LiveDebugVariables.cpp test/CodeGen/X86/dbg-value-range.ll Message-ID: <20110322191843.127942A6C12C@llvm.org> Author: atrick Date: Tue Mar 22 14:18:42 2011 New Revision: 128097 URL: http://llvm.org/viewvc/llvm-project?rev=128097&view=rev Log: Revert r128045 and r128051, debug info enhancements. Temporarily reverting these to see if we can get llvm-objdump to link. Hopefully this is not the problem. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128097&r1=128096&r2=128097&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 22 14:18:42 2011 @@ -2424,7 +2424,8 @@ ME = DbgValues.end(); MI != ME; ++MI) { const MDNode *Var = (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); - if (Var == DV && !PrevMI->isIdenticalTo(*MI)) + if (Var == DV && + !PrevMI->isIdenticalTo(*MI)) MultipleValues.push_back(*MI); PrevMI = *MI; } @@ -2447,7 +2448,7 @@ DbgVariableToDbgInstMap[AbsVar] = MInsn; VarToAbstractVarMap[RegVar] = AbsVar; } - if (MultipleValues.size() <= 1 && !RegClobberInsn.count(MInsn)) { + if (MultipleValues.size() <= 1) { DbgVariableToDbgInstMap[RegVar] = MInsn; continue; } @@ -2457,11 +2458,16 @@ RegVar->setDotDebugLocOffset(0); else RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); - + const MachineInstr *Begin = NULL; + const MachineInstr *End = NULL; for (SmallVector::iterator MVI = MultipleValues.begin(), MVE = MultipleValues.end(); MVI != MVE; ++MVI) { - const MachineInstr *Begin = *MVI; + if (!Begin) { + Begin = *MVI; + continue; + } + End = *MVI; MachineLocation MLoc; if (Begin->getNumOperands() == 3) { if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm()) @@ -2469,25 +2475,25 @@ } else MLoc = Asm->getDebugValueLocation(Begin); - if (!MLoc.getReg()) - continue; - - // Compute the range for a register location. const MCSymbol *FLabel = getLabelBeforeInsn(Begin); - const MCSymbol *SLabel = 0; - - if (const MachineInstr *ClobberMI = RegClobberInsn.lookup(Begin)) - // The register range starting at Begin may be clobbered. - SLabel = getLabelAfterInsn(ClobberMI); - else if (MVI + 1 == MVE) - // If Begin is the last instruction then its value is valid + const MCSymbol *SLabel = getLabelBeforeInsn(End); + if (MLoc.getReg()) + DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); + + Begin = End; + if (MVI + 1 == MVE) { + // If End is the last instruction then its value is valid // until the end of the funtion. - SLabel = FunctionEndSym; - else - // The value is valid until the next DBG_VALUE. - SLabel = getLabelBeforeInsn(MVI[1]); - - DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); + MachineLocation EMLoc; + if (End->getNumOperands() == 3) { + if (End->getOperand(0).isReg() && Begin->getOperand(1).isImm()) + EMLoc.set(Begin->getOperand(0).getReg(), Begin->getOperand(1).getImm()); + } else + EMLoc = Asm->getDebugValueLocation(End); + if (EMLoc.getReg()) + DotDebugLocEntries. + push_back(DotDebugLocEntry(SLabel, FunctionEndSym, EMLoc)); + } } DotDebugLocEntries.push_back(DotDebugLocEntry()); } @@ -2562,7 +2568,7 @@ /// endInstruction - Process end of an instruction. void DwarfDebug::endInstruction(const MachineInstr *MI) { - if (InsnsNeedsLabelAfter.count(MI) != 0) { + if (InsnsEndScopeSet.count(MI) != 0) { // Emit a label if this instruction ends a scope. MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(Label); @@ -2827,7 +2833,7 @@ RE = Ranges.end(); RI != RE; ++RI) { assert(RI->first && "DbgRange does not have first instruction!"); assert(RI->second && "DbgRange does not have second instruction!"); - InsnsNeedsLabelAfter.insert(RI->second); + InsnsEndScopeSet.insert(RI->second); } } } @@ -2908,14 +2914,6 @@ /// ProcessedArgs - Collection of arguments already processed. SmallPtrSet ProcessedArgs; - /// LastDbgValue - Refer back to the last DBG_VALUE instruction to mention MD. - DenseMap LastDbgValue; - - const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); - - /// LiveUserVar - Map physreg numbers to the MDNode they contain. - std::vector LiveUserVar(TRI->getNumRegs()); - DebugLoc PrevLoc; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) @@ -2925,15 +2923,7 @@ DebugLoc DL = MI->getDebugLoc(); if (MI->isDebugValue()) { assert (MI->getNumOperands() > 1 && "Invalid machine instruction!"); - - // Keep track of variables in registers. - const MDNode *Var = - MI->getOperand(MI->getNumOperands() - 1).getMetadata(); - LastDbgValue[Var] = MI; - if (isDbgValueInDefinedReg(MI)) - LiveUserVar[MI->getOperand(0).getReg()] = Var; - - DIVariable DV(Var); + DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata()); if (!DV.Verify()) continue; // If DBG_VALUE is for a local variable then it needs a label. if (DV.getTag() != dwarf::DW_TAG_arg_variable) @@ -2954,32 +2944,6 @@ } else if (DL != PrevLoc) // Otherwise, instruction needs a location only if it is new location. InsnNeedsLabel.insert(MI); - - // Check if the instruction clobbers any registers with debug vars. - for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), - MOE = MI->operands_end(); MOI != MOE; ++MOI) { - if (!MOI->isReg() || !MOI->isDef() || !MOI->getReg()) - continue; - for (const unsigned *AI = TRI->getOverlaps(MOI->getReg()); - unsigned Reg = *AI; ++AI) { - const MDNode *Var = LiveUserVar[Reg]; - if (!Var) - continue; - // Reg is now clobbered. - LiveUserVar[Reg] = 0; - - // Was MD last defined by a DBG_VALUE referring to Reg? - const MachineInstr *Last = LastDbgValue.lookup(Var); - if (!Last || Last->getParent() != MI->getParent()) - continue; - if (!isDbgValueInDefinedReg(Last) || - Last->getOperand(0).getReg() != Reg) - continue; - // MD is clobbered. Make sure the next instruction gets a label. - InsnsNeedsLabelAfter.insert(MI); - RegClobberInsn[Last] = MI; - } - } } if (!DL.isUnknown() || UnknownLocations) @@ -3049,8 +3013,7 @@ VarToAbstractVarMap.clear(); DbgVariableToDbgInstMap.clear(); DeleteContainerSeconds(DbgScopeMap); - InsnsNeedsLabelAfter.clear(); - RegClobberInsn.clear(); + InsnsEndScopeSet.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128097&r1=128096&r2=128097&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Mar 22 14:18:42 2011 @@ -200,6 +200,8 @@ typedef SmallVector ScopeVector; + SmallPtrSet InsnsEndScopeSet; + /// InlineInfo - Keep track of inlined functions and their location. This /// information is used to populate debug_inlined section. typedef std::pair InlineInfoLabels; @@ -222,16 +224,6 @@ /// a debuggging information entity. SmallPtrSet InsnNeedsLabel; - /// InsnsNeedsLabelAfter - Collection of instructions that need a label after - /// the instruction because they end a scope of clobber a register. - SmallPtrSet InsnsNeedsLabelAfter; - - /// RegClobberInsn - For each DBG_VALUE instruction referring to a register - /// that is clobbered before the variable gets a new DBG_VALUE, map the - /// instruction that clobbered the register. This instruction will also be in - /// InsnsNeedsLabelAfter. - DenseMap RegClobberInsn; - SmallVector DebugRangeSymbols; /// Previous instruction's location information. This is used to determine Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=128097&r1=128096&r2=128097&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Tue Mar 22 14:18:42 2011 @@ -101,6 +101,10 @@ void insertDebugValue(MachineBasicBlock *MBB, SlotIndex Idx, unsigned LocNo, LiveIntervals &LIS, const TargetInstrInfo &TII); + /// insertDebugKill - Insert an undef DBG_VALUE into MBB at Idx. + void insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, + LiveIntervals &LIS, const TargetInstrInfo &TII); + public: /// UserValue - Create a new UserValue. UserValue(const MDNode *var, unsigned o, DebugLoc L, @@ -748,6 +752,13 @@ .addOperand(Loc).addImm(offset).addMetadata(variable); } +void UserValue::insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, + LiveIntervals &LIS, const TargetInstrInfo &TII) { + MachineBasicBlock::iterator I = findInsertLocation(MBB, Idx, LIS); + BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE)).addReg(0) + .addImm(offset).addMetadata(variable); +} + void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS, const TargetInstrInfo &TII) { MachineFunction::iterator MFEnd = VRM->getMachineFunction().end(); @@ -779,6 +790,12 @@ break; ++I; + if (Stop == MBBEnd) + continue; + // The current interval ends before MBB. + // Insert a kill if there is a gap. + if (!I.valid() || I.start() > Stop) + insertDebugKill(MBB, Stop, LIS, TII); } } Modified: llvm/trunk/test/CodeGen/X86/dbg-value-range.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-value-range.ll?rev=128097&r1=128096&r2=128097&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-value-range.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Tue Mar 22 14:18:42 2011 @@ -41,17 +41,15 @@ !18 = metadata !{i32 7, i32 2, metadata !12, null} !19 = metadata !{i32 8, i32 2, metadata !12, null} -; Check that variable bar:b value range is appropriately trucated in debug info. -; The variable is in %rdi which is clobbered by 'movl %ebx, %edi' -; Here Ltmp7 is the end of the location range. +; check that variable bar:b value range is appropriately trucated in debug info. Here Ltmp5 is end of +; location range. ;CHECK:Ltmp6 -;CHECK-NEXT: movl -;CHECK-NEXT: Ltmp7 +;CHECK-NEXT: DEBUG_VALUE: bar:b <- undef ;CHECK:Ldebug_loc0: ;CHECK-NEXT: .quad Ltmp -;CHECK-NEXT: .quad Ltmp7 +;CHECK-NEXT: .quad Ltmp6 ;CHECK-NEXT: .short 1 ;CHECK-NEXT: .byte 85 ;CHECK-NEXT: .quad 0 From rafael.espindola at gmail.com Tue Mar 22 14:20:47 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 22 Mar 2011 19:20:47 -0000 Subject: [llvm-commits] [llvm] r128098 - in /llvm/trunk: include/llvm/Support/MemoryBuffer.h lib/Support/MemoryBuffer.cpp tools/lto/LTOCodeGenerator.cpp Message-ID: <20110322192047.C2D762A6C12C@llvm.org> Author: rafael Date: Tue Mar 22 14:20:47 2011 New Revision: 128098 URL: http://llvm.org/viewvc/llvm-project?rev=128098&view=rev Log: We don't need a null terminator for the output file. Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h llvm/trunk/lib/Support/MemoryBuffer.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=128098&r1=128097&r2=128098&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original) +++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Tue Mar 22 14:20:47 2011 @@ -64,10 +64,12 @@ /// specified, this means that the client knows that the file exists and that /// it has the specified size. static error_code getFile(StringRef Filename, OwningPtr &result, - int64_t FileSize = -1); + int64_t FileSize = -1, + bool RequiresNullTerminator = true); static error_code getFile(const char *Filename, OwningPtr &result, - int64_t FileSize = -1); + int64_t FileSize = -1, + bool RequiresNullTerminator = true); /// getOpenFile - Given an already-open file descriptor, read the file and /// return a MemoryBuffer. Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=128098&r1=128097&r2=128098&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Mar 22 14:20:47 2011 @@ -196,15 +196,18 @@ error_code MemoryBuffer::getFile(StringRef Filename, OwningPtr &result, - int64_t FileSize) { + int64_t FileSize, + bool RequiresNullTerminator) { // Ensure the path is null terminated. SmallString<256> PathBuf(Filename.begin(), Filename.end()); - return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize); + return MemoryBuffer::getFile(PathBuf.c_str(), result, FileSize, + RequiresNullTerminator); } error_code MemoryBuffer::getFile(const char *Filename, OwningPtr &result, - int64_t FileSize) { + int64_t FileSize, + bool RequiresNullTerminator) { int OpenFlags = O_RDONLY; #ifdef O_BINARY OpenFlags |= O_BINARY; // Open input file in binary mode on win32. @@ -213,7 +216,8 @@ if (FD == -1) { return error_code(errno, posix_category()); } - error_code ret = getOpenFile(FD, Filename, result, FileSize); + error_code ret = getOpenFile(FD, Filename, result, FileSize, FileSize, + 0, RequiresNullTerminator); close(FD); return ret; } Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=128098&r1=128097&r2=128098&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Mar 22 14:20:47 2011 @@ -209,8 +209,11 @@ // read .o file into memory buffer OwningPtr BuffPtr; - if (error_code ec = MemoryBuffer::getFile(uniqueObjStr.c_str(),BuffPtr)) + if (error_code ec = MemoryBuffer::getFile(uniqueObjStr.c_str(), BuffPtr, + -1, false)) { errMsg = ec.message(); + return NULL; + } _nativeObjectFile = BuffPtr.take(); // remove temp files From isanbard at gmail.com Tue Mar 22 14:33:30 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 22 Mar 2011 19:33:30 -0000 Subject: [llvm-commits] [test-suite] r128099 - in /test-suite/branches/release_29: ./ MultiSource/Applications/lemon/Makefile Message-ID: <20110322193330.C0F952A6C12C@llvm.org> Author: void Date: Tue Mar 22 14:33:30 2011 New Revision: 128099 URL: http://llvm.org/viewvc/llvm-project?rev=128099&view=rev Log: --- Merging r128083 into '.': U MultiSource/Applications/lemon/Makefile Modified: test-suite/branches/release_29/ (props changed) test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile Propchange: test-suite/branches/release_29/ ------------------------------------------------------------------------------ svn:mergeinfo = /test-suite/trunk:128083 Modified: test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile?rev=128099&r1=128098&r2=128099&view=diff ============================================================================== --- test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile (original) +++ test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile Tue Mar 22 14:33:30 2011 @@ -6,6 +6,9 @@ RUN_OPTIONS = $(PROJ_SRC_DIR)/parse.y $(PROJ_SRC_DIR)/example1.y $(PROJ_SRC_DIR)/example2.y $(PROJ_SRC_DIR)/example3.y $(PROJ_SRC_DIR)/example4.y $(PROJ_SRC_DIR)/example5.y $(PROJ_SRC_DIR)/lighttpd_configparser.y $(PROJ_SRC_DIR)/lighttpd_mod_ssi_exprparser.y $(PROJ_SRC_DIR)/wireshark_dtd_grammar.lemon $(PROJ_SRC_DIR)/wireshark_grammar.lemon $(PROJ_SRC_DIR)/wireshark_mate_grammar.lemon $(PROJ_SRC_DIR)/xapian_queryparser.lemony $(PROJ_SRC_DIR)/ecmascript.y HASH_PROGRAM_OUTPUT = 1 +# With a Debug+Asserts build may time out if the default limit is used. +RUNTIMELIMIT := 750 + include $(LEVEL)/Makefile.config include ../../Makefile.multisrc From echristo at apple.com Tue Mar 22 14:39:17 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 22 Mar 2011 19:39:17 -0000 Subject: [llvm-commits] [llvm] r128100 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110322193917.636102A6C12C@llvm.org> Author: echristo Date: Tue Mar 22 14:39:17 2011 New Revision: 128100 URL: http://llvm.org/viewvc/llvm-project?rev=128100&view=rev Log: Migrate the fix in r128041 to ARM's fastisel support as well. Fixes rdar://9169640 Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=128100&r1=128099&r2=128100&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Tue Mar 22 14:39:17 2011 @@ -686,24 +686,29 @@ TmpOffset += SL->getElementOffset(Idx); } else { uint64_t S = TD.getTypeAllocSize(GTI.getIndexedType()); - SmallVector Worklist; - Worklist.push_back(Op); - do { - Op = Worklist.pop_back_val(); + for (;;) { if (const ConstantInt *CI = dyn_cast(Op)) { // Constant-offset addressing. TmpOffset += CI->getSExtValue() * S; - } else if (isa(Op) && - isa(cast(Op)->getOperand(1))) { - // An add with a constant operand. Fold the constant. + break; + } + if (isa(Op) && + (!isa(Op) || + FuncInfo.MBBMap[cast(Op)->getParent()] + == FuncInfo.MBB) && + isa(cast(Op)->getOperand(1))) { + // An add (in the same block) with a constant operand. Fold the + // constant. ConstantInt *CI = - cast(cast(Op)->getOperand(1)); + cast(cast(Op)->getOperand(1)); TmpOffset += CI->getSExtValue() * S; - // Add the other operand back to the work list. - Worklist.push_back(cast(Op)->getOperand(0)); - } else - goto unsupported_gep; - } while (!Worklist.empty()); + // Iterate on the other operand. + Op = cast(Op)->getOperand(0); + continue; + } + // Unsupported + goto unsupported_gep; + } } } From johnny.chen at apple.com Tue Mar 22 15:00:10 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Mar 2011 20:00:10 -0000 Subject: [llvm-commits] [llvm] r128103 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110322200010.78FE22A6C12C@llvm.org> Author: johnny Date: Tue Mar 22 15:00:10 2011 New Revision: 128103 URL: http://llvm.org/viewvc/llvm-project?rev=128103&view=rev Log: A8.6.399 VSTM: VFP Load/Store Multiple Instructions used to embed the IA/DB addressing mode within the MC instruction; that has been changed so that now, for example, VSTMDDB_UPD and VSTMDIA_UPD are two instructions. Update the ARMDisassemblerCore.cpp's DisassembleVFPLdStMulFrm() to reflect the change. Also add a test case. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128103&r1=128102&r2=128103&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Tue Mar 22 15:00:10 2011 @@ -1799,9 +1799,8 @@ } // VFP Load/Store Multiple Instructions. -// This is similar to the algorithm for LDM/STM in that operand 0 (the base) and -// operand 1 (the AM4 mode imm) is followed by two predicate operands. It is -// followed by a reglist of either DPR(s) or SPR(s). +// We have an optional write back reg, the base, and two predicate operands. +// It is then followed by a reglist of either DPR(s) or SPR(s). // // VLDMD[_UPD], VLDMS[_UPD], VSTMD[_UPD], VSTMS[_UPD] static bool DisassembleVFPLdStMulFrm(MCInst &MI, unsigned Opcode, uint32_t insn, @@ -1826,15 +1825,6 @@ MI.addOperand(MCOperand::CreateReg(Base)); - // Next comes the AM4 Opcode. - ARM_AM::AMSubMode SubMode = getAMSubModeForBits(getPUBits(insn)); - // Must be either "ia" or "db" submode. - if (SubMode != ARM_AM::ia && SubMode != ARM_AM::db) { - DEBUG(errs() << "Illegal addressing mode 4 sub-mode!\n"); - return false; - } - MI.addOperand(MCOperand::CreateImm(ARM_AM::getAM4ModeImm(SubMode))); - // Handling the two predicate operands before the reglist. int64_t CondVal = insn >> ARMII::CondShift; MI.addOperand(MCOperand::CreateImm(CondVal == 0xF ? 0xE : CondVal)); Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128103&r1=128102&r2=128103&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Tue Mar 22 15:00:10 2011 @@ -130,3 +130,6 @@ # CHECK: blx #-4 0xff 0xf7 0xfe 0xef + +# CHECK: vpush {d8, d9, d10} +0x2d 0xed 0x06 0x8b From jan_sjodin at yahoo.com Tue Mar 22 15:04:35 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 22 Mar 2011 13:04:35 -0700 (PDT) Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <20110321221553.0D84D2A6C12C@llvm.org> References: <20110321221553.0D84D2A6C12C@llvm.org> Message-ID: <180608.55464.qm@web55606.mail.re4.yahoo.com> Are you planning to add support for ELF also? - Jan ________________________________ From: Jim Grosbach To: llvm-commits at cs.uiuc.edu Sent: Mon, March 21, 2011 6:15:52 PM Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp Author: grosbach Date: Mon Mar 21 17:15:52 2011 New Revision: 128031 URL: http://llvm.org/viewvc/llvm-project?rev=128031&view=rev Log: Library-ize the dyld components of llvm-rtdyld. Move the dynamic linking functionality of the llvm-rtdyld program into an ExecutionEngine support library. Update llvm-rtdyld to just load an object file into memory, use the library to process it, then run the _main() function, if one is found. Added: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/Makefile llvm/trunk/tools/llvm-rtdyld/Makefile llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Added: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=128031&view=auto ============================================================================== --- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (added) +++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Mon Mar 21 17:15:52 2011 @@ -0,0 +1,45 @@ +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Interface for the runtime dynamic linker facilities of the MC-JIT. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_RUNTIME_DYLD_H +#define LLVM_RUNTIME_DYLD_H + +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/Memory.h" + +namespace llvm { + +class RuntimeDyldImpl; +class MemoryBuffer; + +class RuntimeDyld { + RuntimeDyld(const RuntimeDyld &); // DO NOT IMPLEMENT + void operator=(const RuntimeDyld &); // DO NOT IMPLEMENT + + // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public + // interface. + RuntimeDyldImpl *Dyld; +public: + RuntimeDyld(); + ~RuntimeDyld(); + + bool loadObject(MemoryBuffer *InputBuffer); + void *getSymbolAddress(StringRef Name); + // FIXME: Should be parameterized to get the memory block associated with + // a particular loaded object. + sys::MemoryBlock getMemoryBlock(); +}; + +} // end namespace llvm + +#endif Modified: llvm/trunk/lib/ExecutionEngine/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Makefile?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/Makefile (original) +++ llvm/trunk/lib/ExecutionEngine/Makefile Mon Mar 21 17:15:52 2011 @@ -8,6 +8,6 @@ ##===----------------------------------------------------------------------===## LEVEL = ../.. LIBRARYNAME = LLVMExecutionEngine -PARALLEL_DIRS = Interpreter JIT MCJIT +PARALLEL_DIRS = Interpreter JIT MCJIT RuntimeDyld include $(LEVEL)/Makefile.common Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt Mon Mar 21 17:15:52 2011 @@ -0,0 +1,3 @@ +add_llvm_library(LLVMRuntimeDyld + RuntimeDyld.cpp + ) Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile Mon Mar 21 17:15:52 2011 @@ -0,0 +1,13 @@ +##===- lib/ExecutionEngine/MCJIT/Makefile ------------------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## + +LEVEL = ../../.. +LIBRARYNAME = LLVMRuntimeDyld + +include $(LEVEL)/Makefile.common Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128031&view=auto ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (added) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Mar 21 17:15:52 2011 @@ -0,0 +1,329 @@ +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implementation of the MC-JIT runtime dynamic linker. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" +#include "llvm/ExecutionEngine/RuntimeDyld.h" +#include "llvm/Object/MachOObject.h" +#include "llvm/Support/Memory.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/system_error.h" +using namespace llvm; +using namespace llvm::object; + +namespace llvm { +class RuntimeDyldImpl { + // Master symbol table. As modules are loaded and external symbols are + // resolved, their addresses are stored here. + StringMap SymbolTable; + + // FIXME: Should have multiple data blocks, one for each loaded chunk of + // compiled code. + sys::MemoryBlock Data; + + bool HasError; + std::string ErrorStr; + + // Set the error state and record an error string. + bool Error(const Twine &Msg) { + ErrorStr = Msg.str(); + HasError = true; + return true; + } + + bool loadSegment32(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC); + bool loadSegment64(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC); + +public: + bool loadObject(MemoryBuffer *InputBuffer); + + void *getSymbolAddress(StringRef Name) { + // Use lookup() rather than [] because we don't want to add an entry + // if there isn't one already, which the [] operator does. + return SymbolTable.lookup(Name); + } + + sys::MemoryBlock getMemoryBlock() { return Data; } + + // Is the linker in an error state? + bool hasError() { return HasError; } + + // Mark the error condition as handled and continue. + void clearError() { HasError = false; } + + // Get the error message. + StringRef getErrorString() { return ErrorStr; } +}; + + + +bool RuntimeDyldImpl:: +loadSegment32(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC) { + InMemoryStruct Segment32LC; + Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); + if (!Segment32LC) + return Error("unable to load segment load command"); + + // Map the segment into memory. + std::string ErrorStr; + Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); + if (!Data.base()) + return Error("unable to allocate memory block: '" + ErrorStr + "'"); + memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, + Segment32LC->FileSize).data(), + Segment32LC->FileSize); + memset((char*)Data.base() + Segment32LC->FileSize, 0, + Segment32LC->VMSize - Segment32LC->FileSize); + + // Bind the section indices to address. + void **SectionBases = new void*[Segment32LC->NumSections]; + for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { + InMemoryStruct Sect; + Obj->ReadSection(*SegmentLCI, i, Sect); + if (!Sect) + return Error("unable to load section: '" + Twine(i) + "'"); + + // FIXME: We don't support relocations yet. + if (Sect->NumRelocationTableEntries != 0) + return Error("not yet implemented: relocations!"); + + // FIXME: Improve check. + if (Sect->Flags != 0x80000400) + return Error("unsupported section type!"); + + SectionBases[i] = (char*) Data.base() + Sect->Address; + } + + // Bind all the symbols to address. + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { + InMemoryStruct STE; + Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); + if (!STE) + return Error("unable to read symbol: '" + Twine(i) + "'"); + if (STE->SectionIndex == 0) + return Error("unexpected undefined symbol!"); + + unsigned Index = STE->SectionIndex - 1; + if (Index >= Segment32LC->NumSections) + return Error("invalid section index for symbol: '" + Twine() + "'"); + + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + + // Get the section base address. + void *SectionBase = SectionBases[Index]; + + // Get the symbol address. + void *Address = (char*) SectionBase + STE->Value; + + // FIXME: Check the symbol type and flags. + if (STE->Type != 0xF) + return Error("unexpected symbol type!"); + if (STE->Flags != 0x0) + return Error("unexpected symbol type!"); + + SymbolTable[Name] = Address; + } + + delete SectionBases; + return false; +} + + +bool RuntimeDyldImpl:: +loadSegment64(const MachOObject *Obj, + const MachOObject::LoadCommandInfo *SegmentLCI, + const InMemoryStruct &SymtabLC) { + InMemoryStruct Segment64LC; + Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); + if (!Segment64LC) + return Error("unable to load segment load command"); + + // Map the segment into memory. + std::string ErrorStr; + Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); + if (!Data.base()) + return Error("unable to allocate memory block: '" + ErrorStr + "'"); + memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, + Segment64LC->FileSize).data(), + Segment64LC->FileSize); + memset((char*)Data.base() + Segment64LC->FileSize, 0, + Segment64LC->VMSize - Segment64LC->FileSize); + + // Bind the section indices to address. + void **SectionBases = new void*[Segment64LC->NumSections]; + for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { + InMemoryStruct Sect; + Obj->ReadSection64(*SegmentLCI, i, Sect); + if (!Sect) + return Error("unable to load section: '" + Twine(i) + "'"); + + // FIXME: We don't support relocations yet. + if (Sect->NumRelocationTableEntries != 0) + return Error("not yet implemented: relocations!"); + + // FIXME: Improve check. + if (Sect->Flags != 0x80000400) + return Error("unsupported section type!"); + + SectionBases[i] = (char*) Data.base() + Sect->Address; + } + + // Bind all the symbols to address. + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { + InMemoryStruct STE; + Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); + if (!STE) + return Error("unable to read symbol: '" + Twine(i) + "'"); + if (STE->SectionIndex == 0) + return Error("unexpected undefined symbol!"); + + unsigned Index = STE->SectionIndex - 1; + if (Index >= Segment64LC->NumSections) + return Error("invalid section index for symbol: '" + Twine() + "'"); + + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + + // Get the section base address. + void *SectionBase = SectionBases[Index]; + + // Get the symbol address. + void *Address = (char*) SectionBase + STE->Value; + + // FIXME: Check the symbol type and flags. + if (STE->Type != 0xF) + return Error("unexpected symbol type!"); + if (STE->Flags != 0x0) + return Error("unexpected symbol type!"); + + SymbolTable[Name] = Address; + } + + delete SectionBases; + return false; +} + + + +bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) { + // If the linker is in an error state, don't do anything. + if (hasError()) + return true; + // Load the Mach-O wrapper object. + std::string ErrorStr; + OwningPtr Obj( + MachOObject::LoadFromBuffer(InputBuffer, &ErrorStr)); + if (!Obj) + return Error("unable to load object: '" + ErrorStr + "'"); + + // Validate that the load commands match what we expect. + const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, + *DysymtabLCI = 0; + for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { + const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); + switch (LCI.Command.Type) { + case macho::LCT_Segment: + case macho::LCT_Segment64: + if (SegmentLCI) + return Error("unexpected input object (multiple segments)"); + SegmentLCI = &LCI; + break; + case macho::LCT_Symtab: + if (SymtabLCI) + return Error("unexpected input object (multiple symbol tables)"); + SymtabLCI = &LCI; + break; + case macho::LCT_Dysymtab: + if (DysymtabLCI) + return Error("unexpected input object (multiple symbol tables)"); + DysymtabLCI = &LCI; + break; + default: + return Error("unexpected input object (unexpected load command"); + } + } + + if (!SymtabLCI) + return Error("no symbol table found in object"); + if (!SegmentLCI) + return Error("no symbol table found in object"); + + // Read and register the symbol table data. + InMemoryStruct SymtabLC; + Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); + if (!SymtabLC) + return Error("unable to load symbol table load command"); + Obj->RegisterStringTable(*SymtabLC); + + // Read the dynamic link-edit information, if present (not present in static + // objects). + if (DysymtabLCI) { + InMemoryStruct DysymtabLC; + Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); + if (!DysymtabLC) + return Error("unable to load dynamic link-exit load command"); + + // FIXME: We don't support anything interesting yet. + if (DysymtabLC->LocalSymbolsIndex != 0) + return Error("NOT YET IMPLEMENTED: local symbol entries"); + if (DysymtabLC->ExternalSymbolsIndex != 0) + return Error("NOT YET IMPLEMENTED: non-external symbol entries"); + if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) + return Error("NOT YET IMPLEMENTED: undefined symbol entries"); + } + + // Load the segment load command. + if (SegmentLCI->Command.Type == macho::LCT_Segment) { + if (loadSegment32(Obj.get(), SegmentLCI, SymtabLC)) + return true; + } else { + if (loadSegment64(Obj.get(), SegmentLCI, SymtabLC)) + return true; + } + + return false; +} + + +//===----------------------------------------------------------------------===// +// RuntimeDyld class implementation +RuntimeDyld::RuntimeDyld() { + Dyld = new RuntimeDyldImpl; +} + +RuntimeDyld::~RuntimeDyld() { + delete Dyld; +} + +bool RuntimeDyld::loadObject(MemoryBuffer *InputBuffer) { + return Dyld->loadObject(InputBuffer); +} + +void *RuntimeDyld::getSymbolAddress(StringRef Name) { + return Dyld->getSymbolAddress(Name); +} + +sys::MemoryBlock RuntimeDyld::getMemoryBlock() { + return Dyld->getMemoryBlock(); +} + +} // end namespace llvm Modified: llvm/trunk/tools/llvm-rtdyld/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/Makefile?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/Makefile (original) +++ llvm/trunk/tools/llvm-rtdyld/Makefile Mon Mar 21 17:15:52 2011 @@ -18,6 +18,6 @@ # early so we can set up LINK_COMPONENTS before including Makefile.rules include $(LEVEL)/Makefile.config -LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object +LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object RuntimeDyld include $(LLVM_SRC_ROOT)/Makefile.rules Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=128031&r1=128030&r2=128031&view=diff ============================================================================== --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original) +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Mon Mar 21 17:15:52 2011 @@ -13,6 +13,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/Object/MachOObject.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" @@ -51,157 +52,6 @@ } /* *** */ -static bool -loadSegment32(const MachOObject *Obj, - sys::MemoryBlock &Data, - const MachOObject::LoadCommandInfo *SegmentLCI, - const InMemoryStruct &SymtabLC, - StringMap &SymbolTable) { - InMemoryStruct Segment32LC; - Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); - if (!Segment32LC) - return Error("unable to load segment load command"); - - // Map the segment into memory. - std::string ErrorStr; - Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); - if (!Data.base()) - return Error("unable to allocate memory block: '" + ErrorStr + "'"); - memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, - Segment32LC->FileSize).data(), - Segment32LC->FileSize); - memset((char*)Data.base() + Segment32LC->FileSize, 0, - Segment32LC->VMSize - Segment32LC->FileSize); - - // Bind the section indices to address. - void **SectionBases = new void*[Segment32LC->NumSections]; - for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { - InMemoryStruct Sect; - Obj->ReadSection(*SegmentLCI, i, Sect); - if (!Sect) - return Error("unable to load section: '" + Twine(i) + "'"); - - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); - - // FIXME: Improve check. - if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); - - SectionBases[i] = (char*) Data.base() + Sect->Address; - } - - // Bind all the symbols to address. - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { - InMemoryStruct STE; - Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); - if (!STE) - return Error("unable to read symbol: '" + Twine(i) + "'"); - if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); - - unsigned Index = STE->SectionIndex - 1; - if (Index >= Segment32LC->NumSections) - return Error("invalid section index for symbol: '" + Twine() + "'"); - - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - - // Get the section base address. - void *SectionBase = SectionBases[Index]; - - // Get the symbol address. - void *Address = (char*) SectionBase + STE->Value; - - // FIXME: Check the symbol type and flags. - if (STE->Type != 0xF) - return Error("unexpected symbol type!"); - if (STE->Flags != 0x0) - return Error("unexpected symbol type!"); - - SymbolTable[Name] = Address; - } - - delete SectionBases; - return false; -} - -static bool -loadSegment64(const MachOObject *Obj, - sys::MemoryBlock &Data, - const MachOObject::LoadCommandInfo *SegmentLCI, - const InMemoryStruct &SymtabLC, - StringMap &SymbolTable) { - InMemoryStruct Segment64LC; - Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); - if (!Segment64LC) - return Error("unable to load segment load command"); - - // Map the segment into memory. - std::string ErrorStr; - Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); - if (!Data.base()) - return Error("unable to allocate memory block: '" + ErrorStr + "'"); - memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, - Segment64LC->FileSize).data(), - Segment64LC->FileSize); - memset((char*)Data.base() + Segment64LC->FileSize, 0, - Segment64LC->VMSize - Segment64LC->FileSize); - - // Bind the section indices to address. - void **SectionBases = new void*[Segment64LC->NumSections]; - for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { - InMemoryStruct Sect; - Obj->ReadSection64(*SegmentLCI, i, Sect); - if (!Sect) - return Error("unable to load section: '" + Twine(i) + "'"); - - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); - - // FIXME: Improve check. - if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); - - SectionBases[i] = (char*) Data.base() + Sect->Address; - } - - // Bind all the symbols to address. - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { - InMemoryStruct STE; - Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); - if (!STE) - return Error("unable to read symbol: '" + Twine(i) + "'"); - if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); - - unsigned Index = STE->SectionIndex - 1; - if (Index >= Segment64LC->NumSections) - return Error("invalid section index for symbol: '" + Twine() + "'"); - - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - - // Get the section base address. - void *SectionBase = SectionBases[Index]; - - // Get the symbol address. - void *Address = (char*) SectionBase + STE->Value; - - // FIXME: Check the symbol type and flags. - if (STE->Type != 0xF) - return Error("unexpected symbol type!"); - if (STE->Flags != 0x0) - return Error("unexpected symbol type!"); - - SymbolTable[Name] = Address; - } - - delete SectionBases; - return false; -} static int executeInput() { // Load the input memory buffer. @@ -209,94 +59,28 @@ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFile, InputBuffer)) return Error("unable to read input: '" + ec.message() + "'"); - // Load the Mach-O wrapper object. - std::string ErrorStr; - OwningPtr Obj( - MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); - if (!Obj) - return Error("unable to load object: '" + ErrorStr + "'"); - - // Validate that the load commands match what we expect. - const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, - *DysymtabLCI = 0; - for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { - const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); - switch (LCI.Command.Type) { - case macho::LCT_Segment: - case macho::LCT_Segment64: - if (SegmentLCI) - return Error("unexpected input object (multiple segments)"); - SegmentLCI = &LCI; - break; - case macho::LCT_Symtab: - if (SymtabLCI) - return Error("unexpected input object (multiple symbol tables)"); - SymtabLCI = &LCI; - break; - case macho::LCT_Dysymtab: - if (DysymtabLCI) - return Error("unexpected input object (multiple symbol tables)"); - DysymtabLCI = &LCI; - break; - default: - return Error("unexpected input object (unexpected load command"); - } - } - - if (!SymtabLCI) - return Error("no symbol table found in object"); - if (!SegmentLCI) - return Error("no symbol table found in object"); - - // Read and register the symbol table data. - InMemoryStruct SymtabLC; - Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); - if (!SymtabLC) - return Error("unable to load symbol table load command"); - Obj->RegisterStringTable(*SymtabLC); - - // Read the dynamic link-edit information, if present (not present in static - // objects). - if (DysymtabLCI) { - InMemoryStruct DysymtabLC; - Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); - if (!DysymtabLC) - return Error("unable to load dynamic link-exit load command"); - - // FIXME: We don't support anything interesting yet. - if (DysymtabLC->LocalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: local symbol entries"); - if (DysymtabLC->ExternalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: non-external symbol entries"); - if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) - return Error("NOT YET IMPLEMENTED: undefined symbol entries"); - } + // Instantiate a dynamic linker. + RuntimeDyld Dyld; - // Load the segment load command. - sys::MemoryBlock Data; - StringMap SymbolTable; - if (SegmentLCI->Command.Type == macho::LCT_Segment) { - if (loadSegment32(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) - return true; - } else { - if (loadSegment64(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) - return true; - } + // Load the object file into it. + if (Dyld.loadObject(InputBuffer.take())) + return true; // Get the address of "_main". - StringMap::iterator it = SymbolTable.find("_main"); - if (it == SymbolTable.end()) + void *MainAddress = Dyld.getSymbolAddress("_main"); + if (MainAddress == 0) return Error("no definition for '_main'"); // Invalidate the instruction cache. + sys::MemoryBlock Data = Dyld.getMemoryBlock(); sys::Memory::InvalidateInstructionCache(Data.base(), Data.size()); // Make sure the memory is executable. + std::string ErrorStr; if (!sys::Memory::setExecutable(Data, &ErrorStr)) return Error("unable to mark function executable: '" + ErrorStr + "'"); // Dispatch to _main(). - void *MainAddress = it->second; errs() << "loaded '_main' at: " << MainAddress << "\n"; int (*Main)(int, const char**) = _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110322/3cf0e825/attachment-0001.html From johnny.chen at apple.com Tue Mar 22 15:21:08 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Mar 2011 20:21:08 -0000 Subject: [llvm-commits] [llvm] r128106 - /llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Message-ID: <20110322202108.537AD2A6C12C@llvm.org> Author: johnny Date: Tue Mar 22 15:21:08 2011 New Revision: 128106 URL: http://llvm.org/viewvc/llvm-project?rev=128106&view=rev Log: Add one more test case for VFP Load/Store Multiple (vpop). Modified: llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt?rev=128106&r1=128105&r2=128106&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Tue Mar 22 15:21:08 2011 @@ -59,3 +59,6 @@ # CHECK: vmov.f64 d0, #5.000000e-01 0x00 0x0b 0xb6 0xee + +# CHECK: vpop {d8} +0x02 0x8b 0xbd 0xec From grosbach at apple.com Tue Mar 22 15:32:34 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 13:32:34 -0700 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <180608.55464.qm@web55606.mail.re4.yahoo.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> Message-ID: <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> That depends on what you're looking to do. What specifically do you mean by supporting ELF? The code should work as-is on an ELF based system. It just needs the input object file to be a MachO. Even as this gets fleshed out to handle more things, it's only at the edges where the JITed code interfaces with external bits that there's likely to be any extra work required to run on an ELF based system, and that should be relatively self-contained. So if you mean whether this infrastructure should work on an ELF based host, then yes, at least most of it should work without modification. If you mean using ELF as a container instead of MachO, then no, I have no plans to do that. -Jim On Mar 22, 2011, at 1:04 PM, Jan Sjodin wrote: > Are you planning to add support for ELF also? > > - Jan > > From: Jim Grosbach > To: llvm-commits at cs.uiuc.edu > Sent: Mon, March 21, 2011 6:15:52 PM > Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp > > Author: grosbach > Date: Mon Mar 21 17:15:52 2011 > New Revision: 128031 > > URL: http://llvm.org/viewvc/llvm-project?rev=128031&view=rev > Log: > Library-ize the dyld components of llvm-rtdyld. > > Move the dynamic linking functionality of the llvm-rtdyld program into an > ExecutionEngine support library. Update llvm-rtdyld to just load an object > file into memory, use the library to process it, then run the _main() > function, if one is found. > > > Added: > llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h > llvm/trunk/lib/ExecutionEngine/RuntimeDyld/ > llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt > llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile > llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp > Modified: > llvm/trunk/lib/ExecutionEngine/Makefile > llvm/trunk/tools/llvm-rtdyld/Makefile > llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp > > Added: llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h?rev=128031&view=auto > ============================================================================== > --- llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h (added) > +++ llvm/trunk/include/llvm/ExecutionEngine/RuntimeDyld.h Mon Mar 21 17:15:52 2011 > @@ -0,0 +1,45 @@ > +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Interface for the runtime dynamic linker facilities of the MC-JIT. > +// > +//===----------------------------------------------------------------------===// > + > +#ifndef LLVM_RUNTIME_DYLD_H > +#define LLVM_RUNTIME_DYLD_H > + > +#include "llvm/ADT/StringRef.h" > +#include "llvm/Support/Memory.h" > + > +namespace llvm { > + > +class RuntimeDyldImpl; > +class MemoryBuffer; > + > +class RuntimeDyld { > + RuntimeDyld(const RuntimeDyld &); // DO NOT IMPLEMENT > + void operator=(const RuntimeDyld &); // DO NOT IMPLEMENT > + > + // RuntimeDyldImpl is the actual class. RuntimeDyld is just the public > + // interface. > + RuntimeDyldImpl *Dyld; > +public: > + RuntimeDyld(); > + ~RuntimeDyld(); > + > + bool loadObject(MemoryBuffer *InputBuffer); > + void *getSymbolAddress(StringRef Name); > + // FIXME: Should be parameterized to get the memory block associated with > + // a particular loaded object. > + sys::MemoryBlock getMemoryBlock(); > +}; > + > +} // end namespace llvm > + > +#endif > > Modified: llvm/trunk/lib/ExecutionEngine/Makefile > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Makefile?rev=128031&r1=128030&r2=128031&view=diff > ============================================================================== > --- llvm/trunk/lib/ExecutionEngine/Makefile (original) > +++ llvm/trunk/lib/ExecutionEngine/Makefile Mon Mar 21 17:15:52 2011 > @@ -8,6 +8,6 @@ > ##===----------------------------------------------------------------------===## > LEVEL = ../.. > LIBRARYNAME = LLVMExecutionEngine > -PARALLEL_DIRS = Interpreter JIT MCJIT > +PARALLEL_DIRS = Interpreter JIT MCJIT RuntimeDyld > > include $(LEVEL)/Makefile.common > > Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt?rev=128031&view=auto > ============================================================================== > --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt (added) > +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt Mon Mar 21 17:15:52 2011 > @@ -0,0 +1,3 @@ > +add_llvm_library(LLVMRuntimeDyld > + RuntimeDyld.cpp > + ) > > Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile?rev=128031&view=auto > ============================================================================== > --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile (added) > +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Makefile Mon Mar 21 17:15:52 2011 > @@ -0,0 +1,13 @@ > +##===- lib/ExecutionEngine/MCJIT/Makefile ------------------*- Makefile -*-===## > +# > +# The LLVM Compiler Infrastructure > +# > +# This file is distributed under the University of Illinois Open Source > +# License. See LICENSE.TXT for details. > +# > +##===----------------------------------------------------------------------===## > + > +LEVEL = ../../.. > +LIBRARYNAME = LLVMRuntimeDyld > + > +include $(LEVEL)/Makefile.common > > Added: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128031&view=auto > ============================================================================== > --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (added) > +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Mon Mar 21 17:15:52 2011 > @@ -0,0 +1,329 @@ > +//===-- RuntimeDyld.h - Run-time dynamic linker for MC-JIT ------*- C++ -*-===// > +// > +// The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Implementation of the MC-JIT runtime dynamic linker. > +// > +//===----------------------------------------------------------------------===// > + > +#include "llvm/ADT/OwningPtr.h" > +#include "llvm/ADT/StringMap.h" > +#include "llvm/ADT/StringRef.h" > +#include "llvm/ADT/Twine.h" > +#include "llvm/ExecutionEngine/RuntimeDyld.h" > +#include "llvm/Object/MachOObject.h" > +#include "llvm/Support/Memory.h" > +#include "llvm/Support/MemoryBuffer.h" > +#include "llvm/Support/system_error.h" > +using namespace llvm; > +using namespace llvm::object; > + > +namespace llvm { > +class RuntimeDyldImpl { > + // Master symbol table. As modules are loaded and external symbols are > + // resolved, their addresses are stored here. > + StringMap SymbolTable; > + > + // FIXME: Should have multiple data blocks, one for each loaded chunk of > + // compiled code. > + sys::MemoryBlock Data; > + > + bool HasError; > + std::string ErrorStr; > + > + // Set the error state and record an error string. > + bool Error(const Twine &Msg) { > + ErrorStr = Msg.str(); > + HasError = true; > + return true; > + } > + > + bool loadSegment32(const MachOObject *Obj, > + const MachOObject::LoadCommandInfo *SegmentLCI, > + const InMemoryStruct &SymtabLC); > + bool loadSegment64(const MachOObject *Obj, > + const MachOObject::LoadCommandInfo *SegmentLCI, > + const InMemoryStruct &SymtabLC); > + > +public: > + bool loadObject(MemoryBuffer *InputBuffer); > + > + void *getSymbolAddress(StringRef Name) { > + // Use lookup() rather than [] because we don't want to add an entry > + // if there isn't one already, which the [] operator does. > + return SymbolTable.lookup(Name); > + } > + > + sys::MemoryBlock getMemoryBlock() { return Data; } > + > + // Is the linker in an error state? > + bool hasError() { return HasError; } > + > + // Mark the error condition as handled and continue. > + void clearError() { HasError = false; } > + > + // Get the error message. > + StringRef getErrorString() { return ErrorStr; } > +}; > + > + > + > +bool RuntimeDyldImpl:: > +loadSegment32(const MachOObject *Obj, > + const MachOObject::LoadCommandInfo *SegmentLCI, > + const InMemoryStruct &SymtabLC) { > + InMemoryStruct Segment32LC; > + Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); > + if (!Segment32LC) > + return Error("unable to load segment load command"); > + > + // Map the segment into memory. > + std::string ErrorStr; > + Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); > + if (!Data.base()) > + return Error("unable to allocate memory block: '" + ErrorStr + "'"); > + memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, > + Segment32LC->FileSize).data(), > + Segment32LC->FileSize); > + memset((char*)Data.base() + Segment32LC->FileSize, 0, > + Segment32LC->VMSize - Segment32LC->FileSize); > + > + // Bind the section indices to address. > + void **SectionBases = new void*[Segment32LC->NumSections]; > + for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { > + InMemoryStruct Sect; > + Obj->ReadSection(*SegmentLCI, i, Sect); > + if (!Sect) > + return Error("unable to load section: '" + Twine(i) + "'"); > + > + // FIXME: We don't support relocations yet. > + if (Sect->NumRelocationTableEntries != 0) > + return Error("not yet implemented: relocations!"); > + > + // FIXME: Improve check. > + if (Sect->Flags != 0x80000400) > + return Error("unsupported section type!"); > + > + SectionBases[i] = (char*) Data.base() + Sect->Address; > + } > + > + // Bind all the symbols to address. > + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { > + InMemoryStruct STE; > + Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); > + if (!STE) > + return Error("unable to read symbol: '" + Twine(i) + "'"); > + if (STE->SectionIndex == 0) > + return Error("unexpected undefined symbol!"); > + > + unsigned Index = STE->SectionIndex - 1; > + if (Index >= Segment32LC->NumSections) > + return Error("invalid section index for symbol: '" + Twine() + "'"); > + > + // Get the symbol name. > + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); > + > + // Get the section base address. > + void *SectionBase = SectionBases[Index]; > + > + // Get the symbol address. > + void *Address = (char*) SectionBase + STE->Value; > + > + // FIXME: Check the symbol type and flags. > + if (STE->Type != 0xF) > + return Error("unexpected symbol type!"); > + if (STE->Flags != 0x0) > + return Error("unexpected symbol type!"); > + > + SymbolTable[Name] = Address; > + } > + > + delete SectionBases; > + return false; > +} > + > + > +bool RuntimeDyldImpl:: > +loadSegment64(const MachOObject *Obj, > + const MachOObject::LoadCommandInfo *SegmentLCI, > + const InMemoryStruct &SymtabLC) { > + InMemoryStruct Segment64LC; > + Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); > + if (!Segment64LC) > + return Error("unable to load segment load command"); > + > + // Map the segment into memory. > + std::string ErrorStr; > + Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); > + if (!Data.base()) > + return Error("unable to allocate memory block: '" + ErrorStr + "'"); > + memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, > + Segment64LC->FileSize).data(), > + Segment64LC->FileSize); > + memset((char*)Data.base() + Segment64LC->FileSize, 0, > + Segment64LC->VMSize - Segment64LC->FileSize); > + > + // Bind the section indices to address. > + void **SectionBases = new void*[Segment64LC->NumSections]; > + for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { > + InMemoryStruct Sect; > + Obj->ReadSection64(*SegmentLCI, i, Sect); > + if (!Sect) > + return Error("unable to load section: '" + Twine(i) + "'"); > + > + // FIXME: We don't support relocations yet. > + if (Sect->NumRelocationTableEntries != 0) > + return Error("not yet implemented: relocations!"); > + > + // FIXME: Improve check. > + if (Sect->Flags != 0x80000400) > + return Error("unsupported section type!"); > + > + SectionBases[i] = (char*) Data.base() + Sect->Address; > + } > + > + // Bind all the symbols to address. > + for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { > + InMemoryStruct STE; > + Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); > + if (!STE) > + return Error("unable to read symbol: '" + Twine(i) + "'"); > + if (STE->SectionIndex == 0) > + return Error("unexpected undefined symbol!"); > + > + unsigned Index = STE->SectionIndex - 1; > + if (Index >= Segment64LC->NumSections) > + return Error("invalid section index for symbol: '" + Twine() + "'"); > + > + // Get the symbol name. > + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); > + > + // Get the section base address. > + void *SectionBase = SectionBases[Index]; > + > + // Get the symbol address. > + void *Address = (char*) SectionBase + STE->Value; > + > + // FIXME: Check the symbol type and flags. > + if (STE->Type != 0xF) > + return Error("unexpected symbol type!"); > + if (STE->Flags != 0x0) > + return Error("unexpected symbol type!"); > + > + SymbolTable[Name] = Address; > + } > + > + delete SectionBases; > + return false; > +} > + > + > + > +bool RuntimeDyldImpl::loadObject(MemoryBuffer *InputBuffer) { > + // If the linker is in an error state, don't do anything. > + if (hasError()) > + return true; > + // Load the Mach-O wrapper object. > + std::string ErrorStr; > + OwningPtr Obj( > + MachOObject::LoadFromBuffer(InputBuffer, &ErrorStr)); > + if (!Obj) > + return Error("unable to load object: '" + ErrorStr + "'"); > + > + // Validate that the load commands match what we expect. > + const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, > + *DysymtabLCI = 0; > + for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { > + const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); > + switch (LCI.Command.Type) { > + case macho::LCT_Segment: > + case macho::LCT_Segment64: > + if (SegmentLCI) > + return Error("unexpected input object (multiple segments)"); > + SegmentLCI = &LCI; > + break; > + case macho::LCT_Symtab: > + if (SymtabLCI) > + return Error("unexpected input object (multiple symbol tables)"); > + SymtabLCI = &LCI; > + break; > + case macho::LCT_Dysymtab: > + if (DysymtabLCI) > + return Error("unexpected input object (multiple symbol tables)"); > + DysymtabLCI = &LCI; > + break; > + default: > + return Error("unexpected input object (unexpected load command"); > + } > + } > + > + if (!SymtabLCI) > + return Error("no symbol table found in object"); > + if (!SegmentLCI) > + return Error("no symbol table found in object"); > + > + // Read and register the symbol table data. > + InMemoryStruct SymtabLC; > + Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); > + if (!SymtabLC) > + return Error("unable to load symbol table load command"); > + Obj->RegisterStringTable(*SymtabLC); > + > + // Read the dynamic link-edit information, if present (not present in static > + // objects). > + if (DysymtabLCI) { > + InMemoryStruct DysymtabLC; > + Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); > + if (!DysymtabLC) > + return Error("unable to load dynamic link-exit load command"); > + > + // FIXME: We don't support anything interesting yet. > + if (DysymtabLC->LocalSymbolsIndex != 0) > + return Error("NOT YET IMPLEMENTED: local symbol entries"); > + if (DysymtabLC->ExternalSymbolsIndex != 0) > + return Error("NOT YET IMPLEMENTED: non-external symbol entries"); > + if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) > + return Error("NOT YET IMPLEMENTED: undefined symbol entries"); > + } > + > + // Load the segment load command. > + if (SegmentLCI->Command.Type == macho::LCT_Segment) { > + if (loadSegment32(Obj.get(), SegmentLCI, SymtabLC)) > + return true; > + } else { > + if (loadSegment64(Obj.get(), SegmentLCI, SymtabLC)) > + return true; > + } > + > + return false; > +} > + > + > +//===----------------------------------------------------------------------===// > +// RuntimeDyld class implementation > +RuntimeDyld::RuntimeDyld() { > + Dyld = new RuntimeDyldImpl; > +} > + > +RuntimeDyld::~RuntimeDyld() { > + delete Dyld; > +} > + > +bool RuntimeDyld::loadObject(MemoryBuffer *InputBuffer) { > + return Dyld->loadObject(InputBuffer); > +} > + > +void *RuntimeDyld::getSymbolAddress(StringRef Name) { > + return Dyld->getSymbolAddress(Name); > +} > + > +sys::MemoryBlock RuntimeDyld::getMemoryBlock() { > + return Dyld->getMemoryBlock(); > +} > + > +} // end namespace llvm > > Modified: llvm/trunk/tools/llvm-rtdyld/Makefile > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/Makefile?rev=128031&r1=128030&r2=128031&view=diff > ============================================================================== > --- llvm/trunk/tools/llvm-rtdyld/Makefile (original) > +++ llvm/trunk/tools/llvm-rtdyld/Makefile Mon Mar 21 17:15:52 2011 > @@ -18,6 +18,6 @@ > # early so we can set up LINK_COMPONENTS before including Makefile.rules > include $(LEVEL)/Makefile.config > > -LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object > +LINK_COMPONENTS := $(TARGETS_TO_BUILD) support MC object RuntimeDyld > > include $(LLVM_SRC_ROOT)/Makefile.rules > > Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=128031&r1=128030&r2=128031&view=diff > ============================================================================== > --- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original) > +++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Mon Mar 21 17:15:52 2011 > @@ -13,6 +13,7 @@ > > #include "llvm/ADT/StringMap.h" > #include "llvm/ADT/OwningPtr.h" > +#include "llvm/ExecutionEngine/RuntimeDyld.h" > #include "llvm/Object/MachOObject.h" > #include "llvm/Support/CommandLine.h" > #include "llvm/Support/ManagedStatic.h" > @@ -51,157 +52,6 @@ > } > > /* *** */ > -static bool > -loadSegment32(const MachOObject *Obj, > - sys::MemoryBlock &Data, > - const MachOObject::LoadCommandInfo *SegmentLCI, > - const InMemoryStruct &SymtabLC, > - StringMap &SymbolTable) { > - InMemoryStruct Segment32LC; > - Obj->ReadSegmentLoadCommand(*SegmentLCI, Segment32LC); > - if (!Segment32LC) > - return Error("unable to load segment load command"); > - > - // Map the segment into memory. > - std::string ErrorStr; > - Data = sys::Memory::AllocateRWX(Segment32LC->VMSize, 0, &ErrorStr); > - if (!Data.base()) > - return Error("unable to allocate memory block: '" + ErrorStr + "'"); > - memcpy(Data.base(), Obj->getData(Segment32LC->FileOffset, > - Segment32LC->FileSize).data(), > - Segment32LC->FileSize); > - memset((char*)Data.base() + Segment32LC->FileSize, 0, > - Segment32LC->VMSize - Segment32LC->FileSize); > - > - // Bind the section indices to address. > - void **SectionBases = new void*[Segment32LC->NumSections]; > - for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { > - InMemoryStruct Sect; > - Obj->ReadSection(*SegmentLCI, i, Sect); > - if (!Sect) > - return Error("unable to load section: '" + Twine(i) + "'"); > - > - // FIXME: We don't support relocations yet. > - if (Sect->NumRelocationTableEntries != 0) > - return Error("not yet implemented: relocations!"); > - > - // FIXME: Improve check. > - if (Sect->Flags != 0x80000400) > - return Error("unsupported section type!"); > - > - SectionBases[i] = (char*) Data.base() + Sect->Address; > - } > - > - // Bind all the symbols to address. > - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { > - InMemoryStruct STE; > - Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); > - if (!STE) > - return Error("unable to read symbol: '" + Twine(i) + "'"); > - if (STE->SectionIndex == 0) > - return Error("unexpected undefined symbol!"); > - > - unsigned Index = STE->SectionIndex - 1; > - if (Index >= Segment32LC->NumSections) > - return Error("invalid section index for symbol: '" + Twine() + "'"); > - > - // Get the symbol name. > - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); > - > - // Get the section base address. > - void *SectionBase = SectionBases[Index]; > - > - // Get the symbol address. > - void *Address = (char*) SectionBase + STE->Value; > - > - // FIXME: Check the symbol type and flags. > - if (STE->Type != 0xF) > - return Error("unexpected symbol type!"); > - if (STE->Flags != 0x0) > - return Error("unexpected symbol type!"); > - > - SymbolTable[Name] = Address; > - } > - > - delete SectionBases; > - return false; > -} > - > -static bool > -loadSegment64(const MachOObject *Obj, > - sys::MemoryBlock &Data, > - const MachOObject::LoadCommandInfo *SegmentLCI, > - const InMemoryStruct &SymtabLC, > - StringMap &SymbolTable) { > - InMemoryStruct Segment64LC; > - Obj->ReadSegment64LoadCommand(*SegmentLCI, Segment64LC); > - if (!Segment64LC) > - return Error("unable to load segment load command"); > - > - // Map the segment into memory. > - std::string ErrorStr; > - Data = sys::Memory::AllocateRWX(Segment64LC->VMSize, 0, &ErrorStr); > - if (!Data.base()) > - return Error("unable to allocate memory block: '" + ErrorStr + "'"); > - memcpy(Data.base(), Obj->getData(Segment64LC->FileOffset, > - Segment64LC->FileSize).data(), > - Segment64LC->FileSize); > - memset((char*)Data.base() + Segment64LC->FileSize, 0, > - Segment64LC->VMSize - Segment64LC->FileSize); > - > - // Bind the section indices to address. > - void **SectionBases = new void*[Segment64LC->NumSections]; > - for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { > - InMemoryStruct Sect; > - Obj->ReadSection64(*SegmentLCI, i, Sect); > - if (!Sect) > - return Error("unable to load section: '" + Twine(i) + "'"); > - > - // FIXME: We don't support relocations yet. > - if (Sect->NumRelocationTableEntries != 0) > - return Error("not yet implemented: relocations!"); > - > - // FIXME: Improve check. > - if (Sect->Flags != 0x80000400) > - return Error("unsupported section type!"); > - > - SectionBases[i] = (char*) Data.base() + Sect->Address; > - } > - > - // Bind all the symbols to address. > - for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { > - InMemoryStruct STE; > - Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); > - if (!STE) > - return Error("unable to read symbol: '" + Twine(i) + "'"); > - if (STE->SectionIndex == 0) > - return Error("unexpected undefined symbol!"); > - > - unsigned Index = STE->SectionIndex - 1; > - if (Index >= Segment64LC->NumSections) > - return Error("invalid section index for symbol: '" + Twine() + "'"); > - > - // Get the symbol name. > - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); > - > - // Get the section base address. > - void *SectionBase = SectionBases[Index]; > - > - // Get the symbol address. > - void *Address = (char*) SectionBase + STE->Value; > - > - // FIXME: Check the symbol type and flags. > - if (STE->Type != 0xF) > - return Error("unexpected symbol type!"); > - if (STE->Flags != 0x0) > - return Error("unexpected symbol type!"); > - > - SymbolTable[Name] = Address; > - } > - > - delete SectionBases; > - return false; > -} > > static int executeInput() { > // Load the input memory buffer. > @@ -209,94 +59,28 @@ > if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFile, InputBuffer)) > return Error("unable to read input: '" + ec.message() + "'"); > > - // Load the Mach-O wrapper object. > - std::string ErrorStr; > - OwningPtr Obj( > - MachOObject::LoadFromBuffer(InputBuffer.take(), &ErrorStr)); > - if (!Obj) > - return Error("unable to load object: '" + ErrorStr + "'"); > - > - // Validate that the load commands match what we expect. > - const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, > - *DysymtabLCI = 0; > - for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { > - const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); > - switch (LCI.Command.Type) { > - case macho::LCT_Segment: > - case macho::LCT_Segment64: > - if (SegmentLCI) > - return Error("unexpected input object (multiple segments)"); > - SegmentLCI = &LCI; > - break; > - case macho::LCT_Symtab: > - if (SymtabLCI) > - return Error("unexpected input object (multiple symbol tables)"); > - SymtabLCI = &LCI; > - break; > - case macho::LCT_Dysymtab: > - if (DysymtabLCI) > - return Error("unexpected input object (multiple symbol tables)"); > - DysymtabLCI = &LCI; > - break; > - default: > - return Error("unexpected input object (unexpected load command"); > - } > - } > - > - if (!SymtabLCI) > - return Error("no symbol table found in object"); > - if (!SegmentLCI) > - return Error("no symbol table found in object"); > - > - // Read and register the symbol table data. > - InMemoryStruct SymtabLC; > - Obj->ReadSymtabLoadCommand(*SymtabLCI, SymtabLC); > - if (!SymtabLC) > - return Error("unable to load symbol table load command"); > - Obj->RegisterStringTable(*SymtabLC); > - > - // Read the dynamic link-edit information, if present (not present in static > - // objects). > - if (DysymtabLCI) { > - InMemoryStruct DysymtabLC; > - Obj->ReadDysymtabLoadCommand(*DysymtabLCI, DysymtabLC); > - if (!DysymtabLC) > - return Error("unable to load dynamic link-exit load command"); > - > - // FIXME: We don't support anything interesting yet. > - if (DysymtabLC->LocalSymbolsIndex != 0) > - return Error("NOT YET IMPLEMENTED: local symbol entries"); > - if (DysymtabLC->ExternalSymbolsIndex != 0) > - return Error("NOT YET IMPLEMENTED: non-external symbol entries"); > - if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) > - return Error("NOT YET IMPLEMENTED: undefined symbol entries"); > - } > + // Instantiate a dynamic linker. > + RuntimeDyld Dyld; > > - // Load the segment load command. > - sys::MemoryBlock Data; > - StringMap SymbolTable; > - if (SegmentLCI->Command.Type == macho::LCT_Segment) { > - if (loadSegment32(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) > - return true; > - } else { > - if (loadSegment64(Obj.get(), Data, SegmentLCI, SymtabLC, SymbolTable)) > - return true; > - } > + // Load the object file into it. > + if (Dyld.loadObject(InputBuffer.take())) > + return true; > > // Get the address of "_main". > - StringMap::iterator it = SymbolTable.find("_main"); > - if (it == SymbolTable.end()) > + void *MainAddress = Dyld.getSymbolAddress("_main"); > + if (MainAddress == 0) > return Error("no definition for '_main'"); > > // Invalidate the instruction cache. > + sys::MemoryBlock Data = Dyld.getMemoryBlock(); > sys::Memory::InvalidateInstructionCache(Data.base(), Data.size()); > > // Make sure the memory is executable. > + std::string ErrorStr; > if (!sys::Memory::setExecutable(Data, &ErrorStr)) > return Error("unable to mark function executable: '" + ErrorStr + "'"); > > // Dispatch to _main(). > - void *MainAddress = it->second; > errs() << "loaded '_main' at: " << MainAddress << "\n"; > > int (*Main)(int, const char**) = > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From jan_sjodin at yahoo.com Tue Mar 22 15:45:35 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 22 Mar 2011 13:45:35 -0700 (PDT) Subject: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp In-Reply-To: <501755.94659.qm@web55603.mail.re4.yahoo.com> References: <20110312130737.62D8C2A6C12C@llvm.org> <517378.41476.qm@web55607.mail.re4.yahoo.com> <4D8271DF.6020203@gmail.com> <501755.94659.qm@web55603.mail.re4.yahoo.com> Message-ID: <192835.66033.qm@web55601.mail.re4.yahoo.com> I had accidentally put this comment for a different patch: > I was continuing to try and see what the problem actually was. The difference >between the machines was that th debuginfo for glibc was included on the test >machine but not my own. I did a small test and linked in a dummy > > file before the test file and was able to reproduce the issue. This means that >there is a bug somewhere else or that the "optimization" is really something >required and the comment should be updated > >- Jan In any case I think I am stuck and need some help. I found the two offsets in the generated .s files that causes the bug: .Lset32 = .Labbrev_begin-.Lsection_abbrev # Offset Into Abbrev. Section .long .Lset32 and .Lset34 = .Linfo_begin1-.Lsection_info # Offset of Compilation Unit Info .long .Lset34 This will not work unless the resulting .o file appears first in the list of files to be linked, or if all object files before do not have any debug information. Without the patch these look like: .long .Labbrev_begin # Offset Into Abbrev. Section and .long .Linfo_begin1 # Offset of Compilation Unit Info In lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp we have this code: // If the section in question will end up with an address of 0 anyway, we can // just emit an absolute reference to save a relocation. if (Section.isBaseAddressKnownZero()) { OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); return; } The comment for the optimization cannot be true since without this, the generated code is wrong. I wanted to know why the above values cannot be differences, but have to be direct references. Is it a different kind of offset? If so, should LLVM distinguish between different kinds of offsets? I would be happy if someone with more knowledge could explain. - Jan ________________________________ From: Jan Sjodin To: Rafael Avila de Espindola ; llvm-commits at cs.uiuc.edu Sent: Thu, March 17, 2011 5:59:13 PM Subject: Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Test machine: GNU ld (GNU Binutils for Debian) 2.18.0.20080103 My machine: GNU ld (GNU Binutils for Ubuntu) 2.20.51-system.20100908 I actually did a few different things to see if I could possibly reproduce the problem on my machine. 1. I downloaded the closest versions of gdb, gcc and binutils that i could find: Test machine: gcc (Debian 4.3.2-1.1) 4.3.2, GNU gdb 6.8-debian and binutils (see above) Downloaded and compiled: gcc 4.3.2, gdb 6.8 and binutils 2.18 2. Compiled llvm, llvm-gcc with these and was not able to reproduce the problem. 3. Copied the ld binary and libbfd-2.18.0.20080103.so from the test machine to my own machine to see if I could use that linker to reproduce the error, and still was not able to reproduce the problem. There is something weird going on with that specific machine and I have no clue what it is. I know that ld is involved somehow. Perhaps it is some other supporting library that is at fault. - Jan ________________________________ From: Rafael Avila de Espindola To: llvm-commits at cs.uiuc.edu Sent: Thu, March 17, 2011 4:41:03 PM Subject: Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp On 11-03-17 03:57 PM, Jan Sjodin wrote: > I have been investigating this failure for the past couple of days. > There is something wrong with the linker on the test machine. If i take > the generated asm file (.s) and assemble and link on my own machine it > works fine. If i assemble on the test machine and link on my machine it > works fine, but if I link on the test machine the ELF format becomes > corrupted somehow. This shows up e.g. with readelf -a, where the object > file is okay, but the binary does not list the symbol table (it is there > and can be listed with readelf -s) The patch should be good otherwise, > the object file is smaller with the patch than without. What are the liker versions on both cases? > - Jan Cheers, Rafael _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110322/9c4d961c/attachment.html From jan_sjodin at yahoo.com Tue Mar 22 15:48:52 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Tue, 22 Mar 2011 13:48:52 -0700 (PDT) Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> Message-ID: <313975.13529.qm@web55605.mail.re4.yahoo.com> I was mainly thinking of debug info and being able to run gdb. Would that work? - Jan ________________________________ From: Jim Grosbach To: Jan Sjodin Cc: llvm-commits at cs.uiuc.edu Sent: Tue, March 22, 2011 4:32:34 PM Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp That depends on what you're looking to do. What specifically do you mean by supporting ELF? The code should work as-is on an ELF based system. It just needs the input object file to be a MachO. Even as this gets fleshed out to handle more things, it's only at the edges where the JITed code interfaces with external bits that there's likely to be any extra work required to run on an ELF based system, and that should be relatively self-contained. So if you mean whether this infrastructure should work on an ELF based host, then yes, at least most of it should work without modification. If you mean using ELF as a container instead of MachO, then no, I have no plans to do that. -Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110322/1f4ab020/attachment.html From eli.friedman at gmail.com Tue Mar 22 15:49:53 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 22 Mar 2011 20:49:53 -0000 Subject: [llvm-commits] [llvm] r128107 - /llvm/trunk/lib/Target/README.txt Message-ID: <20110322204953.EBABF2A6C12C@llvm.org> Author: efriedma Date: Tue Mar 22 15:49:53 2011 New Revision: 128107 URL: http://llvm.org/viewvc/llvm-project?rev=128107&view=rev Log: A bit more analysis of a memset-related README entry. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=128107&r1=128106&r2=128107&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Tue Mar 22 15:49:53 2011 @@ -2074,11 +2074,12 @@ } This shouldn't need the ((zext (%n - 1)) + 1) game, and it should ideally fold -the two memset's together. The issue with %n seems to stem from poor handling -of the original loop. +the two memset's together. -To simplify this, we need SCEV to know that "n != 0" because of the dominating -conditional. That would turn the second memset into a simple memset of 'n'. +The issue with the addition only occurs in 64-bit mode, and appears to be at +least partially caused by Scalar Evolution not keeping its cache updated: it +returns the "wrong" result immediately after indvars runs, but figures out the +expected result if it is run from scratch on IR resulting from running indvars. //===---------------------------------------------------------------------===// From echristo at apple.com Tue Mar 22 15:55:12 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 22 Mar 2011 13:55:12 -0700 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <313975.13529.qm@web55605.mail.re4.yahoo.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> <313975.13529.qm@web55605.mail.re4.yahoo.com> Message-ID: <6B5E58C2-0C74-4009-8F03-209ACC4F77AE@apple.com> On Mar 22, 2011, at 1:48 PM, Jan Sjodin wrote: > I was mainly thinking of debug info and being able to run gdb. Would that work? Not really. That'll need ELF input and output support. -eric From grosbach at apple.com Tue Mar 22 15:59:27 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 22 Mar 2011 13:59:27 -0700 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <313975.13529.qm@web55605.mail.re4.yahoo.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> <313975.13529.qm@web55605.mail.re4.yahoo.com> Message-ID: No, but to be fair, that's not hooked up to work on a native MachO platform, either. :) Since the debug info is DWARF in both cases, it's possible that a lot of things will just work without much, if any, ELF customization. There will still need to be gdb-specific hooks to register the info and EH frame, of course. I may be being overly optimistic, though. -Jim On Mar 22, 2011, at 1:48 PM, Jan Sjodin wrote: > I was mainly thinking of debug info and being able to run gdb. Would that work? > > - Jan > > From: Jim Grosbach > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 22, 2011 4:32:34 PM > Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp > > That depends on what you're looking to do. What specifically do you mean by supporting ELF? The code should work as-is on an ELF based system. It just needs the input object file to be a MachO. > > Even as this gets fleshed out to handle more things, it's only at the edges where the JITed code interfaces with external bits that there's likely to be any extra work required to run on an ELF based system, and that should be relatively self-contained. > > So if you mean whether this infrastructure should work on an ELF based host, then yes, at least most of it should work without modification. If you mean using ELF as a container instead of MachO, then no, I have no plans to do that. > > -Jim > From rafael.espindola at gmail.com Tue Mar 22 15:57:13 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 22 Mar 2011 20:57:13 -0000 Subject: [llvm-commits] [llvm] r128108 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp tools/lto/lto.exports Message-ID: <20110322205713.78DB42A6C12C@llvm.org> Author: rafael Date: Tue Mar 22 15:57:13 2011 New Revision: 128108 URL: http://llvm.org/viewvc/llvm-project?rev=128108&view=rev Log: Add a lto_codegen_compile_to_file to avoid producing a file, reading it to memory and writing it back to disk. Modified: llvm/trunk/include/llvm-c/lto.h llvm/trunk/tools/gold/gold-plugin.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOCodeGenerator.h llvm/trunk/tools/lto/lto.cpp llvm/trunk/tools/lto/lto.exports Modified: llvm/trunk/include/llvm-c/lto.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/lto.h (original) +++ llvm/trunk/include/llvm-c/lto.h Tue Mar 22 15:57:13 2011 @@ -272,6 +272,13 @@ extern const void* lto_codegen_compile(lto_code_gen_t cg, size_t* length); +/** + * Generates code for all added modules into one native object file. + * The name of the file is written to name. Returns true on error. + */ +extern bool +lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); + /** * Sets options to help debug codegen bugs. Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Mar 22 15:57:13 2011 @@ -398,38 +398,10 @@ exit(0); } size_t bufsize = 0; - const char *buffer = static_cast(lto_codegen_compile(code_gen, - &bufsize)); - - std::string ErrMsg; - const char *objPath; - sys::Path uniqueObjPath("/tmp/llvmgold.o"); - if (!options::obj_path.empty()) { - objPath = options::obj_path.c_str(); - } else { - if (uniqueObjPath.createTemporaryFileOnDisk(true, &ErrMsg)) { - (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); - return LDPS_ERR; - } - objPath = uniqueObjPath.c_str(); - } - tool_output_file objFile(objPath, ErrMsg, - raw_fd_ostream::F_Binary); - if (!ErrMsg.empty()) { - (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); - return LDPS_ERR; - } - - objFile.os().write(buffer, bufsize); - objFile.os().close(); - if (objFile.os().has_error()) { - (*message)(LDPL_ERROR, "Error writing output file '%s'", - objPath); - objFile.os().clear_error(); - return LDPS_ERR; + if (lto_codegen_compile_to_file(code_gen, &objPath)) { + (*message)(LDPL_ERROR, "Could not produce a combined object file\n"); } - objFile.keep(); lto_codegen_dispose(code_gen); for (std::list::iterator I = Modules.begin(), Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Mar 22 15:57:13 2011 @@ -176,54 +176,63 @@ } -const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) +bool LTOCodeGenerator::compile_to_file(const char** name, std::string& errMsg) { - // make unique temp .o file to put generated object file - sys::PathWithStatus uniqueObjPath("lto-llvm.o"); - if ( uniqueObjPath.createTemporaryFileOnDisk(false, &errMsg) ) { - uniqueObjPath.eraseFromDisk(); - return NULL; - } - sys::RemoveFileOnSignal(uniqueObjPath); + // make unique temp .o file to put generated object file + sys::PathWithStatus uniqueObjPath("lto-llvm.o"); + if ( uniqueObjPath.createTemporaryFileOnDisk(false, &errMsg) ) { + uniqueObjPath.eraseFromDisk(); + return true; + } + sys::RemoveFileOnSignal(uniqueObjPath); - // generate object file - bool genResult = false; - tool_output_file objFile(uniqueObjPath.c_str(), errMsg); - if (!errMsg.empty()) - return NULL; - genResult = this->generateObjectFile(objFile.os(), errMsg); - objFile.os().close(); - if (objFile.os().has_error()) { - objFile.os().clear_error(); - return NULL; - } - objFile.keep(); - if ( genResult ) { - uniqueObjPath.eraseFromDisk(); - return NULL; - } + // generate object file + bool genResult = false; + tool_output_file objFile(uniqueObjPath.c_str(), errMsg); + if (!errMsg.empty()) + return NULL; + genResult = this->generateObjectFile(objFile.os(), errMsg); + objFile.os().close(); + if (objFile.os().has_error()) { + objFile.os().clear_error(); + return true; + } + objFile.keep(); + if ( genResult ) { + uniqueObjPath.eraseFromDisk(); + return true; + } - const std::string& uniqueObjStr = uniqueObjPath.str(); - // remove old buffer if compile() called twice - delete _nativeObjectFile; - - // read .o file into memory buffer - OwningPtr BuffPtr; - if (error_code ec = MemoryBuffer::getFile(uniqueObjStr.c_str(), BuffPtr, - -1, false)) { - errMsg = ec.message(); - return NULL; - } - _nativeObjectFile = BuffPtr.take(); + _nativeObjectPath = uniqueObjPath.str(); + *name = _nativeObjectPath.c_str(); + return false; +} - // remove temp files - uniqueObjPath.eraseFromDisk(); +const void* LTOCodeGenerator::compile(size_t* length, std::string& errMsg) +{ + const char *name; + if (compile_to_file(&name, errMsg)) + return NULL; + + // remove old buffer if compile() called twice + delete _nativeObjectFile; + + // read .o file into memory buffer + OwningPtr BuffPtr; + if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) { + errMsg = ec.message(); + return NULL; + } + _nativeObjectFile = BuffPtr.take(); + + // remove temp files + sys::Path(_nativeObjectPath).eraseFromDisk(); - // return buffer, unless error - if ( _nativeObjectFile == NULL ) - return NULL; - *length = _nativeObjectFile->getBufferSize(); - return _nativeObjectFile->getBufferStart(); + // return buffer, unless error + if ( _nativeObjectFile == NULL ) + return NULL; + *length = _nativeObjectFile->getBufferSize(); + return _nativeObjectFile->getBufferStart(); } bool LTOCodeGenerator::determineTarget(std::string& errMsg) Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Mar 22 15:57:13 2011 @@ -41,6 +41,7 @@ void addMustPreserveSymbol(const char* sym); bool writeMergedModules(const char* path, std::string& errMsg); + bool compile_to_file(const char** name, std::string& errMsg); const void* compile(size_t* length, std::string& errMsg); void setCodeGenDebugOptions(const char *opts); private: @@ -66,6 +67,7 @@ llvm::MemoryBuffer* _nativeObjectFile; std::vector _codegenOptions; std::string _mCpu; + std::string _nativeObjectPath; }; #endif // LTO_CODE_GENERATOR_H Modified: llvm/trunk/tools/lto/lto.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.cpp (original) +++ llvm/trunk/tools/lto/lto.cpp Tue Mar 22 15:57:13 2011 @@ -293,6 +293,12 @@ return cg->compile(length, sLastErrorString); } +extern bool +lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) +{ + return cg->compile_to_file(name, sLastErrorString); +} + // // Used to pass extra options to the code generator Modified: llvm/trunk/tools/lto/lto.exports URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.exports?rev=128108&r1=128107&r2=128108&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.exports (original) +++ llvm/trunk/tools/lto/lto.exports Tue Mar 22 15:57:13 2011 @@ -26,3 +26,4 @@ lto_codegen_set_assembler_args lto_codegen_set_assembler_path lto_codegen_set_cpu +lto_codegen_compile_to_file From dpatel at apple.com Tue Mar 22 17:13:17 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 22 Mar 2011 22:13:17 -0000 Subject: [llvm-commits] [llvm] r128112 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Message-ID: <20110322221318.06CD22A6C12C@llvm.org> Author: dpatel Date: Tue Mar 22 17:13:17 2011 New Revision: 128112 URL: http://llvm.org/viewvc/llvm-project?rev=128112&view=rev Log: Try to appease buildbot gods. Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Modified: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128112&r1=128111&r2=128112&view=diff ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Tue Mar 22 17:13:17 2011 @@ -1,6 +1,6 @@ // RUN: %llvmgcc %s -m64 -S -O0 -o - | FileCheck %s // XFAIL: * -// XTARGET: darwin +// XTARGET: x86_64 // Radar 9156771 typedef struct RGBColor { unsigned short red; From johnny.chen at apple.com Tue Mar 22 17:28:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Mar 2011 22:28:49 -0000 Subject: [llvm-commits] [llvm] r128113 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110322222849.8289D2A6C12C@llvm.org> Author: johnny Date: Tue Mar 22 17:28:49 2011 New Revision: 128113 URL: http://llvm.org/viewvc/llvm-project?rev=128113&view=rev Log: LDRT and LDRBT was incorrectly tagged as IndexModeNone during the refactorings (r119821). We now tag them as IndexModePost. This fixed http://llvm.org/bugs/show_bug.cgi?id=9530. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=128113&r1=128112&r2=128113&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Mar 22 17:28:49 2011 @@ -1700,13 +1700,13 @@ // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only. let mayLoad = 1, neverHasSideEffects = 1 in { def LDRT : AI2ldstidx<1, 0, 0, (outs GPR:$dst, GPR:$base_wb), - (ins GPR:$base, am2offset:$offset), IndexModeNone, + (ins GPR:$base, am2offset:$offset), IndexModePost, LdFrm, IIC_iLoad_ru, "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { let Inst{21} = 1; // overwrite } def LDRBT : AI2ldstidx<1, 1, 0, (outs GPR:$dst, GPR:$base_wb), - (ins GPR:$base, am2offset:$offset), IndexModeNone, + (ins GPR:$base, am2offset:$offset), IndexModePost, LdFrm, IIC_iLoad_bh_ru, "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { let Inst{21} = 1; // overwrite Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128113&r1=128112&r2=128113&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Tue Mar 22 17:28:49 2011 @@ -163,3 +163,6 @@ # CHECK: ldrdeq r2, [r0], -r12 0xdc 0x24 0x00 0x00 + +# CHECK: ldrbt r3, [r4], -r5, lsl #12 +0x05 0x36 0x74 0xe6 From stoklund at 2pi.dk Tue Mar 22 17:33:08 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 22 Mar 2011 22:33:08 -0000 Subject: [llvm-commits] [llvm] r128114 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/CodeGen/LiveDebugVariables.cpp test/CodeGen/X86/dbg-value-range.ll Message-ID: <20110322223309.0654F2A6C12C@llvm.org> Author: stoklund Date: Tue Mar 22 17:33:08 2011 New Revision: 128114 URL: http://llvm.org/viewvc/llvm-project?rev=128114&view=rev Log: Reapply r128045 and r128051 with fixes. This will extend the ranges of debug info variables in registers until they are clobbered. Fix 1: Don't mistake DBG_VALUE instructions referring to incoming arguments on the stack with DBG_VALUE instructions referring to variables in the frame pointer. This fixes the gdb test-suite failure. Fix 2: Don't trace through copies to physical registers setting up call arguments. These registers are call clobbered, and the source register is more likely to be a callee-saved register that can be extended through the call instruction. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128114&r1=128113&r2=128114&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Mar 22 17:33:08 2011 @@ -2382,9 +2382,9 @@ /// DBG_VALUE instruction, is in a defined reg. static bool isDbgValueInDefinedReg(const MachineInstr *MI) { assert (MI->isDebugValue() && "Invalid DBG_VALUE machine instruction!"); - if (MI->getOperand(0).isReg() && MI->getOperand(0).getReg()) - return true; - return false; + return MI->getNumOperands() == 3 && + MI->getOperand(0).isReg() && MI->getOperand(0).getReg() && + MI->getOperand(1).isImm() && MI->getOperand(1).getImm() == 0; } /// collectVariableInfo - Populate DbgScope entries with variables' info. @@ -2407,7 +2407,7 @@ DbgValues.push_back(MInsn); } - // This is a collection of DBV_VALUE instructions describing same variable. + // This is a collection of DBG_VALUE instructions describing same variable. SmallVector MultipleValues; for(SmallVector::iterator I = DbgValues.begin(), E = DbgValues.end(); I != E; ++I) { @@ -2424,8 +2424,7 @@ ME = DbgValues.end(); MI != ME; ++MI) { const MDNode *Var = (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); - if (Var == DV && - !PrevMI->isIdenticalTo(*MI)) + if (Var == DV && !PrevMI->isIdenticalTo(*MI)) MultipleValues.push_back(*MI); PrevMI = *MI; } @@ -2448,7 +2447,7 @@ DbgVariableToDbgInstMap[AbsVar] = MInsn; VarToAbstractVarMap[RegVar] = AbsVar; } - if (MultipleValues.size() <= 1) { + if (MultipleValues.size() <= 1 && !RegClobberInsn.count(MInsn)) { DbgVariableToDbgInstMap[RegVar] = MInsn; continue; } @@ -2458,16 +2457,11 @@ RegVar->setDotDebugLocOffset(0); else RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); - const MachineInstr *Begin = NULL; - const MachineInstr *End = NULL; + for (SmallVector::iterator MVI = MultipleValues.begin(), MVE = MultipleValues.end(); MVI != MVE; ++MVI) { - if (!Begin) { - Begin = *MVI; - continue; - } - End = *MVI; + const MachineInstr *Begin = *MVI; MachineLocation MLoc; if (Begin->getNumOperands() == 3) { if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm()) @@ -2475,25 +2469,25 @@ } else MLoc = Asm->getDebugValueLocation(Begin); + if (!MLoc.getReg()) + continue; + + // Compute the range for a register location. const MCSymbol *FLabel = getLabelBeforeInsn(Begin); - const MCSymbol *SLabel = getLabelBeforeInsn(End); - if (MLoc.getReg()) - DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); - - Begin = End; - if (MVI + 1 == MVE) { - // If End is the last instruction then its value is valid + const MCSymbol *SLabel = 0; + + if (const MachineInstr *ClobberMI = RegClobberInsn.lookup(Begin)) + // The register range starting at Begin may be clobbered. + SLabel = getLabelAfterInsn(ClobberMI); + else if (MVI + 1 == MVE) + // If Begin is the last instruction then its value is valid // until the end of the funtion. - MachineLocation EMLoc; - if (End->getNumOperands() == 3) { - if (End->getOperand(0).isReg() && Begin->getOperand(1).isImm()) - EMLoc.set(Begin->getOperand(0).getReg(), Begin->getOperand(1).getImm()); - } else - EMLoc = Asm->getDebugValueLocation(End); - if (EMLoc.getReg()) - DotDebugLocEntries. - push_back(DotDebugLocEntry(SLabel, FunctionEndSym, EMLoc)); - } + SLabel = FunctionEndSym; + else + // The value is valid until the next DBG_VALUE. + SLabel = getLabelBeforeInsn(MVI[1]); + + DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); } DotDebugLocEntries.push_back(DotDebugLocEntry()); } @@ -2568,7 +2562,7 @@ /// endInstruction - Process end of an instruction. void DwarfDebug::endInstruction(const MachineInstr *MI) { - if (InsnsEndScopeSet.count(MI) != 0) { + if (InsnsNeedsLabelAfter.count(MI) != 0) { // Emit a label if this instruction ends a scope. MCSymbol *Label = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(Label); @@ -2833,7 +2827,7 @@ RE = Ranges.end(); RI != RE; ++RI) { assert(RI->first && "DbgRange does not have first instruction!"); assert(RI->second && "DbgRange does not have second instruction!"); - InsnsEndScopeSet.insert(RI->second); + InsnsNeedsLabelAfter.insert(RI->second); } } } @@ -2914,6 +2908,14 @@ /// ProcessedArgs - Collection of arguments already processed. SmallPtrSet ProcessedArgs; + /// LastDbgValue - Refer back to the last DBG_VALUE instruction to mention MD. + DenseMap LastDbgValue; + + const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); + + /// LiveUserVar - Map physreg numbers to the MDNode they contain. + std::vector LiveUserVar(TRI->getNumRegs()); + DebugLoc PrevLoc; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) @@ -2923,7 +2925,15 @@ DebugLoc DL = MI->getDebugLoc(); if (MI->isDebugValue()) { assert (MI->getNumOperands() > 1 && "Invalid machine instruction!"); - DIVariable DV(MI->getOperand(MI->getNumOperands() - 1).getMetadata()); + + // Keep track of variables in registers. + const MDNode *Var = + MI->getOperand(MI->getNumOperands() - 1).getMetadata(); + LastDbgValue[Var] = MI; + if (isDbgValueInDefinedReg(MI)) + LiveUserVar[MI->getOperand(0).getReg()] = Var; + + DIVariable DV(Var); if (!DV.Verify()) continue; // If DBG_VALUE is for a local variable then it needs a label. if (DV.getTag() != dwarf::DW_TAG_arg_variable) @@ -2944,6 +2954,32 @@ } else if (DL != PrevLoc) // Otherwise, instruction needs a location only if it is new location. InsnNeedsLabel.insert(MI); + + // Check if the instruction clobbers any registers with debug vars. + for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), + MOE = MI->operands_end(); MOI != MOE; ++MOI) { + if (!MOI->isReg() || !MOI->isDef() || !MOI->getReg()) + continue; + for (const unsigned *AI = TRI->getOverlaps(MOI->getReg()); + unsigned Reg = *AI; ++AI) { + const MDNode *Var = LiveUserVar[Reg]; + if (!Var) + continue; + // Reg is now clobbered. + LiveUserVar[Reg] = 0; + + // Was MD last defined by a DBG_VALUE referring to Reg? + const MachineInstr *Last = LastDbgValue.lookup(Var); + if (!Last || Last->getParent() != MI->getParent()) + continue; + if (!isDbgValueInDefinedReg(Last) || + Last->getOperand(0).getReg() != Reg) + continue; + // MD is clobbered. Make sure the next instruction gets a label. + InsnsNeedsLabelAfter.insert(MI); + RegClobberInsn[Last] = MI; + } + } } if (!DL.isUnknown() || UnknownLocations) @@ -3013,7 +3049,8 @@ VarToAbstractVarMap.clear(); DbgVariableToDbgInstMap.clear(); DeleteContainerSeconds(DbgScopeMap); - InsnsEndScopeSet.clear(); + InsnsNeedsLabelAfter.clear(); + RegClobberInsn.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128114&r1=128113&r2=128114&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Tue Mar 22 17:33:08 2011 @@ -200,8 +200,6 @@ typedef SmallVector ScopeVector; - SmallPtrSet InsnsEndScopeSet; - /// InlineInfo - Keep track of inlined functions and their location. This /// information is used to populate debug_inlined section. typedef std::pair InlineInfoLabels; @@ -224,6 +222,16 @@ /// a debuggging information entity. SmallPtrSet InsnNeedsLabel; + /// InsnsNeedsLabelAfter - Collection of instructions that need a label after + /// the instruction because they end a scope of clobber a register. + SmallPtrSet InsnsNeedsLabelAfter; + + /// RegClobberInsn - For each DBG_VALUE instruction referring to a register + /// that is clobbered before the variable gets a new DBG_VALUE, map the + /// instruction that clobbered the register. This instruction will also be in + /// InsnsNeedsLabelAfter. + DenseMap RegClobberInsn; + SmallVector DebugRangeSymbols; /// Previous instruction's location information. This is used to determine Modified: llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp?rev=128114&r1=128113&r2=128114&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveDebugVariables.cpp Tue Mar 22 17:33:08 2011 @@ -101,10 +101,6 @@ void insertDebugValue(MachineBasicBlock *MBB, SlotIndex Idx, unsigned LocNo, LiveIntervals &LIS, const TargetInstrInfo &TII); - /// insertDebugKill - Insert an undef DBG_VALUE into MBB at Idx. - void insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, - LiveIntervals &LIS, const TargetInstrInfo &TII); - public: /// UserValue - Create a new UserValue. UserValue(const MDNode *var, unsigned o, DebugLoc L, @@ -515,6 +511,13 @@ MachineInstr *MI = &*UI; unsigned DstReg = MI->getOperand(0).getReg(); + // Don't follow copies to physregs. These are usually setting up call + // arguments, and the argument registers are always call clobbered. We are + // better off in the source register which could be a callee-saved register, + // or it could be spilled. + if (!TargetRegisterInfo::isVirtualRegister(DstReg)) + continue; + // Is LocNo extended to reach this copy? If not, another def may be blocking // it, or we are looking at a wrong value of LI. SlotIndex Idx = LIS.getInstructionIndex(MI); @@ -752,13 +755,6 @@ .addOperand(Loc).addImm(offset).addMetadata(variable); } -void UserValue::insertDebugKill(MachineBasicBlock *MBB, SlotIndex Idx, - LiveIntervals &LIS, const TargetInstrInfo &TII) { - MachineBasicBlock::iterator I = findInsertLocation(MBB, Idx, LIS); - BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE)).addReg(0) - .addImm(offset).addMetadata(variable); -} - void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS, const TargetInstrInfo &TII) { MachineFunction::iterator MFEnd = VRM->getMachineFunction().end(); @@ -790,12 +786,6 @@ break; ++I; - if (Stop == MBBEnd) - continue; - // The current interval ends before MBB. - // Insert a kill if there is a gap. - if (!I.valid() || I.start() > Stop) - insertDebugKill(MBB, Stop, LIS, TII); } } Modified: llvm/trunk/test/CodeGen/X86/dbg-value-range.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-value-range.ll?rev=128114&r1=128113&r2=128114&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-value-range.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Tue Mar 22 17:33:08 2011 @@ -41,15 +41,17 @@ !18 = metadata !{i32 7, i32 2, metadata !12, null} !19 = metadata !{i32 8, i32 2, metadata !12, null} -; check that variable bar:b value range is appropriately trucated in debug info. Here Ltmp5 is end of -; location range. +; Check that variable bar:b value range is appropriately trucated in debug info. +; The variable is in %rdi which is clobbered by 'movl %ebx, %edi' +; Here Ltmp7 is the end of the location range. ;CHECK:Ltmp6 -;CHECK-NEXT: DEBUG_VALUE: bar:b <- undef +;CHECK-NEXT: movl +;CHECK-NEXT: Ltmp7 ;CHECK:Ldebug_loc0: ;CHECK-NEXT: .quad Ltmp -;CHECK-NEXT: .quad Ltmp6 +;CHECK-NEXT: .quad Ltmp7 ;CHECK-NEXT: .short 1 ;CHECK-NEXT: .byte 85 ;CHECK-NEXT: .quad 0 From resistor at mac.com Tue Mar 22 17:52:54 2011 From: resistor at mac.com (Owen Anderson) Date: Tue, 22 Mar 2011 22:52:54 -0000 Subject: [llvm-commits] [llvm] r128117 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20110322225254.DF0EB2A6C12C@llvm.org> Author: resistor Date: Tue Mar 22 17:52:54 2011 New Revision: 128117 URL: http://llvm.org/viewvc/llvm-project?rev=128117&view=rev Log: RIT_ARM_ThumbBranch32Bit relocations are not used and should never be generated. This fixes kimwitu++, bullet, and tramp3dv4 with the ARM integrated assembler. Fixes . Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=128117&r1=128116&r2=128117&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Tue Mar 22 17:52:54 2011 @@ -821,7 +821,7 @@ // 1 - :upper16: for movt instructions // high bit of r_length: // 0 - arm instructions - // 1 - thumb instructions + // 1 - thumb instructions // the other half of the relocated expression is in the following pair // relocation entry in the the low 16 bits of r_address field. unsigned ThumbBit = 0; @@ -949,15 +949,11 @@ // Handle Thumb branches. case ARM::fixup_arm_thumb_br: + case ARM::fixup_arm_thumb_bl: RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit); Log2Size = llvm::Log2_32(2); return true; - case ARM::fixup_arm_thumb_bl: - RelocType = unsigned(macho::RIT_ARM_ThumbBranch32Bit); - Log2Size = llvm::Log2_32(4); - return true; - case ARM::fixup_arm_thumb_blx: RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit); // Report as 'long', even though that is not quite accurate. From dpatel at apple.com Tue Mar 22 18:07:03 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 22 Mar 2011 23:07:03 -0000 Subject: [llvm-commits] [llvm] r128119 - /llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Message-ID: <20110322230703.DFD552A6C12C@llvm.org> Author: dpatel Date: Tue Mar 22 18:07:03 2011 New Revision: 128119 URL: http://llvm.org/viewvc/llvm-project?rev=128119&view=rev Log: Remove the test. Removed: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c Removed: llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c?rev=128118&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (original) +++ llvm/trunk/test/FrontendC/2011-03-18-StructReturn.c (removed) @@ -1,19 +0,0 @@ -// RUN: %llvmgcc %s -m64 -S -O0 -o - | FileCheck %s -// XFAIL: * -// XTARGET: x86_64 -// Radar 9156771 -typedef struct RGBColor { - unsigned short red; - unsigned short green; - unsigned short blue; -} RGBColor; - -RGBColor func(); - -RGBColor X; -void foo() { -//CHECK: store i48 - X = func(); -} - - From johnny.chen at apple.com Tue Mar 22 18:08:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Mar 2011 23:08:56 -0000 Subject: [llvm-commits] [llvm] r128120 - in /llvm/trunk/test/MC/Disassembler/ARM: arm-tests.txt thumb-tests.txt Message-ID: <20110322230856.770112A6C12C@llvm.org> Author: johnny Date: Tue Mar 22 18:08:56 2011 New Revision: 128120 URL: http://llvm.org/viewvc/llvm-project?rev=128120&view=rev Log: Add disassembly test cases for: A8.6.292 VCMPE Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128120&r1=128119&r2=128120&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Tue Mar 22 18:08:56 2011 @@ -166,3 +166,6 @@ # CHECK: ldrbt r3, [r4], -r5, lsl #12 0x05 0x36 0x74 0xe6 + +# CHECK: vcmpe.f64 d8, #0 +0xc0 0x8b 0xb5 0xee Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128120&r1=128119&r2=128120&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Tue Mar 22 18:08:56 2011 @@ -133,3 +133,6 @@ # CHECK: vpush {d8, d9, d10} 0x2d 0xed 0x06 0x8b + +# CHECK: vcmpe.f64 d8, #0 +0xb5 0xee 0xc0 0x8b From anton at korobeynikov.info Tue Mar 22 18:50:19 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Wed, 23 Mar 2011 02:50:19 +0300 Subject: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. In-Reply-To: <504570.72198.qm@web55608.mail.re4.yahoo.com> References: <504570.72198.qm@web55608.mail.re4.yahoo.com> Message-ID: Hi Jan > Ping! The patch looks ok for me, but could you please look into dwarf standard to check which behavior is per standard, Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From johnny.chen at apple.com Tue Mar 22 18:49:46 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Tue, 22 Mar 2011 23:49:46 -0000 Subject: [llvm-commits] [llvm] r128122 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Message-ID: <20110322234946.ABD7B2A6C12C@llvm.org> Author: johnny Date: Tue Mar 22 18:49:46 2011 New Revision: 128122 URL: http://llvm.org/viewvc/llvm-project?rev=128122&view=rev Log: For ARM Disassembler, start a newline to dump the opcode and friends for an instruction. Change inspired by llvm-bug 9530 submitted by Jyun-Yan You. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=128122&r1=128121&r2=128122&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Tue Mar 22 18:49:46 2011 @@ -378,7 +378,7 @@ Size = 4; DEBUG({ - errs() << "Opcode=" << Opcode << " Name=" << ARMUtils::OpcodeName(Opcode) + errs() << "\nOpcode=" << Opcode << " Name=" < Author: dgregor Date: Tue Mar 22 20:05:46 2011 New Revision: 128130 URL: http://llvm.org/viewvc/llvm-project?rev=128130&view=rev Log: Update the Clang attribute emitter to handle attributes of 'version' kind, and fix serialization/deserialization of IdentifierInfo attributes. These are requires for the new 'availability' attribute. Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=128130&r1=128129&r2=128130&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Tue Mar 22 20:05:46 2011 @@ -46,6 +46,7 @@ ">(GetDecl(Record[Idx++]))") .Case("QualType", "GetType(Record[Idx++])") .Case("Expr *", "ReadSubExpr()") + .Case("IdentifierInfo *", "GetIdentifierInfo(Record, Idx)") .Default("Record[Idx++]"); } @@ -56,6 +57,8 @@ ", Record);\n") .Case("QualType", "AddTypeRef(" + std::string(name) + ", Record);\n") .Case("Expr *", "AddStmt(" + std::string(name) + ");\n") + .Case("IdentifierInfo *", + "AddIdentifierRef(" + std::string(name) + ", Record);\n") .Default("Record.push_back(" + std::string(name) + ");\n"); } @@ -415,6 +418,47 @@ OS << "Record.push_back(SA->get" << getUpperName() << "());\n"; } }; + + class VersionArgument : public Argument { + public: + VersionArgument(Record &Arg, StringRef Attr) + : Argument(Arg, Attr) + {} + + void writeAccessors(raw_ostream &OS) const { + OS << " VersionTuple get" << getUpperName() << "() const {\n"; + OS << " return " << getLowerName() << ";\n"; + OS << " }\n"; + OS << " void set" << getUpperName() + << "(ASTContext &C, VersionTuple V) {\n"; + OS << " " << getLowerName() << " = V;\n"; + OS << " }"; + } + void writeCloneArgs(raw_ostream &OS) const { + OS << "get" << getUpperName() << "()"; + } + void writeCtorBody(raw_ostream &OS) const { + } + void writeCtorInitializers(raw_ostream &OS) const { + OS << getLowerName() << "(" << getUpperName() << ")"; + } + void writeCtorParameters(raw_ostream &OS) const { + OS << "VersionTuple " << getUpperName(); + } + void writeDeclarations(raw_ostream &OS) const { + OS << "VersionTuple " << getLowerName() << ";\n"; + } + void writePCHReadDecls(raw_ostream &OS) const { + OS << " VersionTuple " << getLowerName() + << "= ReadVersionTuple(Record, Idx);\n"; + } + void writePCHReadArgs(raw_ostream &OS) const { + OS << getLowerName(); + } + void writePCHWrite(raw_ostream &OS) const { + OS << " AddVersionTuple(SA->get" << getUpperName() << "(), Record);\n"; + } + }; } static Argument *createArgument(Record &Arg, StringRef Attr, @@ -441,6 +485,8 @@ Ptr = new SimpleArgument(Arg, Attr, "unsigned"); else if (ArgName == "VariadicUnsignedArgument") Ptr = new VariadicArgument(Arg, Attr, "unsigned"); + else if (ArgName == "VersionArgument") + Ptr = new VersionArgument(Arg, Attr); if (!Ptr) { std::vector Bases = Search->getSuperClasses(); From nicholas at mxc.ca Tue Mar 22 20:30:34 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 22 Mar 2011 18:30:34 -0700 Subject: [llvm-commits] [llvm] r128107 - /llvm/trunk/lib/Target/README.txt In-Reply-To: <20110322204953.EBABF2A6C12C@llvm.org> References: <20110322204953.EBABF2A6C12C@llvm.org> Message-ID: <4D894D3A.50306@mxc.ca> Eli Friedman wrote: > Author: efriedma > Date: Tue Mar 22 15:49:53 2011 > New Revision: 128107 > > URL: http://llvm.org/viewvc/llvm-project?rev=128107&view=rev > Log: > A bit more analysis of a memset-related README entry. > > > Modified: > llvm/trunk/lib/Target/README.txt > > Modified: llvm/trunk/lib/Target/README.txt > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=128107&r1=128106&r2=128107&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/README.txt (original) > +++ llvm/trunk/lib/Target/README.txt Tue Mar 22 15:49:53 2011 > @@ -2074,11 +2074,12 @@ > } > > This shouldn't need the ((zext (%n - 1)) + 1) game, and it should ideally fold > -the two memset's together. The issue with %n seems to stem from poor handling > -of the original loop. > +the two memset's together. > > -To simplify this, we need SCEV to know that "n != 0" because of the dominating > -conditional. That would turn the second memset into a simple memset of 'n'. > +The issue with the addition only occurs in 64-bit mode, and appears to be at > +least partially caused by Scalar Evolution not keeping its cache updated: it > +returns the "wrong" result immediately after indvars runs, but figures out the > +expected result if it is run from scratch on IR resulting from running indvars. Yes, this is: http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037495.html which is still unsolved, even though I've added numerous optimizations to SCEV since that posting. Nick > > //===---------------------------------------------------------------------===// > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From atrick at apple.com Tue Mar 22 20:38:28 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 01:38:28 -0000 Subject: [llvm-commits] [llvm] r128132 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Message-ID: <20110323013828.5A70D2A6C12C@llvm.org> Author: atrick Date: Tue Mar 22 20:38:28 2011 New Revision: 128132 URL: http://llvm.org/viewvc/llvm-project?rev=128132&view=rev Log: Added block number and name to isel debug output. I'm tired of doing this manually for each checkout. If anyone knows a better way debug isel for non-trivial tests feel free to revert and let me know how to do it. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=128132&r1=128131&r2=128132&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Tue Mar 22 20:38:28 2011 @@ -489,13 +489,19 @@ if (TimePassesIsEnabled) GroupName = "Instruction Selection and Scheduling"; std::string BlockName; + int BlockNumber = -1; +#ifdef NDEBUG if (ViewDAGCombine1 || ViewLegalizeTypesDAGs || ViewLegalizeDAGs || ViewDAGCombine2 || ViewDAGCombineLT || ViewISelDAGs || ViewSchedDAGs || ViewSUnitDAGs) +#endif + { + BlockNumber = FuncInfo->MBB->getNumber(); BlockName = MF->getFunction()->getNameStr() + ":" + FuncInfo->MBB->getBasicBlock()->getNameStr(); - - DEBUG(dbgs() << "Initial selection DAG:\n"; CurDAG->dump()); + } + DEBUG(dbgs() << "Initial selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); if (ViewDAGCombine1) CurDAG->viewGraph("dag-combine1 input for " + BlockName); @@ -505,7 +511,8 @@ CurDAG->Combine(Unrestricted, *AA, OptLevel); } - DEBUG(dbgs() << "Optimized lowered selection DAG:\n"; CurDAG->dump()); + DEBUG(dbgs() << "Optimized lowered selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); // Second step, hack on the DAG until it only uses operations and types that // the target supports. @@ -518,7 +525,8 @@ Changed = CurDAG->LegalizeTypes(); } - DEBUG(dbgs() << "Type-legalized selection DAG:\n"; CurDAG->dump()); + DEBUG(dbgs() << "Type-legalized selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); if (Changed) { if (ViewDAGCombineLT) @@ -531,8 +539,8 @@ CurDAG->Combine(NoIllegalTypes, *AA, OptLevel); } - DEBUG(dbgs() << "Optimized type-legalized selection DAG:\n"; - CurDAG->dump()); + DEBUG(dbgs() << "Optimized type-legalized selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); } { @@ -556,8 +564,8 @@ CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); } - DEBUG(dbgs() << "Optimized vector-legalized selection DAG:\n"; - CurDAG->dump()); + DEBUG(dbgs() << "Optimized vector-legalized selection DAG: BB#" + << BlockNumber << " '" << BlockName << "'\n"; CurDAG->dump()); } if (ViewLegalizeDAGs) CurDAG->viewGraph("legalize input for " + BlockName); @@ -567,7 +575,8 @@ CurDAG->Legalize(OptLevel); } - DEBUG(dbgs() << "Legalized selection DAG:\n"; CurDAG->dump()); + DEBUG(dbgs() << "Legalized selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); if (ViewDAGCombine2) CurDAG->viewGraph("dag-combine2 input for " + BlockName); @@ -577,7 +586,8 @@ CurDAG->Combine(NoIllegalOperations, *AA, OptLevel); } - DEBUG(dbgs() << "Optimized legalized selection DAG:\n"; CurDAG->dump()); + DEBUG(dbgs() << "Optimized legalized selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); if (OptLevel != CodeGenOpt::None) ComputeLiveOutVRegInfo(); @@ -591,7 +601,8 @@ DoInstructionSelection(); } - DEBUG(dbgs() << "Selected selection DAG:\n"; CurDAG->dump()); + DEBUG(dbgs() << "Selected selection DAG: BB#" << BlockNumber + << " '" << BlockName << "'\n"; CurDAG->dump()); if (ViewSchedDAGs) CurDAG->viewGraph("scheduler input for " + BlockName); @@ -632,7 +643,9 @@ } void SelectionDAGISel::DoInstructionSelection() { - DEBUG(errs() << "===== Instruction selection begins:\n"); + DEBUG(errs() << "===== Instruction selection begins: BB#" + << FuncInfo->MBB->getNumber() + << " '" << FuncInfo->MBB->getName() << "'\n"); PreprocessISelDAG(); From andersca at mac.com Tue Mar 22 21:19:48 2011 From: andersca at mac.com (Anders Carlsson) Date: Wed, 23 Mar 2011 02:19:48 -0000 Subject: [llvm-commits] [llvm] r128140 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/non-escaping-local-object.ll Message-ID: <20110323021948.CB0A92A6C12C@llvm.org> Author: andersca Date: Tue Mar 22 21:19:48 2011 New Revision: 128140 URL: http://llvm.org/viewvc/llvm-project?rev=128140&view=rev Log: A global variable with internal linkage where all uses are in one function and whose address is never taken is a non-escaping local object and can't alias anything else. Added: llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=128140&r1=128139&r2=128140&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Tue Mar 22 21:19:48 2011 @@ -57,6 +57,29 @@ return false; } +/// areAllUsesInOneFunction - Return true if all the uses of the given value +/// are in the same function. Note that this returns false if any of the uses +/// are from non-instruction values. +static bool areAllUsesInOneFunction(const Value *V) { + const llvm::Function *Fn = 0; + + for (Value::const_use_iterator UI = V->use_begin(), E = V->use_end(); + UI != E; ++UI) { + if (const Instruction *I = dyn_cast(*UI)) { + if (!Fn) { + Fn = I->getParent()->getParent(); + continue; + } + + if (Fn != I->getParent()->getParent()) + return false; + } else + return false; + } + + return true; +} + /// isNonEscapingLocalObject - Return true if the pointer is to a function-local /// object that never escapes from the function. static bool isNonEscapingLocalObject(const Value *V) { @@ -79,6 +102,16 @@ return true; return !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true); } + + // If this is an internal global variable that's only used in this function, + // check if it escapes the function. + if (const GlobalVariable *GV = dyn_cast(V)) { + if (GV->hasInternalLinkage() && areAllUsesInOneFunction(GV)) { + return !PointerMayBeCaptured(V, /*ReturnCaptures=*/true, + /*StoreCaptures=*/true); + } + } + return false; } Added: llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll?rev=128140&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll Tue Mar 22 21:19:48 2011 @@ -0,0 +1,19 @@ +; RUN: opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output < %s |& FileCheck %s + + at global = internal global i32 0 + +declare void @should_not_be_called() +declare i32 @f() + +; CHECK: Function: g: 2 pointers, 0 call sites +define void @g(i32* nocapture %p) { + store i32 0, i32* @global + + ; @global is internal, is only used in this function, and never has its + ; address taken so it can't alias p. + ; CHECK: NoAlias: i32* %p, i32* @global + store i32 1, i32* %p + %1 = load i32* @global + ret void +} + From eli.friedman at gmail.com Tue Mar 22 21:31:55 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Tue, 22 Mar 2011 19:31:55 -0700 Subject: [llvm-commits] [llvm] r128107 - /llvm/trunk/lib/Target/README.txt In-Reply-To: <4D894D3A.50306@mxc.ca> References: <20110322204953.EBABF2A6C12C@llvm.org> <4D894D3A.50306@mxc.ca> Message-ID: On Tue, Mar 22, 2011 at 6:30 PM, Nick Lewycky wrote: > Eli Friedman wrote: >> >> Author: efriedma >> Date: Tue Mar 22 15:49:53 2011 >> New Revision: 128107 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128107&view=rev >> Log: >> A bit more analysis of a memset-related README entry. >> >> >> Modified: >> ? ? llvm/trunk/lib/Target/README.txt >> >> Modified: llvm/trunk/lib/Target/README.txt >> URL: >> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=128107&r1=128106&r2=128107&view=diff >> >> ============================================================================== >> --- llvm/trunk/lib/Target/README.txt (original) >> +++ llvm/trunk/lib/Target/README.txt Tue Mar 22 15:49:53 2011 >> @@ -2074,11 +2074,12 @@ >> ?} >> >> ?This shouldn't need the ((zext (%n - 1)) + 1) game, and it should ideally >> fold >> -the two memset's together. The issue with %n seems to stem from poor >> handling >> -of the original loop. >> +the two memset's together. >> >> -To simplify this, we need SCEV to know that "n != 0" because of the >> dominating >> -conditional. ?That would turn the second memset into a simple memset of >> 'n'. >> +The issue with the addition only occurs in 64-bit mode, and appears to be >> at >> +least partially caused by Scalar Evolution not keeping its cache updated: >> it >> +returns the "wrong" result immediately after indvars runs, but figures >> out the >> +expected result if it is run from scratch on IR resulting from running >> indvars. > > Yes, this is: > > ?http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037495.html > > which is still unsolved, even though I've added numerous optimizations to > SCEV since that posting. Mmm... at least for test/Transforms/IndVarSimplify/signed-trip-count.ll , it looks like the issue has to do with the value of the calls to getMaxBackedgeTakenCount() in ScalarEvolution::getSignedRange and ScalarEvolution::getUnsignedRange. Before the loop exit condition is rewritten, SCEV returns "2147483646"; after, it returns "(-1 + (zext i32 %n to i64))". Not surprisingly, this completely screws up the range analysis. -Eli From stoklund at 2pi.dk Tue Mar 22 23:32:49 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 23 Mar 2011 04:32:49 -0000 Subject: [llvm-commits] [llvm] r128143 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp Message-ID: <20110323043249.A9D322A6C12C@llvm.org> Author: stoklund Date: Tue Mar 22 23:32:49 2011 New Revision: 128143 URL: http://llvm.org/viewvc/llvm-project?rev=128143&view=rev Log: Dump the register map before rewriting. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=128143&r1=128142&r2=128143&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Tue Mar 22 23:32:49 2011 @@ -259,7 +259,7 @@ DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n" << "********** Function: " << MF->getFunction()->getName() << '\n'); - + DEBUG(dump()); SmallVector SuperKills; for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end(); From stoklund at 2pi.dk Tue Mar 22 23:32:52 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 23 Mar 2011 04:32:52 -0000 Subject: [llvm-commits] [llvm] r128144 - /llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Message-ID: <20110323043252.1FFDB2A6C12D@llvm.org> Author: stoklund Date: Tue Mar 22 23:32:51 2011 New Revision: 128144 URL: http://llvm.org/viewvc/llvm-project?rev=128144&view=rev Log: Allow the allocation of empty live ranges that have uses. Empty ranges may represent undef values. Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocBasic.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocBasic.cpp?rev=128144&r1=128143&r2=128144&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocBasic.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocBasic.cpp Tue Mar 22 23:32:51 2011 @@ -289,6 +289,8 @@ // Continue assigning vregs one at a time to available physical registers. while (LiveInterval *VirtReg = dequeue()) { + assert(!VRM->hasPhys(VirtReg->reg) && "Register already assigned"); + // Unused registers can appear when the spiller coalesces snippets. if (MRI->reg_nodbg_empty(VirtReg->reg)) { DEBUG(dbgs() << "Dropping unused " << *VirtReg << '\n'); @@ -315,7 +317,12 @@ for (VirtRegVec::iterator I = SplitVRegs.begin(), E = SplitVRegs.end(); I != E; ++I) { LiveInterval *SplitVirtReg = *I; - if (SplitVirtReg->empty()) continue; + assert(!VRM->hasPhys(SplitVirtReg->reg) && "Register already assigned"); + if (MRI->reg_nodbg_empty(SplitVirtReg->reg)) { + DEBUG(dbgs() << "not queueing unused " << *SplitVirtReg << '\n'); + LIS->removeInterval(SplitVirtReg->reg); + continue; + } DEBUG(dbgs() << "queuing new interval: " << *SplitVirtReg << "\n"); assert(TargetRegisterInfo::isVirtualRegister(SplitVirtReg->reg) && "expect split value in virtual register"); From stoklund at 2pi.dk Tue Mar 22 23:43:16 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 23 Mar 2011 04:43:16 -0000 Subject: [llvm-commits] [llvm] r128145 - /llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Message-ID: <20110323044316.D09462A6C12C@llvm.org> Author: stoklund Date: Tue Mar 22 23:43:16 2011 New Revision: 128145 URL: http://llvm.org/viewvc/llvm-project?rev=128145&view=rev Log: Notify the delegate before removing dead values from a live interval. The register allocator needs to know when the range shrinks. Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=128145&r1=128144&r2=128145&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Tue Mar 22 23:43:16 2011 @@ -182,6 +182,8 @@ // Remove defined value. if (MOI->isDef()) { if (VNInfo *VNI = LI.getVNInfoAt(Idx)) { + if (delegate_) + delegate_->LRE_WillShrinkVirtReg(LI.reg); LI.removeValNo(VNI); if (LI.empty()) { ToShrink.remove(&LI); From zwarich at apple.com Wed Mar 23 00:25:55 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 23 Mar 2011 05:25:55 -0000 Subject: [llvm-commits] [llvm] r128146 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/vector_promote.ll Message-ID: <20110323052555.AC0FB2A6C12C@llvm.org> Author: zwarich Date: Wed Mar 23 00:25:55 2011 New Revision: 128146 URL: http://llvm.org/viewvc/llvm-project?rev=128146&view=rev Log: Fix PR9464 by correcting some math that just happened to be right in most cases that were hit in practice. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=128146&r1=128145&r2=128146&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Wed Mar 23 00:25:55 2011 @@ -654,18 +654,18 @@ /// getScaledElementType - Gets a scaled element type for a partial vector /// access of an alloca. The input type must be an integer or float, and /// the resulting type must be an integer, float or double. -static const Type *getScaledElementType(const Type *OldTy, unsigned Scale) { +static const Type *getScaledElementType(const Type *OldTy, + unsigned NewBitWidth) { assert((OldTy->isIntegerTy() || OldTy->isFloatTy()) && "Partial vector " "accesses must be scaled from integer or float elements."); LLVMContext &Context = OldTy->getContext(); - unsigned Size = OldTy->getPrimitiveSizeInBits() * Scale; if (OldTy->isIntegerTy()) - return Type::getIntNTy(Context, Size); - if (Size == 32) + return Type::getIntNTy(Context, NewBitWidth); + if (NewBitWidth == 32) return Type::getFloatTy(Context); - if (Size == 64) + if (NewBitWidth == 64) return Type::getDoubleTy(Context); llvm_unreachable("Invalid type for a partial vector access of an alloca!"); @@ -703,9 +703,9 @@ "from a nonzero offset."); const Type *ToElementTy = cast(ToType)->getElementType(); - unsigned Scale = AllocaSize / ToTypeSize; - const Type *CastElementTy = getScaledElementType(ToElementTy, Scale); - unsigned NumCastVectorElements = VTy->getNumElements() / Scale; + const Type *CastElementTy = getScaledElementType(ToElementTy, + ToTypeSize * 8); + unsigned NumCastVectorElements = AllocaSize / ToTypeSize; LLVMContext &Context = FromVal->getContext(); const Type *CastTy = VectorType::get(CastElementTy, @@ -841,9 +841,8 @@ const Type *ToElementTy = cast(SV->getType())->getElementType(); - unsigned Scale = VecSize / ValSize; - const Type *CastElementTy = getScaledElementType(ToElementTy, Scale); - unsigned NumCastVectorElements = VTy->getNumElements() / Scale; + const Type *CastElementTy = getScaledElementType(ToElementTy, ValSize); + unsigned NumCastVectorElements = VecSize / ValSize; LLVMContext &Context = SV->getContext(); const Type *OldCastTy = VectorType::get(CastElementTy, Modified: llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll?rev=128146&r1=128145&r2=128146&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll Wed Mar 23 00:25:55 2011 @@ -171,3 +171,19 @@ ; CHECK: @test11 ; CHECK-NOT: alloca } + +define void @test12() { +entry: + %a = alloca <64 x i8>, align 64 + store <64 x i8> undef, <64 x i8>* %a, align 64 + %p = bitcast <64 x i8>* %a to <16 x i8>* + %0 = load <16 x i8>* %p, align 64 + store <16 x i8> undef, <16 x i8>* %p, align 64 + %q = bitcast <16 x i8>* %p to <64 x i8>* + %1 = load <64 x i8>* %q, align 64 + ret void +; CHECK: @test12 +; CHECK-NOT: alloca +; CHECK: extractelement <4 x i128> +; CHECK: insertelement <4 x i128> +} From rafael.espindola at gmail.com Wed Mar 23 00:35:28 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Wed, 23 Mar 2011 01:35:28 -0400 Subject: [llvm-commits] [RFC] Use topological sorting when writing the type table Message-ID: <4D8986A0.2060005@gmail.com> I am trying to reduce the time of LTO builds a bit. I started profiling gnu ar (which uses libLTO via the gold plugin) and noticed that a lot of time was spent in type unification. Type unification is known to be a problem when linking, but I was surprised to see it during 'ar' since no module was being merged. It turns out that it was because of forward references, which are handled in the reader by creating opaque types. I changed the writer to do a topological sort of the types before writing. The time impact is pretty impressive. The timing for producing libgklayout.a in the firefox build (a 49MB file) goes from real 2m4.186s user 2m3.591s sys 0m0.211s to real 0m23.944s user 0m23.698s sys 0m0.185s I have attached the proof of concept patch that does it. Would a not as copy and stl heavy patch implementing the same idea be OK? Cheers, Rafael -------------- next part -------------- A non-text attachment was scrubbed... Name: sort.patch Type: text/x-patch Size: 4105 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110323/4636d620/attachment.bin From sabre at nondot.org Wed Mar 23 00:42:02 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 22 Mar 2011 22:42:02 -0700 Subject: [llvm-commits] [RFC] Use topological sorting when writing the type table In-Reply-To: <4D8986A0.2060005@gmail.com> References: <4D8986A0.2060005@gmail.com> Message-ID: <97C665D7-BC15-4B0B-A3C0-30F39B2D461A@nondot.org> On Mar 22, 2011, at 10:35 PM, Rafael ?vila de Esp?ndola wrote: > I am trying to reduce the time of LTO builds a bit. I started profiling > gnu ar (which uses libLTO via the gold plugin) and noticed that a lot of > time was spent in type unification. > > Type unification is known to be a problem when linking, but I was > surprised to see it during 'ar' since no module was being merged. It > turns out that it was because of forward references, which are handled > in the reader by creating opaque types. > > I changed the writer to do a topological sort of the types before > writing. The time impact is pretty impressive. The timing for producing > libgklayout.a in the firefox build (a 49MB file) goes from > > real 2m4.186s > user 2m3.591s > sys 0m0.211s > > to > > real 0m23.944s > user 0m23.698s > sys 0m0.185s > > I have attached the proof of concept patch that does it. Would a not as > copy and stl heavy patch implementing the same idea be OK? Yes, I'm ok with the idea in principle if the patch were reworked. We used to do something similar but dropped it along the way. FWIW, I'm hoping to have some time in the next 6 months to do the type system rewrite, which will hopefully define this away. -Chris From fvbommel at gmail.com Wed Mar 23 04:15:19 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Wed, 23 Mar 2011 10:15:19 +0100 Subject: [llvm-commits] [llvm] r128140 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/non-escaping-local-object.ll In-Reply-To: <20110323021948.CB0A92A6C12C@llvm.org> References: <20110323021948.CB0A92A6C12C@llvm.org> Message-ID: On Wed, Mar 23, 2011 at 3:19 AM, Anders Carlsson wrote: > Log: > A global variable with internal linkage where all uses are in one function and whose address is never taken is a non-escaping local object and can't alias anything else. > ?/// isNonEscapingLocalObject - Return true if the pointer is to a function-local > ?/// object that never escapes from the function. > ?static bool isNonEscapingLocalObject(const Value *V) { > @@ -79,6 +102,16 @@ > ? ? ? ? return true; > ? ? ? return !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true); > ? ? } > + > + ?// If this is an internal global variable that's only used in this function, > + ?// check if it escapes the function. > + ?if (const GlobalVariable *GV = dyn_cast(V)) { > + ? ?if (GV->hasInternalLinkage() && areAllUsesInOneFunction(GV)) { > + ? ? ?return !PointerMayBeCaptured(V, /*ReturnCaptures=*/true, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? /*StoreCaptures=*/true); Looking at the places where this function is used, I see it being used for things like checking whether a function call might modify this object. Note that for internal globals used in one function, it isn't safe to assume that simply because they don't escape they can't be modified by calls -- a call might recurse, allowing another instance of this function to modify it. For instance: int foo(int x) { static int counter = 0; counter++; if (bar(x)) foo(x - 1); return counter; } Even though "counter" is an internal global used only in foo(), calls can still modify it without it needing to escape first -- it essentially comes pre-escaped, so isNonEscapingLocalObject() shouldn't return true for it. Note that the recursion could be through an arbitrarily long call chain (or e.g. indirectly through function pointers) so this case isn't always easy to detect. It might be better to either: a) remove this code here and create a new function that returns true if the argument is a non-escaping local object or an internal global used in a single function, then inspect all uses of isNonEscapingLocalObject() to see whether they should be calling that new function instead, or b) add a parameter to isNonEscapingLocalObject() to flag whether this is a safe option. (Preferably defaulting to false), or c) simply revert this patch. From Renato.Golin at arm.com Wed Mar 23 05:25:29 2011 From: Renato.Golin at arm.com (Renato Golin) Date: Wed, 23 Mar 2011 10:25:29 +0000 Subject: [llvm-commits] [llvm] r128085 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td In-Reply-To: <20110322150624.EE38E2A6C12C@llvm.org> References: <20110322150624.EE38E2A6C12C@llvm.org> Message-ID: <4D89CA99.2000901@arm.com> On 22/03/11 15:06, Bruno Cardoso Lopes wrote: > Author: bruno > Date: Tue Mar 22 10:06:24 2011 > New Revision: 128085 > > URL: http://llvm.org/viewvc/llvm-project?rev=128085&view=rev > > Log: > Change MRC and MRC2 instructions to model the output register properly Hi Bruno, Are we generating them via the code gen, or this is still only for disassembly? cheers, --renato -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From jay.foad at gmail.com Wed Mar 23 07:00:23 2011 From: jay.foad at gmail.com (Jay Foad) Date: Wed, 23 Mar 2011 12:00:23 +0000 Subject: [llvm-commits] [PATCH][RFC] InstrTypes.h: don't include Operator.h Message-ID: I noticed that InstrTypes.h include Operator.h, even though it doesn't seem to be required for anything in InstrTypes.h. This patch removes the include and adjusts a bunch of .cpp files accordingly. Tested with "make all check", LLVM and Clang. I see this as an improvement, because it makes the header files more independent and minimalist. But perhaps you'd prefer that .cpp files don't have to explicitly #include Operator.h, when they've already asked for all InstrTypes to be defined. Thoughts? Thanks, Jay. -------------- next part -------------- A non-text attachment was scrubbed... Name: instrtypes-operator.diff Type: text/x-patch Size: 10626 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110323/80349d33/attachment.bin From bruno.cardoso at gmail.com Wed Mar 23 07:22:50 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 23 Mar 2011 09:22:50 -0300 Subject: [llvm-commits] [llvm] r128085 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb.td ARMInstrThumb2.td In-Reply-To: <4D89CA99.2000901@arm.com> References: <20110322150624.EE38E2A6C12C@llvm.org> <4D89CA99.2000901@arm.com> Message-ID: Hi, On Wed, Mar 23, 2011 at 7:25 AM, Renato Golin wrote: > On 22/03/11 15:06, Bruno Cardoso Lopes wrote: >> Author: bruno >> Date: Tue Mar 22 10:06:24 2011 >> New Revision: 128085 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128085&view=rev >> >> Log: >> Change MRC and MRC2 instructions to model the output register properly > > Hi Bruno, > > Are we generating them via the code gen, or this is still only for > disassembly? Disassembly and asm parsing! -- Bruno Cardoso Lopes http://www.brunocardoso.cc From baldrick at free.fr Wed Mar 23 04:38:49 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 23 Mar 2011 10:38:49 +0100 Subject: [llvm-commits] [llvm] r128140 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/non-escaping-local-object.ll In-Reply-To: <20110323021948.CB0A92A6C12C@llvm.org> References: <20110323021948.CB0A92A6C12C@llvm.org> Message-ID: <4D89BFA9.502@free.fr> Hi Anders, > A global variable with internal linkage where all uses are in one function and whose address is never taken is a non-escaping local object and can't alias anything else. what about recursive functions? > +define void @g(i32* nocapture %p) { > + store i32 0, i32* @global > + > + ; @global is internal, is only used in this function, and never has its > + ; address taken so it can't alias p. > + ; CHECK: NoAlias: i32* %p, i32* @global > + store i32 1, i32* %p > + %1 = load i32* @global > + ret void > +} For example, suppose @g called itself, passing @global for %p. Would the "does not escape" check catch this? Ciao, Duncan. From andersca at mac.com Wed Mar 23 10:51:12 2011 From: andersca at mac.com (Anders Carlsson) Date: Wed, 23 Mar 2011 15:51:12 -0000 Subject: [llvm-commits] [llvm] r128149 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/non-escaping-local-object.ll Message-ID: <20110323155112.A88992A6C12C@llvm.org> Author: andersca Date: Wed Mar 23 10:51:12 2011 New Revision: 128149 URL: http://llvm.org/viewvc/llvm-project?rev=128149&view=rev Log: Revert r128140 for now. Removed: llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=128149&r1=128148&r2=128149&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Mar 23 10:51:12 2011 @@ -57,29 +57,6 @@ return false; } -/// areAllUsesInOneFunction - Return true if all the uses of the given value -/// are in the same function. Note that this returns false if any of the uses -/// are from non-instruction values. -static bool areAllUsesInOneFunction(const Value *V) { - const llvm::Function *Fn = 0; - - for (Value::const_use_iterator UI = V->use_begin(), E = V->use_end(); - UI != E; ++UI) { - if (const Instruction *I = dyn_cast(*UI)) { - if (!Fn) { - Fn = I->getParent()->getParent(); - continue; - } - - if (Fn != I->getParent()->getParent()) - return false; - } else - return false; - } - - return true; -} - /// isNonEscapingLocalObject - Return true if the pointer is to a function-local /// object that never escapes from the function. static bool isNonEscapingLocalObject(const Value *V) { @@ -102,16 +79,6 @@ return true; return !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true); } - - // If this is an internal global variable that's only used in this function, - // check if it escapes the function. - if (const GlobalVariable *GV = dyn_cast(V)) { - if (GV->hasInternalLinkage() && areAllUsesInOneFunction(GV)) { - return !PointerMayBeCaptured(V, /*ReturnCaptures=*/true, - /*StoreCaptures=*/true); - } - } - return false; } Removed: llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll?rev=128148&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/non-escaping-local-object.ll (removed) @@ -1,19 +0,0 @@ -; RUN: opt -basicaa -aa-eval -print-all-alias-modref-info -disable-output < %s |& FileCheck %s - - at global = internal global i32 0 - -declare void @should_not_be_called() -declare i32 @f() - -; CHECK: Function: g: 2 pointers, 0 call sites -define void @g(i32* nocapture %p) { - store i32 0, i32* @global - - ; @global is internal, is only used in this function, and never has its - ; address taken so it can't alias p. - ; CHECK: NoAlias: i32* %p, i32* @global - store i32 1, i32* %p - %1 = load i32* @global - ret void -} - From dpatel at apple.com Wed Mar 23 11:30:03 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 23 Mar 2011 16:30:03 -0000 Subject: [llvm-commits] [debuginfo-tests] r128151 - /debuginfo-tests/trunk/forward-declare-class.cpp Message-ID: <20110323163003.C0F802A6C12C@llvm.org> Author: dpatel Date: Wed Mar 23 11:30:03 2011 New Revision: 128151 URL: http://llvm.org/viewvc/llvm-project?rev=128151&view=rev Log: Test case for r128150. Added: debuginfo-tests/trunk/forward-declare-class.cpp Added: debuginfo-tests/trunk/forward-declare-class.cpp URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/forward-declare-class.cpp?rev=128151&view=auto ============================================================================== --- debuginfo-tests/trunk/forward-declare-class.cpp (added) +++ debuginfo-tests/trunk/forward-declare-class.cpp Wed Mar 23 11:30:03 2011 @@ -0,0 +1,23 @@ +// RUN: %clangxx -O0 -g %s -c -o %t.o +// RUN: %test_debuginfo %s %t.o +// Radar 9168773 + +// DEBUGGER: ptype A +// CHECK: type = struct A { +// CHECK-NEXT: int MyData; +// CHECK-NEXT: } +class A; +class B { +public: + void foo(const A *p); +}; + +B iEntry; + +class A { +public: + int MyData; +}; + +A irp; + From andersca at mac.com Wed Mar 23 10:55:39 2011 From: andersca at mac.com (Anders Carlsson) Date: Wed, 23 Mar 2011 08:55:39 -0700 Subject: [llvm-commits] [llvm] r128140 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/non-escaping-local-object.ll In-Reply-To: References: <20110323021948.CB0A92A6C12C@llvm.org> Message-ID: <6FD5875F-3AF0-4CB2-AFFB-4C6424819365@mac.com> Hi Frits, i reverted this patch for now. Thanks for reviewing! - Anders From justin.holewinski at gmail.com Wed Mar 23 11:58:51 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Wed, 23 Mar 2011 16:58:51 -0000 Subject: [llvm-commits] [llvm] r128153 - in /llvm/trunk/lib/Target/PTX: PTXISelDAGToDAG.cpp PTXISelLowering.cpp PTXInstrInfo.td Message-ID: <20110323165851.D0EE62A6C12D@llvm.org> Author: jholewinski Date: Wed Mar 23 11:58:51 2011 New Revision: 128153 URL: http://llvm.org/viewvc/llvm-project?rev=128153&view=rev Log: PTX: Improve support for 64-bit addressing - Fix bug in ADDRrr/ADDRri/ADDRii selection for 64-bit addresses - Add comparison selection for i64 - Add zext selection for i32 -> i64 - Add shl/shr/sha support for i64 Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp?rev=128153&r1=128152&r2=128153&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Wed Mar 23 11:58:51 2011 @@ -130,8 +130,11 @@ isImm(Addr.getOperand(0)) || isImm(Addr.getOperand(1))) return false; + assert(Addr.getValueType().isSimple() && "Type must be simple"); + R1 = Addr; - R2 = CurDAG->getTargetConstant(0, MVT::i32); + R2 = CurDAG->getTargetConstant(0, Addr.getValueType().getSimpleVT()); + return true; } @@ -143,8 +146,12 @@ if (isImm(Addr)) return false; // it is [reg] + + assert(Addr.getValueType().isSimple() && "Type must be simple"); + Base = Addr; - Offset = CurDAG->getTargetConstant(0, MVT::i32); + Offset = CurDAG->getTargetConstant(0, Addr.getValueType().getSimpleVT()); + return true; } @@ -177,7 +184,10 @@ // is [imm]? if (SelectImm(Addr, Base)) { - Offset = CurDAG->getTargetConstant(0, MVT::i32); + assert(Addr.getValueType().isSimple() && "Type must be simple"); + + Offset = CurDAG->getTargetConstant(0, Addr.getValueType().getSimpleVT()); + return true; } @@ -194,7 +204,8 @@ return false; ConstantSDNode *CN = cast(node); - imm = CurDAG->getTargetConstant(*CN->getConstantIntValue(), MVT::i32); + imm = CurDAG->getTargetConstant(*CN->getConstantIntValue(), + operand.getValueType()); return true; } Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=128153&r1=128152&r2=128153&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Mar 23 11:58:51 2011 @@ -41,6 +41,7 @@ // Customize translation of memory addresses setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); + setOperationAction(ISD::GlobalAddress, MVT::i64, Custom); // Expand BR_CC into BRCOND setOperationAction(ISD::BR_CC, MVT::Other, Expand); @@ -85,10 +86,12 @@ DebugLoc dl = Op.getDebugLoc(); const GlobalValue *GV = cast(Op)->getGlobal(); + assert(PtrVT.isSimple() && "Pointer must be to primitive type."); + SDValue targetGlobal = DAG.getTargetGlobalAddress(GV, dl, PtrVT); SDValue movInstr = DAG.getNode(PTXISD::COPY_ADDRESS, dl, - MVT::i32, + PtrVT.getSimpleVT(), targetGlobal); return movInstr; Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=128153&r1=128152&r2=128153&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Mar 23 11:58:51 2011 @@ -285,18 +285,42 @@ } multiclass INT3ntnc { - def rr : InstPTX<(outs RRegu32:$d), - (ins RRegu32:$a, RRegu32:$b), - !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegu32:$d, (opnode RRegu32:$a, RRegu32:$b))]>; - def ri : InstPTX<(outs RRegu32:$d), - (ins RRegu32:$a, i32imm:$b), - !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegu32:$d, (opnode RRegu32:$a, imm:$b))]>; - def ir : InstPTX<(outs RRegu32:$d), - (ins i32imm:$a, RRegu32:$b), - !strconcat(opcstr, "\t$d, $a, $b"), - [(set RRegu32:$d, (opnode imm:$a, RRegu32:$b))]>; + def rr16 : InstPTX<(outs RRegu16:$d), + (ins RRegu16:$a, RRegu16:$b), + !strconcat(opcstr, "16\t$d, $a, $b"), + [(set RRegu16:$d, (opnode RRegu16:$a, RRegu16:$b))]>; + def rr32 : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, RRegu32:$b), + !strconcat(opcstr, "32\t$d, $a, $b"), + [(set RRegu32:$d, (opnode RRegu32:$a, RRegu32:$b))]>; + def rr64 : InstPTX<(outs RRegu64:$d), + (ins RRegu64:$a, RRegu64:$b), + !strconcat(opcstr, "64\t$d, $a, $b"), + [(set RRegu64:$d, (opnode RRegu64:$a, RRegu64:$b))]>; + def ri16 : InstPTX<(outs RRegu16:$d), + (ins RRegu16:$a, i16imm:$b), + !strconcat(opcstr, "16\t$d, $a, $b"), + [(set RRegu16:$d, (opnode RRegu16:$a, imm:$b))]>; + def ri32 : InstPTX<(outs RRegu32:$d), + (ins RRegu32:$a, i32imm:$b), + !strconcat(opcstr, "32\t$d, $a, $b"), + [(set RRegu32:$d, (opnode RRegu32:$a, imm:$b))]>; + def ri64 : InstPTX<(outs RRegu64:$d), + (ins RRegu64:$a, i64imm:$b), + !strconcat(opcstr, "64\t$d, $a, $b"), + [(set RRegu64:$d, (opnode RRegu64:$a, imm:$b))]>; + def ir16 : InstPTX<(outs RRegu16:$d), + (ins i16imm:$a, RRegu16:$b), + !strconcat(opcstr, "16\t$d, $a, $b"), + [(set RRegu16:$d, (opnode imm:$a, RRegu16:$b))]>; + def ir32 : InstPTX<(outs RRegu32:$d), + (ins i32imm:$a, RRegu32:$b), + !strconcat(opcstr, "32\t$d, $a, $b"), + [(set RRegu32:$d, (opnode imm:$a, RRegu32:$b))]>; + def ir64 : InstPTX<(outs RRegu64:$d), + (ins i64imm:$a, RRegu64:$b), + !strconcat(opcstr, "64\t$d, $a, $b"), + [(set RRegu64:$d, (opnode imm:$a, RRegu64:$b))]>; } multiclass PTX_SETP; defm SETPGTu32 : PTX_SETP; defm SETPGEu32 : PTX_SETP; +defm SETPEQu64 : PTX_SETP; +defm SETPNEu64 : PTX_SETP; +defm SETPLTu64 : PTX_SETP; +defm SETPLEu64 : PTX_SETP; +defm SETPGTu64 : PTX_SETP; +defm SETPGEu64 : PTX_SETP; ///===- Logic and Shift Instructions --------------------------------------===// -defm SHL : INT3ntnc<"shl.b32", PTXshl>; -defm SRL : INT3ntnc<"shr.u32", PTXsrl>; -defm SRA : INT3ntnc<"shr.s32", PTXsra>; +defm SHL : INT3ntnc<"shl.b", PTXshl>; +defm SRL : INT3ntnc<"shr.u", PTXsrl>; +defm SRA : INT3ntnc<"shr.s", PTXsra>; defm AND : PTX_LOGIC<"and", and>; defm OR : PTX_LOGIC<"or", or>; @@ -537,9 +567,12 @@ } let isReMaterializable = 1, isAsCheapAsAMove = 1 in { - def MOVaddr + def MOVaddr32 : InstPTX<(outs RRegu32:$d), (ins i32imm:$a), "mov.u32\t$d, $a", [(set RRegu32:$d, (PTXcopyaddress tglobaladdr:$a))]>; + def MOVaddr64 + : InstPTX<(outs RRegu64:$d), (ins i64imm:$a), "mov.u64\t$d, $a", + [(set RRegu64:$d, (PTXcopyaddress tglobaladdr:$a))]>; } // Loads @@ -573,6 +606,10 @@ : InstPTX<(outs RRegu32:$d), (ins Preds:$a), "cvt.u32.pred\t$d, $a", [(set RRegu32:$d, (zext Preds:$a))]>; +def CVT_u64_u32 + : InstPTX<(outs RRegu64:$d), (ins RRegu32:$a), "cvt.u64.u32\t$d, $a", + [(set RRegu64:$d, (zext RRegu32:$a))]>; + ///===- Control Flow Instructions -----------------------------------------===// let isBranch = 1, isTerminator = 1, isBarrier = 1 in { From jan_sjodin at yahoo.com Wed Mar 23 12:27:06 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Wed, 23 Mar 2011 10:27:06 -0700 (PDT) Subject: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp In-Reply-To: <192835.66033.qm@web55601.mail.re4.yahoo.com> References: <20110312130737.62D8C2A6C12C@llvm.org> <517378.41476.qm@web55607.mail.re4.yahoo.com> <4D8271DF.6020203@gmail.com> <501755.94659.qm@web55603.mail.re4.yahoo.com> <192835.66033.qm@web55601.mail.re4.yahoo.com> Message-ID: <200464.41183.qm@web55608.mail.re4.yahoo.com> I found this blog entry that explains why: http://blogs.sun.com/dbx/entry/dwarf_and_relocations I may write a patch that changes the comment to reflect this. - Jan ________________________________ From: Jan Sjodin To: Rafael Avila de Espindola ; llvm-commits at cs.uiuc.edu Sent: Tue, March 22, 2011 4:45:35 PM Subject: Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp I had accidentally put this comment for a different patch: > I was continuing to try and see what the problem actually was. The difference >between the machines was that th debuginfo for glibc was included on the test >machine but not my own. I did a small test and linked in a dummy > > file before the test file and was able to reproduce the issue. This means that >there is a bug somewhere else or that the "optimization" is really something >required and the comment should be updated > >- Jan In any case I think I am stuck and need some help. I found the two offsets in the generated .s files that causes the bug: .Lset32 = .Labbrev_begin-.Lsection_abbrev # Offset Into Abbrev. Section .long .Lset32 and .Lset34 = .Linfo_begin1-.Lsection_info # Offset of Compilation Unit Info .long .Lset34 This will not work unless the resulting .o file appears first in the list of files to be linked, or if all object files before do not have any debug information. Without the patch these look like: .long .Labbrev_begin # Offset Into Abbrev. Section and .long .Linfo_begin1 # Offset of Compilation Unit Info In lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp we have this code: // If the section in question will end up with an address of 0 anyway, we can // just emit an absolute reference to save a relocation. if (Section.isBaseAddressKnownZero()) { OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); return; } The comment for the optimization cannot be true since without this, the generated code is wrong. I wanted to know why the above values cannot be differences, but have to be direct references. Is it a different kind of offset? If so, should LLVM distinguish between different kinds of offsets? I would be happy if someone with more knowledge could explain. - Jan ________________________________ From: Jan Sjodin To: Rafael Avila de Espindola ; llvm-commits at cs.uiuc.edu Sent: Thu, March 17, 2011 5:59:13 PM Subject: Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Test machine: GNU ld (GNU Binutils for Debian) 2.18.0.20080103 My machine: GNU ld (GNU Binutils for Ubuntu) 2.20.51-system.20100908 I actually did a few different things to see if I could possibly reproduce the problem on my machine. 1. I downloaded the closest versions of gdb, gcc and binutils that i could find: Test machine: gcc (Debian 4.3.2-1.1) 4.3.2, GNU gdb 6.8-debian and binutils (see above) Downloaded and compiled: gcc 4.3.2, gdb 6.8 and binutils 2.18 2. Compiled llvm, llvm-gcc with these and was not able to reproduce the problem. 3. Copied the ld binary and libbfd-2.18.0.20080103.so from the test machine to my own machine to see if I could use that linker to reproduce the error, and still was not able to reproduce the problem. There is something weird going on with that specific machine and I have no clue what it is. I know that ld is involved somehow. Perhaps it is some other supporting library that is at fault. - Jan ________________________________ From: Rafael Avila de Espindola To: llvm-commits at cs.uiuc.edu Sent: Thu, March 17, 2011 4:41:03 PM Subject: Re: [llvm-commits] [llvm] r127540 - in /llvm/trunk: include/llvm/MC/MCSection.h include/llvm/MC/MCSectionELF.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp On 11-03-17 03:57 PM, Jan Sjodin wrote: > I have been investigating this failure for the past couple of days. > There is something wrong with the linker on the test machine. If i take > the generated asm file (.s) and assemble and link on my own machine it > works fine. If i assemble on the test machine and link on my machine it > works fine, but if I link on the test machine the ELF format becomes > corrupted somehow. This shows up e.g. with readelf -a, where the object > file is okay, but the binary does not list the symbol table (it is there > and can be listed with readelf -s) The patch should be good otherwise, > the object file is smaller with the patch than without. What are the liker versions on both cases? > - Jan Cheers, Rafael _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110323/c91ce1be/attachment.html From ofv at wanadoo.es Wed Mar 23 12:42:13 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Wed, 23 Mar 2011 17:42:13 -0000 Subject: [llvm-commits] [llvm] r128154 - in /llvm/trunk: CMakeLists.txt cmake/config-ix.cmake cmake/modules/LLVMConfig.cmake Message-ID: <20110323174213.59F182A6C12C@llvm.org> Author: ofv Date: Wed Mar 23 12:42:13 2011 New Revision: 128154 URL: http://llvm.org/viewvc/llvm-project?rev=128154&view=rev Log: Supports building with a list of targets that does not contain X86. Fixes PR9533. Modified: llvm/trunk/CMakeLists.txt llvm/trunk/cmake/config-ix.cmake llvm/trunk/cmake/modules/LLVMConfig.cmake Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=128154&r1=128153&r2=128154&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Wed Mar 23 12:42:13 2011 @@ -81,6 +81,9 @@ XCore ) +# List of targets with JIT support: +set(LLVM_TARGETS_WITH_JIT X86 PowerPC ARM) + if( MSVC ) set(LLVM_TARGETS_TO_BUILD X86 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=128154&r1=128153&r2=128154&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Wed Mar 23 12:42:13 2011 @@ -321,24 +321,19 @@ elseif (LLVM_NATIVE_ARCH MATCHES "msp430") set(LLVM_NATIVE_ARCH MSP430) else () - message(STATUS - "Unknown architecture ${LLVM_NATIVE_ARCH}; lli will not JIT code") - set(LLVM_NATIVE_ARCH) + message(FATAL_ERROR "Unknown architecture ${LLVM_NATIVE_ARCH}") endif () -if (LLVM_NATIVE_ARCH) - list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) - if (NATIVE_ARCH_IDX EQUAL -1) - message(STATUS - "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") - set(LLVM_NATIVE_ARCH) - else () - message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}") - set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target) - set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo) - set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter) - endif () -endif() +list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) +if (NATIVE_ARCH_IDX EQUAL -1) + message(STATUS + "Native target ${LLVM_NATIVE_ARCH} is not selected; lli will not JIT code") +else () + message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}") + set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target) + set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo) + set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter) +endif () if( MINGW ) set(HAVE_LIBIMAGEHLP 1) Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake?rev=128154&r1=128153&r2=128154&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMConfig.cmake (original) +++ llvm/trunk/cmake/modules/LLVMConfig.cmake Wed Mar 23 12:42:13 2011 @@ -64,15 +64,22 @@ string(TOUPPER "${llvm_libs}" capitalized_libs) # Expand some keywords: + list(FIND LLVM_TARGETS_TO_BUILD "${LLVM_NATIVE_ARCH}" have_native_backend) list(FIND link_components "engine" engine_required) - if( NOT engine_required STREQUAL "-1" ) - # TODO: as we assume we are on X86, this is `jit'. - list(APPEND link_components "jit") - list(APPEND link_components "native") + if( NOT engine_required EQUAL -1 ) + list(FIND LLVM_TARGETS_WITH_JIT "${LLVM_NATIVE_ARCH}" have_jit) + if( NOT have_native_backend EQUAL -1 AND NOT have_jit EQUAL -1 ) + list(APPEND link_components "jit") + list(APPEND link_components "native") + else() + list(APPEND link_components "interpreter") + endif() endif() list(FIND link_components "native" native_required) - if( NOT native_required STREQUAL "-1" ) - list(APPEND link_components "X86") + if( NOT native_required EQUAL -1 ) + if( NOT have_native_backend EQUAL -1 ) + list(APPEND link_components ${LLVM_NATIVE_ARCH}) + endif() endif() # Translate symbolic component names to real libraries: From stoklund at 2pi.dk Wed Mar 23 13:37:30 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 23 Mar 2011 18:37:30 -0000 Subject: [llvm-commits] [llvm] r128155 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110323183730.3679B2A6C12C@llvm.org> Author: stoklund Date: Wed Mar 23 13:37:30 2011 New Revision: 128155 URL: http://llvm.org/viewvc/llvm-project?rev=128155&view=rev Log: Don't coalesce identical DBG_VALUE instructions prematurely. Each of these instructions may have a RegsClobberInsn entry that can't be ignored. Consecutive ranges are coalesced later when DwarfDebug::emitDebugLoc merges entries. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128155&r1=128154&r2=128155&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 23 13:37:30 2011 @@ -2419,14 +2419,12 @@ if (Processed.count(DV) != 0) continue; - const MachineInstr *PrevMI = MInsn; for (SmallVector::iterator MI = I+1, ME = DbgValues.end(); MI != ME; ++MI) { const MDNode *Var = (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); - if (Var == DV && !PrevMI->isIdenticalTo(*MI)) + if (Var == DV) MultipleValues.push_back(*MI); - PrevMI = *MI; } DbgScope *Scope = NULL; From grosbach at apple.com Wed Mar 23 14:51:34 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 19:51:34 -0000 Subject: [llvm-commits] [llvm] r128160 - /llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Message-ID: <20110323195134.589B22A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 14:51:34 2011 New Revision: 128160 URL: http://llvm.org/viewvc/llvm-project?rev=128160&view=rev Log: Make sure to report any errors from the runtime dyld. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=128160&r1=128159&r2=128160&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Wed Mar 23 14:51:34 2011 @@ -90,7 +90,8 @@ // FIXME: It would be nice to avoid making yet another copy. MemoryBuffer *MB = MemoryBuffer::getMemBufferCopy(StringRef(Buffer.data(), Buffer.size())); - Dyld.loadObject(MB); + if (Dyld.loadObject(MB)) + report_fatal_error(Dyld.getErrorString()); } MCJIT::~MCJIT() { From grosbach at apple.com Wed Mar 23 14:52:00 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 19:52:00 -0000 Subject: [llvm-commits] [llvm] r128161 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110323195200.8383D2A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 14:52:00 2011 New Revision: 128161 URL: http://llvm.org/viewvc/llvm-project?rev=128161&view=rev Log: Start of relocation resolution for the runtime dyld library. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128161&r1=128160&r2=128161&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Mar 23 14:52:00 2011 @@ -11,15 +11,21 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "dyld" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/Object/MachOObject.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/Format.h" #include "llvm/Support/Memory.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/system_error.h" +#include "llvm/Support/raw_ostream.h" using namespace llvm; using namespace llvm::object; @@ -43,6 +49,10 @@ return true; } + bool resolveRelocation(uint32_t BaseSection, macho::RelocationEntry RE, + SmallVectorImpl &SectionBases, + SmallVectorImpl &SymbolNames); + bool loadSegment32(const MachOObject *Obj, const MachOObject::LoadCommandInfo *SegmentLCI, const InMemoryStruct &SymtabLC); @@ -73,7 +83,85 @@ StringRef getErrorString() { return ErrorStr; } }; +// FIXME: Relocations for targets other than x86_64. +bool RuntimeDyldImpl:: +resolveRelocation(uint32_t BaseSection, macho::RelocationEntry RE, + SmallVectorImpl &SectionBases, + SmallVectorImpl &SymbolNames) { + // struct relocation_info { + // int32_t r_address; + // uint32_t r_symbolnum:24, + // r_pcrel:1, + // r_length:2, + // r_extern:1, + // r_type:4; + // }; + uint32_t SymbolNum = RE.Word1 & 0xffffff; // 24-bit value + bool isPCRel = (RE.Word1 >> 24) & 1; + unsigned Log2Size = (RE.Word1 >> 25) & 3; + bool isExtern = (RE.Word1 >> 27) & 1; + unsigned Type = (RE.Word1 >> 28) & 0xf; + if (RE.Word0 & macho::RF_Scattered) + return Error("NOT YET IMPLEMENTED: scattered relocations."); + + // The address requiring a relocation. + intptr_t Address = (intptr_t)SectionBases[BaseSection] + RE.Word0; + + // Figure out the target address of the relocation. If isExtern is true, + // this relocation references the symbol table, otherwise it references + // a section in the same object, numbered from 1 through NumSections + // (SectionBases is [0, NumSections-1]). + intptr_t Value; + if (isExtern) { + StringRef Name = SymbolNames[SymbolNum]; + if (SymbolTable.lookup(Name)) { + // The symbol is in our symbol table, so we can resolve it directly. + Value = (intptr_t)SymbolTable[Name]; + } else { + return Error("NOT YET IMPLEMENTED: relocations to pre-compiled code."); + } + DEBUG(dbgs() << "Resolve relocation(" << Type << ") from '" << Name + << "' to " << format("0x%x", Address) << ".\n"); + } else { + // For non-external relocations, the SymbolNum is actual a section number + // as described above. + Value = (intptr_t)SectionBases[SymbolNum - 1]; + } + // If the relocation is PC-relative, the value to be encoded is the + // pointer difference. + if (isPCRel) + // FIXME: It seems this value needs to be adjusted by 4 for an effective PC + // address. Is that expected? Only for branches, perhaps? + Value -= Address + 4; + + switch(Type) { + default: + llvm_unreachable("Invalid relocation type!"); + case macho::RIT_X86_64_Unsigned: + case macho::RIT_X86_64_Branch: { + // Mask in the target value a byte at a time (we don't have an alignment + // guarantee for the target address, so this is safest). + unsigned Len = 1 << Log2Size; + uint8_t *p = (uint8_t*)Address; + for (unsigned i = 0; i < Len; ++i) { + *p++ = (uint8_t)Value; + Value >>= 8; + } + return false; + } + case macho::RIT_X86_64_Signed: + case macho::RIT_X86_64_GOTLoad: + case macho::RIT_X86_64_GOT: + case macho::RIT_X86_64_Subtractor: + case macho::RIT_X86_64_Signed1: + case macho::RIT_X86_64_Signed2: + case macho::RIT_X86_64_Signed4: + case macho::RIT_X86_64_TLV: + return Error("Relocation type not implemented yet!"); + } + return false; +} bool RuntimeDyldImpl:: loadSegment32(const MachOObject *Obj, @@ -96,7 +184,7 @@ Segment32LC->VMSize - Segment32LC->FileSize); // Bind the section indices to address. - void **SectionBases = new void*[Segment32LC->NumSections]; + SmallVector SectionBases; for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { InMemoryStruct Sect; Obj->ReadSection(*SegmentLCI, i, Sect); @@ -111,7 +199,7 @@ if (Sect->Flags != 0x80000400) return Error("unsupported section type!"); - SectionBases[i] = (char*) Data.base() + Sect->Address; + SectionBases.push_back((char*) Data.base() + Sect->Address); } // Bind all the symbols to address. @@ -142,6 +230,8 @@ if (STE->Flags != 0x0) return Error("unexpected symbol type!"); + DEBUG(dbgs() << "Symbol: '" << Name << "' @ " << Address << "\n"); + SymbolTable[Name] = Address; } @@ -149,7 +239,6 @@ // FIXME: We really should use the JITMemoryManager for this. sys::Memory::setRangeExecutable(Data.base(), Data.size()); - delete SectionBases; return false; } @@ -174,41 +263,54 @@ memset((char*)Data.base() + Segment64LC->FileSize, 0, Segment64LC->VMSize - Segment64LC->FileSize); - // Bind the section indices to address. - void **SectionBases = new void*[Segment64LC->NumSections]; + // Bind the section indices to addresses and record the relocations we + // need to resolve. + typedef std::pair RelocationMap; + SmallVector Relocations; + + SmallVector SectionBases; for (unsigned i = 0; i != Segment64LC->NumSections; ++i) { InMemoryStruct Sect; Obj->ReadSection64(*SegmentLCI, i, Sect); if (!Sect) return Error("unable to load section: '" + Twine(i) + "'"); - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); + // Resolve any relocations the section has. + for (unsigned j = 0; j != Sect->NumRelocationTableEntries; ++j) { + InMemoryStruct RE; + Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE); + Relocations.push_back(RelocationMap(j, *RE)); + } // FIXME: Improve check. if (Sect->Flags != 0x80000400) return Error("unsupported section type!"); - SectionBases[i] = (char*) Data.base() + Sect->Address; + SectionBases.push_back((char*) Data.base() + Sect->Address); } - // Bind all the symbols to address. + // Bind all the symbols to address. Keep a record of the names for use + // by relocation resolution. + SmallVector SymbolNames; for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { InMemoryStruct STE; Obj->ReadSymbol64TableEntry(SymtabLC->SymbolTableOffset, i, STE); if (!STE) return Error("unable to read symbol: '" + Twine(i) + "'"); + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + SymbolNames.push_back(Name); + + // Just skip undefined symbols. They'll be loaded from whatever + // module they come from (or system dylib) when we resolve relocations + // involving them. if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); + continue; unsigned Index = STE->SectionIndex - 1; if (Index >= Segment64LC->NumSections) return Error("invalid section index for symbol: '" + Twine() + "'"); - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - // Get the section base address. void *SectionBase = SectionBases[Index]; @@ -221,14 +323,21 @@ if (STE->Flags != 0x0) return Error("unexpected symbol type!"); + DEBUG(dbgs() << "Symbol: '" << Name << "' @ " << Address << "\n"); SymbolTable[Name] = Address; } + // Now resolve any relocations. + for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { + if (resolveRelocation(Relocations[i].first, Relocations[i].second, + SectionBases, SymbolNames)) + return true; + } + // We've loaded the section; now mark the functions in it as executable. // FIXME: We really should use the JITMemoryManager for this. sys::Memory::setRangeExecutable(Data.base(), Data.size()); - delete SectionBases; return false; } @@ -291,12 +400,12 @@ return Error("unable to load dynamic link-exit load command"); // FIXME: We don't support anything interesting yet. - if (DysymtabLC->LocalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: local symbol entries"); - if (DysymtabLC->ExternalSymbolsIndex != 0) - return Error("NOT YET IMPLEMENTED: non-external symbol entries"); - if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) - return Error("NOT YET IMPLEMENTED: undefined symbol entries"); +// if (DysymtabLC->LocalSymbolsIndex != 0) +// return Error("NOT YET IMPLEMENTED: local symbol entries"); +// if (DysymtabLC->ExternalSymbolsIndex != 0) +// return Error("NOT YET IMPLEMENTED: non-external symbol entries"); +// if (DysymtabLC->UndefinedSymbolsIndex != SymtabLC->NumSymbolTableEntries) +// return Error("NOT YET IMPLEMENTED: undefined symbol entries"); } // Load the segment load command. From atrick at apple.com Wed Mar 23 15:40:18 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 20:40:18 -0000 Subject: [llvm-commits] [llvm] r128163 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <20110323204018.82F342A6C12C@llvm.org> Author: atrick Date: Wed Mar 23 15:40:18 2011 New Revision: 128163 URL: http://llvm.org/viewvc/llvm-project?rev=128163&view=rev Log: whitespace Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=128163&r1=128162&r2=128163&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Wed Mar 23 15:40:18 2011 @@ -1812,7 +1812,7 @@ if (!SU->getNode()) return; - + for (SUnit::pred_iterator I = SU->Preds.begin(), E = SU->Preds.end(); I != E; ++I) { if (I->isCtrl()) @@ -1880,7 +1880,7 @@ const SDNode *N = SU->getNode(); if (!N) return; - + if (!N->isMachineOpcode()) { if (N->getOpcode() != ISD::CopyToReg) return; From atrick at apple.com Wed Mar 23 15:42:39 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 20:42:39 -0000 Subject: [llvm-commits] [llvm] r128164 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <20110323204239.542292A6C12C@llvm.org> Author: atrick Date: Wed Mar 23 15:42:39 2011 New Revision: 128164 URL: http://llvm.org/viewvc/llvm-project?rev=128164&view=rev Log: Ensure that def-side physreg copies are scheduled above any other uses so the scheduler can't create new interferences on the copies themselves. Prior to this fix the scheduler could get stuck in a loop creating copies. Fixes PR9509. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=128164&r1=128163&r2=128164&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Wed Mar 23 15:42:39 2011 @@ -935,6 +935,15 @@ AddPred(SuccSU, D); DelDeps.push_back(std::make_pair(SuccSU, *I)); } + else { + // Avoid scheduling the def-side copy before other successors. Otherwise + // we could introduce another physreg interference on the copy and + // continue inserting copies indefinitely. + SDep D(CopyFromSU, SDep::Order, /*Latency=*/0, + /*Reg=*/0, /*isNormalMemory=*/false, + /*isMustAlias=*/false, /*isArtificial=*/true); + AddPred(SuccSU, D); + } } for (unsigned i = 0, e = DelDeps.size(); i != e; ++i) RemovePred(DelDeps[i].first, DelDeps[i].second); From joerg at britannica.bec.de Wed Mar 23 15:55:36 2011 From: joerg at britannica.bec.de (Joerg Sonnenberger) Date: Wed, 23 Mar 2011 21:55:36 +0100 Subject: [llvm-commits] [PATCH][MC] VIA PadLock support Message-ID: <20110323205536.GA19360@britannica.bec.de> Hi all, attached patch adds the various crypto functions of the VIA PadLock extension. Due to the additional prefixes, this is a bit messy. On the positive side, it cleans up a few of the hard-coded constants to be less redundant. This differs from GAS in one important aspect: I'm not asserting that the instructions are used with the REP prefix. GAS seems to alias them to the form with rep prefix if it not present. Not sure if that should be supported or if it can be asserted. Joerg -------------- next part -------------- A non-text attachment was scrubbed... Name: padlock.diff Type: text/x-diff Size: 20124 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110323/2b68d8aa/attachment.bin From resistor at mac.com Wed Mar 23 16:19:57 2011 From: resistor at mac.com (Owen Anderson) Date: Wed, 23 Mar 2011 21:19:57 -0000 Subject: [llvm-commits] [llvm] r128169 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20110323211957.1E49D2A6C12C@llvm.org> Author: resistor Date: Wed Mar 23 16:19:56 2011 New Revision: 128169 URL: http://llvm.org/viewvc/llvm-project?rev=128169&view=rev Log: Fix a bug introduced by my patch yesterday: BL is a 4-byte instructions like BLX, rather than a 2-byte instruction like B. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=128169&r1=128168&r2=128169&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Wed Mar 23 16:19:56 2011 @@ -949,14 +949,13 @@ // Handle Thumb branches. case ARM::fixup_arm_thumb_br: - case ARM::fixup_arm_thumb_bl: RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit); Log2Size = llvm::Log2_32(2); return true; - + + case ARM::fixup_arm_thumb_bl: case ARM::fixup_arm_thumb_blx: RelocType = unsigned(macho::RIT_ARM_ThumbBranch22Bit); - // Report as 'long', even though that is not quite accurate. Log2Size = llvm::Log2_32(4); return true; From grosbach at apple.com Wed Mar 23 16:35:02 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 21:35:02 -0000 Subject: [llvm-commits] [llvm] r128171 - /llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Message-ID: <20110323213502.E47802A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 16:35:02 2011 New Revision: 128171 URL: http://llvm.org/viewvc/llvm-project?rev=128171&view=rev Log: Fix double-free of Module. The ExecutionEngine constructor already added the module, so there's no need to call addModule() directly. Doing so causes a double-free of the Module at program termination. Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=128171&r1=128170&r2=128171&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Wed Mar 23 16:35:02 2011 @@ -78,7 +78,6 @@ } // Initialize passes. - ExecutionEngine::addModule(M); // FIXME: When we support multiple modules, we'll want to move the code // gen and finalization out of the constructor here and do it more // on-demand as part of getPointerToFunction(). From resistor at mac.com Wed Mar 23 17:03:45 2011 From: resistor at mac.com (Owen Anderson) Date: Wed, 23 Mar 2011 22:03:45 -0000 Subject: [llvm-commits] [llvm] r128172 - /llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Message-ID: <20110323220345.0D01E2A6C12C@llvm.org> Author: resistor Date: Wed Mar 23 17:03:44 2011 New Revision: 128172 URL: http://llvm.org/viewvc/llvm-project?rev=128172&view=rev Log: The high bit of a Thumb2 ADR's offset is stored in bit 26, not bit 25. This fixes 464.h264ref with the integrated assembler. Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=128172&r1=128171&r2=128172&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Wed Mar 23 17:03:44 2011 @@ -246,7 +246,7 @@ } uint32_t out = (opc << 21); - out |= (Value & 0x800) << 14; + out |= (Value & 0x800) << 15; out |= (Value & 0x700) << 4; out |= (Value & 0x0FF); From grosbach at apple.com Wed Mar 23 17:06:06 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 22:06:06 -0000 Subject: [llvm-commits] [llvm] r128173 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110323220606.EDD362A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 17:06:06 2011 New Revision: 128173 URL: http://llvm.org/viewvc/llvm-project?rev=128173&view=rev Log: Split out relocation resolution into target-specific bits. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128173&r1=128172&r2=128173&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Mar 23 17:06:06 2011 @@ -31,6 +31,9 @@ namespace llvm { class RuntimeDyldImpl { + unsigned CPUType; + unsigned CPUSubtype; + // Master symbol table. As modules are loaded and external symbols are // resolved, their addresses are stored here. StringMap SymbolTable; @@ -52,6 +55,10 @@ bool resolveRelocation(uint32_t BaseSection, macho::RelocationEntry RE, SmallVectorImpl &SectionBases, SmallVectorImpl &SymbolNames); + bool resolveX86_64Relocation(intptr_t Address, intptr_t Value, bool isPCRel, + unsigned Type, unsigned Size); + bool resolveARMRelocation(intptr_t Address, intptr_t Value, bool isPCRel, + unsigned Type, unsigned Size); bool loadSegment32(const MachOObject *Obj, const MachOObject::LoadCommandInfo *SegmentLCI, @@ -128,6 +135,20 @@ Value = (intptr_t)SectionBases[SymbolNum - 1]; } + unsigned Size = 1 << Log2Size; + switch (CPUType) { + default: assert(0 && "Unsupported CPU type!"); + case mach::CTM_x86_64: + return resolveX86_64Relocation(Address, Value, isPCRel, Type, Size); + case mach::CTM_ARM: + return resolveARMRelocation(Address, Value, isPCRel, Type, Size); + } + llvm_unreachable(""); +} + +bool RuntimeDyldImpl::resolveX86_64Relocation(intptr_t Address, intptr_t Value, + bool isPCRel, unsigned Type, + unsigned Size) { // If the relocation is PC-relative, the value to be encoded is the // pointer difference. if (isPCRel) @@ -142,9 +163,8 @@ case macho::RIT_X86_64_Branch: { // Mask in the target value a byte at a time (we don't have an alignment // guarantee for the target address, so this is safest). - unsigned Len = 1 << Log2Size; uint8_t *p = (uint8_t*)Address; - for (unsigned i = 0; i < Len; ++i) { + for (unsigned i = 0; i < Size; ++i) { *p++ = (uint8_t)Value; Value >>= 8; } @@ -163,6 +183,46 @@ return false; } +bool RuntimeDyldImpl::resolveARMRelocation(intptr_t Address, intptr_t Value, + bool isPCRel, unsigned Type, + unsigned Size) { + // If the relocation is PC-relative, the value to be encoded is the + // pointer difference. + if (isPCRel) { + Value -= Address; + // ARM PCRel relocations have an effective-PC offset of two instructions + // (four bytes in Thumb mode, 8 bytes in ARM mode). + // FIXME: For now, assume ARM mode. + Value -= 8; + } + + switch(Type) { + default: + case macho::RIT_Vanilla: { + llvm_unreachable("Invalid relocation type!"); + // Mask in the target value a byte at a time (we don't have an alignment + // guarantee for the target address, so this is safest). + uint8_t *p = (uint8_t*)Address; + for (unsigned i = 0; i < Size; ++i) { + *p++ = (uint8_t)Value; + Value >>= 8; + } + return false; + } + case macho::RIT_Pair: + case macho::RIT_Difference: + case macho::RIT_ARM_LocalDifference: + case macho::RIT_ARM_PreboundLazyPointer: + case macho::RIT_ARM_Branch24Bit: + case macho::RIT_ARM_ThumbBranch22Bit: + case macho::RIT_ARM_ThumbBranch32Bit: + case macho::RIT_ARM_Half: + case macho::RIT_ARM_HalfDifference: + return Error("Relocation type not implemented yet!"); + } + return false; +} + bool RuntimeDyldImpl:: loadSegment32(const MachOObject *Obj, const MachOObject::LoadCommandInfo *SegmentLCI, @@ -352,10 +412,18 @@ if (!Obj) return Error("unable to load object: '" + ErrorStr + "'"); + // Get the CPU type information from the header. + const macho::Header &Header = Obj->getHeader(); + + // FIXME: Error checking that the loaded object is compatible with + // the system we're running on. + CPUType = Header.CPUType; + CPUSubtype = Header.CPUSubtype; + // Validate that the load commands match what we expect. const MachOObject::LoadCommandInfo *SegmentLCI = 0, *SymtabLCI = 0, *DysymtabLCI = 0; - for (unsigned i = 0; i != Obj->getHeader().NumLoadCommands; ++i) { + for (unsigned i = 0; i != Header.NumLoadCommands; ++i) { const MachOObject::LoadCommandInfo &LCI = Obj->getLoadCommandInfo(i); switch (LCI.Command.Type) { case macho::LCT_Segment: From atrick at apple.com Wed Mar 23 17:16:02 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 22:16:02 -0000 Subject: [llvm-commits] [llvm] r128175 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/long-setcc.ll test/CodeGen/X86/sext-i1.ll Message-ID: <20110323221602.CE2CE2A6C12E@llvm.org> Author: atrick Date: Wed Mar 23 17:16:02 2011 New Revision: 128175 URL: http://llvm.org/viewvc/llvm-project?rev=128175&view=rev Log: Reapply Eli's r127852 now that the pre-RA scheduler can spill EFLAGS. (target-specific branchless method for double-width relational comparisons on x86) Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/long-setcc.ll llvm/trunk/test/CodeGen/X86/sext-i1.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128175&r1=128174&r2=128175&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 23 17:16:02 2011 @@ -447,12 +447,13 @@ setOperationAction(ISD::SETCC , MVT::i8 , Custom); setOperationAction(ISD::SETCC , MVT::i16 , Custom); setOperationAction(ISD::SETCC , MVT::i32 , Custom); + setOperationAction(ISD::SETCC , MVT::i64 , Custom); setOperationAction(ISD::SETCC , MVT::f32 , Custom); setOperationAction(ISD::SETCC , MVT::f64 , Custom); setOperationAction(ISD::SETCC , MVT::f80 , Custom); if (Subtarget->is64Bit()) { setOperationAction(ISD::SELECT , MVT::i64 , Custom); - setOperationAction(ISD::SETCC , MVT::i64 , Custom); + setOperationAction(ISD::SETCC , MVT::i128 , Custom); } setOperationAction(ISD::EH_RETURN , MVT::Other, Custom); @@ -2853,7 +2854,7 @@ } else if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) { // X < 0 -> X == 0, jump on sign. return X86::COND_S; - } else if (SetCCOpcode == ISD::SETLT && RHSC->getZExtValue() == 1) { + } else if (SetCCOpcode == ISD::SETLT && RHSC->isOne()) { // X < 1 -> X <= 0 RHS = DAG.getConstant(0, RHS.getValueType()); return X86::COND_LE; @@ -7436,7 +7437,8 @@ // Lower (X & (1 << N)) == 0 to BT(X, N). // Lower ((X >>u N) & 1) != 0 to BT(X, N). // Lower ((X >>s N) & 1) != 0 to BT(X, N). - if (Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && + if (isTypeLegal(Op0.getValueType()) && + Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && Op1.getOpcode() == ISD::Constant && cast(Op1)->isNullValue() && (CC == ISD::SETEQ || CC == ISD::SETNE)) { @@ -7448,7 +7450,7 @@ // Look for X == 0, X == 1, X != 0, or X != 1. We can simplify some forms of // these. if (Op1.getOpcode() == ISD::Constant && - (cast(Op1)->getZExtValue() == 1 || + (cast(Op1)->isOne() || cast(Op1)->isNullValue()) && (CC == ISD::SETEQ || CC == ISD::SETNE)) { @@ -7471,6 +7473,73 @@ if (X86CC == X86::COND_INVALID) return SDValue(); + if ((!Subtarget->is64Bit() && Op0.getValueType() == MVT::i64) || + (Subtarget->is64Bit() && Op0.getValueType() == MVT::i128)) { + switch (X86CC) { + case X86::COND_E: + case X86::COND_NE: + case X86::COND_S: + case X86::COND_NS: + // Just use the generic lowering, which works well on x86. + return SDValue(); + case X86::COND_B: + case X86::COND_AE: + case X86::COND_L: + case X86::COND_GE: + // Use SBB-based lowering. + break; + case X86::COND_A: + // Use SBB-based lowering; commute so ZF isn't used. + X86CC = X86::COND_B; + std::swap(Op0, Op1); + break; + case X86::COND_BE: + // Use SBB-based lowering; commute so ZF isn't used. + X86CC = X86::COND_AE; + std::swap(Op0, Op1); + break; + case X86::COND_G: + // Use SBB-based lowering; commute so ZF isn't used. + X86CC = X86::COND_L; + std::swap(Op0, Op1); + break; + case X86::COND_LE: + // Use SBB-based lowering; commute so ZF isn't used. + X86CC = X86::COND_GE; + std::swap(Op0, Op1); + break; + default: + assert(0 && "Unexpected X86CC."); + return SDValue(); + } + MVT HalfType = getPointerTy(); + // FIXME: Refactor this code out to implement ISD::SADDO and friends. + SDValue Op0Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, + Op0, DAG.getIntPtrConstant(0)); + SDValue Op1Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, + Op1, DAG.getIntPtrConstant(0)); + SDValue Op0High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, + Op0, DAG.getIntPtrConstant(1)); + SDValue Op1High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, + Op1, DAG.getIntPtrConstant(1)); + // Redirect some cases which will simplify to the generic expansion; + // X86ISD::SUB and X86ISD::SBB are not optimized well at the moment. + // FIXME: We really need to add DAGCombines for SUB/SBB/etc. + if (Op1Low.getOpcode() == ISD::Constant && + cast(Op1Low)->isNullValue()) + return SDValue(); + if (Op0Low.getOpcode() == ISD::Constant && + cast(Op0Low)->isAllOnesValue()) + return SDValue(); + SDValue res1, res2; + SDVTList VTList = DAG.getVTList(HalfType, MVT::i32); + res1 = DAG.getNode(X86ISD::SUB, dl, VTList, Op0Low, Op1Low).getValue(1); + res2 = DAG.getNode(X86ISD::SBB, dl, VTList, Op0High, Op1High, + res1).getValue(1); + return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, + DAG.getConstant(X86CC, MVT::i8), res2); + } + SDValue EFLAGS = EmitCmp(Op0, Op1, X86CC, DAG); return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, DAG.getConstant(X86CC, MVT::i8), EFLAGS); Modified: llvm/trunk/test/CodeGen/X86/long-setcc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/long-setcc.ll?rev=128175&r1=128174&r2=128175&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/long-setcc.ll (original) +++ llvm/trunk/test/CodeGen/X86/long-setcc.ll Wed Mar 23 17:16:02 2011 @@ -1,18 +1,35 @@ -; RUN: llc < %s -march=x86 | grep cmp | count 1 -; RUN: llc < %s -march=x86 | grep shr | count 1 -; RUN: llc < %s -march=x86 | grep xor | count 1 +; RUN: llc < %s -march=x86 | FileCheck %s -define i1 @t1(i64 %x) nounwind { - %B = icmp slt i64 %x, 0 - ret i1 %B +; General case +define i1 @t1(i64 %x, i64 %y) nounwind { +; CHECK: @t1 +; CHECK: subl +; CHECK: sbbl +; CHECK: setl %al + %B = icmp slt i64 %x, %y + ret i1 %B } +; Some special cases define i1 @t2(i64 %x) nounwind { - %tmp = icmp ult i64 %x, 4294967296 - ret i1 %tmp +; CHECK: @t2 +; CHECK: shrl $31, %eax + %B = icmp slt i64 %x, 0 + ret i1 %B } -define i1 @t3(i32 %x) nounwind { - %tmp = icmp ugt i32 %x, -1 - ret i1 %tmp +define i1 @t3(i64 %x) nounwind { +; CHECK: @t3 +; CHECX: cmpl $0 +; CHECX: sete %al + %tmp = icmp ult i64 %x, 4294967296 + ret i1 %tmp +} + +define i1 @t4(i64 %x) nounwind { +; CHECK: @t4 +; CHECX: cmpl $0 +; CHECX: setne %al + %tmp = icmp ugt i64 %x, 4294967295 + ret i1 %tmp } Modified: llvm/trunk/test/CodeGen/X86/sext-i1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-i1.ll?rev=128175&r1=128174&r2=128175&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sext-i1.ll (original) +++ llvm/trunk/test/CodeGen/X86/sext-i1.ll Wed Mar 23 17:16:02 2011 @@ -39,7 +39,8 @@ ; 32: t3: ; 32: cmpl $1 ; 32: sbbl -; 32: cmpl +; 32: subl +; 32: sbbl ; 32: xorl ; 64: t3: From eli.friedman at gmail.com Wed Mar 23 17:18:48 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 23 Mar 2011 22:18:48 -0000 Subject: [llvm-commits] [llvm] r128176 - in /llvm/trunk: lib/CodeGen/SelectionDAG/LegalizeTypes.h lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp test/CodeGen/X86/fp-trunc.ll Message-ID: <20110323221848.A8AC22A6C12C@llvm.org> Author: efriedma Date: Wed Mar 23 17:18:48 2011 New Revision: 128176 URL: http://llvm.org/viewvc/llvm-project?rev=128176&view=rev Log: PR9535: add support for splitting and scalarizing vector ISD::FP_ROUND. Also cleaning up some duplicated code while I'm here. Added: llvm/trunk/test/CodeGen/X86/fp-trunc.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h?rev=128176&r1=128175&r2=128176&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.h Wed Mar 23 17:18:48 2011 @@ -522,6 +522,7 @@ SDValue ScalarizeVecRes_BITCAST(SDNode *N); SDValue ScalarizeVecRes_CONVERT_RNDSAT(SDNode *N); SDValue ScalarizeVecRes_EXTRACT_SUBVECTOR(SDNode *N); + SDValue ScalarizeVecRes_FP_ROUND(SDNode *N); SDValue ScalarizeVecRes_FPOWI(SDNode *N); SDValue ScalarizeVecRes_INSERT_VECTOR_ELT(SDNode *N); SDValue ScalarizeVecRes_LOAD(LoadSDNode *N); @@ -565,7 +566,6 @@ void SplitVecRes_BUILD_PAIR(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_BUILD_VECTOR(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_CONCAT_VECTORS(SDNode *N, SDValue &Lo, SDValue &Hi); - void SplitVecRes_CONVERT_RNDSAT(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_FPOWI(SDNode *N, SDValue &Lo, SDValue &Hi); void SplitVecRes_INSERT_VECTOR_ELT(SDNode *N, SDValue &Lo, SDValue &Hi); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=128176&r1=128175&r2=128176&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Wed Mar 23 17:18:48 2011 @@ -50,6 +50,7 @@ case ISD::BUILD_VECTOR: R = N->getOperand(0); break; case ISD::CONVERT_RNDSAT: R = ScalarizeVecRes_CONVERT_RNDSAT(N); break; case ISD::EXTRACT_SUBVECTOR: R = ScalarizeVecRes_EXTRACT_SUBVECTOR(N); break; + case ISD::FP_ROUND: R = ScalarizeVecRes_FP_ROUND(N); break; case ISD::FP_ROUND_INREG: R = ScalarizeVecRes_InregOp(N); break; case ISD::FPOWI: R = ScalarizeVecRes_FPOWI(N); break; case ISD::INSERT_VECTOR_ELT: R = ScalarizeVecRes_INSERT_VECTOR_ELT(N); break; @@ -151,6 +152,13 @@ N->getOperand(0), N->getOperand(1)); } +SDValue DAGTypeLegalizer::ScalarizeVecRes_FP_ROUND(SDNode *N) { + EVT NewVT = N->getValueType(0).getVectorElementType(); + SDValue Op = GetScalarizedVector(N->getOperand(0)); + return DAG.getNode(ISD::FP_ROUND, N->getDebugLoc(), + NewVT, Op, N->getOperand(1)); +} + SDValue DAGTypeLegalizer::ScalarizeVecRes_FPOWI(SDNode *N) { SDValue Op = GetScalarizedVector(N->getOperand(0)); return DAG.getNode(ISD::FPOWI, N->getDebugLoc(), @@ -411,11 +419,9 @@ case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi); break; case ISD::SELECT_CC: SplitRes_SELECT_CC(N, Lo, Hi); break; case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break; - case ISD::BITCAST: SplitVecRes_BITCAST(N, Lo, Hi); break; case ISD::BUILD_VECTOR: SplitVecRes_BUILD_VECTOR(N, Lo, Hi); break; case ISD::CONCAT_VECTORS: SplitVecRes_CONCAT_VECTORS(N, Lo, Hi); break; - case ISD::CONVERT_RNDSAT: SplitVecRes_CONVERT_RNDSAT(N, Lo, Hi); break; case ISD::EXTRACT_SUBVECTOR: SplitVecRes_EXTRACT_SUBVECTOR(N, Lo, Hi); break; case ISD::FP_ROUND_INREG: SplitVecRes_InregOp(N, Lo, Hi); break; case ISD::FPOWI: SplitVecRes_FPOWI(N, Lo, Hi); break; @@ -434,6 +440,7 @@ break; case ISD::ANY_EXTEND: + case ISD::CONVERT_RNDSAT: case ISD::CTLZ: case ISD::CTPOP: case ISD::CTTZ: @@ -449,6 +456,7 @@ case ISD::FNEARBYINT: case ISD::FNEG: case ISD::FP_EXTEND: + case ISD::FP_ROUND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::FRINT: @@ -594,60 +602,6 @@ Hi = DAG.getNode(ISD::CONCAT_VECTORS, dl, HiVT, &HiOps[0], HiOps.size()); } -void DAGTypeLegalizer::SplitVecRes_CONVERT_RNDSAT(SDNode *N, SDValue &Lo, - SDValue &Hi) { - EVT LoVT, HiVT; - DebugLoc dl = N->getDebugLoc(); - GetSplitDestVTs(N->getValueType(0), LoVT, HiVT); - - SDValue DTyOpLo = DAG.getValueType(LoVT); - SDValue DTyOpHi = DAG.getValueType(HiVT); - - SDValue RndOp = N->getOperand(3); - SDValue SatOp = N->getOperand(4); - ISD::CvtCode CvtCode = cast(N)->getCvtCode(); - - // Split the input. - SDValue VLo, VHi; - EVT InVT = N->getOperand(0).getValueType(); - switch (getTypeAction(InVT)) { - default: llvm_unreachable("Unexpected type action!"); - case Legal: { - EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(), - LoVT.getVectorNumElements()); - VLo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0), - DAG.getIntPtrConstant(0)); - VHi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0), - DAG.getIntPtrConstant(InNVT.getVectorNumElements())); - break; - } - case SplitVector: - GetSplitVector(N->getOperand(0), VLo, VHi); - break; - case WidenVector: { - // If the result needs to be split and the input needs to be widened, - // the two types must have different lengths. Use the widened result - // and extract from it to do the split. - SDValue InOp = GetWidenedVector(N->getOperand(0)); - EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(), - LoVT.getVectorNumElements()); - VLo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, InOp, - DAG.getIntPtrConstant(0)); - VHi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, InOp, - DAG.getIntPtrConstant(InNVT.getVectorNumElements())); - break; - } - } - - SDValue STyOpLo = DAG.getValueType(VLo.getValueType()); - SDValue STyOpHi = DAG.getValueType(VHi.getValueType()); - - Lo = DAG.getConvertRndSat(LoVT, dl, VLo, DTyOpLo, STyOpLo, RndOp, SatOp, - CvtCode); - Hi = DAG.getConvertRndSat(HiVT, dl, VHi, DTyOpHi, STyOpHi, RndOp, SatOp, - CvtCode); -} - void DAGTypeLegalizer::SplitVecRes_EXTRACT_SUBVECTOR(SDNode *N, SDValue &Lo, SDValue &Hi) { SDValue Vec = N->getOperand(0); @@ -847,8 +801,25 @@ } } - Lo = DAG.getNode(N->getOpcode(), dl, LoVT, Lo); - Hi = DAG.getNode(N->getOpcode(), dl, HiVT, Hi); + if (N->getOpcode() == ISD::FP_ROUND) { + Lo = DAG.getNode(N->getOpcode(), dl, LoVT, Lo, N->getOperand(1)); + Hi = DAG.getNode(N->getOpcode(), dl, HiVT, Hi, N->getOperand(1)); + } else if (N->getOpcode() == ISD::CONVERT_RNDSAT) { + SDValue DTyOpLo = DAG.getValueType(LoVT); + SDValue DTyOpHi = DAG.getValueType(HiVT); + SDValue STyOpLo = DAG.getValueType(Lo.getValueType()); + SDValue STyOpHi = DAG.getValueType(Hi.getValueType()); + SDValue RndOp = N->getOperand(3); + SDValue SatOp = N->getOperand(4); + ISD::CvtCode CvtCode = cast(N)->getCvtCode(); + Lo = DAG.getConvertRndSat(LoVT, dl, Lo, DTyOpLo, STyOpLo, RndOp, SatOp, + CvtCode); + Hi = DAG.getConvertRndSat(HiVT, dl, Hi, DTyOpHi, STyOpHi, RndOp, SatOp, + CvtCode); + } else { + Lo = DAG.getNode(N->getOpcode(), dl, LoVT, Lo); + Hi = DAG.getNode(N->getOpcode(), dl, HiVT, Hi); + } } void DAGTypeLegalizer::SplitVecRes_VECTOR_SHUFFLE(ShuffleVectorSDNode *N, @@ -2018,7 +1989,6 @@ case ISD::STORE: Res = WidenVecOp_STORE(N); break; case ISD::FP_EXTEND: - case ISD::FP_ROUND: case ISD::FP_TO_SINT: case ISD::FP_TO_UINT: case ISD::SINT_TO_FP: Added: llvm/trunk/test/CodeGen/X86/fp-trunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-trunc.ll?rev=128176&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/fp-trunc.ll (added) +++ llvm/trunk/test/CodeGen/X86/fp-trunc.ll Wed Mar 23 17:18:48 2011 @@ -0,0 +1,35 @@ +; RUN: llc < %s -march=x86 -mattr=+sse2,-avx + +define <1 x float> @test1(<1 x double> %x) nounwind { +; CHECK: cvtsd2ss +; CHECK: ret + %y = fptrunc <1 x double> %x to <1 x float> + ret <1 x float> %y +} + + +define <2 x float> @test2(<2 x double> %x) nounwind { +; FIXME: It would be nice if this compiled down to a cvtpd2ps +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: ret + %y = fptrunc <2 x double> %x to <2 x float> + ret <2 x float> %y +} + +define <8 x float> @test3(<8 x double> %x) nounwind { +; FIXME: It would be nice if this compiled down to a series of cvtpd2ps +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: cvtsd2ss +; CHECK: ret + %y = fptrunc <8 x double> %x to <8 x float> + ret <8 x float> %y +} + + From dpatel at apple.com Wed Mar 23 17:34:19 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 23 Mar 2011 15:34:19 -0700 Subject: [llvm-commits] [llvm] r128155 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: <20110323183730.3679B2A6C12C@llvm.org> References: <20110323183730.3679B2A6C12C@llvm.org> Message-ID: On Mar 23, 2011, at 11:37 AM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Wed Mar 23 13:37:30 2011 > New Revision: 128155 > > URL: http://llvm.org/viewvc/llvm-project?rev=128155&view=rev > Log: > Don't coalesce identical DBG_VALUE instructions prematurely. > > Each of these instructions may have a RegsClobberInsn entry that can't be > ignored. Consecutive ranges are coalesced later when DwarfDebug::emitDebugLoc > merges entries. How about coalescing these instructions before calculating RegsClobberInsns ? - Devang > > Modified: > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128155&r1=128154&r2=128155&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Mar 23 13:37:30 2011 > @@ -2419,14 +2419,12 @@ > if (Processed.count(DV) != 0) > continue; > > - const MachineInstr *PrevMI = MInsn; > for (SmallVector::iterator MI = I+1, > ME = DbgValues.end(); MI != ME; ++MI) { > const MDNode *Var = > (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); > - if (Var == DV && !PrevMI->isIdenticalTo(*MI)) > + if (Var == DV) > MultipleValues.push_back(*MI); > - PrevMI = *MI; > } > > DbgScope *Scope = NULL; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From eli.friedman at gmail.com Wed Mar 23 17:41:23 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 23 Mar 2011 15:41:23 -0700 Subject: [llvm-commits] [llvm] r128175 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/long-setcc.ll test/CodeGen/X86/sext-i1.ll In-Reply-To: <20110323221602.CE2CE2A6C12E@llvm.org> References: <20110323221602.CE2CE2A6C12E@llvm.org> Message-ID: On Wed, Mar 23, 2011 at 3:16 PM, Andrew Trick wrote: > Author: atrick > Date: Wed Mar 23 17:16:02 2011 > New Revision: 128175 > > URL: http://llvm.org/viewvc/llvm-project?rev=128175&view=rev > Log: > Reapply Eli's r127852 now that the pre-RA scheduler can spill EFLAGS. > (target-specific branchless method for double-width relational comparisons on x86) Mmm... I'm still not very happy with the fact that we're generating pushfl/popfl in cases like the one I mentioned in http://llvm.org/bugs/show_bug.cgi?id=9509#c3 . Especially considering that I'm not entirely sure the method we use for copying EFLAGS is safe on 64-bit systems. -Eli > Modified: > ? ?llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > ? ?llvm/trunk/test/CodeGen/X86/long-setcc.ll > ? ?llvm/trunk/test/CodeGen/X86/sext-i1.ll > > Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128175&r1=128174&r2=128175&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 23 17:16:02 2011 > @@ -447,12 +447,13 @@ > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::i8 ? , Custom); > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::i16 ?, Custom); > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::i32 ?, Custom); > + ?setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::i64 ?, Custom); > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::f32 ?, Custom); > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::f64 ?, Custom); > ? setOperationAction(ISD::SETCC ? ? ? ? ? , MVT::f80 ?, Custom); > ? if (Subtarget->is64Bit()) { > ? ? setOperationAction(ISD::SELECT ? ? ? ?, MVT::i64 ?, Custom); > - ? ?setOperationAction(ISD::SETCC ? ? ? ? , MVT::i64 ?, Custom); > + ? ?setOperationAction(ISD::SETCC ? ? ? ? , MVT::i128 , Custom); > ? } > ? setOperationAction(ISD::EH_RETURN ? ? ? , MVT::Other, Custom); > > @@ -2853,7 +2854,7 @@ > ? ? ? } else if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) { > ? ? ? ? // X < 0 ? -> X == 0, jump on sign. > ? ? ? ? return X86::COND_S; > - ? ? ?} else if (SetCCOpcode == ISD::SETLT && RHSC->getZExtValue() == 1) { > + ? ? ?} else if (SetCCOpcode == ISD::SETLT && RHSC->isOne()) { > ? ? ? ? // X < 1 ? -> X <= 0 > ? ? ? ? RHS = DAG.getConstant(0, RHS.getValueType()); > ? ? ? ? return X86::COND_LE; > @@ -7436,7 +7437,8 @@ > ? // Lower (X & (1 << N)) == 0 to BT(X, N). > ? // Lower ((X >>u N) & 1) != 0 to BT(X, N). > ? // Lower ((X >>s N) & 1) != 0 to BT(X, N). > - ?if (Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && > + ?if (isTypeLegal(Op0.getValueType()) && > + ? ? ?Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && > ? ? ? Op1.getOpcode() == ISD::Constant && > ? ? ? cast(Op1)->isNullValue() && > ? ? ? (CC == ISD::SETEQ || CC == ISD::SETNE)) { > @@ -7448,7 +7450,7 @@ > ? // Look for X == 0, X == 1, X != 0, or X != 1. ?We can simplify some forms of > ? // these. > ? if (Op1.getOpcode() == ISD::Constant && > - ? ? ?(cast(Op1)->getZExtValue() == 1 || > + ? ? ?(cast(Op1)->isOne() || > ? ? ? ?cast(Op1)->isNullValue()) && > ? ? ? (CC == ISD::SETEQ || CC == ISD::SETNE)) { > > @@ -7471,6 +7473,73 @@ > ? if (X86CC == X86::COND_INVALID) > ? ? return SDValue(); > > + ?if ((!Subtarget->is64Bit() && Op0.getValueType() == MVT::i64) || > + ? ? ?(Subtarget->is64Bit() && Op0.getValueType() == MVT::i128)) { > + ? ?switch (X86CC) { > + ? ?case X86::COND_E: > + ? ?case X86::COND_NE: > + ? ?case X86::COND_S: > + ? ?case X86::COND_NS: > + ? ? ?// Just use the generic lowering, which works well on x86. > + ? ? ?return SDValue(); > + ? ?case X86::COND_B: > + ? ?case X86::COND_AE: > + ? ?case X86::COND_L: > + ? ?case X86::COND_GE: > + ? ? ?// Use SBB-based lowering. > + ? ? ?break; > + ? ?case X86::COND_A: > + ? ? ?// Use SBB-based lowering; commute so ZF isn't used. > + ? ? ?X86CC = X86::COND_B; > + ? ? ?std::swap(Op0, Op1); > + ? ? ?break; > + ? ?case X86::COND_BE: > + ? ? ?// Use SBB-based lowering; commute so ZF isn't used. > + ? ? ?X86CC = X86::COND_AE; > + ? ? ?std::swap(Op0, Op1); > + ? ? ?break; > + ? ?case X86::COND_G: > + ? ? ?// Use SBB-based lowering; commute so ZF isn't used. > + ? ? ?X86CC = X86::COND_L; > + ? ? ?std::swap(Op0, Op1); > + ? ? ?break; > + ? ?case X86::COND_LE: > + ? ? ?// Use SBB-based lowering; commute so ZF isn't used. > + ? ? ?X86CC = X86::COND_GE; > + ? ? ?std::swap(Op0, Op1); > + ? ? ?break; > + ? ?default: > + ? ? ?assert(0 && "Unexpected X86CC."); > + ? ? ?return SDValue(); > + ? ?} > + ? ?MVT HalfType = getPointerTy(); > + ? ?// FIXME: Refactor this code out to implement ISD::SADDO and friends. > + ? ?SDValue Op0Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Op0, DAG.getIntPtrConstant(0)); > + ? ?SDValue Op1Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Op1, DAG.getIntPtrConstant(0)); > + ? ?SDValue Op0High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Op0, DAG.getIntPtrConstant(1)); > + ? ?SDValue Op1High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Op1, DAG.getIntPtrConstant(1)); > + ? ?// Redirect some cases which will simplify to the generic expansion; > + ? ?// X86ISD::SUB and X86ISD::SBB are not optimized well at the moment. > + ? ?// FIXME: We really need to add DAGCombines for SUB/SBB/etc. > + ? ?if (Op1Low.getOpcode() == ISD::Constant && > + ? ? ? ?cast(Op1Low)->isNullValue()) > + ? ? ?return SDValue(); > + ? ?if (Op0Low.getOpcode() == ISD::Constant && > + ? ? ? ?cast(Op0Low)->isAllOnesValue()) > + ? ? ?return SDValue(); > + ? ?SDValue res1, res2; > + ? ?SDVTList VTList = DAG.getVTList(HalfType, MVT::i32); > + ? ?res1 = DAG.getNode(X86ISD::SUB, dl, VTList, Op0Low, Op1Low).getValue(1); > + ? ?res2 = DAG.getNode(X86ISD::SBB, dl, VTList, Op0High, Op1High, > + ? ? ? ? ? ? ? ? ? ? ? res1).getValue(1); > + ? ?return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, > + ? ? ? ? ? ? ? ? ? ? ? DAG.getConstant(X86CC, MVT::i8), res2); > + ?} > + > ? SDValue EFLAGS = EmitCmp(Op0, Op1, X86CC, DAG); > ? return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, > ? ? ? ? ? ? ? ? ? ? ?DAG.getConstant(X86CC, MVT::i8), EFLAGS); > > Modified: llvm/trunk/test/CodeGen/X86/long-setcc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/long-setcc.ll?rev=128175&r1=128174&r2=128175&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/long-setcc.ll (original) > +++ llvm/trunk/test/CodeGen/X86/long-setcc.ll Wed Mar 23 17:16:02 2011 > @@ -1,18 +1,35 @@ > -; RUN: llc < %s -march=x86 | grep cmp | count 1 > -; RUN: llc < %s -march=x86 | grep shr | count 1 > -; RUN: llc < %s -march=x86 | grep xor | count 1 > +; RUN: llc < %s -march=x86 | FileCheck %s > > -define i1 @t1(i64 %x) nounwind { > - ? ? ? %B = icmp slt i64 %x, 0 > - ? ? ? ret i1 %B > +; General case > +define i1 @t1(i64 %x, i64 %y) nounwind { > +; CHECK: @t1 > +; CHECK: subl > +; CHECK: sbbl > +; CHECK: setl %al > + ?%B = icmp slt i64 %x, %y > + ?ret i1 %B > ?} > > +; Some special cases > ?define i1 @t2(i64 %x) nounwind { > - ? ? ? %tmp = icmp ult i64 %x, 4294967296 > - ? ? ? ret i1 %tmp > +; CHECK: @t2 > +; CHECK: shrl $31, %eax > + ?%B = icmp slt i64 %x, 0 > + ?ret i1 %B > ?} > > -define i1 @t3(i32 %x) nounwind { > - ? ? ? %tmp = icmp ugt i32 %x, -1 > - ? ? ? ret i1 %tmp > +define i1 @t3(i64 %x) nounwind { > +; CHECK: @t3 > +; CHECX: cmpl $0 > +; CHECX: sete %al > + ?%tmp = icmp ult i64 %x, 4294967296 > + ?ret i1 %tmp > +} > + > +define i1 @t4(i64 %x) nounwind { > +; CHECK: @t4 > +; CHECX: cmpl $0 > +; CHECX: setne %al > + ?%tmp = icmp ugt i64 %x, 4294967295 > + ?ret i1 %tmp > ?} > > Modified: llvm/trunk/test/CodeGen/X86/sext-i1.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-i1.ll?rev=128175&r1=128174&r2=128175&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/sext-i1.ll (original) > +++ llvm/trunk/test/CodeGen/X86/sext-i1.ll Wed Mar 23 17:16:02 2011 > @@ -39,7 +39,8 @@ > ?; 32: t3: > ?; 32: cmpl $1 > ?; 32: sbbl > -; 32: cmpl > +; 32: subl > +; 32: sbbl > ?; 32: xorl > > ?; 64: t3: > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stoklund at 2pi.dk Wed Mar 23 17:49:28 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 23 Mar 2011 15:49:28 -0700 Subject: [llvm-commits] [llvm] r128155 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: References: <20110323183730.3679B2A6C12C@llvm.org> Message-ID: <6075D5B5-7BFC-4906-B96C-D2A0CB0DD129@2pi.dk> On Mar 23, 2011, at 3:34 PM, Devang Patel wrote: > > On Mar 23, 2011, at 11:37 AM, Jakob Stoklund Olesen wrote: > >> Author: stoklund >> Date: Wed Mar 23 13:37:30 2011 >> New Revision: 128155 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128155&view=rev >> Log: >> Don't coalesce identical DBG_VALUE instructions prematurely. >> >> Each of these instructions may have a RegsClobberInsn entry that can't be >> ignored. Consecutive ranges are coalesced later when DwarfDebug::emitDebugLoc >> merges entries. > > How about coalescing these instructions before calculating RegsClobberInsns ? That is possible, but we need to consider the end of basic blocks first. The range of a DBG_VALUE in a register should end at the first of: 1. The next DBG_VALUE for the variable. 2. After the instruction clobbering the register. 3. The end of the basic block. If we fix this, the efficient approach should be easy. /jakob From evan.cheng at apple.com Wed Mar 23 17:52:04 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 23 Mar 2011 22:52:04 -0000 Subject: [llvm-commits] [llvm] r128179 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.cpp test/CodeGen/ARM/2011-03-23-PeepholeBug.ll test/CodeGen/ARM/long_shift.ll Message-ID: <20110323225204.6D9812A6C12C@llvm.org> Author: evancheng Date: Wed Mar 23 17:52:04 2011 New Revision: 128179 URL: http://llvm.org/viewvc/llvm-project?rev=128179&view=rev Log: Cmp peephole optimization isn't always safe for signed arithmetics. int tries = INT_MAX; while (tries > 0) { tries--; } The check should be: subs r4, #1 cmp r4, #0 bgt LBB0_1 The subs can set the overflow V bit when r4 is INT_MAX+1 (which loop canonicalization apparently does in this case). cmp #0 would have cleared it while not changing the N and Z bits. Since BGT is dependent on the V bit, i.e. (N == V) && !Z, it is not safe to eliminate the cmp #0. rdar://9172742 Added: llvm/trunk/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/test/CodeGen/ARM/long_shift.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=128179&r1=128178&r2=128179&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Wed Mar 23 17:52:04 2011 @@ -1612,11 +1612,51 @@ switch (MI->getOpcode()) { default: break; case ARM::ADDri: - case ARM::ANDri: - case ARM::t2ANDri: case ARM::SUBri: case ARM::t2ADDri: - case ARM::t2SUBri: + case ARM::t2SUBri: { + // Scan forward for the use of CPSR, if it's a conditional code requires + // checking of V bit, then this is not safe to do. If we can't find the + // CPSR use (i.e. used in another block), then it's not safe to perform + // the optimization. + bool isSafe = false; + I = CmpInstr; + E = MI->getParent()->end(); + while (!isSafe && ++I != E) { + const MachineInstr &Instr = *I; + for (unsigned IO = 0, EO = Instr.getNumOperands(); + !isSafe && IO != EO; ++IO) { + const MachineOperand &MO = Instr.getOperand(IO); + if (!MO.isReg() || MO.getReg() != ARM::CPSR) + continue; + if (MO.isDef()) { + isSafe = true; + break; + } + // Condition code is after the operand before CPSR. + ARMCC::CondCodes CC = (ARMCC::CondCodes)Instr.getOperand(IO-1).getImm(); + switch (CC) { + default: + isSafe = true; + break; + case ARMCC::VS: + case ARMCC::VC: + case ARMCC::GE: + case ARMCC::LT: + case ARMCC::GT: + case ARMCC::LE: + return false; + } + } + } + + if (!isSafe) + return false; + + // fallthrough + } + case ARM::ANDri: + case ARM::t2ANDri: // Toggle the optional operand to CPSR. MI->getOperand(5).setReg(ARM::CPSR); MI->getOperand(5).setIsDef(true); Added: llvm/trunk/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll?rev=128179&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2011-03-23-PeepholeBug.ll Wed Mar 23 17:52:04 2011 @@ -0,0 +1,41 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -relocation-model=pic -disable-fp-elim -mcpu=cortex-a8 | FileCheck %s + +; subs r4, #1 +; cmp r4, 0 +; bgt +; cmp cannot be optimized away since it will clear the overflow bit. +; gt / ge, lt, le conditions all depend on V bit. +; rdar://9172742 + +define i32 @t() nounwind { +; CHECK: t: +entry: + br label %bb2 + +bb: ; preds = %bb2 + %0 = tail call i32 @rand() nounwind + %1 = icmp eq i32 %0, 50 + br i1 %1, label %bb3, label %bb1 + +bb1: ; preds = %bb + %tmp = tail call i32 @puts() nounwind + %indvar.next = add i32 %indvar, 1 + br label %bb2 + +bb2: ; preds = %bb1, %entry +; CHECK: bb2 +; CHECK: subs [[REG:r[0-9]+]], #1 +; CHECK: cmp [[REG]], #0 +; CHECK: bgt + %indvar = phi i32 [ %indvar.next, %bb1 ], [ 0, %entry ] + %tries.0 = sub i32 2147483647, %indvar + %tmp1 = icmp sgt i32 %tries.0, 0 + br i1 %tmp1, label %bb, label %bb3 + +bb3: ; preds = %bb2, %bb + ret i32 0 +} + +declare i32 @rand() + +declare i32 @puts() nounwind Modified: llvm/trunk/test/CodeGen/ARM/long_shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/long_shift.ll?rev=128179&r1=128178&r2=128179&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/long_shift.ll (original) +++ llvm/trunk/test/CodeGen/ARM/long_shift.ll Wed Mar 23 17:52:04 2011 @@ -24,7 +24,8 @@ ; CHECK: f2 ; CHECK: lsr{{.*}}r2 ; CHECK-NEXT: rsb r3, r2, #32 -; CHECK-NEXT: subs r2, r2, #32 +; CHECK-NEXT: sub r2, r2, #32 +; CHECK-NEXT: cmp r2, #0 ; CHECK-NEXT: orr r0, r0, r1, lsl r3 ; CHECK-NEXT: asrge r0, r1, r2 %a = ashr i64 %x, %y @@ -36,7 +37,8 @@ ; CHECK: f3 ; CHECK: lsr{{.*}}r2 ; CHECK-NEXT: rsb r3, r2, #32 -; CHECK-NEXT: subs r2, r2, #32 +; CHECK-NEXT: sub r2, r2, #32 +; CHECK-NEXT: cmp r2, #0 ; CHECK-NEXT: orr r0, r0, r1, lsl r3 ; CHECK-NEXT: lsrge r0, r1, r2 %a = lshr i64 %x, %y From atrick at apple.com Wed Mar 23 18:03:22 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 16:03:22 -0700 Subject: [llvm-commits] [llvm] r128175 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/long-setcc.ll test/CodeGen/X86/sext-i1.ll In-Reply-To: References: <20110323221602.CE2CE2A6C12E@llvm.org> Message-ID: On Mar 23, 2011, at 3:41 PM, Eli Friedman wrote: > On Wed, Mar 23, 2011 at 3:16 PM, Andrew Trick wrote: >> Author: atrick >> Date: Wed Mar 23 17:16:02 2011 >> New Revision: 128175 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128175&view=rev >> Log: >> Reapply Eli's r127852 now that the pre-RA scheduler can spill EFLAGS. >> (target-specific branchless method for double-width relational comparisons on x86) > > Mmm... I'm still not very happy with the fact that we're generating > pushfl/popfl in cases like the one I mentioned in > http://llvm.org/bugs/show_bug.cgi?id=9509#c3 . Especially considering > that I'm not entirely sure the method we use for copying EFLAGS is > safe on 64-bit systems. > > -Eli Thanks for verifying this corner case. I noticed the code is fairly bad, although the original before your patch wasn't good either. I debated filing another bug to follow up on the performance, but wasn't sure how much we cared about this case. It only occurred in a self-host builder; no benchmarks. Of course, if you think we may have a correctness issue, please file another bug. -Andy >> Modified: >> llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> llvm/trunk/test/CodeGen/X86/long-setcc.ll >> llvm/trunk/test/CodeGen/X86/sext-i1.ll >> >> Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128175&r1=128174&r2=128175&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 23 17:16:02 2011 >> @@ -447,12 +447,13 @@ >> setOperationAction(ISD::SETCC , MVT::i8 , Custom); >> setOperationAction(ISD::SETCC , MVT::i16 , Custom); >> setOperationAction(ISD::SETCC , MVT::i32 , Custom); >> + setOperationAction(ISD::SETCC , MVT::i64 , Custom); >> setOperationAction(ISD::SETCC , MVT::f32 , Custom); >> setOperationAction(ISD::SETCC , MVT::f64 , Custom); >> setOperationAction(ISD::SETCC , MVT::f80 , Custom); >> if (Subtarget->is64Bit()) { >> setOperationAction(ISD::SELECT , MVT::i64 , Custom); >> - setOperationAction(ISD::SETCC , MVT::i64 , Custom); >> + setOperationAction(ISD::SETCC , MVT::i128 , Custom); >> } >> setOperationAction(ISD::EH_RETURN , MVT::Other, Custom); >> >> @@ -2853,7 +2854,7 @@ >> } else if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) { >> // X < 0 -> X == 0, jump on sign. >> return X86::COND_S; >> - } else if (SetCCOpcode == ISD::SETLT && RHSC->getZExtValue() == 1) { >> + } else if (SetCCOpcode == ISD::SETLT && RHSC->isOne()) { >> // X < 1 -> X <= 0 >> RHS = DAG.getConstant(0, RHS.getValueType()); >> return X86::COND_LE; >> @@ -7436,7 +7437,8 @@ >> // Lower (X & (1 << N)) == 0 to BT(X, N). >> // Lower ((X >>u N) & 1) != 0 to BT(X, N). >> // Lower ((X >>s N) & 1) != 0 to BT(X, N). >> - if (Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && >> + if (isTypeLegal(Op0.getValueType()) && >> + Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && >> Op1.getOpcode() == ISD::Constant && >> cast(Op1)->isNullValue() && >> (CC == ISD::SETEQ || CC == ISD::SETNE)) { >> @@ -7448,7 +7450,7 @@ >> // Look for X == 0, X == 1, X != 0, or X != 1. We can simplify some forms of >> // these. >> if (Op1.getOpcode() == ISD::Constant && >> - (cast(Op1)->getZExtValue() == 1 || >> + (cast(Op1)->isOne() || >> cast(Op1)->isNullValue()) && >> (CC == ISD::SETEQ || CC == ISD::SETNE)) { >> >> @@ -7471,6 +7473,73 @@ >> if (X86CC == X86::COND_INVALID) >> return SDValue(); >> >> + if ((!Subtarget->is64Bit() && Op0.getValueType() == MVT::i64) || >> + (Subtarget->is64Bit() && Op0.getValueType() == MVT::i128)) { >> + switch (X86CC) { >> + case X86::COND_E: >> + case X86::COND_NE: >> + case X86::COND_S: >> + case X86::COND_NS: >> + // Just use the generic lowering, which works well on x86. >> + return SDValue(); >> + case X86::COND_B: >> + case X86::COND_AE: >> + case X86::COND_L: >> + case X86::COND_GE: >> + // Use SBB-based lowering. >> + break; >> + case X86::COND_A: >> + // Use SBB-based lowering; commute so ZF isn't used. >> + X86CC = X86::COND_B; >> + std::swap(Op0, Op1); >> + break; >> + case X86::COND_BE: >> + // Use SBB-based lowering; commute so ZF isn't used. >> + X86CC = X86::COND_AE; >> + std::swap(Op0, Op1); >> + break; >> + case X86::COND_G: >> + // Use SBB-based lowering; commute so ZF isn't used. >> + X86CC = X86::COND_L; >> + std::swap(Op0, Op1); >> + break; >> + case X86::COND_LE: >> + // Use SBB-based lowering; commute so ZF isn't used. >> + X86CC = X86::COND_GE; >> + std::swap(Op0, Op1); >> + break; >> + default: >> + assert(0 && "Unexpected X86CC."); >> + return SDValue(); >> + } >> + MVT HalfType = getPointerTy(); >> + // FIXME: Refactor this code out to implement ISD::SADDO and friends. >> + SDValue Op0Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, >> + Op0, DAG.getIntPtrConstant(0)); >> + SDValue Op1Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, >> + Op1, DAG.getIntPtrConstant(0)); >> + SDValue Op0High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, >> + Op0, DAG.getIntPtrConstant(1)); >> + SDValue Op1High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, >> + Op1, DAG.getIntPtrConstant(1)); >> + // Redirect some cases which will simplify to the generic expansion; >> + // X86ISD::SUB and X86ISD::SBB are not optimized well at the moment. >> + // FIXME: We really need to add DAGCombines for SUB/SBB/etc. >> + if (Op1Low.getOpcode() == ISD::Constant && >> + cast(Op1Low)->isNullValue()) >> + return SDValue(); >> + if (Op0Low.getOpcode() == ISD::Constant && >> + cast(Op0Low)->isAllOnesValue()) >> + return SDValue(); >> + SDValue res1, res2; >> + SDVTList VTList = DAG.getVTList(HalfType, MVT::i32); >> + res1 = DAG.getNode(X86ISD::SUB, dl, VTList, Op0Low, Op1Low).getValue(1); >> + res2 = DAG.getNode(X86ISD::SBB, dl, VTList, Op0High, Op1High, >> + res1).getValue(1); >> + return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, >> + DAG.getConstant(X86CC, MVT::i8), res2); >> + } >> + >> SDValue EFLAGS = EmitCmp(Op0, Op1, X86CC, DAG); >> return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, >> DAG.getConstant(X86CC, MVT::i8), EFLAGS); >> >> Modified: llvm/trunk/test/CodeGen/X86/long-setcc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/long-setcc.ll?rev=128175&r1=128174&r2=128175&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/X86/long-setcc.ll (original) >> +++ llvm/trunk/test/CodeGen/X86/long-setcc.ll Wed Mar 23 17:16:02 2011 >> @@ -1,18 +1,35 @@ >> -; RUN: llc < %s -march=x86 | grep cmp | count 1 >> -; RUN: llc < %s -march=x86 | grep shr | count 1 >> -; RUN: llc < %s -march=x86 | grep xor | count 1 >> +; RUN: llc < %s -march=x86 | FileCheck %s >> >> -define i1 @t1(i64 %x) nounwind { >> - %B = icmp slt i64 %x, 0 >> - ret i1 %B >> +; General case >> +define i1 @t1(i64 %x, i64 %y) nounwind { >> +; CHECK: @t1 >> +; CHECK: subl >> +; CHECK: sbbl >> +; CHECK: setl %al >> + %B = icmp slt i64 %x, %y >> + ret i1 %B >> } >> >> +; Some special cases >> define i1 @t2(i64 %x) nounwind { >> - %tmp = icmp ult i64 %x, 4294967296 >> - ret i1 %tmp >> +; CHECK: @t2 >> +; CHECK: shrl $31, %eax >> + %B = icmp slt i64 %x, 0 >> + ret i1 %B >> } >> >> -define i1 @t3(i32 %x) nounwind { >> - %tmp = icmp ugt i32 %x, -1 >> - ret i1 %tmp >> +define i1 @t3(i64 %x) nounwind { >> +; CHECK: @t3 >> +; CHECX: cmpl $0 >> +; CHECX: sete %al >> + %tmp = icmp ult i64 %x, 4294967296 >> + ret i1 %tmp >> +} >> + >> +define i1 @t4(i64 %x) nounwind { >> +; CHECK: @t4 >> +; CHECX: cmpl $0 >> +; CHECX: setne %al >> + %tmp = icmp ugt i64 %x, 4294967295 >> + ret i1 %tmp >> } >> >> Modified: llvm/trunk/test/CodeGen/X86/sext-i1.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-i1.ll?rev=128175&r1=128174&r2=128175&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/X86/sext-i1.ll (original) >> +++ llvm/trunk/test/CodeGen/X86/sext-i1.ll Wed Mar 23 17:16:02 2011 >> @@ -39,7 +39,8 @@ >> ; 32: t3: >> ; 32: cmpl $1 >> ; 32: sbbl >> -; 32: cmpl >> +; 32: subl >> +; 32: sbbl >> ; 32: xorl >> >> ; 64: t3: >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From atrick at apple.com Wed Mar 23 18:11:02 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 23:11:02 -0000 Subject: [llvm-commits] [llvm] r128181 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/long-setcc.ll test/CodeGen/X86/sext-i1.ll Message-ID: <20110323231102.7BA4F2A6C12C@llvm.org> Author: atrick Date: Wed Mar 23 18:11:02 2011 New Revision: 128181 URL: http://llvm.org/viewvc/llvm-project?rev=128181&view=rev Log: Revert r128175. I'm backing this out for the second time. It was supposed to be fixed by r128164, but the mingw self-host must be defeating the fix. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/long-setcc.ll llvm/trunk/test/CodeGen/X86/sext-i1.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128181&r1=128180&r2=128181&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Mar 23 18:11:02 2011 @@ -447,13 +447,12 @@ setOperationAction(ISD::SETCC , MVT::i8 , Custom); setOperationAction(ISD::SETCC , MVT::i16 , Custom); setOperationAction(ISD::SETCC , MVT::i32 , Custom); - setOperationAction(ISD::SETCC , MVT::i64 , Custom); setOperationAction(ISD::SETCC , MVT::f32 , Custom); setOperationAction(ISD::SETCC , MVT::f64 , Custom); setOperationAction(ISD::SETCC , MVT::f80 , Custom); if (Subtarget->is64Bit()) { setOperationAction(ISD::SELECT , MVT::i64 , Custom); - setOperationAction(ISD::SETCC , MVT::i128 , Custom); + setOperationAction(ISD::SETCC , MVT::i64 , Custom); } setOperationAction(ISD::EH_RETURN , MVT::Other, Custom); @@ -2854,7 +2853,7 @@ } else if (SetCCOpcode == ISD::SETLT && RHSC->isNullValue()) { // X < 0 -> X == 0, jump on sign. return X86::COND_S; - } else if (SetCCOpcode == ISD::SETLT && RHSC->isOne()) { + } else if (SetCCOpcode == ISD::SETLT && RHSC->getZExtValue() == 1) { // X < 1 -> X <= 0 RHS = DAG.getConstant(0, RHS.getValueType()); return X86::COND_LE; @@ -7437,8 +7436,7 @@ // Lower (X & (1 << N)) == 0 to BT(X, N). // Lower ((X >>u N) & 1) != 0 to BT(X, N). // Lower ((X >>s N) & 1) != 0 to BT(X, N). - if (isTypeLegal(Op0.getValueType()) && - Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && + if (Op0.getOpcode() == ISD::AND && Op0.hasOneUse() && Op1.getOpcode() == ISD::Constant && cast(Op1)->isNullValue() && (CC == ISD::SETEQ || CC == ISD::SETNE)) { @@ -7450,7 +7448,7 @@ // Look for X == 0, X == 1, X != 0, or X != 1. We can simplify some forms of // these. if (Op1.getOpcode() == ISD::Constant && - (cast(Op1)->isOne() || + (cast(Op1)->getZExtValue() == 1 || cast(Op1)->isNullValue()) && (CC == ISD::SETEQ || CC == ISD::SETNE)) { @@ -7473,73 +7471,6 @@ if (X86CC == X86::COND_INVALID) return SDValue(); - if ((!Subtarget->is64Bit() && Op0.getValueType() == MVT::i64) || - (Subtarget->is64Bit() && Op0.getValueType() == MVT::i128)) { - switch (X86CC) { - case X86::COND_E: - case X86::COND_NE: - case X86::COND_S: - case X86::COND_NS: - // Just use the generic lowering, which works well on x86. - return SDValue(); - case X86::COND_B: - case X86::COND_AE: - case X86::COND_L: - case X86::COND_GE: - // Use SBB-based lowering. - break; - case X86::COND_A: - // Use SBB-based lowering; commute so ZF isn't used. - X86CC = X86::COND_B; - std::swap(Op0, Op1); - break; - case X86::COND_BE: - // Use SBB-based lowering; commute so ZF isn't used. - X86CC = X86::COND_AE; - std::swap(Op0, Op1); - break; - case X86::COND_G: - // Use SBB-based lowering; commute so ZF isn't used. - X86CC = X86::COND_L; - std::swap(Op0, Op1); - break; - case X86::COND_LE: - // Use SBB-based lowering; commute so ZF isn't used. - X86CC = X86::COND_GE; - std::swap(Op0, Op1); - break; - default: - assert(0 && "Unexpected X86CC."); - return SDValue(); - } - MVT HalfType = getPointerTy(); - // FIXME: Refactor this code out to implement ISD::SADDO and friends. - SDValue Op0Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, - Op0, DAG.getIntPtrConstant(0)); - SDValue Op1Low = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, - Op1, DAG.getIntPtrConstant(0)); - SDValue Op0High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, - Op0, DAG.getIntPtrConstant(1)); - SDValue Op1High = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, HalfType, - Op1, DAG.getIntPtrConstant(1)); - // Redirect some cases which will simplify to the generic expansion; - // X86ISD::SUB and X86ISD::SBB are not optimized well at the moment. - // FIXME: We really need to add DAGCombines for SUB/SBB/etc. - if (Op1Low.getOpcode() == ISD::Constant && - cast(Op1Low)->isNullValue()) - return SDValue(); - if (Op0Low.getOpcode() == ISD::Constant && - cast(Op0Low)->isAllOnesValue()) - return SDValue(); - SDValue res1, res2; - SDVTList VTList = DAG.getVTList(HalfType, MVT::i32); - res1 = DAG.getNode(X86ISD::SUB, dl, VTList, Op0Low, Op1Low).getValue(1); - res2 = DAG.getNode(X86ISD::SBB, dl, VTList, Op0High, Op1High, - res1).getValue(1); - return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, - DAG.getConstant(X86CC, MVT::i8), res2); - } - SDValue EFLAGS = EmitCmp(Op0, Op1, X86CC, DAG); return DAG.getNode(X86ISD::SETCC, dl, MVT::i8, DAG.getConstant(X86CC, MVT::i8), EFLAGS); Modified: llvm/trunk/test/CodeGen/X86/long-setcc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/long-setcc.ll?rev=128181&r1=128180&r2=128181&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/long-setcc.ll (original) +++ llvm/trunk/test/CodeGen/X86/long-setcc.ll Wed Mar 23 18:11:02 2011 @@ -1,35 +1,18 @@ -; RUN: llc < %s -march=x86 | FileCheck %s +; RUN: llc < %s -march=x86 | grep cmp | count 1 +; RUN: llc < %s -march=x86 | grep shr | count 1 +; RUN: llc < %s -march=x86 | grep xor | count 1 -; General case -define i1 @t1(i64 %x, i64 %y) nounwind { -; CHECK: @t1 -; CHECK: subl -; CHECK: sbbl -; CHECK: setl %al - %B = icmp slt i64 %x, %y - ret i1 %B +define i1 @t1(i64 %x) nounwind { + %B = icmp slt i64 %x, 0 + ret i1 %B } -; Some special cases define i1 @t2(i64 %x) nounwind { -; CHECK: @t2 -; CHECK: shrl $31, %eax - %B = icmp slt i64 %x, 0 - ret i1 %B + %tmp = icmp ult i64 %x, 4294967296 + ret i1 %tmp } -define i1 @t3(i64 %x) nounwind { -; CHECK: @t3 -; CHECX: cmpl $0 -; CHECX: sete %al - %tmp = icmp ult i64 %x, 4294967296 - ret i1 %tmp -} - -define i1 @t4(i64 %x) nounwind { -; CHECK: @t4 -; CHECX: cmpl $0 -; CHECX: setne %al - %tmp = icmp ugt i64 %x, 4294967295 - ret i1 %tmp +define i1 @t3(i32 %x) nounwind { + %tmp = icmp ugt i32 %x, -1 + ret i1 %tmp } Modified: llvm/trunk/test/CodeGen/X86/sext-i1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sext-i1.ll?rev=128181&r1=128180&r2=128181&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sext-i1.ll (original) +++ llvm/trunk/test/CodeGen/X86/sext-i1.ll Wed Mar 23 18:11:02 2011 @@ -39,8 +39,7 @@ ; 32: t3: ; 32: cmpl $1 ; 32: sbbl -; 32: subl -; 32: sbbl +; 32: cmpl ; 32: xorl ; 64: t3: From eli.friedman at gmail.com Wed Mar 23 18:24:22 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 23 Mar 2011 16:24:22 -0700 Subject: [llvm-commits] [llvm] r128175 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/long-setcc.ll test/CodeGen/X86/sext-i1.ll In-Reply-To: References: <20110323221602.CE2CE2A6C12E@llvm.org> Message-ID: On Wed, Mar 23, 2011 at 4:03 PM, Andrew Trick wrote: > On Mar 23, 2011, at 3:41 PM, Eli Friedman wrote: > >> On Wed, Mar 23, 2011 at 3:16 PM, Andrew Trick wrote: >>> Author: atrick >>> Date: Wed Mar 23 17:16:02 2011 >>> New Revision: 128175 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=128175&view=rev >>> Log: >>> Reapply Eli's r127852 now that the pre-RA scheduler can spill EFLAGS. >>> (target-specific branchless method for double-width relational comparisons on x86) >> >> Mmm... I'm still not very happy with the fact that we're generating >> pushfl/popfl in cases like the one I mentioned in >> http://llvm.org/bugs/show_bug.cgi?id=9509#c3 . ?Especially considering >> that I'm not entirely sure the method we use for copying EFLAGS is >> safe on 64-bit systems. >> >> -Eli > > Thanks for verifying this corner case. I noticed the code is fairly bad, although the original before your patch wasn't good either. I debated filing another bug to follow up on the performance, but wasn't sure how much we cared about this case. It only occurred in a self-host builder; no benchmarks. > > Of course, if you think we may have a correctness issue, please file another bug. Filed PR9539. -Eli From grosbach at apple.com Wed Mar 23 18:32:48 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 23:32:48 -0000 Subject: [llvm-commits] [llvm] r128182 - /llvm/trunk/include/llvm/MC/MCSectionMachO.h Message-ID: <20110323233249.03C792A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 18:32:48 2011 New Revision: 128182 URL: http://llvm.org/viewvc/llvm-project?rev=128182&view=rev Log: Fix comments. Modified: llvm/trunk/include/llvm/MC/MCSectionMachO.h Modified: llvm/trunk/include/llvm/MC/MCSectionMachO.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionMachO.h?rev=128182&r1=128181&r2=128182&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSectionMachO.h (original) +++ llvm/trunk/include/llvm/MC/MCSectionMachO.h Wed Mar 23 18:32:48 2011 @@ -66,10 +66,10 @@ /// S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in /// the Reserved2 field. S_SYMBOL_STUBS = 0x08U, - /// S_SYMBOL_STUBS - Section with only function pointers for + /// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for /// initialization. S_MOD_INIT_FUNC_POINTERS = 0x09U, - /// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for + /// S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for /// termination. S_MOD_TERM_FUNC_POINTERS = 0x0AU, /// S_COALESCED - Section contains symbols that are to be coalesced. From dpatel at apple.com Wed Mar 23 18:34:19 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 23 Mar 2011 23:34:19 -0000 Subject: [llvm-commits] [llvm] r128183 - in /llvm/trunk: lib/Target/ARM/ARMGlobalMerge.cpp test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll test/CodeGen/ARM/global-merge.ll Message-ID: <20110323233419.8D8A72A6C12C@llvm.org> Author: dpatel Date: Wed Mar 23 18:34:19 2011 New Revision: 128183 URL: http://llvm.org/viewvc/llvm-project?rev=128183&view=rev Log: Enable GlobalMerge on darwin. Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll llvm/trunk/test/CodeGen/ARM/global-merge.ll Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp?rev=128183&r1=128182&r2=128183&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp Wed Mar 23 18:34:19 2011 @@ -53,7 +53,6 @@ #define DEBUG_TYPE "arm-global-merge" #include "ARM.h" -#include "ARMTargetMachine.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Attributes.h" #include "llvm/Constants.h" @@ -168,11 +167,6 @@ unsigned MaxOffset = TLI->getMaximalGlobalOffset(); bool Changed = false; - // Disable this pass on darwin. The debugger is not yet ready to extract - // variable's info from a merged global. - if (TLI->getTargetMachine().getSubtarget().isTargetDarwin()) - return false; - // Grab all non-const globals. for (Module::global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) { Modified: llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll?rev=128183&r1=128182&r2=128183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll Wed Mar 23 18:34:19 2011 @@ -1,5 +1,5 @@ ; RUN: llc < %s | FileCheck %s -; XFAIL: * + target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32" target triple = "thumbv7-apple-darwin10" Modified: llvm/trunk/test/CodeGen/ARM/global-merge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/global-merge.ll?rev=128183&r1=128182&r2=128183&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/global-merge.ll (original) +++ llvm/trunk/test/CodeGen/ARM/global-merge.ll Wed Mar 23 18:34:19 2011 @@ -1,5 +1,4 @@ ; RUN: llc < %s -mtriple=thumb-apple-darwin | FileCheck %s -; XFAIL: * ; Test the ARMGlobalMerge pass. Use -march=thumb because it has a small ; value for the maximum offset (127). From grosbach at apple.com Wed Mar 23 18:35:17 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 23 Mar 2011 23:35:17 -0000 Subject: [llvm-commits] [llvm] r128184 - /llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Message-ID: <20110323233517.2B4052A6C12C@llvm.org> Author: grosbach Date: Wed Mar 23 18:35:17 2011 New Revision: 128184 URL: http://llvm.org/viewvc/llvm-project?rev=128184&view=rev Log: Runtime dylib simple ARM 24-bit branch relocation support. Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=128184&r1=128183&r2=128184&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Mar 23 18:35:17 2011 @@ -207,13 +207,28 @@ *p++ = (uint8_t)Value; Value >>= 8; } - return false; + break; } case macho::RIT_Pair: case macho::RIT_Difference: case macho::RIT_ARM_LocalDifference: case macho::RIT_ARM_PreboundLazyPointer: - case macho::RIT_ARM_Branch24Bit: + case macho::RIT_ARM_Branch24Bit: { + // Mask the value into the target address. We know instructions are + // 32-bit aligned, so we can do it all at once. + uint32_t *p = (uint32_t*)Address; + // The low two bits of the value are not encoded. + Value >>= 2; + // Mask the value to 24 bits. + Value &= 0xffffff; + // FIXME: If the destination is a Thumb function (and the instruction + // is a non-predicated BL instruction), we need to change it to a BLX + // instruction instead. + + // Insert the value into the instruction. + *p = (*p & ~0xffffff) | Value; + break; + } case macho::RIT_ARM_ThumbBranch22Bit: case macho::RIT_ARM_ThumbBranch32Bit: case macho::RIT_ARM_Half: @@ -243,7 +258,11 @@ memset((char*)Data.base() + Segment32LC->FileSize, 0, Segment32LC->VMSize - Segment32LC->FileSize); - // Bind the section indices to address. + // Bind the section indices to addresses and record the relocations we + // need to resolve. + typedef std::pair RelocationMap; + SmallVector Relocations; + SmallVector SectionBases; for (unsigned i = 0; i != Segment32LC->NumSections; ++i) { InMemoryStruct Sect; @@ -251,33 +270,42 @@ if (!Sect) return Error("unable to load section: '" + Twine(i) + "'"); - // FIXME: We don't support relocations yet. - if (Sect->NumRelocationTableEntries != 0) - return Error("not yet implemented: relocations!"); + // Remember any relocations the section has so we can resolve them later. + for (unsigned j = 0; j != Sect->NumRelocationTableEntries; ++j) { + InMemoryStruct RE; + Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE); + Relocations.push_back(RelocationMap(j, *RE)); + } // FIXME: Improve check. - if (Sect->Flags != 0x80000400) - return Error("unsupported section type!"); +// if (Sect->Flags != 0x80000400) +// return Error("unsupported section type!"); SectionBases.push_back((char*) Data.base() + Sect->Address); } - // Bind all the symbols to address. + // Bind all the symbols to address. Keep a record of the names for use + // by relocation resolution. + SmallVector SymbolNames; for (unsigned i = 0; i != SymtabLC->NumSymbolTableEntries; ++i) { InMemoryStruct STE; Obj->ReadSymbolTableEntry(SymtabLC->SymbolTableOffset, i, STE); if (!STE) return Error("unable to read symbol: '" + Twine(i) + "'"); + // Get the symbol name. + StringRef Name = Obj->getStringAtIndex(STE->StringIndex); + SymbolNames.push_back(Name); + + // Just skip undefined symbols. They'll be loaded from whatever + // module they come from (or system dylib) when we resolve relocations + // involving them. if (STE->SectionIndex == 0) - return Error("unexpected undefined symbol!"); + continue; unsigned Index = STE->SectionIndex - 1; if (Index >= Segment32LC->NumSections) return Error("invalid section index for symbol: '" + Twine() + "'"); - // Get the symbol name. - StringRef Name = Obj->getStringAtIndex(STE->StringIndex); - // Get the section base address. void *SectionBase = SectionBases[Index]; @@ -295,6 +323,13 @@ SymbolTable[Name] = Address; } + // Now resolve any relocations. + for (unsigned i = 0, e = Relocations.size(); i != e; ++i) { + if (resolveRelocation(Relocations[i].first, Relocations[i].second, + SectionBases, SymbolNames)) + return true; + } + // We've loaded the section; now mark the functions in it as executable. // FIXME: We really should use the JITMemoryManager for this. sys::Memory::setRangeExecutable(Data.base(), Data.size()); @@ -335,7 +370,7 @@ if (!Sect) return Error("unable to load section: '" + Twine(i) + "'"); - // Resolve any relocations the section has. + // Remember any relocations the section has so we can resolve them later. for (unsigned j = 0; j != Sect->NumRelocationTableEntries; ++j) { InMemoryStruct RE; Obj->ReadRelocationEntry(Sect->RelocationTableOffset, j, RE); From johnny.chen at apple.com Wed Mar 23 19:28:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 00:28:38 -0000 Subject: [llvm-commits] [llvm] r128186 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110324002838.401202A6C12C@llvm.org> Author: johnny Date: Wed Mar 23 19:28:38 2011 New Revision: 128186 URL: http://llvm.org/viewvc/llvm-project?rev=128186&view=rev Log: The r128103 fix to cope with the removal of addressing modes from the MC instructions were incomplete. The assert stmt needs to be updated and the operand index incrment is wrong. Fix the bad logic and add some sanity checking to detect bad instruction encoding; and add a test case. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128186&r1=128185&r2=128186&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Mar 23 19:28:38 2011 @@ -1806,7 +1806,7 @@ static bool DisassembleVFPLdStMulFrm(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { - assert(NumOps >= 5 && "VFPLdStMulFrm expects NumOps >= 5"); + assert(NumOps >= 4 && "VFPLdStMulFrm expects NumOps >= 4"); unsigned &OpIdx = NumOpsAdded; @@ -1830,7 +1830,7 @@ MI.addOperand(MCOperand::CreateImm(CondVal == 0xF ? 0xE : CondVal)); MI.addOperand(MCOperand::CreateReg(ARM::CPSR)); - OpIdx += 4; + OpIdx += 3; bool isSPVFP = (Opcode == ARM::VLDMSIA || Opcode == ARM::VLDMSDB || Opcode == ARM::VLDMSIA_UPD || Opcode == ARM::VLDMSDB_UPD || @@ -1844,6 +1844,11 @@ // Fill the variadic part of reglist. unsigned char Imm8 = insn & 0xFF; unsigned Regs = isSPVFP ? Imm8 : Imm8/2; + + // Apply some sanity checks before proceeding. + if (Regs == 0 || (RegD + Regs) > 32 || (!isSPVFP && Regs > 16)) + return false; + for (unsigned i = 0; i < Regs; ++i) { MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, RegClassID, RegD + i))); Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128186&r1=128185&r2=128186&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 23 19:28:38 2011 @@ -169,3 +169,6 @@ # CHECK: vcmpe.f64 d8, #0 0xc0 0x8b 0xb5 0xee + +# CHECK: vldmdb r2, {s7, s8, s9, s10, s11} +0x05 0x3a 0x52 0xed From johnny.chen at apple.com Wed Mar 23 20:07:27 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 01:07:27 -0000 Subject: [llvm-commits] [llvm] r128189 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110324010727.25F6D2A6C12C@llvm.org> Author: johnny Date: Wed Mar 23 20:07:26 2011 New Revision: 128189 URL: http://llvm.org/viewvc/llvm-project?rev=128189&view=rev Log: STRT and STRBT was incorrectly tagged as IndexModeNone during the refactorings (r119821). We now tag them as IndexModePost. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=128189&r1=128188&r2=128189&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Mar 23 20:07:26 2011 @@ -1805,7 +1805,7 @@ def STRT : AI2stridx<0, 0, (outs GPR:$Rn_wb), (ins GPR:$Rt, GPR:$Rn,am2offset:$offset), - IndexModeNone, StFrm, IIC_iStore_ru, + IndexModePost, StFrm, IIC_iStore_ru, "strt", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", [/* For disassembly only; pattern left blank */]> { let Inst{21} = 1; // overwrite @@ -1813,7 +1813,7 @@ def STRBT : AI2stridx<1, 0, (outs GPR:$Rn_wb), (ins GPR:$Rt, GPR:$Rn, am2offset:$offset), - IndexModeNone, StFrm, IIC_iStore_bh_ru, + IndexModePost, StFrm, IIC_iStore_bh_ru, "strbt", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb", [/* For disassembly only; pattern left blank */]> { let Inst{21} = 1; // overwrite Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128189&r1=128188&r2=128189&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 23 20:07:26 2011 @@ -172,3 +172,6 @@ # CHECK: vldmdb r2, {s7, s8, s9, s10, s11} 0x05 0x3a 0x52 0xed + +# CHECK: strtvc r5, [r3], r0, lsr #20 +0x30 0x5a 0xa3 0x76 From johnny.chen at apple.com Wed Mar 23 20:40:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 01:40:42 -0000 Subject: [llvm-commits] [llvm] r128191 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110324014042.E46442A6C12C@llvm.org> Author: johnny Date: Wed Mar 23 20:40:42 2011 New Revision: 128191 URL: http://llvm.org/viewvc/llvm-project?rev=128191&view=rev Log: Load/Store Multiple: These instructions were changed to not embed the addressing mode within the MC instructions We also need to update the corresponding assert stmt. Also add two test cases. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128191&r1=128190&r2=128191&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Mar 23 20:40:42 2011 @@ -1235,13 +1235,13 @@ } // The algorithm for disassembly of LdStMulFrm is different from others because -// it explicitly populates the two predicate operands after operand 0 (the base) -// and operand 1 (the AM4 mode imm). After operand 3, we need to populate the -// reglist with each affected register encoded as an MCOperand. +// it explicitly populates the two predicate operands after the base register. +// After that, we need to populate the reglist with each affected register +// encoded as an MCOperand. static bool DisassembleLdStMulFrm(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { - assert(NumOps >= 5 && "LdStMulFrm expects NumOps >= 5"); + assert(NumOps >= 4 && "LdStMulFrm expects NumOps >= 4"); NumOpsAdded = 0; unsigned Base = getRegisterEnum(B, ARM::GPRRegClassID, decodeRn(insn)); Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128191&r1=128190&r2=128191&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Mar 23 20:40:42 2011 @@ -175,3 +175,9 @@ # CHECK: strtvc r5, [r3], r0, lsr #20 0x30 0x5a 0xa3 0x76 + +# CHECK: stmiblo sp, {r0, r4, r8, r11, r12, pc} +0x11 0x99 0x8d 0x39 + +# CHECK: ldmdb sp, {r0, r4, r8, r11, r12, pc} +0x11 0x99 0x1d 0xe9 From johnny.chen at apple.com Wed Mar 23 21:24:36 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 02:24:36 -0000 Subject: [llvm-commits] [llvm] r128192 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Message-ID: <20110324022437.005A32A6C12C@llvm.org> Author: johnny Date: Wed Mar 23 21:24:36 2011 New Revision: 128192 URL: http://llvm.org/viewvc/llvm-project?rev=128192&view=rev Log: CPS3p: Let's reject impossible imod values by returning false from the DisassembleMiscFrm() function. Fixed rdar://problem/9179416 ARM disassembler crash: "Unknown imod operand" (fuzz testing) Opcode=98 Name=CPS3p Format=ARM_FORMAT_MISCFRM(26) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ------------------------------------------------------------------------------------------------- | 1: 1: 1: 1| 0: 0: 0: 1| 0: 0: 0: 0| 0: 0: 1: 0| 0: 0: 0: 1| 1: 1: 0: 0| 1: 0: 0: 1| 0: 0: 1: 1| ------------------------------------------------------------------------------------------------- Before: cpsUnknown imod operand UNREACHABLE executed at /Volumes/data/lldb/llvm/lib/Target/ARM/InstPrinter/../ARMBaseInfo.h:123! After: /Volumes/data/Radar/9179416/mc-input-arm.txt:1:1: warning: invalid instruction encoding 0x93 0x1c 0x2 0xf1 ^ Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128192&r1=128191&r2=128192&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Mar 23 21:24:36 2011 @@ -2945,6 +2945,9 @@ // no current handling of optional arguments. Fix here when a better handling // of optional arguments is implemented. if (Opcode == ARM::CPS3p) { + // Let's reject impossible imod values by returning false. + if (slice(insn, 19, 18) == 0 || slice(insn, 19, 18) == 1) + return false; MI.addOperand(MCOperand::CreateImm(slice(insn, 19, 18))); // imod MI.addOperand(MCOperand::CreateImm(slice(insn, 8, 6))); // iflags MI.addOperand(MCOperand::CreateImm(slice(insn, 4, 0))); // mode From geek4civic at gmail.com Wed Mar 23 23:26:14 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 24 Mar 2011 13:26:14 +0900 Subject: [llvm-commits] [Review request][PATCH] MC: Recognize alignment stuff on PECOFF. Message-ID: --- include/llvm/MC/MCAsmInfo.h | 14 ++++++++++---- include/llvm/MC/MCStreamer.h | 3 ++- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- lib/MC/MCAsmInfo.cpp | 2 +- lib/MC/MCAsmInfoCOFF.cpp | 2 +- lib/MC/MCAsmStreamer.cpp | 11 +++++++++-- lib/MC/MCELFStreamer.cpp | 6 +++--- lib/MC/MCELFStreamer.h | 3 ++- lib/MC/MCLoggingStreamer.cpp | 5 +++-- lib/MC/MCMachOStreamer.cpp | 3 ++- lib/MC/MCNullStreamer.cpp | 3 ++- lib/MC/MCPureStreamer.cpp | 3 ++- lib/MC/WinCOFFStreamer.cpp | 8 +++++--- lib/Target/ARM/ARMMCAsmInfo.cpp | 2 +- lib/Target/PTX/PTXMCAsmStreamer.cpp | 6 ++++-- lib/Target/PowerPC/PPCMCAsmInfo.cpp | 2 +- tools/lto/LTOModule.cpp | 3 ++- 17 files changed, 51 insertions(+), 27 deletions(-) -- I have not written comments in sources, though, I would like you all to review my patch to confirm whether I would take the *right* way or not, please. Checked on msvc10, cygwin-1.7, msysgit and mingw-w64-20101129. ...Takumi -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-MC-Recognize-alignment-stuff-on-PECOFF.patch.txt Type: text/x-patch Size: 14303 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/e7bdc72b/attachment-0001.bin From etherzhhb at gmail.com Wed Mar 23 23:55:11 2011 From: etherzhhb at gmail.com (ether zhhb) Date: Thu, 24 Mar 2011 12:55:11 +0800 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: <4D6EC30E.8020305@fim.uni-passau.de> References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> <4D6EC30E.8020305@fim.uni-passau.de> Message-ID: hi, hi, I seem Polly have a pass with the same name, how is this patch going on? >> diff --git a/lib/Transforms/Scalar/RegionSimplify.cpp b/lib/Transforms/Scalar/RegionSimplify.cpp >> new file mode 100644 >> index 0000000..9c78269 >> --- /dev/null >> +++ b/lib/Transforms/Scalar/RegionSimplify.cpp >> @@ -0,0 +1,191 @@ >> +//===- RegionSimplify.cpp -------------------------------------------------===// >> +// >> +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> +// >> +// This file converts refined regions detected by the RegionInfo analysis >> +// into simple regions. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#include "llvm/Instructions.h" >> +#include "llvm/ADT/Statistic.h" >> +#include "llvm/Analysis/Dominators.h" >> +#include "llvm/Analysis/RegionPass.h" >> +#include "llvm/Analysis/RegionInfo.h" >> +#include "llvm/Transforms/Utils/BasicBlockUtils.h" >> + >> +#define DEBUG_TYPE "region-simplify" >> + >> +using namespace llvm; >> + >> +STATISTIC(NumEntries, "The # of created entry edges"); >> +STATISTIC(NumExits, "The # of created exit edges"); >> + >> +namespace { >> +class RegionSimplify: public RegionPass { >> + ?bool modified; >> + ?Region *CR; >> + ?void createSingleEntryEdge(Region *R); >> + ?void createSingleExitEdge(Region *R); I seems there are also functions with the same name defined in ScopHelper.cpp of polly, are they the same functions? Instead of implement these functions in a specific pass, i suggest that we move these two functions into lib\Transforms\Utils\BasicBlockUtils.cpp or even lib\Transforms\Utils\RegionUtils.cpp, just like the "SplitBlock" function in llvm. So people can call these function anywhere their want to modify any region. And the RegionSimplify should simply call these functions to do their jobs instead denfining the same functions again. >> +public: >> + ?static char ID; >> + ?explicit RegionSimplify() : >> + ? ?RegionPass(ID) { >> + ? ?initializeRegionSimplifyPass(*PassRegistry::getPassRegistry()); >> + ?} >> + >> + ?virtual void print(raw_ostream&O, const Module *M) const; >> + >> + ?virtual bool runOnRegion(Region *R, RGPassManager&RGM); >> + ?virtual void getAnalysisUsage(AnalysisUsage&AU) const; >> +}; >> +} best regards ether From zwarich at apple.com Wed Mar 23 23:51:52 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 04:51:52 -0000 Subject: [llvm-commits] [llvm] r128194 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324045152.0969F2A6C12C@llvm.org> Author: zwarich Date: Wed Mar 23 23:51:51 2011 New Revision: 128194 URL: http://llvm.org/viewvc/llvm-project?rev=128194&view=rev Log: Check for TLI so that -codegenprepare can be used from opt. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128194&r1=128193&r2=128194&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Mar 23 23:51:51 2011 @@ -589,6 +589,9 @@ /// ret i32 %tmp2 /// bool CodeGenPrepare::DupRetToEnableTailCallOpts(ReturnInst *RI) { + if (!TLI) + return false; + Value *V = RI->getReturnValue(); if (!V) return false; From zwarich at apple.com Wed Mar 23 23:52:04 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 04:52:04 -0000 Subject: [llvm-commits] [llvm] r128195 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324045204.D43EC2A6C12C@llvm.org> Author: zwarich Date: Wed Mar 23 23:52:04 2011 New Revision: 128195 URL: http://llvm.org/viewvc/llvm-project?rev=128195&view=rev Log: When UpdateDT is set, DT is invalid, which could cause problems when trying to use it later. I couldn't make a test that hits this with the current code. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128195&r1=128194&r2=128195&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Mar 23 23:52:04 2011 @@ -331,7 +331,7 @@ // The PHIs are now updated, change everything that refers to BB to use // DestBB and remove BB. BB->replaceAllUsesWith(DestBB); - if (DT) { + if (DT && !UpdateDT) { BasicBlock *BBIDom = DT->getNode(BB)->getIDom()->getBlock(); BasicBlock *DestBBIDom = DT->getNode(DestBB)->getIDom()->getBlock(); BasicBlock *NewIDom = DT->findNearestCommonDominator(BBIDom, DestBBIDom); @@ -534,7 +534,8 @@ // happens. WeakVH IterHandle(CurInstIterator); - ReplaceAndSimplifyAllUses(CI, RetVal, TLI ? TLI->getTargetData() : 0, DT); + ReplaceAndSimplifyAllUses(CI, RetVal, TLI ? TLI->getTargetData() : 0, + UpdateDT ? 0 : DT); // If the iterator instruction was recursively deleted, start over at the // start of the block. From zwarich at apple.com Wed Mar 23 23:52:07 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 04:52:07 -0000 Subject: [llvm-commits] [llvm] r128196 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324045207.5B2C52A6C12D@llvm.org> Author: zwarich Date: Wed Mar 23 23:52:07 2011 New Revision: 128196 URL: http://llvm.org/viewvc/llvm-project?rev=128196&view=rev Log: Use an early return instead of a long if block. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128196&r1=128195&r2=128196&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Mar 23 23:52:07 2011 @@ -597,67 +597,67 @@ if (!V) return false; - if (PHINode *PN = dyn_cast(V)) { - BasicBlock *BB = RI->getParent(); - if (PN->getParent() != BB) - return false; + PHINode *PN = dyn_cast(V); + if (!PN) + return false; - // It's not safe to eliminate the sign / zero extension of the return value. - // See llvm::isInTailCallPosition(). - const Function *F = BB->getParent(); - unsigned CallerRetAttr = F->getAttributes().getRetAttributes(); - if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) - return false; + BasicBlock *BB = RI->getParent(); + if (PN->getParent() != BB) + return false; - // Make sure there are no instructions between PHI and return. - BasicBlock::iterator BI = PN; - do { ++BI; } while (isa(BI)); - if (&*BI != RI) - return false; + // It's not safe to eliminate the sign / zero extension of the return value. + // See llvm::isInTailCallPosition(). + const Function *F = BB->getParent(); + unsigned CallerRetAttr = F->getAttributes().getRetAttributes(); + if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) + return false; - /// Only dup the ReturnInst if the CallInst is likely to be emitted as a - /// tail call. - SmallVector TailCalls; - for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { - CallInst *CI = dyn_cast(PN->getIncomingValue(I)); - // Make sure the phi value is indeed produced by the tail call. - if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && - TLI->mayBeEmittedAsTailCall(CI)) - TailCalls.push_back(CI); - } - - bool Changed = false; - for (unsigned i = 0, e = TailCalls.size(); i != e; ++i) { - CallInst *CI = TailCalls[i]; - CallSite CS(CI); - - // Conservatively require the attributes of the call to match those of - // the return. Ignore noalias because it doesn't affect the call sequence. - unsigned CalleeRetAttr = CS.getAttributes().getRetAttributes(); - if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias) - continue; - - // Make sure the call instruction is followed by an unconditional branch - // to the return block. - BasicBlock *CallBB = CI->getParent(); - BranchInst *BI = dyn_cast(CallBB->getTerminator()); - if (!BI || !BI->isUnconditional() || BI->getSuccessor(0) != BB) - continue; - - // Duplicate the return into CallBB. - (void)FoldReturnIntoUncondBranch(RI, BB, CallBB); - UpdateDT = Changed = true; - ++NumRetsDup; - } - - // If we eliminated all predecessors of the block, delete the block now. - if (Changed && pred_begin(BB) == pred_end(BB)) - BB->eraseFromParent(); + // Make sure there are no instructions between PHI and return. + BasicBlock::iterator BI = PN; + do { ++BI; } while (isa(BI)); + if (&*BI != RI) + return false; - return Changed; + /// Only dup the ReturnInst if the CallInst is likely to be emitted as a tail + /// call. + SmallVector TailCalls; + for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { + CallInst *CI = dyn_cast(PN->getIncomingValue(I)); + // Make sure the phi value is indeed produced by the tail call. + if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && + TLI->mayBeEmittedAsTailCall(CI)) + TailCalls.push_back(CI); } - return false; + bool Changed = false; + for (unsigned i = 0, e = TailCalls.size(); i != e; ++i) { + CallInst *CI = TailCalls[i]; + CallSite CS(CI); + + // Conservatively require the attributes of the call to match those of the + // return. Ignore noalias because it doesn't affect the call sequence. + unsigned CalleeRetAttr = CS.getAttributes().getRetAttributes(); + if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias) + continue; + + // Make sure the call instruction is followed by an unconditional branch to + // the return block. + BasicBlock *CallBB = CI->getParent(); + BranchInst *BI = dyn_cast(CallBB->getTerminator()); + if (!BI || !BI->isUnconditional() || BI->getSuccessor(0) != BB) + continue; + + // Duplicate the return into CallBB. + (void)FoldReturnIntoUncondBranch(RI, BB, CallBB); + UpdateDT = Changed = true; + ++NumRetsDup; + } + + // If we eliminated all predecessors of the block, delete the block now. + if (Changed && pred_begin(BB) == pred_end(BB)) + BB->eraseFromParent(); + + return Changed; } //===----------------------------------------------------------------------===// From zwarich at apple.com Wed Mar 23 23:52:10 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 04:52:10 -0000 Subject: [llvm-commits] [llvm] r128197 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/tailcall-returndup-void.ll Message-ID: <20110324045211.04FB62A6C12E@llvm.org> Author: zwarich Date: Wed Mar 23 23:52:10 2011 New Revision: 128197 URL: http://llvm.org/viewvc/llvm-project?rev=128197&view=rev Log: Do early taildup of ret in CodeGenPrepare for potential tail calls that have a void return type. This fixes PR9487. Added: llvm/trunk/test/CodeGen/X86/tailcall-returndup-void.ll Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128197&r1=128196&r2=128197&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Wed Mar 23 23:52:10 2011 @@ -594,15 +594,12 @@ return false; Value *V = RI->getReturnValue(); - if (!V) - return false; - - PHINode *PN = dyn_cast(V); - if (!PN) + PHINode *PN = V ? dyn_cast(V) : NULL; + if (V && !PN) return false; BasicBlock *BB = RI->getParent(); - if (PN->getParent() != BB) + if (PN && PN->getParent() != BB) return false; // It's not safe to eliminate the sign / zero extension of the return value. @@ -612,21 +609,44 @@ if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) return false; - // Make sure there are no instructions between PHI and return. - BasicBlock::iterator BI = PN; - do { ++BI; } while (isa(BI)); - if (&*BI != RI) - return false; + // Make sure there are no instructions between the PHI and return, or that the + // return is the first instruction in the block. + if (PN) { + BasicBlock::iterator BI = BB->begin(); + do { ++BI; } while (isa(BI)); + if (&*BI != RI) + return false; + } else { + if (&*BB->begin() != RI) + return false; + } /// Only dup the ReturnInst if the CallInst is likely to be emitted as a tail /// call. SmallVector TailCalls; - for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { - CallInst *CI = dyn_cast(PN->getIncomingValue(I)); - // Make sure the phi value is indeed produced by the tail call. - if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && - TLI->mayBeEmittedAsTailCall(CI)) - TailCalls.push_back(CI); + if (PN) { + for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { + CallInst *CI = dyn_cast(PN->getIncomingValue(I)); + // Make sure the phi value is indeed produced by the tail call. + if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && + TLI->mayBeEmittedAsTailCall(CI)) + TailCalls.push_back(CI); + } + } else { + SmallPtrSet VisitedBBs; + for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { + if (!VisitedBBs.insert(*PI)) + continue; + + BasicBlock::InstListType &InstList = (*PI)->getInstList(); + BasicBlock::InstListType::reverse_iterator RI = InstList.rbegin(); + BasicBlock::InstListType::reverse_iterator RE = InstList.rend(); + if (++RI == RE) + continue; + CallInst *CI = dyn_cast(&*RI); + if (CI && CI->getType()->isVoidTy() && TLI->mayBeEmittedAsTailCall(CI)) + TailCalls.push_back(CI); + } } bool Changed = false; Added: llvm/trunk/test/CodeGen/X86/tailcall-returndup-void.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tailcall-returndup-void.ll?rev=128197&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/tailcall-returndup-void.ll (added) +++ llvm/trunk/test/CodeGen/X86/tailcall-returndup-void.ll Wed Mar 23 23:52:10 2011 @@ -0,0 +1,37 @@ +; RUN: llc < %s -march=x86-64 | FileCheck %s +; CHECK: rBM_info +; CHECK-NOT: ret + + at sES_closure = external global [0 x i64] +declare cc10 void @sEH_info(i64* noalias nocapture, i64* noalias nocapture, i64* noalias nocapture, i64, i64, i64) align 8 + +define cc10 void @rBM_info(i64* noalias nocapture %Base_Arg, i64* noalias nocapture %Sp_Arg, i64* noalias nocapture %Hp_Arg, i64 %R1_Arg, i64 %R2_Arg, i64 %R3_Arg) nounwind align 8 { +c263: + %ln265 = getelementptr inbounds i64* %Sp_Arg, i64 -2 + %ln266 = ptrtoint i64* %ln265 to i64 + %ln268 = icmp ult i64 %ln266, %R3_Arg + br i1 %ln268, label %c26a, label %n26p + +n26p: ; preds = %c263 + br i1 icmp ne (i64 and (i64 ptrtoint ([0 x i64]* @sES_closure to i64), i64 7), i64 0), label %c1ZP.i, label %n1ZQ.i + +n1ZQ.i: ; preds = %n26p + %ln1ZT.i = load i64* getelementptr inbounds ([0 x i64]* @sES_closure, i64 0, i64 0), align 8 + %ln1ZU.i = inttoptr i64 %ln1ZT.i to void (i64*, i64*, i64*, i64, i64, i64)* + tail call cc10 void %ln1ZU.i(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64 ptrtoint ([0 x i64]* @sES_closure to i64), i64 ptrtoint ([0 x i64]* @sES_closure to i64), i64 %R3_Arg) nounwind + br label %rBL_info.exit + +c1ZP.i: ; preds = %n26p + tail call cc10 void @sEH_info(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64 ptrtoint ([0 x i64]* @sES_closure to i64), i64 ptrtoint ([0 x i64]* @sES_closure to i64), i64 %R3_Arg) nounwind + br label %rBL_info.exit + +rBL_info.exit: ; preds = %c1ZP.i, %n1ZQ.i + ret void + +c26a: ; preds = %c263 + %ln27h = getelementptr inbounds i64* %Base_Arg, i64 -2 + %ln27j = load i64* %ln27h, align 8 + %ln27k = inttoptr i64 %ln27j to void (i64*, i64*, i64*, i64, i64, i64)* + tail call cc10 void %ln27k(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64 %R1_Arg, i64 %R2_Arg, i64 %R3_Arg) nounwind + ret void +} From grosser at fim.uni-passau.de Thu Mar 24 00:09:46 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 24 Mar 2011 01:09:46 -0400 Subject: [llvm-commits] Patch for simplifying regions In-Reply-To: References: <4D4882FC.8060102@fim.uni-passau.de> <4D6BCEBA.9080609@fim.uni-passau.de> <4D6CF971.5050300@fim.uni-passau.de> <4D6EC30E.8020305@fim.uni-passau.de> Message-ID: <4D8AD21A.8050106@fim.uni-passau.de> On 03/24/2011 12:55 AM, ether zhhb wrote: > hi, > > hi, > > I seem Polly have a pass with the same name, how is this patch going on? I committed that pass temporarily to Polly, as I needed it to fix a bug. Unfortunately, it is not currently in a state that we can commit it upstream. See the last comments in my mail. If they are addressed, I would love to move this one to LLVM. >>> +namespace { >>> +class RegionSimplify: public RegionPass { >>> + bool modified; >>> + Region *CR; >>> + void createSingleEntryEdge(Region *R); >>> + void createSingleExitEdge(Region *R); > I seems there are also functions with the same name defined in > ScopHelper.cpp of polly, are they the same functions? I believe Andreas used the version in Polly as a start for the ones in the RegionSimplify pass. > Instead of implement these functions in a specific pass, i suggest > that we move these two functions into > lib\Transforms\Utils\BasicBlockUtils.cpp or even > lib\Transforms\Utils\RegionUtils.cpp, just like the "SplitBlock" > function in llvm. So people can call these function anywhere their > want to modify any region. And the RegionSimplify should simply call > these functions to do their jobs instead denfining the same functions > again. The functions would be removed from Polly as soon as they are committed upstream. I personally have no strong opinion where to put them in LLVM. As RegionSimplify is at the moment the only user, I think putting them directly into RegionSimplify is a good start. If someone else needs them, we can easily move them over. Cheers Tobi From bigcheesegs at gmail.com Thu Mar 24 00:23:40 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Thu, 24 Mar 2011 05:23:40 -0000 Subject: [llvm-commits] [llvm] r128199 - /llvm/trunk/lib/Support/Unix/PathV2.inc Message-ID: <20110324052340.A76122A6C12C@llvm.org> Author: mspencer Date: Thu Mar 24 00:23:40 2011 New Revision: 128199 URL: http://llvm.org/viewvc/llvm-project?rev=128199&view=rev Log: Remove all uses of PATH_MAX and MAXPATHLEN from PathV2. Modified: llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=128199&r1=128198&r2=128199&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Thu Mar 24 00:23:40 2011 @@ -93,7 +93,8 @@ namespace fs { error_code current_path(SmallVectorImpl &result) { - result.reserve(MAXPATHLEN); + // Reserve an arbitrary amount of space. + result.reserve(128); while (true) { if (::getcwd(result.data(), result.capacity()) == 0) { @@ -417,18 +418,13 @@ } // Make the path absolute. - char real_path_buff[PATH_MAX + 1]; - if (realpath(RandomPath.c_str(), real_path_buff) == NULL) { - int error = errno; + if (error_code ec = make_absolute(RandomPath)) { ::close(RandomFD); ::unlink(RandomPath.c_str()); - return error_code(error, system_category()); + return ec; } - result_path.clear(); - StringRef d(real_path_buff); - result_path.append(d.begin(), d.end()); - + result_path = RandomPath; result_fd = RandomFD; return success; } From evan.cheng at apple.com Thu Mar 24 01:20:03 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 24 Mar 2011 06:20:03 -0000 Subject: [llvm-commits] [llvm] r128203 - /llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <20110324062003.DB85E2A6C12C@llvm.org> Author: evancheng Date: Thu Mar 24 01:20:03 2011 New Revision: 128203 URL: http://llvm.org/viewvc/llvm-project?rev=128203&view=rev Log: Nasty bug in ARMBaseInstrInfo::produceSameValue(). The MachineConstantPoolEntry entries being compared may not be ARMConstantPoolValue. Without checking whether they are ARMConstantPoolValue first, and if the stars and moons are aligned properly, the equality test may return true (when the first few words of two Constants' values happen to be identical) and very bad things can happen. rdar://9125354 Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=128203&r1=128202&r2=128203&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Thu Mar 24 01:20:03 2011 @@ -1080,11 +1080,18 @@ int CPI1 = MO1.getIndex(); const MachineConstantPoolEntry &MCPE0 = MCP->getConstants()[CPI0]; const MachineConstantPoolEntry &MCPE1 = MCP->getConstants()[CPI1]; - ARMConstantPoolValue *ACPV0 = - static_cast(MCPE0.Val.MachineCPVal); - ARMConstantPoolValue *ACPV1 = - static_cast(MCPE1.Val.MachineCPVal); - return ACPV0->hasSameValue(ACPV1); + bool isARMCP0 = MCPE0.isMachineConstantPoolEntry(); + bool isARMCP1 = MCPE1.isMachineConstantPoolEntry(); + if (isARMCP0 && isARMCP1) { + ARMConstantPoolValue *ACPV0 = + static_cast(MCPE0.Val.MachineCPVal); + ARMConstantPoolValue *ACPV1 = + static_cast(MCPE1.Val.MachineCPVal); + return ACPV0->hasSameValue(ACPV1); + } else if (!isARMCP0 && !isARMCP1) { + return MCPE0.Val.ConstVal == MCPE1.Val.ConstVal; + } + return false; } else if (Opcode == ARM::PICLDR) { if (MI1->getOpcode() != Opcode) return false; From evan.cheng at apple.com Thu Mar 24 01:28:45 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 24 Mar 2011 06:28:45 -0000 Subject: [llvm-commits] [llvm] r128204 - /llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h Message-ID: <20110324062845.6FEC62A6C12C@llvm.org> Author: evancheng Date: Thu Mar 24 01:28:45 2011 New Revision: 128204 URL: http://llvm.org/viewvc/llvm-project?rev=128204&view=rev Log: Add comment to clarify what MachineConstantPoolEntry::isMachineConstantPoolEntry() means. Modified: llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h Modified: llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h?rev=128204&r1=128203&r2=128204&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineConstantPool.h Thu Mar 24 01:28:45 2011 @@ -80,7 +80,7 @@ } Val; /// The required alignment for this entry. The top bit is set when Val is - /// a MachineConstantPoolValue. + /// a target specific MachineConstantPoolValue. unsigned Alignment; MachineConstantPoolEntry(const Constant *V, unsigned A) @@ -93,6 +93,9 @@ Alignment |= 1U << (sizeof(unsigned)*CHAR_BIT-1); } + /// isMachineConstantPoolEntry - Return true if the MachineConstantPoolEntry + /// is indeed a target specific constantpool entry, not a wrapper over a + /// Constant. bool isMachineConstantPoolEntry() const { return (int)Alignment < 0; } From atrick at apple.com Thu Mar 24 01:56:21 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 23 Mar 2011 23:56:21 -0700 Subject: [llvm-commits] [llvm] r128199 - /llvm/trunk/lib/Support/Unix/PathV2.inc In-Reply-To: <20110324052340.A76122A6C12C@llvm.org> References: <20110324052340.A76122A6C12C@llvm.org> Message-ID: Hi Michael, It looks like this unit test may not have liked your checkin on clang-x86_64-darwin10-gcc42-RA. Can you either checkin a quick fix, revert, or XFAIL+bug? -Andy ******************** TEST 'Clang :: Frontend/dependency-gen.c' FAILED ********************Script: -- clang: warning: argument unused during compilation: '-S' In file included from :138: :1:10: fatal error: 'a/b/x.h' file not found #include "a/b/x.h" ^ 1 error generated. On Mar 23, 2011, at 10:23 PM, Michael J. Spencer wrote: > Author: mspencer > Date: Thu Mar 24 00:23:40 2011 > New Revision: 128199 > > URL: http://llvm.org/viewvc/llvm-project?rev=128199&view=rev > Log: > Remove all uses of PATH_MAX and MAXPATHLEN from PathV2. > > Modified: > llvm/trunk/lib/Support/Unix/PathV2.inc > > Modified: llvm/trunk/lib/Support/Unix/PathV2.inc > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=128199&r1=128198&r2=128199&view=diff > ============================================================================== > --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) > +++ llvm/trunk/lib/Support/Unix/PathV2.inc Thu Mar 24 00:23:40 2011 > @@ -93,7 +93,8 @@ > namespace fs { > > error_code current_path(SmallVectorImpl &result) { > - result.reserve(MAXPATHLEN); > + // Reserve an arbitrary amount of space. > + result.reserve(128); > > while (true) { > if (::getcwd(result.data(), result.capacity()) == 0) { > @@ -417,18 +418,13 @@ > } > > // Make the path absolute. > - char real_path_buff[PATH_MAX + 1]; > - if (realpath(RandomPath.c_str(), real_path_buff) == NULL) { > - int error = errno; > + if (error_code ec = make_absolute(RandomPath)) { > ::close(RandomFD); > ::unlink(RandomPath.c_str()); > - return error_code(error, system_category()); > + return ec; > } > > - result_path.clear(); > - StringRef d(real_path_buff); > - result_path.append(d.begin(), d.end()); > - > + result_path = RandomPath; > result_fd = RandomFD; > return success; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110323/6d939843/attachment.html From geek4civic at gmail.com Thu Mar 24 02:06:45 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 24 Mar 2011 07:06:45 -0000 Subject: [llvm-commits] [llvm] r128205 - /llvm/trunk/tools/llvm-stub/llvm-stub.c Message-ID: <20110324070645.84AC32A6C12D@llvm.org> Author: chapuni Date: Thu Mar 24 02:06:45 2011 New Revision: 128205 URL: http://llvm.org/viewvc/llvm-project?rev=128205&view=rev Log: llvm-stub.cpp: mingw-w64 tweak. Modified: llvm/trunk/tools/llvm-stub/llvm-stub.c Modified: llvm/trunk/tools/llvm-stub/llvm-stub.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-stub/llvm-stub.c?rev=128205&r1=128204&r2=128205&view=diff ============================================================================== --- llvm/trunk/tools/llvm-stub/llvm-stub.c (original) +++ llvm/trunk/tools/llvm-stub/llvm-stub.c Thu Mar 24 02:06:45 2011 @@ -64,7 +64,7 @@ memcpy((char **)Args+2, argv+1, sizeof(char*)*argc); /* Run the JIT. */ -#ifndef _WIN32 +#if !defined(_WIN32) || defined(__MINGW64__) execvp(Interp, (char **)Args); /* POSIX execvp takes a char *const[]. */ #else execvp(Interp, Args); /* windows execvp takes a const char *const *. */ From geek4civic at gmail.com Thu Mar 24 02:07:00 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 24 Mar 2011 07:07:00 -0000 Subject: [llvm-commits] [llvm] r128206 - in /llvm/trunk: lib/Target/X86/X86FrameLowering.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrControl.td test/CodeGen/X86/win64_alloca_dynalloca.ll test/CodeGen/X86/win_chkstk.ll Message-ID: <20110324070700.ECEF12A6C12D@llvm.org> Author: chapuni Date: Thu Mar 24 02:07:00 2011 New Revision: 128206 URL: http://llvm.org/viewvc/llvm-project?rev=128206&view=rev Log: Target/X86: [PR8777][PR8778] Tweak alloca/chkstk for Windows targets. FIXME: Some cleanups would be needed. Added: llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrControl.td llvm/trunk/test/CodeGen/X86/win_chkstk.ll Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=128206&r1=128205&r2=128206&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Thu Mar 24 02:07:00 2011 @@ -551,60 +551,66 @@ // responsible for adjusting the stack pointer. Touching the stack at 4K // increments is necessary to ensure that the guard pages used by the OS // virtual memory manager are allocated in correct sequence. - if (NumBytes >= 4096 && - (STI.isTargetCygMing() || STI.isTargetWin32()) && - !STI.isTargetEnvMacho()) { + if (NumBytes >= 4096 && STI.isTargetCOFF() && !STI.isTargetEnvMacho()) { + const char *StackProbeSymbol; + bool isSPUpdateNeeded = false; + + if (Is64Bit) { + if (STI.isTargetCygMing()) + StackProbeSymbol = "___chkstk"; + else { + StackProbeSymbol = "__chkstk"; + isSPUpdateNeeded = true; + } + } else if (STI.isTargetCygMing()) + StackProbeSymbol = "_alloca"; + else + StackProbeSymbol = "_chkstk"; + // Check whether EAX is livein for this function. bool isEAXAlive = isEAXLiveIn(MF); - const char *StackProbeSymbol = - STI.isTargetWindows() ? "_chkstk" : "_alloca"; - if (Is64Bit && STI.isTargetCygMing()) - StackProbeSymbol = "__chkstk"; - unsigned CallOp = Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32; - if (!isEAXAlive) { - BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX) - .addImm(NumBytes); - BuildMI(MBB, MBBI, DL, TII.get(CallOp)) - .addExternalSymbol(StackProbeSymbol) - .addReg(StackPtr, RegState::Define | RegState::Implicit) - .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); - } else { + if (isEAXAlive) { + // Sanity check that EAX is not livein for this function. + // It should not be, so throw an assert. + assert(!Is64Bit && "EAX is livein in x64 case!"); + // Save EAX BuildMI(MBB, MBBI, DL, TII.get(X86::PUSH32r)) .addReg(X86::EAX, RegState::Kill); + } - // Allocate NumBytes-4 bytes on stack. We'll also use 4 already - // allocated bytes for EAX. + if (Is64Bit) { + // Handle the 64-bit Windows ABI case where we need to call __chkstk. + // Function prologue is responsible for adjusting the stack pointer. + BuildMI(MBB, MBBI, DL, TII.get(X86::MOV64ri), X86::RAX) + .addImm(NumBytes); + } else { + // Allocate NumBytes-4 bytes on stack in case of isEAXAlive. + // We'll also use 4 already allocated bytes for EAX. BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX) - .addImm(NumBytes - 4); - BuildMI(MBB, MBBI, DL, TII.get(CallOp)) - .addExternalSymbol(StackProbeSymbol) - .addReg(StackPtr, RegState::Define | RegState::Implicit) - .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); - - // Restore EAX - MachineInstr *MI = addRegOffset(BuildMI(MF, DL, TII.get(X86::MOV32rm), - X86::EAX), - StackPtr, false, NumBytes - 4); - MBB.insert(MBBI, MI); + .addImm(isEAXAlive ? NumBytes - 4 : NumBytes); + } + + BuildMI(MBB, MBBI, DL, + TII.get(Is64Bit ? X86::W64ALLOCA : X86::CALLpcrel32)) + .addExternalSymbol(StackProbeSymbol) + .addReg(StackPtr, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + + // MSVC x64's __chkstk needs to adjust %rsp. + // FIXME: %rax preserves the offset and should be available. + if (isSPUpdateNeeded) + emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, + TII, *RegInfo); + + if (isEAXAlive) { + // Restore EAX + MachineInstr *MI = addRegOffset(BuildMI(MF, DL, TII.get(X86::MOV32rm), + X86::EAX), + StackPtr, false, NumBytes - 4); + MBB.insert(MBBI, MI); } - } else if (NumBytes >= 4096 && - STI.isTargetWin64() && - !STI.isTargetEnvMacho()) { - // Sanity check that EAX is not livein for this function. It should - // not be, so throw an assert. - assert(!isEAXLiveIn(MF) && "EAX is livein in the Win64 case!"); - - // Handle the 64-bit Windows ABI case where we need to call __chkstk. - // Function prologue is responsible for adjusting the stack pointer. - BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX) - .addImm(NumBytes); - BuildMI(MBB, MBBI, DL, TII.get(X86::WINCALL64pcrel32)) - .addExternalSymbol("__chkstk") - .addReg(StackPtr, RegState::Define | RegState::Implicit); - emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, - TII, *RegInfo); } else if (NumBytes) emitSPUpdate(MBB, MBBI, StackPtr, -(int64_t)NumBytes, Is64Bit, TII, *RegInfo); Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128206&r1=128205&r2=128206&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Thu Mar 24 02:07:00 2011 @@ -550,12 +550,11 @@ setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); - if (Subtarget->is64Bit()) - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i64, Expand); - if (Subtarget->isTargetCygMing() || Subtarget->isTargetWindows()) - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Custom); - else - setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand); + setOperationAction(ISD::DYNAMIC_STACKALLOC, + (Subtarget->is64Bit() ? MVT::i64 : MVT::i32), + (Subtarget->isTargetCOFF() + && !Subtarget->isTargetEnvMacho() + ? Custom : Expand)); if (!UseSoftFloat && X86ScalarSSEf64) { // f32 and f64 use SSE. @@ -7929,6 +7928,7 @@ SelectionDAG &DAG) const { assert((Subtarget->isTargetCygMing() || Subtarget->isTargetWindows()) && "This should be used only on Windows targets"); + assert(!Subtarget->isTargetEnvMacho()); DebugLoc dl = Op.getDebugLoc(); // Get the inputs. @@ -7939,8 +7939,9 @@ SDValue Flag; EVT SPTy = Subtarget->is64Bit() ? MVT::i64 : MVT::i32; + unsigned Reg = (Subtarget->is64Bit() ? X86::RAX : X86::EAX); - Chain = DAG.getCopyToReg(Chain, dl, X86::EAX, Size, Flag); + Chain = DAG.getCopyToReg(Chain, dl, Reg, Size, Flag); Flag = Chain.getValue(1); SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Glue); @@ -10412,21 +10413,48 @@ const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); DebugLoc DL = MI->getDebugLoc(); + assert(!Subtarget->isTargetEnvMacho()); + // The lowering is pretty easy: we're just emitting the call to _alloca. The // non-trivial part is impdef of ESP. - // FIXME: The code should be tweaked as soon as we'll try to do codegen for - // mingw-w64. - const char *StackProbeSymbol = + if (Subtarget->isTargetWin64()) { + if (Subtarget->isTargetCygMing()) { + // ___chkstk(Mingw64): + // Clobbers R10, R11, RAX and EFLAGS. + // Updates RSP. + BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA)) + .addExternalSymbol("___chkstk") + .addReg(X86::RAX, RegState::Implicit) + .addReg(X86::RSP, RegState::Implicit) + .addReg(X86::RAX, RegState::Define | RegState::Implicit) + .addReg(X86::RSP, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + } else { + // __chkstk(MSVCRT): does not update stack pointer. + // Clobbers R10, R11 and EFLAGS. + // FIXME: RAX(allocated size) might be reused and not killed. + BuildMI(*BB, MI, DL, TII->get(X86::W64ALLOCA)) + .addExternalSymbol("__chkstk") + .addReg(X86::RAX, RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + // RAX has the offset to subtracted from RSP. + BuildMI(*BB, MI, DL, TII->get(X86::SUB64rr), X86::RSP) + .addReg(X86::RSP) + .addReg(X86::RAX); + } + } else { + const char *StackProbeSymbol = Subtarget->isTargetWindows() ? "_chkstk" : "_alloca"; - BuildMI(*BB, MI, DL, TII->get(X86::CALLpcrel32)) - .addExternalSymbol(StackProbeSymbol) - .addReg(X86::EAX, RegState::Implicit) - .addReg(X86::ESP, RegState::Implicit) - .addReg(X86::EAX, RegState::Define | RegState::Implicit) - .addReg(X86::ESP, RegState::Define | RegState::Implicit) - .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + BuildMI(*BB, MI, DL, TII->get(X86::CALLpcrel32)) + .addExternalSymbol(StackProbeSymbol) + .addReg(X86::EAX, RegState::Implicit) + .addReg(X86::ESP, RegState::Implicit) + .addReg(X86::EAX, RegState::Define | RegState::Implicit) + .addReg(X86::ESP, RegState::Define | RegState::Implicit) + .addReg(X86::EFLAGS, RegState::Define | RegState::Implicit); + } MI->eraseFromParent(); // The pseudo instruction is gone now. return BB; Modified: llvm/trunk/lib/Target/X86/X86InstrControl.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrControl.td?rev=128206&r1=128205&r2=128206&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrControl.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrControl.td Thu Mar 24 02:07:00 2011 @@ -263,6 +263,16 @@ Requires<[IsWin64]>; } +let isCall = 1, isCodeGenOnly = 1 in + // __chkstk(MSVC): clobber R10, R11 and EFLAGS. + // ___chkstk(Mingw64): clobber R10, R11, RAX and EFLAGS, and update RSP. + let Defs = [RAX, R10, R11, RSP, EFLAGS], + Uses = [RSP] in { + def W64ALLOCA : Ii32PCRel<0xE8, RawFrm, + (outs), (ins i64i32imm_pcrel:$dst, variable_ops), + "call{q}\t$dst", []>, + Requires<[IsWin64]>; + } let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, isCodeGenOnly = 1 in Added: llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll?rev=128206&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll (added) +++ llvm/trunk/test/CodeGen/X86/win64_alloca_dynalloca.ll Thu Mar 24 02:07:00 2011 @@ -0,0 +1,74 @@ +; RUN: llc < %s -mtriple=x86_64-mingw32 | FileCheck %s -check-prefix=M64 +; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=W64 +; RUN: llc < %s -mtriple=x86_64-win32-macho | FileCheck %s -check-prefix=EFI +; PR8777 +; PR8778 + +define i64 @foo(i64 %n, i64 %x) nounwind { +entry: + + %buf0 = alloca i8, i64 4096, align 1 + +; ___chkstk must adjust %rsp. +; M64: movq %rsp, %rbp +; M64: $4096, %rax +; M64: callq ___chkstk +; M64-NOT: %rsp + +; __chkstk does not adjust %rsp. +; W64: movq %rsp, %rbp +; W64: $4096, %rax +; W64: callq __chkstk +; W64: subq $4096, %rsp + +; Freestanding +; EFI: movq %rsp, %rbp +; EFI: $[[B0OFS:4096|4104]], %rsp +; EFI-NOT: call + + %buf1 = alloca i8, i64 %n, align 1 + +; M64: leaq 15(%rcx), %rax +; M64: andq $-16, %rax +; M64: callq ___chkstk +; M64-NOT: %rsp +; M64: movq %rsp, %rax + +; W64: leaq 15(%rcx), %rax +; W64: andq $-16, %rax +; W64: callq __chkstk +; W64: subq %rax, %rsp +; W64: movq %rsp, %rax + +; EFI: leaq 15(%rcx), %rax +; EFI: andq $-16, %rax +; EFI: movq %rsp, [[R64:%r..]] +; EFI: subq %rax, [[R64]] +; EFI: movq [[R64]], %rsp + + %r = call i64 @bar(i64 %n, i64 %x, i64 %n, i8* %buf0, i8* %buf1) nounwind + +; M64: subq $48, %rsp +; M64: leaq -4096(%rbp), %r9 +; M64: movq %rax, 32(%rsp) +; M64: callq bar + +; W64: subq $48, %rsp +; W64: leaq -4096(%rbp), %r9 +; W64: movq %rax, 32(%rsp) +; W64: callq bar + +; EFI: subq $48, %rsp +; EFI: leaq -[[B0OFS]](%rbp), %r9 +; EFI: movq [[R64]], 32(%rsp) +; EFI: callq _bar + + ret i64 %r + +; M64: movq %rbp, %rsp + +; W64: movq %rbp, %rsp + +} + +declare i64 @bar(i64, i64, i64, i8* nocapture, i8* nocapture) nounwind Modified: llvm/trunk/test/CodeGen/X86/win_chkstk.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/win_chkstk.ll?rev=128206&r1=128205&r2=128206&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/win_chkstk.ll (original) +++ llvm/trunk/test/CodeGen/X86/win_chkstk.ll Thu Mar 24 02:07:00 2011 @@ -3,6 +3,7 @@ ; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X32 ; RUN: llc < %s -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=MINGW_X64 ; RUN: llc < %s -mtriple=i386-pc-linux | FileCheck %s -check-prefix=LINUX +; RUN: llc < %s -mtriple=x86_64-pc-win32-macho | FileCheck %s -check-prefix=LINUX ; Windows and mingw require a prologue helper routine if more than 4096 bytes area ; allocated on the stack. Windows uses __chkstk and mingw uses __alloca. __alloca @@ -16,7 +17,7 @@ ; WIN_X32: calll __chkstk ; WIN_X64: callq __chkstk ; MINGW_X32: calll __alloca -; MINGW_X64: callq __chkstk +; MINGW_X64: callq ___chkstk ; LINUX-NOT: call __chkstk %array4096 = alloca [4096 x i8], align 16 ; <[4096 x i8]*> [#uses=0] ret i32 0 From fvbommel at gmail.com Thu Mar 24 03:56:04 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Thu, 24 Mar 2011 09:56:04 +0100 Subject: [llvm-commits] [llvm] r128197 - in /llvm/trunk: lib/Transforms/Scalar/CodeGenPrepare.cpp test/CodeGen/X86/tailcall-returndup-void.ll In-Reply-To: <20110324045211.04FB62A6C12E@llvm.org> References: <20110324045211.04FB62A6C12E@llvm.org> Message-ID: On Thu, Mar 24, 2011 at 5:52 AM, Cameron Zwarich wrote: > + ?// Make sure there are no instructions between the PHI and return, or that the > + ?// return is the first instruction in the block. > + ?if (PN) { > + ? ?BasicBlock::iterator BI = BB->begin(); > + ? ?do { ++BI; } while (isa(BI)); > + ? ?if (&*BI != RI) > + ? ? ?return false; > + ?} else { > + ? ?if (&*BB->begin() != RI) > + ? ? ?return false; 'void' returns don't get to ignore debug intrinsics? > + ?} > > ? /// Only dup the ReturnInst if the CallInst is likely to be emitted as a tail > ? /// call. > ? SmallVector TailCalls; > - ?for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { > - ? ?CallInst *CI = dyn_cast(PN->getIncomingValue(I)); > - ? ?// Make sure the phi value is indeed produced by the tail call. > - ? ?if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && > - ? ? ? ?TLI->mayBeEmittedAsTailCall(CI)) > - ? ? ?TailCalls.push_back(CI); > + ?if (PN) { > + ? ?for (unsigned I = 0, E = PN->getNumIncomingValues(); I != E; ++I) { > + ? ? ?CallInst *CI = dyn_cast(PN->getIncomingValue(I)); > + ? ? ?// Make sure the phi value is indeed produced by the tail call. > + ? ? ?if (CI && CI->hasOneUse() && CI->getParent() == PN->getIncomingBlock(I) && > + ? ? ? ? ?TLI->mayBeEmittedAsTailCall(CI)) > + ? ? ? ?TailCalls.push_back(CI); > + ? ?} > + ?} else { > + ? ?SmallPtrSet VisitedBBs; > + ? ?for (pred_iterator PI = pred_begin(BB), PE = pred_end(BB); PI != PE; ++PI) { > + ? ? ?if (!VisitedBBs.insert(*PI)) > + ? ? ? ?continue; > + > + ? ? ?BasicBlock::InstListType &InstList = (*PI)->getInstList(); > + ? ? ?BasicBlock::InstListType::reverse_iterator RI = InstList.rbegin(); > + ? ? ?BasicBlock::InstListType::reverse_iterator RE = InstList.rend(); > + ? ? ?if (++RI == RE) > + ? ? ? ?continue; > + ? ? ?CallInst *CI = dyn_cast(&*RI); > + ? ? ?if (CI && CI->getType()->isVoidTy() && TLI->mayBeEmittedAsTailCall(CI)) > + ? ? ? ?TailCalls.push_back(CI); I don't think the 'isVoidTy()' check is necessary -- since void functions don't return a value they shouldn't care about what value their tail-callee returns (as long as it doesn't use sret). For instance, a void function calling an int function should still be able to use a tail call if the other conditions are met. From dpatel at apple.com Thu Mar 24 10:35:25 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 24 Mar 2011 15:35:25 -0000 Subject: [llvm-commits] [llvm] r128211 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324153525.89EC62A6C12C@llvm.org> Author: dpatel Date: Thu Mar 24 10:35:25 2011 New Revision: 128211 URL: http://llvm.org/viewvc/llvm-project?rev=128211&view=rev Log: s/UpdateDT/ModifiedDT/g Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128211&r1=128210&r2=128211&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Mar 24 10:35:25 2011 @@ -81,9 +81,9 @@ /// multiple load/stores of the same address. DenseMap SunkAddrs; - /// UpdateDT - If CFG is modified in anyway, dominator tree may need to + /// ModifiedDT - If CFG is modified in anyway, dominator tree may need to /// be updated. - bool UpdateDT; + bool ModifiedDT; public: static char ID; // Pass identification, replacement for typeid @@ -124,7 +124,7 @@ bool CodeGenPrepare::runOnFunction(Function &F) { bool EverMadeChange = false; - UpdateDT = false; + ModifiedDT = false; DT = getAnalysisIfAvailable(); PFI = getAnalysisIfAvailable(); @@ -150,11 +150,11 @@ MadeChange |= ConstantFoldTerminator(BB); if (MadeChange) - UpdateDT = true; + ModifiedDT = true; EverMadeChange |= MadeChange; } - if (UpdateDT && DT) + if (ModifiedDT && DT) DT->DT->recalculate(F); return EverMadeChange; @@ -331,7 +331,7 @@ // The PHIs are now updated, change everything that refers to BB to use // DestBB and remove BB. BB->replaceAllUsesWith(DestBB); - if (DT && !UpdateDT) { + if (DT && !ModifiedDT) { BasicBlock *BBIDom = DT->getNode(BB)->getIDom()->getBlock(); BasicBlock *DestBBIDom = DT->getNode(DestBB)->getIDom()->getBlock(); BasicBlock *NewIDom = DT->findNearestCommonDominator(BBIDom, DestBBIDom); @@ -535,7 +535,7 @@ WeakVH IterHandle(CurInstIterator); ReplaceAndSimplifyAllUses(CI, RetVal, TLI ? TLI->getTargetData() : 0, - UpdateDT ? 0 : DT); + ModifiedDT ? 0 : DT); // If the iterator instruction was recursively deleted, start over at the // start of the block. @@ -669,7 +669,7 @@ // Duplicate the return into CallBB. (void)FoldReturnIntoUncondBranch(RI, BB, CallBB); - UpdateDT = Changed = true; + ModifiedDT = Changed = true; ++NumRetsDup; } From zwarich at apple.com Thu Mar 24 10:54:11 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 15:54:11 -0000 Subject: [llvm-commits] [llvm] r128212 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324155411.C23282A6C12C@llvm.org> Author: zwarich Date: Thu Mar 24 10:54:11 2011 New Revision: 128212 URL: http://llvm.org/viewvc/llvm-project?rev=128212&view=rev Log: It is enough for the CallInst to have no uses to be made a tail call with a ret void; it doesn't need to have a void type. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128212&r1=128211&r2=128212&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Mar 24 10:54:11 2011 @@ -644,7 +644,7 @@ if (++RI == RE) continue; CallInst *CI = dyn_cast(&*RI); - if (CI && CI->getType()->isVoidTy() && TLI->mayBeEmittedAsTailCall(CI)) + if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI)) TailCalls.push_back(CI); } } From geek4civic at gmail.com Thu Mar 24 02:18:00 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 24 Mar 2011 16:18:00 +0900 Subject: [llvm-commits] [RC1] Status of llvm and clang for Windows x64 In-Reply-To: References: Message-ID: Anton and Bill, I have committed chkstk thing in r128206 with a little cleanup. Checked on x86_64-linux, msvs10, mingw32 and mingw-w64. On Tue, Mar 22, 2011 at 8:59 AM, Anton Korobeynikov wrote: > I think yes. Also, I think the patch for PR8778 should also go in; I > don't like it and think it can be generalized, but for now it's the > best solution available. Thank you to review! I will rewrite it till 3.0 release. ;) ...Takumi From jfonseca at vmware.com Thu Mar 24 09:30:33 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:33 +0000 Subject: [llvm-commits] Prevent unbounded memory consuption of long lived JIT processes Message-ID: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> This series of patches address several issues causing memory usage to grow indefinitely on a long lived process. These are not conventional leaks -- memory will be freed when the LLVM context or/and JIT engine is destroyed -- but for as long as they aren't the memory is usage effectively unbounded. The issues were found using valgrind with '--show-reachable=yes' option: 1. Compile a bunch of functions with JIT once; delete the result; and exit without destroying LLVM context nor JIT engine. (valgrind will report a bunch of unfreed LLVM objects) 2. Do as 1, but compile and delete the functions twice 3. Ditto three times. 4. Etc. Flawless code should not cause the memory usage to increase when compiling the same -- ie valgrind's log for every run should show the very same unfreed objects, regardless of the number of times a given code was compilation, but that was not the case. The attached patches cover most of the causes for new objects being allocated. It should be possible to automate such test, but I didn't get that far. I've ran the nightly tests, and there was no regression, nor significant trend of GCCAS column time. From jfonseca at vmware.com Thu Mar 24 09:30:34 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:34 +0000 Subject: [llvm-commits] [PATCH 1/5] Prevent infinite growth of the DenseMap. In-Reply-To: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> References: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> Message-ID: <1300977038-4242-2-git-send-email-jfonseca@vmware.com> When the hash function uses object pointers all free entries eventually become tombstones as they are used at least once, regardless of the size. DenseMap cannot function with zero empty keys, so it double size to get get ridof the tombstones. However DenseMap never shrinks automatically unless it is cleared, so the net result is that certain tables grow infinitely. The solution is to make a fresh copy of the table without tombstones instead of doubling size, by simply calling grow with the current size. --- include/llvm/ADT/DenseMap.h | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Prevent-infinite-growth-of-the-DenseMap.patch Type: text/x-patch Size: 835 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/a040e88c/attachment-0001.bin From jfonseca at vmware.com Thu Mar 24 09:30:35 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:35 +0000 Subject: [llvm-commits] [PATCH 2/5] Prevent infinite growth of SmallMap instances. In-Reply-To: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> References: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> Message-ID: <1300977038-4242-3-git-send-email-jfonseca@vmware.com> Rehash but don't grow when full of tombstones. --- include/llvm/ADT/StringMap.h | 16 ++-------------- lib/Support/StringMap.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 15 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-Prevent-infinite-growth-of-SmallMap-instances.patch Type: text/x-patch Size: 2357 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/50f9c8d9/attachment-0001.bin From jfonseca at vmware.com Thu Mar 24 09:30:36 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:36 +0000 Subject: [llvm-commits] [PATCH 3/5] Prevent infinite growth of SmallPtrSet instances. In-Reply-To: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> References: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> Message-ID: <1300977038-4242-4-git-send-email-jfonseca@vmware.com> Rehash but don't grow when full of tombstones. --- include/llvm/ADT/SmallPtrSet.h | 2 +- lib/Support/SmallPtrSet.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-Prevent-infinite-growth-of-SmallPtrSet-instances.patch Type: text/x-patch Size: 1915 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/4ccf6cd7/attachment.bin From jfonseca at vmware.com Thu Mar 24 09:30:37 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:37 +0000 Subject: [llvm-commits] [PATCH 4/5] Reset StringMap's NumTombstones on clears and rehashes. In-Reply-To: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> References: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> Message-ID: <1300977038-4242-5-git-send-email-jfonseca@vmware.com> StringMap was not properly updating NumTombstones after a clear or rehash. This was not fatal until now because the table was growing faster than NumTombstones could, but with the previous change of preventing infinite growth of the table the invariant (NumItems + NumTombstones <= NumBuckets) stopped being observed, causing infinite loops in certain situations. --- include/llvm/ADT/StringMap.h | 3 +++ lib/Support/StringMap.cpp | 3 +++ 2 files changed, 6 insertions(+), 0 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-Reset-StringMap-s-NumTombstones-on-clears-and-rehash.patch Type: text/x-patch Size: 1351 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/bd37db50/attachment.bin From jfonseca at vmware.com Thu Mar 24 09:30:38 2011 From: jfonseca at vmware.com (jfonseca at vmware.com) Date: Thu, 24 Mar 2011 14:30:38 +0000 Subject: [llvm-commits] [PATCH 5/5] Don't add the same analysis implementation pair twice. In-Reply-To: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> References: <1300977038-4242-1-git-send-email-jfonseca@vmware.com> Message-ID: <1300977038-4242-6-git-send-email-jfonseca@vmware.com> Prevent infinite growth of the list. --- include/llvm/PassAnalysisSupport.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) -------------- next part -------------- A non-text attachment was scrubbed... Name: 0005-Don-t-add-the-same-analysis-implementation-pair-twic.patch Type: text/x-patch Size: 491 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/76707a28/attachment.bin From sabre at nondot.org Thu Mar 24 11:13:31 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 24 Mar 2011 16:13:31 -0000 Subject: [llvm-commits] [llvm] r128214 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <20110324161332.4E0C62A6C12C@llvm.org> Author: lattner Date: Thu Mar 24 11:13:31 2011 New Revision: 128214 URL: http://llvm.org/viewvc/llvm-project?rev=128214&view=rev Log: fix description, PR9542 Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=128214&r1=128213&r2=128214&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Thu Mar 24 11:13:31 2011 @@ -2219,11 +2219,8 @@

Deleting an instruction from an existing sequence of instructions that form a -BasicBlock is very straight-forward. First, -you must have a pointer to the instruction that you wish to delete. Second, you -need to obtain the pointer to that instruction's basic block. You use the -pointer to the basic block to get its list of instructions and then use the -erase function to remove your instruction. For example:

+BasicBlock is very straight-forward: just +call the instruction's eraseFromParent() method. For example:

@@ -2232,6 +2229,10 @@
 
+

This unlinks the instruction from its containing basic block and deletes +it. If you'd just like to unlink the instruction from its containing basic +block but not delete it, you can use the removeFromParent() method.

+
From jay.foad at gmail.com Thu Mar 24 11:18:19 2011 From: jay.foad at gmail.com (Jay Foad) Date: Thu, 24 Mar 2011 16:18:19 -0000 Subject: [llvm-commits] [llvm] r128216 - /llvm/trunk/include/llvm/Analysis/DIBuilder.h Message-ID: <20110324161819.9DC452A6C12C@llvm.org> Author: foad Date: Thu Mar 24 11:18:19 2011 New Revision: 128216 URL: http://llvm.org/viewvc/llvm-project?rev=128216&view=rev Log: Fix typo in comment. Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h Modified: llvm/trunk/include/llvm/Analysis/DIBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DIBuilder.h?rev=128216&r1=128215&r2=128216&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DIBuilder.h (original) +++ llvm/trunk/include/llvm/Analysis/DIBuilder.h Thu Mar 24 11:18:19 2011 @@ -387,7 +387,7 @@ /// @param Ty Function type. /// @param isLocalToUnit True if this function is not externally visible.. /// @param isDefinition True if this is a function definition. - /// @param Virtuality Attributes describing virutallness. e.g. pure + /// @param Virtuality Attributes describing virtualness. e.g. pure /// virtual function. /// @param VTableIndex Index no of this method in virtual table. /// @param VTableHolder Type that holds vtable. From zwarich at apple.com Thu Mar 24 11:34:59 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Thu, 24 Mar 2011 16:34:59 -0000 Subject: [llvm-commits] [llvm] r128217 - /llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Message-ID: <20110324163459.799452A6C12C@llvm.org> Author: zwarich Date: Thu Mar 24 11:34:59 2011 New Revision: 128217 URL: http://llvm.org/viewvc/llvm-project?rev=128217&view=rev Log: Debug intrinsics must be skipped at the beginning and ends of blocks, lest they affect the generated code. Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Modified: llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp?rev=128217&r1=128216&r2=128217&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/CodeGenPrepare.cpp Thu Mar 24 11:34:59 2011 @@ -617,7 +617,9 @@ if (&*BI != RI) return false; } else { - if (&*BB->begin() != RI) + BasicBlock::iterator BI = BB->begin(); + while (isa(BI)) ++BI; + if (&*BI != RI) return false; } @@ -641,8 +643,10 @@ BasicBlock::InstListType &InstList = (*PI)->getInstList(); BasicBlock::InstListType::reverse_iterator RI = InstList.rbegin(); BasicBlock::InstListType::reverse_iterator RE = InstList.rend(); - if (++RI == RE) + do { ++RI; } while (RI != RE && isa(&*RI)); + if (RI == RE) continue; + CallInst *CI = dyn_cast(&*RI); if (CI && CI->use_empty() && TLI->mayBeEmittedAsTailCall(CI)) TailCalls.push_back(CI); From atrick at apple.com Thu Mar 24 11:43:38 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 24 Mar 2011 16:43:38 -0000 Subject: [llvm-commits] [llvm] r128218 - /llvm/trunk/lib/Support/Unix/PathV2.inc Message-ID: <20110324164338.203C22A6C12C@llvm.org> Author: atrick Date: Thu Mar 24 11:43:37 2011 New Revision: 128218 URL: http://llvm.org/viewvc/llvm-project?rev=128218&view=rev Log: revert r128199 until it can be made to work with Frontend/dependency-gen.c. Modified: llvm/trunk/lib/Support/Unix/PathV2.inc Modified: llvm/trunk/lib/Support/Unix/PathV2.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/PathV2.inc?rev=128218&r1=128217&r2=128218&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/PathV2.inc (original) +++ llvm/trunk/lib/Support/Unix/PathV2.inc Thu Mar 24 11:43:37 2011 @@ -93,8 +93,7 @@ namespace fs { error_code current_path(SmallVectorImpl &result) { - // Reserve an arbitrary amount of space. - result.reserve(128); + result.reserve(MAXPATHLEN); while (true) { if (::getcwd(result.data(), result.capacity()) == 0) { @@ -418,13 +417,18 @@ } // Make the path absolute. - if (error_code ec = make_absolute(RandomPath)) { + char real_path_buff[PATH_MAX + 1]; + if (realpath(RandomPath.c_str(), real_path_buff) == NULL) { + int error = errno; ::close(RandomFD); ::unlink(RandomPath.c_str()); - return ec; + return error_code(error, system_category()); } - result_path = RandomPath; + result_path.clear(); + StringRef d(real_path_buff); + result_path.append(d.begin(), d.end()); + result_fd = RandomFD; return success; } From bob.wilson at apple.com Thu Mar 24 11:54:12 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 24 Mar 2011 16:54:12 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r128219 - /llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h Message-ID: <20110324165412.90A912A6C12C@llvm.org> Author: bwilson Date: Thu Mar 24 11:54:12 2011 New Revision: 128219 URL: http://llvm.org/viewvc/llvm-project?rev=128219&view=rev Log: Link with libSystem before libgcc for iOS simulator SDKs 4.3 and later. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h?rev=128219&r1=128218&r2=128219&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h Thu Mar 24 11:54:12 2011 @@ -169,7 +169,8 @@ /* APPLE LOCAL begin prefer -lSystem 6645902 */ #undef LINK_GCC_C_SEQUENCE_SPEC #define LINK_GCC_C_SEQUENCE_SPEC \ - "%{miphoneos-version-min=*: %G %L} \ + "%{miphoneos-version-min=*: \ + %{!static:%:version-compare(>= 4.3 miphoneos-version-min= -lSystem)} %G %L} \ %{!miphoneos-version-min=*: \ %{!static:%:version-compare(>= 10.6 mmacosx-version-min= -lSystem)} %G %L}" /* APPLE LOCAL end prefer -lSystem 6645902 */ From johnny.chen at apple.com Thu Mar 24 12:04:23 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 17:04:23 -0000 Subject: [llvm-commits] [llvm] r128220 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Message-ID: <20110324170423.19B752A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 12:04:22 2011 New Revision: 128220 URL: http://llvm.org/viewvc/llvm-project?rev=128220&view=rev Log: Add comments to the handling of opcode CPS3p to reject invalid instruction encoding, a test case of invalid CPS3p encoding and one for invalid VLDMSDB due to regs out of range. Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128220&r1=128219&r2=128220&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Thu Mar 24 12:04:22 2011 @@ -2946,6 +2946,8 @@ // of optional arguments is implemented. if (Opcode == ARM::CPS3p) { // Let's reject impossible imod values by returning false. + // AsmPrinter cannot handle imod=0b00, plus (imod=0b00,M=1,iflags!=0) is an + // invalid combination, so we just check for imod=0b00 here. if (slice(insn, 19, 18) == 0 || slice(insn, 19, 18) == 1) return false; MI.addOperand(MCOperand::CreateImm(slice(insn, 19, 18))); // imod Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt?rev=128220&view=auto ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt (added) +++ llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt Thu Mar 24 12:04:22 2011 @@ -0,0 +1,4 @@ +# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 |& grep {invalid instruction encoding} + +# invalid (imod, M, iflags) combination +0x93 0x1c 0x02 0xf1 Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt?rev=128220&view=auto ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt (added) +++ llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Thu Mar 24 12:04:22 2011 @@ -0,0 +1,4 @@ +# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 |& grep {invalid instruction encoding} + +# core registers out of range +0xa5 0xba 0x52 0xed From johnny.chen at apple.com Thu Mar 24 13:40:38 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 18:40:38 -0000 Subject: [llvm-commits] [llvm] r128226 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/neon-tests.txt Message-ID: <20110324184038.3E43D2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 13:40:38 2011 New Revision: 128226 URL: http://llvm.org/viewvc/llvm-project?rev=128226&view=rev Log: The r118201 added support for VORR (immediate). Update ARMDisassemblerCore.cpp to disassemble the VORRiv*i* instructions properly within the DisassembleN1RegModImmFrm() function. Add a test case. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128226&r1=128225&r2=128226&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Thu Mar 24 13:40:38 2011 @@ -2302,6 +2302,8 @@ // VMOV (immediate) // Qd/Dd imm +// VORR (immediate) +// Qd/Dd imm src(=Qd/Dd) static bool DisassembleN1RegModImmFrm(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { @@ -2328,12 +2330,16 @@ case ARM::VMOVv8i16: case ARM::VMVNv4i16: case ARM::VMVNv8i16: + case ARM::VORRiv4i16: + case ARM::VORRiv8i16: esize = ESize16; break; case ARM::VMOVv2i32: case ARM::VMOVv4i32: case ARM::VMVNv2i32: case ARM::VMVNv4i32: + case ARM::VORRiv2i32: + case ARM::VORRiv4i32: esize = ESize32; break; case ARM::VMOVv1i64: @@ -2350,6 +2356,16 @@ MI.addOperand(MCOperand::CreateImm(decodeN1VImm(insn, esize))); NumOpsAdded = 2; + + // VORRiv*i* variants have an extra $src = $Vd to be filled in. + if (NumOps >= 3 && + (OpInfo[2].RegClass == ARM::DPRRegClassID || + OpInfo[2].RegClass == ARM::QPRRegClassID)) { + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[0].RegClass, + decodeNEONRd(insn)))); + NumOpsAdded += 1; + } + return true; } Modified: llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt?rev=128226&r1=128225&r2=128226&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Thu Mar 24 13:40:38 2011 @@ -62,3 +62,6 @@ # CHECK: vpop {d8} 0x02 0x8b 0xbd 0xec + +# CHECK: vorr.i32 q15, #0x4F0000 +0x5f 0xe5 0xc4 0xf2 From grosbach at apple.com Thu Mar 24 13:46:34 2011 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 24 Mar 2011 18:46:34 -0000 Subject: [llvm-commits] [llvm] r128227 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCParser/AsmLexer.h lib/MC/MCAsmInfo.cpp lib/MC/MCParser/AsmLexer.cpp lib/Target/TargetInstrInfo.cpp Message-ID: <20110324184634.9352F2A6C12C@llvm.org> Author: grosbach Date: Thu Mar 24 13:46:34 2011 New Revision: 128227 URL: http://llvm.org/viewvc/llvm-project?rev=128227&view=rev Log: Clean up assembly statement separator support. The MC asm lexer wasn't honoring a non-default (anything but ';') statement separator. Fix that, and generalize a bit to support multi-character statement separators. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCParser/AsmLexer.cpp llvm/trunk/lib/Target/TargetInstrInfo.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=128227&r1=128226&r2=128227&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Thu Mar 24 13:46:34 2011 @@ -66,10 +66,9 @@ /// relative expressions. const char *PCSymbol; // Defaults to "$". - /// SeparatorChar - This character, if specified, is used to separate - /// instructions from each other when on the same line. This is used to - /// measure inline asm instructions. - char SeparatorChar; // Defaults to ';' + /// SeparatorString - This string, if specified, is used to separate + /// instructions from each other when on the same line. + const char *SeparatorString; // Defaults to ';' /// CommentColumn - This indicates the comment num (zero-based) at /// which asm comments should be printed. @@ -350,8 +349,8 @@ const char *getPCSymbol() const { return PCSymbol; } - char getSeparatorChar() const { - return SeparatorChar; + const char *getSeparatorString() const { + return SeparatorString; } unsigned getCommentColumn() const { return CommentColumn; Modified: llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h?rev=128227&r1=128226&r2=128227&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h (original) +++ llvm/trunk/include/llvm/MC/MCParser/AsmLexer.h Thu Mar 24 13:46:34 2011 @@ -49,6 +49,7 @@ virtual StringRef LexUntilEndOfStatement(); bool isAtStartOfComment(char Char); + bool isAtStatementSeparator(const char *Ptr); const MCAsmInfo &getMAI() const { return MAI; } Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=128227&r1=128226&r2=128227&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Thu Mar 24 13:46:34 2011 @@ -26,7 +26,7 @@ LinkerRequiresNonEmptyDwarfLines = false; MaxInstLength = 4; PCSymbol = "$"; - SeparatorChar = ';'; + SeparatorString = ";"; CommentColumn = 40; CommentString = "#"; LabelSuffix = ":"; Modified: llvm/trunk/lib/MC/MCParser/AsmLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmLexer.cpp?rev=128227&r1=128226&r2=128227&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmLexer.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmLexer.cpp Thu Mar 24 13:46:34 2011 @@ -324,8 +324,8 @@ StringRef AsmLexer::LexUntilEndOfStatement() { TokStart = CurPtr; - while (!isAtStartOfComment(*CurPtr) && // Start of line comment. - *CurPtr != ';' && // End of statement marker. + while (!isAtStartOfComment(*CurPtr) && // Start of line comment. + !isAtStatementSeparator(CurPtr) && // End of statement marker. *CurPtr != '\n' && *CurPtr != '\r' && (*CurPtr != 0 || CurPtr != CurBuf->getBufferEnd())) { @@ -339,6 +339,11 @@ return Char == *MAI.getCommentString(); } +bool AsmLexer::isAtStatementSeparator(const char *Ptr) { + return strncmp(Ptr, MAI.getSeparatorString(), + strlen(MAI.getSeparatorString())) == 0; +} + AsmToken AsmLexer::LexToken() { TokStart = CurPtr; // This always consumes at least one character. @@ -346,6 +351,11 @@ if (isAtStartOfComment(CurChar)) return LexLineComment(); + if (isAtStatementSeparator(TokStart)) { + CurPtr += strlen(MAI.getSeparatorString()) - 1; + return AsmToken(AsmToken::EndOfStatement, + StringRef(TokStart, strlen(MAI.getSeparatorString()))); + } switch (CurChar) { default: @@ -362,8 +372,8 @@ // Ignore whitespace. return LexToken(); case '\n': // FALL THROUGH. - case '\r': // FALL THROUGH. - case ';': return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1)); + case '\r': + return AsmToken(AsmToken::EndOfStatement, StringRef(TokStart, 1)); case ':': return AsmToken(AsmToken::Colon, StringRef(TokStart, 1)); case '+': return AsmToken(AsmToken::Plus, StringRef(TokStart, 1)); case '-': return AsmToken(AsmToken::Minus, StringRef(TokStart, 1)); Modified: llvm/trunk/lib/Target/TargetInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetInstrInfo.cpp?rev=128227&r1=128226&r2=128227&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/TargetInstrInfo.cpp Thu Mar 24 13:46:34 2011 @@ -149,10 +149,10 @@ /// Measure the specified inline asm to determine an approximation of its /// length. -/// Comments (which run till the next SeparatorChar or newline) do not +/// Comments (which run till the next SeparatorString or newline) do not /// count as an instruction. /// Any other non-whitespace text is considered an instruction, with -/// multiple instructions separated by SeparatorChar or newlines. +/// multiple instructions separated by SeparatorString or newlines. /// Variable-length instructions are not handled here; this function /// may be overloaded in the target code to do that. unsigned TargetInstrInfo::getInlineAsmLength(const char *Str, @@ -163,7 +163,8 @@ bool atInsnStart = true; unsigned Length = 0; for (; *Str; ++Str) { - if (*Str == '\n' || *Str == MAI.getSeparatorChar()) + if (*Str == '\n' || strncmp(Str, MAI.getSeparatorString(), + strlen(MAI.getSeparatorString())) == 0) atInsnStart = true; if (atInsnStart && !std::isspace(*Str)) { Length += MAI.getMaxInstLength(); From jan_sjodin at yahoo.com Thu Mar 24 13:51:42 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Thu, 24 Mar 2011 11:51:42 -0700 (PDT) Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> <313975.13529.qm@web55605.mail.re4.yahoo.com> Message-ID: <256938.79836.qm@web55605.mail.re4.yahoo.com> I would like to use ELF as a container instead of MachO. If I remember correctly, the idea was that MC-JIT would be able to link in external object files. It might be possible to do with MachO as the container in memory, but it does not seem very clean. The idea was to have both MachO and ELF MC-JITs. Using ELF as the container makes registering with gdb very simple. What I did with JunkJIT works for my current needs, but I would prefer to move on to the ELF MC-JIT, since this is really the way forward and I don't have the same time restrictions anymore. - Jan ________________________________ From: Jim Grosbach To: Jan Sjodin Cc: llvm-commits at cs.uiuc.edu Sent: Tue, March 22, 2011 4:59:27 PM Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp No, but to be fair, that's not hooked up to work on a native MachO platform, either. :) Since the debug info is DWARF in both cases, it's possible that a lot of things will just work without much, if any, ELF customization. There will still need to be gdb-specific hooks to register the info and EH frame, of course. I may be being overly optimistic, though. -Jim On Mar 22, 2011, at 1:48 PM, Jan Sjodin wrote: > I was mainly thinking of debug info and being able to run gdb. Would that work? > > - Jan > > From: Jim Grosbach > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 22, 2011 4:32:34 PM > Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: >include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile >lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt >lib/ExecutionEngine/RuntimeDyld/Makefile >lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile >tools/llvm-rtdyld/llvm-rtdyld.cpp > > That depends on what you're looking to do. What specifically do you mean by >supporting ELF? The code should work as-is on an ELF based system. It just needs >the input object file to be a MachO. > > Even as this gets fleshed out to handle more things, it's only at the edges >where the JITed code interfaces with external bits that there's likely to be any >extra work required to run on an ELF based system, and that should be relatively >self-contained. > > So if you mean whether this infrastructure should work on an ELF based host, >then yes, at least most of it should work without modification. If you mean >using ELF as a container instead of MachO, then no, I have no plans to do that. > > -Jim > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110324/82e797ac/attachment.html From echristo at apple.com Thu Mar 24 13:53:33 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 24 Mar 2011 11:53:33 -0700 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <256938.79836.qm@web55605.mail.re4.yahoo.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> <313975.13529.qm@web55605.mail.re4.yahoo.com> <256938.79836.qm@web55605.mail.re4.yahoo.com> Message-ID: <33B3DB73-1DE5-457B-9DD0-E9B90F68D5B1@apple.com> On Mar 24, 2011, at 11:51 AM, Jan Sjodin wrote: > I would like to use ELF as a container instead of MachO. If I remember correctly, the idea was that MC-JIT would be able to link in external object files. It might be possible to do with MachO as the container in memory, but it does not seem very clean. The idea was to have both MachO and ELF MC-JITs. Using ELF as the container makes registering with gdb very simple. What I did with JunkJIT works for my current needs, but I would prefer to move on to the ELF MC-JIT, since this is really the way forward and I don't have the same time restrictions anymore. There's nothing in the current work to stop you from using this for ELF. Or at least there'd better not be :) -eric From grosbach at apple.com Thu Mar 24 14:43:22 2011 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 24 Mar 2011 12:43:22 -0700 Subject: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp In-Reply-To: <256938.79836.qm@web55605.mail.re4.yahoo.com> References: <20110321221553.0D84D2A6C12C@llvm.org> <180608.55464.qm@web55606.mail.re4.yahoo.com> <8540B167-1F15-4DBE-889C-164EB32812B0@apple.com> <313975.13529.qm@web55605.mail.re4.yahoo.com> <256938.79836.qm@web55605.mail.re4.yahoo.com> Message-ID: <86DBD4F2-F653-4171-9A77-17718D373EAE@apple.com> OK. That's a significantly different proposition than just enabling debug info, though. It'll certainly be possible to implement a RuntimeDyld for ELF. There would need to be some, probably triple based, selection logic of which Dyld to load and the MC-JIT would likewise need to switch which object streamer it creates. That should all be quite transparent to the overall architecture, though. -Jim On Mar 24, 2011, at 11:51 AM, Jan Sjodin wrote: > I would like to use ELF as a container instead of MachO. If I remember correctly, the idea was that MC-JIT would be able to link in external object files. It might be possible to do with MachO as the container in memory, but it does not seem very clean. The idea was to have both MachO and ELF MC-JITs. Using ELF as the container makes registering with gdb very simple. What I did with JunkJIT works for my current needs, but I would prefer to move on to the ELF MC-JIT, since this is really the way forward and I don't have the same time restrictions anymore. > > - Jan > > From: Jim Grosbach > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 22, 2011 4:59:27 PM > Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp > > No, but to be fair, that's not hooked up to work on a native MachO platform, either. :) > > Since the debug info is DWARF in both cases, it's possible that a lot of things will just work without much, if any, ELF customization. There will still need to be gdb-specific hooks to register the info and EH frame, of course. I may be being overly optimistic, though. > > -Jim > > On Mar 22, 2011, at 1:48 PM, Jan Sjodin wrote: > > > I was mainly thinking of debug info and being able to run gdb. Would that work? > > > > - Jan > > > > From: Jim Grosbach > > To: Jan Sjodin > > Cc: llvm-commits at cs.uiuc.edu > > Sent: Tue, March 22, 2011 4:32:34 PM > > Subject: Re: [llvm-commits] [llvm] r128031 - in /llvm/trunk: include/llvm/ExecutionEngine/RuntimeDyld.h lib/ExecutionEngine/Makefile lib/ExecutionEngine/RuntimeDyld/ lib/ExecutionEngine/RuntimeDyld/CMakeLists.txt lib/ExecutionEngine/RuntimeDyld/Makefile lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp tools/llvm-rtdyld/Makefile tools/llvm-rtdyld/llvm-rtdyld.cpp > > > > That depends on what you're looking to do. What specifically do you mean by supporting ELF? The code should work as-is on an ELF based system. It just needs the input object file to be a MachO. > > > > Even as this gets fleshed out to handle more things, it's only at the edges where the JITed code interfaces with external bits that there's likely to be any extra work required to run on an ELF based system, and that should be relatively self-contained. > > > > So if you mean whether this infrastructure should work on an ELF based host, then yes, at least most of it should work without modification. If you mean using ELF as a container instead of MachO, then no, I have no plans to do that. > > > > -Jim > > > From echristo at apple.com Thu Mar 24 15:18:39 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 24 Mar 2011 20:18:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r128230 - in /llvm-gcc-4.2/trunk/gcc: function.c gimplify.c llvm-convert.cpp omp-low.c Message-ID: <20110324201839.71BA92A6C12C@llvm.org> Author: echristo Date: Thu Mar 24 15:18:39 2011 New Revision: 128230 URL: http://llvm.org/viewvc/llvm-project?rev=128230&view=rev Log: Add an evil hack that adds an argument to alloca calls when we can interpose them, and falls back if necessary in order to store the alignment. Previously this code would be broken by multiple vlas in a single function. Fixes rdar://9169834 Modified: llvm-gcc-4.2/trunk/gcc/function.c llvm-gcc-4.2/trunk/gcc/gimplify.c llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/omp-low.c Modified: llvm-gcc-4.2/trunk/gcc/function.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/function.c?rev=128230&r1=128229&r2=128230&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/function.c (original) +++ llvm-gcc-4.2/trunk/gcc/function.c Thu Mar 24 15:18:39 2011 @@ -3287,7 +3287,9 @@ DECL_IGNORED_P (addr) = 0; local = build_fold_indirect_ref (addr); - args = tree_cons (NULL, DECL_SIZE_UNIT (parm), NULL); + /* LLVM local add alloca alignment */ + args = tree_cons(NULL, integer_one_node, NULL); + args = tree_cons (NULL, DECL_SIZE_UNIT (parm), args); t = built_in_decls[BUILT_IN_ALLOCA]; t = build_function_call_expr (t, args); t = fold_convert (ptr_type, t); Modified: llvm-gcc-4.2/trunk/gcc/gimplify.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/gimplify.c?rev=128230&r1=128229&r2=128230&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/gimplify.c (original) +++ llvm-gcc-4.2/trunk/gcc/gimplify.c Thu Mar 24 15:18:39 2011 @@ -1239,7 +1239,7 @@ /* This is a variable-sized decl. Simplify its size and mark it for deferred expansion. Note that mudflap depends on the format of the emitted code: see mx_register_decls(). */ - tree t, args, addr, ptr_type; + tree t, args, addr, ptr_type, align; gimplify_one_sizepos (&DECL_SIZE (decl), stmt_p); gimplify_one_sizepos (&DECL_SIZE_UNIT (decl), stmt_p); @@ -1256,14 +1256,15 @@ SET_DECL_VALUE_EXPR (decl, t); DECL_HAS_VALUE_EXPR_P (decl) = 1; - args = tree_cons (NULL, DECL_SIZE_UNIT (decl), NULL); + /* LLVM LOCAL begin add alloca alignment */ + /* We're adding an extra arg with the alignment to the end of the builtin + call and making up for it on the other end by not emitting the arg. */ + align = build_int_cst(TREE_TYPE(DECL_SIZE_UNIT(decl)), + DECL_ALIGN(decl)/BITS_PER_UNIT); + args = tree_cons (NULL, align, NULL); + args = tree_cons (NULL, DECL_SIZE_UNIT (decl), args); + /* LLVM LOCAL end add alloca alignment */ t = built_in_decls[BUILT_IN_ALLOCA]; - /* LLVM LOCAL begin add alloca alignment */ - /* We may have specified an alignment on the alloca - store it on the - function call so that we can emit this later and not lose it. */ - DECL_USER_ALIGN (t) = DECL_USER_ALIGN (decl); - DECL_ALIGN(t) = DECL_ALIGN(decl); - /* LLVM LOCAL end add alloca alignment */ t = build_function_call_expr (t, args); t = fold_convert (ptr_type, t); Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=128230&r1=128229&r2=128230&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Mar 24 15:18:39 2011 @@ -6772,15 +6772,21 @@ bool TreeToLLVM::EmitBuiltinAlloca(tree exp, Value *&Result) { tree arglist = TREE_OPERAND(exp, 1); - if (!validate_arglist(arglist, INTEGER_TYPE, VOID_TYPE)) + tree align_arg = NULL_TREE; + if (validate_arglist(arglist, INTEGER_TYPE, INTEGER_TYPE, VOID_TYPE)) + // Grab the alignment arg - no need to emit this. + align_arg = TREE_VALUE (TREE_CHAIN (arglist)); + // We may just have a single arg call to __builtin_alloca that we couldn't + // interpose. Check. + else if (validate_arglist(arglist, INTEGER_TYPE, VOID_TYPE)) + align_arg = integer_one_node; + else return false; + Value *Amt = Emit(TREE_VALUE(arglist), 0); AllocaInst *AI = Builder.CreateAlloca(Type::getInt8Ty(Context), Amt); - // If this was originally a vla alloca find the alignment and set it - // on our alloca. - tree fndecl = get_callee_fndecl(exp); - unsigned align = DECL_ALIGN(fndecl) ? DECL_ALIGN(fndecl)/8 : 1; + unsigned align = TREE_INT_CST_LOW(align_arg); AI->setAlignment(align); Result = AI; Modified: llvm-gcc-4.2/trunk/gcc/omp-low.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/omp-low.c?rev=128230&r1=128229&r2=128230&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/omp-low.c (original) +++ llvm-gcc-4.2/trunk/gcc/omp-low.c Thu Mar 24 15:18:39 2011 @@ -1679,7 +1679,9 @@ gcc_assert (DECL_P (ptr)); x = TYPE_SIZE_UNIT (TREE_TYPE (new_var)); - args = tree_cons (NULL, x, NULL); + /* LLVM local add alloca align */ + args = tree_cons (NULL, integer_one_node, NULL); + args = tree_cons (NULL, x, args); x = built_in_decls[BUILT_IN_ALLOCA]; x = build_function_call_expr (x, args); x = fold_convert (TREE_TYPE (ptr), x); @@ -1713,7 +1715,8 @@ } else { - args = tree_cons (NULL, x, NULL); + args = tree_cons (NULL, integer_one_node, NULL); + args = tree_cons (NULL, x, args); x = built_in_decls[BUILT_IN_ALLOCA]; x = build_function_call_expr (x, args); x = fold_convert (TREE_TYPE (new_var), x); From dpatel at apple.com Thu Mar 24 15:30:50 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 24 Mar 2011 20:30:50 -0000 Subject: [llvm-commits] [llvm] r128233 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/CodeGen/X86/unknown-location.ll test/DebugInfo/dbg-file-name.ll Message-ID: <20110324203050.BAE222A6C12C@llvm.org> Author: dpatel Date: Thu Mar 24 15:30:50 2011 New Revision: 128233 URL: http://llvm.org/viewvc/llvm-project?rev=128233&view=rev Log: Keep track of directory namd and fIx regression caused by Rafael's patch r119613. A better approach would be to move source id handling inside MC. Added: llvm/trunk/test/DebugInfo/dbg-file-name.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/test/CodeGen/X86/unknown-location.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128233&r1=128232&r2=128233&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu Mar 24 15:30:50 2011 @@ -516,7 +516,8 @@ unsigned Line = V.getLineNumber(); if (Line == 0) return; - unsigned FileID = GetOrCreateSourceID(V.getContext().getFilename()); + unsigned FileID = GetOrCreateSourceID(V.getContext().getFilename(), + V.getContext().getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -532,7 +533,8 @@ unsigned Line = G.getLineNumber(); if (Line == 0) return; - unsigned FileID = GetOrCreateSourceID(G.getContext().getFilename()); + unsigned FileID = GetOrCreateSourceID(G.getContext().getFilename(), + G.getContext().getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -551,7 +553,7 @@ unsigned Line = SP.getLineNumber(); if (!SP.getContext().Verify()) return; - unsigned FileID = GetOrCreateSourceID(SP.getFilename()); + unsigned FileID = GetOrCreateSourceID(SP.getFilename(), SP.getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -567,7 +569,7 @@ unsigned Line = Ty.getLineNumber(); if (Line == 0 || !Ty.getContext().Verify()) return; - unsigned FileID = GetOrCreateSourceID(Ty.getFilename()); + unsigned FileID = GetOrCreateSourceID(Ty.getFilename(), Ty.getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -585,7 +587,7 @@ return; StringRef FN = NS.getFilename(); - unsigned FileID = GetOrCreateSourceID(FN); + unsigned FileID = GetOrCreateSourceID(FN, NS.getDirectory()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -1859,10 +1861,21 @@ /// in the SourceIds map. This can update DirectoryNames and SourceFileNames /// maps as well. -unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName){ +unsigned DwarfDebug::GetOrCreateSourceID(StringRef FileName, + StringRef DirName) { // If FE did not provide a file name, then assume stdin. if (FileName.empty()) - return GetOrCreateSourceID(""); + return GetOrCreateSourceID("", StringRef()); + + // MCStream expects full path name as filename. + if (!DirName.empty() && !FileName.startswith("/")) { + std::string FullPathName(DirName.data()); + if (!DirName.endswith("/")) + FullPathName += "/"; + FullPathName += FileName.data(); + // Here FullPathName will be copied into StringMap by GetOrCreateSourceID. + return GetOrCreateSourceID(StringRef(FullPathName), StringRef()); + } StringMapEntry &Entry = SourceIdMap.GetOrCreateValue(FileName); if (Entry.getValue()) @@ -1872,7 +1885,7 @@ Entry.setValue(SrcId); // Print out a .file directive to specify files for .loc directives. - Asm->OutStreamer.EmitDwarfFileDirective(SrcId, FileName); + Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.getKey()); return SrcId; } @@ -1898,7 +1911,7 @@ DICompileUnit DIUnit(N); StringRef FN = DIUnit.getFilename(); StringRef Dir = DIUnit.getDirectory(); - unsigned ID = GetOrCreateSourceID(FN); + unsigned ID = GetOrCreateSourceID(FN, Dir); DIE *Die = new DIE(dwarf::DW_TAG_compile_unit); addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string, @@ -3102,7 +3115,7 @@ MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S) { StringRef Fn; - + StringRef Dir; unsigned Src = 1; if (S) { DIDescriptor Scope(S); @@ -3110,19 +3123,23 @@ if (Scope.isCompileUnit()) { DICompileUnit CU(S); Fn = CU.getFilename(); + Dir = CU.getDirectory(); } else if (Scope.isFile()) { DIFile F(S); Fn = F.getFilename(); + Dir = F.getDirectory(); } else if (Scope.isSubprogram()) { DISubprogram SP(S); Fn = SP.getFilename(); + Dir = SP.getDirectory(); } else if (Scope.isLexicalBlock()) { DILexicalBlock DB(S); Fn = DB.getFilename(); + Dir = DB.getDirectory(); } else assert(0 && "Unexpected scope info"); - Src = GetOrCreateSourceID(Fn); + Src = GetOrCreateSourceID(Fn, Dir); } Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, DWARF2_FLAG_IS_STMT, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128233&r1=128232&r2=128233&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Thu Mar 24 15:30:50 2011 @@ -518,7 +518,7 @@ /// GetOrCreateSourceID - Look up the source id with the given directory and /// source file names. If none currently exists, create a new id and insert it /// in the SourceIds map. - unsigned GetOrCreateSourceID(StringRef FullName); + unsigned GetOrCreateSourceID(StringRef DirName, StringRef FullName); /// constructCompileUnit - Create new CompileUnit for the given /// metadata node with tag DW_TAG_compile_unit. Modified: llvm/trunk/test/CodeGen/X86/unknown-location.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unknown-location.ll?rev=128233&r1=128232&r2=128233&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/unknown-location.ll (original) +++ llvm/trunk/test/CodeGen/X86/unknown-location.ll Thu Mar 24 15:30:50 2011 @@ -9,7 +9,7 @@ ; CHECK-NEXT: Ltmp ; CHECK-NEXT: cltd ; CHECK-NEXT: idivl %r8d -; CHECK-NEXT: .loc 1 4 3 +; CHECK-NEXT: .loc 2 4 3 ; CHECK-NEXT: Ltmp ; CHECK-NEXT: addl %ecx, %eax ; CHECK-NEXT: ret Added: llvm/trunk/test/DebugInfo/dbg-file-name.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dbg-file-name.ll?rev=128233&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/dbg-file-name.ll (added) +++ llvm/trunk/test/DebugInfo/dbg-file-name.ll Thu Mar 24 15:30:50 2011 @@ -0,0 +1,66 @@ +; RUN: llc -O0 < %s | FileCheck %s +; Radar 8884898 +; CHECK: file 1 "/Users/manav/one/two/simple.c" + + at .str = private unnamed_addr constant [8 x i8] c"i = %d\0A\00", align 4 + at .str1 = private unnamed_addr constant [12 x i8] c"i + 1 = %d\0A\00", align 4 + +define void @foo(i32 %i) nounwind { +entry: + %i_addr = alloca i32, align 4 + %"alloca point" = bitcast i32 0 to i32 + call void @llvm.dbg.declare(metadata !{i32* %i_addr}, metadata !9), !dbg !10 + store i32 %i, i32* %i_addr + %0 = load i32* %i_addr, align 4, !dbg !11 + %1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8]* @.str, i32 0, i32 0), i32 %0) nounwind, !dbg !11 + %2 = load i32* %i_addr, align 4, !dbg !13 + %3 = add nsw i32 %2, 1, !dbg !13 + %4 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32 %3) nounwind, !dbg !13 + br label %return, !dbg !14 + +return: ; preds = %entry + ret void, !dbg !14 +} + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +declare i32 @printf(i8*, ...) nounwind + +define i32 @main() nounwind { +entry: + %retval = alloca i32 + %0 = alloca i32 + %"alloca point" = bitcast i32 0 to i32 + call void @foo(i32 2) nounwind, !dbg !15 + call void @foo(i32 4) nounwind, !dbg !17 + store i32 0, i32* %0, align 4, !dbg !18 + %1 = load i32* %0, align 4, !dbg !18 + store i32 %1, i32* %retval, align 4, !dbg !18 + br label %return, !dbg !18 + +return: ; preds = %entry + %retval1 = load i32* %retval, !dbg !18 + ret i32 %retval1, !dbg !18 +} + +!llvm.dbg.sp = !{!0, !6} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @foo} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"simple.c", metadata !"/Users/manav/one/two", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 1, metadata !"simple.c", metadata !"/Users/manav/one/two", metadata !"LLVM build 00", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null, metadata !5} +!5 = metadata !{i32 589860, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!6 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 9, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] +!7 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null} ; [ DW_TAG_subroutine_type ] +!8 = metadata !{metadata !5} +!9 = metadata !{i32 590081, metadata !0, metadata !"i", metadata !1, i32 4, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] +!10 = metadata !{i32 4, i32 0, metadata !0, null} +!11 = metadata !{i32 5, i32 0, metadata !12, null} +!12 = metadata !{i32 589835, metadata !0, i32 4, i32 0, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!13 = metadata !{i32 6, i32 0, metadata !12, null} +!14 = metadata !{i32 7, i32 0, metadata !12, null} +!15 = metadata !{i32 10, i32 0, metadata !16, null} +!16 = metadata !{i32 589835, metadata !6, i32 9, i32 0, metadata !1, i32 1} ; [ DW_TAG_lexical_block ] +!17 = metadata !{i32 11, i32 0, metadata !16, null} +!18 = metadata !{i32 12, i32 0, metadata !16, null} From johnny.chen at apple.com Thu Mar 24 15:42:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 20:42:48 -0000 Subject: [llvm-commits] [llvm] r128234 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td test/MC/Disassembler/ARM/arm-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110324204248.D05F82A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 15:42:48 2011 New Revision: 128234 URL: http://llvm.org/viewvc/llvm-project?rev=128234&view=rev Log: ADR was added with the wrong encoding for inst{24-21}, and the ARM decoder was fooled. Set the encoding bits to {0,?,?,0}, not 0. Plus delegate the disassembly of ADR to the more generic ADDri/SUBri instructions, and add a test case for that. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=128234&r1=128233&r2=128234&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Mar 24 15:42:48 2011 @@ -1253,7 +1253,7 @@ // The 'adr' mnemonic encodes differently if the label is before or after // the instruction. The {24-21} opcode bits are set by the fixup, as we don't // know until then which form of the instruction will be used. -def ADR : AI1<0, (outs GPR:$Rd), (ins adrlabel:$label), +def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label), MiscFrm, IIC_iALUi, "adr", "\t$Rd, #$label", []> { bits<4> Rd; bits<12> label; Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128234&r1=128233&r2=128234&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Thu Mar 24 15:42:48 2011 @@ -1,5 +1,8 @@ # RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 | FileCheck %s +# CHECK: addpl r4, pc, #19, 8 +0x4c 0x45 0x8f 0x52 + # CHECK: b #0 0x00 0x00 0x00 0xea Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=128234&r1=128233&r2=128234&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Thu Mar 24 15:42:48 2011 @@ -1584,6 +1584,10 @@ Name == "MOVr_TC") return false; + // Delegate ADR disassembly to the more generic ADDri/SUBri instructions. + if (Name == "ADR") + return false; + // // The following special cases are for conflict resolutions. // From johnny.chen at apple.com Thu Mar 24 15:56:23 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 20:56:23 -0000 Subject: [llvm-commits] [llvm] r128235 - in /llvm/trunk/test/MC/Disassembler/ARM: invalid-CPS3p-arm.txt invalid-VLDMSDB-arm.txt Message-ID: <20110324205623.88F852A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 15:56:23 2011 New Revision: 128235 URL: http://llvm.org/viewvc/llvm-project?rev=128235&view=rev Log: Remove these two test files as they cause llvm-i686-linux-vg_leak build to fail 'test-llvm'. These two are test cases which should result in 'invalid instruction encoding' from running llvm-mc -disassemble. Removed: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Removed: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt?rev=128234&view=auto ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt (removed) @@ -1,4 +0,0 @@ -# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 |& grep {invalid instruction encoding} - -# invalid (imod, M, iflags) combination -0x93 0x1c 0x02 0xf1 Removed: llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt?rev=128234&view=auto ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt (removed) @@ -1,4 +0,0 @@ -# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 |& grep {invalid instruction encoding} - -# core registers out of range -0xa5 0xba 0x52 0xed From bruno.cardoso at gmail.com Thu Mar 24 16:04:58 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 24 Mar 2011 21:04:58 -0000 Subject: [llvm-commits] [llvm] r128236 - in /llvm/trunk: lib/MC/MCDisassembler/EDInfo.h lib/MC/MCDisassembler/EDOperand.cpp lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.h test/MC/ARM/arm_instructions.s test/MC/ARM/thumb2.s utils/TableGen/EDEmitter.cpp Message-ID: <20110324210458.D10122A6C12C@llvm.org> Author: bruno Date: Thu Mar 24 16:04:58 2011 New Revision: 128236 URL: http://llvm.org/viewvc/llvm-project?rev=128236&view=rev Log: Add asm parsing support w/ testcases for strex/ldrex family of instructions Modified: llvm/trunk/lib/MC/MCDisassembler/EDInfo.h llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h llvm/trunk/test/MC/ARM/arm_instructions.s llvm/trunk/test/MC/ARM/thumb2.s llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/MC/MCDisassembler/EDInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDInfo.h?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/EDInfo.h (original) +++ llvm/trunk/lib/MC/MCDisassembler/EDInfo.h Thu Mar 24 16:04:58 2011 @@ -35,6 +35,7 @@ kOperandTypeARMAddrMode5, kOperandTypeARMAddrMode6, kOperandTypeARMAddrMode6Offset, + kOperandTypeARMAddrMode7, kOperandTypeARMAddrModePC, kOperandTypeARMRegisterList, kOperandTypeARMTBAddrMode, @@ -51,7 +52,8 @@ kOperandTypeThumb2AddrModeImm12, kOperandTypeThumb2AddrModeSoReg, kOperandTypeThumb2AddrModeImm8s4, - kOperandTypeThumb2AddrModeImm8s4Offset + kOperandTypeThumb2AddrModeImm8s4Offset, + kOperandTypeThumb2AddrModeReg }; enum OperandFlags { Modified: llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp (original) +++ llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp Thu Mar 24 16:04:58 2011 @@ -73,6 +73,8 @@ case kOperandTypeThumb2AddrModeImm8Offset: case kOperandTypeARMTBAddrMode: case kOperandTypeThumb2AddrModeImm8s4Offset: + case kOperandTypeARMAddrMode7: + case kOperandTypeThumb2AddrModeReg: numMCOperands = 1; break; case kOperandTypeThumb2SoReg: @@ -256,6 +258,7 @@ case kOperandTypeARMAddrMode4: case kOperandTypeARMAddrMode5: case kOperandTypeARMAddrMode6: + case kOperandTypeARMAddrMode7: case kOperandTypeARMAddrModePC: case kOperandTypeARMBranchTarget: case kOperandTypeThumbAddrModeS1: @@ -269,6 +272,7 @@ case kOperandTypeThumb2AddrModeImm12: case kOperandTypeThumb2AddrModeSoReg: case kOperandTypeThumb2AddrModeImm8s4: + case kOperandTypeThumb2AddrModeReg: return 1; } } Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Thu Mar 24 16:04:58 2011 @@ -434,11 +434,11 @@ opc, asm, "", pattern> { bits<4> Rd; bits<4> Rt; - bits<4> Rn; + bits<4> addr; let Inst{27-23} = 0b00011; let Inst{22-21} = opcod; let Inst{20} = 0; - let Inst{19-16} = Rn; + let Inst{19-16} = addr; let Inst{15-12} = Rd; let Inst{11-4} = 0b11111001; let Inst{3-0} = Rt; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Mar 24 16:04:58 2011 @@ -590,6 +590,21 @@ let MIOperandInfo = (ops GPR, i32imm); } +def MemMode7AsmOperand : AsmOperandClass { + let Name = "MemMode7"; + let SuperClasses = []; +} + +// addrmode7 := reg +// Used by load/store exclusive instructions. Useful to enable right assembly +// parsing and printing. Not used for any codegen matching. +// +def addrmode7 : Operand { + let PrintMethod = "printAddrMode7Operand"; + let MIOperandInfo = (ops GPR); + let ParserMatchClass = MemMode7AsmOperand; +} + def nohash_imm : Operand { let PrintMethod = "printNoHashImmediate"; } @@ -3294,39 +3309,26 @@ } let mayLoad = 1 in { -def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, - "ldrexb", "\t$Rt, [$Rn]", - []>; -def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, - "ldrexh", "\t$Rt, [$Rn]", - []>; -def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, - "ldrex", "\t$Rt, [$Rn]", - []>; -def LDREXD : AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2), (ins GPR:$Rn), - NoItinerary, - "ldrexd", "\t$Rt, $Rt2, [$Rn]", - []>; +def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addrmode7:$addr), NoItinerary, + "ldrexb", "\t$Rt, $addr", []>; +def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addrmode7:$addr), NoItinerary, + "ldrexh", "\t$Rt, $addr", []>; +def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addrmode7:$addr), NoItinerary, + "ldrex", "\t$Rt, $addr", []>; +def LDREXD : AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode7:$addr), + NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []>; } let mayStore = 1, Constraints = "@earlyclobber $Rd" in { -def STREXB : AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$src, GPR:$Rn), - NoItinerary, - "strexb", "\t$Rd, $src, [$Rn]", - []>; -def STREXH : AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn), - NoItinerary, - "strexh", "\t$Rd, $Rt, [$Rn]", - []>; -def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn), - NoItinerary, - "strex", "\t$Rd, $Rt, [$Rn]", - []>; +def STREXB : AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addrmode7:$addr), + NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>; +def STREXH : AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addrmode7:$addr), + NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>; +def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addrmode7:$addr), + NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>; def STREXD : AIstrex<0b01, (outs GPR:$Rd), - (ins GPR:$Rt, GPR:$Rt2, GPR:$Rn), - NoItinerary, - "strexd", "\t$Rd, $Rt, $Rt2, [$Rn]", - []>; + (ins GPR:$Rt, GPR:$Rt2, addrmode7:$addr), + NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []>; } // Clear-Exclusive is for disassembly only. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Thu Mar 24 16:04:58 2011 @@ -145,6 +145,15 @@ let ParserMatchClass = MemMode5AsmOperand; } +// t2addrmode_reg := reg +// Used by load/store exclusive instructions. Useful to enable right assembly +// parsing and printing. Not used for any codegen matching. +// +def t2addrmode_reg : Operand { + let PrintMethod = "printAddrMode7Operand"; + let MIOperandInfo = (ops tGPR); + let ParserMatchClass = MemMode7AsmOperand; +} //===----------------------------------------------------------------------===// // Multiclass helpers... @@ -2821,9 +2830,9 @@ let Inst{5-4} = opcod; let Inst{3-0} = 0b1111; - bits<4> Rn; + bits<4> addr; bits<4> Rt; - let Inst{19-16} = Rn; + let Inst{19-16} = addr; let Inst{15-12} = Rt; } class T2I_strex opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, @@ -2837,37 +2846,37 @@ let Inst{5-4} = opcod; bits<4> Rd; - bits<4> Rn; + bits<4> addr; bits<4> Rt; - let Inst{11-8} = Rd; - let Inst{19-16} = Rn; + let Inst{3-0} = Rd; + let Inst{19-16} = addr; let Inst{15-12} = Rt; } let mayLoad = 1 in { -def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins rGPR:$Rn), AddrModeNone, - Size4Bytes, NoItinerary, "ldrexb", "\t$Rt, [$Rn]", +def t2LDREXB : T2I_ldrex<0b00, (outs rGPR:$Rt), (ins t2addrmode_reg:$addr), AddrModeNone, + Size4Bytes, NoItinerary, "ldrexb", "\t$Rt, $addr", "", []>; -def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins rGPR:$Rn), AddrModeNone, - Size4Bytes, NoItinerary, "ldrexh", "\t$Rt, [$Rn]", +def t2LDREXH : T2I_ldrex<0b01, (outs rGPR:$Rt), (ins t2addrmode_reg:$addr), AddrModeNone, + Size4Bytes, NoItinerary, "ldrexh", "\t$Rt, $addr", "", []>; -def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins rGPR:$Rn), AddrModeNone, +def t2LDREX : Thumb2I<(outs rGPR:$Rt), (ins t2addrmode_reg:$addr), AddrModeNone, Size4Bytes, NoItinerary, - "ldrex", "\t$Rt, [$Rn]", "", + "ldrex", "\t$Rt, $addr", "", []> { let Inst{31-27} = 0b11101; let Inst{26-20} = 0b0000101; let Inst{11-8} = 0b1111; let Inst{7-0} = 0b00000000; // imm8 = 0 - bits<4> Rn; bits<4> Rt; - let Inst{19-16} = Rn; + bits<4> addr; + let Inst{19-16} = addr; let Inst{15-12} = Rt; } -def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2), (ins rGPR:$Rn), +def t2LDREXD : T2I_ldrex<0b11, (outs rGPR:$Rt, rGPR:$Rt2), (ins t2addrmode_reg:$addr), AddrModeNone, Size4Bytes, NoItinerary, - "ldrexd", "\t$Rt, $Rt2, [$Rn]", "", + "ldrexd", "\t$Rt, $Rt2, $addr", "", [], {?, ?, ?, ?}> { bits<4> Rt2; let Inst{11-8} = Rt2; @@ -2875,31 +2884,31 @@ } let mayStore = 1, Constraints = "@earlyclobber $Rd" in { -def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd), (ins rGPR:$Rt, rGPR:$Rn), - AddrModeNone, Size4Bytes, NoItinerary, - "strexb", "\t$Rd, $Rt, [$Rn]", "", []>; -def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd), (ins rGPR:$Rt, rGPR:$Rn), - AddrModeNone, Size4Bytes, NoItinerary, - "strexh", "\t$Rd, $Rt, [$Rn]", "", []>; -def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt, rGPR:$Rn), - AddrModeNone, Size4Bytes, NoItinerary, - "strex", "\t$Rd, $Rt, [$Rn]", "", - []> { +def t2STREXB : T2I_strex<0b00, (outs rGPR:$Rd), (ins rGPR:$Rt, t2addrmode_reg:$addr), + AddrModeNone, Size4Bytes, NoItinerary, + "strexb", "\t$Rd, $Rt, $addr", "", []>; +def t2STREXH : T2I_strex<0b01, (outs rGPR:$Rd), (ins rGPR:$Rt, t2addrmode_reg:$addr), + AddrModeNone, Size4Bytes, NoItinerary, + "strexh", "\t$Rd, $Rt, $addr", "", []>; +def t2STREX : Thumb2I<(outs rGPR:$Rd), (ins rGPR:$Rt, t2addrmode_reg:$addr), + AddrModeNone, Size4Bytes, NoItinerary, + "strex", "\t$Rd, $Rt, $addr", "", + []> { let Inst{31-27} = 0b11101; let Inst{26-20} = 0b0000100; let Inst{7-0} = 0b00000000; // imm8 = 0 bits<4> Rd; - bits<4> Rn; + bits<4> addr; bits<4> Rt; let Inst{11-8} = Rd; - let Inst{19-16} = Rn; + let Inst{19-16} = addr; let Inst{15-12} = Rt; } def t2STREXD : T2I_strex<0b11, (outs rGPR:$Rd), - (ins rGPR:$Rt, rGPR:$Rt2, rGPR:$Rn), + (ins rGPR:$Rt, rGPR:$Rt2, t2addrmode_reg:$addr), AddrModeNone, Size4Bytes, NoItinerary, - "strexd", "\t$Rd, $Rt, $Rt2, [$Rn]", "", [], + "strexd", "\t$Rd, $Rt, $Rt2, $addr", "", [], {?, ?, ?, ?}> { bits<4> Rt2; let Inst{11-8} = Rt2; Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Mar 24 16:04:58 2011 @@ -350,6 +350,23 @@ int64_t Value = CE->getValue(); return ((Value & 0x3) == 0 && Value <= 1020 && Value >= -1020); } + bool isMemMode7() const { + if (!isMemory() || + getMemPreindexed() || + getMemPostindexed() || + getMemOffsetIsReg() || + getMemNegative() || + getMemWriteback()) + return false; + + const MCConstantExpr *CE = dyn_cast(getMemOffset()); + if (!CE) return false; + + if (CE->getValue()) + return false; + + return true; + } bool isMemModeRegThumb() const { if (!isMemory() || !getMemOffsetIsReg() || getMemWriteback()) return false; @@ -438,6 +455,15 @@ Inst.addOperand(MCOperand::CreateImm(unsigned(getMemBarrierOpt()))); } + void addMemMode7Operands(MCInst &Inst, unsigned N) const { + assert(N == 1 && isMemMode7() && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum())); + + const MCConstantExpr *CE = dyn_cast(getMemOffset()); + assert((CE || CE->getValue() == 0) && + "No offset operand support in mode 7"); + } + void addMemMode5Operands(MCInst &Inst, unsigned N) const { assert(N == 2 && isMemMode5() && "Invalid number of operands!"); Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Thu Mar 24 16:04:58 2011 @@ -317,6 +317,12 @@ O << "]"; } +void ARMInstPrinter::printAddrMode7Operand(const MCInst *MI, unsigned OpNum, + raw_ostream &O) { + const MCOperand &MO1 = MI->getOperand(OpNum); + O << "[" << getRegisterName(MO1.getReg()) << "]"; +} + void ARMInstPrinter::printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O) { Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h Thu Mar 24 16:04:58 2011 @@ -51,6 +51,7 @@ void printLdStmModeOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printAddrMode5Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printAddrMode6Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O); + void printAddrMode7Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printAddrMode6OffsetOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); Modified: llvm/trunk/test/MC/ARM/arm_instructions.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/arm_instructions.s?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/arm_instructions.s (original) +++ llvm/trunk/test/MC/ARM/arm_instructions.s Thu Mar 24 16:04:58 2011 @@ -284,3 +284,28 @@ @ CHECK: add r1, r2, r3, lsl r4 @ encoding: [0x13,0x14,0x82,0xe0] add r1, r2, r3, lsl r4 + +@ CHECK: strexb r0, r1, [r2] @ encoding: [0x91,0x0f,0xc2,0xe1] + strexb r0, r1, [r2] + +@ CHECK: strexh r0, r1, [r2] @ encoding: [0x91,0x0f,0xe2,0xe1] + strexh r0, r1, [r2] + +@ CHECK: strex r0, r1, [r2] @ encoding: [0x91,0x0f,0x82,0xe1] + strex r0, r1, [r2] + +@ CHECK: strexd r0, r2, r3, [r1] @ encoding: [0x92,0x0f,0xa1,0xe1] + strexd r0, r2, r3, [r1] + +@ CHECK: ldrexb r0, [r0] @ encoding: [0x9f,0x0f,0xd0,0xe1] + ldrexb r0, [r0] + +@ CHECK: ldrexh r0, [r0] @ encoding: [0x9f,0x0f,0xf0,0xe1] + ldrexh r0, [r0] + +@ CHECK: ldrex r0, [r0] @ encoding: [0x9f,0x0f,0x90,0xe1] + ldrex r0, [r0] + +@ CHECK: ldrexd r0, r1, [r0] @ encoding: [0x9f,0x0f,0xb0,0xe1] + ldrexd r0, r1, [r0] + Modified: llvm/trunk/test/MC/ARM/thumb2.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb2.s?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/thumb2.s (original) +++ llvm/trunk/test/MC/ARM/thumb2.s Thu Mar 24 16:04:58 2011 @@ -284,3 +284,19 @@ @ CHECK: msr cpsr_fsxc, r0 @ encoding: [0x80,0xf3,0x00,0x8f] msr cpsr_fsxc, r0 +@ CHECK: strexb r0, r1, [r2] @ encoding: [0xc2,0xe8,0x40,0x1f] + strexb r0, r1, [r2] +@ CHECK: strexh r0, r1, [r2] @ encoding: [0xc2,0xe8,0x50,0x1f] + strexh r0, r1, [r2] +@ CHECK: strex r0, r1, [r2] @ encoding: [0x42,0xe8,0x00,0x10] + strex r0, r1, [r2] +@ CHECK: strexd r0, r2, r3, [r1] @ encoding: [0xc1,0xe8,0x70,0x23] + strexd r0, r2, r3, [r1] +@ CHECK: ldrexb r0, [r0] @ encoding: [0xd0,0xe8,0x4f,0x0f] + ldrexb r0, [r0] +@ CHECK: ldrexh r0, [r0] @ encoding: [0xd0,0xe8,0x5f,0x0f] + ldrexh r0, [r0] +@ CHECK: ldrex r0, [r0] @ encoding: [0x50,0xe8,0x00,0x0f] + ldrex r0, [r0] +@ CHECK: ldrexd r0, r1, [r0] @ encoding: [0xd0,0xe8,0x7f,0x01] + ldrexd r0, r1, [r0] Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=128236&r1=128235&r2=128236&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Thu Mar 24 16:04:58 2011 @@ -637,10 +637,12 @@ MISC("am6offset", "kOperandTypeARMAddrMode6Offset"); // R, I, I MISC("addrmode6dup", "kOperandTypeARMAddrMode6"); // R, R, I, I MISC("addrmodepc", "kOperandTypeARMAddrModePC"); // R, I + MISC("addrmode7", "kOperandTypeARMAddrMode7"); // R MISC("reglist", "kOperandTypeARMRegisterList"); // I, R, ... MISC("dpr_reglist", "kOperandTypeARMDPRRegisterList"); // I, R, ... MISC("spr_reglist", "kOperandTypeARMSPRRegisterList"); // I, R, ... MISC("it_mask", "kOperandTypeThumbITMask"); // I + MISC("t2addrmode_reg", "kOperandTypeThumb2AddrModeReg"); // R MISC("t2addrmode_imm8", "kOperandTypeThumb2AddrModeImm8"); // R, I MISC("t2am_imm8_offset", "kOperandTypeThumb2AddrModeImm8Offset");//I MISC("t2addrmode_imm12", "kOperandTypeThumb2AddrModeImm12"); // R, I @@ -858,6 +860,7 @@ operandTypes.addEntry("kOperandTypeARMAddrMode5"); operandTypes.addEntry("kOperandTypeARMAddrMode6"); operandTypes.addEntry("kOperandTypeARMAddrMode6Offset"); + operandTypes.addEntry("kOperandTypeARMAddrMode7"); operandTypes.addEntry("kOperandTypeARMAddrModePC"); operandTypes.addEntry("kOperandTypeARMRegisterList"); operandTypes.addEntry("kOperandTypeARMDPRRegisterList"); @@ -869,6 +872,7 @@ operandTypes.addEntry("kOperandTypeThumbAddrModeRR"); operandTypes.addEntry("kOperandTypeThumbAddrModeSP"); operandTypes.addEntry("kOperandTypeThumbAddrModePC"); + operandTypes.addEntry("kOperandTypeThumb2AddrModeReg"); operandTypes.addEntry("kOperandTypeThumb2SoReg"); operandTypes.addEntry("kOperandTypeThumb2SoImm"); operandTypes.addEntry("kOperandTypeThumb2AddrModeImm8"); From baldrick at free.fr Thu Mar 24 16:18:23 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 24 Mar 2011 22:18:23 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r128230 - in /llvm-gcc-4.2/trunk/gcc: function.c gimplify.c llvm-convert.cpp omp-low.c In-Reply-To: <20110324201839.71BA92A6C12C@llvm.org> References: <20110324201839.71BA92A6C12C@llvm.org> Message-ID: <4D8BB51F.3090501@free.fr> Hi Eric, > Add an evil hack that adds an argument to alloca calls when we can > interpose them, and falls back if necessary in order to store the > alignment. Previously this code would be broken by multiple vlas > in a single function. got a testcase? Ciao, Duncan. From benny.kra at googlemail.com Thu Mar 24 16:14:28 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 24 Mar 2011 21:14:28 -0000 Subject: [llvm-commits] [llvm] r128238 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassembler.cpp test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Message-ID: <20110324211428.315672A6C12C@llvm.org> Author: d0k Date: Thu Mar 24 16:14:28 2011 New Revision: 128238 URL: http://llvm.org/viewvc/llvm-project?rev=128238&view=rev Log: Plug a leak in the arm disassembler and put the tests back. Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt - copied unchanged from r128234, llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS3p-arm.txt llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt - copied unchanged from r128234, llvm/trunk/test/MC/Disassembler/ARM/invalid-VLDMSDB-arm.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=128238&r1=128237&r2=128238&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Thu Mar 24 16:14:28 2011 @@ -18,6 +18,7 @@ #include "ARMDisassembler.h" #include "ARMDisassemblerCore.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/MC/EDInstInfo.h" #include "llvm/MC/MCInst.h" #include "llvm/Target/TargetRegistry.h" @@ -384,15 +385,13 @@ showBitVector(errs(), insn); }); - ARMBasicMCBuilder *Builder = CreateMCBuilder(Opcode, Format); + OwningPtr Builder(CreateMCBuilder(Opcode, Format)); if (!Builder) return false; if (!Builder->Build(MI, insn)) return false; - delete Builder; - return true; } From echristo at apple.com Thu Mar 24 16:20:46 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 24 Mar 2011 14:20:46 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r128230 - in /llvm-gcc-4.2/trunk/gcc: function.c gimplify.c llvm-convert.cpp omp-low.c In-Reply-To: <4D8BB51F.3090501@free.fr> References: <20110324201839.71BA92A6C12C@llvm.org> <4D8BB51F.3090501@free.fr> Message-ID: On Mar 24, 2011, at 2:18 PM, Duncan Sands wrote: > Hi Eric, > >> Add an evil hack that adds an argument to alloca calls when we can >> interpose them, and falls back if necessary in order to store the >> alignment. Previously this code would be broken by multiple vlas >> in a single function. > > got a test case? I do, I'm not quite sure where to put it at this point since we've been trying to not put things in the llvm test suite for it. Thoughts? -eric From baldrick at free.fr Thu Mar 24 16:22:58 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 24 Mar 2011 22:22:58 +0100 Subject: [llvm-commits] [llvm-gcc-4.2] r128230 - in /llvm-gcc-4.2/trunk/gcc: function.c gimplify.c llvm-convert.cpp omp-low.c In-Reply-To: References: <20110324201839.71BA92A6C12C@llvm.org> <4D8BB51F.3090501@free.fr> Message-ID: <4D8BB632.4070509@free.fr> >>> Add an evil hack that adds an argument to alloca calls when we can >>> interpose them, and falls back if necessary in order to store the >>> alignment. Previously this code would be broken by multiple vlas >>> in a single function. >> >> got a test case? > > I do, I'm not quite sure where to put it at this point since we've been > trying to not put things in the llvm test suite for it. > > Thoughts? Can you please put it in the LLVM testsuite. That's where such tests have always gone, so why change now :) Since this is the last llvm-gcc release, I will probably move all the front-end tests to the dragonegg repository at some point after 2.9 comes out. Ciao, Duncan. From echristo at apple.com Thu Mar 24 16:24:30 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 24 Mar 2011 14:24:30 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r128230 - in /llvm-gcc-4.2/trunk/gcc: function.c gimplify.c llvm-convert.cpp omp-low.c In-Reply-To: <4D8BB632.4070509@free.fr> References: <20110324201839.71BA92A6C12C@llvm.org> <4D8BB51F.3090501@free.fr> <4D8BB632.4070509@free.fr> Message-ID: On Mar 24, 2011, at 2:22 PM, Duncan Sands wrote: >>>> Add an evil hack that adds an argument to alloca calls when we can >>>> interpose them, and falls back if necessary in order to store the >>>> alignment. Previously this code would be broken by multiple vlas >>>> in a single function. >>> >>> got a test case? >> >> I do, I'm not quite sure where to put it at this point since we've been >> trying to not put things in the llvm test suite for it. >> >> Thoughts? > > Can you please put it in the LLVM testsuite. That's where such tests have > always gone, so why change now :) Since this is the last llvm-gcc release, > I will probably move all the front-end tests to the dragonegg repository > at some point after 2.9 comes out. Makes total sense. I'll do that :) Thanks. -eric From johnny.chen at apple.com Thu Mar 24 16:36:56 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 21:36:56 -0000 Subject: [llvm-commits] [llvm] r128240 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110324213657.0892C2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 16:36:56 2011 New Revision: 128240 URL: http://llvm.org/viewvc/llvm-project?rev=128240&view=rev Log: T2 Load/Store Multiple: These instructions were changed to not embed the addressing mode within the MC instructions We also need to update the corresponding assert stmt. Also add a test case. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128240&r1=128239&r2=128240&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Thu Mar 24 16:36:56 2011 @@ -1140,7 +1140,7 @@ Opcode == ARM::t2STMIA || Opcode == ARM::t2STMIA_UPD || Opcode == ARM::t2STMDB || Opcode == ARM::t2STMDB_UPD) && "Unexpected opcode"); - assert(NumOps >= 5 && "Thumb2 LdStMul expects NumOps >= 5"); + assert(NumOps >= 4 && "Thumb2 LdStMul expects NumOps >= 4"); NumOpsAdded = 0; Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128240&r1=128239&r2=128240&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 24 16:36:56 2011 @@ -136,3 +136,6 @@ # CHECK: vcmpe.f64 d8, #0 0xb5 0xee 0xc0 0x8b + +# CHECK: stmdb.w sp, {r0, r2, r3, r8, r11, lr} +0x0d 0xe9 0x0d 0x49 From johnny.chen at apple.com Thu Mar 24 16:42:55 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 21:42:55 -0000 Subject: [llvm-commits] [llvm] r128241 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Message-ID: <20110324214255.650652A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 16:42:55 2011 New Revision: 128241 URL: http://llvm.org/viewvc/llvm-project?rev=128241&view=rev Log: Plug a leak by ThumbDisassembler::getInstruction(), thanks to Benjamin Kramer! Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=128241&r1=128240&r2=128241&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Thu Mar 24 16:42:55 2011 @@ -465,7 +465,7 @@ showBitVector(errs(), insn); }); - ARMBasicMCBuilder *Builder = CreateMCBuilder(Opcode, Format); + OwningPtr Builder(CreateMCBuilder(Opcode, Format)); if (!Builder) return false; @@ -474,8 +474,6 @@ if (!Builder->Build(MI, insn)) return false; - delete Builder; - return true; } From echristo at apple.com Thu Mar 24 16:59:03 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 24 Mar 2011 21:59:03 -0000 Subject: [llvm-commits] [llvm] r128242 - /llvm/trunk/test/FrontendC/vla-3.c Message-ID: <20110324215903.F15452A6C12C@llvm.org> Author: echristo Date: Thu Mar 24 16:59:03 2011 New Revision: 128242 URL: http://llvm.org/viewvc/llvm-project?rev=128242&view=rev Log: Testcase for llvm-gcc commit r128230. Added: llvm/trunk/test/FrontendC/vla-3.c Added: llvm/trunk/test/FrontendC/vla-3.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/vla-3.c?rev=128242&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/vla-3.c (added) +++ llvm/trunk/test/FrontendC/vla-3.c Thu Mar 24 16:59:03 2011 @@ -0,0 +1,11 @@ +// RUN: %llvmgcc -std=gnu99 %s -S -o - | grep ".*alloca.*align 16" + +void adr(char *); + +void vlaalign(int size) +{ + char __attribute__((aligned(16))) tmp[size+32]; + char tmp2[size+16]; + + adr(tmp); +} From johnny.chen at apple.com Thu Mar 24 17:04:39 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 22:04:39 -0000 Subject: [llvm-commits] [llvm] r128243 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/neon-tests.txt Message-ID: <20110324220439.9D7AD2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 17:04:39 2011 New Revision: 128243 URL: http://llvm.org/viewvc/llvm-project?rev=128243&view=rev Log: Handle the added VBICiv*i* NEON instructions, too. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128243&r1=128242&r2=128243&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Thu Mar 24 17:04:39 2011 @@ -2302,6 +2302,7 @@ // VMOV (immediate) // Qd/Dd imm +// VBIC (immediate) // VORR (immediate) // Qd/Dd imm src(=Qd/Dd) static bool DisassembleN1RegModImmFrm(MCInst &MI, unsigned Opcode, @@ -2330,6 +2331,8 @@ case ARM::VMOVv8i16: case ARM::VMVNv4i16: case ARM::VMVNv8i16: + case ARM::VBICiv4i16: + case ARM::VBICiv8i16: case ARM::VORRiv4i16: case ARM::VORRiv8i16: esize = ESize16; @@ -2338,6 +2341,8 @@ case ARM::VMOVv4i32: case ARM::VMVNv2i32: case ARM::VMVNv4i32: + case ARM::VBICiv2i32: + case ARM::VBICiv4i32: case ARM::VORRiv2i32: case ARM::VORRiv4i32: esize = ESize32; @@ -2347,7 +2352,7 @@ esize = ESize64; break; default: - assert(0 && "Unreachable code!"); + assert(0 && "Unexpected opcode!"); return false; } @@ -2357,7 +2362,7 @@ NumOpsAdded = 2; - // VORRiv*i* variants have an extra $src = $Vd to be filled in. + // VBIC/VORRiv*i* variants have an extra $src = $Vd to be filled in. if (NumOps >= 3 && (OpInfo[2].RegClass == ARM::DPRRegClassID || OpInfo[2].RegClass == ARM::QPRRegClassID)) { Modified: llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt?rev=128243&r1=128242&r2=128243&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/neon-tests.txt Thu Mar 24 17:04:39 2011 @@ -65,3 +65,6 @@ # CHECK: vorr.i32 q15, #0x4F0000 0x5f 0xe5 0xc4 0xf2 + +# CHECK: vbic.i32 q2, #0xA900 +0x79 0x53 0x82 0xf3 From matthewbg at google.com Thu Mar 24 17:05:48 2011 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Thu, 24 Mar 2011 22:05:48 -0000 Subject: [llvm-commits] [llvm] r128244 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20110324220548.8D3742A6C12C@llvm.org> Author: matthewbg Date: Thu Mar 24 17:05:48 2011 New Revision: 128244 URL: http://llvm.org/viewvc/llvm-project?rev=128244&view=rev Log: Suppress an unused variable warning in -asserts builds Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=128244&r1=128243&r2=128244&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Thu Mar 24 17:05:48 2011 @@ -460,6 +460,7 @@ Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum())); const MCConstantExpr *CE = dyn_cast(getMemOffset()); + (void)CE; assert((CE || CE->getValue() == 0) && "No offset operand support in mode 7"); } From dpatel at apple.com Thu Mar 24 17:39:09 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 24 Mar 2011 22:39:09 -0000 Subject: [llvm-commits] [llvm] r128245 - in /llvm/trunk/test: CodeGen/X86/dbg-file-name.ll DebugInfo/dbg-file-name.ll Message-ID: <20110324223909.2D4BF2A6C12C@llvm.org> Author: dpatel Date: Thu Mar 24 17:39:09 2011 New Revision: 128245 URL: http://llvm.org/viewvc/llvm-project?rev=128245&view=rev Log: Move test in x86 specific area. Added: llvm/trunk/test/CodeGen/X86/dbg-file-name.ll - copied, changed from r128233, llvm/trunk/test/DebugInfo/dbg-file-name.ll Removed: llvm/trunk/test/DebugInfo/dbg-file-name.ll Copied: llvm/trunk/test/CodeGen/X86/dbg-file-name.ll (from r128233, llvm/trunk/test/DebugInfo/dbg-file-name.ll) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-file-name.ll?p2=llvm/trunk/test/CodeGen/X86/dbg-file-name.ll&p1=llvm/trunk/test/DebugInfo/dbg-file-name.ll&r1=128233&r2=128245&rev=128245&view=diff ============================================================================== --- llvm/trunk/test/DebugInfo/dbg-file-name.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-file-name.ll Thu Mar 24 17:39:09 2011 @@ -1,4 +1,7 @@ ; RUN: llc -O0 < %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" + ; Radar 8884898 ; CHECK: file 1 "/Users/manav/one/two/simple.c" Removed: llvm/trunk/test/DebugInfo/dbg-file-name.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/dbg-file-name.ll?rev=128244&view=auto ============================================================================== --- llvm/trunk/test/DebugInfo/dbg-file-name.ll (original) +++ llvm/trunk/test/DebugInfo/dbg-file-name.ll (removed) @@ -1,66 +0,0 @@ -; RUN: llc -O0 < %s | FileCheck %s -; Radar 8884898 -; CHECK: file 1 "/Users/manav/one/two/simple.c" - - at .str = private unnamed_addr constant [8 x i8] c"i = %d\0A\00", align 4 - at .str1 = private unnamed_addr constant [12 x i8] c"i + 1 = %d\0A\00", align 4 - -define void @foo(i32 %i) nounwind { -entry: - %i_addr = alloca i32, align 4 - %"alloca point" = bitcast i32 0 to i32 - call void @llvm.dbg.declare(metadata !{i32* %i_addr}, metadata !9), !dbg !10 - store i32 %i, i32* %i_addr - %0 = load i32* %i_addr, align 4, !dbg !11 - %1 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8]* @.str, i32 0, i32 0), i32 %0) nounwind, !dbg !11 - %2 = load i32* %i_addr, align 4, !dbg !13 - %3 = add nsw i32 %2, 1, !dbg !13 - %4 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str1, i32 0, i32 0), i32 %3) nounwind, !dbg !13 - br label %return, !dbg !14 - -return: ; preds = %entry - ret void, !dbg !14 -} - -declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone - -declare i32 @printf(i8*, ...) nounwind - -define i32 @main() nounwind { -entry: - %retval = alloca i32 - %0 = alloca i32 - %"alloca point" = bitcast i32 0 to i32 - call void @foo(i32 2) nounwind, !dbg !15 - call void @foo(i32 4) nounwind, !dbg !17 - store i32 0, i32* %0, align 4, !dbg !18 - %1 = load i32* %0, align 4, !dbg !18 - store i32 %1, i32* %retval, align 4, !dbg !18 - br label %return, !dbg !18 - -return: ; preds = %entry - %retval1 = load i32* %retval, !dbg !18 - ret i32 %retval1, !dbg !18 -} - -!llvm.dbg.sp = !{!0, !6} - -!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 4, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @foo} ; [ DW_TAG_subprogram ] -!1 = metadata !{i32 589865, metadata !"simple.c", metadata !"/Users/manav/one/two", metadata !2} ; [ DW_TAG_file_type ] -!2 = metadata !{i32 589841, i32 0, i32 1, metadata !"simple.c", metadata !"/Users/manav/one/two", metadata !"LLVM build 00", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] -!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] -!4 = metadata !{null, metadata !5} -!5 = metadata !{i32 589860, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] -!6 = metadata !{i32 589870, i32 0, metadata !1, metadata !"main", metadata !"main", metadata !"main", metadata !1, i32 9, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main} ; [ DW_TAG_subprogram ] -!7 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null} ; [ DW_TAG_subroutine_type ] -!8 = metadata !{metadata !5} -!9 = metadata !{i32 590081, metadata !0, metadata !"i", metadata !1, i32 4, metadata !5, i32 0} ; [ DW_TAG_arg_variable ] -!10 = metadata !{i32 4, i32 0, metadata !0, null} -!11 = metadata !{i32 5, i32 0, metadata !12, null} -!12 = metadata !{i32 589835, metadata !0, i32 4, i32 0, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] -!13 = metadata !{i32 6, i32 0, metadata !12, null} -!14 = metadata !{i32 7, i32 0, metadata !12, null} -!15 = metadata !{i32 10, i32 0, metadata !16, null} -!16 = metadata !{i32 589835, metadata !6, i32 9, i32 0, metadata !1, i32 1} ; [ DW_TAG_lexical_block ] -!17 = metadata !{i32 11, i32 0, metadata !16, null} -!18 = metadata !{i32 12, i32 0, metadata !16, null} From johnny.chen at apple.com Thu Mar 24 18:21:14 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 23:21:14 -0000 Subject: [llvm-commits] [llvm] r128246 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110324232114.D4C2E2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 18:21:14 2011 New Revision: 128246 URL: http://llvm.org/viewvc/llvm-project?rev=128246&view=rev Log: The ARM disassembler was confused with the 16-bit tSTMIA instruction. According to A8.6.189 STM/STMIA/STMEA (Encoding T1), there's only tSTMIA_UPD available. Ignore tSTMIA for the decoder emitter and add a test case for that. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128246&r1=128245&r2=128246&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 24 18:21:14 2011 @@ -139,3 +139,6 @@ # CHECK: stmdb.w sp, {r0, r2, r3, r8, r11, lr} 0x0d 0xe9 0x0d 0x49 + +# CHECK: stmia r5!, {r0, r1, r2, r3, r4} +0x1f 0xc5 Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=128246&r1=128245&r2=128246&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Thu Mar 24 18:21:14 2011 @@ -1615,6 +1615,11 @@ if (!thumbInstruction(Form)) return false; + // A8.6.189 STM / STMIA / STMEA -- Encoding T1 + // There's only STMIA_UPD for Thumb1. + if (Name == "tSTMIA") + return false; + // On Darwin R9 is call-clobbered. Ignore the non-Darwin counterparts. if (Name == "tBL" || Name == "tBLXi" || Name == "tBLXr") return false; From johnny.chen at apple.com Thu Mar 24 18:42:31 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 23:42:31 -0000 Subject: [llvm-commits] [llvm] r128247 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110324234231.6A9CB2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 18:42:31 2011 New Revision: 128247 URL: http://llvm.org/viewvc/llvm-project?rev=128247&view=rev Log: The opcode names ("tLDM", "tLDM_UPD") used for conflict resolution have been stale since the change to ("tLDMIA", "tLDMIA_UPD"). Update the conflict resolution code and add test cases for that. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128247&r1=128246&r2=128247&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 24 18:42:31 2011 @@ -142,3 +142,9 @@ # CHECK: stmia r5!, {r0, r1, r2, r3, r4} 0x1f 0xc5 + +# CHECK: ldmia r5, {r0, r1, r2, r3, r4, r5} +0x3f 0xcd + +# CHECK: ldmia r5!, {r0, r1, r2, r3, r4} +0x1f 0xcd Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=128247&r1=128246&r2=128247&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Thu Mar 24 18:42:31 2011 @@ -1382,7 +1382,7 @@ // 2. source registers are identical => VMOVQ; otherwise => VORRq // 3. LDR, LDRcp => return LDR for now. // FIXME: How can we distinguish between LDR and LDRcp? Do we need to? - // 4. tLDM, tLDM_UPD => Rn = Inst{10-8}, reglist = Inst{7-0}, + // 4. tLDMIA, tLDMIA_UPD => Rn = Inst{10-8}, reglist = Inst{7-0}, // wback = registers = 0 // NOTE: (tLDM, tLDM_UPD) resolution must come before Advanced SIMD // addressing mode resolution!!! @@ -1423,7 +1423,7 @@ << "; // Returning LDR for {LDR, LDRcp}\n"; return true; } - if (name1 == "tLDM" && name2 == "tLDM_UPD") { + if (name1 == "tLDMIA" && name2 == "tLDMIA_UPD") { // Inserting the opening curly brace for this case block. --Indentation; --Indentation; o.indent(Indentation) << "{\n"; From johnny.chen at apple.com Thu Mar 24 19:17:42 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 00:17:42 -0000 Subject: [llvm-commits] [llvm] r128249 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20110325001742.B439C2A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 19:17:42 2011 New Revision: 128249 URL: http://llvm.org/viewvc/llvm-project?rev=128249&view=rev Log: delegate the disassembly of t2ADR to the more generic t2ADDri12/t2SUBri12 instructions, and add a test case for that. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128249&r1=128248&r2=128249&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 24 19:17:42 2011 @@ -148,3 +148,6 @@ # CHECK: ldmia r5!, {r0, r1, r2, r3, r4} 0x1f 0xcd + +# CHECK: addw r0, pc, #1050 +0x0f 0xf2 0x1a 0x40 Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=128249&r1=128248&r2=128249&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Thu Mar 24 19:17:42 2011 @@ -1632,6 +1632,11 @@ if (Name == "tADR") return false; + // Delegate t2ADR disassembly to the more generic t2ADDri12/t2SUBri12 + // instructions. + if (Name == "t2ADR") + return false; + // Ignore tADDrSP, tADDspr, and tPICADD, prefer the generic tADDhirr. // Ignore t2SUBrSPs, prefer the t2SUB[S]r[r|s]. // Ignore t2ADDrSPs, prefer the t2ADD[S]r[r|s]. From eli.friedman at gmail.com Thu Mar 24 19:28:41 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 24 Mar 2011 17:28:41 -0700 Subject: [llvm-commits] [llvm] r128246 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp In-Reply-To: <20110324232114.D4C2E2A6C12C@llvm.org> References: <20110324232114.D4C2E2A6C12C@llvm.org> Message-ID: On Thu, Mar 24, 2011 at 4:21 PM, Johnny Chen wrote: > Author: johnny > Date: Thu Mar 24 18:21:14 2011 > New Revision: 128246 > > URL: http://llvm.org/viewvc/llvm-project?rev=128246&view=rev > Log: > The ARM disassembler was confused with the 16-bit tSTMIA instruction. > According to A8.6.189 STM/STMIA/STMEA (Encoding T1), there's only tSTMIA_UPD available. > Ignore tSTMIA for the decoder emitter and add a test case for that. Why do we have a definition for an instruction which doesn't exist? -Eli From johnny.chen at apple.com Thu Mar 24 19:59:03 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 24 Mar 2011 17:59:03 -0700 Subject: [llvm-commits] [llvm] r128246 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp In-Reply-To: References: <20110324232114.D4C2E2A6C12C@llvm.org> Message-ID: <9A9FBE96-21A0-4AD5-A4F8-0BA5EA40E5AE@apple.com> let mayLoad = 1, hasExtraDefRegAllocReq = 1 in defm tLDM : thumb_ldst_mult<"ldm", IIC_iLoad_m, IIC_iLoad_mu, {1,1,0,0,1,?}, 1>; let mayStore = 1, hasExtraSrcRegAllocReq = 1 in defm tSTM : thumb_ldst_mult<"stm", IIC_iStore_m, IIC_iStore_mu, {1,1,0,0,0,?}, 0>; tLDM uses the defm nicely, but tSTMIA doesn't belong. On Mar 24, 2011, at 5:28 PM, Eli Friedman wrote: > On Thu, Mar 24, 2011 at 4:21 PM, Johnny Chen wrote: >> Author: johnny >> Date: Thu Mar 24 18:21:14 2011 >> New Revision: 128246 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128246&view=rev >> Log: >> The ARM disassembler was confused with the 16-bit tSTMIA instruction. >> According to A8.6.189 STM/STMIA/STMEA (Encoding T1), there's only tSTMIA_UPD available. >> Ignore tSTMIA for the decoder emitter and add a test case for that. > > Why do we have a definition for an instruction which doesn't exist? > > -Eli From johnny.chen at apple.com Thu Mar 24 20:09:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 01:09:48 -0000 Subject: [llvm-commits] [llvm] r128252 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325010948.F07052A6C12C@llvm.org> Author: johnny Date: Thu Mar 24 20:09:48 2011 New Revision: 128252 URL: http://llvm.org/viewvc/llvm-project?rev=128252&view=rev Log: Modify the wrong logic in the assert of DisassembleThumb2LdStDual() (the register classes were changed), modify the comment to be up-to-date, and add a test case for A8.6.66 LDRD (immediate) Encoding T1. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128252&r1=128251&r2=128252&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Thu Mar 24 20:09:48 2011 @@ -1230,9 +1230,6 @@ return true; } -// LLVM, as of Jan-05-2010, does not output , i.e., Rs, in the asm. -// Whereas the ARM Arch. Manual does not require that t2 = t+1 like in ARM ISA. -// // t2LDRDi8: Rd Rs Rn imm8s4 (offset mode) // t2LDRDpci: Rd Rs imm8s4 (Not decoded, prefer the generic t2LDRDi8 version) // t2STRDi8: Rd Rs Rn imm8s4 (offset mode) @@ -1246,18 +1243,21 @@ if (!OpInfo) return false; assert(NumOps >= 4 - && OpInfo[0].RegClass == ARM::GPRRegClassID - && OpInfo[1].RegClass == ARM::GPRRegClassID - && OpInfo[2].RegClass == ARM::GPRRegClassID + && OpInfo[0].RegClass > 0 + && OpInfo[0].RegClass == OpInfo[1].RegClass + && OpInfo[2].RegClass > 0 && OpInfo[3].RegClass < 0 && "Expect >= 4 operands and first 3 as reg operands"); // Add the operands. - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + unsigned RegClassPair = OpInfo[0].RegClass; + unsigned RegClassBase = OpInfo[2].RegClass; + + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, RegClassPair, decodeRd(insn)))); - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, RegClassPair, decodeRs(insn)))); - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, RegClassBase, decodeRn(insn)))); // Finally add (+/-)imm8*4, depending on the U bit. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128252&r1=128251&r2=128252&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Thu Mar 24 20:09:48 2011 @@ -151,3 +151,6 @@ # CHECK: addw r0, pc, #1050 0x0f 0xf2 0x1a 0x40 + +# CHECK: ldrd r3, r8, [r11, #-60] +0x5b 0xe9 0x0f 0x38 From stoklund at 2pi.dk Thu Mar 24 20:48:18 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 25 Mar 2011 01:48:18 -0000 Subject: [llvm-commits] [llvm] r128254 - in /llvm/trunk/lib: CodeGen/RegAllocLinearScan.cpp Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <20110325014818.5E2E32A6C12C@llvm.org> Author: stoklund Date: Thu Mar 24 20:48:18 2011 New Revision: 128254 URL: http://llvm.org/viewvc/llvm-project?rev=128254&view=rev Log: Ignore special ARM allocation hints for unexpected register classes. Add an assertion to linear scan to prevent it from allocating registers outside the register class. Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=128254&r1=128253&r2=128254&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Thu Mar 24 20:48:18 2011 @@ -1110,6 +1110,7 @@ // list. if (physReg) { DEBUG(dbgs() << tri_->getName(physReg) << '\n'); + assert(RC->contains(physReg) && "Invalid candidate"); vrm_->assignVirt2Phys(cur->reg, physReg); addRegUse(physReg); active_.push_back(std::make_pair(cur, cur->begin())); Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=128254&r1=128253&r2=128254&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Thu Mar 24 20:48:18 2011 @@ -448,6 +448,10 @@ ARM::R0, ARM::R2, ARM::R10,ARM::R12,ARM::LR, ARM::R4, ARM::R6, ARM::R8 }; + // We only support even/odd hints for GPR and rGPR. + if (RC != ARM::GPRRegisterClass && RC != ARM::rGPRRegisterClass) + return std::make_pair(RC->allocation_order_begin(MF), + RC->allocation_order_end(MF)); if (HintType == ARMRI::RegPairEven) { if (isPhysicalRegister(HintReg) && getRegisterPairEven(HintReg, MF) == 0) From nicholas at mxc.ca Fri Mar 25 01:04:26 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 25 Mar 2011 06:04:26 -0000 Subject: [llvm-commits] [llvm] r128256 - /llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Message-ID: <20110325060426.9CAFE2A6C12C@llvm.org> Author: nicholas Date: Fri Mar 25 01:04:26 2011 New Revision: 128256 URL: http://llvm.org/viewvc/llvm-project?rev=128256&view=rev Log: No functionality change. Fix up some whitespace and switch out "" for '' when printing a single character. Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=128256&r1=128255&r2=128256&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Fri Mar 25 01:04:26 2011 @@ -375,7 +375,7 @@ dbgs() << str << " intervals:\n"; for (; i != e; ++i) { - dbgs() << "\t" << *i->first << " -> "; + dbgs() << '\t' << *i->first << " -> "; unsigned reg = i->first->reg; if (TargetRegisterInfo::isVirtualRegister(reg)) @@ -390,7 +390,7 @@ } INITIALIZE_PASS_BEGIN(RALinScan, "linearscan-regalloc", - "Linear Scan Register Allocator", false, false) + "Linear Scan Register Allocator", false, false) INITIALIZE_PASS_DEPENDENCY(LiveIntervals) INITIALIZE_PASS_DEPENDENCY(StrongPHIElimination) INITIALIZE_PASS_DEPENDENCY(CalculateSpillWeights) @@ -401,7 +401,7 @@ INITIALIZE_AG_DEPENDENCY(RegisterCoalescer) INITIALIZE_AG_DEPENDENCY(AliasAnalysis) INITIALIZE_PASS_END(RALinScan, "linearscan-regalloc", - "Linear Scan Register Allocator", false, false) + "Linear Scan Register Allocator", false, false) void RALinScan::ComputeRelatedRegClasses() { // First pass, add all reg classes to the union, and determine at least one From nicholas at mxc.ca Fri Mar 25 01:05:50 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 25 Mar 2011 06:05:50 -0000 Subject: [llvm-commits] [llvm] r128257 - /llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Message-ID: <20110325060550.425BF2A6C12C@llvm.org> Author: nicholas Date: Fri Mar 25 01:05:50 2011 New Revision: 128257 URL: http://llvm.org/viewvc/llvm-project?rev=128257&view=rev Log: No functionality change, just adjust some whitespace for coding style compliance. Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=128257&r1=128256&r2=128257&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Fri Mar 25 01:05:50 2011 @@ -125,7 +125,7 @@ const ComparableFunction ComparableFunction::EmptyKey = ComparableFunction(0); const ComparableFunction ComparableFunction::TombstoneKey = ComparableFunction(1); -TargetData * const ComparableFunction::LookupOnly = (TargetData*)(-1); +TargetData *const ComparableFunction::LookupOnly = (TargetData*)(-1); } @@ -212,7 +212,7 @@ return false; } - switch(Ty1->getTypeID()) { + switch (Ty1->getTypeID()) { default: llvm_unreachable("Unknown type!"); // Fall through in Release mode. From isanbard at gmail.com Fri Mar 25 01:36:57 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 25 Mar 2011 06:36:57 -0000 Subject: [llvm-commits] [test-suite] r128265 - /test-suite/tags/RELEASE_29/rc2/ Message-ID: <20110325063657.EB6692A6C12D@llvm.org> Author: void Date: Fri Mar 25 01:36:57 2011 New Revision: 128265 URL: http://llvm.org/viewvc/llvm-project?rev=128265&view=rev Log: Creating test-suite 2.9 release-candidate 2 Added: test-suite/tags/RELEASE_29/rc2/ (props changed) - copied from r128264, test-suite/branches/release_29/ Propchange: test-suite/tags/RELEASE_29/rc2/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Fri Mar 25 01:36:57 2011 @@ -0,0 +1,4 @@ +Makefile.config +config.log +config.status +mklib Propchange: test-suite/tags/RELEASE_29/rc2/ ------------------------------------------------------------------------------ svn:mergeinfo = /test-suite/trunk:128083 From atrick at apple.com Fri Mar 25 01:40:55 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 25 Mar 2011 06:40:55 -0000 Subject: [llvm-commits] [llvm] r128266 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <20110325064055.BF9AD2A6C12C@llvm.org> Author: atrick Date: Fri Mar 25 01:40:55 2011 New Revision: 128266 URL: http://llvm.org/viewvc/llvm-project?rev=128266&view=rev Log: Fix for -pre-RA-sched=source. Yet another case of unchecked NULL node (for physreg copy). May fix PR9509. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=128266&r1=128265&r2=128266&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Fri Mar 25 01:40:55 2011 @@ -1500,6 +1500,8 @@ unsigned getNodePriority(const SUnit *SU) const; unsigned getNodeOrdering(const SUnit *SU) const { + if (!SU->getNode()) return 0; + return scheduleDAG->DAG->GetOrdering(SU->getNode()); } From isanbard at gmail.com Fri Mar 25 01:43:59 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 25 Mar 2011 06:43:59 -0000 Subject: [llvm-commits] [llvm] r128267 - /llvm/trunk/docs/HowToReleaseLLVM.html Message-ID: <20110325064359.AE2172A6C12C@llvm.org> Author: void Date: Fri Mar 25 01:43:59 2011 New Revision: 128267 URL: http://llvm.org/viewvc/llvm-project?rev=128267&view=rev Log: Remove redundant compression option. Modified: llvm/trunk/docs/HowToReleaseLLVM.html Modified: llvm/trunk/docs/HowToReleaseLLVM.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/HowToReleaseLLVM.html?rev=128267&r1=128266&r2=128267&view=diff ============================================================================== --- llvm/trunk/docs/HowToReleaseLLVM.html (original) +++ llvm/trunk/docs/HowToReleaseLLVM.html Fri Mar 25 01:43:59 2011 @@ -256,10 +256,10 @@ $ svn export https://llvm.org/svn/llvm-project/test-suite/tags/RELEASE_XY/rc1 llvm-test-X.Yrc1 $ svn export https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_XY/rc1 clang-X.Yrc1 -$ tar -czvf - llvm-X.Yrc1 | gzip > llvm-X.Yrc1.src.tar.gz -$ tar -czvf - llvm-test-X.Yrc1 | gzip > llvm-test-X.Yrc1.src.tar.gz -$ tar -czvf - llvm-gcc4.2-X.Yrc1 | gzip > llvm-gcc-4.2-X.Yrc1.src.tar.gz -$ tar -czvf - clang-X.Yrc1 | gzip > clang-X.Yrc1.src.tar.gz +$ tar -cvf - llvm-X.Yrc1 | gzip > llvm-X.Yrc1.src.tar.gz +$ tar -cvf - llvm-test-X.Yrc1 | gzip > llvm-test-X.Yrc1.src.tar.gz +$ tar -cvf - llvm-gcc4.2-X.Yrc1 | gzip > llvm-gcc-4.2-X.Yrc1.src.tar.gz +$ tar -cvf - clang-X.Yrc1 | gzip > clang-X.Yrc1.src.tar.gz From baldrick at free.fr Fri Mar 25 02:17:44 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 25 Mar 2011 07:17:44 -0000 Subject: [llvm-commits] [llvm] r128268 - /llvm/trunk/utils/release/findRegressions.py Message-ID: <20110325071744.3CEF42A6C12C@llvm.org> Author: baldrick Date: Fri Mar 25 02:17:44 2011 New Revision: 128268 URL: http://llvm.org/viewvc/llvm-project?rev=128268&view=rev Log: Useful script for finding regressions in the nightly testsuite. I think it was written by Pawel Worach. Added: llvm/trunk/utils/release/findRegressions.py (with props) Added: llvm/trunk/utils/release/findRegressions.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/release/findRegressions.py?rev=128268&view=auto ============================================================================== --- llvm/trunk/utils/release/findRegressions.py (added) +++ llvm/trunk/utils/release/findRegressions.py Fri Mar 25 02:17:44 2011 @@ -0,0 +1,130 @@ +#!/usr/bin/python +import re, string, sys, os, time + +DEBUG = 0 +testDirName = 'llvm-test' +test = ['compile', 'llc', 'jit', 'cbe'] +exectime = ['llc-time', 'jit-time', 'cbe-time',] +comptime = ['llc', 'jit-comptime', 'compile'] + +(tp, exp) = ('compileTime_', 'executeTime_') + +def parse(file): + f=open(file, 'r') + d = f.read() + + #Cleanup weird stuff + d = re.sub(r',\d+:\d','', d) + + r = re.findall(r'TEST-(PASS|FAIL|RESULT.*?):\s+(.*?)\s+(.*?)\r*\n', d) + + test = {} + fname = '' + for t in r: + if DEBUG: + print t + if t[0] == 'PASS' or t[0] == 'FAIL' : + tmp = t[2].split(testDirName) + + if DEBUG: + print tmp + + if len(tmp) == 2: + fname = tmp[1].strip('\r\n') + else: + fname = tmp[0].strip('\r\n') + + if not test.has_key(fname) : + test[fname] = {} + + for k in test: + test[fname][k] = 'NA' + test[fname][t[1]] = t[0] + if DEBUG: + print test[fname][t[1]] + else : + try: + n = t[0].split('RESULT-')[1] + + if DEBUG: + print n; + + if n == 'llc' or n == 'jit-comptime' or n == 'compile': + test[fname][tp + n] = float(t[2].split(' ')[2]) + if DEBUG: + print test[fname][tp + n] + + elif n.endswith('-time') : + test[fname][exp + n] = float(t[2].strip('\r\n')) + if DEBUG: + print test[fname][exp + n] + + else : + print "ERROR!" + sys.exit(1) + + except: + continue + + return test + +# Diff results and look for regressions. +def diffResults(d_old, d_new): + + for t in sorted(d_old.keys()) : + if DEBUG: + print t + + if d_new.has_key(t) : + + # Check if the test passed or failed. + for x in test: + if d_old[t].has_key(x): + if d_new[t].has_key(x): + if d_old[t][x] == 'PASS': + if d_new[t][x] != 'PASS': + print t + " *** REGRESSION (" + x + ")\n" + else: + if d_new[t][x] == 'PASS': + print t + " * NEW PASS (" + x + ")\n" + + else : + print t + "*** REGRESSION (" + x + ")\n" + + # For execution time, if there is no result, its a fail. + for x in exectime: + if d_old[t].has_key(tp + x): + if not d_new[t].has_key(tp + x): + print t + " *** REGRESSION (" + tp + x + ")\n" + + else : + if d_new[t].has_key(tp + x): + print t + " * NEW PASS (" + tp + x + ")\n" + + + for x in comptime: + if d_old[t].has_key(exp + x): + if not d_new[t].has_key(exp + x): + print t + " *** REGRESSION (" + exp + x + ")\n" + + else : + if d_new[t].has_key(exp + x): + print t + " * NEW PASS (" + exp + x + ")\n" + + else : + print t + ": Removed from test-suite.\n" + + +#Main +if len(sys.argv) < 3 : + print 'Usage:', sys.argv[0], \ + ' ' + sys.exit(-1) + +d_old = parse(sys.argv[1]) +d_new = parse(sys.argv[2]) + + +diffResults(d_old, d_new) + + Propchange: llvm/trunk/utils/release/findRegressions.py ------------------------------------------------------------------------------ svn:executable = * From baldrick at free.fr Fri Mar 25 04:12:07 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 25 Mar 2011 09:12:07 -0000 Subject: [llvm-commits] [test-suite] r128270 - /test-suite/trunk/MultiSource/Applications/lemon/Makefile Message-ID: <20110325091207.816942A6C12C@llvm.org> Author: baldrick Date: Fri Mar 25 04:12:07 2011 New Revision: 128270 URL: http://llvm.org/viewvc/llvm-project?rev=128270&view=rev Log: This timeout was not enough on some machines. Modified: test-suite/trunk/MultiSource/Applications/lemon/Makefile Modified: test-suite/trunk/MultiSource/Applications/lemon/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/lemon/Makefile?rev=128270&r1=128269&r2=128270&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/lemon/Makefile (original) +++ test-suite/trunk/MultiSource/Applications/lemon/Makefile Fri Mar 25 04:12:07 2011 @@ -7,7 +7,7 @@ HASH_PROGRAM_OUTPUT = 1 # With a Debug+Asserts build may time out if the default limit is used. -RUNTIMELIMIT := 750 +RUNTIMELIMIT := 1500 include $(LEVEL)/Makefile.config From daniel at zuster.org Fri Mar 25 10:52:51 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 25 Mar 2011 15:52:51 -0000 Subject: [llvm-commits] [compiler-rt] r128282 - in /compiler-rt/trunk: lib/comparedf2.c lib/comparesf2.c lib/eqdf2.c lib/eqsf2.c lib/fp_lib.h lib/gedf2.c lib/gesf2.c lib/gtdf2.c lib/gtsf2.c lib/ledf2.c lib/lesf2.c lib/ltdf2.c lib/ltsf2.c lib/nedf2.c lib/nesf2.c lib/unorddf2.c lib/unordsf2.c make/platform/clang_darwin.mk Message-ID: <20110325155251.EBAD42A6C12C@llvm.org> Author: ddunbar Date: Fri Mar 25 10:52:51 2011 New Revision: 128282 URL: http://llvm.org/viewvc/llvm-project?rev=128282&view=rev Log: Split single & double comparison routines into separate implementation files, for consistency. Added: compiler-rt/trunk/lib/eqdf2.c compiler-rt/trunk/lib/eqsf2.c compiler-rt/trunk/lib/gedf2.c compiler-rt/trunk/lib/gesf2.c compiler-rt/trunk/lib/gtdf2.c compiler-rt/trunk/lib/gtsf2.c compiler-rt/trunk/lib/ledf2.c compiler-rt/trunk/lib/lesf2.c compiler-rt/trunk/lib/ltdf2.c compiler-rt/trunk/lib/ltsf2.c compiler-rt/trunk/lib/nedf2.c compiler-rt/trunk/lib/nesf2.c compiler-rt/trunk/lib/unorddf2.c compiler-rt/trunk/lib/unordsf2.c Removed: compiler-rt/trunk/lib/comparedf2.c compiler-rt/trunk/lib/comparesf2.c Modified: compiler-rt/trunk/lib/fp_lib.h compiler-rt/trunk/make/platform/clang_darwin.mk Removed: compiler-rt/trunk/lib/comparedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparedf2.c?rev=128281&view=auto ============================================================================== --- compiler-rt/trunk/lib/comparedf2.c (original) +++ compiler-rt/trunk/lib/comparedf2.c (removed) @@ -1,132 +0,0 @@ -//===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// // This file implements the following soft-float comparison routines: -// -// __eqdf2 __gedf2 __unorddf2 -// __ledf2 __gtdf2 -// __ltdf2 -// __nedf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __ledf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gedf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unorddf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT { - LE_LESS = -1, - LE_EQUAL = 0, - LE_GREATER = 1, - LE_UNORDERED = 1 -}; - -enum LE_RESULT __ledf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - // If either a or b is NaN, they are unordered. - if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; - - // If a and b are both zeros, they are equal. - if ((aAbs | bAbs) == 0) return LE_EQUAL; - - // If at least one of a and b is positive, we get the same result comparing - // a and b as signed integers as we would with a floating-point compare. - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } - - // Otherwise, both are negative, so we need to flip the sense of the - // comparison to get the correct result. (This assumes a twos- or ones- - // complement integer representation; if integers are represented in a - // sign-magnitude representation, then this flip is incorrect). - else { - if (aInt > bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } -} - -enum GE_RESULT { - GE_LESS = -1, - GE_EQUAL = 0, - GE_GREATER = 1, - GE_UNORDERED = -1 // Note: different from LE_UNORDERED -}; - -enum GE_RESULT __gedf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; - if ((aAbs | bAbs) == 0) return GE_EQUAL; - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } else { - if (aInt > bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } -} - -int __unorddf2(fp_t a, fp_t b) { - const rep_t aAbs = toRep(a) & absMask; - const rep_t bAbs = toRep(b) & absMask; - return aAbs > infRep || bAbs > infRep; -} - -// The following are alternative names for the preceeding routines. - -enum LE_RESULT __eqdf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} - -enum LE_RESULT __ltdf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} - -enum LE_RESULT __nedf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} - -enum GE_RESULT __gtdf2(fp_t a, fp_t b) { - return __gedf2(a, b); -} - Removed: compiler-rt/trunk/lib/comparesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparesf2.c?rev=128281&view=auto ============================================================================== --- compiler-rt/trunk/lib/comparesf2.c (original) +++ compiler-rt/trunk/lib/comparesf2.c (removed) @@ -1,131 +0,0 @@ -//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the following soft-fp_t comparison routines: -// -// __eqsf2 __gesf2 __unordsf2 -// __lesf2 __gtsf2 -// __ltsf2 -// __nesf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __lesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unordsf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT { - LE_LESS = -1, - LE_EQUAL = 0, - LE_GREATER = 1, - LE_UNORDERED = 1 -}; - -enum LE_RESULT __lesf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - // If either a or b is NaN, they are unordered. - if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; - - // If a and b are both zeros, they are equal. - if ((aAbs | bAbs) == 0) return LE_EQUAL; - - // If at least one of a and b is positive, we get the same result comparing - // a and b as signed integers as we would with a fp_ting-point compare. - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } - - // Otherwise, both are negative, so we need to flip the sense of the - // comparison to get the correct result. (This assumes a twos- or ones- - // complement integer representation; if integers are represented in a - // sign-magnitude representation, then this flip is incorrect). - else { - if (aInt > bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } -} - -enum GE_RESULT { - GE_LESS = -1, - GE_EQUAL = 0, - GE_GREATER = 1, - GE_UNORDERED = -1 // Note: different from LE_UNORDERED -}; - -enum GE_RESULT __gesf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; - if ((aAbs | bAbs) == 0) return GE_EQUAL; - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } else { - if (aInt > bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } -} - -int __unordsf2(fp_t a, fp_t b) { - const rep_t aAbs = toRep(a) & absMask; - const rep_t bAbs = toRep(b) & absMask; - return aAbs > infRep || bAbs > infRep; -} - -// The following are alternative names for the preceeding routines. - -enum LE_RESULT __eqsf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} - -enum LE_RESULT __ltsf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} - -enum LE_RESULT __nesf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} - -enum GE_RESULT __gtsf2(fp_t a, fp_t b) { - return __gesf2(a, b); -} Added: compiler-rt/trunk/lib/eqdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqdf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/eqdf2.c (added) +++ compiler-rt/trunk/lib/eqdf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/eqdf2.c - Double-precision comparisons -----------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __ledf2(fp_t a, fp_t b); +enum LE_RESULT __eqdf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} Added: compiler-rt/trunk/lib/eqsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqsf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/eqsf2.c (added) +++ compiler-rt/trunk/lib/eqsf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __lesf2(fp_t a, fp_t b); +enum LE_RESULT __eqsf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} Modified: compiler-rt/trunk/lib/fp_lib.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fp_lib.h?rev=128282&r1=128281&r2=128282&view=diff ============================================================================== --- compiler-rt/trunk/lib/fp_lib.h (original) +++ compiler-rt/trunk/lib/fp_lib.h Fri Mar 25 10:52:51 2011 @@ -25,6 +25,20 @@ #include #include +// Result enumerations used in comparison routines. +enum LE_RESULT { + LE_LESS = -1, + LE_EQUAL = 0, + LE_GREATER = 1, + LE_UNORDERED = 1 +}; +enum GE_RESULT { + GE_LESS = -1, + GE_EQUAL = 0, + GE_GREATER = 1, + GE_UNORDERED = -1 // Note: different from LE_UNORDERED +}; + #if defined SINGLE_PRECISION typedef uint32_t rep_t; Added: compiler-rt/trunk/lib/gedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gedf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/gedf2.c (added) +++ compiler-rt/trunk/lib/gedf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,61 @@ +//===-- lib/gedf2.c - Double-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the following soft-float comparison routines: +// +// __eqdf2 __gedf2 __unorddf2 +// __ledf2 __gtdf2 +// __ltdf2 +// __nedf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __ledf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gedf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unorddf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum GE_RESULT __gedf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; + if ((aAbs | bAbs) == 0) return GE_EQUAL; + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } else { + if (aInt > bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } +} Added: compiler-rt/trunk/lib/gesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gesf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/gesf2.c (added) +++ compiler-rt/trunk/lib/gesf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,61 @@ +//===-- lib/gesf2.c - Single-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the following soft-fp_t comparison routines: +// +// __eqsf2 __gesf2 __unordsf2 +// __lesf2 __gtsf2 +// __ltsf2 +// __nesf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __lesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unordsf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum GE_RESULT __gesf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; + if ((aAbs | bAbs) == 0) return GE_EQUAL; + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } else { + if (aInt > bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } +} Added: compiler-rt/trunk/lib/gtdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtdf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/gtdf2.c (added) +++ compiler-rt/trunk/lib/gtdf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,17 @@ +//===-- lib/gtdf2.c - Double-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum GE_RESULT __gedf2(fp_t a, fp_t b); +enum GE_RESULT __gtdf2(fp_t a, fp_t b) { + return __gedf2(a, b); +} + Added: compiler-rt/trunk/lib/gtsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtsf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/gtsf2.c (added) +++ compiler-rt/trunk/lib/gtsf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/gtsf2.c - Single-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum GE_RESULT __gesf2(fp_t a, fp_t b); +enum GE_RESULT __gtsf2(fp_t a, fp_t b) { + return __gesf2(a, b); +} Added: compiler-rt/trunk/lib/ledf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ledf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/ledf2.c (added) +++ compiler-rt/trunk/lib/ledf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,73 @@ +//===-- lib/ledf2.c - Double-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// // This file implements the following soft-float comparison routines: +// +// __eqdf2 __gedf2 __unorddf2 +// __ledf2 __gtdf2 +// __ltdf2 +// __nedf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __ledf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gedf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unorddf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __ledf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + // If either a or b is NaN, they are unordered. + if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; + + // If a and b are both zeros, they are equal. + if ((aAbs | bAbs) == 0) return LE_EQUAL; + + // If at least one of a and b is positive, we get the same result comparing + // a and b as signed integers as we would with a floating-point compare. + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } + + // Otherwise, both are negative, so we need to flip the sense of the + // comparison to get the correct result. (This assumes a twos- or ones- + // complement integer representation; if integers are represented in a + // sign-magnitude representation, then this flip is incorrect). + else { + if (aInt > bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } +} Added: compiler-rt/trunk/lib/lesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lesf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/lesf2.c (added) +++ compiler-rt/trunk/lib/lesf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,73 @@ +//===-- lib/lesf2.c - Single-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the following soft-fp_t comparison routines: +// +// __eqsf2 __gesf2 __unordsf2 +// __lesf2 __gtsf2 +// __ltsf2 +// __nesf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __lesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unordsf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __lesf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + // If either a or b is NaN, they are unordered. + if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; + + // If a and b are both zeros, they are equal. + if ((aAbs | bAbs) == 0) return LE_EQUAL; + + // If at least one of a and b is positive, we get the same result comparing + // a and b as signed integers as we would with a fp_ting-point compare. + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } + + // Otherwise, both are negative, so we need to flip the sense of the + // comparison to get the correct result. (This assumes a twos- or ones- + // complement integer representation; if integers are represented in a + // sign-magnitude representation, then this flip is incorrect). + else { + if (aInt > bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } +} Added: compiler-rt/trunk/lib/ltdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltdf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/ltdf2.c (added) +++ compiler-rt/trunk/lib/ltdf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/ltdf2.c - Double-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __ledf2(fp_t a, fp_t b); +enum LE_RESULT __ltdf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} Added: compiler-rt/trunk/lib/ltsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltsf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/ltsf2.c (added) +++ compiler-rt/trunk/lib/ltsf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __lesf2(fp_t a, fp_t b); +enum LE_RESULT __ltsf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} Added: compiler-rt/trunk/lib/nedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nedf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/nedf2.c (added) +++ compiler-rt/trunk/lib/nedf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,17 @@ +//===-- lib/nedf2.c - Double-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __ledf2(fp_t a, fp_t b); +enum LE_RESULT __nedf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} + Added: compiler-rt/trunk/lib/nesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nesf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/nesf2.c (added) +++ compiler-rt/trunk/lib/nesf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,16 @@ +//===-- lib/nesf2.c - Single-precision comparisons ----------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT __lesf2(fp_t a, fp_t b); +enum LE_RESULT __nesf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} Added: compiler-rt/trunk/lib/unorddf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unorddf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/unorddf2.c (added) +++ compiler-rt/trunk/lib/unorddf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,47 @@ +//===-- lib/unorddf2.c - Double-precision comparisons -------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// // This file implements the following soft-float comparison routines: +// +// __eqdf2 __gedf2 __unorddf2 +// __ledf2 __gtdf2 +// __ltdf2 +// __nedf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __ledf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gedf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unorddf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +int __unorddf2(fp_t a, fp_t b) { + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + return aAbs > infRep || bAbs > infRep; +} Added: compiler-rt/trunk/lib/unordsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unordsf2.c?rev=128282&view=auto ============================================================================== --- compiler-rt/trunk/lib/unordsf2.c (added) +++ compiler-rt/trunk/lib/unordsf2.c Fri Mar 25 10:52:51 2011 @@ -0,0 +1,17 @@ +//===-- lib/unordsf2.c - Single-precision comparisons -------------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +int __unordsf2(fp_t a, fp_t b) { + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + return aAbs > infRep || bAbs > infRep; +} Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=128282&r1=128281&r2=128282&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Fri Mar 25 10:52:51 2011 @@ -223,8 +223,7 @@ CCKEXT_MISSING_FUNCTIONS := \ cmpdf2 cmpsf2 div0 \ ffssi2 \ - gtdf2 gtsf2 ltdf2 ltsf2 \ - udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ + udiv_w_sdiv bswapdi2 \ bswapsi2 \ gcc_bcmp \ do_global_dtors \ From jan_sjodin at yahoo.com Fri Mar 25 11:04:04 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Fri, 25 Mar 2011 09:04:04 -0700 (PDT) Subject: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. In-Reply-To: References: <504570.72198.qm@web55608.mail.re4.yahoo.com> Message-ID: <687867.19021.qm@web55607.mail.re4.yahoo.com> I found this discussion on llvm-dev: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-August/034104.html This shows that my patch is correct in the sense that it does emit an offset (dwarfdump complained about the type of the entry not being DW_FORM_data4), but my patch would theoretically not work for ELF since it requires an absolute label so that a relocation is created. The thing is that the absolute label vs. label difference is not limited to the stmt list, but is true for debug_abbrev, debug_pubnames etc. My patch relies like the other sections on this conversion (which is not an optimization at all, but actually ensures that a relocation will be created) in: AsmPrinterDwarf.cpp:194: // If the section in question will end up with an address of 0 anyway, we can // just emit an absolute reference to save a relocation. if (Section.isBaseAddressKnownZero()) { OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); return; } This code converts the difference into the direct reference needed in ELF. I do not know why there was a problem specifically with section_line back then, but apparently that was fixed since I could now disable the check: if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) and rely on the conversion later on. Like I mentioned earlier, what dwarfdump really complained about was the type of the entry. I could equally rewrite my patch like this: Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 128274) +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy) @@ -1925,7 +1925,7 @@ // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) - addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, + addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, Asm->GetTempSymbol("section_line")); else addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); The reason why gdb did not complain about this is probably that the type was ignored and everything worked since the data was correct. The question is what the proper cleanup should be. We could simply remove the doesDwarfUsesAbsoluteLabelForStmtList and make EmitSectionOffset decide if a label reference or a label difference should be emitted. The alternative would be to eliminate the conversion in EmitSectionOffset and expand doesDwarfUsesAbsoluteLabelForStmtList into something like doesDwarfUsesAbsoluteLabelForSections (I don't know if it is limited to certain sections), and change DwarfDebug to add labels and emit symbol values instead of just using EmitSectionOffset. I do not know what is best in this case, but having both mechanisms is not clean. - Jan ________________________________ From: Anton Korobeynikov To: Jan Sjodin Cc: llvm-commits at cs.uiuc.edu Sent: Tue, March 22, 2011 7:50:19 PM Subject: Re: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. Hi Jan > Ping! The patch looks ok for me, but could you please look into dwarf standard to check which behavior is per standard, Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From Renato.Golin at arm.com Fri Mar 25 11:52:04 2011 From: Renato.Golin at arm.com (Renato Golin) Date: Fri, 25 Mar 2011 16:52:04 +0000 Subject: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. In-Reply-To: <687867.19021.qm@web55607.mail.re4.yahoo.com> References: <504570.72198.qm@web55608.mail.re4.yahoo.com> , <687867.19021.qm@web55607.mail.re4.yahoo.com> Message-ID: Hey, this is exactly what my patch was doing! ;) http://llvm.org/bugs/show_bug.cgi?id=9493 but it was reverted since it broke Darwin, http://llvm.org/bugs/show_bug.cgi?id=9497 Your patch looks remarkably similar to mine, though maybe the change in yours is in the right place. ;) If you can make both bugs above pass, I'm happy with the patch. cheers, --renato ________________________________________ From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Jan Sjodin [jan_sjodin at yahoo.com] Sent: 25 March 2011 16:04 To: Anton Korobeynikov; Devang Patel Cc: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. I found this discussion on llvm-dev: http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-August/034104.html This shows that my patch is correct in the sense that it does emit an offset (dwarfdump complained about the type of the entry not being DW_FORM_data4), but my patch would theoretically not work for ELF since it requires an absolute label so that a relocation is created. The thing is that the absolute label vs. label difference is not limited to the stmt list, but is true for debug_abbrev, debug_pubnames etc. My patch relies like the other sections on this conversion (which is not an optimization at all, but actually ensures that a relocation will be created) in: AsmPrinterDwarf.cpp:194: // If the section in question will end up with an address of 0 anyway, we can // just emit an absolute reference to save a relocation. if (Section.isBaseAddressKnownZero()) { OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); return; } This code converts the difference into the direct reference needed in ELF. I do not know why there was a problem specifically with section_line back then, but apparently that was fixed since I could now disable the check: if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) and rely on the conversion later on. Like I mentioned earlier, what dwarfdump really complained about was the type of the entry. I could equally rewrite my patch like this: Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 128274) +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy) @@ -1925,7 +1925,7 @@ // DW_AT_stmt_list is a offset of line number information for this // compile unit in debug_line section. if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) - addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, + addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, Asm->GetTempSymbol("section_line")); else addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); The reason why gdb did not complain about this is probably that the type was ignored and everything worked since the data was correct. The question is what the proper cleanup should be. We could simply remove the doesDwarfUsesAbsoluteLabelForStmtList and make EmitSectionOffset decide if a label reference or a label difference should be emitted. The alternative would be to eliminate the conversion in EmitSectionOffset and expand doesDwarfUsesAbsoluteLabelForStmtList into something like doesDwarfUsesAbsoluteLabelForSections (I don't know if it is limited to certain sections), and change DwarfDebug to add labels and emit symbol values instead of just using EmitSectionOffset. I do not know what is best in this case, but having both mechanisms is not clean. - Jan ________________________________ From: Anton Korobeynikov To: Jan Sjodin Cc: llvm-commits at cs.uiuc.edu Sent: Tue, March 22, 2011 7:50:19 PM Subject: Re: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. Hi Jan > Ping! The patch looks ok for me, but could you please look into dwarf standard to check which behavior is per standard, Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From johnny.chen at apple.com Fri Mar 25 12:03:12 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 17:03:12 -0000 Subject: [llvm-commits] [llvm] r128283 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt Message-ID: <20110325170312.98B002A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 12:03:12 2011 New Revision: 128283 URL: http://llvm.org/viewvc/llvm-project?rev=128283&view=rev Log: Also need to handle invalid imod values for CPS2p. rdar://problem/9186136 Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128283&r1=128282&r2=128283&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Fri Mar 25 12:03:12 2011 @@ -2965,8 +2965,10 @@ // opcodes which match the same real instruction. This is needed since there's // no current handling of optional arguments. Fix here when a better handling // of optional arguments is implemented. - if (Opcode == ARM::CPS3p) { - // Let's reject impossible imod values by returning false. + if (Opcode == ARM::CPS3p) { // M = 1 + // Let's reject these impossible imod values by returning false: + // 1. (imod=0b01) + // // AsmPrinter cannot handle imod=0b00, plus (imod=0b00,M=1,iflags!=0) is an // invalid combination, so we just check for imod=0b00 here. if (slice(insn, 19, 18) == 0 || slice(insn, 19, 18) == 1) @@ -2977,13 +2979,18 @@ NumOpsAdded = 3; return true; } - if (Opcode == ARM::CPS2p) { + if (Opcode == ARM::CPS2p) { // mode = 0, M = 0 + // Let's reject these impossible imod values by returning false: + // 1. (imod=0b00,M=0) + // 2. (imod=0b01) + if (slice(insn, 19, 18) == 0 || slice(insn, 19, 18) == 1) + return false; MI.addOperand(MCOperand::CreateImm(slice(insn, 19, 18))); // imod MI.addOperand(MCOperand::CreateImm(slice(insn, 8, 6))); // iflags NumOpsAdded = 2; return true; } - if (Opcode == ARM::CPS1p) { + if (Opcode == ARM::CPS1p) { // imod = 0, iflags = 0, M = 1 MI.addOperand(MCOperand::CreateImm(slice(insn, 4, 0))); // mode NumOpsAdded = 1; return true; Added: llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt?rev=128283&view=auto ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt (added) +++ llvm/trunk/test/MC/Disassembler/ARM/invalid-CPS2p-arm.txt Fri Mar 25 12:03:12 2011 @@ -0,0 +1,4 @@ +# RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 |& grep {invalid instruction encoding} + +# invalid imod value (0b01) +0xc0 0x67 0x4 0xf1 From stoklund at 2pi.dk Fri Mar 25 12:20:59 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 25 Mar 2011 17:20:59 -0000 Subject: [llvm-commits] [llvm] r128284 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/CodeGen/X86/2010-05-26-DotDebugLoc.ll test/CodeGen/X86/dbg-value-range.ll test/CodeGen/X86/unknown-location.ll Message-ID: <20110325172059.3C3742A6C12C@llvm.org> Author: stoklund Date: Fri Mar 25 12:20:59 2011 New Revision: 128284 URL: http://llvm.org/viewvc/llvm-project?rev=128284&view=rev Log: Emit less labels for debug info and stop emitting .loc directives for DBG_VALUEs. The .dot directives don't need labels, that is a leftover from when we created line number info manually. Instructions following a DBG_VALUE can share its label since the DBG_VALUE doesn't produce any code. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll llvm/trunk/test/CodeGen/X86/dbg-value-range.ll llvm/trunk/test/CodeGen/X86/unknown-location.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128284&r1=128283&r2=128284&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Mar 25 12:20:59 2011 @@ -2538,47 +2538,46 @@ /// beginInstruction - Process beginning of an instruction. void DwarfDebug::beginInstruction(const MachineInstr *MI) { - if (InsnNeedsLabel.count(MI) == 0) { - LabelsBeforeInsn[MI] = PrevLabel; - return; + // Check if source location changes, but ignore DBG_VALUE locations. + if (!MI->isDebugValue()) { + DebugLoc DL = MI->getDebugLoc(); + if (DL != PrevInstLoc && (!DL.isUnknown() || UnknownLocations)) { + PrevInstLoc = DL; + if (!DL.isUnknown()) { + const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); + recordSourceLine(DL.getLine(), DL.getCol(), Scope); + } else + recordSourceLine(0, 0, 0); + } } - // Check location. - DebugLoc DL = MI->getDebugLoc(); - if (!DL.isUnknown()) { - const MDNode *Scope = DL.getScope(Asm->MF->getFunction()->getContext()); - PrevLabel = recordSourceLine(DL.getLine(), DL.getCol(), Scope); - PrevInstLoc = DL; - LabelsBeforeInsn[MI] = PrevLabel; + // Insert labels where requested. + if (!InsnNeedsLabel.count(MI)) return; - } - // If location is unknown then use temp label for this DBG_VALUE - // instruction. - if (MI->isDebugValue()) { + if (!PrevLabel) { PrevLabel = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(PrevLabel); - LabelsBeforeInsn[MI] = PrevLabel; - return; } - - if (UnknownLocations) { - PrevLabel = recordSourceLine(0, 0, 0); - LabelsBeforeInsn[MI] = PrevLabel; - return; - } - - assert (0 && "Instruction is not processed!"); + LabelsBeforeInsn[MI] = PrevLabel; } /// endInstruction - Process end of an instruction. void DwarfDebug::endInstruction(const MachineInstr *MI) { - if (InsnsNeedsLabelAfter.count(MI) != 0) { - // Emit a label if this instruction ends a scope. - MCSymbol *Label = MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(Label); - LabelsAfterInsn[MI] = Label; + // Don't create a new label after DBG_VALUE instructions. + // They don't generate code. + if (!MI->isDebugValue()) + PrevLabel = 0; + + if (!InsnsNeedsLabelAfter.count(MI)) + return; + + // We need a label after this instruction. + if (!PrevLabel) { + PrevLabel = MMI->getContext().CreateTempSymbol(); + Asm->OutStreamer.EmitLabel(PrevLabel); } + LabelsAfterInsn[MI] = PrevLabel; } /// getOrCreateDbgScope - Create DbgScope for the scope. @@ -2838,6 +2837,7 @@ RE = Ranges.end(); RI != RE; ++RI) { assert(RI->first && "DbgRange does not have first instruction!"); assert(RI->second && "DbgRange does not have second instruction!"); + InsnNeedsLabel.insert(RI->first); InsnsNeedsLabelAfter.insert(RI->second); } } @@ -2927,7 +2927,6 @@ /// LiveUserVar - Map physreg numbers to the MDNode they contain. std::vector LiveUserVar(TRI->getNumRegs()); - DebugLoc PrevLoc; for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E; ++I) for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); @@ -2957,15 +2956,6 @@ else if (!ProcessedArgs.insert(DV)) InsnNeedsLabel.insert(MI); } else { - // If location is unknown then instruction needs a location only if - // UnknownLocations flag is set. - if (DL.isUnknown()) { - if (UnknownLocations && !PrevLoc.isUnknown()) - InsnNeedsLabel.insert(MI); - } else if (DL != PrevLoc) - // Otherwise, instruction needs a location only if it is new location. - InsnNeedsLabel.insert(MI); - // Check if the instruction clobbers any registers with debug vars. for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), MOE = MI->operands_end(); MOI != MOE; ++MOI) { @@ -2992,11 +2982,9 @@ } } } - - if (!DL.isUnknown() || UnknownLocations) - PrevLoc = DL; } + PrevInstLoc = DebugLoc(); PrevLabel = FunctionBeginSym; } @@ -3112,8 +3100,7 @@ /// recordSourceLine - Register a source line with debug info. Returns the /// unique label that was emitted and which provides correspondence to /// the source line list. -MCSymbol *DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, - const MDNode *S) { +void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S){ StringRef Fn; StringRef Dir; unsigned Src = 1; @@ -3144,10 +3131,6 @@ Asm->OutStreamer.EmitDwarfLocDirective(Src, Line, Col, DWARF2_FLAG_IS_STMT, 0, 0); - - MCSymbol *Label = MMI->getContext().CreateTempSymbol(); - Asm->OutStreamer.EmitLabel(Label); - return Label; } //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128284&r1=128283&r2=128284&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Mar 25 12:20:59 2011 @@ -536,7 +536,7 @@ /// recordSourceLine - Register a source line with debug info. Returns the /// unique label that was emitted and which provides correspondence to /// the source line list. - MCSymbol *recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope); + void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope); /// recordVariableFrameIndex - Record a variable's index. void recordVariableFrameIndex(const DbgVariable *V, int Index); Modified: llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll?rev=128284&r1=128283&r2=128284&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-05-26-DotDebugLoc.ll Fri Mar 25 12:20:59 2011 @@ -55,12 +55,21 @@ !29 = metadata !{i32 524299, metadata !9, i32 17, i32 0} ; [ DW_TAG_lexical_block ] !30 = metadata !{i32 19, i32 0, metadata !29, null} +; The variable bar:myvar changes registers after the first movq. +; It is cobbered by popq %rbx +; CHECK: movq +; CHECK-NEXT: [[LABEL:Ltmp[0-9]*]] +; CHECK: .loc 1 19 0 +; CHECK: popq +; CHECK-NEXT: [[CLOBBER:Ltmp[0-9]*]] + + ; CHECK: Ldebug_loc0: ; CHECK-NEXT: .quad Lfunc_begin0 -; CHECK-NEXT: .quad Ltmp3 +; CHECK-NEXT: .quad [[LABEL]] ; CHECK-NEXT: .short 1 ; CHECK-NEXT: .byte 85 -; CHECK-NEXT: .quad Ltmp3 -; CHECK-NEXT: .quad Ltmp6 +; CHECK-NEXT: .quad [[LABEL]] +; CHECK-NEXT: .quad [[CLOBBER]] ; CHECK-NEXT: .short 1 ; CHECK-NEXT: .byte 83 Modified: llvm/trunk/test/CodeGen/X86/dbg-value-range.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-value-range.ll?rev=128284&r1=128283&r2=128284&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-value-range.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-value-range.ll Fri Mar 25 12:20:59 2011 @@ -45,13 +45,13 @@ ; The variable is in %rdi which is clobbered by 'movl %ebx, %edi' ; Here Ltmp7 is the end of the location range. -;CHECK:Ltmp6 -;CHECK-NEXT: movl -;CHECK-NEXT: Ltmp7 +;CHECK: .loc 1 7 2 +;CHECK: movl +;CHECK-NEXT: [[CLOBBER:Ltmp[0-9]*]] ;CHECK:Ldebug_loc0: -;CHECK-NEXT: .quad Ltmp -;CHECK-NEXT: .quad Ltmp7 +;CHECK-NEXT: .quad +;CHECK-NEXT: .quad [[CLOBBER]] ;CHECK-NEXT: .short 1 ;CHECK-NEXT: .byte 85 ;CHECK-NEXT: .quad 0 Modified: llvm/trunk/test/CodeGen/X86/unknown-location.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/unknown-location.ll?rev=128284&r1=128283&r2=128284&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/unknown-location.ll (original) +++ llvm/trunk/test/CodeGen/X86/unknown-location.ll Fri Mar 25 12:20:59 2011 @@ -4,16 +4,11 @@ ; represent this in the debug information. This is done by setting line ; and column to 0 -; CHECK: leal (%rdi,%rsi), %eax +; CHECK: leal ; CHECK-NEXT: .loc 1 0 0 -; CHECK-NEXT: Ltmp -; CHECK-NEXT: cltd -; CHECK-NEXT: idivl %r8d +; CHECK: cltd +; CHECK-NEXT: idivl ; CHECK-NEXT: .loc 2 4 3 -; CHECK-NEXT: Ltmp -; CHECK-NEXT: addl %ecx, %eax -; CHECK-NEXT: ret -; CHECK-NEXT: Ltmp define i32 @foo(i32 %w, i32 %x, i32 %y, i32 %z) nounwind { entry: From johnny.chen at apple.com Fri Mar 25 12:31:16 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 17:31:16 -0000 Subject: [llvm-commits] [llvm] r128285 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110325173116.E31C12A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 12:31:16 2011 New Revision: 128285 URL: http://llvm.org/viewvc/llvm-project?rev=128285&view=rev Log: Instruction formats of SWP/SWPB were changed from LdStExFrm to MiscFrm. Modify the disassembler to handle that. rdar://problem/9184053 Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=128285&r1=128284&r2=128285&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Fri Mar 25 12:31:16 2011 @@ -2951,6 +2951,11 @@ case ARM::WFI: case ARM::SEV: return true; + case ARM::SWP: + case ARM::SWPB: + // SWP, SWPB: Rd Rm Rn + // Delegate to DisassembleLdStExFrm().... + return DisassembleLdStExFrm(MI, Opcode, insn, NumOps, NumOpsAdded, B); default: break; } Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128285&r1=128284&r2=128285&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Fri Mar 25 12:31:16 2011 @@ -184,3 +184,6 @@ # CHECK: ldmdb sp, {r0, r4, r8, r11, r12, pc} 0x11 0x99 0x1d 0xe9 + +# CHECK: swpge r3, r2, [r6] +0x92 0x30 0x06 0xa1 From benny.kra at googlemail.com Fri Mar 25 12:32:40 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 25 Mar 2011 17:32:40 -0000 Subject: [llvm-commits] [llvm] r128286 - /llvm/trunk/lib/Target/README.txt Message-ID: <20110325173240.A04B42A6C12C@llvm.org> Author: d0k Date: Fri Mar 25 12:32:40 2011 New Revision: 128286 URL: http://llvm.org/viewvc/llvm-project?rev=128286&view=rev Log: Add a note. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=128286&r1=128285&r2=128286&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Fri Mar 25 12:32:40 2011 @@ -2238,4 +2238,23 @@ //===---------------------------------------------------------------------===// +define i1 @test1(i32 %x) nounwind { + %and = and i32 %x, 3 + %cmp = icmp ult i32 %and, 2 + ret i1 %cmp +} +Can be folded to (x & 2) == 0. + +define i1 @test2(i32 %x) nounwind { + %and = and i32 %x, 3 + %cmp = icmp ugt i32 %and, 1 + ret i1 %cmp +} + +Can be folded to (x & 2) != 0. + +SimplifyDemandedBits shrinks the "and" constant to 2 but instcombine misses the +icmp transform. + +//===---------------------------------------------------------------------===// From daniel at zuster.org Fri Mar 25 12:47:14 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 25 Mar 2011 17:47:14 -0000 Subject: [llvm-commits] [llvm] r128288 - /llvm/trunk/lib/MC/MCParser/AsmParser.cpp Message-ID: <20110325174714.8C97A2A6C12C@llvm.org> Author: ddunbar Date: Fri Mar 25 12:47:14 2011 New Revision: 128288 URL: http://llvm.org/viewvc/llvm-project?rev=128288&view=rev Log: Tidyness. Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=128288&r1=128287&r2=128288&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Mar 25 12:47:14 2011 @@ -880,6 +880,7 @@ EatToEndOfStatement(); return false; } + // Allow an integer followed by a ':' as a directional local label. if (Lexer.is(AsmToken::Integer)) { LocalLabelVal = getTok().getIntVal(); @@ -896,8 +897,7 @@ return TokError("unexpected token at start of statement"); } } - } - else if (ParseIdentifier(IDVal)) { + } else if (ParseIdentifier(IDVal)) { if (!TheCondState.Ignore) return TokError("unexpected token at start of statement"); IDVal = ""; From daniel at zuster.org Fri Mar 25 12:47:18 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 25 Mar 2011 17:47:18 -0000 Subject: [llvm-commits] [llvm] r128289 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/dot-symbol.s Message-ID: <20110325174718.2C29B2A6C12D@llvm.org> Author: ddunbar Date: Fri Mar 25 12:47:17 2011 New Revision: 128289 URL: http://llvm.org/viewvc/llvm-project?rev=128289&view=rev Log: MC: Improve some diagnostics on uses of '.' pseudo-symbol. Added: llvm/trunk/test/MC/AsmParser/dot-symbol.s Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=128289&r1=128288&r2=128289&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Mar 25 12:47:17 2011 @@ -897,12 +897,19 @@ return TokError("unexpected token at start of statement"); } } + + } else if (Lexer.is(AsmToken::Dot)) { + // Treat '.' as a valid identifier in this context. + Lex(); + IDVal = "."; + } else if (ParseIdentifier(IDVal)) { if (!TheCondState.Ignore) return TokError("unexpected token at start of statement"); IDVal = ""; } + // Handle conditional assembly here before checking for skipping. We // have to do this so that .endif isn't skipped in a ".if 0" block for // example. @@ -935,6 +942,10 @@ // identifier ':' -> Label. Lex(); + // Diagnose attempt to use '.' as a label. + if (IDVal == ".") + return Error(IDLoc, "invalid use of pseudo-symbol '.' as a label"); + // Diagnose attempt to use a variable as a label. // // FIXME: Diagnostics. Note the location of the definition as a label. @@ -978,7 +989,7 @@ return HandleMacroEntry(IDVal, IDLoc, M); // Otherwise, we have a normal instruction or directive. - if (IDVal[0] == '.') { + if (IDVal[0] == '.' && IDVal != ".") { // Assembler features if (IDVal == ".set" || IDVal == ".equ") return ParseDirectiveSet(IDVal, true); @@ -1306,6 +1317,12 @@ if (Lexer.isNot(AsmToken::EndOfStatement)) return TokError("unexpected token in assignment"); + // Error on assignment to '.'. + if (Name == ".") { + return Error(EqualLoc, ("assignment to pseudo-symbol '.' is unsupported " + "(use '.space' or '.org').)")); + } + // Eat the end of statement marker. Lex(); Added: llvm/trunk/test/MC/AsmParser/dot-symbol.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/dot-symbol.s?rev=128289&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/dot-symbol.s (added) +++ llvm/trunk/test/MC/AsmParser/dot-symbol.s Fri Mar 25 12:47:17 2011 @@ -0,0 +1,12 @@ +# Historically 'as' treats '.' as a reference to the current location in +# arbitrary contects. We don't support this in general. + +# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t +# RUN: FileCheck -input-file %t %s + +# CHECK: assignment to pseudo-symbol '.' is unsupported (use '.space' or '.org'). +. = . + 8 + +# CHECK: invalid use of pseudo-symbol '.' as a label +.: + .long 0 From jan_sjodin at yahoo.com Fri Mar 25 13:23:50 2011 From: jan_sjodin at yahoo.com (Jan Sjodin) Date: Fri, 25 Mar 2011 11:23:50 -0700 (PDT) Subject: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false for X86ELFMCAsmInfo. In-Reply-To: References: <504570.72198.qm@web55608.mail.re4.yahoo.com> , <687867.19021.qm@web55607.mail.re4.yahoo.com> Message-ID: <201822.31535.qm@web55606.mail.re4.yahoo.com> I setting DwarfUsesAbsoluteLabelForStmtList = false would not fix this bug, since we are using EmitLabelDifference directly, but it can be made to work. I see two potential ways of fixing it: 1. Set DwarfUsesAbsoluteLabelForStmtList = false and use EmitSectionOffset: Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 127576) +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy) @@ -3272,7 +3272,9 @@ case dwarf::DW_AT_location: { if (UseDotDebugLocEntry.count(Die) != 0) { DIELabel *L = cast(Values[i]); - Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4); + // Emitting section offset, so the assembler can decide on + // reference to label directly, or a label difference. + Asm->EmitSectionOffset(L->getValue(), DwarfDebugLocSectionSym); } else Values[i]->EmitValue(Asm, Form); break; 2. Set DwarfUsesAbsoluteLabelForStmtList = true and do the check here. Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 127576) +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy) @@ -3272,7 +3272,13 @@ case dwarf::DW_AT_location: { if (UseDotDebugLocEntry.count(Die) != 0) { DIELabel *L = cast(Values[i]); - Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4); + if(Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) { + // Emitting reference to label directly, so the assembler can + // emit the relocations and the offset automatically. + Asm->EmitReference(L->getValue(), dwarf::DW_EH_PE_udata4); + } else { + Asm->EmitLabelDifference(L->getValue(), DwarfDebugLocSectionSym, 4); + } } else Values[i]->EmitValue(Asm, Form); break; Using doesDwarfUsesAbsoluteLabelForStmtList in this context highlights the issue of the naming of both the method (too specific) and of the DwarfUsesAbsoluteLabelForStmtList flag in the previous solution. Especially the flag is confusing, since the name contradicts what actually happens. Setting it to false will actually have the opposite effect for ELF if EmitSectionOffset is used. :) - Jan ----- Original Message ---- > From: Renato Golin > To: Jan Sjodin ; Anton Korobeynikov >; Devang Patel > Cc: "llvm-commits at cs.uiuc.edu" > Sent: Fri, March 25, 2011 12:52:04 PM > Subject: RE: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false >for X86ELFMCAsmInfo. > > > Hey, this is exactly what my patch was doing! ;) > > http://llvm.org/bugs/show_bug.cgi?id=9493 > > but it was reverted since it broke Darwin, > > http://llvm.org/bugs/show_bug.cgi?id=9497 > > > Your patch looks remarkably similar to mine, though maybe the change in yours >is in the right place. ;) > > If you can make both bugs above pass, I'm happy with the patch. > > cheers, > --renato > > ________________________________________ > From: llvm-commits-bounces at cs.uiuc.edu [llvm-commits-bounces at cs.uiuc.edu] On >Behalf Of Jan Sjodin [jan_sjodin at yahoo.com] > Sent: 25 March 2011 16:04 > To: Anton Korobeynikov; Devang Patel > Cc: llvm-commits at cs.uiuc.edu > Subject: Re: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false >for X86ELFMCAsmInfo. > > I found this discussion on llvm-dev: > http://lists.cs.uiuc.edu/pipermail/llvmdev/2010-August/034104.html > > This shows that my patch is correct in the sense that it does emit an offset > (dwarfdump complained about the type of the entry not being DW_FORM_data4), >but > my patch would theoretically not work for ELF since it requires an absolute > label so that a relocation is created. The thing is that the absolute label >vs. > label difference is not limited to the stmt list, but is true for >debug_abbrev, > debug_pubnames etc. My patch relies like the other sections on this conversion > (which is not an optimization at all, but actually ensures that a relocation > will be created) in: > > AsmPrinterDwarf.cpp:194: > // If the section in question will end up with an address of 0 anyway, we >can > // just emit an absolute reference to save a relocation. > if (Section.isBaseAddressKnownZero()) { > OutStreamer.EmitSymbolValue(Label, 4, 0/*AddrSpace*/); > return; > } > > This code converts the difference into the direct reference needed in ELF. I >do > not know why there was a problem specifically with section_line back then, but > apparently that was fixed since I could now disable the check: if > (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) and rely on the conversion > later on. Like I mentioned earlier, what dwarfdump really complained about was > the type of the entry. I could equally rewrite my patch like this: > Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp > =================================================================== > --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp (revision 128274) > +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp (working copy) > @@ -1925,7 +1925,7 @@ > // DW_AT_stmt_list is a offset of line number information for this > // compile unit in debug_line section. > if (Asm->MAI->doesDwarfUsesAbsoluteLabelForStmtList()) > - addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_addr, > + addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, > Asm->GetTempSymbol("section_line")); > else > addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); > > The reason why gdb did not complain about this is probably that the type was > ignored and everything worked since the data was correct. > > The question is what the proper cleanup should be. We could simply remove the > doesDwarfUsesAbsoluteLabelForStmtList and make EmitSectionOffset decide if a > label reference or a label difference should be emitted. The alternative would > be to eliminate the conversion in EmitSectionOffset and expand > doesDwarfUsesAbsoluteLabelForStmtList into something like > doesDwarfUsesAbsoluteLabelForSections (I don't know if it is limited to >certain > sections), and change DwarfDebug to add labels and emit symbol values instead >of > just using EmitSectionOffset. I do not know what is best in this case, but > having both mechanisms is not clean. > > - Jan > > ________________________________ > From: Anton Korobeynikov > To: Jan Sjodin > Cc: llvm-commits at cs.uiuc.edu > Sent: Tue, March 22, 2011 7:50:19 PM > Subject: Re: [llvm-commits] Change DwarfUsesAbsoluteLabelForStmtList to false > for X86ELFMCAsmInfo. > > Hi Jan > > > Ping! > The patch looks ok for me, but could you please look into dwarf > standard to check which behavior is per standard, > > Thanks! > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > -- IMPORTANT NOTICE: The contents of this email and any attachments are >confidential and may also be privileged. If you are not the intended recipient, >please notify the sender immediately and do not disclose the contents to any >other person, use it for any purpose, or store or copy the information in any >medium. Thank you. > > From johnny.chen at apple.com Fri Mar 25 13:29:49 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 18:29:49 -0000 Subject: [llvm-commits] [llvm] r128293 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325182949.A76652A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 13:29:49 2011 New Revision: 128293 URL: http://llvm.org/viewvc/llvm-project?rev=128293&view=rev Log: Modify DisassembleThumb2LdStEx() to be more robust/correct in light of recent change to t2LDREX/t2STREX instructions. Add two test cases. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128293&r1=128292&r2=128293&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Mar 25 13:29:49 2011 @@ -1194,8 +1194,8 @@ OpIdx = 0; assert(NumOps >= 2 - && OpInfo[0].RegClass == ARM::GPRRegClassID - && OpInfo[1].RegClass == ARM::GPRRegClassID + && OpInfo[0].RegClass > 0 + && OpInfo[1].RegClass > 0 && "Expect >=2 operands and first two as reg operands"); bool isStore = (ARM::t2STREX <= Opcode && Opcode <= ARM::t2STREXH); @@ -1205,25 +1205,25 @@ // Add the destination operand for store. if (isStore) { MI.addOperand(MCOperand::CreateReg( - getRegisterEnum(B, ARM::GPRRegClassID, + getRegisterEnum(B, OpInfo[OpIdx].RegClass, isSW ? decodeRs(insn) : decodeRm(insn)))); ++OpIdx; } // Source operand for store and destination operand for load. - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass, decodeRd(insn)))); ++OpIdx; // Thumb2 doubleword complication: with an extra source/destination operand. if (isDW) { - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B,OpInfo[OpIdx].RegClass, decodeRs(insn)))); ++OpIdx; } // Finally add the pointer operand. - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass, decodeRn(insn)))); ++OpIdx; Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128293&r1=128292&r2=128293&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 13:29:49 2011 @@ -154,3 +154,9 @@ # CHECK: ldrd r3, r8, [r11, #-60] 0x5b 0xe9 0x0f 0x38 + +# CHECK: ldrex r8, [r2] +0x52 0xe8 0x00 0x8f + +# CHECK: strexd r1, r7, r8, [r2] +0xc2 0xe8 0x71 0x78 From isanbard at gmail.com Fri Mar 25 13:36:39 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 25 Mar 2011 18:36:39 -0000 Subject: [llvm-commits] [test-suite] r128294 - in /test-suite/branches/release_29: ./ MultiSource/Applications/lemon/Makefile Message-ID: <20110325183639.1C3D22A6C12C@llvm.org> Author: void Date: Fri Mar 25 13:36:38 2011 New Revision: 128294 URL: http://llvm.org/viewvc/llvm-project?rev=128294&view=rev Log: This timeout was not enough on some machines. --- Merging r128270 into '.': U MultiSource/Applications/lemon/Makefile Modified: test-suite/branches/release_29/ (props changed) test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile Propchange: test-suite/branches/release_29/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Fri Mar 25 13:36:38 2011 @@ -1 +1 @@ -/test-suite/trunk:128083 +/test-suite/trunk:128083,128270 Modified: test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile?rev=128294&r1=128293&r2=128294&view=diff ============================================================================== --- test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile (original) +++ test-suite/branches/release_29/MultiSource/Applications/lemon/Makefile Fri Mar 25 13:36:38 2011 @@ -7,7 +7,7 @@ HASH_PROGRAM_OUTPUT = 1 # With a Debug+Asserts build may time out if the default limit is used. -RUNTIMELIMIT := 750 +RUNTIMELIMIT := 1500 include $(LEVEL)/Makefile.config From johnny.chen at apple.com Fri Mar 25 13:40:21 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 18:40:21 -0000 Subject: [llvm-commits] [llvm] r128295 - /llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325184021.631222A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 13:40:21 2011 New Revision: 128295 URL: http://llvm.org/viewvc/llvm-project?rev=128295&view=rev Log: A8.6.226 TBB, TBH: Add two test cases. Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128295&r1=128294&r2=128295&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 13:40:21 2011 @@ -160,3 +160,9 @@ # CHECK: strexd r1, r7, r8, [r2] 0xc2 0xe8 0x71 0x78 + +# CHECK: tbh [r5, r4, lsl #1] +0xd5 0xe8 0x14 0xf0 + +# CHECK: tbb [r5, r4] +0xd5 0xe8 0x04 0xf0 From daniel at zuster.org Fri Mar 25 13:45:40 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 25 Mar 2011 18:45:40 -0000 Subject: [llvm-commits] [compiler-rt] r128296 - in /compiler-rt/trunk: lib/comparedf2.c lib/comparesf2.c lib/eqdf2.c lib/eqsf2.c lib/fp_lib.h lib/gedf2.c lib/gesf2.c lib/gtdf2.c lib/gtsf2.c lib/ledf2.c lib/lesf2.c lib/ltdf2.c lib/ltsf2.c lib/nedf2.c lib/nesf2.c lib/unorddf2.c lib/unordsf2.c make/platform/clang_darwin.mk Message-ID: <20110325184540.3D1F32A6C12C@llvm.org> Author: ddunbar Date: Fri Mar 25 13:45:39 2011 New Revision: 128296 URL: http://llvm.org/viewvc/llvm-project?rev=128296&view=rev Log: Revert "Split single & double comparison routines into separate implementation files," for now, I missed some necesary updates. Added: compiler-rt/trunk/lib/comparedf2.c compiler-rt/trunk/lib/comparesf2.c Removed: compiler-rt/trunk/lib/eqdf2.c compiler-rt/trunk/lib/eqsf2.c compiler-rt/trunk/lib/gedf2.c compiler-rt/trunk/lib/gesf2.c compiler-rt/trunk/lib/gtdf2.c compiler-rt/trunk/lib/gtsf2.c compiler-rt/trunk/lib/ledf2.c compiler-rt/trunk/lib/lesf2.c compiler-rt/trunk/lib/ltdf2.c compiler-rt/trunk/lib/ltsf2.c compiler-rt/trunk/lib/nedf2.c compiler-rt/trunk/lib/nesf2.c compiler-rt/trunk/lib/unorddf2.c compiler-rt/trunk/lib/unordsf2.c Modified: compiler-rt/trunk/lib/fp_lib.h compiler-rt/trunk/make/platform/clang_darwin.mk Added: compiler-rt/trunk/lib/comparedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparedf2.c?rev=128296&view=auto ============================================================================== --- compiler-rt/trunk/lib/comparedf2.c (added) +++ compiler-rt/trunk/lib/comparedf2.c Fri Mar 25 13:45:39 2011 @@ -0,0 +1,132 @@ +//===-- lib/comparedf2.c - Double-precision comparisons -----------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// // This file implements the following soft-float comparison routines: +// +// __eqdf2 __gedf2 __unorddf2 +// __ledf2 __gtdf2 +// __ltdf2 +// __nedf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __ledf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gedf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unorddf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define DOUBLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT { + LE_LESS = -1, + LE_EQUAL = 0, + LE_GREATER = 1, + LE_UNORDERED = 1 +}; + +enum LE_RESULT __ledf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + // If either a or b is NaN, they are unordered. + if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; + + // If a and b are both zeros, they are equal. + if ((aAbs | bAbs) == 0) return LE_EQUAL; + + // If at least one of a and b is positive, we get the same result comparing + // a and b as signed integers as we would with a floating-point compare. + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } + + // Otherwise, both are negative, so we need to flip the sense of the + // comparison to get the correct result. (This assumes a twos- or ones- + // complement integer representation; if integers are represented in a + // sign-magnitude representation, then this flip is incorrect). + else { + if (aInt > bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } +} + +enum GE_RESULT { + GE_LESS = -1, + GE_EQUAL = 0, + GE_GREATER = 1, + GE_UNORDERED = -1 // Note: different from LE_UNORDERED +}; + +enum GE_RESULT __gedf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; + if ((aAbs | bAbs) == 0) return GE_EQUAL; + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } else { + if (aInt > bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } +} + +int __unorddf2(fp_t a, fp_t b) { + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + return aAbs > infRep || bAbs > infRep; +} + +// The following are alternative names for the preceeding routines. + +enum LE_RESULT __eqdf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} + +enum LE_RESULT __ltdf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} + +enum LE_RESULT __nedf2(fp_t a, fp_t b) { + return __ledf2(a, b); +} + +enum GE_RESULT __gtdf2(fp_t a, fp_t b) { + return __gedf2(a, b); +} + Added: compiler-rt/trunk/lib/comparesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/comparesf2.c?rev=128296&view=auto ============================================================================== --- compiler-rt/trunk/lib/comparesf2.c (added) +++ compiler-rt/trunk/lib/comparesf2.c Fri Mar 25 13:45:39 2011 @@ -0,0 +1,131 @@ +//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the following soft-fp_t comparison routines: +// +// __eqsf2 __gesf2 __unordsf2 +// __lesf2 __gtsf2 +// __ltsf2 +// __nesf2 +// +// The semantics of the routines grouped in each column are identical, so there +// is a single implementation for each, and wrappers to provide the other names. +// +// The main routines behave as follows: +// +// __lesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// 1 if either a or b is NaN +// +// __gesf2(a,b) returns -1 if a < b +// 0 if a == b +// 1 if a > b +// -1 if either a or b is NaN +// +// __unordsf2(a,b) returns 0 if both a and b are numbers +// 1 if either a or b is NaN +// +// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of +// NaN values. +// +//===----------------------------------------------------------------------===// + +#define SINGLE_PRECISION +#include "fp_lib.h" + +enum LE_RESULT { + LE_LESS = -1, + LE_EQUAL = 0, + LE_GREATER = 1, + LE_UNORDERED = 1 +}; + +enum LE_RESULT __lesf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + // If either a or b is NaN, they are unordered. + if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; + + // If a and b are both zeros, they are equal. + if ((aAbs | bAbs) == 0) return LE_EQUAL; + + // If at least one of a and b is positive, we get the same result comparing + // a and b as signed integers as we would with a fp_ting-point compare. + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } + + // Otherwise, both are negative, so we need to flip the sense of the + // comparison to get the correct result. (This assumes a twos- or ones- + // complement integer representation; if integers are represented in a + // sign-magnitude representation, then this flip is incorrect). + else { + if (aInt > bInt) return LE_LESS; + else if (aInt == bInt) return LE_EQUAL; + else return LE_GREATER; + } +} + +enum GE_RESULT { + GE_LESS = -1, + GE_EQUAL = 0, + GE_GREATER = 1, + GE_UNORDERED = -1 // Note: different from LE_UNORDERED +}; + +enum GE_RESULT __gesf2(fp_t a, fp_t b) { + + const srep_t aInt = toRep(a); + const srep_t bInt = toRep(b); + const rep_t aAbs = aInt & absMask; + const rep_t bAbs = bInt & absMask; + + if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; + if ((aAbs | bAbs) == 0) return GE_EQUAL; + if ((aInt & bInt) >= 0) { + if (aInt < bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } else { + if (aInt > bInt) return GE_LESS; + else if (aInt == bInt) return GE_EQUAL; + else return GE_GREATER; + } +} + +int __unordsf2(fp_t a, fp_t b) { + const rep_t aAbs = toRep(a) & absMask; + const rep_t bAbs = toRep(b) & absMask; + return aAbs > infRep || bAbs > infRep; +} + +// The following are alternative names for the preceeding routines. + +enum LE_RESULT __eqsf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} + +enum LE_RESULT __ltsf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} + +enum LE_RESULT __nesf2(fp_t a, fp_t b) { + return __lesf2(a, b); +} + +enum GE_RESULT __gtsf2(fp_t a, fp_t b) { + return __gesf2(a, b); +} Removed: compiler-rt/trunk/lib/eqdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqdf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/eqdf2.c (original) +++ compiler-rt/trunk/lib/eqdf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/eqdf2.c - Double-precision comparisons -----------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __ledf2(fp_t a, fp_t b); -enum LE_RESULT __eqdf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} Removed: compiler-rt/trunk/lib/eqsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/eqsf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/eqsf2.c (original) +++ compiler-rt/trunk/lib/eqsf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __lesf2(fp_t a, fp_t b); -enum LE_RESULT __eqsf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} Modified: compiler-rt/trunk/lib/fp_lib.h URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fp_lib.h?rev=128296&r1=128295&r2=128296&view=diff ============================================================================== --- compiler-rt/trunk/lib/fp_lib.h (original) +++ compiler-rt/trunk/lib/fp_lib.h Fri Mar 25 13:45:39 2011 @@ -25,20 +25,6 @@ #include #include -// Result enumerations used in comparison routines. -enum LE_RESULT { - LE_LESS = -1, - LE_EQUAL = 0, - LE_GREATER = 1, - LE_UNORDERED = 1 -}; -enum GE_RESULT { - GE_LESS = -1, - GE_EQUAL = 0, - GE_GREATER = 1, - GE_UNORDERED = -1 // Note: different from LE_UNORDERED -}; - #if defined SINGLE_PRECISION typedef uint32_t rep_t; Removed: compiler-rt/trunk/lib/gedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gedf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/gedf2.c (original) +++ compiler-rt/trunk/lib/gedf2.c (removed) @@ -1,61 +0,0 @@ -//===-- lib/gedf2.c - Double-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the following soft-float comparison routines: -// -// __eqdf2 __gedf2 __unorddf2 -// __ledf2 __gtdf2 -// __ltdf2 -// __nedf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __ledf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gedf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unorddf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum GE_RESULT __gedf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; - if ((aAbs | bAbs) == 0) return GE_EQUAL; - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } else { - if (aInt > bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } -} Removed: compiler-rt/trunk/lib/gesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gesf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/gesf2.c (original) +++ compiler-rt/trunk/lib/gesf2.c (removed) @@ -1,61 +0,0 @@ -//===-- lib/gesf2.c - Single-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the following soft-fp_t comparison routines: -// -// __eqsf2 __gesf2 __unordsf2 -// __lesf2 __gtsf2 -// __ltsf2 -// __nesf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __lesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unordsf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum GE_RESULT __gesf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - if (aAbs > infRep || bAbs > infRep) return GE_UNORDERED; - if ((aAbs | bAbs) == 0) return GE_EQUAL; - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } else { - if (aInt > bInt) return GE_LESS; - else if (aInt == bInt) return GE_EQUAL; - else return GE_GREATER; - } -} Removed: compiler-rt/trunk/lib/gtdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtdf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/gtdf2.c (original) +++ compiler-rt/trunk/lib/gtdf2.c (removed) @@ -1,17 +0,0 @@ -//===-- lib/gtdf2.c - Double-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum GE_RESULT __gedf2(fp_t a, fp_t b); -enum GE_RESULT __gtdf2(fp_t a, fp_t b) { - return __gedf2(a, b); -} - Removed: compiler-rt/trunk/lib/gtsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/gtsf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/gtsf2.c (original) +++ compiler-rt/trunk/lib/gtsf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/gtsf2.c - Single-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum GE_RESULT __gesf2(fp_t a, fp_t b); -enum GE_RESULT __gtsf2(fp_t a, fp_t b) { - return __gesf2(a, b); -} Removed: compiler-rt/trunk/lib/ledf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ledf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/ledf2.c (original) +++ compiler-rt/trunk/lib/ledf2.c (removed) @@ -1,73 +0,0 @@ -//===-- lib/ledf2.c - Double-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// // This file implements the following soft-float comparison routines: -// -// __eqdf2 __gedf2 __unorddf2 -// __ledf2 __gtdf2 -// __ltdf2 -// __nedf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __ledf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gedf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unorddf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __ledf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - // If either a or b is NaN, they are unordered. - if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; - - // If a and b are both zeros, they are equal. - if ((aAbs | bAbs) == 0) return LE_EQUAL; - - // If at least one of a and b is positive, we get the same result comparing - // a and b as signed integers as we would with a floating-point compare. - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } - - // Otherwise, both are negative, so we need to flip the sense of the - // comparison to get the correct result. (This assumes a twos- or ones- - // complement integer representation; if integers are represented in a - // sign-magnitude representation, then this flip is incorrect). - else { - if (aInt > bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } -} Removed: compiler-rt/trunk/lib/lesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lesf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/lesf2.c (original) +++ compiler-rt/trunk/lib/lesf2.c (removed) @@ -1,73 +0,0 @@ -//===-- lib/lesf2.c - Single-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements the following soft-fp_t comparison routines: -// -// __eqsf2 __gesf2 __unordsf2 -// __lesf2 __gtsf2 -// __ltsf2 -// __nesf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __lesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gesf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unordsf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __lesf2( ) and __gesf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __lesf2(fp_t a, fp_t b) { - - const srep_t aInt = toRep(a); - const srep_t bInt = toRep(b); - const rep_t aAbs = aInt & absMask; - const rep_t bAbs = bInt & absMask; - - // If either a or b is NaN, they are unordered. - if (aAbs > infRep || bAbs > infRep) return LE_UNORDERED; - - // If a and b are both zeros, they are equal. - if ((aAbs | bAbs) == 0) return LE_EQUAL; - - // If at least one of a and b is positive, we get the same result comparing - // a and b as signed integers as we would with a fp_ting-point compare. - if ((aInt & bInt) >= 0) { - if (aInt < bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } - - // Otherwise, both are negative, so we need to flip the sense of the - // comparison to get the correct result. (This assumes a twos- or ones- - // complement integer representation; if integers are represented in a - // sign-magnitude representation, then this flip is incorrect). - else { - if (aInt > bInt) return LE_LESS; - else if (aInt == bInt) return LE_EQUAL; - else return LE_GREATER; - } -} Removed: compiler-rt/trunk/lib/ltdf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltdf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/ltdf2.c (original) +++ compiler-rt/trunk/lib/ltdf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/ltdf2.c - Double-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __ledf2(fp_t a, fp_t b); -enum LE_RESULT __ltdf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} Removed: compiler-rt/trunk/lib/ltsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ltsf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/ltsf2.c (original) +++ compiler-rt/trunk/lib/ltsf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/comparesf2.c - Single-precision comparisons -----------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __lesf2(fp_t a, fp_t b); -enum LE_RESULT __ltsf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} Removed: compiler-rt/trunk/lib/nedf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nedf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/nedf2.c (original) +++ compiler-rt/trunk/lib/nedf2.c (removed) @@ -1,17 +0,0 @@ -//===-- lib/nedf2.c - Double-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __ledf2(fp_t a, fp_t b); -enum LE_RESULT __nedf2(fp_t a, fp_t b) { - return __ledf2(a, b); -} - Removed: compiler-rt/trunk/lib/nesf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/nesf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/nesf2.c (original) +++ compiler-rt/trunk/lib/nesf2.c (removed) @@ -1,16 +0,0 @@ -//===-- lib/nesf2.c - Single-precision comparisons ----------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -enum LE_RESULT __lesf2(fp_t a, fp_t b); -enum LE_RESULT __nesf2(fp_t a, fp_t b) { - return __lesf2(a, b); -} Removed: compiler-rt/trunk/lib/unorddf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unorddf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/unorddf2.c (original) +++ compiler-rt/trunk/lib/unorddf2.c (removed) @@ -1,47 +0,0 @@ -//===-- lib/unorddf2.c - Double-precision comparisons -------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// // This file implements the following soft-float comparison routines: -// -// __eqdf2 __gedf2 __unorddf2 -// __ledf2 __gtdf2 -// __ltdf2 -// __nedf2 -// -// The semantics of the routines grouped in each column are identical, so there -// is a single implementation for each, and wrappers to provide the other names. -// -// The main routines behave as follows: -// -// __ledf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// 1 if either a or b is NaN -// -// __gedf2(a,b) returns -1 if a < b -// 0 if a == b -// 1 if a > b -// -1 if either a or b is NaN -// -// __unorddf2(a,b) returns 0 if both a and b are numbers -// 1 if either a or b is NaN -// -// Note that __ledf2( ) and __gedf2( ) are identical except in their handling of -// NaN values. -// -//===----------------------------------------------------------------------===// - -#define DOUBLE_PRECISION -#include "fp_lib.h" - -int __unorddf2(fp_t a, fp_t b) { - const rep_t aAbs = toRep(a) & absMask; - const rep_t bAbs = toRep(b) & absMask; - return aAbs > infRep || bAbs > infRep; -} Removed: compiler-rt/trunk/lib/unordsf2.c URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/unordsf2.c?rev=128295&view=auto ============================================================================== --- compiler-rt/trunk/lib/unordsf2.c (original) +++ compiler-rt/trunk/lib/unordsf2.c (removed) @@ -1,17 +0,0 @@ -//===-- lib/unordsf2.c - Single-precision comparisons -------------*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#define SINGLE_PRECISION -#include "fp_lib.h" - -int __unordsf2(fp_t a, fp_t b) { - const rep_t aAbs = toRep(a) & absMask; - const rep_t bAbs = toRep(b) & absMask; - return aAbs > infRep || bAbs > infRep; -} Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=128296&r1=128295&r2=128296&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Fri Mar 25 13:45:39 2011 @@ -223,7 +223,8 @@ CCKEXT_MISSING_FUNCTIONS := \ cmpdf2 cmpsf2 div0 \ ffssi2 \ - udiv_w_sdiv bswapdi2 \ + gtdf2 gtsf2 ltdf2 ltsf2 \ + udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ bswapsi2 \ gcc_bcmp \ do_global_dtors \ From grosbach at apple.com Fri Mar 25 14:18:41 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 25 Mar 2011 12:18:41 -0700 Subject: [llvm-commits] [llvm] r128246 - in /llvm/trunk: test/MC/Disassembler/ARM/thumb-tests.txt utils/TableGen/ARMDecoderEmitter.cpp In-Reply-To: References: <20110324232114.D4C2E2A6C12C@llvm.org> Message-ID: <6C2A2566-7F62-417C-9F4C-AE35E214427C@apple.com> On Mar 24, 2011, at 5:28 PM, Eli Friedman wrote: > On Thu, Mar 24, 2011 at 4:21 PM, Johnny Chen wrote: >> Author: johnny >> Date: Thu Mar 24 18:21:14 2011 >> New Revision: 128246 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128246&view=rev >> Log: >> The ARM disassembler was confused with the 16-bit tSTMIA instruction. >> According to A8.6.189 STM/STMIA/STMEA (Encoding T1), there's only tSTMIA_UPD available. >> Ignore tSTMIA for the decoder emitter and add a test case for that. > > Why do we have a definition for an instruction which doesn't exist? It's a bug. From daniel at zuster.org Fri Mar 25 14:19:11 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 25 Mar 2011 19:19:11 -0000 Subject: [llvm-commits] [compiler-rt] r128298 - /compiler-rt/trunk/make/platform/clang_darwin.mk Message-ID: <20110325191911.1EA8F2A6C12C@llvm.org> Author: ddunbar Date: Fri Mar 25 14:19:10 2011 New Revision: 128298 URL: http://llvm.org/viewvc/llvm-project?rev=128298&view=rev Log: clang/Darwin: Add all the comparison functions, the desire to cherry pick just the ones we want isn't worth the effort. Modified: compiler-rt/trunk/make/platform/clang_darwin.mk Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=128298&r1=128297&r2=128298&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Fri Mar 25 14:19:10 2011 @@ -135,10 +135,8 @@ floatsisf \ floatunsidf \ floatunsisf \ - gtdf2 \ - gtsf2 \ - ltdf2 \ - ltsf2 \ + comparedf2 \ + comparesf2 \ modsi3 \ muldf3 \ mulsf3 \ @@ -223,7 +221,6 @@ CCKEXT_MISSING_FUNCTIONS := \ cmpdf2 cmpsf2 div0 \ ffssi2 \ - gtdf2 gtsf2 ltdf2 ltsf2 \ udiv_w_sdiv unorddf2 unordsf2 bswapdi2 \ bswapsi2 \ gcc_bcmp \ From johnny.chen at apple.com Fri Mar 25 14:35:37 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 19:35:37 -0000 Subject: [llvm-commits] [llvm] r128299 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325193537.D7EE22A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 14:35:37 2011 New Revision: 128299 URL: http://llvm.org/viewvc/llvm-project?rev=128299&view=rev Log: DisassembleThumb2LdSt() did not handle t2LDRs correctly with respect to RegClass. Add two test cases. rdar://problem/9182892 Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128299&r1=128298&r2=128299&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Mar 25 14:35:37 2011 @@ -1868,7 +1868,7 @@ OpInfo[1].RegClass == ARM::GPRRegClassID && "Expect >= 3 operands and first two as reg operands"); - bool ThreeReg = (OpInfo[2].RegClass == ARM::GPRRegClassID); + bool ThreeReg = (OpInfo[2].RegClass > 0); bool TIED_TO = ThreeReg && TID.getOperandConstraint(2, TOI::TIED_TO) != -1; bool Imm12 = !ThreeReg && slice(insn, 23, 23) == 1; // ARMInstrThumb2.td @@ -1912,7 +1912,8 @@ ++OpIdx; if (ThreeReg) { - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + // This could be an offset register or a TIED_TO register. + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B,OpInfo[OpIdx].RegClass, R2))); ++OpIdx; } Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128299&r1=128298&r2=128299&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 14:35:37 2011 @@ -166,3 +166,9 @@ # CHECK: tbb [r5, r4] 0xd5 0xe8 0x04 0xf0 + +# CHECK: ldr.w r4, [sp, r4, lsl #3] +0x5d 0xf8 0x34 0x40 + +# CHECK: ldr.w r5, [r6, #30] +0x56 0xf8 0x1e 0x56 From isanbard at gmail.com Fri Mar 25 15:21:35 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 25 Mar 2011 20:21:35 -0000 Subject: [llvm-commits] [www] r128301 - /www/trunk/index.html Message-ID: <20110325202135.5E9D12A6C12C@llvm.org> Author: void Date: Fri Mar 25 15:21:35 2011 New Revision: 128301 URL: http://llvm.org/viewvc/llvm-project?rev=128301&view=rev Log: Update release date. Modified: www/trunk/index.html Modified: www/trunk/index.html URL: http://llvm.org/viewvc/llvm-project/www/trunk/index.html?rev=128301&r1=128300&r2=128301&view=diff ============================================================================== --- www/trunk/index.html (original) +++ www/trunk/index.html Fri Mar 25 15:21:35 2011 @@ -142,7 +142,7 @@
  • March 14th-21st — Preparation for Phase 2 (fixing bugs, merging patches)
  • March 21st-28th — Testing Phase 2
  • March 28th-April 3rd — Preparation for release
  • -
  • April 3rd — Release
  • +
  • April 4th — Release
  • From johnny.chen at apple.com Fri Mar 25 17:19:07 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 22:19:07 -0000 Subject: [llvm-commits] [llvm] r128304 - in /llvm/trunk: lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325221907.55D702A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 17:19:07 2011 New Revision: 128304 URL: http://llvm.org/viewvc/llvm-project?rev=128304&view=rev Log: Fix DisassembleThumb2DPReg()'s handling of RegClass. Cannot hardcode GPRRegClassID. Also add some test cases. rdar://problem/9189829 Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128304&r1=128303&r2=128304&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Mar 25 17:19:07 2011 @@ -1947,25 +1947,25 @@ OpIdx = 0; assert(NumOps >= 2 && - OpInfo[0].RegClass == ARM::rGPRRegClassID && - OpInfo[1].RegClass == ARM::rGPRRegClassID && + OpInfo[0].RegClass > 0 && + OpInfo[1].RegClass > 0 && "Expect >= 2 operands and first two as reg operands"); // Build the register operands, followed by the optional rotation amount. - bool ThreeReg = NumOps > 2 && OpInfo[2].RegClass == ARM::rGPRRegClassID; + bool ThreeReg = NumOps > 2 && OpInfo[2].RegClass > 0; - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::rGPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass, decodeRs(insn)))); ++OpIdx; if (ThreeReg) { - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::rGPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B,OpInfo[OpIdx].RegClass, decodeRn(insn)))); ++OpIdx; } - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::rGPRRegClassID, + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, OpInfo[OpIdx].RegClass, decodeRm(insn)))); ++OpIdx; Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128304&r1=128303&r2=128304&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 17:19:07 2011 @@ -172,3 +172,12 @@ # CHECK: ldr.w r5, [r6, #30] 0x56 0xf8 0x1e 0x56 + +# CHECK: sel r7, r3, r5 +0xa3 0xfa 0x85 0xf7 + +# CHECK: lsl.w r7, r3, r5 +0x03 0xfa 0x05 0xf7 + +# CHECK: adds.w r7, r3, r5 +0x13 0xeb 0x05 0x07 From johnny.chen at apple.com Fri Mar 25 17:43:28 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 22:43:28 -0000 Subject: [llvm-commits] [llvm] r128305 - /llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110325224328.8583D2A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 17:43:28 2011 New Revision: 128305 URL: http://llvm.org/viewvc/llvm-project?rev=128305&view=rev Log: Add two test cases t2SMLABT and t2SMMULR for DisassembleThumb2Mul(). Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128305&r1=128304&r2=128305&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 17:43:28 2011 @@ -181,3 +181,9 @@ # CHECK: adds.w r7, r3, r5 0x13 0xeb 0x05 0x07 + +# CHECK: smlabt r4, r3, r2, r1 +0x13 0xfb 0x12 0x14 + +# CHECK: smmulr r7, r8, r9 +0x58 0xfb 0x19 0xf7 From johnny.chen at apple.com Fri Mar 25 18:02:58 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Fri, 25 Mar 2011 23:02:58 -0000 Subject: [llvm-commits] [llvm] r128306 - in /llvm/trunk/test/MC/Disassembler/ARM: arm-tests.txt thumb-tests.txt Message-ID: <20110325230258.47F3D2A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 18:02:58 2011 New Revision: 128306 URL: http://llvm.org/viewvc/llvm-project?rev=128306&view=rev Log: Add test for A8.6.246 UMULL to both arm-tests.txt amd thumb-tests.txt. Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=128306&r1=128305&r2=128306&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Fri Mar 25 18:02:58 2011 @@ -187,3 +187,6 @@ # CHECK: swpge r3, r2, [r6] 0x92 0x30 0x06 0xa1 + +# CHECK: umull r1, r2, r3, r4 +0x93 0x14 0x82 0xe0 Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128306&r1=128305&r2=128306&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 18:02:58 2011 @@ -187,3 +187,6 @@ # CHECK: smmulr r7, r8, r9 0x58 0xfb 0x19 0xf7 + +# CHECK: umull r1, r2, r3, r4 +0xa3 0xfb 0x04 0x12 From enderby at apple.com Fri Mar 25 19:06:33 2011 From: enderby at apple.com (Kevin Enderby) Date: Sat, 26 Mar 2011 00:06:33 -0000 Subject: [llvm-commits] [llvm] r128308 - in /llvm/trunk: include/llvm-c/Disassembler.h lib/MC/MCDisassembler/Disassembler.cpp lib/MC/MCDisassembler/Disassembler.h Message-ID: <20110326000633.A05582A6C12C@llvm.org> Author: enderby Date: Fri Mar 25 19:06:33 2011 New Revision: 128308 URL: http://llvm.org/viewvc/llvm-project?rev=128308&view=rev Log: Adding a C API to the disassembler for use by such tools as Darwin's otool(1). This is a work in progress as the interface for producing symbolic operands is not done. But a hacked prototype using information from the object file's relocation entiries and replacing immediate operands with MCExpr's has been shown to work with no changes to the instrucion printer. These APIs will be moved into a dynamic library at some point. Added: llvm/trunk/include/llvm-c/Disassembler.h llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp llvm/trunk/lib/MC/MCDisassembler/Disassembler.h Added: llvm/trunk/include/llvm-c/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Disassembler.h?rev=128308&view=auto ============================================================================== --- llvm/trunk/include/llvm-c/Disassembler.h (added) +++ llvm/trunk/include/llvm-c/Disassembler.h Fri Mar 25 19:06:33 2011 @@ -0,0 +1,106 @@ +/*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file is distributed under the University of Illinois Open Source *| +|* License. See LICENSE.TXT for details. *| +|* *| +|*===----------------------------------------------------------------------===*| +|* *| +|* This header provides public interface to a disassembler library. *| +|* LLVM provides an implementation of this interface. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_DISASSEMBLER_H +#define LLVM_C_DISASSEMBLER_H 1 + +#include +#include + +/** + * An opaque reference to a disassembler context. + */ +typedef void *LLVMDisasmContextRef; + +/** + * The type for the operand information call back function. This is called to + * get the symbolic information for an operand of an instruction. Typically + * this is from the relocation information, symbol table, etc. That block of + * information is saved when the disassembler context is created and passed to + * the call back in the DisInfo parameter. The instruction containing operand + * is at the PC parameter. For some instruction sets, there can be more than + * one operand with symbolic information. To determine the symbolic operand + * infomation for each operand, the bytes for the specific operand in the + * instruction are specified by the Offset parameter and its byte widith is the + * size parameter. For instructions sets with fixed widths and one symbolic + * operand per instruction, the Offset parameter will be zero and Size parameter + * will be the instruction width. The information is returned in TagBuf and is + * Triple specific with its specific information defined by the value of + * TagType for that Triple. If symbolic information is returned the function + * returns 1 else it returns 0. + */ +typedef int (*LLVMOpInfoCallback)(void *DisInfo, + uint64_t PC, + uint64_t Offset, + uint64_t Size, + int TagType, + void *TagBuf); + +/** + * The type for the symbol lookup function. This may be called by the + * disassembler for such things like adding a comment for a PC plus a constant + * offset load instruction to use a symbol name instead of a load address value. + * It is passed the block information is saved when the disassembler context is + * created and a value of a symbol to look up. If no symbol is found NULL is + * to be returned. + */ +typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo, + uint64_t SymbolValue); + +#ifdef __cplusplus +extern "C" { +#endif /* !defined(__cplusplus) */ + +/** + * Create a disassembler for the TripleName. Symbolic disassembly is supported + * by passing a block of information in the DisInfo parameter and specifing the + * TagType and call back functions as described above. These can all be passed + * as NULL. If successfull this returns a disassembler context if not it + * returns NULL. + */ +extern LLVMDisasmContextRef +LLVMCreateDisasm(const char *TripleName, + void *DisInfo, + int TagType, + LLVMOpInfoCallback GetOpInfo, + LLVMSymbolLookupCallback SymbolLookUp); + +/** + * Dispose of a disassembler context. + */ +extern void +LLVMDisasmDispose(LLVMDisasmContextRef DC); + +/** + * Disassmble a single instruction using the disassembler context specified in + * the parameter DC. The bytes of the instuction are specified in the parameter + * Bytes, and contains at least BytesSize number of bytes. The instruction is + * at the address specified by the PC parameter. If a valid instruction can be + * disassembled its string is returned indirectly in OutString which whos size + * is specified in the parameter OutStringSize. This function returns the + * number of bytes in the instruction or zero if there was no valid instruction. + */ +extern size_t +LLVMDisasmInstruction(LLVMDisasmContextRef DC, + uint8_t *Bytes, + uint64_t BytesSize, + uint64_t PC, + char *OutString, + size_t OutStringSize); + +#ifdef __cplusplus +} +#endif /* !defined(__cplusplus) */ + +#endif /* !defined(LLVM_C_DISASSEMBLER_H) */ Added: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=128308&view=auto ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (added) +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Fri Mar 25 19:06:33 2011 @@ -0,0 +1,169 @@ +//===-- lib/MC/Disassembler.cpp - Disassembler Public C Interface -*- C -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include "Disassembler.h" +#include +#include "llvm-c/Disassembler.h" + +#include +#include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCDisassembler.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCContext.h" +#include "llvm/Target/TargetRegistry.h" +#include "llvm/Target/TargetAsmInfo.h" // FIXME. +#include "llvm/Target/TargetMachine.h" // FIXME. +#include "llvm/Target/targetSelect.h" +#include "llvm/Support/MemoryObject.h" + +namespace llvm { +class Target; +} // namespace llvm +using namespace llvm; + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// +// LLVMCreateDisasm() creates a disassembler for the TripleName. Symbolic +// disassembly is supported by passing a block of information in the DisInfo +// parameter and specifing the TagType and call back functions as described in +// the header llvm-c/Disassembler.h . The pointer to the block and the +// functions can all be passed as NULL. If successfull this returns a +// disassembler context if not it returns NULL. +// +LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, + int TagType, LLVMOpInfoCallback GetOpInfo, + LLVMSymbolLookupCallback SymbolLookUp) { + // Initialize targets and assembly printers/parsers. + llvm::InitializeAllTargetInfos(); + // FIXME: We shouldn't need to initialize the Target(Machine)s. + llvm::InitializeAllTargets(); + llvm::InitializeAllAsmPrinters(); + llvm::InitializeAllAsmParsers(); + llvm::InitializeAllDisassemblers(); + + // Get the target. + std::string Error; + const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error); + assert(TheTarget && "Unable to create target!"); + + // Get the assembler info needed to setup the MCContext. + const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName); + assert(MAI && "Unable to create target asm info!"); + + // Package up features to be passed to target/subtarget + std::string FeaturesStr; + + // FIXME: We shouldn't need to do this (and link in codegen). + // When we split this out, we should do it in a way that makes + // it straightforward to switch subtargets on the fly. + TargetMachine *TM = TheTarget->createTargetMachine(TripleName, FeaturesStr); + assert(TM && "Unable to create target machine!"); + + // Get the target assembler info needed to setup the context. + const TargetAsmInfo *tai = new TargetAsmInfo(*TM); + assert(tai && "Unable to create target assembler!"); + + // Set up the MCContext for creating symbols and MCExpr's. + MCContext *Ctx = new MCContext(*MAI, tai); + assert(Ctx && "Unable to create MCContext!"); + + // Set up disassembler. + const MCDisassembler *DisAsm = TheTarget->createMCDisassembler(); + assert(DisAsm && "Unable to create disassembler!"); + + // Set up the instruction printer. + int AsmPrinterVariant = MAI->getAssemblerDialect(); + MCInstPrinter *IP = TheTarget->createMCInstPrinter(*TM, AsmPrinterVariant, + *MAI); + assert(IP && "Unable to create instruction printer!"); + + LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType, + GetOpInfo, SymbolLookUp, + TheTarget, MAI, TM, tai, Ctx, + DisAsm, IP); + assert(DC && "Allocation failure!"); + return DC; +} + +// +// LLVMDisasmDispose() disposes of the disassembler specified by the context. +// +void LLVMDisasmDispose(LLVMDisasmContextRef DCR){ + LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + delete DC; +} + +namespace { +// +// The memory object created by LLVMDisasmInstruction(). +// +class DisasmMemoryObject : public MemoryObject { +private: + uint8_t *Bytes; + uint64_t Size; + uint64_t BasePC; +public: + DisasmMemoryObject(uint8_t *bytes, uint64_t size, uint64_t basePC) : + Bytes(bytes), Size(size), BasePC(basePC) {} + + uint64_t getBase() const { return BasePC; } + uint64_t getExtent() const { return Size; } + + int readByte(uint64_t Addr, uint8_t *Byte) const { + if (Addr - BasePC >= Size) + return -1; + *Byte = Bytes[Addr - BasePC]; + return 0; + } +}; +} // namespace + +// +// LLVMDisasmInstruction() disassmbles a single instruction using the +// disassembler context specified in the parameter DC. The bytes of the +// instuction are specified in the parameter Bytes, and contains at least +// BytesSize number of bytes. The instruction is at the address specified by +// the PC parameter. If a valid instruction can be disassembled its string is +// returned indirectly in OutString which whos size is specified in the +// parameter OutStringSize. This function returns the number of bytes in the +// instruction or zero if there was no valid instruction. If this function +// returns zero the caller will have to pick how many bytes they want to step +// over by printing a .byte, .long etc. to continue. +// +size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, + uint64_t BytesSize, uint64_t PC, char *OutString, + size_t OutStringSize){ + LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; + // Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject. + DisasmMemoryObject MemoryObject(Bytes, BytesSize, PC); + + uint64_t Size; + MCInst Inst; + const MCDisassembler *DisAsm = DC->getDisAsm(); + MCInstPrinter *IP = DC->getIP(); + if (!DisAsm->getInstruction(Inst, Size, MemoryObject, PC, /*REMOVE*/ nulls())) + return 0; + + std::string InsnStr; + raw_string_ostream OS(InsnStr); + raw_ostream &Out = OS; + IP->printInst(&Inst, Out); + + std::string p; + p = OS.str(); + snprintf(OutString, OutStringSize, "%s", p.c_str()); + return Size; +} + +#ifdef __cplusplus +} +#endif // __cplusplus Added: llvm/trunk/lib/MC/MCDisassembler/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.h?rev=128308&view=auto ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.h (added) +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.h Fri Mar 25 19:06:33 2011 @@ -0,0 +1,90 @@ +//===------------- Disassembler.h - LLVM Disassembler -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the interface for the Disassembly library's disassembler +// context. The disassembler is responsible for producing strings for +// individual instructions according to a given architecture and disassembly +// syntax. +// +//===----------------------------------------------------------------------===// +#include "llvm-c/Disassembler.h" +#include +#include "llvm/ADT/OwningPtr.h" + +namespace llvm { +class TargetAsmInfo; +class MCContext; +class MCAsmInfo; +class MCDisassembler; +class MCInstPrinter; +class Target; +class TargetMachine; + +// +// This is the disassembler context returned by LLVMCreateDisasm(). +// +class LLVMDisasmContext { +private: + // + // The passed parameters when the disassembler context is created. + // + // The TripleName for this disassembler. + std::string TripleName; + // The pointer to the caller's block of symbolic information. + void *DisInfo; + // The Triple specific symbolic information type returned by GetOpInfo. + int TagType; + // The function to get the symbolic information for operands. + LLVMOpInfoCallback GetOpInfo; + // The function to look up a symbol name. + LLVMSymbolLookupCallback SymbolLookUp; + // + // The objects created and saved by LLVMCreateDisasm() then used by + // LLVMDisasmInstruction(). + // + // The LLVM target corresponding to the disassembler. + // FIXME: using llvm::OwningPtr causes a malloc error + // when this LLVMDisasmContext is deleted. + const Target *TheTarget; + // The assembly information for the target architecture. + llvm::OwningPtr MAI; + // The target machine instance. + llvm::OwningPtr TM; + // The disassembler for the target architecture. + // FIXME: using llvm::OwningPtr causes a malloc + // error when this LLVMDisasmContext is deleted. + const TargetAsmInfo *Tai; + // The assembly context for creating symbols and MCExprs. + llvm::OwningPtr Ctx; + // The disassembler for the target architecture. + llvm::OwningPtr DisAsm; + // The instruction printer for the target architecture. + llvm::OwningPtr IP; + +public: + LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType, + LLVMOpInfoCallback getOpInfo, + LLVMSymbolLookupCallback symbolLookUp, + const Target *theTarget, const MCAsmInfo *mAI, + llvm::TargetMachine *tM, const TargetAsmInfo *tai, + llvm::MCContext *ctx, const MCDisassembler *disAsm, + MCInstPrinter *iP) : TripleName(tripleName), + DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo), + SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) { + TM.reset(tM); + MAI.reset(mAI); + Ctx.reset(ctx); + DisAsm.reset(disAsm); + IP.reset(iP); + } + const MCDisassembler *getDisAsm() const { return DisAsm.get(); } + MCInstPrinter *getIP() { return IP.get(); } +}; + +} // namespace llvm From enderby at apple.com Fri Mar 25 19:23:05 2011 From: enderby at apple.com (Kevin Enderby) Date: Sat, 26 Mar 2011 00:23:05 -0000 Subject: [llvm-commits] [llvm] r128309 - in /llvm/trunk: include/llvm-c/Disassembler.h lib/MC/MCDisassembler/Disassembler.cpp lib/MC/MCDisassembler/Disassembler.h Message-ID: <20110326002305.E94C02A6C12C@llvm.org> Author: enderby Date: Fri Mar 25 19:23:05 2011 New Revision: 128309 URL: http://llvm.org/viewvc/llvm-project?rev=128309&view=rev Log: Remove the files for r128308 as it is causing a buildbot failure. Removed: llvm/trunk/include/llvm-c/Disassembler.h llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp llvm/trunk/lib/MC/MCDisassembler/Disassembler.h Removed: llvm/trunk/include/llvm-c/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Disassembler.h?rev=128308&view=auto ============================================================================== --- llvm/trunk/include/llvm-c/Disassembler.h (original) +++ llvm/trunk/include/llvm-c/Disassembler.h (removed) @@ -1,106 +0,0 @@ -/*===-- llvm-c/Disassembler.h - Disassembler Public C Interface ---*- C -*-===*\ -|* *| -|* The LLVM Compiler Infrastructure *| -|* *| -|* This file is distributed under the University of Illinois Open Source *| -|* License. See LICENSE.TXT for details. *| -|* *| -|*===----------------------------------------------------------------------===*| -|* *| -|* This header provides public interface to a disassembler library. *| -|* LLVM provides an implementation of this interface. *| -|* *| -\*===----------------------------------------------------------------------===*/ - -#ifndef LLVM_C_DISASSEMBLER_H -#define LLVM_C_DISASSEMBLER_H 1 - -#include -#include - -/** - * An opaque reference to a disassembler context. - */ -typedef void *LLVMDisasmContextRef; - -/** - * The type for the operand information call back function. This is called to - * get the symbolic information for an operand of an instruction. Typically - * this is from the relocation information, symbol table, etc. That block of - * information is saved when the disassembler context is created and passed to - * the call back in the DisInfo parameter. The instruction containing operand - * is at the PC parameter. For some instruction sets, there can be more than - * one operand with symbolic information. To determine the symbolic operand - * infomation for each operand, the bytes for the specific operand in the - * instruction are specified by the Offset parameter and its byte widith is the - * size parameter. For instructions sets with fixed widths and one symbolic - * operand per instruction, the Offset parameter will be zero and Size parameter - * will be the instruction width. The information is returned in TagBuf and is - * Triple specific with its specific information defined by the value of - * TagType for that Triple. If symbolic information is returned the function - * returns 1 else it returns 0. - */ -typedef int (*LLVMOpInfoCallback)(void *DisInfo, - uint64_t PC, - uint64_t Offset, - uint64_t Size, - int TagType, - void *TagBuf); - -/** - * The type for the symbol lookup function. This may be called by the - * disassembler for such things like adding a comment for a PC plus a constant - * offset load instruction to use a symbol name instead of a load address value. - * It is passed the block information is saved when the disassembler context is - * created and a value of a symbol to look up. If no symbol is found NULL is - * to be returned. - */ -typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo, - uint64_t SymbolValue); - -#ifdef __cplusplus -extern "C" { -#endif /* !defined(__cplusplus) */ - -/** - * Create a disassembler for the TripleName. Symbolic disassembly is supported - * by passing a block of information in the DisInfo parameter and specifing the - * TagType and call back functions as described above. These can all be passed - * as NULL. If successfull this returns a disassembler context if not it - * returns NULL. - */ -extern LLVMDisasmContextRef -LLVMCreateDisasm(const char *TripleName, - void *DisInfo, - int TagType, - LLVMOpInfoCallback GetOpInfo, - LLVMSymbolLookupCallback SymbolLookUp); - -/** - * Dispose of a disassembler context. - */ -extern void -LLVMDisasmDispose(LLVMDisasmContextRef DC); - -/** - * Disassmble a single instruction using the disassembler context specified in - * the parameter DC. The bytes of the instuction are specified in the parameter - * Bytes, and contains at least BytesSize number of bytes. The instruction is - * at the address specified by the PC parameter. If a valid instruction can be - * disassembled its string is returned indirectly in OutString which whos size - * is specified in the parameter OutStringSize. This function returns the - * number of bytes in the instruction or zero if there was no valid instruction. - */ -extern size_t -LLVMDisasmInstruction(LLVMDisasmContextRef DC, - uint8_t *Bytes, - uint64_t BytesSize, - uint64_t PC, - char *OutString, - size_t OutStringSize); - -#ifdef __cplusplus -} -#endif /* !defined(__cplusplus) */ - -#endif /* !defined(LLVM_C_DISASSEMBLER_H) */ Removed: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=128308&view=auto ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original) +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (removed) @@ -1,169 +0,0 @@ -//===-- lib/MC/Disassembler.cpp - Disassembler Public C Interface -*- C -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -#include "Disassembler.h" -#include -#include "llvm-c/Disassembler.h" - -#include -#include "llvm/MC/MCAsmInfo.h" -#include "llvm/MC/MCDisassembler.h" -#include "llvm/MC/MCInst.h" -#include "llvm/MC/MCInstPrinter.h" -#include "llvm/MC/MCContext.h" -#include "llvm/Target/TargetRegistry.h" -#include "llvm/Target/TargetAsmInfo.h" // FIXME. -#include "llvm/Target/TargetMachine.h" // FIXME. -#include "llvm/Target/targetSelect.h" -#include "llvm/Support/MemoryObject.h" - -namespace llvm { -class Target; -} // namespace llvm -using namespace llvm; - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -// -// LLVMCreateDisasm() creates a disassembler for the TripleName. Symbolic -// disassembly is supported by passing a block of information in the DisInfo -// parameter and specifing the TagType and call back functions as described in -// the header llvm-c/Disassembler.h . The pointer to the block and the -// functions can all be passed as NULL. If successfull this returns a -// disassembler context if not it returns NULL. -// -LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo, - int TagType, LLVMOpInfoCallback GetOpInfo, - LLVMSymbolLookupCallback SymbolLookUp) { - // Initialize targets and assembly printers/parsers. - llvm::InitializeAllTargetInfos(); - // FIXME: We shouldn't need to initialize the Target(Machine)s. - llvm::InitializeAllTargets(); - llvm::InitializeAllAsmPrinters(); - llvm::InitializeAllAsmParsers(); - llvm::InitializeAllDisassemblers(); - - // Get the target. - std::string Error; - const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error); - assert(TheTarget && "Unable to create target!"); - - // Get the assembler info needed to setup the MCContext. - const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName); - assert(MAI && "Unable to create target asm info!"); - - // Package up features to be passed to target/subtarget - std::string FeaturesStr; - - // FIXME: We shouldn't need to do this (and link in codegen). - // When we split this out, we should do it in a way that makes - // it straightforward to switch subtargets on the fly. - TargetMachine *TM = TheTarget->createTargetMachine(TripleName, FeaturesStr); - assert(TM && "Unable to create target machine!"); - - // Get the target assembler info needed to setup the context. - const TargetAsmInfo *tai = new TargetAsmInfo(*TM); - assert(tai && "Unable to create target assembler!"); - - // Set up the MCContext for creating symbols and MCExpr's. - MCContext *Ctx = new MCContext(*MAI, tai); - assert(Ctx && "Unable to create MCContext!"); - - // Set up disassembler. - const MCDisassembler *DisAsm = TheTarget->createMCDisassembler(); - assert(DisAsm && "Unable to create disassembler!"); - - // Set up the instruction printer. - int AsmPrinterVariant = MAI->getAssemblerDialect(); - MCInstPrinter *IP = TheTarget->createMCInstPrinter(*TM, AsmPrinterVariant, - *MAI); - assert(IP && "Unable to create instruction printer!"); - - LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType, - GetOpInfo, SymbolLookUp, - TheTarget, MAI, TM, tai, Ctx, - DisAsm, IP); - assert(DC && "Allocation failure!"); - return DC; -} - -// -// LLVMDisasmDispose() disposes of the disassembler specified by the context. -// -void LLVMDisasmDispose(LLVMDisasmContextRef DCR){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; - delete DC; -} - -namespace { -// -// The memory object created by LLVMDisasmInstruction(). -// -class DisasmMemoryObject : public MemoryObject { -private: - uint8_t *Bytes; - uint64_t Size; - uint64_t BasePC; -public: - DisasmMemoryObject(uint8_t *bytes, uint64_t size, uint64_t basePC) : - Bytes(bytes), Size(size), BasePC(basePC) {} - - uint64_t getBase() const { return BasePC; } - uint64_t getExtent() const { return Size; } - - int readByte(uint64_t Addr, uint8_t *Byte) const { - if (Addr - BasePC >= Size) - return -1; - *Byte = Bytes[Addr - BasePC]; - return 0; - } -}; -} // namespace - -// -// LLVMDisasmInstruction() disassmbles a single instruction using the -// disassembler context specified in the parameter DC. The bytes of the -// instuction are specified in the parameter Bytes, and contains at least -// BytesSize number of bytes. The instruction is at the address specified by -// the PC parameter. If a valid instruction can be disassembled its string is -// returned indirectly in OutString which whos size is specified in the -// parameter OutStringSize. This function returns the number of bytes in the -// instruction or zero if there was no valid instruction. If this function -// returns zero the caller will have to pick how many bytes they want to step -// over by printing a .byte, .long etc. to continue. -// -size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, - uint64_t BytesSize, uint64_t PC, char *OutString, - size_t OutStringSize){ - LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; - // Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject. - DisasmMemoryObject MemoryObject(Bytes, BytesSize, PC); - - uint64_t Size; - MCInst Inst; - const MCDisassembler *DisAsm = DC->getDisAsm(); - MCInstPrinter *IP = DC->getIP(); - if (!DisAsm->getInstruction(Inst, Size, MemoryObject, PC, /*REMOVE*/ nulls())) - return 0; - - std::string InsnStr; - raw_string_ostream OS(InsnStr); - raw_ostream &Out = OS; - IP->printInst(&Inst, Out); - - std::string p; - p = OS.str(); - snprintf(OutString, OutStringSize, "%s", p.c_str()); - return Size; -} - -#ifdef __cplusplus -} -#endif // __cplusplus Removed: llvm/trunk/lib/MC/MCDisassembler/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.h?rev=128308&view=auto ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.h (original) +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.h (removed) @@ -1,90 +0,0 @@ -//===------------- Disassembler.h - LLVM Disassembler -----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the interface for the Disassembly library's disassembler -// context. The disassembler is responsible for producing strings for -// individual instructions according to a given architecture and disassembly -// syntax. -// -//===----------------------------------------------------------------------===// -#include "llvm-c/Disassembler.h" -#include -#include "llvm/ADT/OwningPtr.h" - -namespace llvm { -class TargetAsmInfo; -class MCContext; -class MCAsmInfo; -class MCDisassembler; -class MCInstPrinter; -class Target; -class TargetMachine; - -// -// This is the disassembler context returned by LLVMCreateDisasm(). -// -class LLVMDisasmContext { -private: - // - // The passed parameters when the disassembler context is created. - // - // The TripleName for this disassembler. - std::string TripleName; - // The pointer to the caller's block of symbolic information. - void *DisInfo; - // The Triple specific symbolic information type returned by GetOpInfo. - int TagType; - // The function to get the symbolic information for operands. - LLVMOpInfoCallback GetOpInfo; - // The function to look up a symbol name. - LLVMSymbolLookupCallback SymbolLookUp; - // - // The objects created and saved by LLVMCreateDisasm() then used by - // LLVMDisasmInstruction(). - // - // The LLVM target corresponding to the disassembler. - // FIXME: using llvm::OwningPtr causes a malloc error - // when this LLVMDisasmContext is deleted. - const Target *TheTarget; - // The assembly information for the target architecture. - llvm::OwningPtr MAI; - // The target machine instance. - llvm::OwningPtr TM; - // The disassembler for the target architecture. - // FIXME: using llvm::OwningPtr causes a malloc - // error when this LLVMDisasmContext is deleted. - const TargetAsmInfo *Tai; - // The assembly context for creating symbols and MCExprs. - llvm::OwningPtr Ctx; - // The disassembler for the target architecture. - llvm::OwningPtr DisAsm; - // The instruction printer for the target architecture. - llvm::OwningPtr IP; - -public: - LLVMDisasmContext(std::string tripleName, void *disInfo, int tagType, - LLVMOpInfoCallback getOpInfo, - LLVMSymbolLookupCallback symbolLookUp, - const Target *theTarget, const MCAsmInfo *mAI, - llvm::TargetMachine *tM, const TargetAsmInfo *tai, - llvm::MCContext *ctx, const MCDisassembler *disAsm, - MCInstPrinter *iP) : TripleName(tripleName), - DisInfo(disInfo), TagType(tagType), GetOpInfo(getOpInfo), - SymbolLookUp(symbolLookUp), TheTarget(theTarget), Tai(tai) { - TM.reset(tM); - MAI.reset(mAI); - Ctx.reset(ctx); - DisAsm.reset(disAsm); - IP.reset(iP); - } - const MCDisassembler *getDisAsm() const { return DisAsm.get(); } - MCInstPrinter *getIP() { return IP.get(); } -}; - -} // namespace llvm From isanbard at gmail.com Fri Mar 25 20:20:37 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 01:20:37 -0000 Subject: [llvm-commits] [llvm] r128319 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll Message-ID: <20110326012037.D5AF02A6C12C@llvm.org> Author: void Date: Fri Mar 25 20:20:37 2011 New Revision: 128319 URL: http://llvm.org/viewvc/llvm-project?rev=128319&view=rev Log: PR9561: A store with a negative offset (via GEP) could erroniously say that it completely overlaps a previous store, thus mistakenly deleting that store. Check for this condition. Added: llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128319&r1=128318&r2=128319&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Mar 25 20:20:37 2011 @@ -354,8 +354,10 @@ // In this case, we see if the later store completely overlaps all bytes // stored by the previous store. if (Off1 < Off2 || // Earlier starts before Later. + Off2 < 0 || // Later is -. Off1+Earlier.Size > Off2+Later.Size) // Earlier goes beyond Later. return false; + // Otherwise, we have complete overlap. return true; } Added: llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll?rev=128319&view=auto ============================================================================== --- llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll (added) +++ llvm/trunk/test/Transforms/DeadStoreElimination/2011-03-25-DSEMiscompile.ll Fri Mar 25 20:20:37 2011 @@ -0,0 +1,22 @@ +; RUN: opt < %s -basicaa -dse -S | FileCheck %s +; PR9561 +target triple = "i386-apple-darwin9.8" + + at A = external global [0 x i32] + +declare cc10 void @Func2(i32*, i32*, i32*, i32) + +define cc10 void @Func1(i32* noalias %Arg1, i32* noalias %Arg2, i32* %Arg3, i32 %Arg4) { +entry: + store i32 add (i32 ptrtoint ([0 x i32]* @A to i32), i32 1), i32* %Arg2 +; CHECK: store i32 add (i32 ptrtoint ([0 x i32]* @A to i32), i32 1), i32* %Arg2 + %ln2gz = getelementptr i32* %Arg1, i32 14 + %ln2gA = bitcast i32* %ln2gz to double* + %ln2gB = load double* %ln2gA + %ln2gD = getelementptr i32* %Arg2, i32 -3 + %ln2gE = bitcast i32* %ln2gD to double* + store double %ln2gB, double* %ln2gE +; CHECK: store double %ln2gB, double* %ln2gE + tail call cc10 void @Func2(i32* %Arg1, i32* %Arg2, i32* %Arg3, i32 %Arg4) nounwind + ret void +} From echristo at apple.com Fri Mar 25 20:21:03 2011 From: echristo at apple.com (Eric Christopher) Date: Sat, 26 Mar 2011 01:21:03 -0000 Subject: [llvm-commits] [llvm] r128320 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/Thumb2/bfi.ll Message-ID: <20110326012103.E0B762A6C12C@llvm.org> Author: echristo Date: Fri Mar 25 20:21:03 2011 New Revision: 128320 URL: http://llvm.org/viewvc/llvm-project?rev=128320&view=rev Log: Fix the bfi handling for or (and a mask) (and b mask). We need the two masks to match inversely for the code as is to work. For the example given we actually want: bfi r0, r2, #1, #1 not #0, however, given the way the pattern is written it's not possible at the moment. Fixes rdar://9177502 Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/test/CodeGen/Thumb2/bfi.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=128320&r1=128319&r2=128320&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Mar 25 20:21:03 2011 @@ -5168,6 +5168,7 @@ static SDValue PerformANDCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI) { + // Attempt to use immediate-form VBIC BuildVectorSDNode *BVN = dyn_cast(N->getOperand(1)); DebugLoc dl = N->getDebugLoc(); @@ -5241,9 +5242,9 @@ // // 2) or (and A, mask), (and B, mask2) => ARMbfi A, (lsr B, amt), mask // 2a) iff isBitFieldInvertedMask(mask) && isBitFieldInvertedMask(~mask2) - // && CountPopulation_32(mask) == CountPopulation_32(~mask2) + // && mask == ~mask2 // 2b) iff isBitFieldInvertedMask(~mask) && isBitFieldInvertedMask(mask2) - // && CountPopulation_32(mask) == CountPopulation_32(~mask2) + // && ~mask == mask2 // (i.e., copy a bitfield value into another bitfield of the same width) if (N0.getOpcode() != ISD::AND) return SDValue(); @@ -5289,26 +5290,26 @@ return SDValue(); unsigned Mask2 = N11C->getZExtValue(); + // Mask and ~Mask2 (or reverse) must be equivalent for the BFI pattern + // as is to match. if (ARM::isBitFieldInvertedMask(Mask) && - ARM::isBitFieldInvertedMask(~Mask2) && - (CountPopulation_32(Mask) == CountPopulation_32(~Mask2))) { + (Mask == ~Mask2)) { // The pack halfword instruction works better for masks that fit it, // so use that when it's available. if (Subtarget->hasT2ExtractPack() && (Mask == 0xffff || Mask == 0xffff0000)) return SDValue(); // 2a - unsigned lsb = CountTrailingZeros_32(Mask2); + unsigned amt = CountTrailingZeros_32(Mask2); Res = DAG.getNode(ISD::SRL, DL, VT, N1.getOperand(0), - DAG.getConstant(lsb, MVT::i32)); + DAG.getConstant(amt, MVT::i32)); Res = DAG.getNode(ARMISD::BFI, DL, VT, N00, Res, DAG.getConstant(Mask, MVT::i32)); // Do not add new nodes to DAG combiner worklist. DCI.CombineTo(N, Res, false); return SDValue(); } else if (ARM::isBitFieldInvertedMask(~Mask) && - ARM::isBitFieldInvertedMask(Mask2) && - (CountPopulation_32(~Mask) == CountPopulation_32(Mask2))) { + (~Mask == Mask2)) { // The pack halfword instruction works better for masks that fit it, // so use that when it's available. if (Subtarget->hasT2ExtractPack() && @@ -5319,7 +5320,7 @@ Res = DAG.getNode(ISD::SRL, DL, VT, N00, DAG.getConstant(lsb, MVT::i32)); Res = DAG.getNode(ARMISD::BFI, DL, VT, N1.getOperand(0), Res, - DAG.getConstant(Mask2, MVT::i32)); + DAG.getConstant(Mask2, MVT::i32)); // Do not add new nodes to DAG combiner worklist. DCI.CombineTo(N, Res, false); return SDValue(); Modified: llvm/trunk/test/CodeGen/Thumb2/bfi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/bfi.ll?rev=128320&r1=128319&r2=128320&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/bfi.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/bfi.ll Fri Mar 25 20:21:03 2011 @@ -49,3 +49,14 @@ %ins12 = or i32 %ins7, 3137 ret i32 %ins12 } + +; rdar://9177502 +define i32 @f5(i32 %a, i32 %b) nounwind readnone { +entry: +; CHECK f5 +; CHECK-NOT: bfi r0, r2, #0, #1 +%and = and i32 %a, 2 +%b.masked = and i32 %b, -2 +%and3 = or i32 %b.masked, %and +ret i32 %and3 +} From johnny.chen at apple.com Fri Mar 25 20:32:48 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Sat, 26 Mar 2011 01:32:48 -0000 Subject: [llvm-commits] [llvm] r128322 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassembler.cpp lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/ARM/thumb-tests.txt Message-ID: <20110326013248.8C1B02A6C12C@llvm.org> Author: johnny Date: Fri Mar 25 20:32:48 2011 New Revision: 128322 URL: http://llvm.org/viewvc/llvm-project?rev=128322&view=rev Log: Fixed the t2PLD and friends disassembly and add two test cases. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=128322&r1=128321&r2=128322&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Fri Mar 25 20:32:48 2011 @@ -284,6 +284,24 @@ } } +// Helper function for special case handling of PLD (literal) and friends. +// See A8.6.117 T1 & T2 and friends for why we morphed the opcode +// before returning it. +static unsigned T2Morph2PLDLiteral(unsigned Opcode) { + switch (Opcode) { + default: + return Opcode; // Return unmorphed opcode. + + case ARM::t2PLDi8: case ARM::t2PLDs: + case ARM::t2PLDWi12: case ARM::t2PLDWi8: + case ARM::t2PLDWs: + return ARM::t2PLDi12; + + case ARM::t2PLIi8: case ARM::t2PLIs: + return ARM::t2PLIi12; + } +} + /// decodeThumbSideEffect is a decorator function which can potentially twiddle /// the instruction or morph the returned opcode under Thumb2. /// @@ -334,12 +352,27 @@ } // --------- Transform End Marker --------- + unsigned unmorphed = decodeThumbInstruction(insn); + // See, for example, A6.3.7 Load word: Table A6-18 Load word. // See A8.6.57 T3, T4 & A8.6.60 T2 and friends for why we morphed the opcode // before returning it to our caller. if (op1 == 3 && slice(op2, 6, 5) == 0 && slice(op2, 0, 0) == 1 - && slice(insn, 19, 16) == 15) - return T2Morph2LoadLiteral(decodeThumbInstruction(insn)); + && slice(insn, 19, 16) == 15) { + unsigned morphed = T2Morph2LoadLiteral(unmorphed); + if (morphed != unmorphed) + return morphed; + } + + // See, for example, A8.6.117 PLD,PLDW (immediate) T1 & T2, and friends for + // why we morphed the opcode before returning it to our caller. + if (slice(insn, 31, 25) == 0x7C && slice(insn, 15, 12) == 0xF + && slice(insn, 22, 22) == 0 && slice(insn, 20, 20) == 1 + && slice(insn, 19, 16) == 15) { + unsigned morphed = T2Morph2PLDLiteral(unmorphed); + if (morphed != unmorphed) + return morphed; + } // One last check for NEON/VFP instructions. if ((op1 == 1 || op1 == 3) && slice(op2, 6, 6) == 1) Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=128322&r1=128321&r2=128322&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Mar 25 20:32:48 2011 @@ -1786,7 +1786,7 @@ decodeRn(insn)))); ++OpIdx; - if (OpInfo[OpIdx].RegClass == ARM::GPRRegClassID) { + if (OpInfo[OpIdx].RegClass == ARM::rGPRRegClassID) { MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, decodeRm(insn)))); } else { @@ -1794,15 +1794,11 @@ && !OpInfo[OpIdx].isOptionalDef() && "Pure imm operand expected"); int Offset = 0; - if (slice(insn, 19, 16) == 0xFF) { - bool Negative = slice(insn, 23, 23) == 0; - unsigned Imm12 = getImm12(insn); - Offset = Negative ? -1 - Imm12 : 1 * Imm12; - } else if (Opcode == ARM::t2PLDi8 || Opcode == ARM::t2PLDWi8 || - Opcode == ARM::t2PLIi8) { + if (Opcode == ARM::t2PLDi8 || Opcode == ARM::t2PLDWi8 || + Opcode == ARM::t2PLIi8) { // A8.6.117 Encoding T2: add = FALSE unsigned Imm8 = getImm8(insn); - Offset = -1 - Imm8; + Offset = -1 * Imm8; } else // The i12 forms. See, for example, A8.6.117 Encoding T1. Offset = decodeImm12(insn); MI.addOperand(MCOperand::CreateImm(Offset)); Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=128322&r1=128321&r2=128322&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Fri Mar 25 20:32:48 2011 @@ -190,3 +190,9 @@ # CHECK: umull r1, r2, r3, r4 0xa3 0xfb 0x04 0x12 + +# CHECK: pld [r5, r0, lsl #1] +0x15 0xf8 0x10 0xf0 + +# CHECK: pld [pc, #-16] +0x1f 0xf8 0x10 0xf0 From stoklund at 2pi.dk Fri Mar 25 21:19:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 26 Mar 2011 02:19:36 -0000 Subject: [llvm-commits] [llvm] r128327 - in /llvm/trunk: include/llvm/CodeGen/MachineBasicBlock.h lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/CodeGen/X86/dbg-merge-loc-entry.ll Message-ID: <20110326021936.93DFB2A6C12C@llvm.org> Author: stoklund Date: Fri Mar 25 21:19:36 2011 New Revision: 128327 URL: http://llvm.org/viewvc/llvm-project?rev=128327&view=rev Log: Collect and coalesce DBG_VALUE instructions before emitting the function. Correctly terminate the range of register DBG_VALUEs when the register is clobbered or when the basic block ends. The code is now ready to deal with variables that are sometimes in a register and sometimes on the stack. We just need to teach emitDebugLoc to say 'stack slot'. Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/test/CodeGen/X86/dbg-merge-loc-entry.ll Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=128327&r1=128326&r2=128327&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Fri Mar 25 21:19:36 2011 @@ -309,6 +309,10 @@ /// instruction in the basic block, or end() iterator getLastNonDebugInstr(); + const_iterator getLastNonDebugInstr() const { + return const_cast(this)->getLastNonDebugInstr(); + } + /// SplitCriticalEdge - Split the critical edge from this block to the /// given successor block, and return the newly created block, or null /// if splitting is not possible. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=128327&r1=128326&r2=128327&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Mar 25 21:19:36 2011 @@ -2408,38 +2408,21 @@ /// collection info from MMI table. collectVariableInfoFromMMITable(MF, Processed); - SmallVector DbgValues; - // Collect variable information from DBG_VALUE machine instructions; - for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end(); - I != E; ++I) - for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); - II != IE; ++II) { - const MachineInstr *MInsn = II; - if (!MInsn->isDebugValue()) - continue; - DbgValues.push_back(MInsn); - } - - // This is a collection of DBG_VALUE instructions describing same variable. - SmallVector MultipleValues; - for(SmallVector::iterator I = DbgValues.begin(), - E = DbgValues.end(); I != E; ++I) { - const MachineInstr *MInsn = *I; - MultipleValues.clear(); - if (isDbgValueInDefinedReg(MInsn)) - MultipleValues.push_back(MInsn); - DIVariable DV(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata()); - if (Processed.count(DV) != 0) + for (SmallVectorImpl::const_iterator + UVI = UserVariables.begin(), UVE = UserVariables.end(); UVI != UVE; + ++UVI) { + const MDNode *Var = *UVI; + if (Processed.count(Var)) continue; - for (SmallVector::iterator MI = I+1, - ME = DbgValues.end(); MI != ME; ++MI) { - const MDNode *Var = - (*MI)->getOperand((*MI)->getNumOperands()-1).getMetadata(); - if (Var == DV) - MultipleValues.push_back(*MI); - } + // History contains relevant DBG_VALUE instructions for Var and instructions + // clobbering it. + SmallVectorImpl &History = DbgValues[Var]; + if (History.empty()) + continue; + const MachineInstr *MInsn = History.front(); + DIVariable DV(Var); DbgScope *Scope = NULL; if (DV.getTag() == dwarf::DW_TAG_arg_variable && DISubprogram(DV.getContext()).describes(MF->getFunction())) @@ -2451,6 +2434,7 @@ continue; Processed.insert(DV); + assert(MInsn->isDebugValue() && "History must begin with debug value"); DbgVariable *RegVar = new DbgVariable(DV); if (!addCurrentFnArgument(MF, RegVar, Scope)) Scope->addVariable(RegVar); @@ -2458,21 +2442,21 @@ DbgVariableToDbgInstMap[AbsVar] = MInsn; VarToAbstractVarMap[RegVar] = AbsVar; } - if (MultipleValues.size() <= 1 && !RegClobberInsn.count(MInsn)) { + + // Simple ranges that are fully coalesced. + if (History.size() <= 1 || (History.size() == 2 && + MInsn->isIdenticalTo(History.back()))) { DbgVariableToDbgInstMap[RegVar] = MInsn; continue; } // handle multiple DBG_VALUE instructions describing one variable. - if (DotDebugLocEntries.empty()) - RegVar->setDotDebugLocOffset(0); - else - RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); + RegVar->setDotDebugLocOffset(DotDebugLocEntries.size()); - for (SmallVector::iterator - MVI = MultipleValues.begin(), MVE = MultipleValues.end(); - MVI != MVE; ++MVI) { - const MachineInstr *Begin = *MVI; + for (SmallVectorImpl::const_iterator + HI = History.begin(), HE = History.end(); HI != HE; ++HI) { + const MachineInstr *Begin = *HI; + assert(Begin->isDebugValue() && "Invalid History entry"); MachineLocation MLoc; if (Begin->getNumOperands() == 3) { if (Begin->getOperand(0).isReg() && Begin->getOperand(1).isImm()) @@ -2480,6 +2464,7 @@ } else MLoc = Asm->getDebugValueLocation(Begin); + // FIXME: emitDebugLoc only understands registers. if (!MLoc.getReg()) continue; @@ -2487,17 +2472,23 @@ const MCSymbol *FLabel = getLabelBeforeInsn(Begin); const MCSymbol *SLabel = 0; - if (const MachineInstr *ClobberMI = RegClobberInsn.lookup(Begin)) - // The register range starting at Begin may be clobbered. - SLabel = getLabelAfterInsn(ClobberMI); - else if (MVI + 1 == MVE) - // If Begin is the last instruction then its value is valid + if (HI + 1 == HE) + // If Begin is the last instruction in History then its value is valid // until the end of the funtion. SLabel = FunctionEndSym; - else - // The value is valid until the next DBG_VALUE. - SLabel = getLabelBeforeInsn(MVI[1]); + else { + const MachineInstr *End = HI[1]; + if (End->isDebugValue()) + SLabel = getLabelBeforeInsn(End); + else { + // End is a normal instruction clobbering the range. + SLabel = getLabelAfterInsn(End); + assert(SLabel && "Forgot label after clobber instruction"); + ++HI; + } + } + // The value is valid until the next DBG_VALUE or clobber. DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); } DotDebugLocEntries.push_back(DotDebugLocEntry()); @@ -2519,21 +2510,14 @@ /// getLabelBeforeInsn - Return Label preceding the instruction. const MCSymbol *DwarfDebug::getLabelBeforeInsn(const MachineInstr *MI) { - DenseMap::iterator I = - LabelsBeforeInsn.find(MI); - if (I == LabelsBeforeInsn.end()) - // FunctionBeginSym always preceeds all the instruction in current function. - return FunctionBeginSym; - return I->second; + MCSymbol *Label = LabelsBeforeInsn.lookup(MI); + assert(Label && "Didn't insert label before instruction"); + return Label; } /// getLabelAfterInsn - Return Label immediately following the instruction. const MCSymbol *DwarfDebug::getLabelAfterInsn(const MachineInstr *MI) { - DenseMap::iterator I = - LabelsAfterInsn.find(MI); - if (I == LabelsAfterInsn.end()) - return NULL; - return I->second; + return LabelsAfterInsn.lookup(MI); } /// beginInstruction - Process beginning of an instruction. @@ -2552,14 +2536,22 @@ } // Insert labels where requested. - if (!InsnNeedsLabel.count(MI)) + DenseMap::iterator I = + LabelsBeforeInsn.find(MI); + + // No label needed. + if (I == LabelsBeforeInsn.end()) + return; + + // Label already assigned. + if (I->second) return; if (!PrevLabel) { PrevLabel = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(PrevLabel); } - LabelsBeforeInsn[MI] = PrevLabel; + I->second = PrevLabel; } /// endInstruction - Process end of an instruction. @@ -2569,7 +2561,15 @@ if (!MI->isDebugValue()) PrevLabel = 0; - if (!InsnsNeedsLabelAfter.count(MI)) + DenseMap::iterator I = + LabelsAfterInsn.find(MI); + + // No label needed. + if (I == LabelsAfterInsn.end()) + return; + + // Label already assigned. + if (I->second) return; // We need a label after this instruction. @@ -2577,7 +2577,7 @@ PrevLabel = MMI->getContext().CreateTempSymbol(); Asm->OutStreamer.EmitLabel(PrevLabel); } - LabelsAfterInsn[MI] = PrevLabel; + I->second = PrevLabel; } /// getOrCreateDbgScope - Create DbgScope for the scope. @@ -2837,8 +2837,8 @@ RE = Ranges.end(); RI != RE; ++RI) { assert(RI->first && "DbgRange does not have first instruction!"); assert(RI->second && "DbgRange does not have second instruction!"); - InsnNeedsLabel.insert(RI->first); - InsnsNeedsLabelAfter.insert(RI->second); + requestLabelBeforeInsn(RI->first); + requestLabelAfterInsn(RI->second); } } } @@ -2916,46 +2916,78 @@ recordSourceLine(Line, Col, TheScope); + assert(UserVariables.empty() && DbgValues.empty() && "Maps weren't cleaned"); + /// ProcessedArgs - Collection of arguments already processed. SmallPtrSet ProcessedArgs; - /// LastDbgValue - Refer back to the last DBG_VALUE instruction to mention MD. - DenseMap LastDbgValue; - const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); /// LiveUserVar - Map physreg numbers to the MDNode they contain. std::vector LiveUserVar(TRI->getNumRegs()); for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); - I != E; ++I) + I != E; ++I) { + bool AtBlockEntry = true; for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); II != IE; ++II) { const MachineInstr *MI = II; - DebugLoc DL = MI->getDebugLoc(); + if (MI->isDebugValue()) { assert (MI->getNumOperands() > 1 && "Invalid machine instruction!"); - // Keep track of variables in registers. + // Keep track of user variables. const MDNode *Var = MI->getOperand(MI->getNumOperands() - 1).getMetadata(); - LastDbgValue[Var] = MI; + + // Variable is in a register, we need to check for clobbers. if (isDbgValueInDefinedReg(MI)) LiveUserVar[MI->getOperand(0).getReg()] = Var; - DIVariable DV(Var); - if (!DV.Verify()) continue; - // If DBG_VALUE is for a local variable then it needs a label. - if (DV.getTag() != dwarf::DW_TAG_arg_variable) - InsnNeedsLabel.insert(MI); - // DBG_VALUE for inlined functions argument needs a label. - else if (!DISubprogram(getDISubprogram(DV.getContext())). - describes(MF->getFunction())) - InsnNeedsLabel.insert(MI); - // DBG_VALUE indicating argument location change needs a label. - else if (!ProcessedArgs.insert(DV)) - InsnNeedsLabel.insert(MI); + // Check the history of this variable. + SmallVectorImpl &History = DbgValues[Var]; + if (History.empty()) { + UserVariables.push_back(Var); + // The first mention of a function argument gets the FunctionBeginSym + // label, so arguments are visible when breaking at function entry. + DIVariable DV(Var); + if (DV.Verify() && DV.getTag() == dwarf::DW_TAG_arg_variable && + DISubprogram(getDISubprogram(DV.getContext())) + .describes(MF->getFunction())) + LabelsBeforeInsn[MI] = FunctionBeginSym; + } else { + // We have seen this variable before. Try to coalesce DBG_VALUEs. + const MachineInstr *Prev = History.back(); + if (Prev->isDebugValue()) { + // Coalesce identical entries at the end of History. + if (History.size() >= 2 && + Prev->isIdenticalTo(History[History.size() - 2])) + History.pop_back(); + + // Terminate old register assignments that don't reach MI; + MachineFunction::const_iterator PrevMBB = Prev->getParent(); + if (PrevMBB != I && (!AtBlockEntry || llvm::next(PrevMBB) != I) && + isDbgValueInDefinedReg(Prev)) { + // Previous register assignment needs to terminate at the end of + // its basic block. + MachineBasicBlock::const_iterator LastMI = + PrevMBB->getLastNonDebugInstr(); + if (LastMI == PrevMBB->end()) + // Drop DBG_VALUE for empty range. + History.pop_back(); + else { + // Terminate after LastMI. + History.push_back(LastMI); + } + } + } + } + History.push_back(MI); } else { + // Not a DBG_VALUE instruction. + if (!MI->isLabel()) + AtBlockEntry = false; + // Check if the instruction clobbers any registers with debug vars. for (MachineInstr::const_mop_iterator MOI = MI->operands_begin(), MOE = MI->operands_end(); MOI != MOE; ++MOI) { @@ -2970,19 +3002,57 @@ LiveUserVar[Reg] = 0; // Was MD last defined by a DBG_VALUE referring to Reg? - const MachineInstr *Last = LastDbgValue.lookup(Var); - if (!Last || Last->getParent() != MI->getParent()) + DbgValueHistoryMap::iterator HistI = DbgValues.find(Var); + if (HistI == DbgValues.end()) continue; - if (!isDbgValueInDefinedReg(Last) || - Last->getOperand(0).getReg() != Reg) + SmallVectorImpl &History = HistI->second; + if (History.empty()) continue; - // MD is clobbered. Make sure the next instruction gets a label. - InsnsNeedsLabelAfter.insert(MI); - RegClobberInsn[Last] = MI; + const MachineInstr *Prev = History.back(); + // Sanity-check: Register assignments are terminated at the end of + // their block. + if (!Prev->isDebugValue() || Prev->getParent() != MI->getParent()) + continue; + // Is the variable still in Reg? + if (!isDbgValueInDefinedReg(Prev) || + Prev->getOperand(0).getReg() != Reg) + continue; + // Var is clobbered. Make sure the next instruction gets a label. + History.push_back(MI); } } } } + } + + for (DbgValueHistoryMap::iterator I = DbgValues.begin(), E = DbgValues.end(); + I != E; ++I) { + SmallVectorImpl &History = I->second; + if (History.empty()) + continue; + + // Make sure the final register assignments are terminated. + const MachineInstr *Prev = History.back(); + if (Prev->isDebugValue() && isDbgValueInDefinedReg(Prev)) { + const MachineBasicBlock *PrevMBB = Prev->getParent(); + MachineBasicBlock::const_iterator LastMI = PrevMBB->getLastNonDebugInstr(); + if (LastMI == PrevMBB->end()) + // Drop DBG_VALUE for empty range. + History.pop_back(); + else { + // Terminate after LastMI. + History.push_back(LastMI); + } + } + // Request labels for the full history. + for (unsigned i = 0, e = History.size(); i != e; ++i) { + const MachineInstr *MI = History[i]; + if (MI->isDebugValue()) + requestLabelBeforeInsn(MI); + else + requestLabelAfterInsn(MI); + } + } PrevInstLoc = DebugLoc(); PrevLabel = FunctionBeginSym; @@ -3043,13 +3113,12 @@ // Clear debug info CurrentFnDbgScope = NULL; CurrentFnArguments.clear(); - InsnNeedsLabel.clear(); DbgVariableToFrameIndexMap.clear(); VarToAbstractVarMap.clear(); DbgVariableToDbgInstMap.clear(); DeleteContainerSeconds(DbgScopeMap); - InsnsNeedsLabelAfter.clear(); - RegClobberInsn.clear(); + UserVariables.clear(); + DbgValues.clear(); ConcreteScopes.clear(); DeleteContainerSeconds(AbstractScopes); AbstractScopesList.clear(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=128327&r1=128326&r2=128327&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Fri Mar 25 21:19:36 2011 @@ -218,19 +218,16 @@ /// instruction. DenseMap LabelsAfterInsn; - /// insnNeedsLabel - Collection of instructions that need a label to mark - /// a debuggging information entity. - SmallPtrSet InsnNeedsLabel; - - /// InsnsNeedsLabelAfter - Collection of instructions that need a label after - /// the instruction because they end a scope of clobber a register. - SmallPtrSet InsnsNeedsLabelAfter; - - /// RegClobberInsn - For each DBG_VALUE instruction referring to a register - /// that is clobbered before the variable gets a new DBG_VALUE, map the - /// instruction that clobbered the register. This instruction will also be in - /// InsnsNeedsLabelAfter. - DenseMap RegClobberInsn; + /// UserVariables - Every user variable mentioned by a DBG_VALUE instruction + /// in order of appearance. + SmallVector UserVariables; + + /// DbgValues - For each user variable, keep a list of DBG_VALUE + /// instructions in order. The list can also contain normal instructions that + /// clobber the previous DBG_VALUE. + typedef DenseMap > + DbgValueHistoryMap; + DbgValueHistoryMap DbgValues; SmallVector DebugRangeSymbols; @@ -570,6 +567,23 @@ /// side table maintained by MMI. void collectVariableInfoFromMMITable(const MachineFunction * MF, SmallPtrSet &P); + + /// requestLabelBeforeInsn - Ensure that a label will be emitted before MI. + void requestLabelBeforeInsn(const MachineInstr *MI) { + LabelsBeforeInsn.insert(std::make_pair(MI, (MCSymbol*)0)); + } + + /// getLabelBeforeInsn - Return Label preceding the instruction. + const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); + + /// requestLabelAfterInsn - Ensure that a label will be emitted after MI. + void requestLabelAfterInsn(const MachineInstr *MI) { + LabelsAfterInsn.insert(std::make_pair(MI, (MCSymbol*)0)); + } + + /// getLabelAfterInsn - Return Label immediately following the instruction. + const MCSymbol *getLabelAfterInsn(const MachineInstr *MI); + public: //===--------------------------------------------------------------------===// // Main entry points. @@ -593,12 +607,6 @@ /// void endFunction(const MachineFunction *MF); - /// getLabelBeforeInsn - Return Label preceding the instruction. - const MCSymbol *getLabelBeforeInsn(const MachineInstr *MI); - - /// getLabelAfterInsn - Return Label immediately following the instruction. - const MCSymbol *getLabelAfterInsn(const MachineInstr *MI); - /// beginInstruction - Process beginning of an instruction. void beginInstruction(const MachineInstr *MI); Modified: llvm/trunk/test/CodeGen/X86/dbg-merge-loc-entry.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-merge-loc-entry.ll?rev=128327&r1=128326&r2=128327&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-merge-loc-entry.ll (original) +++ llvm/trunk/test/CodeGen/X86/dbg-merge-loc-entry.ll Fri Mar 25 21:19:36 2011 @@ -4,7 +4,7 @@ ;CHECK: Ldebug_loc0: ;CHECK-NEXT: .quad Lfunc_begin0 -;CHECK-NEXT: .quad Lfunc_end0 +;CHECK-NEXT: .quad L ;CHECK-NEXT: .short 1 ## Loc expr size ;CHECK-NEXT: .byte 85 ## DW_OP_reg5 ;CHECK-NEXT: .quad 0 From dgregor at apple.com Fri Mar 25 22:40:01 2011 From: dgregor at apple.com (Douglas Gregor) Date: Sat, 26 Mar 2011 03:40:01 -0000 Subject: [llvm-commits] [llvm] r128330 - /llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Message-ID: <20110326034001.6BE832A6C12C@llvm.org> Author: dgregor Date: Fri Mar 25 22:40:01 2011 New Revision: 128330 URL: http://llvm.org/viewvc/llvm-project?rev=128330&view=rev Log: Extend Clang's TableGen emitter for attributes to support bool arguments. Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=128330&r1=128329&r2=128330&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Fri Mar 25 22:40:01 2011 @@ -477,6 +477,8 @@ Ptr = new SimpleArgument(Arg, Attr, "FunctionDecl *"); else if (ArgName == "IdentifierArgument") Ptr = new SimpleArgument(Arg, Attr, "IdentifierInfo *"); + else if (ArgName == "BoolArgument") Ptr = new SimpleArgument(Arg, Attr, + "bool"); else if (ArgName == "IntArgument") Ptr = new SimpleArgument(Arg, Attr, "int"); else if (ArgName == "StringArgument") Ptr = new StringArgument(Arg, Attr); else if (ArgName == "TypeArgument") From zwarich at apple.com Fri Mar 25 23:58:50 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Sat, 26 Mar 2011 04:58:50 -0000 Subject: [llvm-commits] [llvm] r128331 - in /llvm/trunk: lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/vector_promote.ll Message-ID: <20110326045850.F044D2A6C12C@llvm.org> Author: zwarich Date: Fri Mar 25 23:58:50 2011 New Revision: 128331 URL: http://llvm.org/viewvc/llvm-project?rev=128331&view=rev Log: Fix a typo and add a test. Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll Modified: llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=128331&r1=128330&r2=128331&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Mar 25 23:58:50 2011 @@ -380,7 +380,7 @@ return true; const Type *ElementTy = cast(VectorTy)->getElementType(); - const Type *InElementTy = cast(VectorTy)->getElementType(); + const Type *InElementTy = cast(VInTy)->getElementType(); // Do not allow mixed integer and floating-point accesses from vectors of // different sizes. Modified: llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll?rev=128331&r1=128330&r2=128331&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll (original) +++ llvm/trunk/test/Transforms/ScalarRepl/vector_promote.ll Fri Mar 25 23:58:50 2011 @@ -187,3 +187,18 @@ ; CHECK: extractelement <4 x i128> ; CHECK: insertelement <4 x i128> } + +define float @test13(<4 x float> %x, <2 x i32> %y) { + %a = alloca <4 x float> + store <4 x float> %x, <4 x float>* %a + %p = bitcast <4 x float>* %a to <2 x float>* + %b = load <2 x float>* %p + %q = getelementptr <4 x float>* %a, i32 0, i32 2 + %c = load float* %q + %r = bitcast <4 x float>* %a to <2 x i32>* + store <2 x i32> %y, <2 x i32>* %r + ret float %c +; CHECK: @test13 +; CHECK-NOT: alloca +; CHECK: bitcast <4 x float> %x to i128 +} From isanbard at gmail.com Sat Mar 26 03:02:59 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 08:02:59 -0000 Subject: [llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <20110326080259.683482A6C12D@llvm.org> Author: void Date: Sat Mar 26 03:02:59 2011 New Revision: 128332 URL: http://llvm.org/viewvc/llvm-project?rev=128332&view=rev Log: Rework the logic that determines if a store completely overlaps an ealier store. There are two ways that a later store can comletely overlap a previous store: 1. They both start at the same offset, but the earlier store's size is <= the later's size, or 2. The earlier store's offset is > the later's offset, but it's offset + size doesn't extend past the later's offset + size. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128332&r1=128331&r2=128332&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 03:02:59 2011 @@ -340,26 +340,34 @@ // Okay, we have stores to two completely different pointers. Try to // decompose the pointer into a "base + constant_offset" form. If the base // pointers are equal, then we can reason about the two stores. - int64_t Off1 = 0, Off2 = 0; - const Value *BP1 = GetPointerBaseWithConstantOffset(P1, Off1, TD); - const Value *BP2 = GetPointerBaseWithConstantOffset(P2, Off2, TD); + int64_t EarlierOff = 0, LaterOff = 0; + const Value *BP1 = GetPointerBaseWithConstantOffset(P1, EarlierOff, TD); + const Value *BP2 = GetPointerBaseWithConstantOffset(P2, LaterOff, TD); // If the base pointers still differ, we have two completely different stores. if (BP1 != BP2) return false; - - // Otherwise, we might have a situation like: - // store i16 -> P + 1 Byte - // store i32 -> P - // In this case, we see if the later store completely overlaps all bytes - // stored by the previous store. - if (Off1 < Off2 || // Earlier starts before Later. - Off2 < 0 || // Later is -. - Off1+Earlier.Size > Off2+Later.Size) // Earlier goes beyond Later. - return false; - // Otherwise, we have complete overlap. - return true; + // The later store completely overlaps the earlier store if: + // + // 1. Both start at the same offset and the later one's size is greater than + // or equal to the earlier one's, or + // + // |--earlier--| + // |-- later --| + // + // 2. The earlier store has an offset greater than the later offset, but which + // still lies completely within the later store. + // + // |--earlier--| + // |----- later ------| + if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || + (EarlierOff > LaterOff && + EarlierOff + Earlier.Size <= LaterOff + Later.Size)) + return true; + + // Otherwise, they don't completely overlap. + return false; } /// isPossibleSelfRead - If 'Inst' might be a self read (i.e. a noop copy of a From zwarich at apple.com Sat Mar 26 03:12:02 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Sat, 26 Mar 2011 01:12:02 -0700 Subject: [llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <20110326080259.683482A6C12D@llvm.org> References: <20110326080259.683482A6C12D@llvm.org> Message-ID: <0A09A577-6114-4826-9BB2-56BA1DF2D463@apple.com> Test? Cameron On 2011-03-26, at 1:02 AM, Bill Wendling wrote: > Author: void > Date: Sat Mar 26 03:02:59 2011 > New Revision: 128332 > > URL: http://llvm.org/viewvc/llvm-project?rev=128332&view=rev > Log: > Rework the logic that determines if a store completely overlaps an ealier store. > > There are two ways that a later store can comletely overlap a previous store: > > 1. They both start at the same offset, but the earlier store's size is <= the > later's size, or > 2. The earlier store's offset is > the later's offset, but it's offset + size > doesn't extend past the later's offset + size. > > Modified: > llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128332&r1=128331&r2=128332&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 03:02:59 2011 > @@ -340,26 +340,34 @@ > // Okay, we have stores to two completely different pointers. Try to > // decompose the pointer into a "base + constant_offset" form. If the base > // pointers are equal, then we can reason about the two stores. > - int64_t Off1 = 0, Off2 = 0; > - const Value *BP1 = GetPointerBaseWithConstantOffset(P1, Off1, TD); > - const Value *BP2 = GetPointerBaseWithConstantOffset(P2, Off2, TD); > + int64_t EarlierOff = 0, LaterOff = 0; > + const Value *BP1 = GetPointerBaseWithConstantOffset(P1, EarlierOff, TD); > + const Value *BP2 = GetPointerBaseWithConstantOffset(P2, LaterOff, TD); > > // If the base pointers still differ, we have two completely different stores. > if (BP1 != BP2) > return false; > - > - // Otherwise, we might have a situation like: > - // store i16 -> P + 1 Byte > - // store i32 -> P > - // In this case, we see if the later store completely overlaps all bytes > - // stored by the previous store. > - if (Off1 < Off2 || // Earlier starts before Later. > - Off2 < 0 || // Later is -. > - Off1+Earlier.Size > Off2+Later.Size) // Earlier goes beyond Later. > - return false; > > - // Otherwise, we have complete overlap. > - return true; > + // The later store completely overlaps the earlier store if: > + // > + // 1. Both start at the same offset and the later one's size is greater than > + // or equal to the earlier one's, or > + // > + // |--earlier--| > + // |-- later --| > + // > + // 2. The earlier store has an offset greater than the later offset, but which > + // still lies completely within the later store. > + // > + // |--earlier--| > + // |----- later ------| > + if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || > + (EarlierOff > LaterOff && > + EarlierOff + Earlier.Size <= LaterOff + Later.Size)) > + return true; > + > + // Otherwise, they don't completely overlap. > + return false; > } > > /// isPossibleSelfRead - If 'Inst' might be a self read (i.e. a noop copy of a > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From fvbommel at gmail.com Sat Mar 26 03:20:34 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Sat, 26 Mar 2011 09:20:34 +0100 Subject: [llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <20110326080259.683482A6C12D@llvm.org> References: <20110326080259.683482A6C12D@llvm.org> Message-ID: On Sat, Mar 26, 2011 at 9:02 AM, Bill Wendling wrote: > + ?// The later store completely overlaps the earlier store if: > + ?// > + ?// 1. Both start at the same offset and the later one's size is greater than > + ?// ? ?or equal to the earlier one's, or > + ?// > + ?// ? ? ?|--earlier--| > + ?// ? ? ?|-- ? later ? --| > + ?// > + ?// 2. The earlier store has an offset greater than the later offset, but which > + ?// ? ?still lies completely within the later store. > + ?// > + ?// ? ? ? ?|--earlier--| > + ?// ? ?|----- ?later ?------| > + ?if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || > + ? ? ?(EarlierOff > LaterOff && > + ? ? ? EarlierOff + Earlier.Size <= LaterOff + Later.Size)) This simplifies to if (EarlierOff >= LaterOff && EarlierOff + Earlier.Size <= LaterOff + Later.Size) since adding an equal offset on both sides of a comparison doesn't change its result. > There are two ways that a later store can comletely overlap a previous store: So I guess there's really only *one* way the later store can completely overlap the first :). From isanbard at gmail.com Sat Mar 26 04:31:18 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 02:31:18 -0700 Subject: [llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <0A09A577-6114-4826-9BB2-56BA1DF2D463@apple.com> References: <20110326080259.683482A6C12D@llvm.org> <0A09A577-6114-4826-9BB2-56BA1DF2D463@apple.com> Message-ID: <549760E9-90C3-42E7-AC57-B5080B426A25@gmail.com> It was added earlier (see r128319). And there's all ready a test directory for DSE. -bw On Mar 26, 2011, at 1:12 AM, Cameron Zwarich wrote: > Test? > > Cameron > > On 2011-03-26, at 1:02 AM, Bill Wendling wrote: > >> Author: void >> Date: Sat Mar 26 03:02:59 2011 >> New Revision: 128332 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=128332&view=rev >> Log: >> Rework the logic that determines if a store completely overlaps an ealier store. >> >> There are two ways that a later store can comletely overlap a previous store: >> >> 1. They both start at the same offset, but the earlier store's size is <= the >> later's size, or >> 2. The earlier store's offset is > the later's offset, but it's offset + size >> doesn't extend past the later's offset + size. >> >> Modified: >> llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp >> >> Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128332&r1=128331&r2=128332&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 03:02:59 2011 >> @@ -340,26 +340,34 @@ >> // Okay, we have stores to two completely different pointers. Try to >> // decompose the pointer into a "base + constant_offset" form. If the base >> // pointers are equal, then we can reason about the two stores. >> - int64_t Off1 = 0, Off2 = 0; >> - const Value *BP1 = GetPointerBaseWithConstantOffset(P1, Off1, TD); >> - const Value *BP2 = GetPointerBaseWithConstantOffset(P2, Off2, TD); >> + int64_t EarlierOff = 0, LaterOff = 0; >> + const Value *BP1 = GetPointerBaseWithConstantOffset(P1, EarlierOff, TD); >> + const Value *BP2 = GetPointerBaseWithConstantOffset(P2, LaterOff, TD); >> >> // If the base pointers still differ, we have two completely different stores. >> if (BP1 != BP2) >> return false; >> - >> - // Otherwise, we might have a situation like: >> - // store i16 -> P + 1 Byte >> - // store i32 -> P >> - // In this case, we see if the later store completely overlaps all bytes >> - // stored by the previous store. >> - if (Off1 < Off2 || // Earlier starts before Later. >> - Off2 < 0 || // Later is -. >> - Off1+Earlier.Size > Off2+Later.Size) // Earlier goes beyond Later. >> - return false; >> >> - // Otherwise, we have complete overlap. >> - return true; >> + // The later store completely overlaps the earlier store if: >> + // >> + // 1. Both start at the same offset and the later one's size is greater than >> + // or equal to the earlier one's, or >> + // >> + // |--earlier--| >> + // |-- later --| >> + // >> + // 2. The earlier store has an offset greater than the later offset, but which >> + // still lies completely within the later store. >> + // >> + // |--earlier--| >> + // |----- later ------| >> + if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || >> + (EarlierOff > LaterOff && >> + EarlierOff + Earlier.Size <= LaterOff + Later.Size)) >> + return true; >> + >> + // Otherwise, they don't completely overlap. >> + return false; >> } >> >> /// isPossibleSelfRead - If 'Inst' might be a self read (i.e. a noop copy of a >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From isanbard at gmail.com Sat Mar 26 04:34:12 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 02:34:12 -0700 Subject: [llvm-commits] [llvm] r128332 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: References: <20110326080259.683482A6C12D@llvm.org> Message-ID: <2602EBFC-86CD-423C-85A4-0D45C2C3CFCF@gmail.com> On Mar 26, 2011, at 1:20 AM, Frits van Bommel wrote: > On Sat, Mar 26, 2011 at 9:02 AM, Bill Wendling wrote: >> + // The later store completely overlaps the earlier store if: >> + // >> + // 1. Both start at the same offset and the later one's size is greater than >> + // or equal to the earlier one's, or >> + // >> + // |--earlier--| >> + // |-- later --| >> + // >> + // 2. The earlier store has an offset greater than the later offset, but which >> + // still lies completely within the later store. >> + // >> + // |--earlier--| >> + // |----- later ------| >> + if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || >> + (EarlierOff > LaterOff && >> + EarlierOff + Earlier.Size <= LaterOff + Later.Size)) > > This simplifies to > > if (EarlierOff >= LaterOff && EarlierOff + Earlier.Size <= > LaterOff + Later.Size) > > since adding an equal offset on both sides of a comparison doesn't > change its result. > Sure. I knew it could be simplified, but I wanted to keep the logic simple because it was hard for me to follow in the first place. :) I can change it though. >> There are two ways that a later store can comletely overlap a previous store: > > So I guess there's really only *one* way the later store can > completely overlap the first :). > If you want to get technical about it. ;-) -bw From isanbard at gmail.com Sat Mar 26 04:32:07 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 09:32:07 -0000 Subject: [llvm-commits] [llvm] r128333 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Message-ID: <20110326093207.F321E2A6C12C@llvm.org> Author: void Date: Sat Mar 26 04:32:07 2011 New Revision: 128333 URL: http://llvm.org/viewvc/llvm-project?rev=128333&view=rev Log: Simplification noticed by Frits. Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128333&r1=128332&r2=128333&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 04:32:07 2011 @@ -361,9 +361,8 @@ // // |--earlier--| // |----- later ------| - if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || - (EarlierOff > LaterOff && - EarlierOff + Earlier.Size <= LaterOff + Later.Size)) + if (EarlierOff >= LaterOff && + EarlierOff + Earlier.Size <= LaterOff + Later.Size) return true; // Otherwise, they don't completely overlap. From benny.kra at googlemail.com Sat Mar 26 07:38:19 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 26 Mar 2011 12:38:19 -0000 Subject: [llvm-commits] [llvm] r128338 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20110326123819.520932A6C12C@llvm.org> Author: d0k Date: Sat Mar 26 07:38:19 2011 New Revision: 128338 URL: http://llvm.org/viewvc/llvm-project?rev=128338&view=rev Log: Make helper static. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=128338&r1=128337&r2=128338&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Mar 26 07:38:19 2011 @@ -3891,8 +3891,8 @@ /// getShuffleScalarElt - Returns the scalar element that will make up the ith /// element of the result of the vector shuffle. -SDValue getShuffleScalarElt(SDNode *N, int Index, SelectionDAG &DAG, - unsigned Depth) { +static SDValue getShuffleScalarElt(SDNode *N, int Index, SelectionDAG &DAG, + unsigned Depth) { if (Depth == 6) return SDValue(); // Limit search depth. From gohman at apple.com Sat Mar 26 10:39:25 2011 From: gohman at apple.com (Dan Gohman) Date: Sat, 26 Mar 2011 08:39:25 -0700 Subject: [llvm-commits] [llvm] r128333 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <20110326093207.F321E2A6C12C@llvm.org> References: <20110326093207.F321E2A6C12C@llvm.org> Message-ID: <689909C8-632D-42DC-81DD-310B056D372D@apple.com> On Mar 26, 2011, at 2:32 AM, Bill Wendling wrote: > Author: void > Date: Sat Mar 26 04:32:07 2011 > New Revision: 128333 > > URL: http://llvm.org/viewvc/llvm-project?rev=128333&view=rev > Log: > Simplification noticed by Frits. > > Modified: > llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > > Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=128333&r1=128332&r2=128333&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Sat Mar 26 04:32:07 2011 > @@ -361,9 +361,8 @@ > // > // |--earlier--| > // |----- later ------| > - if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || > - (EarlierOff > LaterOff && > - EarlierOff + Earlier.Size <= LaterOff + Later.Size)) > + if (EarlierOff >= LaterOff && > + EarlierOff + Earlier.Size <= LaterOff + Later.Size) > return true; I don't have time to fully investigate, but the testcase passes without the fix, and the new code is now equivalent by De Morgan's law to the old code. Dan From fvbommel at gmail.com Sat Mar 26 10:52:31 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Sat, 26 Mar 2011 16:52:31 +0100 Subject: [llvm-commits] [llvm] r128333 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: <689909C8-632D-42DC-81DD-310B056D372D@apple.com> References: <20110326093207.F321E2A6C12C@llvm.org> <689909C8-632D-42DC-81DD-310B056D372D@apple.com> Message-ID: On Sat, Mar 26, 2011 at 4:39 PM, Dan Gohman wrote: > On Mar 26, 2011, at 2:32 AM, Bill Wendling wrote: >> Simplification noticed by Frits. >> >> Modified: >> ? ?llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp >> - ?if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || >> - ? ? ?(EarlierOff > LaterOff && >> - ? ? ? EarlierOff + Earlier.Size <= LaterOff + Later.Size)) >> + ?if (EarlierOff >= LaterOff && >> + ? ? ?EarlierOff + Earlier.Size <= LaterOff + Later.Size) >> ? ? return true; > > I don't have time to fully investigate, but the testcase passes without the fix, What testcase? This commit doesn't have a testcase (and doesn't need one, given the next point). > and the new code is now equivalent by De Morgan's law to the old code. Hint: the commit message called it a "simplification" because it *is* equivalent (but simpler) code. I'm not sure where you're getting De Morgan's law from though, since there's no negation anywhere... (The only De Morgan's laws I know about are these: ) From benny.kra at googlemail.com Sat Mar 26 11:35:11 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 26 Mar 2011 16:35:11 -0000 Subject: [llvm-commits] [llvm] r128342 - in /llvm/trunk/lib/CodeGen/SelectionDAG: SelectionDAGBuilder.cpp SelectionDAGBuilder.h Message-ID: <20110326163511.2D3E42A6C12C@llvm.org> Author: d0k Date: Sat Mar 26 11:35:10 2011 New Revision: 128342 URL: http://llvm.org/viewvc/llvm-project?rev=128342&view=rev Log: Turn SelectionDAGBuilder::GetRegistersForValue into a local function. It couldn't be used outside of the file because SDISelAsmOperandInfo is local to SelectionDAGBuilder.cpp. Making it a static function avoids a weird linkage dance. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=128342&r1=128341&r2=128342&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Sat Mar 26 11:35:10 2011 @@ -50,7 +50,6 @@ #include "llvm/Target/TargetIntrinsicInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetOptions.h" -#include "llvm/Support/Compiler.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -5202,12 +5201,11 @@ LowerCallTo(&I, Callee, I.isTailCall()); } -namespace llvm { +namespace { /// AsmOperandInfo - This contains information for each constraint that we are /// lowering. -class LLVM_LIBRARY_VISIBILITY SDISelAsmOperandInfo : - public TargetLowering::AsmOperandInfo { +class SDISelAsmOperandInfo : public TargetLowering::AsmOperandInfo { public: /// CallOperand - If this is the result output operand or a clobber /// this is null, otherwise it is the incoming operand to the CallInst. @@ -5295,7 +5293,7 @@ typedef SmallVector SDISelAsmOperandInfoVector; -} // end llvm namespace. +} // end anonymous namespace /// isAllocatableRegister - If the specified register is safe to allocate, /// i.e. it isn't a stack pointer or some other special register, return the @@ -5354,11 +5352,13 @@ /// OpInfo describes the operand. /// Input and OutputRegs are the set of already allocated physical registers. /// -void SelectionDAGBuilder:: -GetRegistersForValue(SDISelAsmOperandInfo &OpInfo, - std::set &OutputRegs, - std::set &InputRegs) { - LLVMContext &Context = FuncInfo.Fn->getContext(); +static void GetRegistersForValue(SelectionDAG &DAG, + const TargetLowering &TLI, + DebugLoc DL, + SDISelAsmOperandInfo &OpInfo, + std::set &OutputRegs, + std::set &InputRegs) { + LLVMContext &Context = *DAG.getContext(); // Compute whether this value requires an input register, an output register, // or both. @@ -5404,7 +5404,7 @@ // vector types). EVT RegVT = *PhysReg.second->vt_begin(); if (RegVT.getSizeInBits() == OpInfo.ConstraintVT.getSizeInBits()) { - OpInfo.CallOperand = DAG.getNode(ISD::BITCAST, getCurDebugLoc(), + OpInfo.CallOperand = DAG.getNode(ISD::BITCAST, DL, RegVT, OpInfo.CallOperand); OpInfo.ConstraintVT = RegVT; } else if (RegVT.isInteger() && OpInfo.ConstraintVT.isFloatingPoint()) { @@ -5414,7 +5414,7 @@ // machine. RegVT = EVT::getIntegerVT(Context, OpInfo.ConstraintVT.getSizeInBits()); - OpInfo.CallOperand = DAG.getNode(ISD::BITCAST, getCurDebugLoc(), + OpInfo.CallOperand = DAG.getNode(ISD::BITCAST, DL, RegVT, OpInfo.CallOperand); OpInfo.ConstraintVT = RegVT; } @@ -5685,7 +5685,8 @@ // If this constraint is for a specific register, allocate it before // anything else. if (OpInfo.ConstraintType == TargetLowering::C_Register) - GetRegistersForValue(OpInfo, OutputRegs, InputRegs); + GetRegistersForValue(DAG, TLI, getCurDebugLoc(), OpInfo, OutputRegs, + InputRegs); } // Second pass - Loop over all of the operands, assigning virtual or physregs @@ -5696,7 +5697,8 @@ // C_Register operands have already been allocated, Other/Memory don't need // to be. if (OpInfo.ConstraintType == TargetLowering::C_RegisterClass) - GetRegistersForValue(OpInfo, OutputRegs, InputRegs); + GetRegistersForValue(DAG, TLI, getCurDebugLoc(), OpInfo, OutputRegs, + InputRegs); } // AsmNodeOperands - The operands for the ISD::INLINEASM node. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=128342&r1=128341&r2=128342&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Sat Mar 26 11:35:10 2011 @@ -60,7 +60,6 @@ class PHINode; class PtrToIntInst; class ReturnInst; -class SDISelAsmOperandInfo; class SDDbgValue; class SExtInst; class SelectInst; @@ -380,10 +379,6 @@ assert(N.getNode() == 0 && "Already set a value for this node!"); N = NewN; } - - void GetRegistersForValue(SDISelAsmOperandInfo &OpInfo, - std::set &OutputRegs, - std::set &InputRegs); void FindMergedConditions(const Value *Cond, MachineBasicBlock *TBB, MachineBasicBlock *FBB, MachineBasicBlock *CurBB, From stoklund at 2pi.dk Sat Mar 26 17:16:41 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 26 Mar 2011 22:16:41 -0000 Subject: [llvm-commits] [llvm] r128351 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp LiveRangeEdit.h Message-ID: <20110326221641.4F73D2A6C12C@llvm.org> Author: stoklund Date: Sat Mar 26 17:16:41 2011 New Revision: 128351 URL: http://llvm.org/viewvc/llvm-project?rev=128351&view=rev Log: Use individual register classes when spilling snippets. The main register class may have been inflated by live range splitting, so that register class is not necessarily valid for the snippet instructions. Use the original register class for the stack slot interval. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp llvm/trunk/lib/CodeGen/LiveRangeEdit.h Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=128351&r1=128350&r2=128351&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Sat Mar 26 17:16:41 2011 @@ -48,7 +48,7 @@ // Variables that are valid during spill(), but used by multiple methods. LiveRangeEdit *Edit; - const TargetRegisterClass *RC; + LiveInterval *StackInt; int StackSlot; unsigned Original; @@ -431,12 +431,12 @@ // Conservatively extend the stack slot range to the range of the original // value. We may be able to do better with stack slot coloring by being more // careful here. - LiveInterval &StackInt = LSS.getInterval(StackSlot); + assert(StackInt && "No stack slot assigned yet."); LiveInterval &OrigLI = LIS.getInterval(Original); VNInfo *OrigVNI = OrigLI.getVNInfoAt(Idx); - StackInt.MergeValueInAsValue(OrigLI, OrigVNI, StackInt.getValNumInfo(0)); + StackInt->MergeValueInAsValue(OrigLI, OrigVNI, StackInt->getValNumInfo(0)); DEBUG(dbgs() << "\tmerged orig valno " << OrigVNI->id << ": " - << StackInt << '\n'); + << *StackInt << '\n'); // Already spilled everywhere. if (SVI.AllDefsAreReloads) @@ -455,7 +455,8 @@ ++MII; } // Insert spill without kill flag immediately after def. - TII.storeRegToStackSlot(*MBB, MII, SVI.SpillReg, false, StackSlot, RC, &TRI); + TII.storeRegToStackSlot(*MBB, MII, SVI.SpillReg, false, StackSlot, + MRI.getRegClass(SVI.SpillReg), &TRI); --MII; // Point to store instruction. LIS.InsertMachineInstrInMaps(MII); VRM.addSpillSlotUse(StackSlot, MII); @@ -469,7 +470,7 @@ assert(VNI && "Missing value"); SmallVector, 8> WorkList; WorkList.push_back(std::make_pair(&SLI, VNI)); - LiveInterval &StackInt = LSS.getInterval(StackSlot); + assert(StackInt && "No stack slot assigned yet."); do { LiveInterval *LI; @@ -483,8 +484,8 @@ continue; // Add all of VNI's live range to StackInt. - StackInt.MergeValueInAsValue(*LI, VNI, StackInt.getValNumInfo(0)); - DEBUG(dbgs() << "Merged to stack int: " << StackInt << '\n'); + StackInt->MergeValueInAsValue(*LI, VNI, StackInt->getValNumInfo(0)); + DEBUG(dbgs() << "Merged to stack int: " << *StackInt << '\n'); // Find all spills and copies of VNI. for (MachineRegisterInfo::use_nodbg_iterator UI = MRI.use_nodbg_begin(Reg); @@ -723,7 +724,8 @@ MachineBasicBlock::iterator MI) { MachineBasicBlock &MBB = *MI->getParent(); SlotIndex Idx = LIS.getInstructionIndex(MI).getDefIndex(); - TII.loadRegFromStackSlot(MBB, MI, NewLI.reg, StackSlot, RC, &TRI); + TII.loadRegFromStackSlot(MBB, MI, NewLI.reg, StackSlot, + MRI.getRegClass(NewLI.reg), &TRI); --MI; // Point to load instruction. SlotIndex LoadIdx = LIS.InsertMachineInstrInMaps(MI).getDefIndex(); VRM.addSpillSlotUse(StackSlot, MI); @@ -744,7 +746,8 @@ assert(VNI && VNI->def.getDefIndex() == Idx && "Inconsistent VNInfo"); Idx = VNI->def; - TII.storeRegToStackSlot(MBB, ++MI, NewLI.reg, true, StackSlot, RC, &TRI); + TII.storeRegToStackSlot(MBB, ++MI, NewLI.reg, true, StackSlot, + MRI.getRegClass(NewLI.reg), &TRI); --MI; // Point to store instruction. SlotIndex StoreIdx = LIS.InsertMachineInstrInMaps(MI).getDefIndex(); VRM.addSpillSlotUse(StackSlot, MI); @@ -818,7 +821,7 @@ // Allocate interval around instruction. // FIXME: Infer regclass from instruction alone. - LiveInterval &NewLI = Edit->create(LIS, VRM); + LiveInterval &NewLI = Edit->createFrom(Reg, LIS, VRM); NewLI.markNotSpillable(); if (Reads) @@ -853,6 +856,7 @@ // Share a stack slot among all descendants of Original. Original = VRM.getOriginal(edit.getReg()); StackSlot = VRM.getStackSlot(Original); + StackInt = 0; DEBUG(dbgs() << "Inline spilling " << MRI.getRegClass(edit.getReg())->getName() @@ -870,22 +874,22 @@ if (Edit->getParent().empty()) return; - RC = MRI.getRegClass(edit.getReg()); - - if (StackSlot == VirtRegMap::NO_STACK_SLOT) + // Update LiveStacks now that we are committed to spilling. + if (StackSlot == VirtRegMap::NO_STACK_SLOT) { StackSlot = VRM.assignVirt2StackSlot(Original); + StackInt = &LSS.getOrCreateInterval(StackSlot, MRI.getRegClass(Original)); + StackInt->getNextValue(SlotIndex(), 0, LSS.getVNInfoAllocator()); + } else + StackInt = &LSS.getInterval(StackSlot); if (Original != edit.getReg()) VRM.assignVirt2StackSlot(edit.getReg(), StackSlot); - // Update LiveStacks now that we are committed to spilling. - LiveInterval &stacklvr = LSS.getOrCreateInterval(StackSlot, RC); - if (!stacklvr.hasAtLeastOneValue()) - stacklvr.getNextValue(SlotIndex(), 0, LSS.getVNInfoAllocator()); + assert(StackInt->getNumValNums() == 1 && "Bad stack interval values"); for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) - stacklvr.MergeRangesInAsValue(LIS.getInterval(RegsToSpill[i]), - stacklvr.getValNumInfo(0)); - DEBUG(dbgs() << "Merged spilled regs: " << stacklvr << '\n'); + StackInt->MergeRangesInAsValue(LIS.getInterval(RegsToSpill[i]), + StackInt->getValNumInfo(0)); + DEBUG(dbgs() << "Merged spilled regs: " << *StackInt << '\n'); // Spill around uses of all RegsToSpill. for (unsigned i = 0, e = RegsToSpill.size(); i != e; ++i) Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=128351&r1=128350&r2=128351&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original) +++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Sat Mar 26 17:16:41 2011 @@ -65,9 +65,6 @@ /// live range trimmed or entirely removed. SmallPtrSet rematted_; - /// createFrom - Create a new virtual register based on OldReg. - LiveInterval &createFrom(unsigned, LiveIntervals&, VirtRegMap &); - /// scanRemattable - Identify the parent_ values that may rematerialize. void scanRemattable(LiveIntervals &lis, const TargetInstrInfo &tii, @@ -113,6 +110,9 @@ return uselessRegs_; } + /// createFrom - Create a new virtual register based on OldReg. + LiveInterval &createFrom(unsigned OldReg, LiveIntervals&, VirtRegMap&); + /// create - Create a new register with the same class and original slot as /// parent. LiveInterval &create(LiveIntervals &LIS, VirtRegMap &VRM) { From isanbard at gmail.com Sat Mar 26 19:42:24 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sat, 26 Mar 2011 17:42:24 -0700 Subject: [llvm-commits] [llvm] r128333 - /llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp In-Reply-To: References: <20110326093207.F321E2A6C12C@llvm.org> <689909C8-632D-42DC-81DD-310B056D372D@apple.com> Message-ID: On Mar 26, 2011, at 8:52 AM, Frits van Bommel wrote: > On Sat, Mar 26, 2011 at 4:39 PM, Dan Gohman wrote: >> On Mar 26, 2011, at 2:32 AM, Bill Wendling wrote: >>> Simplification noticed by Frits. >>> >>> Modified: >>> llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp > >>> - if ((EarlierOff == LaterOff && Earlier.Size <= Later.Size) || >>> - (EarlierOff > LaterOff && >>> - EarlierOff + Earlier.Size <= LaterOff + Later.Size)) >>> + if (EarlierOff >= LaterOff && >>> + EarlierOff + Earlier.Size <= LaterOff + Later.Size) >>> return true; >> >> I don't have time to fully investigate, but the testcase passes without the fix, > > What testcase? This commit doesn't have a testcase (and doesn't need > one, given the next point). > >> and the new code is now equivalent by De Morgan's law to the old code. > > Hint: the commit message called it a "simplification" because it *is* > equivalent (but simpler) code. > > I'm not sure where you're getting De Morgan's law from though, since > there's no negation anywhere... > (The only De Morgan's laws I know about are these: > ) I think he means from what it originally was. The reason I'm messing with this code is because of PR9561. What I did is a De Morgan's change from the old code. But I disagree that the testcase passed before the previous change: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20110321/118574.html At least it didn't pass for me. :) -bw From isanbard at gmail.com Sat Mar 26 19:43:08 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 27 Mar 2011 00:43:08 -0000 Subject: [llvm-commits] [test-suite] r128358 - /test-suite/tags/RELEASE_29/rc3/ Message-ID: <20110327004308.53D562A6C12D@llvm.org> Author: void Date: Sat Mar 26 19:43:08 2011 New Revision: 128358 URL: http://llvm.org/viewvc/llvm-project?rev=128358&view=rev Log: Creating test-suite 2.9 release-candidate 3 Added: test-suite/tags/RELEASE_29/rc3/ (props changed) - copied from r128357, test-suite/branches/release_29/ Propchange: test-suite/tags/RELEASE_29/rc3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Mar 26 19:43:08 2011 @@ -0,0 +1,4 @@ +Makefile.config +config.log +config.status +mklib Propchange: test-suite/tags/RELEASE_29/rc3/ ------------------------------------------------------------------------------ svn:mergeinfo = /test-suite/trunk:128083,128270 From isanbard at gmail.com Sat Mar 26 19:46:34 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 27 Mar 2011 00:46:34 -0000 Subject: [llvm-commits] [test-suite] r128362 - /test-suite/tags/RELEASE_29/rc3/ Message-ID: <20110327004634.AADE92A6C12F@llvm.org> Author: void Date: Sat Mar 26 19:46:34 2011 New Revision: 128362 URL: http://llvm.org/viewvc/llvm-project?rev=128362&view=rev Log: Remove llvm-gcc-4.2 2.9 release-candidate 3 tag Removed: test-suite/tags/RELEASE_29/rc3/ From isanbard at gmail.com Sat Mar 26 20:17:38 2011 From: isanbard at gmail.com (Bill Wendling) Date: Sun, 27 Mar 2011 01:17:38 -0000 Subject: [llvm-commits] [test-suite] r128369 - /test-suite/tags/RELEASE_29/rc3/ Message-ID: <20110327011738.E0D7A2A6C12D@llvm.org> Author: void Date: Sat Mar 26 20:17:38 2011 New Revision: 128369 URL: http://llvm.org/viewvc/llvm-project?rev=128369&view=rev Log: Creating test-suite 2.9 release-candidate 3 Added: test-suite/tags/RELEASE_29/rc3/ (props changed) - copied from r128368, test-suite/branches/release_29/ Propchange: test-suite/tags/RELEASE_29/rc3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Mar 26 20:17:38 2011 @@ -0,0 +1,4 @@ +Makefile.config +config.log +config.status +mklib Propchange: test-suite/tags/RELEASE_29/rc3/ ------------------------------------------------------------------------------ svn:mergeinfo = /test-suite/trunk:128083,128270 From geek4civic at gmail.com Sat Mar 26 20:44:41 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Sun, 27 Mar 2011 01:44:41 -0000 Subject: [llvm-commits] [llvm] r128370 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp Message-ID: <20110327014441.237092A6C12C@llvm.org> Author: chapuni Date: Sat Mar 26 20:44:40 2011 New Revision: 128370 URL: http://llvm.org/viewvc/llvm-project?rev=128370&view=rev Log: Fix whitespace. Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=128370&r1=128369&r2=128370&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Mar 26 20:44:40 2011 @@ -844,13 +844,13 @@ OS << "0b"; for (unsigned j = 8; j--;) { unsigned Bit = (Code[i] >> j) & 1; - + unsigned FixupBit; if (getContext().getTargetAsmInfo().isLittleEndian()) FixupBit = i * 8 + j; else FixupBit = i * 8 + (7-j); - + if (uint8_t MapEntry = FixupMap[FixupBit]) { assert(Bit == 0 && "Encoder wrote into fixed up bit!"); OS << char('A' + MapEntry - 1); From nicholas at mxc.ca Sun Mar 27 02:30:57 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 27 Mar 2011 07:30:57 -0000 Subject: [llvm-commits] [llvm] r128373 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineSelect.cpp test/Transforms/InstCombine/select.ll Message-ID: <20110327073057.3E3242A6C12D@llvm.org> Author: nicholas Date: Sun Mar 27 02:30:57 2011 New Revision: 128373 URL: http://llvm.org/viewvc/llvm-project?rev=128373&view=rev Log: Add a small missed optimization: turn X == C ? X : Y into X == C ? C : Y. This removes one use of X which helps it pass the many hasOneUse() checks. In my analysis, this turns up very often where X = A >>exact B and that can't be simplified unless X has one use (except by increasing the lifetime of A which is generally a performance loss). Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/trunk/test/Transforms/InstCombine/select.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=128373&r1=128372&r2=128373&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Sun Mar 27 02:30:57 2011 @@ -424,6 +424,19 @@ return ReplaceInstUsesWith(SI, TrueVal); /// NOTE: if we wanted to, this is where to detect integer MIN/MAX } + + if (isa(CmpRHS)) { + if (CmpLHS == TrueVal && Pred == ICmpInst::ICMP_EQ) { + // Transform (X == C) ? X : Y -> (X == C) ? C : Y + SI.setOperand(1, CmpRHS); + Changed = true; + } else if (CmpLHS == FalseVal && Pred == ICmpInst::ICMP_NE) { + // Transform (X != C) ? Y : X -> (X != C) ? Y : C + SI.setOperand(2, CmpRHS); + Changed = true; + } + } + return Changed ? &SI : 0; } Modified: llvm/trunk/test/Transforms/InstCombine/select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select.ll?rev=128373&r1=128372&r2=128373&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/select.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/select.ll Sun Mar 27 02:30:57 2011 @@ -724,3 +724,16 @@ ; CHECK: select i1 %cmp ; CHECK: ret } + +define i32 @test54(i32 %X, i32 %Y) { + %A = ashr exact i32 %X, %Y + %B = icmp eq i32 %A, 0 + %C = select i1 %B, i32 %A, i32 1 + ret i32 %C +; CHECK: @test54 +; CHECK-NOT: ashr +; CHECK-NOT: select +; CHECK: icmp ne i32 %X, 0 +; CHECK: zext +; CHECK: ret +} From baldrick at free.fr Sun Mar 27 08:52:32 2011 From: baldrick at free.fr (Duncan Sands) Date: Sun, 27 Mar 2011 13:52:32 -0000 Subject: [llvm-commits] [llvm] r128378 - /llvm/trunk/utils/release/test-release.sh Message-ID: <20110327135232.44F902A6C12C@llvm.org> Author: baldrick Date: Sun Mar 27 08:52:32 2011 New Revision: 128378 URL: http://llvm.org/viewvc/llvm-project?rev=128378&view=rev Log: Partially revert commit 127155: I think it is much more convenient to have structured log files rather than one big file produced by piping output. Modified: llvm/trunk/utils/release/test-release.sh Modified: llvm/trunk/utils/release/test-release.sh URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/release/test-release.sh?rev=128378&r1=128377&r2=128378&view=diff ============================================================================== --- llvm/trunk/utils/release/test-release.sh (original) +++ llvm/trunk/utils/release/test-release.sh Sun Mar 27 08:52:32 2011 @@ -118,6 +118,11 @@ llvmCore_srcdir=$BuildDir/llvmCore-$Release-rc$RC.src llvmgcc42_srcdir=$BuildDir/llvmgcc42-$Release-rc$RC.src +# Location of log files. +LogDirName="$Release-rc$RC.logs" +LogDir=$BuildDir/$LogDirName +mkdir -p $LogDir + # SVN URLs for the sources. Base_url="http://llvm.org/svn/llvm-project" llvmCore_RC_url="$Base_url/llvm/tags/RELEASE_$Release_no_dot/rc$RC" @@ -196,7 +201,8 @@ $llvmCore_srcdir/configure --prefix=$InstallDir \ --enable-optimized=$Optimized \ --enable-assertions=$Assertions \ - --with-llvmgccdir=$llvmgccDir + --with-llvmgccdir=$llvmgccDir \ + > $LogDir/llvm.configure.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 cd - } @@ -217,11 +223,13 @@ cd $ObjDir echo "# Compiling llvm $Release-rc$RC $Flavor" echo "# make -j $NumJobs VERBOSE=1 $ExtraOpts" - make -j $NumJobs VERBOSE=1 $ExtraOpts $CompilerFlags + make -j $NumJobs VERBOSE=1 $ExtraOpts $CompilerFlags \ + > $LogDir/llvm.make.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 echo "# Installing llvm $Release-rc$RC $Flavor" echo "# make install" - make install + make install \ + > $LogDir/llvm.install.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 cd - } @@ -231,9 +239,12 @@ ObjDir="$3" cd $ObjDir - make check - make -C tools/clang test - make unittests + make check \ + > $LogDir/llvm.check.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 + make -C tools/clang test \ + > $LogDir/clang.check.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 + make unittests \ + > $LogDir/llvm.unittests.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 cd - } @@ -262,7 +273,8 @@ --enable-languages=$languages" $llvmgcc42_srcdir/configure --prefix=$InstallDir \ --program-prefix=llvm- --enable-llvm=$llvmObjDir \ - --enable-languages=$languages + --enable-languages=$languages \ + > $LogDir/llvm-gcc.configure.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 cd - } @@ -280,11 +292,13 @@ cd $ObjDir echo "# Compiling llvm-gcc $Release-rc$RC $Flavor" echo "# make -j $NumJobs bootstrap LLVM_VERSION_INFO=$Release" - make -j $NumJobs bootstrap LLVM_VERSION_INFO=$Release $CompilerFlags + make -j $NumJobs bootstrap LLVM_VERSION_INFO=$Release $CompilerFlags \ + > $LogDir/llvm-gcc.make.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 echo "# Installing llvm-gcc $Release-rc$RC $Flavor" echo "# make install" - make install + make install \ + > $LogDir/llvm-gcc.install.$Release-rc$RC-Phase$Phase-$Flavor.log 2>&1 cd - } @@ -292,6 +306,7 @@ export_sources fi +( Flavors="Debug Release Release+Asserts" if [ "$do_64bit" = "yes" ]; then Flavors="$Flavors Release-64" @@ -375,7 +390,9 @@ echo "# Testing - built with llvmgcc42" test_llvmCore 2 $Flavor $llvmCore_phase2_objdir done +) 2>&1 | tee $LogDir/testing.$Release-rc$RC.log # Woo hoo! echo "### Testing Finished ###" +echo "### Logs: $LogDir" exit 0 From fvbommel at gmail.com Sun Mar 27 09:26:13 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Sun, 27 Mar 2011 14:26:13 -0000 Subject: [llvm-commits] [llvm] r128379 - in /llvm/trunk: include/llvm/ADT/APInt.h lib/Analysis/ConstantFolding.cpp lib/Support/APInt.cpp test/Transforms/ConstProp/overflow-ops.ll Message-ID: <20110327142613.9AF5C2A6C12C@llvm.org> Author: fvbommel Date: Sun Mar 27 09:26:13 2011 New Revision: 128379 URL: http://llvm.org/viewvc/llvm-project?rev=128379&view=rev Log: Constant folding support for calls to umul.with.overflow(), basically identical to the smul.with.overflow() code. Modified: llvm/trunk/include/llvm/ADT/APInt.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Support/APInt.cpp llvm/trunk/test/Transforms/ConstProp/overflow-ops.ll Modified: llvm/trunk/include/llvm/ADT/APInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=128379&r1=128378&r2=128379&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APInt.h (original) +++ llvm/trunk/include/llvm/ADT/APInt.h Sun Mar 27 09:26:13 2011 @@ -818,6 +818,7 @@ APInt usub_ov(const APInt &RHS, bool &Overflow) const; APInt sdiv_ov(const APInt &RHS, bool &Overflow) const; APInt smul_ov(const APInt &RHS, bool &Overflow) const; + APInt umul_ov(const APInt &RHS, bool &Overflow) const; APInt sshl_ov(unsigned Amt, bool &Overflow) const; /// @returns the bit value at bitPosition Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=128379&r1=128378&r2=128379&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Sun Mar 27 09:26:13 2011 @@ -1048,11 +1048,12 @@ case Intrinsic::ctpop: case Intrinsic::ctlz: case Intrinsic::cttz: - case Intrinsic::uadd_with_overflow: - case Intrinsic::usub_with_overflow: case Intrinsic::sadd_with_overflow: + case Intrinsic::uadd_with_overflow: case Intrinsic::ssub_with_overflow: + case Intrinsic::usub_with_overflow: case Intrinsic::smul_with_overflow: + case Intrinsic::umul_with_overflow: case Intrinsic::convert_from_fp16: case Intrinsic::convert_to_fp16: case Intrinsic::x86_sse_cvtss2si: @@ -1362,7 +1363,8 @@ case Intrinsic::uadd_with_overflow: case Intrinsic::ssub_with_overflow: case Intrinsic::usub_with_overflow: - case Intrinsic::smul_with_overflow: { + case Intrinsic::smul_with_overflow: + case Intrinsic::umul_with_overflow: { APInt Res; bool Overflow; switch (F->getIntrinsicID()) { @@ -1382,6 +1384,9 @@ case Intrinsic::smul_with_overflow: Res = Op1->getValue().smul_ov(Op2->getValue(), Overflow); break; + case Intrinsic::umul_with_overflow: + Res = Op1->getValue().umul_ov(Op2->getValue(), Overflow); + break; } Constant *Ops[] = { ConstantInt::get(F->getContext(), Res), Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=128379&r1=128378&r2=128379&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Sun Mar 27 09:26:13 2011 @@ -2078,6 +2078,16 @@ return Res; } +APInt APInt::umul_ov(const APInt &RHS, bool &Overflow) const { + APInt Res = *this * RHS; + + if (*this != 0 && RHS != 0) + Overflow = Res.udiv(RHS) != *this || Res.udiv(*this) != RHS; + else + Overflow = false; + return Res; +} + APInt APInt::sshl_ov(unsigned ShAmt, bool &Overflow) const { Overflow = ShAmt >= getBitWidth(); if (Overflow) Modified: llvm/trunk/test/Transforms/ConstProp/overflow-ops.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstProp/overflow-ops.ll?rev=128379&r1=128378&r2=128379&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ConstProp/overflow-ops.ll (original) +++ llvm/trunk/test/Transforms/ConstProp/overflow-ops.ll Sun Mar 27 09:26:13 2011 @@ -2,6 +2,14 @@ %i8i1 = type {i8, i1} +declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8) +declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8) +declare {i8, i1} @llvm.umul.with.overflow.i8(i8, i8) + +declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8) +declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8) +declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8) + ;;----------------------------- ;; uadd ;;----------------------------- @@ -47,6 +55,28 @@ } ;;----------------------------- +;; umul +;;----------------------------- + +define {i8, i1} @umul_1() nounwind { +entry: + %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3) + ret {i8, i1} %t + +; CHECK: @umul_1 +; CHECK: ret %i8i1 { i8 44, i1 true } +} + +define {i8, i1} @umul_2() nounwind { +entry: + %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2) + ret {i8, i1} %t + +; CHECK: @umul_2 +; CHECK: ret %i8i1 { i8 -56, i1 false } +} + +;;----------------------------- ;; sadd ;;----------------------------- @@ -163,14 +193,9 @@ ; CHECK: ret %i8i1 { i8 -10, i1 false } } - - -declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8) -declare {i8, i1} @llvm.usub.with.overflow.i8(i8, i8) - -declare {i8, i1} @llvm.sadd.with.overflow.i8(i8, i8) -declare {i8, i1} @llvm.ssub.with.overflow.i8(i8, i8) -declare {i8, i1} @llvm.smul.with.overflow.i8(i8, i8) +;;----------------------------- +;; smul +;;----------------------------- ; rdar://8501501 define {i8, i1} @smul_1() nounwind { From benny.kra at googlemail.com Sun Mar 27 10:04:38 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 27 Mar 2011 15:04:38 -0000 Subject: [llvm-commits] [llvm] r128380 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Message-ID: <20110327150438.A585C2A6C12C@llvm.org> Author: d0k Date: Sun Mar 27 10:04:38 2011 New Revision: 128380 URL: http://llvm.org/viewvc/llvm-project?rev=128380&view=rev Log: Use APInt's umul_ov instead of rolling our own overflow detection. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=128380&r1=128379&r2=128380&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Sun Mar 27 10:04:38 2011 @@ -487,14 +487,15 @@ APInt RHSKnownOne(BitWidth, 0); ComputeMaskedBits(RHS, Mask, RHSKnownZero, RHSKnownOne); - // Get the largest possible values for each operand, extended to be large - // enough so that every possible product of two BitWidth-sized ints fits. - APInt LHSMax = (~LHSKnownZero).zext(BitWidth*2); - APInt RHSMax = (~RHSKnownZero).zext(BitWidth*2); + // Get the largest possible values for each operand. + APInt LHSMax = ~LHSKnownZero; + APInt RHSMax = ~RHSKnownZero; // If multiplying the maximum values does not overflow then we can turn // this into a plain NUW mul. - if ((LHSMax * RHSMax).getActiveBits() <= BitWidth) { + bool Overflow; + LHSMax.umul_ov(RHSMax, Overflow); + if (!Overflow) { Value *Mul = Builder->CreateNUWMul(LHS, RHS, "umul_with_overflow"); Constant *V[] = { UndefValue::get(LHS->getType()), From nicholas at mxc.ca Sun Mar 27 14:51:23 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 27 Mar 2011 19:51:23 -0000 Subject: [llvm-commits] [llvm] r128388 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineSelect.cpp test/Transforms/InstCombine/select.ll Message-ID: <20110327195123.44A382A6C12E@llvm.org> Author: nicholas Date: Sun Mar 27 14:51:23 2011 New Revision: 128388 URL: http://llvm.org/viewvc/llvm-project?rev=128388&view=rev Log: Teach the transformation that moves binary operators around selects to preserve the subclass optional data. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp llvm/trunk/test/Transforms/InstCombine/select.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=128388&r1=128387&r2=128388&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Sun Mar 27 14:51:23 2011 @@ -214,7 +214,7 @@ unsigned OpToFold = 0; if ((SFO & 1) && FalseVal == TVI->getOperand(0)) { OpToFold = 1; - } else if ((SFO & 2) && FalseVal == TVI->getOperand(1)) { + } else if ((SFO & 2) && FalseVal == TVI->getOperand(1)) { OpToFold = 2; } @@ -227,9 +227,16 @@ Instruction *NewSel = SelectInst::Create(SI.getCondition(), OOp, C); InsertNewInstBefore(NewSel, SI); NewSel->takeName(TVI); - if (BinaryOperator *BO = dyn_cast(TVI)) - return BinaryOperator::Create(BO->getOpcode(), FalseVal, NewSel); - llvm_unreachable("Unknown instruction!!"); + BinaryOperator *TVI_BO = cast(TVI); + BinaryOperator *BO = BinaryOperator::Create(TVI_BO->getOpcode(), + FalseVal, NewSel); + if (isa(BO)) + BO->setIsExact(TVI_BO->isExact()); + if (isa(BO)) { + BO->setHasNoUnsignedWrap(TVI_BO->hasNoUnsignedWrap()); + BO->setHasNoSignedWrap(TVI_BO->hasNoSignedWrap()); + } + return BO; } } } @@ -243,7 +250,7 @@ unsigned OpToFold = 0; if ((SFO & 1) && TrueVal == FVI->getOperand(0)) { OpToFold = 1; - } else if ((SFO & 2) && TrueVal == FVI->getOperand(1)) { + } else if ((SFO & 2) && TrueVal == FVI->getOperand(1)) { OpToFold = 2; } @@ -256,9 +263,16 @@ Instruction *NewSel = SelectInst::Create(SI.getCondition(), C, OOp); InsertNewInstBefore(NewSel, SI); NewSel->takeName(FVI); - if (BinaryOperator *BO = dyn_cast(FVI)) - return BinaryOperator::Create(BO->getOpcode(), TrueVal, NewSel); - llvm_unreachable("Unknown instruction!!"); + BinaryOperator *FVI_BO = cast(FVI); + BinaryOperator *BO = BinaryOperator::Create(FVI_BO->getOpcode(), + TrueVal, NewSel); + if (isa(BO)) + BO->setIsExact(FVI_BO->isExact()); + if (isa(BO)) { + BO->setHasNoUnsignedWrap(FVI_BO->hasNoUnsignedWrap()); + BO->setHasNoSignedWrap(FVI_BO->hasNoSignedWrap()); + } + return BO; } } } Modified: llvm/trunk/test/Transforms/InstCombine/select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select.ll?rev=128388&r1=128387&r2=128388&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/select.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/select.ll Sun Mar 27 14:51:23 2011 @@ -737,3 +737,15 @@ ; CHECK: zext ; CHECK: ret } + +define i1 @test55(i1 %X, i32 %Y, i32 %Z) { + %A = ashr exact i32 %Y, %Z + %B = select i1 %X, i32 %Y, i32 %A + %C = icmp eq i32 %B, 0 + ret i1 %C +; CHECK: @test55 +; CHECK-NOT: ashr +; CHECK-NOT: select +; CHECK: icmp eq +; CHECK: ret i1 +} From stoklund at 2pi.dk Sun Mar 27 17:49:21 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sun, 27 Mar 2011 22:49:21 -0000 Subject: [llvm-commits] [llvm] r128397 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Message-ID: <20110327224921.C1F062A6C12C@llvm.org> Author: stoklund Date: Sun Mar 27 17:49:21 2011 New Revision: 128397 URL: http://llvm.org/viewvc/llvm-project?rev=128397&view=rev Log: Drop interference reassignment in favor of eviction. The reassignment phase was able to move interference with a higher spill weight, but it didn't happen very often and it was fairly expensive. The existing interference eviction picks up the slack. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=128397&r1=128396&r2=128397&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Sun Mar 27 17:49:21 2011 @@ -49,7 +49,6 @@ STATISTIC(NumGlobalSplits, "Number of split global live ranges"); STATISTIC(NumLocalSplits, "Number of split local live ranges"); -STATISTIC(NumReassigned, "Number of interferences reassigned"); STATISTIC(NumEvicted, "Number of interferences evicted"); static RegisterRegAlloc greedyRegAlloc("greedy", "greedy register allocator", @@ -164,10 +163,6 @@ bool LRE_CanEraseVirtReg(unsigned); void LRE_WillShrinkVirtReg(unsigned); - bool checkUncachedInterference(LiveInterval&, unsigned); - LiveInterval *getSingleInterference(LiveInterval&, unsigned); - bool reassignVReg(LiveInterval &InterferingVReg, unsigned OldPhysReg); - void mapGlobalInterference(unsigned, SmallVectorImpl&); float calcSplitConstraints(const SmallVectorImpl&); @@ -180,8 +175,6 @@ unsigned nextSplitPoint(unsigned); bool canEvictInterference(LiveInterval&, unsigned, float&); - unsigned tryReassign(LiveInterval&, AllocationOrder&, - SmallVectorImpl&); unsigned tryEvict(LiveInterval&, AllocationOrder&, SmallVectorImpl&); unsigned tryRegionSplit(LiveInterval&, AllocationOrder&, @@ -288,17 +281,20 @@ unsigned Prio; LRStage.grow(Reg); - if (LRStage[Reg] == RS_Original) - // 1st generation ranges are handled first, long -> short. + if (LRStage[Reg] == RS_Second) + // Unsplit ranges that couldn't be allocated immediately are deferred until + // everything else has been allocated. Long ranges are allocated last so + // they are split against realistic interference. + Prio = (1u << 31) - Size; + else { + // Everything else is allocated in long->short order. Long ranges that don't + // fit should be spilled ASAP so they don't create interference. Prio = (1u << 31) + Size; - else - // Repeat offenders are handled second, short -> long - Prio = (1u << 30) - Size; - - // Boost ranges that have a physical register hint. - const unsigned Hint = VRM->getRegAllocPref(Reg); - if (TargetRegisterInfo::isPhysicalRegister(Hint)) - Prio |= (1u << 30); + + // Boost ranges that have a physical register hint. + if (TargetRegisterInfo::isPhysicalRegister(VRM->getRegAllocPref(Reg))) + Prio |= (1u << 30); + } Queue.push(std::make_pair(Prio, Reg)); } @@ -312,100 +308,6 @@ } //===----------------------------------------------------------------------===// -// Register Reassignment -//===----------------------------------------------------------------------===// - -// Check interference without using the cache. -bool RAGreedy::checkUncachedInterference(LiveInterval &VirtReg, - unsigned PhysReg) { - for (const unsigned *AliasI = TRI->getOverlaps(PhysReg); *AliasI; ++AliasI) { - LiveIntervalUnion::Query subQ(&VirtReg, &PhysReg2LiveUnion[*AliasI]); - if (subQ.checkInterference()) - return true; - } - return false; -} - -/// getSingleInterference - Return the single interfering virtual register -/// assigned to PhysReg. Return 0 if more than one virtual register is -/// interfering. -LiveInterval *RAGreedy::getSingleInterference(LiveInterval &VirtReg, - unsigned PhysReg) { - // Check physreg and aliases. - LiveInterval *Interference = 0; - for (const unsigned *AliasI = TRI->getOverlaps(PhysReg); *AliasI; ++AliasI) { - LiveIntervalUnion::Query &Q = query(VirtReg, *AliasI); - if (Q.checkInterference()) { - if (Interference) - return 0; - if (Q.collectInterferingVRegs(2) > 1) - return 0; - Interference = Q.interferingVRegs().front(); - } - } - return Interference; -} - -// Attempt to reassign this virtual register to a different physical register. -// -// FIXME: we are not yet caching these "second-level" interferences discovered -// in the sub-queries. These interferences can change with each call to -// selectOrSplit. However, we could implement a "may-interfere" cache that -// could be conservatively dirtied when we reassign or split. -// -// FIXME: This may result in a lot of alias queries. We could summarize alias -// live intervals in their parent register's live union, but it's messy. -bool RAGreedy::reassignVReg(LiveInterval &InterferingVReg, - unsigned WantedPhysReg) { - assert(TargetRegisterInfo::isVirtualRegister(InterferingVReg.reg) && - "Can only reassign virtual registers"); - assert(TRI->regsOverlap(WantedPhysReg, VRM->getPhys(InterferingVReg.reg)) && - "inconsistent phys reg assigment"); - - AllocationOrder Order(InterferingVReg.reg, *VRM, ReservedRegs); - while (unsigned PhysReg = Order.next()) { - // Don't reassign to a WantedPhysReg alias. - if (TRI->regsOverlap(PhysReg, WantedPhysReg)) - continue; - - if (checkUncachedInterference(InterferingVReg, PhysReg)) - continue; - - // Reassign the interfering virtual reg to this physical reg. - unsigned OldAssign = VRM->getPhys(InterferingVReg.reg); - DEBUG(dbgs() << "reassigning: " << InterferingVReg << " from " << - TRI->getName(OldAssign) << " to " << TRI->getName(PhysReg) << '\n'); - unassign(InterferingVReg, OldAssign); - assign(InterferingVReg, PhysReg); - ++NumReassigned; - return true; - } - return false; -} - -/// tryReassign - Try to reassign a single interference to a different physreg. -/// @param VirtReg Currently unassigned virtual register. -/// @param Order Physregs to try. -/// @return Physreg to assign VirtReg, or 0. -unsigned RAGreedy::tryReassign(LiveInterval &VirtReg, AllocationOrder &Order, - SmallVectorImpl &NewVRegs){ - NamedRegionTimer T("Reassign", TimerGroupName, TimePassesIsEnabled); - - Order.rewind(); - while (unsigned PhysReg = Order.next()) { - LiveInterval *InterferingVReg = getSingleInterference(VirtReg, PhysReg); - if (!InterferingVReg) - continue; - if (TargetRegisterInfo::isPhysicalRegister(InterferingVReg->reg)) - continue; - if (reassignVReg(*InterferingVReg, PhysReg)) - return PhysReg; - } - return 0; -} - - -//===----------------------------------------------------------------------===// // Interference eviction //===----------------------------------------------------------------------===// @@ -851,22 +753,8 @@ SE->finish(); ++NumGlobalSplits; - if (VerifyEnabled) { + if (VerifyEnabled) MF->verify(this, "After splitting live range around region"); - -#ifndef NDEBUG - // Make sure that at least one of the new intervals can allocate to PhysReg. - // That was the whole point of splitting the live range. - bool found = false; - for (LiveRangeEdit::iterator I = LREdit.begin(), E = LREdit.end(); I != E; - ++I) - if (!checkUncachedInterference(**I, PhysReg)) { - found = true; - break; - } - assert(found && "No allocatable intervals after pointless splitting"); -#endif - } } unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order, @@ -1242,10 +1130,6 @@ unsigned RAGreedy::selectOrSplit(LiveInterval &VirtReg, SmallVectorImpl &NewVRegs) { - LiveRangeStage Stage = getStage(VirtReg); - if (Stage == RS_Original) - LRStage[VirtReg.reg] = RS_Second; - // First try assigning a free register. AllocationOrder Order(VirtReg.reg, *VRM, ReservedRegs); while (unsigned PhysReg = Order.next()) { @@ -1253,9 +1137,6 @@ return PhysReg; } - if (unsigned PhysReg = tryReassign(VirtReg, Order, NewVRegs)) - return PhysReg; - if (unsigned PhysReg = tryEvict(VirtReg, Order, NewVRegs)) return PhysReg; @@ -1264,7 +1145,9 @@ // The first time we see a live range, don't try to split or spill. // Wait until the second time, when all smaller ranges have been allocated. // This gives a better picture of the interference to split around. + LiveRangeStage Stage = getStage(VirtReg); if (Stage == RS_Original) { + LRStage[VirtReg.reg] = RS_Second; DEBUG(dbgs() << "wait for second round\n"); NewVRegs.push_back(&VirtReg); return 0; From stoklund at 2pi.dk Sun Mar 27 17:49:24 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sun, 27 Mar 2011 22:49:24 -0000 Subject: [llvm-commits] [llvm] r128398 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20110327224924.222ED2A6C12D@llvm.org> Author: stoklund Date: Sun Mar 27 17:49:23 2011 New Revision: 128398 URL: http://llvm.org/viewvc/llvm-project?rev=128398&view=rev Log: Amend debug output. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=128398&r1=128397&r2=128398&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Sun Mar 27 17:49:23 2011 @@ -95,9 +95,10 @@ assert(fixed && "Couldn't fix broken live interval"); } - DEBUG(dbgs() << " counted " + DEBUG(dbgs() << "Analyze counted " << UsingInstrs.size() << " instrs, " - << UsingBlocks.size() << " blocks.\n"); + << UsingBlocks.size() << " blocks, " + << LiveBlocks.size() << " spanned.\n"); } /// calcLiveBlockInfo - Fill the LiveBlocks array with information about blocks From fvbommel at gmail.com Sun Mar 27 18:32:31 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Sun, 27 Mar 2011 23:32:31 -0000 Subject: [llvm-commits] [llvm] r128399 - /llvm/trunk/lib/Transforms/InstCombine/InstCombine.h Message-ID: <20110327233231.3C5132A6C12C@llvm.org> Author: fvbommel Date: Sun Mar 27 18:32:31 2011 New Revision: 128399 URL: http://llvm.org/viewvc/llvm-project?rev=128399&view=rev Log: Add some debug output when -instcombine uses RAUW. This can make debug output for those cases much clearer since without this it only showed that the original instruction was removed, not what it was replaced with. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombine.h Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombine.h?rev=128399&r1=128398&r2=128399&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombine.h (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombine.h Sun Mar 27 18:32:31 2011 @@ -246,7 +246,10 @@ // segment of unreachable code, so just clobber the instruction. if (&I == V) V = UndefValue::get(I.getType()); - + + DEBUG(errs() << "IC: Replacing " << I << "\n" + " with " << *V << '\n'); + I.replaceAllUsesWith(V); return &I; }