dotnet3.1/SOURCES/coreclr-clang13.patch

84 lines
2.8 KiB
Diff

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