[llvm-branch-commits] [cfe-branch] r368422 - Merging r368104 and r368202:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 9 02:48:02 PDT 2019
Author: hans
Date: Fri Aug 9 02:48:02 2019
New Revision: 368422
URL: http://llvm.org/viewvc/llvm-project?rev=368422&view=rev
Log:
Merging r368104 and r368202:
------------------------------------------------------------------------
r368104 | void | 2019-08-07 00:41:22 +0200 (Wed, 07 Aug 2019) | 13 lines
Delay diagnosing asm constraints that require immediates until after inlining
Summary:
An inline asm call may result in an immediate input value after inlining.
Therefore, don't emit a diagnostic here if the input isn't an immediate.
Reviewers: joerg, eli.friedman, rsmith
Subscribers: asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, s.egerton, krytarowski, mgorny, riccibruno, eraman, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D60943
------------------------------------------------------------------------
------------------------------------------------------------------------
r368202 | void | 2019-08-07 21:36:48 +0200 (Wed, 07 Aug 2019) | 2 lines
Add target requirements for those bots which don't handle x86.
------------------------------------------------------------------------
Added:
cfe/branches/release_90/test/CodeGen/pr41027.c
- copied, changed from r368104, cfe/trunk/test/CodeGen/pr41027.c
Removed:
cfe/branches/release_90/test/Sema/pr41027.c
Modified:
cfe/branches/release_90/ (props changed)
cfe/branches/release_90/lib/CodeGen/CGStmt.cpp
cfe/branches/release_90/lib/Sema/SemaStmtAsm.cpp
cfe/branches/release_90/test/Sema/inline-asm-validate-riscv.c
cfe/branches/release_90/test/Sema/inline-asm-validate-x86.c
Propchange: cfe/branches/release_90/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Aug 9 02:48:02 2019
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367823,367906
+/cfe/trunk:366429,366448,366457,366474,366480,366483,366511,366670,366694,366699,366878,367008,367039,367055,367103,367134,367301,367305,367323,367387,367403,367520,367530,367661,367675,367823,367906,368104,368202
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_90/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/CodeGen/CGStmt.cpp?rev=368422&r1=368421&r2=368422&view=diff
==============================================================================
--- cfe/branches/release_90/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/release_90/lib/CodeGen/CGStmt.cpp Fri Aug 9 02:48:02 2019
@@ -1846,11 +1846,9 @@ llvm::Value* CodeGenFunction::EmitAsmInp
InputExpr->EvaluateAsRValue(EVResult, getContext(), true);
llvm::APSInt IntResult;
- if (!EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
- getContext()))
- llvm_unreachable("Invalid immediate constant!");
-
- return llvm::ConstantInt::get(getLLVMContext(), IntResult);
+ if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
+ getContext()))
+ return llvm::ConstantInt::get(getLLVMContext(), IntResult);
}
Expr::EvalResult Result;
Modified: cfe/branches/release_90/lib/Sema/SemaStmtAsm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/lib/Sema/SemaStmtAsm.cpp?rev=368422&r1=368421&r2=368422&view=diff
==============================================================================
--- cfe/branches/release_90/lib/Sema/SemaStmtAsm.cpp (original)
+++ cfe/branches/release_90/lib/Sema/SemaStmtAsm.cpp Fri Aug 9 02:48:02 2019
@@ -383,25 +383,19 @@ StmtResult Sema::ActOnGCCAsmStmt(SourceL
} else if (Info.requiresImmediateConstant() && !Info.allowsRegister()) {
if (!InputExpr->isValueDependent()) {
Expr::EvalResult EVResult;
- if (!InputExpr->EvaluateAsRValue(EVResult, Context, true))
- return StmtError(
- Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected)
- << Info.getConstraintStr() << InputExpr->getSourceRange());
-
- // For compatibility with GCC, we also allow pointers that would be
- // integral constant expressions if they were cast to int.
- llvm::APSInt IntResult;
- if (!EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
- Context))
- return StmtError(
- Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected)
- << Info.getConstraintStr() << InputExpr->getSourceRange());
-
- if (!Info.isValidAsmImmediate(IntResult))
- return StmtError(Diag(InputExpr->getBeginLoc(),
- diag::err_invalid_asm_value_for_constraint)
- << IntResult.toString(10) << Info.getConstraintStr()
- << InputExpr->getSourceRange());
+ if (InputExpr->EvaluateAsRValue(EVResult, Context, true)) {
+ // For compatibility with GCC, we also allow pointers that would be
+ // integral constant expressions if they were cast to int.
+ llvm::APSInt IntResult;
+ if (EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
+ Context))
+ if (!Info.isValidAsmImmediate(IntResult))
+ return StmtError(Diag(InputExpr->getBeginLoc(),
+ diag::err_invalid_asm_value_for_constraint)
+ << IntResult.toString(10)
+ << Info.getConstraintStr()
+ << InputExpr->getSourceRange());
+ }
}
} else {
Copied: cfe/branches/release_90/test/CodeGen/pr41027.c (from r368104, cfe/trunk/test/CodeGen/pr41027.c)
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/CodeGen/pr41027.c?p2=cfe/branches/release_90/test/CodeGen/pr41027.c&p1=cfe/trunk/test/CodeGen/pr41027.c&r1=368104&r2=368422&rev=368422&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/pr41027.c (original)
+++ cfe/branches/release_90/test/CodeGen/pr41027.c Fri Aug 9 02:48:02 2019
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S -O2 -o - %s | FileCheck %s
// CHECK-LABEL: f:
Modified: cfe/branches/release_90/test/Sema/inline-asm-validate-riscv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Sema/inline-asm-validate-riscv.c?rev=368422&r1=368421&r2=368422&view=diff
==============================================================================
--- cfe/branches/release_90/test/Sema/inline-asm-validate-riscv.c (original)
+++ cfe/branches/release_90/test/Sema/inline-asm-validate-riscv.c Fri Aug 9 02:48:02 2019
@@ -4,7 +4,6 @@
void I(int i) {
static const int BelowMin = -2049;
static const int AboveMax = 2048;
- asm volatile ("" :: "I"(i)); // expected-error{{constraint 'I' expects an integer constant expression}}
asm volatile ("" :: "I"(BelowMin)); // expected-error{{value '-2049' out of range for constraint 'I'}}
asm volatile ("" :: "I"(AboveMax)); // expected-error{{value '2048' out of range for constraint 'I'}}
}
@@ -12,7 +11,6 @@ void I(int i) {
void J(int j) {
static const int BelowMin = -1;
static const int AboveMax = 1;
- asm volatile ("" :: "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
asm volatile ("" :: "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
asm volatile ("" :: "J"(AboveMax)); // expected-error{{value '1' out of range for constraint 'J'}}
}
@@ -20,7 +18,6 @@ void J(int j) {
void K(int k) {
static const int BelowMin = -1;
static const int AboveMax = 32;
- asm volatile ("" :: "K"(k)); // expected-error{{constraint 'K' expects an integer constant expression}}
asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}}
asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}}
}
Modified: cfe/branches/release_90/test/Sema/inline-asm-validate-x86.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Sema/inline-asm-validate-x86.c?rev=368422&r1=368421&r2=368422&view=diff
==============================================================================
--- cfe/branches/release_90/test/Sema/inline-asm-validate-x86.c (original)
+++ cfe/branches/release_90/test/Sema/inline-asm-validate-x86.c Fri Aug 9 02:48:02 2019
@@ -6,9 +6,6 @@ void I(int i, int j) {
static const int AboveMax = 32;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "I"(j)); // expected-error{{constraint 'I' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "I"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'I'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -23,9 +20,6 @@ void J(int i, int j) {
static const int AboveMax = 64;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "J"(j)); // expected-error{{constraint 'J' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "J"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'J'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -40,9 +34,6 @@ void K(int i, int j) {
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "K"(j)); // expected-error{{constraint 'K' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "K"(BelowMin)); // expected-error{{value '-129' out of range for constraint 'K'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -62,9 +53,6 @@ void L(int i, int j) {
static const int Valid3 = 0xffffffff;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "L"(j)); // expected-error{{constraint 'L' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "L"(Invalid1)); // expected-error{{value '1' out of range for constraint 'L'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -91,9 +79,6 @@ void M(int i, int j) {
static const int AboveMax = 4;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "M"(j)); // expected-error{{constraint 'M' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "M"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'M'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -108,9 +93,6 @@ void N(int i, int j) {
static const int AboveMax = 256;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "N"(j)); // expected-error{{constraint 'N' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "N"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'N'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -125,9 +107,6 @@ void O(int i, int j) {
static const int AboveMax = 128;
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "O"(j)); // expected-error{{constraint 'O' expects an integer constant expression}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "O"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'O'}}
__asm__("xorl %0,%2"
: "=r"(i)
@@ -146,10 +125,6 @@ void pr40890(void) {
__asm__ __volatile__("\n#define S_A abcd%0\n" : : "n"(&((struct s*)0)->a));
// This offset-from-null pointer can be used as an integer constant expression.
__asm__ __volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s*)0)->b));
- // This pointer cannot be used as an integer constant expression.
- __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "n"(&s.a)); // expected-error{{constraint 'n' expects an integer constant expression}}
- // Floating-point is also not okay.
- __asm__ __volatile__("\n#define PI abcd%0\n" : : "n"(3.14f)); // expected-error{{constraint 'n' expects an integer constant expression}}
#ifdef AMD64
// This arbitrary pointer is fine.
__asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));
Removed: cfe/branches/release_90/test/Sema/pr41027.c
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_90/test/Sema/pr41027.c?rev=368421&view=auto
==============================================================================
--- cfe/branches/release_90/test/Sema/pr41027.c (original)
+++ cfe/branches/release_90/test/Sema/pr41027.c (removed)
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64 -fsyntax-only %s
-// XFAIL: *
-
-inline void pr41027(unsigned a, unsigned b) {
- if (__builtin_constant_p(a)) {
- __asm__ volatile("outl %0,%w1" : : "a"(b), "n"(a));
- } else {
- __asm__ volatile("outl %0,%w1" : : "a"(b), "d"(a));
- }
-}
More information about the llvm-branch-commits
mailing list