[llvm] r223150 - Restructure some assertion checking based on post commit feedback by Aaron and Tom.
Philip Reames
listmail at philipreames.com
Tue Dec 2 13:01:48 PST 2014
Author: reames
Date: Tue Dec 2 15:01:48 2014
New Revision: 223150
URL: http://llvm.org/viewvc/llvm-project?rev=223150&view=rev
Log:
Restructure some assertion checking based on post commit feedback by Aaron and Tom.
Modified:
llvm/trunk/include/llvm/IR/Statepoint.h
llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
Modified: llvm/trunk/include/llvm/IR/Statepoint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Statepoint.h?rev=223150&r1=223149&r2=223150&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Statepoint.h (original)
+++ llvm/trunk/include/llvm/IR/Statepoint.h Tue Dec 2 15:01:48 2014
@@ -129,7 +129,13 @@ class StatepointBase {
#ifndef NDEBUG
+ /// Asserts if this statepoint is malformed. Common cases for failure
+ /// include incorrect length prefixes for variable length sections or
+ /// illegal values for parameters.
void verify() {
+ assert(numCallArgs() >= 0 &&
+ "number of arguments to actually callee can't be negative");
+
// The internal asserts in the iterator accessors do the rest.
(void)call_args_begin();
(void)call_args_end();
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=223150&r1=223149&r2=223150&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Tue Dec 2 15:01:48 2014
@@ -228,10 +228,6 @@ static SDNode *lowerCallFromStatepoint(c
dyn_cast<IntrinsicInst>(&CI)->getIntrinsicID() &&
"function called must be the statepoint function");
- int NumCallArgs = dyn_cast<ConstantInt>(CI.getArgOperand(1))->getZExtValue();
- assert(NumCallArgs >= 0 && "non-negative");
- (void)NumCallArgs;
-
ImmutableStatepoint StatepointOperands(&CI);
// Lower the actual call itself - This is a bit of a hack, but we want to
@@ -240,9 +236,6 @@ static SDNode *lowerCallFromStatepoint(c
// differently. Hopefully, this is slightly more robust w.r.t. calling
// convention, return values, and other function attributes.
Value *ActualCallee = const_cast<Value *>(StatepointOperands.actualCallee());
-#ifndef NDEBUG
- StatepointOperands.verify();
-#endif
std::vector<Value *> Args;
CallInst::const_op_iterator arg_begin = StatepointOperands.call_args_begin();
@@ -500,6 +493,13 @@ void SelectionDAGBuilder::visitStatepoin
#endif
ImmutableStatepoint ISP(&CI);
+#ifndef NDEBUG
+ // If this is a malformed statepoint, report it early to simplify debugging.
+ // This should catch any IR level mistake that's made when constructing or
+ // transforming statepoints.
+ ISP.verify();
+#endif
+
// Lower statepoint vmstate and gcstate arguments
SmallVector<SDValue, 10> LoweredArgs;
More information about the llvm-commits
mailing list