-
Notifications
You must be signed in to change notification settings - Fork 14.3k
llvm-reduce: Fix overly conservative operands-to-args user restriction #133854
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,9 @@ | |
|
||
using namespace llvm; | ||
|
||
static bool canReplaceFunction(Function *F) { | ||
return all_of(F->uses(), [](Use &Op) { | ||
if (auto *CI = dyn_cast<CallBase>(Op.getUser())) | ||
return &CI->getCalledOperandUse() == &Op; | ||
return false; | ||
}); | ||
static bool canReplaceFunction(const Function &F) { | ||
// TODO: Add controls to avoid ABI breaks (e.g. don't break main) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO llvm-reduce should be reducing main There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just remove this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shoul, but it would be useful to have a mode to opt out and avoid breaking anything needed to execute the function (bugpoint has a more primitive version of the option than the one I would like) |
||
return true; | ||
} | ||
|
||
static bool canReduceUse(Use &Op) { | ||
|
@@ -59,8 +56,9 @@ static bool canReduceUse(Use &Op) { | |
static void replaceFunctionCalls(Function *OldF, Function *NewF) { | ||
SmallVector<CallBase *> Callers; | ||
for (Use &U : OldF->uses()) { | ||
auto *CI = cast<CallBase>(U.getUser()); | ||
assert(&U == &CI->getCalledOperandUse()); | ||
auto *CI = dyn_cast<CallBase>(U.getUser()); | ||
if (!CI || !CI->isCallee(&U)) // RAUW can handle these fine. | ||
continue; | ||
|
||
Function *CalledF = CI->getCalledFunction(); | ||
if (CalledF == OldF) { | ||
|
@@ -209,7 +207,7 @@ void llvm::reduceOperandsToArgsDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) { | |
|
||
SmallVector<Use *> OperandsToReduce; | ||
for (Function &F : make_early_inc_range(Program.functions())) { | ||
if (!canReplaceFunction(&F)) | ||
if (!canReplaceFunction(F)) | ||
continue; | ||
OperandsToReduce.clear(); | ||
for (Instruction &I : instructions(&F)) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we pass
null
here now, should we not ideally introduce a new argument?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever this this does anything, the call sites are adjusted to pass the default type value to the new argument