From 7e42e33fff3244cde7532a5c1c69c9d15e8e0e6d Mon Sep 17 00:00:00 2001 From: Zhuowei Zhang Date: Sun, 14 Apr 2019 15:52:09 -0700 Subject: [PATCH] WebAssembly: remove even more PCRel relocations This removes the PCRel reloc in \01l_type_metadata_table but nowhere else --- lib/IRGen/GenDecl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 696bdc9c50e65..fcf13a083361b 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -2814,6 +2814,11 @@ IRGenModule::emitDirectRelativeReference(llvm::Constant *target, // Convert the target to an integer. auto targetAddr = llvm::ConstantExpr::getPtrToInt(target, SizeTy); + // WebAssembly hack: WebAssembly doesn't support PC-relative references + if (TargetInfo.OutputObjectFormat == llvm::Triple::Wasm) { + return targetAddr; + } + SmallVector indices; indices.push_back(llvm::ConstantInt::get(Int32Ty, 0)); for (unsigned baseIndex : baseIndices) {