Idea for Open Project : Smarter way of dumping LLVM IR with -emit-after-all

Hello LLVM Devs,

I have an idea to improve effectiveness of IR dump with -emit-after-all based on Adam Nemet’s 2016 LLVM Dev presentation.
I think we can track changes in each function, basic block and instructions by dumping it to YAML files (initially) then track changes done by each pass incrementally as it is done in optimization remark emitter. Once we have required information in YAML files we can present it in much readable way (similar to diff ) through HTML technologies.
I think we can track chances in each entities by giving them a unique number and that will also map to HTML presentation layer.
However I have not thought if existing ORE framework can be used or not for this purpose. But if community thinks this is useful then I would like to work on this.
Also suggest if you can find any problem with this approach.

Sincerely,
Vivek

I think this sounds useful. I think that we can use ORE for this; I think you’ll need some infrastructure improvement so that we can emit the remarks from the pass managers but not pay the cost of serializing the IR unless something is going to use the information. -Hal

I think this sounds useful. I think that we can use ORE for this; I think you’ll need some infrastructure improvement so that we can emit the remarks from the pass managers but not pay the cost of serializing the IR unless something is going to use the information.

That is a general feature we just have to have for other remarks too that are expensive to construct. See https://bugs.llvm.org/show_bug.cgi?id=32352.

Vivek, feel free to grab this if you want to work on it. I can describe the current situation and we can discuss the design in the PR.

Thanks,
Adam

Hello LLVM Devs,

I have an idea to improve effectiveness of IR dump with -emit-after-all
based on Adam Nemet's 2016 LLVM Dev presentation.
I think we can track changes in each function, basic block and
instructions by dumping it to YAML files (initially) then track changes
done by each pass incrementally as it is done in optimization remark
emitter. Once we have required information in YAML files we can present it
in much readable way (similar to diff ) through HTML technologies.

I think this sounds useful.

I think we can track chances in each entities by giving them a unique
number and that will also map to HTML presentation layer.
However I have not thought if existing ORE framework can be used or not
for this purpose.

I think that we can use ORE for this; I think you'll need some
infrastructure improvement so that we can emit the remarks from the pass
managers but not pay the cost of serializing the IR unless something is
going to use the information.

That is a general feature we just have to have for other remarks too that
are expensive to construct. See https://bugs.llvm.org/
show_bug.cgi?id=32352.

Vivek, feel free to grab this if you want to work on it. I can describe
the current situation and we can discuss the design in the PR.

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

Hello LLVM Devs,

I have an idea to improve effectiveness of IR dump with -emit-after-all based on Adam Nemet’s 2016 LLVM Dev presentation.
I think we can track changes in each function, basic block and instructions by dumping it to YAML files (initially) then track changes done by each pass incrementally as it is done in optimization remark emitter. Once we have required information in YAML files we can present it in much readable way (similar to diff ) through HTML technologies.

I think this sounds useful.

I think we can track chances in each entities by giving them a unique number and that will also map to HTML presentation layer.
However I have not thought if existing ORE framework can be used or not for this purpose.

I think that we can use ORE for this; I think you’ll need some infrastructure improvement so that we can emit the remarks from the pass managers but not pay the cost of serializing the IR unless something is going to use the information.

That is a general feature we just have to have for other remarks too that are expensive to construct. See https://bugs.llvm.org/show_bug.cgi?id=32352.

Vivek, feel free to grab this if you want to work on it. I can describe the current situation and we can discuss the design in the PR.

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.

Moving the discussion to https://bugs.llvm.org/show_bug.cgi?id=32352.

Adam