mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-23 07:52:06 +00:00
Modular Codegen: Separate flags for function and debug info support
This allows using and testing these two features separately. (noteably, debug info is, so far as I know, always a win (basically). But function modular codegen is currently a loss for highly optimized code - where most of the linkonce_odr definitions are optimized away, so providing weak_odr definitions is only overhead) llvm-svn: 300104
This commit is contained in:
parent
05bf27ac3f
commit
f63556d8b4
@ -201,7 +201,8 @@ LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
|
||||
LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
|
||||
LANGOPT(NewAlignOverride , 32, 0, "maximum alignment guaranteed by '::operator new(size_t)'")
|
||||
LANGOPT(ConceptsTS , 1, 0, "enable C++ Extensions for Concepts")
|
||||
BENIGN_LANGOPT(ModularCodegen , 1, 0, "Modular codegen")
|
||||
BENIGN_LANGOPT(ModulesCodegen , 1, 0, "Modules code generation")
|
||||
BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info")
|
||||
BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
|
||||
BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")
|
||||
BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form")
|
||||
|
@ -436,10 +436,14 @@ def fmodules_local_submodule_visibility :
|
||||
Flag<["-"], "fmodules-local-submodule-visibility">,
|
||||
HelpText<"Enforce name visibility rules across submodules of the same "
|
||||
"top-level module.">;
|
||||
def fmodule_codegen :
|
||||
def fmodules_codegen :
|
||||
Flag<["-"], "fmodules-codegen">,
|
||||
HelpText<"Generate code for uses of this module that assumes an explicit "
|
||||
"object file will be built for the module">;
|
||||
def fmodules_debuginfo :
|
||||
Flag<["-"], "fmodules-debuginfo">,
|
||||
HelpText<"Generate debug info for types in an object file built from this "
|
||||
"module and do not generate them elsewhere">;
|
||||
def fmodule_format_EQ : Joined<["-"], "fmodule-format=">,
|
||||
HelpText<"Select the container format for clang modules and PCH. "
|
||||
"Supported options are 'raw' and 'obj'.">;
|
||||
|
@ -2017,7 +2017,8 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
|
||||
Args.hasArg(OPT_fmodules_decluse) || Opts.ModulesStrictDeclUse;
|
||||
Opts.ModulesLocalVisibility =
|
||||
Args.hasArg(OPT_fmodules_local_submodule_visibility) || Opts.ModulesTS;
|
||||
Opts.ModularCodegen = Args.hasArg(OPT_fmodule_codegen);
|
||||
Opts.ModulesCodegen = Args.hasArg(OPT_fmodules_codegen);
|
||||
Opts.ModulesDebugInfo = Args.hasArg(OPT_fmodules_debuginfo);
|
||||
Opts.ModulesSearchAll = Opts.Modules &&
|
||||
!Args.hasArg(OPT_fno_modules_search_all) &&
|
||||
Args.hasArg(OPT_fmodules_search_all);
|
||||
|
@ -91,7 +91,6 @@ ModuleMap::ModuleMap(SourceManager &SourceMgr, DiagnosticsEngine &Diags,
|
||||
HeaderInfo(HeaderInfo), BuiltinIncludeDir(nullptr),
|
||||
SourceModule(nullptr), NumCreatedModules(0) {
|
||||
MMapLangOpts.LineComment = true;
|
||||
MMapLangOpts.ModularCodegen = LangOpts.ModularCodegen;
|
||||
}
|
||||
|
||||
ModuleMap::~ModuleMap() {
|
||||
|
@ -4782,7 +4782,7 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
|
||||
if (!EagerlyDeserializedDecls.empty())
|
||||
Stream.EmitRecord(EAGERLY_DESERIALIZED_DECLS, EagerlyDeserializedDecls);
|
||||
|
||||
if (Context.getLangOpts().ModularCodegen)
|
||||
if (!ModularCodegenDecls.empty())
|
||||
Stream.EmitRecord(MODULAR_CODEGEN_DECLS, ModularCodegenDecls);
|
||||
|
||||
// Write the record containing tentative definitions.
|
||||
@ -5788,11 +5788,10 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
|
||||
|
||||
// getODRHash will compute the ODRHash if it has not been previously computed.
|
||||
Record->push_back(D->getODRHash());
|
||||
|
||||
bool ModularCodegen = Writer->Context->getLangOpts().ModularCodegen &&
|
||||
Writer->WritingModule && !D->isDependentType();
|
||||
Record->push_back(ModularCodegen);
|
||||
if (ModularCodegen)
|
||||
bool ModulesDebugInfo = Writer->Context->getLangOpts().ModulesDebugInfo &&
|
||||
Writer->WritingModule && !D->isDependentType();
|
||||
Record->push_back(ModulesDebugInfo);
|
||||
if (ModulesDebugInfo)
|
||||
Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(D));
|
||||
|
||||
// IsLambda bit is already saved.
|
||||
|
@ -2228,10 +2228,10 @@ void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
|
||||
Writer->ClearSwitchCaseIDs();
|
||||
|
||||
assert(FD->doesThisDeclarationHaveABody());
|
||||
bool ModularCodegen = Writer->Context->getLangOpts().ModularCodegen &&
|
||||
bool ModulesCodegen = Writer->Context->getLangOpts().ModulesCodegen &&
|
||||
Writer->WritingModule && !FD->isDependentContext();
|
||||
Record->push_back(ModularCodegen);
|
||||
if (ModularCodegen)
|
||||
Record->push_back(ModulesCodegen);
|
||||
if (ModulesCodegen)
|
||||
Writer->ModularCodegenDecls.push_back(Writer->GetDeclRef(FD));
|
||||
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
|
||||
Record->push_back(CD->getNumCtorInitializers());
|
||||
|
4
clang/test/Modules/Inputs/codegen-flags/foo.h
Normal file
4
clang/test/Modules/Inputs/codegen-flags/foo.h
Normal file
@ -0,0 +1,4 @@
|
||||
struct foo {
|
||||
};
|
||||
inline void f1() {
|
||||
}
|
1
clang/test/Modules/Inputs/codegen-flags/foo.modulemap
Normal file
1
clang/test/Modules/Inputs/codegen-flags/foo.modulemap
Normal file
@ -0,0 +1 @@
|
||||
module foo { header "foo.h" }
|
5
clang/test/Modules/Inputs/codegen-flags/use.cpp
Normal file
5
clang/test/Modules/Inputs/codegen-flags/use.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "foo.h"
|
||||
void use() {
|
||||
f1();
|
||||
foo f;
|
||||
}
|
25
clang/test/Modules/codegen-flags.test
Normal file
25
clang/test/Modules/codegen-flags.test
Normal file
@ -0,0 +1,25 @@
|
||||
RUN: rm -rf %t
|
||||
REQUIRES: x86-registered-target
|
||||
|
||||
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen-flags/foo.modulemap -o %t/foo-cg.pcm
|
||||
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-debuginfo -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen-flags/foo.modulemap -o %t/foo-di.pcm
|
||||
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo-cg.pcm | FileCheck --check-prefix=CG %s
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo-di.pcm | FileCheck --check-prefix=DI %s
|
||||
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -fmodule-file=%t/foo-cg.pcm %S/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=CG-USE %s
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -fmodule-file=%t/foo-di.pcm %S/Inputs/codegen-flags/use.cpp | FileCheck --check-prefix=DI-USE %s
|
||||
|
||||
CG: define weak_odr void @_Z2f1v
|
||||
CG: DICompileUnit
|
||||
CG-NOT: DICompositeType
|
||||
|
||||
CG-USE: declare void @_Z2f1v
|
||||
CG-USE: DICompileUnit
|
||||
CG-USE: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
|
||||
|
||||
DI-NOT: define
|
||||
DI: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
|
||||
|
||||
DI-USE: define linkonce_odr void @_Z2f1v
|
||||
DI-USE: = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", {{.*}}, flags: DIFlagFwdDecl
|
@ -1,7 +1,7 @@
|
||||
RUN: rm -rf %t
|
||||
REQUIRES: x86-registered-target
|
||||
|
||||
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
|
||||
RUN: %clang_cc1 -triple=x86_64-linux-gnu -fmodules-codegen -fmodules-debuginfo -x c++ -fmodules -emit-module -fmodule-name=foo %S/Inputs/codegen/foo.modulemap -o %t/foo.pcm
|
||||
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - %t/foo.pcm | FileCheck --check-prefix=FOO --check-prefix=BOTH %s
|
||||
RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -debug-info-kind=limited -o - -fmodules -fmodule-file=%t/foo.pcm %S/Inputs/codegen/use.cpp | FileCheck --check-prefix=BOTH --check-prefix=USE %s
|
||||
|
Loading…
Reference in New Issue
Block a user