This is an archive of the discontinued LLVM Phabricator instance.

Allow diagnostic handlers to check for optimization remarks.
ClosedPublic

Authored by dnovillo on Apr 11 2014, 3:02 PM.

Details

Summary

When optimization remarks are enabled via the driver flag -Rpass, we
should allow the FE diagnostic handler to check if the given pass name
needs a diagnostic.

We were unconditionally checking the pattern defined in opt's
-pass-remarks flag. This was causing the FE to not emit any diagnostics.

Diff Detail

Event Timeline

Hi Diego,

I'd like we take another direction for this patch. See my inline comment.

Thanks,
-Quentin

lib/IR/LLVMContext.cpp
178

I am not a huge fan of duplicating this test (i.e., this is the test used in LLVMContext::diagnose).

Could we instead teach optimizationRemarksEnabledFor to always returns true when we set a diagnostic handler?

For instance, we could change the method used to check the optimization remarks within LLVMContext::setDiagnosticHandler.

dnovillo added inline comments.Apr 15 2014, 12:20 PM
lib/IR/LLVMContext.cpp
178

Oh, sure. I had initially done that, but it didn't seem like the predicate optimizationRemarksEnabledFor() was semantically equivalent if it also checks for a handler.

I'll sink the decision in LLVMContext::setDiagnosticHandler.

dnovillo updated this revision to Unknown Object (????).Apr 15 2014, 3:41 PM

I did something slightly different. Setting a new function pointer
just for the optimization remarks seemed like overkill. I am doing
something similar to what is done in the front end.

The backend handler checks whether it's dealing with an optimization
remark. If so, it further checks the regexp passed in -pass-remarks.
This seemed less invasive than the additional function pointer.

qcolombet accepted this revision.Apr 15 2014, 3:59 PM

Hi Diego,

That’s a good idea.

LGTM.

Thanks,
-Quentin

dnovillo closed this revision.Apr 16 2014, 1:55 PM