[PATCH] D33773: [ARM] llc -arm-execute-only with floating point runs into UNREACHABLE

Alexandros Lamprineas via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 02:40:11 PDT 2017


labrinea updated this revision to Diff 101873.
labrinea added a comment.

When generating execute-only code invoke the generic AsmPrinter in order to place the literals in the data section, otherwise handle Constant Pools in EmitInstruction.


https://reviews.llvm.org/D33773

Files:
  lib/Target/ARM/ARMAsmPrinter.cpp
  lib/Target/ARM/ARMAsmPrinter.h
  test/CodeGen/ARM/constantfp.ll


Index: test/CodeGen/ARM/constantfp.ll
===================================================================
--- test/CodeGen/ARM/constantfp.ll
+++ test/CodeGen/ARM/constantfp.ll
@@ -176,3 +176,36 @@
 ; CHECK-XO-DOUBLE-BE-NOT: vldr
   ret double 3.140000e-01
 }
+
+; This is a target independent optimization, performed by the
+; DAG Combiner, which promotes floating point literals into
+; constant pools:
+;
+; (a cond b) ? 1.0f : 2.0f -> load (ConstPoolAddr + ((a cond b) ? 0 : 4)
+;
+; We need to make sure that the constant pools are placed in
+; the data section when generating execute-only code:
+
+define arm_aapcs_vfpcc float @lower_fpconst_select(float %f) {
+
+; CHECK-NO-XO-LABEL: lower_fpconst_select
+; CHECK-NO-XO: adr [[REG:r[0-9]+]], [[LABEL:.?LCPI[0-9]+_[0-9]+]]
+; CHECK-NO-XO: vldr {{s[0-9]+}}, {{[[]}}[[REG]]{{[]]}}
+; CHECK-NO-XO-NOT: .rodata
+; CHECK-NO-XO: [[LABEL]]:
+; CHECK-NO-XO: .long   1335165689
+; CHECK-NO-XO: .long   1307470632
+
+; CHECK-XO-FLOAT: .rodata
+; CHECK-XO-FLOAT: [[LABEL:.?LCPI[0-9]+_[0-9]+]]:
+; CHECK-XO-FLOAT: .long   1335165689
+; CHECK-XO-FLOAT: .long   1307470632
+; CHECK-XO-FLOAT: .section        .text,"axy",%progbits,unique,0
+; CHECK-XO-FLOAT: lower_fpconst_select:
+; CHECK-XO-FLOAT: adr [[REG:r[0-9]+]], [[LABEL]]
+; CHECK-XO-FLOAT: vldr {{s[0-9]+}}, {{[[]}}[[REG]]{{[]]}}
+
+  %cmp = fcmp nnan oeq float %f, 0.000000e+00
+  %sel = select i1 %cmp, float 5.000000e+08, float 5.000000e+09
+  ret float %sel
+}
Index: lib/Target/ARM/ARMAsmPrinter.h
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.h
+++ lib/Target/ARM/ARMAsmPrinter.h
@@ -92,9 +92,7 @@
   void EmitInstruction(const MachineInstr *MI) override;
   bool runOnMachineFunction(MachineFunction &F) override;
 
-  void EmitConstantPool() override {
-    // we emit constant pools customly!
-  }
+  void EmitConstantPool() override;
   void EmitFunctionBodyEnd() override;
   void EmitFunctionEntryLabel() override;
   void EmitStartOfAsmFile(Module &M) override;
Index: lib/Target/ARM/ARMAsmPrinter.cpp
===================================================================
--- lib/Target/ARM/ARMAsmPrinter.cpp
+++ lib/Target/ARM/ARMAsmPrinter.cpp
@@ -61,6 +61,14 @@
     : AsmPrinter(TM, std::move(Streamer)), AFI(nullptr), MCP(nullptr),
       InConstantPool(false), OptimizationGoals(-1) {}
 
+// When generating execute-only code invoke the generic AsmPrinter
+// in order to place the literals in the data section, otherwise
+// handle Constant Pools in EmitInstruction.
+void ARMAsmPrinter::EmitConstantPool() {
+  if (Subtarget->genExecuteOnly())
+    AsmPrinter::EmitConstantPool();
+}
+
 void ARMAsmPrinter::EmitFunctionBodyEnd() {
   // Make sure to terminate any constant pools that were at the end
   // of the function.
@@ -1504,6 +1512,10 @@
     return;
   }
   case ARM::CONSTPOOL_ENTRY: {
+    // Handle this case in EmitConstantPool.
+    if (Subtarget->genExecuteOnly())
+      return;
+
     /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool
     /// in the function.  The first operand is the ID# for this instruction, the
     /// second is the index into the MachineConstantPool that this is, the third


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33773.101873.patch
Type: text/x-patch
Size: 3216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170608/d64bb42a/attachment.bin>


More information about the llvm-commits mailing list