mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add SIL syntax for declaring debug variables.
Debug variable info may be attached to debug_value, debug_value_addr, alloc_box, and alloc_stack instructions. In order to write textual SIL -> SIL testcases that exercise the handling of debug information by SIL passes, we need to make a couple of additions to the textual SIL language. In memory, the debug information attached to SIL instructions references information from the AST. If we want to create debug info from parsing a textual .sil file, these bits need to be made explicit. Performance Notes: This is memory neutral for compilations from Swift source code, because the variable name is still stored in the AST. For compilations from textual source the variable name is stored in tail- allocated memory following the SIL instruction that introduces the variable. <rdar://problem/22707128>
This commit is contained in:
@@ -28,7 +28,7 @@ SILValue SILGenFunction::emitSelfDecl(VarDecl *selfDecl) {
|
||||
SILLocation PrologueLoc(selfDecl);
|
||||
PrologueLoc.markAsPrologue();
|
||||
unsigned ArgNo = 1; // Hardcoded for destructors.
|
||||
B.createDebugValue(PrologueLoc, selfValue, ArgNo);
|
||||
B.createDebugValue(PrologueLoc, selfValue, {selfDecl->isLet(), ArgNo});
|
||||
return selfValue;
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ struct ArgumentInitVisitor :
|
||||
if (isa<BuiltinUnsafeValueBufferType>(objectType)) {
|
||||
// FIXME: mark a debug location?
|
||||
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(address);
|
||||
gen.B.createDebugValueAddr(loc, address, ArgNo);
|
||||
gen.B.createDebugValueAddr(loc, address, {vd->isLet(), ArgNo});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -278,9 +278,9 @@ struct ArgumentInitVisitor :
|
||||
// argument if we're responsible for it.
|
||||
gen.VarLocs[vd] = SILGenFunction::VarLoc::get(argrv.getValue());
|
||||
if (argrv.getType().isAddress())
|
||||
gen.B.createDebugValueAddr(loc, argrv.getValue(), ArgNo);
|
||||
gen.B.createDebugValueAddr(loc, argrv.getValue(), {vd->isLet(), ArgNo});
|
||||
else
|
||||
gen.B.createDebugValue(loc, argrv.getValue(), ArgNo);
|
||||
gen.B.createDebugValue(loc, argrv.getValue(), {vd->isLet(), ArgNo});
|
||||
} else {
|
||||
// If the variable is mutable, we need to copy or move the argument
|
||||
// value to local mutable memory.
|
||||
@@ -464,7 +464,7 @@ static void emitCaptureArguments(SILGenFunction &gen, CapturedValue capture,
|
||||
if (auto *AllocStack = dyn_cast<AllocStackInst>(val))
|
||||
AllocStack->setArgNo(ArgNo);
|
||||
else
|
||||
gen.B.createDebugValue(Loc, val, ArgNo);
|
||||
gen.B.createDebugValue(Loc, val, {/*Constant*/true, ArgNo});
|
||||
if (!lowering.isTrivial())
|
||||
gen.enterDestroyCleanup(val);
|
||||
break;
|
||||
@@ -479,7 +479,7 @@ static void emitCaptureArguments(SILGenFunction &gen, CapturedValue capture,
|
||||
SILValue box = new (gen.SGM.M) SILArgument(gen.F.begin(), boxTy, VD);
|
||||
SILValue addr = gen.B.createProjectBox(VD, box);
|
||||
gen.VarLocs[VD] = SILGenFunction::VarLoc::get(addr, box);
|
||||
gen.B.createDebugValueAddr(Loc, addr, ArgNo);
|
||||
gen.B.createDebugValueAddr(Loc, addr, {/*Constant*/false, ArgNo});
|
||||
gen.Cleanups.pushCleanup<StrongReleaseCleanup>(box);
|
||||
break;
|
||||
}
|
||||
@@ -488,7 +488,7 @@ static void emitCaptureArguments(SILGenFunction &gen, CapturedValue capture,
|
||||
SILType ty = gen.getLoweredType(type).getAddressType();
|
||||
SILValue addr = new (gen.SGM.M) SILArgument(gen.F.begin(), ty, VD);
|
||||
gen.VarLocs[VD] = SILGenFunction::VarLoc::get(addr);
|
||||
gen.B.createDebugValueAddr(Loc, addr, ArgNo);
|
||||
gen.B.createDebugValueAddr(Loc, addr, {/*Constant*/true, ArgNo});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user