[PATCH] D45280: WebAssembly: Never write more than 32-bits for WebAssembly::OPERAND_OFFSET32
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 12:34:33 PDT 2018
sbc100 updated this revision to Diff 141024.
sbc100 added a comment.
remove debugging
Repository:
rL LLVM
https://reviews.llvm.org/D45280
Files:
lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
test/MC/WebAssembly/offset.ll
Index: test/MC/WebAssembly/offset.ll
===================================================================
--- /dev/null
+++ test/MC/WebAssembly/offset.ll
@@ -0,0 +1,15 @@
+; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+target triple = "wasm32-unknown-unknown-wasm"
+
+define i32 @load_i32_from_negative_address() {
+ %s = inttoptr i32 -1 to i32*
+ %t = load i32, i32* %s
+ ret i32 %t
+}
+
+; CHECK: - Type: CODE
+; CHECK-NEXT: Functions:
+; CHECK-NEXT: - Index: 0
+; CHECK-NEXT: Locals:
+; CHECK-NEXT: Body: 41002802FFFFFFFF0F0B
Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
===================================================================
--- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
+++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCCodeEmitter.cpp
@@ -23,9 +23,11 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/raw_ostream.h"
+
using namespace llvm;
#define DEBUG_TYPE "mccodeemitter"
@@ -86,8 +88,11 @@
assert(Desc.TSFlags == 0 &&
"WebAssembly non-variable_ops don't use TSFlags");
const MCOperandInfo &Info = Desc.OpInfo[i];
+ DEBUG(dbgs() << "Encoding immediate: type=" << int(Info.OperandType) << "\n");
if (Info.OperandType == WebAssembly::OPERAND_I32IMM) {
encodeSLEB128(int32_t(MO.getImm()), OS);
+ } else if (Info.OperandType == WebAssembly::OPERAND_OFFSET32) {
+ encodeULEB128(uint32_t(MO.getImm()), OS);
} else if (Info.OperandType == WebAssembly::OPERAND_I64IMM) {
encodeSLEB128(int64_t(MO.getImm()), OS);
} else if (Info.OperandType == WebAssembly::OPERAND_GLOBAL) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45280.141024.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180404/e22de72a/attachment.bin>
More information about the llvm-commits
mailing list