Comments (6)
Further, I wonder if it's possible to control the "strength" or "degree" of both forward and backward slicing. Sometimes I want %c to be replaced with an arbitrary argument, and sometimes I want %add to be eliminated or even ret i32 %add to be replaced with ret i32 %call. In this way we can control the complexity and specificity of a certain sliced IR. If not, could you provide an appropriate place to hack it?
What you describe is not slicing, so no, the slicer does not support this. I would suggest you just create a pass/new tool that uses DG to do this. I would start with llvm-slicer
, after this point in the code: https://github.com/mchalupa/dg/blob/master/tools/llvm-slicer.cpp#L267C22-L267C22, you can go through the dependence graph and unmark nodes that should be in the slice but you want to preserve them. In this step you can also remember instructions that you want to replace and after slicing itself (https://github.com/mchalupa/dg/blob/master/tools/llvm-slicer.cpp#L285), you can replace them with different instructions.
It seems to require emitting debug instructions, but now I only have IR. I prefer to taking the name of Value/Instruction as a type of slicing criterion. If there is not such option, where can I hack?
Instructions in LLVM do not have names by default, so this is not reliable and not implemented, but you can hack it here: https://github.com/mchalupa/dg/blob/master/tools/llvm-slicer-crit.cpp#L1113
from dg.
Hi,
I slice it based on other_func(ret1), and want store of b to be sliced:
I'm not sure I understand. other_func(ret1)
is not part of the code, what do you mean exactly by this slicing criterion? If you slice the code w.r.t calls to other_func
then the slice you posted looks correct.
Apart from this, it's there any easy way to hack dg so that any type of instructions (not only call-sites/ret) can be the slicing criterions?
Any instruction can be a slicing criterion: https://github.com/mchalupa/dg/blob/master/doc/llvm-slicer.md#slicing-criteria-the--sc-option
from dg.
I slice it based on other_func(ret1), and want store of b to be sliced
Oh, you want forward slicing?
from dg.
I may not clarify it well, what I really want is to control the "strength" of forward/backward slicing. Take a llvm-ir as example (because I work only on llvm-ir, instead of C now)
declare i32 @dummy(i32)
define i32 @foo(i32 %a, ptr %b) {
entry:
%c = sub i32 0, %a
%call = call i32 @dummy(i32 %c)
store i32 666, ptr %b, align 4
%add = add i32 %call, 1
ret i32 %add
}
Firstly, we take dummy
as the slicing criterion, and then the store of b
doesn't influence dummy
and isn't influenced by dummy
. So store b
should be eliminated unconditionally.
%add
depends on dummy
, so it should not be eliminated unconditionally for me. But without -forward
option, dg produces:
define i32 @foo(i32 %a, ptr %b) {
entry:
%c = sub i32 0, %a
%call = call i32 @dummy(i32 %c)
br label %safe_return
safe_return: ; preds = %entry
ret i32 undef
}
And thanks for your reminder, with -forward
as you say, it produces what I want now:
define i32 @foo(i32 %a, ptr %b) {
entry:
%c = sub i32 0, %a
%call = call i32 @dummy(i32 %c)
%add = add i32 %call, 1
ret i32 %add
}
Further, I wonder if it's possible to control the "strength" or "degree" of both forward and backward slicing. Sometimes I want %c
to be replaced with an arbitrary argument, and sometimes I want %add
to be eliminated or even ret i32 %add
to be replaced with ret i32 %call
. In this way we can control the complexity and specificity of a certain sliced IR. If not, could you provide an appropriate place to hack it?
from dg.
Any instruction can be a slicing criterion: https://github.com/mchalupa/dg/blob/master/doc/llvm-slicer.md#slicing-criteria-the--sc-option
It seems to require emitting debug instructions, but now I only have IR. I prefer to taking the name of Value/Instruction as a type of slicing criterion. If there is not such option, where can I hack?
from dg.
Thanks for your explanation and assistance. That's really helpful to me, your guide on where to hack it is highly appreciated!
from dg.
Related Issues (20)
- How to `llvm-to-source` a `.sliced` file that is obtained from a linked bitcode file HOT 2
- How to slice the following c++ file? HOT 3
- install error HOT 11
- Slice results only from DDG HOT 5
- the results of slicing seems wrong HOT 5
- version of SVF used HOT 5
- How to slice the program accurately HOT 12
- Address boundary error when building dg graph in Make 4.2 HOT 4
- llvm-slicer hangs somewhere when slicing sqlite-3.38.0 HOT 6
- Intra-procedural slicing HOT 1
- Crash and Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed. HOT 4
- Slice process is blocked HOT 9
- Please update SVFPointerAnalysis.h in dg due to SVF updated. HOT 2
- [Question] Is it possible to use dg to slice and analyze Linux source code? HOT 3
- Build failed HOT 6
- Is data-dependence analysis driven by self-defined pointer analysis or SVF? HOT 8
- Can DG only do data dependency analysis without program slicing? HOT 1
- Support LLVM 18
- pta-show tool not working due to llvm-pta-dump incorrect dot syntax output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dg.