Skip to content

Commit 75e10a6

Browse files
committed
This fixes a bot failure in the LLDB testsuite.
This removes an assertion that no longer serves its purpose and relaxes the IRBuilder checks for debug info when generating code inside the debugger. When LLDB is JIT-compiling expressions, it will not generate a SWIFT_ENTRY_POINT_FUNCTION (there will be one per expression) but it will still generate the equivalent of top level code. rdar://problem/26955467
1 parent 361d9e6 commit 75e10a6

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ void IRGenModule::emitRuntimeRegistration() {
539539

540540
// If we're debugging, we probably don't have a main. Find a
541541
// function marked with the LLDBDebuggerFunction attribute instead.
542-
if (!EntryPoint && Context.LangOpts.DebuggerSupport) {
542+
if (Context.LangOpts.DebuggerSupport) {
543+
assert(!EntryPoint && "unexpected main");
543544
for (SILFunction &SF : getSILModule()) {
544545
if (SF.hasLocation()) {
545546
if (Decl* D = SF.getLocation().getAsASTNode<Decl>()) {
@@ -573,15 +574,16 @@ void IRGenModule::emitRuntimeRegistration() {
573574
{
574575
llvm::BasicBlock *EntryBB = &EntryFunction->getEntryBlock();
575576
llvm::BasicBlock::iterator IP = EntryBB->getFirstInsertionPt();
576-
IRBuilder Builder(getLLVMContext(), DebugInfo);
577+
IRBuilder Builder(getLLVMContext(),
578+
DebugInfo && !Context.LangOpts.DebuggerSupport);
577579
Builder.llvm::IRBuilderBase::SetInsertPoint(EntryBB, IP);
578-
if (DebugInfo)
580+
if (DebugInfo && !Context.LangOpts.DebuggerSupport)
579581
DebugInfo->setEntryPointLoc(Builder);
580582
Builder.CreateCall(RegistrationFunction, {});
581583
}
582584

583585
IRGenFunction RegIGF(*this, RegistrationFunction);
584-
if (DebugInfo)
586+
if (DebugInfo && !Context.LangOpts.DebuggerSupport)
585587
DebugInfo->emitArtificialFunction(RegIGF, RegistrationFunction);
586588

587589
// Register ObjC protocols, classes, and extensions we added.

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,6 @@ static CanSILFunctionType getFunctionType(SILType SILTy) {
490490
llvm::DIScope *IRGenDebugInfo::getEntryPointFn() {
491491
// Lazily create EntryPointFn.
492492
if (!EntryPointFn) {
493-
auto main = IGM.getSILModule().lookUpFunction(SWIFT_ENTRY_POINT_FUNCTION);
494-
assert(main && "emitting TopLevelCodeDecl in module without "
495-
SWIFT_ENTRY_POINT_FUNCTION "?");
496493
EntryPointFn = DBuilder.createReplaceableCompositeType(
497494
llvm::dwarf::DW_TAG_subroutine_type, SWIFT_ENTRY_POINT_FUNCTION,
498495
MainFile, MainFile, 0);

lib/IRGen/IRGenFunction.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@
3131
using namespace swift;
3232
using namespace irgen;
3333

34-
IRGenFunction::IRGenFunction(IRGenModule &IGM,
35-
llvm::Function *Fn,
34+
IRGenFunction::IRGenFunction(IRGenModule &IGM, llvm::Function *Fn,
3635
const SILDebugScope *DbgScope,
3736
Optional<SILLocation> DbgLoc)
38-
: IGM(IGM), Builder(IGM.getLLVMContext(), IGM.DebugInfo),
39-
CurFn(Fn), DbgScope(DbgScope)
40-
{
37+
: IGM(IGM), Builder(IGM.getLLVMContext(),
38+
IGM.DebugInfo && !IGM.Context.LangOpts.DebuggerSupport),
39+
CurFn(Fn), DbgScope(DbgScope) {
4140

4241
// Make sure the instructions in this function are attached its debug scope.
4342
if (IGM.DebugInfo) {

0 commit comments

Comments
 (0)