From 678b918040d88b4914a7cf79b3b5a35ad77bcf55 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Tue, 6 Feb 2018 01:25:39 -0800 Subject: [PATCH] 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 --- .clang-format | 2 +- .../ConstantPropagationAnalysis.cpp | 28 +++++-------------- .../ConstantPropagationTransform.cpp | 12 ++------ .../InterproceduralConstantPropagation.cpp | 10 ++----- 4 files changed, 13 insertions(+), 39 deletions(-) diff --git a/.clang-format b/.clang-format index 704189df744..d65c4703e47 100644 --- a/.clang-format +++ b/.clang-format @@ -7,7 +7,7 @@ AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true -BinPackArguments: false +BinPackArguments: true BinPackParameters: false BreakBeforeBinaryOperators: false BreakBeforeBraces: Attach diff --git a/opt/constant_propagation/ConstantPropagationAnalysis.cpp b/opt/constant_propagation/ConstantPropagationAnalysis.cpp index 08c1f364180..c03b8499cdb 100644 --- a/opt/constant_propagation/ConstantPropagationAnalysis.cpp +++ b/opt/constant_propagation/ConstantPropagationAnalysis.cpp @@ -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)); } @@ -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()); @@ -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; } @@ -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; diff --git a/opt/constant_propagation/ConstantPropagationTransform.cpp b/opt/constant_propagation/ConstantPropagationTransform.cpp index 2572c7d5b94..824472171ba 100644 --- a/opt/constant_propagation/ConstantPropagationTransform.cpp +++ b/opt/constant_propagation/ConstantPropagationTransform.cpp @@ -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)); @@ -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); diff --git a/opt/constant_propagation/InterproceduralConstantPropagation.cpp b/opt/constant_propagation/InterproceduralConstantPropagation.cpp index ef99b746422..3b62a27ead9 100644 --- a/opt/constant_propagation/InterproceduralConstantPropagation.cpp +++ b/opt/constant_propagation/InterproceduralConstantPropagation.cpp @@ -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}; @@ -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()); }