Skip to content

Commit 1b6340d

Browse files
authored
[Debugify] applyDebugify - remove unnecessary defaults arg values and assert dereferencable values (#127186)
The applyDebugify helpers were providing default arguments despite all callers providing them, so strip them for clarity. The Function variant was asserting that DebugInfoBeforePass was non-null before dereferencing so I've added an equivalent assert to the Method variant as well. Fixes #97626
1 parent c65ed96 commit 1b6340d

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

llvm/lib/Transforms/Utils/Debugify.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -214,30 +214,27 @@ bool llvm::applyDebugifyMetadata(
214214
return true;
215215
}
216216

217-
static bool
218-
applyDebugify(Function &F,
219-
enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
220-
DebugInfoPerPass *DebugInfoBeforePass = nullptr,
221-
StringRef NameOfWrappedPass = "") {
217+
static bool applyDebugify(Function &F, enum DebugifyMode Mode,
218+
DebugInfoPerPass *DebugInfoBeforePass,
219+
StringRef NameOfWrappedPass = "") {
222220
Module &M = *F.getParent();
223221
auto FuncIt = F.getIterator();
224222
if (Mode == DebugifyMode::SyntheticDebugInfo)
225223
return applyDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
226224
"FunctionDebugify: ", /*ApplyToMF*/ nullptr);
227-
assert(DebugInfoBeforePass);
225+
assert(DebugInfoBeforePass && "Missing debug info metadata");
228226
return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
229227
"FunctionDebugify (original debuginfo)",
230228
NameOfWrappedPass);
231229
}
232230

233-
static bool
234-
applyDebugify(Module &M,
235-
enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
236-
DebugInfoPerPass *DebugInfoBeforePass = nullptr,
237-
StringRef NameOfWrappedPass = "") {
231+
static bool applyDebugify(Module &M, enum DebugifyMode Mode,
232+
DebugInfoPerPass *DebugInfoBeforePass,
233+
StringRef NameOfWrappedPass = "") {
238234
if (Mode == DebugifyMode::SyntheticDebugInfo)
239235
return applyDebugifyMetadata(M, M.functions(),
240236
"ModuleDebugify: ", /*ApplyToMF*/ nullptr);
237+
assert(DebugInfoBeforePass && "Missing debug info metadata");
241238
return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
242239
"ModuleDebugify (original debuginfo)",
243240
NameOfWrappedPass);

0 commit comments

Comments
 (0)