[PATCH] D26701: [WebAssembly] Add triple support for the new wasm object format

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 17 12:45:22 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL292252: [WebAssembly] Add triple support for the new wasm object format (authored by djg).

Changed prior to commit:
  https://reviews.llvm.org/D26701?vs=84718&id=84723#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D26701

Files:
  llvm/trunk/include/llvm/ADT/Triple.h
  llvm/trunk/lib/MC/MCObjectFileInfo.cpp
  llvm/trunk/lib/ProfileData/InstrProf.cpp
  llvm/trunk/lib/Support/Triple.cpp
  llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/trunk/unittests/ADT/TripleTest.cpp


Index: llvm/trunk/include/llvm/ADT/Triple.h
===================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h
+++ llvm/trunk/include/llvm/ADT/Triple.h
@@ -206,6 +206,7 @@
     COFF,
     ELF,
     MachO,
+    Wasm,
   };
 
 private:
@@ -576,6 +577,11 @@
     return getObjectFormat() == Triple::MachO;
   }
 
+  /// Tests whether the OS uses the Wasm binary format.
+  bool isOSBinFormatWasm() const {
+    return getObjectFormat() == Triple::Wasm;
+  }
+
   /// Tests whether the target is the PS4 CPU
   bool isPS4CPU() const {
     return getArch() == Triple::x86_64 &&
Index: llvm/trunk/lib/ProfileData/InstrProf.cpp
===================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp
@@ -794,7 +794,7 @@
     return true;
 
   Triple TT(M.getTargetTriple());
-  if (!TT.isOSBinFormatELF())
+  if (!TT.isOSBinFormatELF() && !TT.isOSBinFormatWasm())
     return false;
 
   // See createPGOFuncNameVar for more details. To avoid link errors, profile
Index: llvm/trunk/lib/Support/Triple.cpp
===================================================================
--- llvm/trunk/lib/Support/Triple.cpp
+++ llvm/trunk/lib/Support/Triple.cpp
@@ -510,6 +510,7 @@
     .EndsWith("coff", Triple::COFF)
     .EndsWith("elf", Triple::ELF)
     .EndsWith("macho", Triple::MachO)
+    .EndsWith("wasm", Triple::Wasm)
     .Default(Triple::UnknownObjectFormat);
 }
 
@@ -581,6 +582,7 @@
   case Triple::COFF: return "coff";
   case Triple::ELF: return "elf";
   case Triple::MachO: return "macho";
+  case Triple::Wasm: return "wasm";
   }
   llvm_unreachable("unknown object format type");
 }
Index: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
===================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp
@@ -843,6 +843,9 @@
     Env = IsELF;
     initELFMCObjectFileInfo(TT);
     break;
+  case Triple::Wasm:
+    report_fatal_error("Cannot initialize MC for wasm object file format yet.");
+    break;
   case Triple::UnknownObjectFormat:
     report_fatal_error("Cannot initialize MC for unknown object file format.");
     break;
Index: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -1853,7 +1853,8 @@
     GlobalValue *InstrumentedGlobal = NewGlobal;
 
     bool CanUsePrivateAliases =
-        TargetTriple.isOSBinFormatELF() || TargetTriple.isOSBinFormatMachO();
+        TargetTriple.isOSBinFormatELF() || TargetTriple.isOSBinFormatMachO() ||
+        TargetTriple.isOSBinFormatWasm();
     if (CanUsePrivateAliases && ClUsePrivateAliasForGlobals) {
       // Create local alias for NewGlobal to avoid crash on ODR between
       // instrumented and non-instrumented libraries.
Index: llvm/trunk/unittests/ADT/TripleTest.cpp
===================================================================
--- llvm/trunk/unittests/ADT/TripleTest.cpp
+++ llvm/trunk/unittests/ADT/TripleTest.cpp
@@ -888,6 +888,9 @@
   EXPECT_EQ(Triple::ELF, Triple("i686-pc-windows-msvc-elf").getObjectFormat());
   EXPECT_EQ(Triple::ELF, Triple("i686-pc-cygwin-elf").getObjectFormat());
 
+  EXPECT_EQ(Triple::Wasm, Triple("wasm32-unknown-unknown-wasm").getObjectFormat());
+  EXPECT_EQ(Triple::Wasm, Triple("wasm64-unknown-unknown-wasm").getObjectFormat());
+
   Triple MSVCNormalized(Triple::normalize("i686-pc-windows-msvc-elf"));
   EXPECT_EQ(Triple::ELF, MSVCNormalized.getObjectFormat());
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26701.84723.patch
Type: text/x-patch
Size: 3708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170117/15f78299/attachment.bin>


More information about the llvm-commits mailing list