[llvm] 5fc05c3 - Fix Z3 function calls regarding arithmetic operations
Gabor Marton via llvm-commits
llvm-commits at lists.llvm.org
Thu May 14 06:47:14 PDT 2020
Author: Gabor Marton
Date: 2020-05-14T15:46:13+02:00
New Revision: 5fc05c376a3cc0fb9a532e41d12e51f3d9916692
URL: https://github.com/llvm/llvm-project/commit/5fc05c376a3cc0fb9a532e41d12e51f3d9916692
DIFF: https://github.com/llvm/llvm-project/commit/5fc05c376a3cc0fb9a532e41d12e51f3d9916692.diff
LOG: Fix Z3 function calls regarding arithmetic operations
Summary:
The order of Z3_mk_fpa_mul, Z3_mk_fpa_div, Z3_mk_fpa_add and Z3_mk_fpa_sub functions' arguments is: context, rounding_mode, ast1, ast2.
See for example: https://github.com/Z3Prover/z3/blob/a14c2a30516003cd1a60f8b7deca029033d11c78/src/api/api_fpa.cpp#L433
At function calls from LLVM the argument order was different: rounding_mode was passed as last argument.
Unfortunately these Z3_ast and other function parameter types are technically like void* which are reinterpret_cast-ed to a specific class type. So there was no type error, but the assertions fail in runtime if something goes wrong. Such a crash happened during Z3 refutation while using StaticAnalyzer.
Reviewers: Szelethus, xazax.hun, baloghadamsoftware, steakhal, martong, mikhail.ramalho
Reviewed By: martong
Subscribers: hiraditya, rnkovacs, mikhail.ramalho, martong, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D79883
Patch by Tibor Brunner!
Added:
Modified:
llvm/lib/Support/Z3Solver.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Support/Z3Solver.cpp b/llvm/lib/Support/Z3Solver.cpp
index a83d0f441a4b..3e0cb493559a 100644
--- a/llvm/lib/Support/Z3Solver.cpp
+++ b/llvm/lib/Support/Z3Solver.cpp
@@ -516,16 +516,16 @@ class Z3Solver : public SMTSolver {
SMTExprRef RoundingMode = getFloatRoundingMode();
return newExprRef(
Z3Expr(Context,
- Z3_mk_fpa_mul(Context.Context, toZ3Expr(*LHS).AST,
- toZ3Expr(*RHS).AST, toZ3Expr(*RoundingMode).AST)));
+ Z3_mk_fpa_mul(Context.Context, toZ3Expr(*RoundingMode).AST,
+ toZ3Expr(*LHS).AST, toZ3Expr(*RHS).AST)));
}
SMTExprRef mkFPDiv(const SMTExprRef &LHS, const SMTExprRef &RHS) override {
SMTExprRef RoundingMode = getFloatRoundingMode();
return newExprRef(
Z3Expr(Context,
- Z3_mk_fpa_div(Context.Context, toZ3Expr(*LHS).AST,
- toZ3Expr(*RHS).AST, toZ3Expr(*RoundingMode).AST)));
+ Z3_mk_fpa_div(Context.Context, toZ3Expr(*RoundingMode).AST,
+ toZ3Expr(*LHS).AST, toZ3Expr(*RHS).AST)));
}
SMTExprRef mkFPRem(const SMTExprRef &LHS, const SMTExprRef &RHS) override {
@@ -538,16 +538,16 @@ class Z3Solver : public SMTSolver {
SMTExprRef RoundingMode = getFloatRoundingMode();
return newExprRef(
Z3Expr(Context,
- Z3_mk_fpa_add(Context.Context, toZ3Expr(*LHS).AST,
- toZ3Expr(*RHS).AST, toZ3Expr(*RoundingMode).AST)));
+ Z3_mk_fpa_add(Context.Context, toZ3Expr(*RoundingMode).AST,
+ toZ3Expr(*LHS).AST, toZ3Expr(*RHS).AST)));
}
SMTExprRef mkFPSub(const SMTExprRef &LHS, const SMTExprRef &RHS) override {
SMTExprRef RoundingMode = getFloatRoundingMode();
return newExprRef(
Z3Expr(Context,
- Z3_mk_fpa_sub(Context.Context, toZ3Expr(*LHS).AST,
- toZ3Expr(*RHS).AST, toZ3Expr(*RoundingMode).AST)));
+ Z3_mk_fpa_sub(Context.Context, toZ3Expr(*RoundingMode).AST,
+ toZ3Expr(*LHS).AST, toZ3Expr(*RHS).AST)));
}
SMTExprRef mkFPLt(const SMTExprRef &LHS, const SMTExprRef &RHS) override {
More information about the llvm-commits
mailing list