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

Quentin Colombet qcolombet at apple.com
Tue Dec 10 16:31:36 PST 2013


Hi dblaikie, rengolin, chandlerc, echristo,

Hi,

This patch implements the latest  proposal discussed a few weeks ago regarding adding warning capabilities in LLVM.
The original RFC:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063845.html

The latest discussion with the new design:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131111/195244.html
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20131118/195627.html 

//// Overview ////

The patch adds a new LLVMContext::diagnose that can be used to communicate to the front-end, if any, that something of interest happened.
The diagnostics are supported by a new abstraction, the DiagnosticInfo class.
The base class contains the following information:
- The kind of the report: What this is this about.
- The severity of the report: How bad this is.

This patch also adds 3 classes:
- DiagnosticInfoInlineAsm: For inline asm reporting. Basically, this diagnostic will be used to switch to the new diagnostic API for LLVMContext::emitError.
- DiagnosticStackSize: For stack size reporting. Comes as a replacement of the hard coded warning in PEI.
- DiagnosticOther: For all other reporting. Features a message with %[0-9]+ specifiers and an array of values. Each specifier will be replaced by the printing of the related index from the array of values.

This patch introduces a new DiagnosticHandlerTy and a new DiagnosticContext that should be set by the front-end to be able to map these diagnostics in its own system.

//// Next Steps ////

- Send the patch for clang (I have it on hold).
- Switch to this reporting for all warnings printing happening in the backend (i.e., get rid of the hard coded warnings).
- Switch LLVMContext::emitError to the new diagnostic API.
- Add an entry in LLVM documentation about this diagnostic reporting feature.

//// Open Questions ////

- Should we make SMDiagnostic a sub class of DiagnosticInfo?
The idea would be to get rid of the InlineAsmDiagHandler.

- Do we want to provide a C API for this?

- Do we want to extend that to fatal error as well?
That would be a nice homogenization of the framework (replace (some of) the calls to report_fatal_error).

Thanks for your reviews.

Cheers,
Quentin

PS: Hal, DiagnosticPrinter class does not include SCEV or MachineInstr because these are not part of the IR library.

http://llvm-reviews.chandlerc.com/D2376

Files:
  include/llvm/IR/LLVMContext.h
  include/llvm/Support/DiagnosticInfo.h
  include/llvm/Support/DiagnosticPrinter.h
  lib/CodeGen/PrologEpilogInserter.cpp
  lib/IR/LLVMContext.cpp
  lib/IR/LLVMContextImpl.cpp
  lib/IR/LLVMContextImpl.h
  lib/Support/CMakeLists.txt
  lib/Support/DiagnosticInfo.cpp
  lib/Support/DiagnosticPrinter.cpp
  test/CodeGen/ARM/warn-stack.ll
  test/CodeGen/X86/warn-stack.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2376.1.patch
Type: text/x-patch
Size: 25410 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131210/b00653e3/attachment.bin>


More information about the llvm-commits mailing list