[llvm] [Debugify] applyDebugify - remove unnecessary defaults arg values and assert dereferencable values (PR #127186)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 14 01:37:44 PST 2025
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/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
>From 02de313d51a8380115475e4a061ac32fd77a5fd6 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Fri, 14 Feb 2025 09:35:40 +0000
Subject: [PATCH] [Debugify] applyDebugify - remove unnecessary defaults arg
values and assert dereferencable values
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
---
llvm/lib/Transforms/Utils/Debugify.cpp | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index e47a6ce6e9205..e6b5e267d192b 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -214,30 +214,27 @@ bool llvm::applyDebugifyMetadata(
return true;
}
-static bool
-applyDebugify(Function &F,
- enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
- DebugInfoPerPass *DebugInfoBeforePass = nullptr,
- StringRef NameOfWrappedPass = "") {
+static bool applyDebugify(Function &F, enum DebugifyMode Mode,
+ DebugInfoPerPass *DebugInfoBeforePass,
+ StringRef NameOfWrappedPass = "") {
Module &M = *F.getParent();
auto FuncIt = F.getIterator();
if (Mode == DebugifyMode::SyntheticDebugInfo)
return applyDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
"FunctionDebugify: ", /*ApplyToMF*/ nullptr);
- assert(DebugInfoBeforePass);
+ assert(DebugInfoBeforePass && "Missing debug info metadata");
return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
"FunctionDebugify (original debuginfo)",
NameOfWrappedPass);
}
-static bool
-applyDebugify(Module &M,
- enum DebugifyMode Mode = DebugifyMode::SyntheticDebugInfo,
- DebugInfoPerPass *DebugInfoBeforePass = nullptr,
- StringRef NameOfWrappedPass = "") {
+static bool applyDebugify(Module &M, enum DebugifyMode Mode,
+ DebugInfoPerPass *DebugInfoBeforePass,
+ StringRef NameOfWrappedPass = "") {
if (Mode == DebugifyMode::SyntheticDebugInfo)
return applyDebugifyMetadata(M, M.functions(),
"ModuleDebugify: ", /*ApplyToMF*/ nullptr);
+ assert(DebugInfoBeforePass && "Missing debug info metadata");
return collectDebugInfoMetadata(M, M.functions(), *DebugInfoBeforePass,
"ModuleDebugify (original debuginfo)",
NameOfWrappedPass);
More information about the llvm-commits
mailing list