[llvm] r304505 - [WebAssembly] MC: Fix references to undefined externals in data section
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 18:05:24 PDT 2017
Author: sbc
Date: Thu Jun 1 20:05:24 2017
New Revision: 304505
URL: http://llvm.org/viewvc/llvm-project?rev=304505&view=rev
Log:
[WebAssembly] MC: Fix references to undefined externals in data section
Undefined externals don't need to have a size or an offset.
This was broken by r303915. Added a test for this case.
This fixes the "Compile LLVM Torture (o)" step on the wasm
waterfall.
Differential Revision: https://reviews.llvm.org/D33803
Added:
llvm/trunk/test/MC/WebAssembly/external-data.ll
Modified:
llvm/trunk/lib/MC/WasmObjectWriter.cpp
llvm/trunk/lib/Target/WebAssembly/known_gcc_test_failures.txt
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=304505&r1=304504&r2=304505&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Thu Jun 1 20:05:24 2017
@@ -730,16 +730,21 @@ void WasmObjectWriter::writeObject(MCAss
if (IsAddressTaken.count(&WS))
TableElems.push_back(Index);
} else {
- if (WS.getOffset() != 0)
- report_fatal_error("data sections must contain one variable each");
- if (!WS.getSize())
- report_fatal_error("data symbols must have a size set with .size");
-
- int64_t Size = 0;
- if (!WS.getSize()->evaluateAsAbsolute(Size, Layout))
- report_fatal_error(".size expression must be evaluatable");
+ if (WS.isTemporary() && !WS.getSize())
+ continue;
if (WS.isDefined(false)) {
+ if (WS.getOffset() != 0)
+ report_fatal_error("data sections must contain one variable each: " +
+ WS.getName());
+ if (!WS.getSize())
+ report_fatal_error("data symbols must have a size set with .size: " +
+ WS.getName());
+
+ int64_t Size = 0;
+ if (!WS.getSize()->evaluateAsAbsolute(Size, Layout))
+ report_fatal_error(".size expression must be evaluatable");
+
MCSectionWasm &DataSection =
static_cast<MCSectionWasm &>(WS.getSection());
Modified: llvm/trunk/lib/Target/WebAssembly/known_gcc_test_failures.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/known_gcc_test_failures.txt?rev=304505&r1=304504&r2=304505&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/known_gcc_test_failures.txt (original)
+++ llvm/trunk/lib/Target/WebAssembly/known_gcc_test_failures.txt Thu Jun 1 20:05:24 2017
@@ -88,6 +88,3 @@ pr45695.c wasm-o
pr49279.c wasm-o
pr49390.c wasm-o
pr52286.c wasm-o
-
-# fatal error: error in backend: data symbols must have a size set with .size
-921110-1.c wasm-o
Added: llvm/trunk/test/MC/WebAssembly/external-data.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/external-data.ll?rev=304505&view=auto
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/external-data.ll (added)
+++ llvm/trunk/test/MC/WebAssembly/external-data.ll Thu Jun 1 20:05:24 2017
@@ -0,0 +1,21 @@
+; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o - | obj2yaml | FileCheck %s
+; Verify relocations are correctly generated for addresses of externals
+; in the data section.
+
+declare i32 @f1(...)
+
+ at foo = global i64 7, align 4
+ at far = local_unnamed_addr global i32 (...)* @f1, align 4
+
+; CHECK: - Type: DATA
+; CHECK: Relocations:
+; CHECK: - Type: R_WEBASSEMBLY_GLOBAL_ADDR_I32
+; CHECK: Index: 0
+; CHECK: Offset: 0x0000000E
+; CHECK: Segments:
+; CHECK: - Index: 0
+; CHECK: Offset:
+; CHECK: Opcode: I32_CONST
+; CHECK: Value: 0
+; CHECK: Content: 0700000000000000FFFFFFFF
+
More information about the llvm-commits
mailing list