Bug 1542827 - Revert a change to LLVM to fix unwinding to the exception handler on Windows/AArch64 r=glandium a=pascalc
authorGabriele Svelto <gsvelto@mozilla.com>
Wed, 24 Apr 2019 11:52:11 +0000
changeset 526444 2c11d977339516c3fd0a475fdd9689d3b9e7eb11
parent 526443 652cbee2d7f42b3d7186eda8a7617cdc6063fa50
child 526445 360d480593d585f7f5e0587deb11ffa3ff38b57b
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium, pascalc
bugs1542827
milestone67.0
Bug 1542827 - Revert a change to LLVM to fix unwinding to the exception handler on Windows/AArch64 r=glandium a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D27798
build/build-clang/clang-win64.json
build/build-clang/revert-r355311.patch
--- a/build/build-clang/clang-win64.json
+++ b/build/build-clang/clang-win64.json
@@ -12,11 +12,12 @@
     "python_path": "c:/mozilla-build/python/python.exe",
     "cc": "cl.exe",
     "cxx": "cl.exe",
     "ml": "ml64.exe",
     "patches": [
       "workaround-issue38586.patch",
       "unpoison-thread-stacks.patch",
       "downgrade-mangling-error.patch",
-      "loosen-msvc-detection.patch"
+      "loosen-msvc-detection.patch",
+      "revert-r355311.patch"
     ]
 }
new file mode 100644
--- /dev/null
+++ b/build/build-clang/revert-r355311.patch
@@ -0,0 +1,117 @@
+We need to revert LLVM's r355311 because it breaks exception handling in
+Windows/AArch64 builds
+
+diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+index ac5bdae9f1f..09e0706e284 100644
+--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
++++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+@@ -605,28 +605,19 @@ void AArch64AsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
+ 
+ void AArch64AsmPrinter::EmitJumpTableInfo() {
+   const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
+   if (!MJTI) return;
+ 
+   const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
+   if (JT.empty()) return;
+ 
+-  const Function &F = MF->getFunction();
+   const TargetLoweringObjectFile &TLOF = getObjFileLowering();
+-  bool JTInDiffSection =
+-      !STI->isTargetCOFF() ||
+-      !TLOF.shouldPutJumpTableInFunctionSection(
+-          MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32,
+-          F);
+-  if (JTInDiffSection) {
+-      // Drop it in the readonly section.
+-      MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(F, TM);
+-      OutStreamer->SwitchSection(ReadOnlySec);
+-  }
++  MCSection *ReadOnlySec = TLOF.getSectionForJumpTable(MF->getFunction(), TM);
++  OutStreamer->SwitchSection(ReadOnlySec);
+ 
+   auto AFI = MF->getInfo<AArch64FunctionInfo>();
+   for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) {
+     const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
+ 
+     // If this jump table was deleted, ignore it.
+     if (JTBBs.empty()) continue;
+ 
+diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+index d657fd414f3..d32f5a0ab29 100644
+--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
++++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+@@ -204,18 +204,18 @@ static std::string computeDataLayout(const Triple &TT,
+     return "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128";
+   if (LittleEndian)
+     return "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
+   return "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128";
+ }
+ 
+ static Reloc::Model getEffectiveRelocModel(const Triple &TT,
+                                            Optional<Reloc::Model> RM) {
+-  // AArch64 Darwin and Windows are always PIC.
+-  if (TT.isOSDarwin() || TT.isOSWindows())
++  // AArch64 Darwin is always PIC.
++  if (TT.isOSDarwin())
+     return Reloc::PIC_;
+   // On ELF platforms the default static relocation model has a smart enough
+   // linker to cope with referencing external symbols defined in a shared
+   // library. Hence DynamicNoPIC doesn't need to be promoted to PIC.
+   if (!RM.hasValue() || *RM == Reloc::DynamicNoPIC)
+     return Reloc::Static;
+   return *RM;
+ }
+diff --git a/llvm/test/CodeGen/AArch64/win64-jumptable.ll b/llvm/test/CodeGen/AArch64/win64-jumptable.ll
+deleted file mode 100644
+index 8148a593c91..00000000000
+--- a/llvm/test/CodeGen/AArch64/win64-jumptable.ll
++++ /dev/null
+@@ -1,48 +0,0 @@
+-; RUN: llc -o - %s -mtriple=aarch64-windows -aarch64-enable-compress-jump-tables=0 | FileCheck %s
+-
+-define void @f(i32 %x) {
+-entry:
+-  switch i32 %x, label %sw.epilog [
+-    i32 0, label %sw.bb
+-    i32 1, label %sw.bb1
+-    i32 2, label %sw.bb2
+-    i32 3, label %sw.bb3
+-  ]
+-
+-sw.bb:                                            ; preds = %entry
+-  tail call void @g(i32 0) #2
+-  br label %sw.epilog
+-
+-sw.bb1:                                           ; preds = %entry
+-  tail call void @g(i32 1) #2
+-  br label %sw.epilog
+-
+-sw.bb2:                                           ; preds = %entry
+-  tail call void @g(i32 2) #2
+-  br label %sw.epilog
+-
+-sw.bb3:                                           ; preds = %entry
+-  tail call void @g(i32 3) #2
+-  br label %sw.epilog
+-
+-sw.epilog:                                        ; preds = %entry, %sw.bb3, %sw.bb2, %sw.bb1, %sw.bb
+-  tail call void @g(i32 10) #2
+-  ret void
+-}
+-
+-declare void @g(i32)
+-
+-; CHECK:		.text
+-; CHECK:		f:
+-; CHECK:		.seh_proc f
+-; CHECK:		b	g
+-; CHECK-NEXT:	.p2align	2
+-; CHECK-NEXT:	.LJTI0_0:
+-; CHECK:		.word	.LBB0_2-.LJTI0_0
+-; CHECK:		.word	.LBB0_3-.LJTI0_0
+-; CHECK:		.word	.LBB0_4-.LJTI0_0
+-; CHECK:		.word	.LBB0_5-.LJTI0_0
+-; CHECK:		.section	.xdata,"dr"
+-; CHECK:		.seh_handlerdata
+-; CHECK:		.text
+-; CHECK:		.seh_endproc