[LLVMdev] Suggestion: include object data in assertion messages

someguy just.s0m3.guy+llvmdev at gmail.com
Thu Mar 12 01:47:54 PDT 2009


Hi all,

There are many assertions sprinkled throughout the llvm codebase,
which is a GoodThing. Most of the assertions even have informative
messages, which is a BetterThing.

However, assertion messages are static strings, and don't include any
information about the particular object/value which caused the
assertion. In a 'data oriented' system like llvm, this makes it really
difficult to pinpoint which node is actually triggering the assertion.

For example, in ScheduleDAGSDNodesEmit.cpp
(lib/CodeGen/SelectionDAG/), in the ScheduleDAGSDNodes::AddOperand
method, there is the following assert:

assert(Op.getValueType() !=MVT::Other && Op.getValueType() !=
MVT::Flag && "Chain and flag operands should occur at end of operand
list!");

In order to understand which operand was causing the failure, I need
to dig quite a lot.

What I propose is that an 'assertf' function be added, which wraps
assert and sprintf. This would allow the 'missing' information to be
added to assertion messages. This (imo) would be the BestThing ;)

Thoughts?



More information about the llvm-dev mailing list