This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGf76d3b800f73: [clang][CGStmt] fix crash on invalid asm statement (authored by ztong0001, committed by MaskRay).
Changed prior to commit: https://reviews.llvm.org/D120596?vs=411577&id=412496#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D120596/new/ https://reviews.llvm.org/D120596 Files: clang/lib/CodeGen/CGStmt.cpp clang/test/CodeGen/X86/x86_64-PR42672.c Index: clang/test/CodeGen/X86/x86_64-PR42672.c =================================================================== --- clang/test/CodeGen/X86/x86_64-PR42672.c +++ clang/test/CodeGen/X86/x86_64-PR42672.c @@ -5,6 +5,7 @@ // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -DPOSSIBLE_X -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-X // RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_X -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_X // RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_9BYTES -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_9BYTES +// RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_9BYTES_V2 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_9BYTES_V2 // Make sure Clang doesn't treat |lockval| as asm input. void _raw_spin_lock(void) { @@ -115,3 +116,11 @@ } // CHECK-IMPOSSIBLE_9BYTES: impossible constraint in asm: can't store value into a register + +void crbug_999160_regtest_v2(void) { +#ifdef IMPOSSIBLE_9BYTES_V2 + char buf[9]; + asm("" : "=r"(buf) : "0"(buf)); +#endif +} +// CHECK-IMPOSSIBLE_9BYTES_V2: impossible constraint in asm: can't store value into a register Index: clang/lib/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -2518,10 +2518,8 @@ Arg = Builder.CreateZExt(Arg, OutputTy); else if (isa<llvm::PointerType>(OutputTy)) Arg = Builder.CreateZExt(Arg, IntPtrTy); - else { - assert(OutputTy->isFloatingPointTy() && "Unexpected output type"); + else if (OutputTy->isFloatingPointTy()) Arg = Builder.CreateFPExt(Arg, OutputTy); - } } // Deal with the tied operands' constraint code in adjustInlineAsmType. ReplaceConstraint = OutputConstraints[Output];
Index: clang/test/CodeGen/X86/x86_64-PR42672.c =================================================================== --- clang/test/CodeGen/X86/x86_64-PR42672.c +++ clang/test/CodeGen/X86/x86_64-PR42672.c @@ -5,6 +5,7 @@ // RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -DPOSSIBLE_X -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-X // RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_X -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_X // RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_9BYTES -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_9BYTES +// RUN: not %clang_cc1 -triple=x86_64-unknown-linux-gnu -DIMPOSSIBLE_9BYTES_V2 -emit-llvm %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-IMPOSSIBLE_9BYTES_V2 // Make sure Clang doesn't treat |lockval| as asm input. void _raw_spin_lock(void) { @@ -115,3 +116,11 @@ } // CHECK-IMPOSSIBLE_9BYTES: impossible constraint in asm: can't store value into a register + +void crbug_999160_regtest_v2(void) { +#ifdef IMPOSSIBLE_9BYTES_V2 + char buf[9]; + asm("" : "=r"(buf) : "0"(buf)); +#endif +} +// CHECK-IMPOSSIBLE_9BYTES_V2: impossible constraint in asm: can't store value into a register Index: clang/lib/CodeGen/CGStmt.cpp =================================================================== --- clang/lib/CodeGen/CGStmt.cpp +++ clang/lib/CodeGen/CGStmt.cpp @@ -2518,10 +2518,8 @@ Arg = Builder.CreateZExt(Arg, OutputTy); else if (isa<llvm::PointerType>(OutputTy)) Arg = Builder.CreateZExt(Arg, IntPtrTy); - else { - assert(OutputTy->isFloatingPointTy() && "Unexpected output type"); + else if (OutputTy->isFloatingPointTy()) Arg = Builder.CreateFPExt(Arg, OutputTy); - } } // Deal with the tied operands' constraint code in adjustInlineAsmType. ReplaceConstraint = OutputConstraints[Output];
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits