|
|
91b1de |
From 9a2857177a8a2a388298ad5674f6e5edd1e5b853 Mon Sep 17 00:00:00 2001
|
|
|
91b1de |
From: Jan Vorlicek <jan.vorlicek@volny.cz>
|
|
|
91b1de |
Date: Tue, 4 Jan 2022 23:51:52 +0100
|
|
|
91b1de |
Subject: [PATCH] Fix build with Clang 13 (#63314)
|
|
|
91b1de |
|
|
|
91b1de |
* Fix clang 13 induced runtime issues (#62170)
|
|
|
91b1de |
|
|
|
91b1de |
The clang 13 optimizer started to assume that "this" pointer is always
|
|
|
91b1de |
properly aligned. That lead to elimination of some code that was actually
|
|
|
91b1de |
needed.
|
|
|
91b1de |
It also takes pointer aliasing rules more strictly in one place in jit.
|
|
|
91b1de |
That caused the optimizer to falsely assume that a callee with an argument
|
|
|
91b1de |
passed by reference is not modifying that argument and used a stale
|
|
|
91b1de |
copy of the original value at the caller site.
|
|
|
91b1de |
|
|
|
91b1de |
This change fixes both of the issues. With this fix, runtime compiled
|
|
|
91b1de |
using clang 13 seems to be fully functional.
|
|
|
91b1de |
|
|
|
91b1de |
* Fix build with clang 13 (#60328)
|
|
|
91b1de |
---
|
|
|
91b1de |
src/inc/corhlpr.h | 8 ++++----
|
|
|
91b1de |
src/jit/bitsetasshortlong.h | 4 ++--
|
|
|
91b1de |
2 files changed, 6 insertions(+), 6 deletions(-)
|
|
|
91b1de |
|
|
|
91b1de |
diff --git a/src/inc/corhlpr.h b/src/inc/corhlpr.h
|
|
|
91b1de |
index 5b263a5382..c512069fca 100644
|
|
|
91b1de |
--- a/src/inc/corhlpr.h
|
|
|
91b1de |
+++ b/src/inc/corhlpr.h
|
|
|
91b1de |
@@ -335,7 +335,7 @@ struct COR_ILMETHOD_SECT
|
|
|
91b1de |
const COR_ILMETHOD_SECT* Next() const
|
|
|
91b1de |
{
|
|
|
91b1de |
if (!More()) return(0);
|
|
|
91b1de |
- return ((COR_ILMETHOD_SECT*)(((BYTE *)this) + DataSize()))->Align();
|
|
|
91b1de |
+ return ((COR_ILMETHOD_SECT*)Align(((BYTE *)this) + DataSize()));
|
|
|
91b1de |
}
|
|
|
91b1de |
|
|
|
91b1de |
const BYTE* Data() const
|
|
|
91b1de |
@@ -373,9 +373,9 @@ struct COR_ILMETHOD_SECT
|
|
|
91b1de |
return((AsSmall()->Kind & CorILMethod_Sect_FatFormat) != 0);
|
|
|
91b1de |
}
|
|
|
91b1de |
|
|
|
91b1de |
- const COR_ILMETHOD_SECT* Align() const
|
|
|
91b1de |
+ static const void* Align(const void* p)
|
|
|
91b1de |
{
|
|
|
91b1de |
- return((COR_ILMETHOD_SECT*) ((((UINT_PTR) this) + 3) & ~3));
|
|
|
91b1de |
+ return((void*) ((((UINT_PTR) p) + 3) & ~3));
|
|
|
91b1de |
}
|
|
|
91b1de |
|
|
|
91b1de |
protected:
|
|
|
91b1de |
@@ -578,7 +578,7 @@ typedef struct tagCOR_ILMETHOD_FAT : IMAGE_COR_ILMETHOD_FAT
|
|
|
91b1de |
|
|
|
91b1de |
const COR_ILMETHOD_SECT* GetSect() const {
|
|
|
91b1de |
if (!More()) return (0);
|
|
|
91b1de |
- return(((COR_ILMETHOD_SECT*) (GetCode() + GetCodeSize()))->Align());
|
|
|
91b1de |
+ return(((COR_ILMETHOD_SECT*) COR_ILMETHOD_SECT::Align(GetCode() + GetCodeSize())));
|
|
|
91b1de |
}
|
|
|
91b1de |
} COR_ILMETHOD_FAT;
|
|
|
91b1de |
|
|
|
91b1de |
diff --git a/src/jit/bitsetasshortlong.h b/src/jit/bitsetasshortlong.h
|
|
|
91b1de |
index 17e0e3a69c..0c40283ce5 100644
|
|
|
91b1de |
--- a/src/jit/bitsetasshortlong.h
|
|
|
91b1de |
+++ b/src/jit/bitsetasshortlong.h
|
|
|
91b1de |
@@ -346,7 +346,7 @@ public:
|
|
|
91b1de |
{
|
|
|
91b1de |
if (IsShort(env))
|
|
|
91b1de |
{
|
|
|
91b1de |
- (size_t&)out = (size_t)out & ((size_t)gen | (size_t)in);
|
|
|
91b1de |
+ out = (BitSetShortLongRep)((size_t)out & ((size_t)gen | (size_t)in));
|
|
|
91b1de |
}
|
|
|
91b1de |
else
|
|
|
91b1de |
{
|
|
|
91b1de |
@@ -362,7 +362,7 @@ public:
|
|
|
91b1de |
{
|
|
|
91b1de |
if (IsShort(env))
|
|
|
91b1de |
{
|
|
|
91b1de |
- (size_t&)in = (size_t)use | ((size_t)out & ~(size_t)def);
|
|
|
91b1de |
+ in = (BitSetShortLongRep)((size_t)use | ((size_t)out & ~(size_t)def));
|
|
|
91b1de |
}
|
|
|
91b1de |
else
|
|
|
91b1de |
{
|
|
|
91b1de |
--
|
|
|
91b1de |
2.34.1
|
|
|
91b1de |
|