Skip to content

Commit 15eb5af

Browse files
Merge branch 'main' into users/yuxuanchen1997/coro-fix-cgscc-update
2 parents 3bbd280 + d3b9855 commit 15eb5af

File tree

71 files changed

+1129
-338
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1129
-338
lines changed

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,6 +1670,15 @@ static bool interp__builtin_operator_delete(InterpState &S, CodePtr OpPC,
16701670
S, OpPC, *AllocForm, DynamicAllocator::Form::Operator, BlockDesc, Source);
16711671
}
16721672

1673+
static bool interp__builtin_arithmetic_fence(InterpState &S, CodePtr OpPC,
1674+
const InterpFrame *Frame,
1675+
const Function *Func,
1676+
const CallExpr *Call) {
1677+
const Floating &Arg0 = S.Stk.peek<Floating>();
1678+
S.Stk.push<Floating>(Arg0);
1679+
return true;
1680+
}
1681+
16731682
bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
16741683
const CallExpr *Call, uint32_t BuiltinID) {
16751684
const InterpFrame *Frame = S.Current;
@@ -2111,6 +2120,11 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
21112120
return false;
21122121
break;
21132122

2123+
case Builtin::BI__arithmetic_fence:
2124+
if (!interp__builtin_arithmetic_fence(S, OpPC, Frame, F, Call))
2125+
return false;
2126+
break;
2127+
21142128
default:
21152129
S.FFDiag(S.Current->getLocation(OpPC),
21162130
diag::note_invalid_subexpr_in_const_expr)

clang/test/Sema/arithmetic-fence-builtin.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
2+
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter
23
// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
4+
// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter
35
// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
46
// RUN: -fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
7+
// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s -fexperimental-new-constant-interpreter \
8+
// RUN: -fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
59
// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s
10+
// RUN: %clang_cc1 -triple spir64 -emit-llvm -o - -verify -x c++ %s -fexperimental-new-constant-interpreter
611
#ifndef PPC
712
int v;
813
template <typename T> T addT(T a, T b) {

compiler-rt/lib/asan/scripts/asan_symbolize.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def symbolize(self, addr, binary, offset):
316316
# * For C functions atos omits parentheses and argument types.
317317
# * For C++ functions the function name (i.e., `foo` above) may contain
318318
# templates which may contain parentheses.
319-
match = re.match("^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
319+
match = re.match(r"^(.*) \(in (.*)\) \((.*:\d*)\)$", atos_line)
320320
logging.debug("atos_line: %s", atos_line)
321321
if match:
322322
function_name = match.group(1)
@@ -541,7 +541,7 @@ def process_line_posix(self, line):
541541
# names in the regex because it could be an
542542
# Objective-C or C++ demangled name.
543543
stack_trace_line_format = (
544-
"^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
544+
r"^( *#([0-9]+) *)(0x[0-9a-f]+) *(?:in *.+)? *\((.*)\+(0x[0-9a-f]+)\)"
545545
)
546546
match = re.match(stack_trace_line_format, line)
547547
if not match:

compiler-rt/lib/hwasan/scripts/hwasan_symbolize

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ class Symbolizer:
316316
self.__last_access_tag = int(match.group(2), 16)
317317

318318
def process_tag_dump_line(self, line, ignore_tags=False):
319-
m = re.match(r'.*?(0x[0-9a-f]+):' + '([ ]*[\[ ][0-9a-f][0-9a-f]\]?)' * 16, line)
319+
m = re.match(r'.*?(0x[0-9a-f]+):' + r'([ ]*[\[ ][0-9a-f][0-9a-f]\]?)' * 16, line)
320320
if m is None:
321321
return False
322322
addr = m.group(1)

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,13 @@ TEST(TestRtsanInterceptors, VallocDiesWhenRealtime) {
122122
ExpectNonRealtimeSurvival(Func);
123123
}
124124

125-
#if __has_builtin(__builtin_available) && SANITIZER_APPLE
126-
#define ALIGNED_ALLOC_AVAILABLE() (__builtin_available(macOS 10.15, *))
127-
#else
128-
// We are going to assume this is true until we hit systems where it isn't
129-
#define ALIGNED_ALLOC_AVAILABLE() (true)
130-
#endif
131-
125+
#if SANITIZER_INTERCEPT_ALIGNED_ALLOC
132126
TEST(TestRtsanInterceptors, AlignedAllocDiesWhenRealtime) {
133-
if (ALIGNED_ALLOC_AVAILABLE()) {
134-
auto Func = []() { EXPECT_NE(nullptr, aligned_alloc(16, 32)); };
135-
ExpectRealtimeDeath(Func, "aligned_alloc");
136-
ExpectNonRealtimeSurvival(Func);
137-
}
127+
auto Func = []() { EXPECT_NE(nullptr, aligned_alloc(16, 32)); };
128+
ExpectRealtimeDeath(Func, "aligned_alloc");
129+
ExpectNonRealtimeSurvival(Func);
138130
}
131+
#endif
139132

140133
// free_sized and free_aligned_sized (both C23) are not yet supported
141134
TEST(TestRtsanInterceptors, FreeDiesWhenRealtime) {

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,6 @@
8484
#define SI_NOT_MAC 1
8585
#endif
8686

87-
#if SANITIZER_APPLE
88-
# include <Availability.h>
89-
90-
// aligned_alloc was introduced in OSX 10.15
91-
// Linking will fail when using an older SDK
92-
# if defined(__MAC_10_15)
93-
// macOS 10.15 is greater than our minimal deployment target. To ensure we
94-
// generate a weak reference so the dylib continues to work on older
95-
// systems, we need to forward declare the intercepted function as "weak
96-
// imports".
97-
SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
98-
__sanitizer::usize __size);
99-
# define SI_MAC_SDK_10_15_AVAILABLE 1
100-
# else
101-
# define SI_MAC_SDK_10_15_AVAILABLE 0
102-
# endif // defined(__MAC_10_15)
103-
104-
#endif // SANITIZER_APPLE
105-
10687
#if SANITIZER_IOS
10788
#define SI_IOS 1
10889
#else
@@ -519,8 +500,7 @@ SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
519500
#define SANITIZER_INTERCEPT_PVALLOC (SI_GLIBC || SI_ANDROID)
520501
#define SANITIZER_INTERCEPT_CFREE (SI_GLIBC && !SANITIZER_RISCV64)
521502
#define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX
522-
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC \
523-
(!SI_MAC || SI_MAC_SDK_10_15_AVAILABLE)
503+
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC)
524504
#define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD)
525505
#define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID
526506
#define SANITIZER_INTERCEPT_WCSLEN 1

libcxx/include/__vector/vector.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ class _LIBCPP_TEMPLATE_VIS vector {
165165
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI
166166
vector(size_type __n, const value_type& __x, const allocator_type& __a)
167167
: __alloc_(__a) {
168+
auto __guard = std::__make_exception_guard(__destroy_vector(*this));
168169
if (__n > 0) {
169170
__vallocate(__n);
170171
__construct_at_end(__n, __x);
171172
}
173+
__guard.__complete();
172174
}
173175

174176
template <class _InputIterator,

libcxx/test/std/containers/sequences/vector/vector.cons/exceptions.pass.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ int main(int, char**) {
139139
check_new_delete_called();
140140
#endif // TEST_STD_VER >= 14
141141

142+
try { // Throw in vector(size_type, value_type, const allocator_type&) from the type
143+
int throw_after = 1;
144+
ThrowingT v(throw_after);
145+
std::vector<ThrowingT> vec(1, v, std::allocator<ThrowingT>());
146+
} catch (int) {
147+
}
148+
check_new_delete_called();
149+
142150
try { // Throw in vector(InputIterator, InputIterator) from input iterator
143151
std::vector<int> vec((Iterator<std::input_iterator_tag>()), Iterator<std::input_iterator_tag>(2));
144152
} catch (int) {

lld/ELF/Symbols.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class Symbol {
7575

7676
// The default copy constructor is deleted due to atomic flags. Define one for
7777
// places where no atomic is needed.
78-
Symbol(const Symbol &o) { memcpy(this, &o, sizeof(o)); }
78+
Symbol(const Symbol &o) { memcpy(static_cast<void *>(this), &o, sizeof(o)); }
7979

8080
protected:
8181
const char *nameData;

llvm/include/llvm/ADT/GenericCycleImpl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ bool GenericCycle<ContextT>::contains(const GenericCycle *C) const {
4747
template <typename ContextT>
4848
void GenericCycle<ContextT>::getExitBlocks(
4949
SmallVectorImpl<BlockT *> &TmpStorage) const {
50+
if (!ExitBlocksCache.empty()) {
51+
TmpStorage = ExitBlocksCache;
52+
return;
53+
}
54+
5055
TmpStorage.clear();
5156

5257
size_t NumExitBlocks = 0;
@@ -65,6 +70,7 @@ void GenericCycle<ContextT>::getExitBlocks(
6570

6671
TmpStorage.resize(NumExitBlocks);
6772
}
73+
ExitBlocksCache.append(TmpStorage.begin(), TmpStorage.end());
6874
}
6975

7076
template <typename ContextT>
@@ -298,6 +304,8 @@ void GenericCycleInfo<ContextT>::moveTopLevelCycleToNewParent(CycleT *NewParent,
298304
for (auto &It : BlockMapTopLevel)
299305
if (It.second == Child)
300306
It.second = NewParent;
307+
NewParent->clearCache();
308+
Child->clearCache();
301309
}
302310

303311
template <typename ContextT>
@@ -316,6 +324,7 @@ void GenericCycleInfo<ContextT>::addBlockToCycle(BlockT *Block, CycleT *Cycle) {
316324
}
317325

318326
BlockMapTopLevel.try_emplace(Block, Cycle);
327+
Cycle->clearCache();
319328
}
320329

321330
/// \brief Main function of the cycle info computations.

llvm/include/llvm/ADT/GenericCycleInfo.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,27 @@ template <typename ContextT> class GenericCycle {
7474
/// always have the same depth.
7575
unsigned Depth = 0;
7676

77+
/// Cache for the results of GetExitBlocks
78+
mutable SmallVector<BlockT *, 4> ExitBlocksCache;
79+
7780
void clear() {
7881
Entries.clear();
7982
Children.clear();
8083
Blocks.clear();
8184
Depth = 0;
8285
ParentCycle = nullptr;
86+
clearCache();
87+
}
88+
89+
void appendEntry(BlockT *Block) {
90+
Entries.push_back(Block);
91+
clearCache();
8392
}
8493

85-
void appendEntry(BlockT *Block) { Entries.push_back(Block); }
86-
void appendBlock(BlockT *Block) { Blocks.insert(Block); }
94+
void appendBlock(BlockT *Block) {
95+
Blocks.insert(Block);
96+
clearCache();
97+
}
8798

8899
GenericCycle(const GenericCycle &) = delete;
89100
GenericCycle &operator=(const GenericCycle &) = delete;
@@ -102,6 +113,11 @@ template <typename ContextT> class GenericCycle {
102113
return Entries;
103114
}
104115

116+
/// Clear the cache of the cycle.
117+
/// This should be run in all non-const function in GenericCycle
118+
/// and GenericCycleInfo.
119+
void clearCache() const { ExitBlocksCache.clear(); }
120+
105121
/// \brief Return whether \p Block is an entry block of the cycle.
106122
bool isEntry(const BlockT *Block) const {
107123
return is_contained(Entries, Block);
@@ -112,6 +128,7 @@ template <typename ContextT> class GenericCycle {
112128
assert(contains(Block));
113129
Entries.clear();
114130
Entries.push_back(Block);
131+
clearCache();
115132
}
116133

117134
/// \brief Return whether \p Block is contained in the cycle.

llvm/include/llvm/Analysis/TargetLibraryInfo.def

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,21 @@ TLI_DEFINE_ENUM_INTERNAL(erfl)
11401140
TLI_DEFINE_STRING_INTERNAL("erfl")
11411141
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)
11421142

1143+
/// double tgamma(double x);
1144+
TLI_DEFINE_ENUM_INTERNAL(tgamma)
1145+
TLI_DEFINE_STRING_INTERNAL("tgamma")
1146+
TLI_DEFINE_SIG_INTERNAL(Dbl, Dbl)
1147+
1148+
/// float tgammaf(float x);
1149+
TLI_DEFINE_ENUM_INTERNAL(tgammaf)
1150+
TLI_DEFINE_STRING_INTERNAL("tgammaf")
1151+
TLI_DEFINE_SIG_INTERNAL(Flt, Flt)
1152+
1153+
/// long double tgammal(long double x);
1154+
TLI_DEFINE_ENUM_INTERNAL(tgammal)
1155+
TLI_DEFINE_STRING_INTERNAL("tgammal")
1156+
TLI_DEFINE_SIG_INTERNAL(LDbl, LDbl)
1157+
11431158
/// int execl(const char *path, const char *arg, ...);
11441159
TLI_DEFINE_ENUM_INTERNAL(execl)
11451160
TLI_DEFINE_STRING_INTERNAL("execl")

llvm/include/llvm/CodeGen/LiveRegMatrix.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,16 @@ class LiveRegMatrix {
118118
/// the segment [Start, End).
119119
bool checkInterference(SlotIndex Start, SlotIndex End, MCRegister PhysReg);
120120

121+
/// Check for interference in the segment [Start, End) that may prevent
122+
/// assignment to PhysReg, like checkInterference. Returns a lane mask of
123+
/// which lanes of the physical register interfere in the segment [Start, End)
124+
/// of some other interval already assigned to PhysReg.
125+
///
126+
/// If this function returns LaneBitmask::getNone(), PhysReg is completely
127+
/// free at the segment [Start, End).
128+
LaneBitmask checkInterferenceLanes(SlotIndex Start, SlotIndex End,
129+
MCRegister PhysReg);
130+
121131
/// Assign VirtReg to PhysReg.
122132
/// This will mark VirtReg's live range as occupied in the LiveRegMatrix and
123133
/// update VirtRegMap. The live range is expected to be available in PhysReg.

llvm/include/llvm/ExecutionEngine/JITLink/MachO.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define LLVM_EXECUTIONENGINE_JITLINK_MACHO_H
1515

1616
#include "llvm/ExecutionEngine/JITLink/JITLink.h"
17+
#include "llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h"
1718

1819
namespace llvm {
1920
namespace jitlink {
@@ -33,6 +34,26 @@ createLinkGraphFromMachOObject(MemoryBufferRef ObjectBuffer);
3334
void link_MachO(std::unique_ptr<LinkGraph> G,
3435
std::unique_ptr<JITLinkContext> Ctx);
3536

37+
/// Get a pointer to the standard MachO data section (creates an empty
38+
/// section with RW- permissions and standard lifetime if one does not
39+
/// already exist).
40+
inline Section &getMachODefaultRWDataSection(LinkGraph &G) {
41+
if (auto *DataSec = G.findSectionByName(orc::MachODataDataSectionName))
42+
return *DataSec;
43+
return G.createSection(orc::MachODataDataSectionName,
44+
orc::MemProt::Read | orc::MemProt::Write);
45+
}
46+
47+
/// Get a pointer to the standard MachO text section (creates an empty
48+
/// section with R-X permissions and standard lifetime if one does not
49+
/// already exist).
50+
inline Section &getMachODefaultTextSection(LinkGraph &G) {
51+
if (auto *TextSec = G.findSectionByName(orc::MachOTextTextSectionName))
52+
return *TextSec;
53+
return G.createSection(orc::MachOTextTextSectionName,
54+
orc::MemProt::Read | orc::MemProt::Exec);
55+
}
56+
3657
} // end namespace jitlink
3758
} // end namespace llvm
3859

llvm/include/llvm/ExecutionEngine/Orc/Shared/MachOObjectFormat.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extern StringRef MachOSwift5TypesSectionName;
4949
extern StringRef MachOSwift5TypeRefSectionName;
5050
extern StringRef MachOSwift5FieldMetadataSectionName;
5151
extern StringRef MachOSwift5EntrySectionName;
52+
extern StringRef MachOTextTextSectionName;
5253
extern StringRef MachOThreadBSSSectionName;
5354
extern StringRef MachOThreadDataSectionName;
5455
extern StringRef MachOThreadVarsSectionName;

llvm/include/llvm/SandboxIR/Pass.h

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,29 @@
1212
#include "llvm/Support/ErrorHandling.h"
1313
#include "llvm/Support/raw_ostream.h"
1414

15-
namespace llvm::sandboxir {
15+
namespace llvm {
16+
17+
class ScalarEvolution;
18+
19+
namespace sandboxir {
1620

1721
class Function;
1822
class Region;
1923

24+
class Analyses {
25+
ScalarEvolution *SE = nullptr;
26+
27+
Analyses() = default;
28+
29+
public:
30+
Analyses(ScalarEvolution &SE) : SE(&SE) {}
31+
32+
public:
33+
ScalarEvolution &getScalarEvolution() const { return *SE; }
34+
/// For use by unit tests.
35+
static Analyses emptyForTesting() { return Analyses(); }
36+
};
37+
2038
/// The base class of a Sandbox IR Pass.
2139
class Pass {
2240
protected:
@@ -52,7 +70,7 @@ class FunctionPass : public Pass {
5270
/// \p Name can't contain any spaces or start with '-'.
5371
FunctionPass(StringRef Name) : Pass(Name) {}
5472
/// \Returns true if it modifies \p F.
55-
virtual bool runOnFunction(Function &F) = 0;
73+
virtual bool runOnFunction(Function &F, const Analyses &A) = 0;
5674
};
5775

5876
/// A pass that runs on a sandbox::Region.
@@ -61,9 +79,10 @@ class RegionPass : public Pass {
6179
/// \p Name can't contain any spaces or start with '-'.
6280
RegionPass(StringRef Name) : Pass(Name) {}
6381
/// \Returns true if it modifies \p R.
64-
virtual bool runOnRegion(Region &R) = 0;
82+
virtual bool runOnRegion(Region &R, const Analyses &A) = 0;
6583
};
6684

67-
} // namespace llvm::sandboxir
85+
} // namespace sandboxir
86+
} // namespace llvm
6887

6988
#endif // LLVM_SANDBOXIR_PASS_H

0 commit comments

Comments
 (0)