[llvm] r242040 - Fix handling of the 'n' asm constraint with invalid operands.

James Y Knight jyknight at google.com
Mon Jul 13 09:36:23 PDT 2015


Author: jyknight
Date: Mon Jul 13 11:36:22 2015
New Revision: 242040

URL: http://llvm.org/viewvc/llvm-project?rev=242040&view=rev
Log:
Fix handling of the 'n' asm constraint with invalid operands.

It had accidently accepted a symbol+offset value (and emitted
incorrect code for it, keeping only the offset part) instead of
properly reporting the constraint as invalid.

Differential Revision: http://reviews.llvm.org/D11039

Added:
    llvm/trunk/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=242040&r1=242039&r2=242040&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Mon Jul 13 11:36:22 2015
@@ -2218,8 +2218,8 @@ void TargetLowering::LowerAsmOperandForC
         Ops.push_back(DAG.getTargetGlobalAddress(GA->getGlobal(),
                                                  C ? SDLoc(C) : SDLoc(),
                                                  Op.getValueType(), Offs));
-        return;
       }
+      return;
     }
     if (C) {   // just C, no GV.
       // Simple constants are not allowed for 's'.
@@ -2229,8 +2229,8 @@ void TargetLowering::LowerAsmOperandForC
         // ScheduleDAGSDNodes::EmitNode, which is very generic.
         Ops.push_back(DAG.getTargetConstant(C->getAPIntValue().getSExtValue(),
                                             SDLoc(C), MVT::i64));
-        return;
       }
+      return;
     }
     break;
   }

Added: llvm/trunk/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-bad-constraint-n.ll?rev=242040&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/inline-asm-bad-constraint-n.ll (added)
+++ llvm/trunk/test/CodeGen/X86/inline-asm-bad-constraint-n.ll Mon Jul 13 11:36:22 2015
@@ -0,0 +1,10 @@
+; RUN: not llc -march=x86 -no-integrated-as < %s 2>&1 | FileCheck %s
+
+ at x = global i32 0, align 4
+
+;CHECK:	error: invalid operand for inline asm constraint 'n'
+define void @foo() {
+  %a = getelementptr i32, i32* @x, i32 1
+  call void asm sideeffect "foo $0", "n"(i32* %a) nounwind
+  ret void
+}





More information about the llvm-commits mailing list