[llvm] 4f3eb80 - [Xtensa] Call isUInt<8> in range-check asserts (#204731)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 21 06:54:52 PDT 2026
Author: Kern Handa
Date: 2026-06-21T14:54:47+01:00
New Revision: 4f3eb803343711c69e287da8a3272ab9449b53a9
URL: https://github.com/llvm/llvm-project/commit/4f3eb803343711c69e287da8a3272ab9449b53a9
DIFF: https://github.com/llvm/llvm-project/commit/4f3eb803343711c69e287da8a3272ab9449b53a9.diff
LOG: [Xtensa] Call isUInt<8> in range-check asserts (#204731)
`printOffset8m8_AsmOperand` and `getSelect_256OpValue` assert on
`isUInt<8>` without calling it, so the expression takes the function's
address and the range check never runs. This also trips
`-Werror,-Wpointer-bool-conversion` in builds with assertions enabled.
Pass the operand value so the bound is actually checked.
Added:
Modified:
llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp
llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp
index 4540f16f34801..42971c79cf8bf 100644
--- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp
+++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.cpp
@@ -314,7 +314,8 @@ void XtensaInstPrinter::printOffset8m8_AsmOperand(const MCInst *MI, int OpNum,
raw_ostream &O) {
if (MI->getOperand(OpNum).isImm()) {
int64_t Value = MI->getOperand(OpNum).getImm();
- assert(isUInt<8> && "Invalid argument, value must be in range [0,255]");
+ assert(isUInt<8>(Value) &&
+ "Invalid argument, value must be in range [0,255]");
O << Value;
} else
printOperand(MI, OpNum, O);
diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
index b35e5e3e03b07..349a747d3d51f 100644
--- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
@@ -618,7 +618,7 @@ XtensaMCCodeEmitter::getSelect_256OpValue(const MCInst &MI, unsigned OpNo,
const MCOperand &MO = MI.getOperand(OpNo);
uint8_t Res = static_cast<uint8_t>(MO.getImm());
- assert(isUInt<8> && "Unexpected operand value!");
+ assert(isUInt<8>(Res) && "Unexpected operand value!");
return Res;
}
More information about the llvm-commits
mailing list