Skip to content

Commit 678b918

Browse files
int3facebook-github-bot
authored andcommitted
clang-format: Set BinPackArguments to true
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
1 parent 199de47 commit 678b918

File tree

4 files changed

+13
-39
lines changed

4 files changed

+13
-39
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ AllowShortIfStatementsOnASingleLine: true
77
AllowShortLoopsOnASingleLine: false
88
AlwaysBreakBeforeMultilineStrings: true
99
AlwaysBreakTemplateDeclarations: true
10-
BinPackArguments: false
10+
BinPackArguments: true
1111
BinPackParameters: false
1212
BreakBeforeBinaryOperators: false
1313
BreakBeforeBraces: Attach

opt/constant_propagation/ConstantPropagationAnalysis.cpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,8 @@ void analyze_non_branch(const IRInstruction* insn,
7676
env->set(dst, SignedConstantDomain::top());
7777
return;
7878
}
79-
TRACE(CONSTP,
80-
5,
81-
"Propagating constant [Value: %X] -> [Reg: %d]\n",
82-
src,
83-
*value,
84-
dst);
79+
TRACE(CONSTP, 5, "Propagating constant [Value: %X] -> [Reg: %d]\n", src,
80+
*value, dst);
8581
env->set(dst, SignedConstantDomain(*value));
8682
}
8783

@@ -115,14 +111,10 @@ void analyze_compare(const IRInstruction* insn, ConstantEnvironment* env) {
115111
} else { // l_val < r_val
116112
result = -1;
117113
}
118-
TRACE(CONSTP,
119-
5,
114+
TRACE(CONSTP, 5,
120115
"Propagated constant in branch instruction %s, "
121116
"Operands [%d] [%d] -> Result: [%d]\n",
122-
SHOW(insn),
123-
l_val,
124-
r_val,
125-
result);
117+
SHOW(insn), l_val, r_val, result);
126118
env->set(insn->dest(), SignedConstantDomain(result));
127119
} else {
128120
env->set(insn->dest(), SignedConstantDomain::top());
@@ -149,11 +141,8 @@ void FixpointIterator::analyze_instruction(const IRInstruction* insn,
149141

150142
case OPCODE_CONST:
151143
case OPCODE_CONST_WIDE: {
152-
TRACE(CONSTP,
153-
5,
154-
"Discovered new constant for reg: %d value: %ld\n",
155-
insn->dest(),
156-
insn->get_literal());
144+
TRACE(CONSTP, 5, "Discovered new constant for reg: %d value: %ld\n",
145+
insn->dest(), insn->get_literal());
157146
env->set(insn->dest(), SignedConstantDomain(insn->get_literal()));
158147
break;
159148
}
@@ -217,10 +206,7 @@ void FixpointIterator::analyze_instruction(const IRInstruction* insn,
217206
}
218207
return v + lit;
219208
};
220-
TRACE(CONSTP,
221-
5,
222-
"Attempting to fold %s with literal %lu\n",
223-
SHOW(insn),
209+
TRACE(CONSTP, 5, "Attempting to fold %s with literal %lu\n", SHOW(insn),
224210
lit);
225211
analyze_non_branch(insn, env, add_in_bounds);
226212
break;

opt/constant_propagation/ConstantPropagationTransform.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,8 @@ void Transform::eliminate_dead_branch(
8282
// unreachable
8383
if (intra_cp.analyze_edge(edge, env).is_bottom()) {
8484
auto is_fallthrough = edge->type() == EDGE_GOTO;
85-
TRACE(CONSTP,
86-
2,
87-
"Changed conditional branch %s as it is always %s\n",
88-
SHOW(insn),
89-
is_fallthrough ? "true" : "false");
85+
TRACE(CONSTP, 2, "Changed conditional branch %s as it is always %s\n",
86+
SHOW(insn), is_fallthrough ? "true" : "false");
9087
++m_stats.branches_removed;
9188
m_insn_replacements.emplace_back(
9289
insn, new IRInstruction(is_fallthrough ? OPCODE_GOTO : OPCODE_NOP));
@@ -106,10 +103,7 @@ void Transform::apply_changes(IRCode* code) {
106103
code->remove_opcode(old_op);
107104
delete new_op;
108105
} else {
109-
TRACE(CONSTP,
110-
4,
111-
"Replacing instruction %s -> %s\n",
112-
SHOW(old_op),
106+
TRACE(CONSTP, 4, "Replacing instruction %s -> %s\n", SHOW(old_op),
113107
SHOW(new_op));
114108
if (is_branch(old_op->opcode())) {
115109
code->replace_branch(old_op, new_op);

opt/constant_propagation/InterproceduralConstantPropagation.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ void simplify_constant_fields(const Scope& scope,
8080
if (!field_env.get(field).constant_domain().is_value()) {
8181
continue;
8282
}
83-
TRACE(ICONSTP,
84-
3,
85-
"%s has value %s\n",
86-
SHOW(field),
83+
TRACE(ICONSTP, 3, "%s has value %s\n", SHOW(field),
8784
field_env.get(field).constant_domain().str().c_str());
8885
if (is_sget(op)) {
8986
IRInstruction* replacement{nullptr};
@@ -325,10 +322,7 @@ class Propagator {
325322
if (args.is_bottom()) {
326323
args.set_to_top();
327324
} else if (!args.is_top()) {
328-
TRACE(ICONSTP,
329-
3,
330-
"Have args for %s: %s\n",
331-
SHOW(method),
325+
TRACE(ICONSTP, 3, "Have args for %s: %s\n", SHOW(method),
332326
args.str().c_str());
333327
}
334328

0 commit comments

Comments
 (0)