Add support for missed and analysis optimization remarks.

Summary:
This adds two new diagnostics: -pass-remarks-missed and
-pass-remarks-analysis. They take the same values as -pass-remarks but
are intended to be triggered in different contexts.

-pass-remarks-missed is used by LLVMContext::emitOptimizationRemarkMissed,
which passes call when they tried to apply a transformation but
couldn't.

-pass-remarks-analysis is used by LLVMContext::emitOptimizationRemarkAnalysis,
which passes call when they want to inform the user about analysis
results.

The patch also:

1- Adds support in the inliner for the two new remarks and a
   test case.

2- Moves emitOptimizationRemark* functions to the llvm namespace.

3- Adds an LLVMContext argument instead of making them member functions
   of LLVMContext.

Reviewers: qcolombet

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D3682

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209442 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Diego Novillo
2014-05-22 14:19:46 +00:00
parent de70176f5f
commit d16404a0e7
12 changed files with 387 additions and 92 deletions

View File

@ -20,6 +20,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
@ -789,9 +790,9 @@ struct StrLenOpt : public LibCallOptimization {
uint64_t LenTrue = GetStringLength(SI->getTrueValue());
uint64_t LenFalse = GetStringLength(SI->getFalseValue());
if (LenTrue && LenFalse) {
Context->emitOptimizationRemark(
"simplify-libcalls", *Caller, SI->getDebugLoc(),
"folded strlen(select) to select of constants");
emitOptimizationRemark(*Context, "simplify-libcalls", *Caller,
SI->getDebugLoc(),
"folded strlen(select) to select of constants");
return B.CreateSelect(SI->getCondition(),
ConstantInt::get(CI->getType(), LenTrue-1),
ConstantInt::get(CI->getType(), LenFalse-1));