Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way for OptimizationRemarkEmitter::allowExtraAnalysis to check if (specific) remarks are enabled #31699

Closed
llvmbot opened this issue Mar 20, 2017 · 7 comments
Labels
bugzilla Issues migrated from bugzilla llvm-tools All llvm tools that do not have corresponding tag

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 20, 2017

Bugzilla Link 32352
Resolution FIXED
Resolved on Nov 07, 2018 00:22
Version trunk
OS All
Reporter LLVM Bugzilla Contributor
CC @ahmedbougacha,@ayalz,@hfinkel,@MatzeB,@pcc,@tobiasgrosser

Extended Description

There is already a need for this. For example WholeProgramDevirt instantiates a remark just to check its Enabled field to see if remarks are on or not. This actually does not work because clang does not use the Enabled field only (opt's -pass-remarks* do).

Also GlobalISel wants to do something like this and it's currently using a cl::opt as a work-around.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 8, 2017

Moving the discussion from llvm-dev here. This was Vivek's question.

Hi Adam,

I looked into code related to above feature request and perhaps I am not yet clear about this.
I have tried out following things:

  1. allowExtraAnalysis function will have a string parameter which is pass name.

  2. Find an appropriate entry point in Clang where we can make a shared_ptr for
    OptimizationRemarkPattern, OptimizationRemarkAnalysisPattern in LLVMContext class.

  3. Use above changes so that allowExtraAnalysis can be used to check if specific
    remark is on or not.

However I am confused because there is one more class DiagnosticInfo in LLVM which handles same thing for opt's flags, but why those informations are not used in allowExtraAnalysis() ? Have I understood the purpose of allowExtraAnalysis or not ?

Please guide here.

Sincerely,
Vivek

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 8, 2017

Thanks for taking this on!

  1. allowExtraAnalysis function will have a string parameter which is pass
    name.

I think it will also need the remark kind (e.g. DK_OptRemarkAnalysis) unless we want to return all three in a structure. The latter may be useful since passes may want to cache these together in order to have zero-overhead checking to see whether the remarks are off.

  1. Find an appropriate entry point in Clang where we can make a shared_ptr
    for
    OptimizationRemarkPattern, OptimizationRemarkAnalysisPattern in LLVMContext
    class.

I am assuming you were thinking of doing this to call isEnabled on the remark; unfortunately that does not work. (I know that is what WholeProgramDevirt does too.) isEnabled is not used in clang in llvm (opt/llc):

https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenAction.cpp#L598

I think that the new design should move isEnabled to the DiagnosticHandler in the context. DiagnosticHandler is only a callback now so it should probably become a class. Then clients can ask whether a kind of remark (OptRemark, OptRemarkMissed, OptRemarkAnalysis) is enabled for a pass specified by the pass name.

  1. Use above changes so that allowExtraAnalysis can be used to check if
    specific
    remark is on or not.

Yes.

However I am confused because there is one more` class DiagnosticInfo in LLVM
which handles same thing for opt's flags, but why those informations are not
used in allowExtraAnalysis() ? Have I understood the purpose of
allowExtraAnalysis or not ?

As explained above.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 9, 2017

Thanks for taking this on!

  1. allowExtraAnalysis function will have a string parameter which is pass
    name.

I think it will also need the remark kind (e.g. DK_OptRemarkAnalysis) unless
we want to return all three in a structure. The latter may be useful since
passes may want to cache these together in order to have zero-overhead
checking to see whether the remarks are off.

  1. Find an appropriate entry point in Clang where we can make a shared_ptr
    for
    OptimizationRemarkPattern, OptimizationRemarkAnalysisPattern in LLVMContext
    class.

I am assuming you were thinking of doing this to call isEnabled on the
remark; unfortunately that does not work. (I know that is what
WholeProgramDevirt does too.) isEnabled is not used in clang in llvm
(opt/llc):

https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenAction.
cpp#L598
No actually I wanted to keep pointer for CodeGenOpts.OptimizationRemarkPattern and other similar objects in LLVMContext so that we can take decision based on clang's -Rpass options.
With that thought I am confused because as opt/llc and clang uses different options for same thing and user passes both things (particularly in clang though -mllvm) then it can creates problem. So I thought we can teach clang that drop opt/llc's options for ORE.

-Vivek

I think that the new design should move isEnabled to the DiagnosticHandler
in the context. DiagnosticHandler is only a callback now so it should
probably become a class. Then clients can ask whether a kind of remark
(OptRemark, OptRemarkMissed, OptRemarkAnalysis) is enabled for a pass
specified by the pass name.

  1. Use above changes so that allowExtraAnalysis can be used to check if
    specific
    remark is on or not.

Yes.

However I am confused because there is one more` class DiagnosticInfo in LLVM
which handles same thing for opt's flags, but why those informations are not
used in allowExtraAnalysis() ? Have I understood the purpose of
allowExtraAnalysis or not ?

As explained above.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 9, 2017

Thanks for taking this on!

  1. allowExtraAnalysis function will have a string parameter which is pass
    name.

I think it will also need the remark kind (e.g. DK_OptRemarkAnalysis) unless
we want to return all three in a structure. The latter may be useful since
passes may want to cache these together in order to have zero-overhead
checking to see whether the remarks are off.

  1. Find an appropriate entry point in Clang where we can make a shared_ptr
    for
    OptimizationRemarkPattern, OptimizationRemarkAnalysisPattern in LLVMContext
    class.

I am assuming you were thinking of doing this to call isEnabled on the
remark; unfortunately that does not work. (I know that is what
WholeProgramDevirt does too.) isEnabled is not used in clang in llvm
(opt/llc):

https://github.com/llvm-mirror/clang/blob/master/lib/CodeGen/CodeGenAction.
cpp#L598
No actually I wanted to keep pointer for
CodeGenOpts.OptimizationRemarkPattern and other similar objects in
LLVMContext so that we can take decision based on clang's -Rpass options.
With that thought I am confused because as opt/llc and clang uses different
options for same thing and user passes both things (particularly in clang
though -mllvm) then it can creates problem. So I thought we can teach clang
that drop opt/llc's options for ORE.
I am not sure why currently it is not done but when -fsave-optimization-record is present then clang should covert -Rpass to -mllvm equivalent opt/llc's option.

-Vivek

I think that the new design should move isEnabled to the DiagnosticHandler
in the context. DiagnosticHandler is only a callback now so it should
probably become a class. Then clients can ask whether a kind of remark
(OptRemark, OptRemarkMissed, OptRemarkAnalysis) is enabled for a pass
specified by the pass name.

  1. Use above changes so that allowExtraAnalysis can be used to check if
    specific
    remark is on or not.

Yes.

However I am confused because there is one more` class DiagnosticInfo in LLVM
which handles same thing for opt's flags, but why those informations are not
used in allowExtraAnalysis() ? Have I understood the purpose of
allowExtraAnalysis or not ?

As explained above.

@hfinkel
Copy link
Collaborator

hfinkel commented May 9, 2017

I am not sure why currently it is not done but when -fsave-optimization-record is present then clang should covert -Rpass to -mllvm equivalent opt/llc's option.

-mllvm options are for compiler development purposes only; they're not part of the user interface. Moreover, using command-line options to pass information between the frontend and the backend is highly discouraged.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 17, 2017

Work in progress patch is https://reviews.llvm.org/D33514

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 19, 2017

Vivek fixed this in r313382. Thanks Vivek!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

2 participants