[PATCH] Add warning capabilities in LLVM (backend part)

hfinkel at anl.gov hfinkel at anl.gov
Fri Nov 15 10:51:23 PST 2013

  I'm very glad that you're working on this... I have some requests re: the interface.

Comment at: include/llvm/IR/LLVMContext.h:87
@@ +86,3 @@
+  typedef void (*ReportHandlerTy)(void *Context, ReportKind Kind,
+                                  StringRef StringData,
+                                  ReportSeverity Severity,
I think that having this capability is really important, but I think that we'll want a slightly more structured interface.

First, inline asm calls have "srcloc" metadata associated with them; this allows the frontend to match any error to the frontend source location. This capability is not really inline-asm specific, however, and I think it should be expressed in the interface. Thus, adding a const MDNode *SrcLoc parameter would be good.

Second, I don't think that "StringRef StringData" is a good way to send arbitrary data to the frontend. I recommend ArrayRef<Value *>. That will allow references to many different things to be passed, and since MDNodes are also values, we can also construct arbitrary collections, strings, etc. While this might entail constructing values not used for later code generation, I hope that error reporting is not on a common hot path, and so this should not be  a problem.

Third (and I feel less-strongly about this, but think it is a good idea), the default message printer should recognize %0, %1, etc. as references to the values in the data array. These can be printed using the default Value printer (dump()) by default, but this gives the opportunity for a frontend to do something more sophisticated as well. Also, this saves us from having to spew stringstream-like printing code all over the backends.


More information about the llvm-commits mailing list