I'm working with the opt tool to manually run optimization passes on LLVM IR code, and I'm quite new to it. While running analysis passes, the sources I've been referring to used the -analyze flag with opt to perform analysis and print the results without transforming the input. However, with the version I have installed, opt warns me that the -analyze option is deprecated for the new pass manager.
Now I did find out that I can disable the new pass manager by using -enable-new-pm=0, and that works as expected. I can also use the new pass manager and discard the generated output by redirecting to /dev/null. However, I'd like to know if there is an official equivalent -analyze while using the new pass manager.
My searches seem to yield only two results of note - the LLVM docs and the LLVM blog post introducing the new PM. Neither of these seem to discuss the -analyze flag.
Equivalent of -analyze in the new pass manager is
--passes="print<your-analysis-pass-name>"
Here is the example usage:
opt -load-pass-plugin examplepass.so --passes="print<examplepass>" -disable-output example.bc
Further information and details you can look this awesome github repository for llvm passes and their usages with legacy(old) and new pass managers: https://github.com/banach-space/llvm-tutor
Related
I am using the following code to work with pyomo model.
opt = pe.SolverFactory('gurobi')
res = opt.solve(model, tee=False,options=solver_opt)
walltime = res.solver.time
I tried several times to get the code snippet "res.solver.time" for obtaining the "walltime". Hence, I want to know where I can get the full list of methods and attributes in "opt". Then I can obtain other useful information. Thank you for help.
Anytime I'm poking around for a particular feature, I keep a terminal window open with ipython and use the code introspection feature to poke around (input 4 below). Then you can use ? or ?? (deep info, typically the source code) to get more info as in input 3 below.
Just type the command, '.', tab and poke around
This is the same stuff you would get from any IDE that supports introspection based code completion. I like PyCharm for same reasons.
Realize of course that what is shown below are the methods associated with pyomo's opt object and NOT the solver (glpk in my case, gurobi in yours) options!
I'm trying to write some complex Starlark rules that link and build multiple dynamic libraries on Linux using the (relatively) new cc_common APIs.
There seems to be 2 different ways you can create compile/link actions using this API:
Using the compile()/link() methods, which are relatively "high-level", and
Using the create_compile_variables()/create_link_variables() along with get_memory_inefficient_command_line() and then calling actions.run() directly with the generated command line.
In particualr, I'm trying to get #2 to work. My question is, how can I create the param_file to pass into create_link_variables? There doesn't seem to be any Starlark API for this.
https://docs.bazel.build/versions/1.1.0/skylark/lib/cc_common.html#create_link_variables
agoessling I have shared a couple of source files for you here
It should give you a pretty good idea of how this lower level cc_common API can be used end to end.
There are still known holes in this API, i.e. not everything possible with the built-in cc rules also possible through cc_common, but I would say 90% is available.
I am not associated with the Bazel team and the code is the result of my own digging and sniffing. No warranties, but it works for me. Let me know if you get stuck on something - I will try to help.
If you get an idea of how to do some of it better (prettier, more compatible with the built-in rules, more platform-independent, etc.) I am all ears. Good luck!
How is the state of the art in source-to-source transformation with clang?
I followed almost every resource on the Web and I can achieve to do source rewrites (Rewriter) via a clang plugin, but the final binary is not updated (the CodeGen is the main activity, and it is compiled regardless of what I have modified in my plugin, even using AddBeforeMainAction in the getActionType).
I have seen some documents regarding libTooling and how to create an independent program that uses clang as library, but my purpose it is to create a plugin (FrontendPluginRegistry::Add<>, something "easy" to plug to a non-custom clang binary) and achieve source-to-source modifications (transparently to the users, avoiding overwriting their source files).
Edit: In case it is not clear:
I need something like a "plugin" to extend clang in an easy way. I need something that is "integrated" in the compiling process. Why? because I need to modify the source code during the compilation phase, inject new code, modify the source code from the user in one step (I don't want to create a tool to parse the user source code and then compile the output files). Also, I would like to distribute my code (plugin) to allow users to use it by themselves.
It is mandatory that it is during the compilation phase of clang (clang $FLAGS $PLUGIN $ETC -o program source_files...).
the CodeGen is the main activity, and it is compiled regardless of what I have modified in my plugin
Yes, this is because Clang AST is designed to be immutable. You can't change it after parsing.
So state of the art s2s transformation in Clang looks like that:
Parse C++ source code to AST
Apply text replacements to original source code, generate new source code
Parse new source code to create new AST
You can do all steps "in memory", so end user won't notice.
Update:
I have never written clang plugins myself. But here is what I've noticed:
If you run Clang fronted to actually generate object code:
clang -cc1 -emit-obj main.c
It will run EmitObjAction. EmitObjAction is a FrontEnd Action, so it will parse input source and run codegen. So if you run other FrontEnd actions in parallel, they will have no effect on EmitObjAction. Because each FrontEnd action parses original input source code.
What you can do, is to replace EmitObjAction with your own fork that will do as much of re-parsing as you want.
If you set PluginASTAction::ActionType to ReplaceAction, it should replace built-in Codegen action by your own supplied from plugin.
I've used the LLVM IR API for some time now and is pretty comfortable using it.
However, when it comes to the x86 backend I'm lost...
First of all, I cannot find a reference on how to create new instructions and insert them into a MachineBasicBlock.
Next, the Backend API doesn't mirror the familiar IR API, where I can create new IR instructions using new and insert them before other instructions or at the end of a basic block.
Finally, using CLion, when opening the project, the .inc files are not found in the source directory, so a lot of references are not resolved, e.g., register info.
Could someone link to a ressource on how to program with the backend LLVM API?
Also, an example of how to add a few instructions (e.g., mov or lea) into a MachineBasicBlock would also be welcome!
I tried this steps in order to create a patch
code change for each version update
jungels.net/articles/diff-patch-ten-minutes.html
Can able to create a patch
if i run the patch,it replaces the code straight away.....Incase if the updated version has some code changes,it doesn't bothers,it will straight away copy the modified code what i have....
How to overcome this issue?(ie::Need to have the updated version code changes also)
Use version control. As already noted.
If you really taking about sphinxsearc, its available via SVN
https://code.google.com/p/sphinxsearch/source/checkout
So checkout a copy. Make any changes as needed to your local working copy. Can then just run svn update which will download the latest changes from teh repository, but wont discard your local edits.
(Can also use SVN to create 'patch' files directly. to keep a record of your changes against the current version of sphinx)