[SelectionDAGBuilder] Replace asserts inside LLVM_DEBUG. NFC#199748
[SelectionDAGBuilder] Replace asserts inside LLVM_DEBUG. NFC#199748davemgreen wants to merge 1 commit into
Conversation
These assert were inside an LLVM_DEBUG macro, meaning they were very rarely if ever tested. The second "LowerFormalArguments emitted a value with the wrong type!" assert would fire in a number of tests so has been removed. The other was replaced with an all_of assert.
|
@llvm/pr-subscribers-llvm-selectiondag Author: David Green (davemgreen) ChangesThese assert were inside an LLVM_DEBUG macro, meaning they were very rarely if ever tested. The second "LowerFormalArguments emitted a value with the wrong type!" assert would fire in a number of tests so has been removed. The other was replaced with an all_of assert. Noticed when looking at #198107 / #199412. Full diff: https://github.com/llvm/llvm-project/pull/199748.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 579bff7d3ab60..05c75c484889e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -12097,14 +12097,8 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
"LowerFormalArguments didn't return a valid chain!");
assert(InVals.size() == Ins.size() &&
"LowerFormalArguments didn't emit the correct number of values!");
- LLVM_DEBUG({
- for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
- assert(InVals[i].getNode() &&
- "LowerFormalArguments emitted a null value!");
- assert(EVT(Ins[i].VT) == InVals[i].getValueType() &&
- "LowerFormalArguments emitted a value with the wrong type!");
- }
- });
+ assert(all_of(InVals, [](SDValue InVal) { return InVal.getNode(); }) &&
+ "LowerFormalArguments emitted a null value!");
// Update the DAG with the new chain value resulting from argument lowering.
DAG.setRoot(NewRoot);
|
efriedma-quic
left a comment
There was a problem hiding this comment.
LGTM
I was curious, so I dug a bit for other instances of this pattern. Fortunately it seems to be pretty rare. Found some use in flang/lib/Optimizer/Transforms/FIRToMemRef.cpp, mlir/lib/Transforms/Utils/DialectConversion.cpp . (Not a comprehensive survey.)
These assert were inside an LLVM_DEBUG macro, meaning they were very rarely if ever tested. The second "LowerFormalArguments emitted a value with the wrong type!" assert would fire in a number of tests so has been removed. The other was replaced with an all_of assert.
Noticed when looking at #198107 / #199412.