[llvm] r362638 - [WebAssembly] Limit PIC support to the Emscripten target
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 5 13:01:01 PDT 2019
Author: djg
Date: Wed Jun 5 13:01:01 2019
New Revision: 362638
URL: http://llvm.org/viewvc/llvm-project?rev=362638&view=rev
Log:
[WebAssembly] Limit PIC support to the Emscripten target
The current PIC support currently only works with Emscripten, so
disable it for other targets.
This is the PIC portion of https://reviews.llvm.org/D62542.
Reviewed By: dschuff, sbc100
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
llvm/trunk/test/CodeGen/WebAssembly/address-offsets.ll
llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll
llvm/trunk/test/CodeGen/WebAssembly/load-store-pic.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp?rev=362638&r1=362637&r2=362638&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp Wed Jun 5 13:01:01 2019
@@ -83,13 +83,22 @@ extern "C" void LLVMInitializeWebAssembl
// WebAssembly Lowering public interface.
//===----------------------------------------------------------------------===//
-static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM) {
+static Reloc::Model getEffectiveRelocModel(Optional<Reloc::Model> RM,
+ const Triple &TT) {
if (!RM.hasValue()) {
// Default to static relocation model. This should always be more optimial
// than PIC since the static linker can determine all global addresses and
// assume direct function calls.
return Reloc::Static;
}
+
+ if (!TT.isOSEmscripten()) {
+ // Relocation modes other than static are currently implemented in a way
+ // that only works for Emscripten, so disable them if we aren't targeting
+ // Emscripten.
+ return Reloc::Static;
+ }
+
return *RM;
}
@@ -102,7 +111,7 @@ WebAssemblyTargetMachine::WebAssemblyTar
: LLVMTargetMachine(T,
TT.isArch64Bit() ? "e-m:e-p:64:64-i64:64-n32:64-S128"
: "e-m:e-p:32:32-i64:64-n32:64-S128",
- TT, CPU, FS, Options, getEffectiveRelocModel(RM),
+ TT, CPU, FS, Options, getEffectiveRelocModel(RM, TT),
getEffectiveCodeModel(CM, CodeModel::Large), OL),
TLOF(new WebAssemblyTargetObjectFile()) {
// WebAssembly type-checks instructions, but a noreturn function with a return
Modified: llvm/trunk/test/CodeGen/WebAssembly/address-offsets.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/address-offsets.ll?rev=362638&r1=362637&r2=362638&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/address-offsets.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/address-offsets.ll Wed Jun 5 13:01:01 2019
@@ -6,7 +6,7 @@
; a variety of circumstances.
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
+target triple = "wasm32-unknown-emscripten"
@g = external global [0 x i32], align 4
Modified: llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll?rev=362638&r1=362637&r2=362638&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll Wed Jun 5 13:01:01 2019
@@ -1,7 +1,7 @@
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=1 | FileCheck %s
; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers -relocation-model=pic -fast-isel=0 | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
+target triple = "wasm32-unknown-emscripten"
declare i32 @foo()
declare i32 @bar()
Modified: llvm/trunk/test/CodeGen/WebAssembly/load-store-pic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/load-store-pic.ll?rev=362638&r1=362637&r2=362638&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/load-store-pic.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/load-store-pic.ll Wed Jun 5 13:01:01 2019
@@ -6,7 +6,7 @@
; We test here both with and without fast-isel.
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
-target triple = "wasm32-unknown-unknown"
+target triple = "wasm32-unknown-emscripten"
@hidden_global = external hidden global i32
@hidden_global_array = external hidden global [10 x i32]
More information about the llvm-commits
mailing list