This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[PATCH 4/4] Add warning for non-constant memory models
- From: Andi Kleen <andi at firstfloor dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: libstdc++ at gcc dot gnu dot org, rth at redhat dot com, Andi Kleen <ak at linux dot intel dot com>
- Date: Sat, 16 Mar 2013 14:29:29 +0100
- Subject: [PATCH 4/4] Add warning for non-constant memory models
- References: <1363440569-17331-1-git-send-email-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
Non constant memory models drop HLE attribute bits. Since we had
problems with this even in gcc code itself, like libstdc++ <atomic>
passing variables when not optimizing, add a warning for this case.
Passed bootstrap and test on x86_64-linux.
gcc/:
2013-03-15 Andi Kleen <ak@my.domain.org>
PR target/55947
* gcc/builtins.c (get_memmodel): Warn for non constant
memory model.
---
gcc/builtins.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 68b6a2c..c4efc4c 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -5280,10 +5280,14 @@ get_memmodel (tree exp)
rtx op;
unsigned HOST_WIDE_INT val;
- /* If the parameter is not a constant, it's a run time value so we'll just
- convert it to MEMMODEL_SEQ_CST to avoid annoying runtime checking. */
+ /* Warn about non constant memory models, as we drop target specific
+ bits (like HLE). */
if (TREE_CODE (exp) != INTEGER_CST)
- return MEMMODEL_SEQ_CST;
+ {
+ warning (OPT_Winvalid_memory_model,
+ "Non constant memory model: Assuming __ATOMIC_SEQ_CST");
+ return MEMMODEL_SEQ_CST;
+ }
op = expand_normal (exp);
--
1.7.10.4