[WebAssembly] Disable tee_local optimizations when targeting the ELF ABI.
authorDan Gohman <dan433584@gmail.com>
Wed, 20 Dec 2017 00:59:28 +0000 (00:59 +0000)
committerDan Gohman <dan433584@gmail.com>
Wed, 20 Dec 2017 00:59:28 +0000 (00:59 +0000)
These optimizations depend on the ExplicitLocals pass to lower TEE
instructions, which is disabled in the ELF ABI, so disable them too.

llvm-svn: 321131

llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp

index 2bdba96..a4bb967 100644 (file)
@@ -746,6 +746,14 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
   MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
   LiveIntervals &LIS = getAnalysis<LiveIntervals>();
 
+  // Disable the TEE optimization if we aren't doing direct wasm object
+  // emission, because lowering TEE to TEE_LOCAL is done in the ExplicitLocals
+  // pass, which is also disabled.
+  bool UseTee = true;
+  if (MF.getSubtarget<WebAssemblySubtarget>()
+        .getTargetTriple().isOSBinFormatELF())
+    UseTee = false;
+
   // Walk the instructions from the bottom up. Currently we don't look past
   // block boundaries, and the blocks aren't ordered so the block visitation
   // order isn't significant, but we may want to change this in the future.
@@ -811,7 +819,7 @@ bool WebAssemblyRegStackify::runOnMachineFunction(MachineFunction &MF) {
           Insert =
               RematerializeCheapDef(Reg, Op, *Def, MBB, Insert->getIterator(),
                                     LIS, MFI, MRI, TII, TRI);
-        } else if (CanMove &&
+        } else if (UseTee && CanMove &&
                    OneUseDominatesOtherUses(Reg, Op, MBB, MRI, MDT, LIS, MFI)) {
           Insert = MoveAndTeeForMultiUse(Reg, Op, Def, MBB, Insert, LIS, MFI,
                                          MRI, TII);