public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* SRA generates uninitialized var use
@ 2011-06-18 10:20 Xinliang David Li
  2011-06-19 12:45 ` Xinliang David Li
  2011-06-20 11:15 ` Richard Guenther
  0 siblings, 2 replies; 11+ messages in thread
From: Xinliang David Li @ 2011-06-18 10:20 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Guenther

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

Compiling the test case in the patch with -O2 -m32 without the fix,
the program will abort. The problem is a var decl whose address is
taken is not marked as addressable leading to bad SSA update (missing
VUSE).  (the triaging used the the .after and .after_cleanup dump diff
and found the problem).

the test is on going. Ok after testing?

Thanks,

David

[-- Attachment #2: sra_bug.p --]
[-- Type: application/octet-stream, Size: 3317 bytes --]

2011-06-18  David Li  <davidxl@google.com>

	* tree-sra.c (generate_subtree_copies): Mark var_decl
	addressable.


2011-06-18  David Li  <davidxl@google.com>
	* testsuite/g++.dg/tree-ssa/sra_bug.C: New test.

Index: tree-sra.c
===================================================================
--- tree-sra.c	(revision 175051)
+++ tree-sra.c	(working copy)
@@ -2280,6 +2280,8 @@ generate_subtree_copies (struct access *
 	  expr = build_ref_for_model (loc, agg, access->offset - top_offset,
 				      access, gsi, insert_after);
 
+          if (TREE_CODE (agg) == VAR_DECL)
+	    TREE_ADDRESSABLE (agg) = 1;
 	  if (write)
 	    {
 	      if (access->grp_partial_lhs)
Index: testsuite/g++.dg/tree-ssa/sra_bug.C
===================================================================
--- testsuite/g++.dg/tree-ssa/sra_bug.C	(revision 0)
+++ testsuite/g++.dg/tree-ssa/sra_bug.C	(revision 0)
@@ -0,0 +1,90 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include <stdio.h>
+#include <stdlib.h>
+typedef int int32;
+typedef unsigned int uint32;
+typedef unsigned long long uint64;
+typedef short int16;
+
+class Tp {
+ public:
+  Tp(int, const int segment, const int index) __attribute__((noinline));
+
+  inline bool operator==(const Tp& other) const;
+  inline bool operator!=(const Tp& other) const;
+  int GetType() const { return type_; }
+  int GetSegment() const { return segment_; }
+  int GetIndex() const { return index_; }
+ private:
+  inline static bool IsValidSegment(const int segment);
+  static const int kSegmentBits = 28;
+  static const int kTypeBits = 4;
+  static const int kMaxSegment = (1 << kSegmentBits) - 1;
+
+  union {
+
+    struct {
+      int32 index_;
+      uint32 segment_ : kSegmentBits;
+      uint32 type_ : kTypeBits;
+    };
+    struct {
+      int32 dummy_;
+      uint32 type_and_segment_;
+    };
+    uint64 value_;
+  };
+};
+
+Tp::Tp(int t, const int segment, const int index)
+ : index_(index), segment_(segment), type_(t) {}
+
+inline bool Tp::operator==(const Tp& other) const {
+  return value_ == other.value_;
+}
+inline bool Tp::operator!=(const Tp& other) const {
+  return value_ != other.value_;
+}
+
+class Range {
+ public:
+  inline Range(const Tp& position, const int count) __attribute__((always_inline));
+  inline Tp GetBeginTokenPosition() const;
+  inline Tp GetEndTokenPosition() const;
+ private:
+  Tp position_;
+  int count_;
+  int16 begin_index_;
+  int16 end_index_;
+};
+
+inline Range::Range(const Tp& position,
+                    const int count)
+    : position_(position), count_(count), begin_index_(0), end_index_(0)
+    { }
+
+inline Tp Range::GetBeginTokenPosition() const {
+  return position_;
+}
+inline Tp Range::GetEndTokenPosition() const {
+  return Tp(position_.GetType(), position_.GetSegment(),
+            position_.GetIndex() + count_);
+}
+
+int main ()
+{
+  Range range(Tp(0, 0, 3), 0);
+  if (!(range.GetBeginTokenPosition() == Tp(0, 0, 3)))
+    {
+      fprintf (stderr, " FAILED 1!!!!\n");
+      abort ();
+    }
+  if (!(range.GetEndTokenPosition() == Tp(0, 0, 3)))
+    {
+      fprintf (stderr, "FAILED 2\n");
+      abort();
+    }
+  return 0;
+}

Property changes on: testsuite/g++.dg/tree-ssa/sra_bug.C
___________________________________________________________________
Added: svn:executable
   + *


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-06-23 14:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-18 10:20 SRA generates uninitialized var use Xinliang David Li
2011-06-19 12:45 ` Xinliang David Li
2011-06-20 11:15 ` Richard Guenther
2011-06-20 16:23   ` Xinliang David Li
2011-06-20 20:58     ` Richard Guenther
2011-06-20 23:40       ` Xinliang David Li
2011-06-21  8:56         ` Richard Guenther
2011-06-21 16:11           ` Xinliang David Li
2011-06-21 16:11             ` Richard Guenther
2011-06-22 14:00               ` Martin Jambor
2011-06-23 14:37       ` Martin Jambor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).