[llvm] fix assert in AArch64Arm64ECCallLowering.cpp (PR #98408)
Guillaume Belz via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 16:04:32 PDT 2024
https://github.com/GuillaumeBelz created https://github.com/llvm/llvm-project/pull/98408
The precedence of `==` operator is superior to `?:` operator. This line is evaluated as:
```cpp
assert((ArgTranslations.size() == F->isVarArg()) ? 5 : PassthroughArgSize);
```
I guess this is not what is wanted. This causes a warning with gcc:
```
[131/602] Building CXX object lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64Arm64ECCallLowering.cpp.o
In file included from /usr/include/c++/11/cassert:44,
from /home/linux/dev/llvm-project/llvm/include/llvm/Support/CommandLine.h:33,
from /home/linux/dev/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp:31:
/home/linux/dev/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp: In member function ‘llvm::Function* {anonymous}::AArch64Arm64ECCallLowering::buildEntryThunk(llvm::Function*)’:
/home/linux/dev/llvm-project/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp:528:50: warning: ‘?:’ using integer constants in boolean context [-Wint-in-bool-context]
528 | assert(ArgTranslations.size() == F->isVarArg() ? 5 : PassthroughArgSize);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
```
Add parenthesis to fix the problem.
>From 9aacc4bbc82c472649c96e5f5e900bb49c2914b6 Mon Sep 17 00:00:00 2001
From: Guillaume Belz <1651508+GuillaumeBelz at users.noreply.github.com>
Date: Wed, 10 Jul 2024 15:53:09 -0700
Subject: [PATCH] Update AArch64Arm64ECCallLowering.cpp
---
llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
index 8d9463968b898..4ff52eb252d20 100644
--- a/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64Arm64ECCallLowering.cpp
@@ -525,7 +525,7 @@ Function *AArch64Arm64ECCallLowering::buildEntryThunk(Function *F) {
unsigned ThunkArgOffset = TransformDirectToSRet ? 2 : 1;
unsigned PassthroughArgSize =
(F->isVarArg() ? 5 : Thunk->arg_size()) - ThunkArgOffset;
- assert(ArgTranslations.size() == F->isVarArg() ? 5 : PassthroughArgSize);
+ assert(ArgTranslations.size() == (F->isVarArg() ? 5 : PassthroughArgSize));
// Translate arguments to call.
SmallVector<Value *> Args;
More information about the llvm-commits
mailing list