-
Notifications
You must be signed in to change notification settings - Fork 135
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
It there any way to preserve instructions depends on or depended by sliced criterions? #456
Comments
Hi,
I'm not sure I understand.
Any instruction can be a slicing criterion: https://github.com/mchalupa/dg/blob/master/doc/llvm-slicer.md#slicing-criteria-the--sc-option |
Oh, you want forward slicing? |
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
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 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 |
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? |
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
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 |
Thanks for your explanation and assistance. That's really helpful to me, your guide on where to hack it is highly appreciated! |
@mchalupa, hi!. I'm working on reducing two semantically equivalent IRs, which share similar syntatical structure. Now I want to slice based those different instructions, and cut off anything irrelevant to them. For example:
I slice it based on
other_func(ret1)
, and want store of b to be sliced:But actually we only get a single
other_func(a)
:So it's there any way to realize it ?
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?
The text was updated successfully, but these errors were encountered: