r233162 - [Modules] Make the DeclUpdates map be processed in insertion order.

Chandler Carruth chandlerc at gmail.com
Tue Mar 24 18:02:13 PDT 2015


Author: chandlerc
Date: Tue Mar 24 20:02:12 2015
New Revision: 233162

URL: http://llvm.org/viewvc/llvm-project?rev=233162&view=rev
Log:
[Modules] Make the DeclUpdates map be processed in insertion order.

This fixes my stress tests non-determinism so far. However, I've not
started playing with templates, friends, or terrible macros. I've found
at least two more seeming instabilities and am just waiting for a test
case to actually trigger them.

Added:
    cfe/trunk/test/Modules/Inputs/stress1/
    cfe/trunk/test/Modules/Inputs/stress1/common.h
    cfe/trunk/test/Modules/Inputs/stress1/m00.h
    cfe/trunk/test/Modules/Inputs/stress1/m01.h
    cfe/trunk/test/Modules/Inputs/stress1/m02.h
    cfe/trunk/test/Modules/Inputs/stress1/m03.h
    cfe/trunk/test/Modules/Inputs/stress1/merge00.h
    cfe/trunk/test/Modules/Inputs/stress1/module.modulemap
    cfe/trunk/test/Modules/stress1.cpp
Modified:
    cfe/trunk/include/clang/Serialization/ASTWriter.h

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=233162&r1=233161&r2=233162&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Mar 24 20:02:12 2015
@@ -321,7 +321,7 @@ private:
   };
 
   typedef SmallVector<DeclUpdate, 1> UpdateRecord;
-  typedef llvm::DenseMap<const Decl *, UpdateRecord> DeclUpdateMap;
+  typedef llvm::MapVector<const Decl *, UpdateRecord> DeclUpdateMap;
   /// \brief Mapping from declarations that came from a chained PCH to the
   /// record containing modifications to them.
   DeclUpdateMap DeclUpdates;

Added: cfe/trunk/test/Modules/Inputs/stress1/common.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/common.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/common.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/common.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,38 @@
+#ifndef STRESS1_COMMON_H
+#define STRESS1_COMMON_H
+
+inline char function00(char x) { return x + x; }
+inline short function00(short x) { return x + x; }
+inline int function00(int x) { return x + x; }
+
+namespace N00 {
+struct S00 {
+  char c;
+  short s;
+  int i;
+
+  S00(char x) : c(x) {}
+  S00(short x) : s(x) {}
+  S00(int x) : i(x) {}
+
+  char method00(char x) { return x + x; }
+  short method00(short x) { return x + x; }
+  int method00(int x) { return x + x; }
+
+  operator char() { return c; }
+  operator short() { return s; }
+  operator int() { return i; }
+};
+struct S01 {};
+struct S03 {};
+}
+
+namespace N01 {
+struct S00 : N00::S00 {
+  using N00::S00::S00;
+};
+struct S01 {};
+struct S02 {};
+}
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/m00.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/m00.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/m00.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/m00.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M00_H
+#define STRESS1_M00_H
+
+#include "common.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/m01.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/m01.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/m01.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/m01.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M01_H
+#define STRESS1_M01_H
+
+#include "common.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/m02.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/m02.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/m02.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/m02.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M02_H
+#define STRESS1_M02_H
+
+#include "common.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/m03.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/m03.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/m03.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/m03.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,6 @@
+#ifndef STRESS1_M03_H
+#define STRESS1_M03_H
+
+#include "common.h"
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/merge00.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/merge00.h?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/merge00.h (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/merge00.h Tue Mar 24 20:02:12 2015
@@ -0,0 +1,11 @@
+#ifndef STRESS1_MERGE00_H
+#define STRESS1_MERGE00_H
+
+#include "m00.h"
+#include "m01.h"
+#include "m02.h"
+#include "m03.h"
+
+inline int g() { return N00::S00('a').method00('b') + (int)N00::S00(42) + function00(42); }
+
+#endif

Added: cfe/trunk/test/Modules/Inputs/stress1/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/stress1/module.modulemap?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/stress1/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/stress1/module.modulemap Tue Mar 24 20:02:12 2015
@@ -0,0 +1,6 @@
+module m00 { header "Inputs/stress1/m00.h" export * }
+module m01 { header "Inputs/stress1/m01.h" export * }
+module m02 { header "Inputs/stress1/m02.h" export * }
+module m03 { header "Inputs/stress1/m03.h" export * }
+
+module merge00 { header "Inputs/stress1/merge00.h" export * }

Added: cfe/trunk/test/Modules/stress1.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/stress1.cpp?rev=233162&view=auto
==============================================================================
--- cfe/trunk/test/Modules/stress1.cpp (added)
+++ cfe/trunk/test/Modules/stress1.cpp Tue Mar 24 20:02:12 2015
@@ -0,0 +1,100 @@
+// RUN: rm -rf %t
+// RUN: cd %S
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m00 -o %t/m00.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m00 -o %t/m00_check.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: diff %t/m00.pcm %t/m00_check.pcm
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m01 -o %t/m01.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m02 -o %t/m02.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -emit-module -fmodule-name=m03 -o %t/m03.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -emit-module -fmodule-name=merge00 -o %t/merge00.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -emit-module -fmodule-name=merge00 -o %t/merge00_check.pcm \
+// RUN:   Inputs/stress1/module.modulemap
+//
+// RUN: diff %t/merge00.pcm %t/merge00_check.pcm
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-map-file=Inputs/stress1/module.modulemap \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -fmodule-file=%t/merge00.pcm \
+// RUN:   -verify stress1.cpp -S -emit-llvm -o %t/stress1.ll
+//
+// RUN: %clang_cc1 -fmodules -x c++ -std=c++11 \
+// RUN:   -I Inputs/stress1 \
+// RUN:   -fno-implicit-modules -fno-modules-implicit-maps \
+// RUN:   -fmodule-map-file-home-is-cwd \
+// RUN:   -fmodule-map-file=Inputs/stress1/module.modulemap \
+// RUN:   -fmodule-file=%t/m00.pcm \
+// RUN:   -fmodule-file=%t/m01.pcm \
+// RUN:   -fmodule-file=%t/m02.pcm \
+// RUN:   -fmodule-file=%t/m03.pcm \
+// RUN:   -fmodule-file=%t/merge00.pcm \
+// RUN:   -verify stress1.cpp -S -emit-llvm -o %t/stress1_check.ll
+//
+// RUN: diff -u %t/stress1.ll %t/stress1_check.ll
+//
+// expected-no-diagnostics
+
+#include "m00.h"
+#include "m01.h"
+#include "m02.h"
+#include "m03.h"
+
+#include "merge00.h"
+
+int f() { return N01::S00('a').method00('b') + (int)N00::S00(42) + function00(42) + g(); }





More information about the cfe-commits mailing list