[llvm] r233500 - [inline asm] Don't reject duplicated matching constraints

Benjamin Kramer benny.kra at googlemail.com
Sun Mar 29 13:33:07 PDT 2015


Author: d0k
Date: Sun Mar 29 15:33:07 2015
New Revision: 233500

URL: http://llvm.org/viewvc/llvm-project?rev=233500&view=rev
Log:
[inline asm] Don't reject duplicated matching constraints

They're harmless and it's easy to generate them from clang, leading to
a crash in LLVM. Found by afl-fuzz.

Added:
    llvm/trunk/test/CodeGen/X86/inline-asm-duplicated-constraint.ll
Modified:
    llvm/trunk/lib/IR/InlineAsm.cpp

Modified: llvm/trunk/lib/IR/InlineAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/InlineAsm.cpp?rev=233500&r1=233499&r2=233500&view=diff
==============================================================================
--- llvm/trunk/lib/IR/InlineAsm.cpp (original)
+++ llvm/trunk/lib/IR/InlineAsm.cpp Sun Mar 29 15:33:07 2015
@@ -167,7 +167,8 @@ bool InlineAsm::ConstraintInfo::Parse(St
         // Note that operand #n has a matching input.
         scInfo.MatchingInput = ConstraintsSoFar.size();
       } else {
-        if (ConstraintsSoFar[N].hasMatchingInput())
+        if (ConstraintsSoFar[N].hasMatchingInput() &&
+            ConstraintsSoFar[N].MatchingInput != ConstraintsSoFar.size())
           return true;
         // Note that operand #n has a matching input.
         ConstraintsSoFar[N].MatchingInput = ConstraintsSoFar.size();

Added: llvm/trunk/test/CodeGen/X86/inline-asm-duplicated-constraint.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inline-asm-duplicated-constraint.ll?rev=233500&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/inline-asm-duplicated-constraint.ll (added)
+++ llvm/trunk/test/CodeGen/X86/inline-asm-duplicated-constraint.ll Sun Mar 29 15:33:07 2015
@@ -0,0 +1,12 @@
+; RUN: llc < %s -march=x86-64 -no-integrated-as -mtriple=x86_64-linux-gnu | FileCheck %s
+
+; CHECK-LABEL: test1:
+; CHECK: movl	(%rdi), %eax
+; CHECK: nop
+; CHECK: movl	%eax, (%rdi)
+; CHECK: ret
+define void @test1(i32* %l) {
+  %load = load i32, i32* %l
+  call void asm "nop", "=*rmrm,0m0m,~{dirflag},~{fpsr},~{flags}"(i32* %l, i32 %load)
+  ret void
+}





More information about the llvm-commits mailing list