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