[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-08-07 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D60943#1619579 , @JamesNagurne 
wrote:

> In case you haven't seen, this commit breaks non-x86 build bots due to the 
> combination of '-triple x86_64*' and '-S'. Some tests that use this target 
> are only looking for AST dumps, and do not actually require such a target. 
> This is not one of those tests, as it's inspecting assembly.
>  See clang/test/CodeGen/addrsig.c to see how that is handled (via REQUIRES: 
> x86-registered-target).
>
> Oddly enough, other tests that use -triple x86_64* and only inspect the AST 
> don't require the registered target.


Sorry about that. Fixed in r368202.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-08-07 Thread James Nagurne via Phabricator via cfe-commits
JamesNagurne added a comment.

In case you haven't seen, this commit breaks non-x86 build bots due to the 
combination of '-triple x86_64*' and '-S'. Some tests that use this target are 
only looking for AST dumps, and do not actually require such a target. This is 
not one of those tests, as it's inspecting assembly.
See clang/test/CodeGen/addrsig.c to see how that is handled (via REQUIRES: 
x86-registered-target).

Oddly enough, other tests that use -triple x86_64* and only inspect the AST 
don't require the registered target.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-08-07 Thread Bill Wendling via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368104: Delay diagnosing asm constraints that require 
immediates until after inlining (authored by void, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60943?vs=212085=213738#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943

Files:
  cfe/trunk/lib/CodeGen/CGStmt.cpp
  cfe/trunk/lib/Sema/SemaStmtAsm.cpp
  cfe/trunk/test/CodeGen/pr41027.c
  cfe/trunk/test/Sema/inline-asm-validate-riscv.c
  cfe/trunk/test/Sema/inline-asm-validate-x86.c
  cfe/trunk/test/Sema/pr41027.c

Index: cfe/trunk/lib/CodeGen/CGStmt.cpp
===
--- cfe/trunk/lib/CodeGen/CGStmt.cpp
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp
@@ -1846,11 +1846,9 @@
   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;
Index: cfe/trunk/lib/Sema/SemaStmtAsm.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAsm.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAsm.cpp
@@ -383,25 +383,19 @@
 } 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 {
Index: cfe/trunk/test/Sema/inline-asm-validate-riscv.c
===
--- cfe/trunk/test/Sema/inline-asm-validate-riscv.c
+++ cfe/trunk/test/Sema/inline-asm-validate-riscv.c
@@ -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 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 K(int k) {
   

[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-08-05 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

In D60943#1612083 , @joerg wrote:

> The combination of D60942 , D06943 and 
> D65280  solves the problems for me on all 
> targets I have.


Excellent! I submitted D60942 . Go ahead and 
LGTM please. :-) Thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-08-02 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

The combination of D60942 , D06943 and D65280 
 solves the problems for me on all targets I 
have.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-31 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Friendly ping. :-)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-28 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 212085.
void added a comment.
Herald added subscribers: s.egerton, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
apazos, simoncook, johnrusso, rbar, asb.

Move a few more tests around. Some go to the LLVM side.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943

Files:
  lib/CodeGen/CGStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/CodeGen/pr41027.c
  test/Sema/inline-asm-validate-riscv.c
  test/Sema/inline-asm-validate-x86.c
  test/Sema/pr41027.c

Index: test/Sema/pr41027.c
===
--- test/Sema/pr41027.c
+++ /dev/null
@@ -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));
-  }
-}
Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -4,9 +4,6 @@
 void I(int i, int j) {
   static const int BelowMin = -1;
   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'}}
@@ -21,9 +18,6 @@
 void J(int i, int j) {
   static const int BelowMin = -1;
   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'}}
@@ -38,9 +32,6 @@
 void K(int i, int j) {
   static const int BelowMin = -129;
   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'}}
@@ -60,9 +51,6 @@
   static const int Valid1 = 0xff;
   static const int Valid2 = 0x;
   static const int Valid3 = 0x;
-  __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'}}
@@ -89,9 +77,6 @@
 void M(int i, int j) {
   static const int BelowMin = -1;
   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'}}
@@ -106,9 +91,6 @@
 void N(int i, int j) {
   static const int BelowMin = -1;
   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'}}
@@ -123,9 +105,6 @@
 void O(int i, int j) {
   static const int BelowMin = -1;
   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'}}
@@ -146,10 +125,6 @@
   __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"()); // 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*)0xdeadbeef));
Index: test/Sema/inline-asm-validate-riscv.c

[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-28 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 212079.
void added a comment.

Don't emit errors here. Wait until codegen.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943

Files:
  lib/CodeGen/CGStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/inline-asm-validate-x86.c


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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"()); // 
expected-error{{constraint 'n' expects an integer constant expression}}
+  __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "e"()); // 
expected-error{{constraint 'e' 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}}
+  __asm__ __volatile__("\n#define PI abcd%0\n" : : "e"(3.14f)); // 
expected-error{{constraint 'e' expects an integer constant expression}}
 #ifdef AMD64
   // This arbitrary pointer is fine.
   __asm__ __volatile__("\n#define BEEF abcd%0\n" : : 
"n"((int*)0xdeadbeef));
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -383,25 +383,19 @@
 } 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 {
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1846,11 +1846,9 @@
   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;


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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__ 

[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 212072.
void added a comment.

Save checking of immediates until code generation.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943

Files:
  lib/CodeGen/CGStmt.cpp
  lib/Sema/SemaStmtAsm.cpp
  test/Sema/inline-asm-validate-x86.c


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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"()); // 
expected-error{{constraint 'n' expects an integer constant expression}}
+  __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "e"()); // 
expected-error{{constraint 'e' 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}}
+  __asm__ __volatile__("\n#define PI abcd%0\n" : : "e"(3.14f)); // 
expected-error{{constraint 'e' expects an integer constant expression}}
 #ifdef AMD64
   // This arbitrary pointer is fine.
   __asm__ __volatile__("\n#define BEEF abcd%0\n" : : 
"n"((int*)0xdeadbeef));
Index: lib/Sema/SemaStmtAsm.cpp
===
--- lib/Sema/SemaStmtAsm.cpp
+++ lib/Sema/SemaStmtAsm.cpp
@@ -383,25 +383,19 @@
 } 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 {
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1846,11 +1846,9 @@
   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;


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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__ 

[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-27 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

I understand, but the current version just doesn't work anyway to delay it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-26 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

That was intentional. We want to do this for more than just the `n` constraint.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-24 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

You lost the changes to lib/Sema/SemaStmtAsm.cpp to actually do the delaying 
for immediate operands?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-07-09 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Friendly ping.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-06-26 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 206587.
void added a comment.

Modify so that no diagnistics are emitted until we can determine if it's an
immediate or not.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943

Files:
  lib/CodeGen/CGStmt.cpp
  test/Sema/inline-asm-validate-x86.c


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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"()); // 
expected-error{{constraint 'n' expects an integer constant expression}}
+  __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "e"()); // 
expected-error{{constraint 'e' 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}}
+  __asm__ __volatile__("\n#define PI abcd%0\n" : : "e"(3.14f)); // 
expected-error{{constraint 'e' expects an integer constant expression}}
 #ifdef AMD64
   // This arbitrary pointer is fine.
   __asm__ __volatile__("\n#define BEEF abcd%0\n" : : 
"n"((int*)0xdeadbeef));
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1842,11 +1842,9 @@
   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;


Index: test/Sema/inline-asm-validate-x86.c
===
--- test/Sema/inline-asm-validate-x86.c
+++ test/Sema/inline-asm-validate-x86.c
@@ -147,9 +147,9 @@
   // 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"()); // expected-error{{constraint 'n' expects an integer constant expression}}
+  __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "e"()); // expected-error{{constraint 'e' 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}}
+  __asm__ __volatile__("\n#define PI abcd%0\n" : : "e"(3.14f)); // expected-error{{constraint 'e' expects an integer constant expression}}
 #ifdef AMD64
   // This arbitrary pointer is fine.
   __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeef));
Index: lib/CodeGen/CGStmt.cpp
===
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1842,11 +1842,9 @@
   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;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60943: Delay diagnosing asm constraints that require immediates until after inlining

2019-06-26 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

This should be ready for review now. PTAL.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60943/new/

https://reviews.llvm.org/D60943



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits