Skip to content

Commit 9178c4a

Browse files
authored
Merge pull request #71962 from augusto2112/embedded-flag
[DebugInfo] Emit embedded swift into DW_AT_APPLE_flags
2 parents 70cf5d4 + 0b8abda commit 9178c4a

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,8 @@ class IRGenOptions {
602602
}
603603

604604
std::string getDebugFlags(StringRef PrivateDiscriminator,
605-
bool EnableCXXInterop) const {
605+
bool EnableCXXInterop,
606+
bool EnableEmbeddedSwift) const {
606607
std::string Flags = DebugFlags;
607608
if (!PrivateDiscriminator.empty()) {
608609
if (!Flags.empty())
@@ -614,6 +615,12 @@ class IRGenOptions {
614615
Flags += " ";
615616
Flags += "-enable-experimental-cxx-interop";
616617
}
618+
if (EnableEmbeddedSwift) {
619+
if (!Flags.empty())
620+
Flags += " ";
621+
Flags += "-enable-embedded-swift";
622+
}
623+
617624
return Flags;
618625
}
619626

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2380,9 +2380,12 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
23802380

23812381
bool EnableCXXInterop =
23822382
IGM.getSILModule().getASTContext().LangOpts.EnableCXXInterop;
2383+
bool EnableEmbeddedSwift =
2384+
IGM.getSILModule().getASTContext().LangOpts.hasFeature(Feature::Embedded);
23832385
TheCU = DBuilder.createCompileUnit(
23842386
Lang, MainFile, Producer, Opts.shouldOptimize(),
2385-
Opts.getDebugFlags(PD, EnableCXXInterop), MajorRuntimeVersion, SplitName,
2387+
Opts.getDebugFlags(PD, EnableCXXInterop, EnableEmbeddedSwift),
2388+
MajorRuntimeVersion, SplitName,
23862389
Opts.DebugInfoLevel > IRGenDebugInfoLevel::LineTables
23872390
? llvm::DICompileUnit::FullDebug
23882391
: llvm::DICompileUnit::LineTablesOnly,

lib/IRGen/IRGenModule.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,16 @@ static clang::CodeGenerator *createClangCodeGenerator(ASTContext &Context,
122122
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
123123
CGO.DwarfVersion = Opts.DWARFVersion;
124124
CGO.DwarfDebugFlags =
125-
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
125+
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop,
126+
Context.LangOpts.hasFeature(Feature::Embedded));
126127
break;
127128
case IRGenDebugInfoFormat::CodeView:
128129
CGO.EmitCodeView = true;
129130
CGO.DebugCompilationDir = Opts.DebugCompilationDir;
130131
// This actually contains the debug flags for codeview.
131132
CGO.DwarfDebugFlags =
132-
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop);
133+
Opts.getDebugFlags(PD, Context.LangOpts.EnableCXXInterop,
134+
Context.LangOpts.hasFeature(Feature::Embedded));
133135
break;
134136
}
135137
if (!Opts.TrapFuncName.empty()) {

test/DebugInfo/embedded.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Check that the "-enable-embedded-swift" is stored as a flag in the
2+
// Compile Unit.
3+
4+
// RUN: %target-swift-frontend -emit-ir -enable-experimental-feature Embedded -g %s -o - | %FileCheck %s
5+
6+
// REQUIRES: swift_in_compiler
7+
// REQUIRES: executable_test
8+
// REQUIRES: OS=macosx
9+
10+
// CHECK: !DICompileUnit({{.*}}flags: "-enable-embedded-swift"

0 commit comments

Comments
 (0)