|
|
417dba |
From 9cd95a5608b667e22727d9eb1a5330efd61dfe50 Mon Sep 17 00:00:00 2001
|
|
|
417dba |
From: Jan Vorlicek <janvorli@microsoft.com>
|
|
|
417dba |
Date: Mon, 29 Nov 2021 17:32:45 -0800
|
|
|
417dba |
Subject: [PATCH] Fix clang 13 induced runtime issues
|
|
|
417dba |
|
|
|
417dba |
The clang 13 optimizer started to assume that "this" pointer is always
|
|
|
417dba |
properly aligned. That lead to elimination of some code that was actually
|
|
|
417dba |
needed.
|
|
|
417dba |
It also takes pointer aliasing rules more strictly in one place in jit.
|
|
|
417dba |
That caused the optimizer to falsely assume that a callee with an argument
|
|
|
417dba |
passed by reference is not modifying that argument and used a stale
|
|
|
417dba |
copy of the original value at the caller site.
|
|
|
417dba |
|
|
|
417dba |
This change fixes both of the issues. With this fix, runtime compiled
|
|
|
417dba |
using clang 13 seems to be fully functional.
|
|
|
417dba |
---
|
|
|
417dba |
src/coreclr/inc/corhlpr.h | 8 ++++----
|
|
|
417dba |
src/coreclr/jit/bitsetasshortlong.h | 4 ++--
|
|
|
417dba |
2 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
417dba |
|
|
|
417dba |
diff --git a/src/coreclr/inc/corhlpr.h b/src/coreclr/inc/corhlpr.h
|
|
|
417dba |
index 450514da95c1..427e8cdc0ff5 100644
|
|
|
417dba |
--- a/src/coreclr/inc/corhlpr.h
|
|
|
417dba |
+++ b/src/coreclr/inc/corhlpr.h
|
|
|
417dba |
@@ -336,7 +336,7 @@ struct COR_ILMETHOD_SECT
|
|
|
417dba |
const COR_ILMETHOD_SECT* Next() const
|
|
|
417dba |
{
|
|
|
417dba |
if (!More()) return(0);
|
|
|
417dba |
- return ((COR_ILMETHOD_SECT*)(((BYTE *)this) + DataSize()))->Align();
|
|
|
417dba |
+ return ((COR_ILMETHOD_SECT*)Align(((BYTE *)this) + DataSize()));
|
|
|
417dba |
}
|
|
|
417dba |
|
|
|
417dba |
const BYTE* Data() const
|
|
|
417dba |
@@ -374,9 +374,9 @@ struct COR_ILMETHOD_SECT
|
|
|
417dba |
return((AsSmall()->Kind & CorILMethod_Sect_FatFormat) != 0);
|
|
|
417dba |
}
|
|
|
417dba |
|
|
|
417dba |
- const COR_ILMETHOD_SECT* Align() const
|
|
|
417dba |
+ static const void* Align(const void* p)
|
|
|
417dba |
{
|
|
|
417dba |
- return((COR_ILMETHOD_SECT*) ((((UINT_PTR) this) + 3) & ~3));
|
|
|
417dba |
+ return((void*) ((((UINT_PTR) p) + 3) & ~3));
|
|
|
417dba |
}
|
|
|
417dba |
|
|
|
417dba |
protected:
|
|
|
417dba |
@@ -579,7 +579,7 @@ typedef struct tagCOR_ILMETHOD_FAT : IMAGE_COR_ILMETHOD_FAT
|
|
|
417dba |
|
|
|
417dba |
const COR_ILMETHOD_SECT* GetSect() const {
|
|
|
417dba |
if (!More()) return (0);
|
|
|
417dba |
- return(((COR_ILMETHOD_SECT*) (GetCode() + GetCodeSize()))->Align());
|
|
|
417dba |
+ return(((COR_ILMETHOD_SECT*) COR_ILMETHOD_SECT::Align(GetCode() + GetCodeSize())));
|
|
|
417dba |
}
|
|
|
417dba |
} COR_ILMETHOD_FAT;
|
|
|
417dba |
|
|
|
417dba |
diff --git a/src/coreclr/jit/bitsetasshortlong.h b/src/coreclr/jit/bitsetasshortlong.h
|
|
|
417dba |
index d343edeeda4c..365cf346a10a 100644
|
|
|
417dba |
--- a/src/coreclr/jit/bitsetasshortlong.h
|
|
|
417dba |
+++ b/src/coreclr/jit/bitsetasshortlong.h
|
|
|
417dba |
@@ -345,7 +345,7 @@ class BitSetOps</*BitSetType*/ BitSetShortLongRep,
|
|
|
417dba |
{
|
|
|
417dba |
if (IsShort(env))
|
|
|
417dba |
{
|
|
|
417dba |
- (size_t&)out = (size_t)out & ((size_t)gen | (size_t)in);
|
|
|
417dba |
+ out = (BitSetShortLongRep)((size_t)out & ((size_t)gen | (size_t)in));
|
|
|
417dba |
}
|
|
|
417dba |
else
|
|
|
417dba |
{
|
|
|
417dba |
@@ -361,7 +361,7 @@ class BitSetOps</*BitSetType*/ BitSetShortLongRep,
|
|
|
417dba |
{
|
|
|
417dba |
if (IsShort(env))
|
|
|
417dba |
{
|
|
|
417dba |
- (size_t&)in = (size_t)use | ((size_t)out & ~(size_t)def);
|
|
|
417dba |
+ in = (BitSetShortLongRep)((size_t)use | ((size_t)out & ~(size_t)def));
|
|
|
417dba |
}
|
|
|
417dba |
else
|
|
|
417dba |
{
|