forked from OSchip/llvm-project
Use enum to set debug info size generated by Clang
llvm-svn: 155697
This commit is contained in:
parent
e57b49ee16
commit
486e1fe954
|
@ -35,6 +35,13 @@ public:
|
|||
Mixed = 2
|
||||
};
|
||||
|
||||
enum DebugInfoKind {
|
||||
NoDebugInfo, // Don't generate debug info.
|
||||
LimitedDebugInfo, // Limit generated debug info to reduce size
|
||||
// (-flimit-debug-info).
|
||||
FullDebugInfo // Generate complete debug info.
|
||||
};
|
||||
|
||||
unsigned AsmVerbose : 1; /// -dA, -fverbose-asm.
|
||||
unsigned ObjCAutoRefCountExceptions : 1; /// Whether ARC should be EH-safe.
|
||||
unsigned CUDAIsDevice : 1; /// Set when compiling for CUDA device.
|
||||
|
@ -42,8 +49,6 @@ public:
|
|||
unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
|
||||
/// aliases to base ctors when possible.
|
||||
unsigned DataSections : 1; /// Set when -fdata-sections is enabled
|
||||
unsigned DebugInfo : 1; /// Should generate debug info (-g).
|
||||
unsigned LimitDebugInfo : 1; /// Limit generated debug info to reduce size.
|
||||
unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled.
|
||||
unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in
|
||||
/// getting .bc files that correspond to the
|
||||
|
@ -127,6 +132,9 @@ public:
|
|||
/// The string to embed in debug information as the current working directory.
|
||||
std::string DebugCompilationDir;
|
||||
|
||||
/// The kind of generated debug info.
|
||||
DebugInfoKind DebugInfo;
|
||||
|
||||
/// The string to embed in the debug information for the compile unit, if
|
||||
/// non-empty.
|
||||
std::string DwarfDebugFlags;
|
||||
|
@ -169,8 +177,6 @@ public:
|
|||
CXAAtExit = 1;
|
||||
CXXCtorDtorAliases = 0;
|
||||
DataSections = 0;
|
||||
DebugInfo = 0;
|
||||
LimitDebugInfo = 0;
|
||||
DisableFPElim = 0;
|
||||
DisableLLVMOpts = 0;
|
||||
DisableRedZone = 0;
|
||||
|
@ -217,6 +223,7 @@ public:
|
|||
StackRealignment = 0;
|
||||
StackAlignment = 0;
|
||||
|
||||
DebugInfo = NoDebugInfo;
|
||||
Inlining = NoInlining;
|
||||
RelocationModel = "pic";
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ void EmitAssemblyHelper::CreatePasses() {
|
|||
CodeGenOpts.EmitGcovArcs,
|
||||
TargetTriple.isMacOSX()));
|
||||
|
||||
if (!CodeGenOpts.DebugInfo)
|
||||
if (CodeGenOpts.DebugInfo == CodeGenOptions::NoDebugInfo)
|
||||
MPM->add(createStripSymbolsPass(true));
|
||||
}
|
||||
|
||||
|
|
|
@ -1227,7 +1227,8 @@ CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
|
|||
CallExpr::const_arg_iterator ArgEnd) {
|
||||
|
||||
CGDebugInfo *DI = getDebugInfo();
|
||||
if (DI && CGM.getCodeGenOpts().LimitDebugInfo) {
|
||||
if (DI &&
|
||||
CGM.getCodeGenOpts().DebugInfo == CodeGenOptions::LimitedDebugInfo) {
|
||||
// If debug info for this class has not been emitted then this is the
|
||||
// right time to do so.
|
||||
const CXXRecordDecl *Parent = D->getParent();
|
||||
|
|
|
@ -546,7 +546,7 @@ llvm::DIDescriptor CGDebugInfo::createContextChain(const Decl *Context) {
|
|||
/// then emit record's fwd if debug info size reduction is enabled.
|
||||
llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy,
|
||||
llvm::DIFile Unit) {
|
||||
if (!CGM.getCodeGenOpts().LimitDebugInfo)
|
||||
if (CGM.getCodeGenOpts().DebugInfo != CodeGenOptions::LimitedDebugInfo)
|
||||
return getOrCreateType(PointeeTy, Unit);
|
||||
|
||||
// Limit debug info for the pointee type.
|
||||
|
@ -1823,7 +1823,7 @@ llvm::DIType CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
|
|||
StringRef RDName = RD->getName();
|
||||
|
||||
llvm::DIDescriptor RDContext;
|
||||
if (CGM.getCodeGenOpts().LimitDebugInfo)
|
||||
if (CGM.getCodeGenOpts().DebugInfo == CodeGenOptions::LimitedDebugInfo)
|
||||
RDContext = createContextChain(cast<Decl>(RD->getDeclContext()));
|
||||
else
|
||||
RDContext = getContextDescriptor(cast<Decl>(RD->getDeclContext()));
|
||||
|
|
|
@ -179,7 +179,7 @@ RValue CodeGenFunction::EmitCXXMemberCallExpr(const CXXMemberCallExpr *CE,
|
|||
const CXXMethodDecl *MD = cast<CXXMethodDecl>(ME->getMemberDecl());
|
||||
|
||||
CGDebugInfo *DI = getDebugInfo();
|
||||
if (DI && CGM.getCodeGenOpts().LimitDebugInfo
|
||||
if (DI && CGM.getCodeGenOpts().DebugInfo == CodeGenOptions::LimitedDebugInfo
|
||||
&& !isa<CallExpr>(ME->getBase())) {
|
||||
QualType PQTy = ME->getBase()->IgnoreParenImpCasts()->getType();
|
||||
if (const PointerType * PTy = dyn_cast<PointerType>(PQTy)) {
|
||||
|
|
|
@ -798,14 +798,15 @@ Value *ScalarExprEmitter::VisitMemberExpr(MemberExpr *E) {
|
|||
return Builder.getInt(Value);
|
||||
}
|
||||
|
||||
// Emit debug info for aggregate now, if it was delayed to reduce
|
||||
// Emit debug info for aggregate now, if it was delayed to reduce
|
||||
// debug info size.
|
||||
CGDebugInfo *DI = CGF.getDebugInfo();
|
||||
if (DI && CGF.CGM.getCodeGenOpts().LimitDebugInfo) {
|
||||
if (DI &&
|
||||
CGF.CGM.getCodeGenOpts().DebugInfo == CodeGenOptions::LimitedDebugInfo) {
|
||||
QualType PQTy = E->getBase()->IgnoreParenImpCasts()->getType();
|
||||
if (const PointerType * PTy = dyn_cast<PointerType>(PQTy))
|
||||
if (FieldDecl *M = dyn_cast<FieldDecl>(E->getMemberDecl()))
|
||||
DI->getOrCreateRecordType(PTy->getPointeeType(),
|
||||
DI->getOrCreateRecordType(PTy->getPointeeType(),
|
||||
M->getParent()->getLocation());
|
||||
}
|
||||
return EmitLoadOfLValue(E);
|
||||
|
|
|
@ -110,7 +110,8 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
|
|||
|
||||
// If debug info or coverage generation is enabled, create the CGDebugInfo
|
||||
// object.
|
||||
if (CodeGenOpts.DebugInfo || CodeGenOpts.EmitGcovArcs ||
|
||||
if (CodeGenOpts.DebugInfo != CodeGenOptions::NoDebugInfo ||
|
||||
CodeGenOpts.EmitGcovArcs ||
|
||||
CodeGenOpts.EmitGcovNotes)
|
||||
DebugInfo = new CGDebugInfo(*this);
|
||||
|
||||
|
|
|
@ -181,8 +181,18 @@ static void AnalyzerOptsToArgs(const AnalyzerOptions &Opts, ToArgsList &Res) {
|
|||
}
|
||||
|
||||
static void CodeGenOptsToArgs(const CodeGenOptions &Opts, ToArgsList &Res) {
|
||||
if (Opts.DebugInfo)
|
||||
Res.push_back("-g");
|
||||
switch (Opts.DebugInfo) {
|
||||
case CodeGenOptions::NoDebugInfo:
|
||||
break;
|
||||
case CodeGenOptions::LimitedDebugInfo:
|
||||
Res.push_back("-g");
|
||||
Res.push_back("-flimit-debug-info");
|
||||
break;
|
||||
case CodeGenOptions::FullDebugInfo:
|
||||
Res.push_back("-g");
|
||||
Res.push_back("-fno-limit-debug-info");
|
||||
break;
|
||||
}
|
||||
if (Opts.DisableLLVMOpts)
|
||||
Res.push_back("-disable-llvm-optzns");
|
||||
if (Opts.DisableRedZone)
|
||||
|
@ -1083,12 +1093,16 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
|
|||
: CodeGenOptions::OnlyAlwaysInlining;
|
||||
// -fno-inline-functions overrides OptimizationLevel > 1.
|
||||
Opts.NoInline = Args.hasArg(OPT_fno_inline);
|
||||
Opts.Inlining = Args.hasArg(OPT_fno_inline_functions) ?
|
||||
Opts.Inlining = Args.hasArg(OPT_fno_inline_functions) ?
|
||||
CodeGenOptions::OnlyAlwaysInlining : Opts.Inlining;
|
||||
|
||||
Opts.DebugInfo = Args.hasArg(OPT_g);
|
||||
Opts.LimitDebugInfo = !Args.hasArg(OPT_fno_limit_debug_info)
|
||||
|| Args.hasArg(OPT_flimit_debug_info);
|
||||
if (Args.hasArg(OPT_g)) {
|
||||
if (Args.hasFlag(OPT_flimit_debug_info, OPT_fno_limit_debug_info, true))
|
||||
Opts.DebugInfo = CodeGenOptions::LimitedDebugInfo;
|
||||
else
|
||||
Opts.DebugInfo = CodeGenOptions::FullDebugInfo;
|
||||
}
|
||||
|
||||
Opts.DisableLLVMOpts = Args.hasArg(OPT_disable_llvm_optzns);
|
||||
Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
|
||||
Opts.ForbidGuardVariables = Args.hasArg(OPT_fforbid_guard_variables);
|
||||
|
|
Loading…
Reference in New Issue