From b16bb4047162915c463b001c2641477183253496 Mon Sep 17 00:00:00 2001 From: Yuri Iozzelli Date: Fri, 9 Aug 2024 10:10:33 +0200 Subject: [PATCH] fix(Writer): fix priority grouping in compileBitCastOffset --- llvm/lib/CheerpWriter/Opcodes.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CheerpWriter/Opcodes.cpp b/llvm/lib/CheerpWriter/Opcodes.cpp index aaebfbb80be7..ec3f36fd7c3f 100644 --- a/llvm/lib/CheerpWriter/Opcodes.cpp +++ b/llvm/lib/CheerpWriter/Opcodes.cpp @@ -375,10 +375,14 @@ void CheerpWriter::compileBitCastOffset(const llvm::User* bi, PARENT_PRIORITY pa llvm::Type* pointedType = (isArray)?elementType->getArrayElementType():elementType; if(TypeSupport::isTypedArrayType(pointedType, /* forceTypedArray*/ true)) { - compileByteLayoutOffset( bi->getOperand(0), BYTE_LAYOUT_OFFSET_FULL ); uint32_t size = targetData.getTypeAllocSize(pointedType); + if(size != 1 && parentPrio > SHIFT) stream << '('; + compileByteLayoutOffset( bi->getOperand(0), BYTE_LAYOUT_OFFSET_FULL ); if(size != 1) + { stream << ">>" << Log2_32(size); + if(parentPrio > SHIFT) stream << ')'; + } return; } }