[llvm] Use DIExpression::foldConstantMath() at the result of an append() (PR #71719)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 8 10:47:06 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 5aa934e2af8727852dec0ec1cfa0cba05d858f70 e37ff7f3fd8bde5a59f8831a8818666353063f6b -- llvm/include/llvm/IR/DebugInfoMetadata.h llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h llvm/lib/IR/DebugInfoMetadata.cpp llvm/unittests/IR/MetadataTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/unittests/IR/MetadataTest.cpp b/llvm/unittests/IR/MetadataTest.cpp
index f233d2ff5d25..03060d1765ea 100644
--- a/llvm/unittests/IR/MetadataTest.cpp
+++ b/llvm/unittests/IR/MetadataTest.cpp
@@ -3398,89 +3398,91 @@ TEST_F(DIExpressionTest, Fold) {
}
TEST_F(DIExpressionTest, Append) {
- // Test appending a {dwarf::DW_OP_constu, <const>, DW_OP_plus} to a DW_OP_plus expression
- SmallVector<uint64_t, 8> Ops = {dwarf::DW_OP_LLVM_arg, 0,
- dwarf::DW_OP_constu, 2, dwarf::DW_OP_plus};
- auto *Expr = DIExpression::get(Context, Ops);
- SmallVector<uint64_t, 8> AppendOps = {dwarf::DW_OP_constu, 3,
- dwarf::DW_OP_plus};
- auto *AppendExpr = DIExpression::append(Expr, AppendOps);
- SmallVector<uint64_t, 8> OpsRes = {
- dwarf::DW_OP_LLVM_arg, 0, dwarf::DW_OP_constu, 5, dwarf::DW_OP_plus};
- auto *ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_plus_uconst, <const>} to a DW_OP_plus
- // expression uint64_t PlusUConstOps[] = {dwarf::DW_OP_plus_uconst, 3};
- AppendOps.clear();
- AppendOps.push_back(dwarf::DW_OP_plus_uconst);
- AppendOps.push_back(3);
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes.clear();
- OpsRes.push_back(dwarf::DW_OP_LLVM_arg);
- OpsRes.push_back(0);
- OpsRes.push_back(dwarf::DW_OP_plus_uconst);
- OpsRes.push_back(5);
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_plus} to an expression
- AppendOps[0] = dwarf::DW_OP_constu;
- AppendOps[1] = 0;
- AppendOps.push_back(dwarf::DW_OP_plus);
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[2] = dwarf::DW_OP_constu;
- OpsRes[3] = Ops[3];
- OpsRes.push_back(dwarf::DW_OP_plus);
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_minus} to an expression
- AppendOps[2] = dwarf::DW_OP_minus;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = Ops[3];
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_shl} to an expression
- AppendOps[2] = dwarf::DW_OP_shl;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = Ops[3];
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_shr} to an expression
- AppendOps[2] = dwarf::DW_OP_shr;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = Ops[3];
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, <const>, DW_OP_mul} to a DW_OP_mul expression
- Ops[4] = dwarf::DW_OP_mul;
- Expr = DIExpression::get(Context, Ops);
- AppendOps[1] = 3;
- AppendOps[2] = dwarf::DW_OP_mul;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = 6;
- OpsRes[4] = dwarf::DW_OP_mul;
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 1, DW_OP_mul} to an expression
- AppendOps[1] = 1;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = Ops[3];
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
-
- // Test appending a {dwarf::DW_OP_constu, 1, DW_OP_div} to an expression
- AppendOps[1] = 1;
- AppendOps[2] = dwarf::DW_OP_div;
- AppendExpr = DIExpression::append(Expr, AppendOps);
- OpsRes[3] = Ops[3];
- ResExpr = DIExpression::get(Context, OpsRes);
- EXPECT_EQ(ResExpr, AppendExpr);
+ // Test appending a {dwarf::DW_OP_constu, <const>, DW_OP_plus} to a DW_OP_plus
+ // expression
+ SmallVector<uint64_t, 8> Ops = {dwarf::DW_OP_LLVM_arg, 0, dwarf::DW_OP_constu,
+ 2, dwarf::DW_OP_plus};
+ auto *Expr = DIExpression::get(Context, Ops);
+ SmallVector<uint64_t, 8> AppendOps = {dwarf::DW_OP_constu, 3,
+ dwarf::DW_OP_plus};
+ auto *AppendExpr = DIExpression::append(Expr, AppendOps);
+ SmallVector<uint64_t, 8> OpsRes = {dwarf::DW_OP_LLVM_arg, 0,
+ dwarf::DW_OP_constu, 5, dwarf::DW_OP_plus};
+ auto *ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_plus_uconst, <const>} to a DW_OP_plus
+ // expression uint64_t PlusUConstOps[] = {dwarf::DW_OP_plus_uconst, 3};
+ AppendOps.clear();
+ AppendOps.push_back(dwarf::DW_OP_plus_uconst);
+ AppendOps.push_back(3);
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes.clear();
+ OpsRes.push_back(dwarf::DW_OP_LLVM_arg);
+ OpsRes.push_back(0);
+ OpsRes.push_back(dwarf::DW_OP_plus_uconst);
+ OpsRes.push_back(5);
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_plus} to an expression
+ AppendOps[0] = dwarf::DW_OP_constu;
+ AppendOps[1] = 0;
+ AppendOps.push_back(dwarf::DW_OP_plus);
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[2] = dwarf::DW_OP_constu;
+ OpsRes[3] = Ops[3];
+ OpsRes.push_back(dwarf::DW_OP_plus);
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_minus} to an expression
+ AppendOps[2] = dwarf::DW_OP_minus;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = Ops[3];
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_shl} to an expression
+ AppendOps[2] = dwarf::DW_OP_shl;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = Ops[3];
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 0, DW_OP_shr} to an expression
+ AppendOps[2] = dwarf::DW_OP_shr;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = Ops[3];
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, <const>, DW_OP_mul} to a DW_OP_mul
+ // expression
+ Ops[4] = dwarf::DW_OP_mul;
+ Expr = DIExpression::get(Context, Ops);
+ AppendOps[1] = 3;
+ AppendOps[2] = dwarf::DW_OP_mul;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = 6;
+ OpsRes[4] = dwarf::DW_OP_mul;
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 1, DW_OP_mul} to an expression
+ AppendOps[1] = 1;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = Ops[3];
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
+
+ // Test appending a {dwarf::DW_OP_constu, 1, DW_OP_div} to an expression
+ AppendOps[1] = 1;
+ AppendOps[2] = dwarf::DW_OP_div;
+ AppendExpr = DIExpression::append(Expr, AppendOps);
+ OpsRes[3] = Ops[3];
+ ResExpr = DIExpression::get(Context, OpsRes);
+ EXPECT_EQ(ResExpr, AppendExpr);
}
TEST_F(DIExpressionTest, isValid) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/71719
More information about the llvm-commits
mailing list