From a5bc863a99fc06e030d077d4f31d13080eb2e064 Mon Sep 17 00:00:00 2001 From: Joseph Tremoulet Date: Fri, 2 Sep 2016 15:22:01 -0400 Subject: [PATCH] Fix GTF_ flag collision Define flag `GTF_IS_IN_CSE` (which is used only to communicate in a call to `gtNodeHasSideEffects` that the caller wants to disregard the side-effect of running a .cctor) as `GTF_BOOLEAN` rather than `GTF_MAKE_CSE` -- as the comment at the definition of `GTF_IS_IN_CSE` indicates, the only requirement on its value is that it not conflict with one of the side-effect flags, but `gtNodeHasSideEffects` does in fact check for `GTF_MAKE_CSE`, so the current value conflicts. Also update the code in `gtNodeHasSideEffects` that is dictated by `GTF_IS_IN_CSE` to check just for that bit, instead of checking that the caller passed in exactly `GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE` -- no need to entangle conceptually independent parameters. Fixes dotnet/coreclr#7042. Commit migrated from https://github.com/dotnet/coreclr/commit/4aae2404c2a74a1d3e7e8a37810e6c7c67aabb64 --- src/coreclr/src/jit/gentree.cpp | 4 ++-- src/coreclr/src/jit/gentree.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/src/jit/gentree.cpp b/src/coreclr/src/jit/gentree.cpp index 548c874..1b3f4f2 100644 --- a/src/coreclr/src/jit/gentree.cpp +++ b/src/coreclr/src/jit/gentree.cpp @@ -13865,9 +13865,9 @@ bool Compiler::gtNodeHasSideEffects(GenTreePtr tree, unsigned flags) return true; } - // with GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE we will CSE helper calls that can run cctors. + // with GTF_IS_IN_CSE we will CSE helper calls that can run cctors. // - if ((flags != GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE) && (s_helperCallProperties.MayRunCctor(helper))) + if (((flags & GTF_IS_IN_CSE) == 0) && (s_helperCallProperties.MayRunCctor(helper))) { return true; } diff --git a/src/coreclr/src/jit/gentree.h b/src/coreclr/src/jit/gentree.h index 1ea7888..619c964 100644 --- a/src/coreclr/src/jit/gentree.h +++ b/src/coreclr/src/jit/gentree.h @@ -740,7 +740,7 @@ public: // // The only requirement of this flag is that it not overlap any of the // side-effect flags. The actual bit used is otherwise arbitrary. -#define GTF_IS_IN_CSE GTF_MAKE_CSE +#define GTF_IS_IN_CSE GTF_BOOLEAN #define GTF_PERSISTENT_SIDE_EFFECTS_IN_CSE (GTF_ASG | GTF_CALL | GTF_IS_IN_CSE) // Can any side-effects be observed externally, say by a caller method? -- 2.7.4