Skip to content

Commit

Permalink
clang-format: Set BinPackArguments to true
Browse files Browse the repository at this point in the history
Summary:
I can't stand how clang-format makes long TRACE statements waste 2
lines by putting them module name and log level on individual lines. I've
formatted constprop since the code there is actively getting churned anyway;
the rest of the codebase can be gradually converted as we touch it.

Reviewed By: minjang

Differential Revision: D6910793

fbshipit-source-id: a17696bdfa4b6b7e2ad1ca1c6c08599d79ca062e
  • Loading branch information
int3 authored and facebook-github-bot committed Feb 6, 2018
1 parent 199de47 commit 678b918
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackArguments: true
BinPackParameters: false
BreakBeforeBinaryOperators: false
BreakBeforeBraces: Attach
Expand Down
28 changes: 7 additions & 21 deletions opt/constant_propagation/ConstantPropagationAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ void analyze_non_branch(const IRInstruction* insn,
env->set(dst, SignedConstantDomain::top());
return;
}
TRACE(CONSTP,
5,
"Propagating constant [Value: %X] -> [Reg: %d]\n",
src,
*value,
dst);
TRACE(CONSTP, 5, "Propagating constant [Value: %X] -> [Reg: %d]\n", src,
*value, dst);
env->set(dst, SignedConstantDomain(*value));
}

Expand Down Expand Up @@ -115,14 +111,10 @@ void analyze_compare(const IRInstruction* insn, ConstantEnvironment* env) {
} else { // l_val < r_val
result = -1;
}
TRACE(CONSTP,
5,
TRACE(CONSTP, 5,
"Propagated constant in branch instruction %s, "
"Operands [%d] [%d] -> Result: [%d]\n",
SHOW(insn),
l_val,
r_val,
result);
SHOW(insn), l_val, r_val, result);
env->set(insn->dest(), SignedConstantDomain(result));
} else {
env->set(insn->dest(), SignedConstantDomain::top());
Expand All @@ -149,11 +141,8 @@ void FixpointIterator::analyze_instruction(const IRInstruction* insn,

case OPCODE_CONST:
case OPCODE_CONST_WIDE: {
TRACE(CONSTP,
5,
"Discovered new constant for reg: %d value: %ld\n",
insn->dest(),
insn->get_literal());
TRACE(CONSTP, 5, "Discovered new constant for reg: %d value: %ld\n",
insn->dest(), insn->get_literal());
env->set(insn->dest(), SignedConstantDomain(insn->get_literal()));
break;
}
Expand Down Expand Up @@ -217,10 +206,7 @@ void FixpointIterator::analyze_instruction(const IRInstruction* insn,
}
return v + lit;
};
TRACE(CONSTP,
5,
"Attempting to fold %s with literal %lu\n",
SHOW(insn),
TRACE(CONSTP, 5, "Attempting to fold %s with literal %lu\n", SHOW(insn),
lit);
analyze_non_branch(insn, env, add_in_bounds);
break;
Expand Down
12 changes: 3 additions & 9 deletions opt/constant_propagation/ConstantPropagationTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,8 @@ void Transform::eliminate_dead_branch(
// unreachable
if (intra_cp.analyze_edge(edge, env).is_bottom()) {
auto is_fallthrough = edge->type() == EDGE_GOTO;
TRACE(CONSTP,
2,
"Changed conditional branch %s as it is always %s\n",
SHOW(insn),
is_fallthrough ? "true" : "false");
TRACE(CONSTP, 2, "Changed conditional branch %s as it is always %s\n",
SHOW(insn), is_fallthrough ? "true" : "false");
++m_stats.branches_removed;
m_insn_replacements.emplace_back(
insn, new IRInstruction(is_fallthrough ? OPCODE_GOTO : OPCODE_NOP));
Expand All @@ -106,10 +103,7 @@ void Transform::apply_changes(IRCode* code) {
code->remove_opcode(old_op);
delete new_op;
} else {
TRACE(CONSTP,
4,
"Replacing instruction %s -> %s\n",
SHOW(old_op),
TRACE(CONSTP, 4, "Replacing instruction %s -> %s\n", SHOW(old_op),
SHOW(new_op));
if (is_branch(old_op->opcode())) {
code->replace_branch(old_op, new_op);
Expand Down
10 changes: 2 additions & 8 deletions opt/constant_propagation/InterproceduralConstantPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ void simplify_constant_fields(const Scope& scope,
if (!field_env.get(field).constant_domain().is_value()) {
continue;
}
TRACE(ICONSTP,
3,
"%s has value %s\n",
SHOW(field),
TRACE(ICONSTP, 3, "%s has value %s\n", SHOW(field),
field_env.get(field).constant_domain().str().c_str());
if (is_sget(op)) {
IRInstruction* replacement{nullptr};
Expand Down Expand Up @@ -325,10 +322,7 @@ class Propagator {
if (args.is_bottom()) {
args.set_to_top();
} else if (!args.is_top()) {
TRACE(ICONSTP,
3,
"Have args for %s: %s\n",
SHOW(method),
TRACE(ICONSTP, 3, "Have args for %s: %s\n", SHOW(method),
args.str().c_str());
}

Expand Down

0 comments on commit 678b918

Please sign in to comment.