I think this is a documentation bug. If we look at the implementation:
DILabel *DIBuilder::createLabel(
DIScope *Scope, StringRef Name, DIFile *File,
unsigned LineNo, bool AlwaysPreserve) {
DIScope *Context = getNonCompileUnitScope(Scope);
auto *Node =
DILabel::get(VMContext, cast_or_null<DILocalScope>(Context), Name,
File, LineNo);
if (AlwaysPreserve) {
/// The optimizer may remove labels. If there is an interest
/// to preserve label info in such situation then append it to
/// the list of retained nodes of the DISubprogram.
DISubprogram *Fn = getDISubprogram(Scope);
assert(Fn && "Missing subprogram for label");
PreservedLabels[Fn].emplace_back(Node);
}
return Node;
}
The position of the doc comment implies that this is something the function will do for us if we pass alwaysPreserve=True
, but when you see this doc comment on the doxygen page, it looks like it's something you have to do yourself!