From c451cf240b066423552c4db454d3386f38a9750c Mon Sep 17 00:00:00 2001 From: Jake Ehrlich Date: Sat, 11 Nov 2017 01:15:41 +0000 Subject: Add CLANG_DEFAULT_OBJCOPY to allow Clang to use llvm-objcopy for dwarf fission llvm-objcopy is getting to where it can be used in non-trivial ways (such as for dwarf fission in clang). It now supports dwarf fission but this feature hasn't been thoroughly tested yet. This change allows people to optionally build clang to use llvm-objcopy rather than GNU objcopy. By default GNU objcopy is still used so nothing should change. Differential Revision: https://reviews.llvm.org/D39029 llvm-svn: 317960 --- clang/lib/CodeGen/CodeGenModule.cpp | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 61a1ed2393e..8d29022b96b 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -441,7 +441,7 @@ void CodeGenModule::Release() { if (Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86) getModule().addModuleFlag(llvm::Module::Error, "NumRegisterParameters", CodeGenOpts.NumRegisterParameters); - + if (CodeGenOpts.DwarfVersion) { // We actually want the latest version when there are conflicts. // We can change from Warning to Latest if such mode is supported. @@ -770,7 +770,7 @@ StringRef CodeGenModule::getBlockMangledName(GlobalDecl GD, SmallString<256> Buffer; llvm::raw_svector_ostream Out(Buffer); if (!D) - MangleCtx.mangleGlobalBlock(BD, + MangleCtx.mangleGlobalBlock(BD, dyn_cast_or_null(initializedGlobalDecl.getDecl()), Out); else if (const auto *CD = dyn_cast(D)) MangleCtx.mangleCtorBlock(CD, GD.getCtorType(), BD, Out); @@ -2010,12 +2010,12 @@ bool CodeGenModule::shouldOpportunisticallyEmitVTables() { void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { const auto *D = cast(GD.getDecl()); - PrettyStackTraceDecl CrashInfo(const_cast(D), D->getLocation(), + PrettyStackTraceDecl CrashInfo(const_cast(D), D->getLocation(), Context.getSourceManager(), "Generating code for declaration"); - + if (isa(D)) { - // At -O0, don't generate IR for functions with available_externally + // At -O0, don't generate IR for functions with available_externally // linkage. if (!shouldEmitFunction(GD)) return; @@ -2041,7 +2041,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD, llvm::GlobalValue *GV) { if (const auto *VD = dyn_cast(D)) return EmitGlobalVarDefinition(VD, !VD->hasDefinition()); - + llvm_unreachable("Invalid argument to EmitGlobalDefinition()"); } @@ -2547,7 +2547,7 @@ CodeGenModule::GetAddrOfGlobal(GlobalDecl GD, } llvm::GlobalVariable * -CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, +CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, llvm::Type *Ty, llvm::GlobalValue::LinkageTypes Linkage) { llvm::GlobalVariable *GV = getModule().getNamedGlobal(Name); @@ -2563,7 +2563,7 @@ CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, assert(GV->isDeclaration() && "Declaration has wrong type!"); OldGV = GV; } - + // Create a new variable. GV = new llvm::GlobalVariable(getModule(), Ty, /*isConstant=*/true, Linkage, nullptr, Name); @@ -2571,13 +2571,13 @@ CodeGenModule::CreateOrReplaceCXXRuntimeVariable(StringRef Name, if (OldGV) { // Replace occurrences of the old variable if needed. GV->takeName(OldGV); - + if (!OldGV->use_empty()) { llvm::Constant *NewPtrForOldDecl = llvm::ConstantExpr::getBitCast(GV, OldGV->getType()); OldGV->replaceAllUsesWith(NewPtrForOldDecl); } - + OldGV->eraseFromParent(); } @@ -3582,7 +3582,7 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() { if (ObjCFastEnumerationStateType.isNull()) { RecordDecl *D = Context.buildImplicitRecord("__objcFastEnumerationState"); D->startDefinition(); - + QualType FieldTypes[] = { Context.UnsignedLongTy, Context.getPointerType(Context.getObjCIdType()), @@ -3590,7 +3590,7 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() { Context.getConstantArrayType(Context.UnsignedLongTy, llvm::APInt(32, 5), ArrayType::Normal, 0) }; - + for (size_t i = 0; i < 4; ++i) { FieldDecl *Field = FieldDecl::Create(Context, D, @@ -3603,18 +3603,18 @@ QualType CodeGenModule::getObjCFastEnumerationStateType() { Field->setAccess(AS_public); D->addDecl(Field); } - + D->completeDefinition(); ObjCFastEnumerationStateType = Context.getTagDeclType(D); } - + return ObjCFastEnumerationStateType; } llvm::Constant * CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) { assert(!E->getType()->isPointerType() && "Strings are always arrays"); - + // Don't emit it as the address of the string, emit the string data itself // as an inline array. if (E->getCharByteWidth() == 1) { @@ -3640,11 +3640,11 @@ CodeGenModule::GetConstantArrayFromStringLiteral(const StringLiteral *E) { Elements.resize(NumElements); return llvm::ConstantDataArray::get(VMContext, Elements); } - + assert(ElemTy->getPrimitiveSizeInBits() == 32); SmallVector Elements; Elements.reserve(NumElements); - + for(unsigned i = 0, e = E->getLength(); i != e; ++i) Elements.push_back(E->getCodeUnit(i)); Elements.resize(NumElements); @@ -3936,11 +3936,11 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) { if (D->getNumIvarInitializers() == 0 || AllTrivialInitializers(*this, D)) return; - + IdentifierInfo *II = &getContext().Idents.get(".cxx_construct"); Selector cxxSelector = getContext().Selectors.getSelector(0, &II); // The constructor returns 'self'. - ObjCMethodDecl *CTORMethod = ObjCMethodDecl::Create(getContext(), + ObjCMethodDecl *CTORMethod = ObjCMethodDecl::Create(getContext(), D->getLocation(), D->getLocation(), cxxSelector, @@ -4076,7 +4076,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { if (cast(D)->getDescribedFunctionTemplate() || cast(D)->isLateTemplateParsed()) return; - + getCXXABI().EmitCXXConstructors(cast(D)); break; case Decl::CXXDestructor: @@ -4102,7 +4102,7 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { ObjCRuntime->GenerateProtocol(Proto); break; } - + case Decl::ObjCCategoryImpl: // Categories have properties but don't support synthesize so we // can ignore them here. @@ -4501,7 +4501,7 @@ llvm::Constant *CodeGenModule::GetAddrOfRTTIDescriptor(QualType Ty, // and it's not for EH? if (!ForEH && !getLangOpts().RTTI) return llvm::Constant::getNullValue(Int8PtrTy); - + if (ForEH && Ty->isObjCObjectPointerType() && LangOpts.ObjCRuntime.isGNUFamily()) return ObjCRuntime->GetEHType(Ty); -- cgit v1.2.3