diff options
Diffstat (limited to 'lib/CodeGen')
-rw-r--r-- | lib/CodeGen/CGDebugInfo.cpp | 63 | ||||
-rw-r--r-- | lib/CodeGen/CGDebugInfo.h | 4 | ||||
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCGNU.cpp | 5 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 63 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCRuntime.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 11 | ||||
-rw-r--r-- | lib/CodeGen/Mangle.cpp | 3 |
9 files changed, 68 insertions, 93 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index a2b8d13..5e872c2 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -50,24 +50,6 @@ void CGDebugInfo::setLocation(SourceLocation Loc) { /// getOrCreateCompileUnit - Get the compile unit from the cache or create a new /// one if necessary. This returns null for invalid source locations. llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { - - // Each input file is encoded as a separate compile unit in LLVM - // debugging information output. However, many target specific tool chains - // prefer to encode only one compile unit in an object file. In this - // situation, the LLVM code generator will include debugging information - // entities in the compile unit that is marked as main compile unit. The - // code generator accepts maximum one main compile unit per module. If a - // module does not contain any main compile unit then the code generator - // will emit multiple compile units in the output object file. Create main - // compile unit if there is not one available. - const LangOptions &LO = M->getLangOptions(); - if (isMainCompileUnitCreated == false) { - if (LO.getMainFileName()) { - createCompileUnit(LO.getMainFileName(), true /* isMain */); - isMainCompileUnitCreated = true; - } - } - // Get source file information. const char *FileName = "<unknown>"; SourceManager &SM = M->getContext().getSourceManager(); @@ -90,26 +72,25 @@ llvm::DICompileUnit CGDebugInfo::getOrCreateCompileUnit(SourceLocation Loc) { AbsFileName = tmp; } - // There is only one main source file at a time whose compile unit - // is already created. - Unit = createCompileUnit(FileName, false /* isMain */); - return Unit; -} - -/// createCompileUnit - Create a new unit for the given file. -llvm::DICompileUnit CGDebugInfo::createCompileUnit(const char *FileName, - bool isMain) { - - // Get absolute path name. - llvm::sys::Path AbsFileName(FileName); - if (!AbsFileName.isAbsolute()) { - llvm::sys::Path tmp = llvm::sys::Path::GetCurrentDirectory(); - tmp.appendComponent(FileName); - AbsFileName = tmp; + // See if thie compile unit is representing main source file. Each source + // file has corresponding compile unit. There is only one main source + // file at a time. + bool isMain = false; + const LangOptions &LO = M->getLangOptions(); + const char *MainFileName = LO.getMainFileName(); + if (isMainCompileUnitCreated == false) { + if (MainFileName) { + if (!strcmp(AbsFileName.getLast().c_str(), MainFileName)) + isMain = true; + } else { + if (Loc.isValid() && SM.isFromMainFile(Loc)) + isMain = true; + } + if (isMain) + isMainCompileUnitCreated = true; } unsigned LangTag; - const LangOptions &LO = M->getLangOptions(); if (LO.CPlusPlus) { if (LO.ObjC1) LangTag = llvm::dwarf::DW_LANG_ObjC_plus_plus; @@ -133,13 +114,12 @@ llvm::DICompileUnit CGDebugInfo::createCompileUnit(const char *FileName, RuntimeVers = LO.ObjCNonFragileABI ? 2 : 1; // Create new compile unit. - return DebugFactory.CreateCompileUnit(LangTag, AbsFileName.getLast(), - AbsFileName.getDirname(), - Producer, isMain, isOptimized, - Flags, RuntimeVers); + return Unit = DebugFactory.CreateCompileUnit(LangTag, AbsFileName.getLast(), + AbsFileName.getDirname(), + Producer, isMain, isOptimized, + Flags, RuntimeVers); } - /// CreateType - Get the Basic type from the cache or create a new /// one if necessary. llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT, @@ -810,6 +790,9 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, case Type::TypeOf: return Slot = getOrCreateType(cast<TypeOfType>(Ty)->getUnderlyingType(), Unit); + case Type::Decltype: + return Slot = getOrCreateType(cast<DecltypeType>(Ty)->getUnderlyingExpr() + ->getType(), Unit); } return Slot; diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 8f3368e..de65580 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -111,9 +111,7 @@ private: void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI, CGBuilderTy &Builder); - /// createCompileUnit - Create a new unit for the given file. - llvm::DICompileUnit createCompileUnit(const char *FileName, bool isMain); - + /// getOrCreateCompileUnit - Get the compile unit from the cache or create a /// new one if necessary. llvm::DICompileUnit getOrCreateCompileUnit(SourceLocation Loc); diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 4e603c3..f97c62f 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -234,7 +234,7 @@ const llvm::Type *CodeGenFunction::BuildByRefType(QualType Ty, } // FIXME: Align this on at least an Align boundary, assert if we can't. assert((Align <= unsigned(Target.getPointerAlign(0))/8) - && "Can't align more thqn pointer yet"); + && "Can't align more than pointer yet"); Types[needsCopyDispose*2 + 4] = LTy; return llvm::StructType::get(Types, false); } diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 51c5b3d..a211407 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -606,11 +606,12 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, cast<llvm::VectorType>(Vec->getType())->getNumElements(); if (NumDstElts == NumSrcElts) { // Use shuffle vector is the src and destination are the same number - // of elements - llvm::SmallVector<llvm::Constant*, 4> Mask; + // of elements and restore the vector mask since it is on the side + // it will be stored. + llvm::SmallVector<llvm::Constant*, 4> Mask(NumDstElts); for (unsigned i = 0; i != NumSrcElts; ++i) { unsigned InIdx = getAccessedFieldNo(i, Elts); - Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx)); + Mask[InIdx] = llvm::ConstantInt::get(llvm::Type::Int32Ty, i); } llvm::Value *MaskV = llvm::ConstantVector::get(&Mask[0], Mask.size()); diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 912479f..4f96b8b 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -139,6 +139,7 @@ public: const ObjCProtocolDecl *PD); virtual void GenerateProtocol(const ObjCProtocolDecl *PD); virtual llvm::Function *ModuleInitFunction(); + virtual void MergeMetadataGlobals(std::vector<llvm::Constant*> &UsedArray); virtual llvm::Function *GetPropertyGetFunction(); virtual llvm::Function *GetPropertySetFunction(); virtual llvm::Function *EnumerationMutationFunction(); @@ -998,6 +999,10 @@ void CGObjCGNU::GenerateClass(const ObjCImplementationDecl *OID) { Classes.push_back(ClassStruct); } +void CGObjCGNU::MergeMetadataGlobals( + std::vector<llvm::Constant*> &UsedArray) { +} + llvm::Function *CGObjCGNU::ModuleInitFunction() { // Only emit an ObjC load function if no Objective-C stuff has been called if (Classes.empty() && Categories.empty() && ConstantStrings.empty() && diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 6ffca81..865e8c2 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -911,6 +911,8 @@ protected: const CallArgList &CallArgs, const ObjCCommonTypesHelper &ObjCTypes); + virtual void MergeMetadataGlobals(std::vector<llvm::Constant*> &UsedArray); + public: CGObjCCommonMac(CodeGen::CodeGenModule &cgm) : CGM(cgm) { } @@ -3426,6 +3428,16 @@ void CGObjCCommonMac::GetNameForMethod(const ObjCMethodDecl *D, NameOut += ']'; } +void CGObjCCommonMac::MergeMetadataGlobals( + std::vector<llvm::Constant*> &UsedArray) { + llvm::Type *i8PTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); + for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(), + e = UsedGlobals.end(); i != e; ++i) { + UsedArray.push_back(llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(*i), + i8PTy)); + } +} + void CGObjCMac::FinishModule() { EmitModuleInfo(); @@ -3447,22 +3459,6 @@ void CGObjCMac::FinishModule() { Values)); } - std::vector<llvm::Constant*> Used; - for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(), - e = UsedGlobals.end(); i != e; ++i) { - Used.push_back(llvm::ConstantExpr::getBitCast(*i, ObjCTypes.Int8PtrTy)); - } - - llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Used.size()); - llvm::GlobalValue *GV = - new llvm::GlobalVariable(AT, false, - llvm::GlobalValue::AppendingLinkage, - llvm::ConstantArray::get(AT, Used), - "llvm.used", - &CGM.getModule()); - - GV->setSection("llvm.metadata"); - // Add assembler directives to add lazy undefined symbol references // for classes which are referenced but not defined. This is // important for correct linker interaction. @@ -4111,24 +4107,6 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() { IMGV->setSection("__DATA, __objc_imageinfo, regular, no_dead_strip"); IMGV->setConstant(true); UsedGlobals.push_back(IMGV); - - std::vector<llvm::Constant*> Used; - - for (std::vector<llvm::GlobalVariable*>::iterator i = UsedGlobals.begin(), - e = UsedGlobals.end(); i != e; ++i) { - Used.push_back(llvm::ConstantExpr::getBitCast(*i, ObjCTypes.Int8PtrTy)); - } - - llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Used.size()); - llvm::GlobalValue *GV = - new llvm::GlobalVariable(AT, false, - llvm::GlobalValue::AppendingLinkage, - llvm::ConstantArray::get(AT, Used), - "llvm.used", - &CGM.getModule()); - - GV->setSection("llvm.metadata"); - } /// LegacyDispatchedSelector - Returns true if SEL is not in the list of @@ -5036,16 +5014,13 @@ CodeGen::RValue CGObjCNonFragileABIMac::EmitMessageSend( } } else if (!IsSuper && ResultType->isFloatingType()) { - if (const BuiltinType *BT = ResultType->getAsBuiltinType()) { - BuiltinType::Kind k = BT->getKind(); - if (k == BuiltinType::LongDouble) { - Fn = ObjCTypes.getMessageSendFpretFixupFn(); - Name += "objc_msgSend_fpret_fixup"; - } - else { - Fn = ObjCTypes.getMessageSendFixupFn(); - Name += "objc_msgSend_fixup"; - } + if (ResultType->isSpecificBuiltinType(BuiltinType::LongDouble)) { + Fn = ObjCTypes.getMessageSendFpretFixupFn(); + Name += "objc_msgSend_fpret_fixup"; + } + else { + Fn = ObjCTypes.getMessageSendFixupFn(); + Name += "objc_msgSend_fixup"; } } else { diff --git a/lib/CodeGen/CGObjCRuntime.h b/lib/CodeGen/CGObjCRuntime.h index b8cf026..0f9cf06 100644 --- a/lib/CodeGen/CGObjCRuntime.h +++ b/lib/CodeGen/CGObjCRuntime.h @@ -95,6 +95,9 @@ public: /// this compilation unit with the runtime library. virtual llvm::Function *ModuleInitFunction() = 0; + /// Add metadata globals to the 'used' globals for final output. + virtual void MergeMetadataGlobals(std::vector<llvm::Constant*> &UsedArray) = 0; + /// Get a selector for the specified name and type values. The /// return value should have the LLVM type for pointer-to /// ASTContext::getObjCSelType(). diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index f926c05..0a531e9 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -406,11 +406,12 @@ void CodeGenModule::AddUsedGlobal(llvm::GlobalValue *GV) { void CodeGenModule::EmitLLVMUsed() { // Don't create llvm.used if there is no need. - if (LLVMUsed.empty()) + // FIXME. Runtime indicates that there might be more 'used' symbols; but not + // necessariy. So, this test is not accurate for emptiness. + if (LLVMUsed.empty() && !Runtime) return; llvm::Type *i8PTy = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, LLVMUsed.size()); // Convert LLVMUsed to what ConstantArray needs. std::vector<llvm::Constant*> UsedArray; @@ -420,6 +421,12 @@ void CodeGenModule::EmitLLVMUsed() { llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(&*LLVMUsed[i]), i8PTy); } + if (Runtime) + Runtime->MergeMetadataGlobals(UsedArray); + if (UsedArray.empty()) + return; + llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, UsedArray.size()); + llvm::GlobalVariable *GV = new llvm::GlobalVariable(ATy, false, llvm::GlobalValue::AppendingLinkage, diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 24e441a..b5ad5ac 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -539,6 +539,9 @@ void CXXNameMangler::mangleType(const BuiltinType *T) { assert(false && "Overloaded and dependent types shouldn't get to name mangling"); break; + case BuiltinType::UndeducedAuto: + assert(0 && "Should not see undeduced auto here"); + break; } } |