Skip to content

Commit 5290d60

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:63086d6aa0af into amd-gfx:b10fae670566
Local branch amd-gfx b10fae6 Merged main:134ae13adaff into amd-gfx:456d45aaa291 Remote branch main 63086d6 [mlir][Interfaces] `LoopLikeOpInterface`: Add `replaceWithAdditionalYields` (llvm#67121)
2 parents b10fae6 + 63086d6 commit 5290d60

Some content is hidden

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

41 files changed

+1514
-718
lines changed

clang/include/clang/Lex/Preprocessor.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class Preprocessor {
132132
llvm::unique_function<void(const clang::Token &)> OnToken;
133133
std::shared_ptr<PreprocessorOptions> PPOpts;
134134
DiagnosticsEngine *Diags;
135-
LangOptions &LangOpts;
135+
const LangOptions &LangOpts;
136136
const TargetInfo *Target = nullptr;
137137
const TargetInfo *AuxTarget = nullptr;
138138
FileManager &FileMgr;
@@ -1161,8 +1161,9 @@ class Preprocessor {
11611161

11621162
public:
11631163
Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
1164-
DiagnosticsEngine &diags, LangOptions &opts, SourceManager &SM,
1165-
HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
1164+
DiagnosticsEngine &diags, const LangOptions &LangOpts,
1165+
SourceManager &SM, HeaderSearch &Headers,
1166+
ModuleLoader &TheModuleLoader,
11661167
IdentifierInfoLookup *IILookup = nullptr,
11671168
bool OwnsHeaderSearch = false,
11681169
TranslationUnitKind TUKind = TU_Complete);

clang/lib/Lex/Preprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
7777
ExternalPreprocessorSource::~ExternalPreprocessorSource() = default;
7878

7979
Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
80-
DiagnosticsEngine &diags, LangOptions &opts,
80+
DiagnosticsEngine &diags, const LangOptions &opts,
8181
SourceManager &SM, HeaderSearch &Headers,
8282
ModuleLoader &TheModuleLoader,
8383
IdentifierInfoLookup *IILookup, bool OwnsHeaders,

compiler-rt/lib/asan/asan_globals.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,9 @@ static void ReportGlobal(const Global &g, const char *prefix) {
8787
g.module_name, g.has_dynamic_init, (void *)g.odr_indicator);
8888

8989
DataInfo info;
90-
Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info);
91-
if (info.line != 0) {
90+
if (Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info) && info.line != 0) {
9291
Report(" location: name=%s, %d\n", info.file, static_cast<int>(info.line));
93-
}
94-
else if (g.gcc_location != 0) {
92+
} else if (g.gcc_location != 0) {
9593
// Fallback to Global::gcc_location
9694
Report(" location: name=%s, %d\n", g.gcc_location->filename, g.gcc_location->line_no);
9795
}
@@ -301,9 +299,7 @@ void PrintGlobalNameIfASCII(InternalScopedString *str, const __asan_global &g) {
301299

302300
void PrintGlobalLocation(InternalScopedString *str, const __asan_global &g) {
303301
DataInfo info;
304-
Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info);
305-
306-
if (info.line != 0) {
302+
if (Symbolizer::GetOrInit()->SymbolizeData(g.beg, &info) && info.line != 0) {
307303
str->AppendF("%s:%d", info.file, static_cast<int>(info.line));
308304
} else if (g.gcc_location != 0) {
309305
// Fallback to Global::gcc_location

compiler-rt/lib/asan/asan_interceptors.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,12 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) {
224224
auto args = asanThreadArgRetval().GetArgs(self);
225225
t->ThreadStart(GetTid());
226226

227+
# if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
228+
SANITIZER_SOLARIS
227229
__sanitizer_sigset_t sigset;
228230
t->GetStartData(sigset);
229231
SetSigProcMask(&sigset, nullptr);
232+
# endif
230233

231234
thread_return_t retval = (*args.routine)(args.arg_retval);
232235
asanThreadArgRetval().Finish(self, retval);
@@ -249,7 +252,10 @@ INTERCEPTOR(int, pthread_create, void *thread, void *attr,
249252
u32 current_tid = GetCurrentTidOrInvalid();
250253

251254
__sanitizer_sigset_t sigset;
255+
# if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
256+
SANITIZER_SOLARIS
252257
ScopedBlockSignals block(&sigset);
258+
# endif
253259

254260
AsanThread *t = AsanThread::Create(sigset, current_tid, &stack, detached);
255261

compiler-rt/lib/asan/asan_posix.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,6 @@ void PlatformTSDDtor(void *tsd) {
110110
key.key = nullptr;
111111
// Make sure that signal handler can not see a stale current thread pointer.
112112
atomic_signal_fence(memory_order_seq_cst);
113-
// After this point it's unsafe to execute signal handlers which may be
114-
// instrumented.
115-
BlockSignals();
116113
AsanThread::TSDDtor(tsd);
117114
}
118115
#else
@@ -141,9 +138,12 @@ void PlatformTSDDtor(void *tsd) {
141138
CHECK_EQ(0, pthread_setspecific(tsd_key, tsd));
142139
return;
143140
}
141+
# if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
142+
SANITIZER_SOLARIS
144143
// After this point it's unsafe to execute signal handlers which may be
145-
// instrumented.
144+
// instrumented. It's probably not just a Linux issue.
146145
BlockSignals();
146+
# endif
147147
AsanThread::TSDDtor(tsd);
148148
}
149149
#endif

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,36 @@ const int FUTEX_WAKE_PRIVATE = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
156156

157157
namespace __sanitizer {
158158

159+
void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) {
160+
CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, set, oldset));
161+
}
162+
163+
void BlockSignals(__sanitizer_sigset_t *oldset) {
164+
__sanitizer_sigset_t set;
165+
internal_sigfillset(&set);
166+
# if SANITIZER_LINUX && !SANITIZER_ANDROID
167+
// Glibc uses SIGSETXID signal during setuid call. If this signal is blocked
168+
// on any thread, setuid call hangs.
169+
// See test/sanitizer_common/TestCases/Linux/setuid.c.
170+
internal_sigdelset(&set, 33);
171+
# endif
172+
# if SANITIZER_LINUX
173+
// Seccomp-BPF-sandboxed processes rely on SIGSYS to handle trapped syscalls.
174+
// If this signal is blocked, such calls cannot be handled and the process may
175+
// hang.
176+
internal_sigdelset(&set, 31);
177+
# endif
178+
SetSigProcMask(&set, oldset);
179+
}
180+
181+
ScopedBlockSignals::ScopedBlockSignals(__sanitizer_sigset_t *copy) {
182+
BlockSignals(&saved_);
183+
if (copy)
184+
internal_memcpy(copy, &saved_, sizeof(saved_));
185+
}
186+
187+
ScopedBlockSignals::~ScopedBlockSignals() { SetSigProcMask(&saved_, nullptr); }
188+
159189
# if SANITIZER_LINUX && defined(__x86_64__)
160190
# include "sanitizer_syscall_linux_x86_64.inc"
161191
# elif SANITIZER_LINUX && SANITIZER_RISCV64

compiler-rt/lib/sanitizer_common/sanitizer_linux.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,22 @@ void ReadProcMaps(ProcSelfMapsBuff *proc_maps);
4646

4747
// Syscall wrappers.
4848
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
49-
uptr internal_sigaltstack(const void *ss, void *oss);
49+
uptr internal_sigaltstack(const void* ss, void* oss);
50+
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
51+
__sanitizer_sigset_t *oldset);
52+
53+
void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset);
54+
void BlockSignals(__sanitizer_sigset_t *oldset = nullptr);
55+
struct ScopedBlockSignals {
56+
explicit ScopedBlockSignals(__sanitizer_sigset_t *copy);
57+
~ScopedBlockSignals();
58+
59+
ScopedBlockSignals &operator=(const ScopedBlockSignals &) = delete;
60+
ScopedBlockSignals(const ScopedBlockSignals &) = delete;
61+
62+
private:
63+
__sanitizer_sigset_t saved_;
64+
};
5065

5166
# if SANITIZER_GLIBC
5267
uptr internal_clock_gettime(__sanitizer_clockid_t clk_id, void *tp);

compiler-rt/lib/sanitizer_common/sanitizer_posix.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -406,35 +406,6 @@ uptr MmapNamed(void *addr, uptr length, int prot, int flags, const char *name) {
406406
return res;
407407
}
408408

409-
void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset) {
410-
CHECK_EQ(0, internal_sigprocmask(SIG_SETMASK, set, oldset));
411-
}
412-
413-
void BlockSignals(__sanitizer_sigset_t *oldset) {
414-
__sanitizer_sigset_t set;
415-
internal_sigfillset(&set);
416-
# if SANITIZER_LINUX && !SANITIZER_ANDROID
417-
// Glibc uses SIGSETXID signal during setuid call. If this signal is blocked
418-
// on any thread, setuid call hangs.
419-
// See test/sanitizer_common/TestCases/Linux/setuid.c.
420-
internal_sigdelset(&set, 33);
421-
# endif
422-
# if SANITIZER_LINUX
423-
// Seccomp-BPF-sandboxed processes rely on SIGSYS to handle trapped syscalls.
424-
// If this signal is blocked, such calls cannot be handled and the process may
425-
// hang.
426-
internal_sigdelset(&set, 31);
427-
# endif
428-
SetSigProcMask(&set, oldset);
429-
}
430-
431-
ScopedBlockSignals::ScopedBlockSignals(__sanitizer_sigset_t *copy) {
432-
BlockSignals(&saved_);
433-
if (copy)
434-
internal_memcpy(copy, &saved_, sizeof(saved_));
435-
}
436-
437-
ScopedBlockSignals::~ScopedBlockSignals() { SetSigProcMask(&saved_, nullptr); }
438409

439410
} // namespace __sanitizer
440411

compiler-rt/lib/sanitizer_common/sanitizer_posix.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ int internal_sigaction(int signum, const void *act, void *oldact);
9898
void internal_sigfillset(__sanitizer_sigset_t *set);
9999
void internal_sigemptyset(__sanitizer_sigset_t *set);
100100
bool internal_sigismember(__sanitizer_sigset_t *set, int signum);
101-
uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
102-
__sanitizer_sigset_t *oldset);
103101

104102
uptr internal_execve(const char *filename, char *const argv[],
105103
char *const envp[]);
@@ -126,19 +124,6 @@ void DecorateMapping(uptr addr, uptr size, const char *name);
126124
# define __sanitizer_dirsiz(dp) ((dp)->d_reclen)
127125
# endif
128126

129-
void SetSigProcMask(__sanitizer_sigset_t *set, __sanitizer_sigset_t *oldset);
130-
void BlockSignals(__sanitizer_sigset_t *oldset = nullptr);
131-
struct ScopedBlockSignals {
132-
explicit ScopedBlockSignals(__sanitizer_sigset_t *copy);
133-
~ScopedBlockSignals();
134-
135-
ScopedBlockSignals &operator=(const ScopedBlockSignals &) = delete;
136-
ScopedBlockSignals(const ScopedBlockSignals &) = delete;
137-
138-
private:
139-
__sanitizer_sigset_t saved_;
140-
};
141-
142127
} // namespace __sanitizer
143128

144129
#endif // SANITIZER_POSIX

compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ bool Symbolizer::SymbolizeData(uptr addr, DataInfo *info) {
117117
return true;
118118
}
119119
}
120-
return true;
120+
return false;
121121
}
122122

123123
bool Symbolizer::SymbolizeFrame(uptr addr, FrameInfo *info) {
@@ -133,7 +133,7 @@ bool Symbolizer::SymbolizeFrame(uptr addr, FrameInfo *info) {
133133
return true;
134134
}
135135
}
136-
return true;
136+
return false;
137137
}
138138

139139
bool Symbolizer::GetModuleNameAndOffsetForPC(uptr pc, const char **module_name,

compiler-rt/lib/sanitizer_common/symbolizer/sanitizer_symbolize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static llvm::symbolize::LLVMSymbolizer *getDefaultSymbolizer() {
2828
return Symbolizer;
2929
llvm::symbolize::LLVMSymbolizer::Options Opts;
3030
Opts.Demangle = Demangle;
31+
Opts.UntagAddresses = true;
3132
Symbolizer = new llvm::symbolize::LLVMSymbolizer(Opts);
3233
return Symbolizer;
3334
}

compiler-rt/test/sanitizer_common/TestCases/Linux/internal_symbolizer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// FIXME: Remove -hwasan-globals=0 when implemented.
2-
// RUN: %clangxx %s -o %t -g -mllvm -hwasan-globals=0 && %run %t 2>&1 | FileCheck %s
1+
// RUN: %clangxx %s -o %t -g && %run %t 2>&1 | FileCheck %s
32

43
// REQUIRES: internal_symbolizer
54

llvm/docs/TableGen/ProgRef.rst

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,11 +1831,18 @@ and non-0 as true.
18311831
result. A logical OR can be performed if all the arguments are either
18321832
0 or 1.
18331833

1834-
``!range([``\ *a*\ ``,``] *b*\ ``)``
1835-
This operator produces half-open range sequence ``[a : b)`` as ``list<int>``.
1836-
*a* is ``0`` by default. ``!range(4)`` is equivalent to ``!range(0, 4)``.
1837-
The result is `[0, 1, 2, 3]`.
1838-
If *a* ``>=`` *b*, then the result is `[]<list<int>>`.
1834+
``!range([``\ *start*\ ``,]`` *end*\ ``[, ``\ *step*\ ``])``
1835+
This operator produces half-open range sequence ``[start : end : step)`` as
1836+
``list<int>``. *start* is ``0`` and *step* is ``1`` by default. *step* can
1837+
be negative and cannot be 0. If *start* ``<`` *end* and *step* is negative,
1838+
or *start* ``>`` *end* and *step* is positive, the result is an empty list
1839+
``[]<list<int>>``. For example:
1840+
* ``!range(4)`` is equivalent to ``!range(0, 4, 1)`` and the result is
1841+
`[0, 1, 2, 3]`.
1842+
* ``!range(1, 4)`` is equivalent to ``!range(1, 4, 1)`` and the result is
1843+
`[1, 2, 3]`.
1844+
* The result of ``!range(0, 4, 2)`` is `[0, 2]`.
1845+
* The results of ``!range(0, 4, -1)`` and ``!range(4, 0, 1)`` are empty.
18391846

18401847
``!range(``\ *list*\ ``)``
18411848
Equivalent to ``!range(0, !size(list))``.

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476043
19+
#define LLVM_MAIN_REVISION 476051
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/TableGen/Record.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,6 @@ class BinOpInit : public OpInit, public FoldingSetNode {
911911
LISTREMOVE,
912912
LISTELEM,
913913
LISTSLICE,
914-
RANGE,
915914
RANGEC,
916915
STRCONCAT,
917916
INTERLEAVE,
@@ -988,6 +987,7 @@ class TernOpInit : public OpInit, public FoldingSetNode {
988987
FILTER,
989988
IF,
990989
DAG,
990+
RANGE,
991991
SUBSTR,
992992
FIND,
993993
SETDAGARG,

llvm/lib/TableGen/Record.cpp

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ Init *BinOpInit::Fold(Record *CurRec) const {
12871287
}
12881288
return ListInit::get(Args, TheList->getElementType());
12891289
}
1290-
case RANGE:
12911290
case RANGEC: {
12921291
auto *LHSi = dyn_cast<IntInit>(LHS);
12931292
auto *RHSi = dyn_cast<IntInit>(RHS);
@@ -1487,8 +1486,9 @@ std::string BinOpInit::getAsString() const {
14871486
case GT: Result = "!gt"; break;
14881487
case LISTCONCAT: Result = "!listconcat"; break;
14891488
case LISTSPLAT: Result = "!listsplat"; break;
1490-
case LISTREMOVE: Result = "!listremove"; break;
1491-
case RANGE: Result = "!range"; break;
1489+
case LISTREMOVE:
1490+
Result = "!listremove";
1491+
break;
14921492
case STRCONCAT: Result = "!strconcat"; break;
14931493
case INTERLEAVE: Result = "!interleave"; break;
14941494
case SETDAGOP: Result = "!setdagop"; break;
@@ -1704,6 +1704,34 @@ Init *TernOpInit::Fold(Record *CurRec) const {
17041704
break;
17051705
}
17061706

1707+
case RANGE: {
1708+
auto *LHSi = dyn_cast<IntInit>(LHS);
1709+
auto *MHSi = dyn_cast<IntInit>(MHS);
1710+
auto *RHSi = dyn_cast<IntInit>(RHS);
1711+
if (!LHSi || !MHSi || !RHSi)
1712+
break;
1713+
1714+
auto Start = LHSi->getValue();
1715+
auto End = MHSi->getValue();
1716+
auto Step = RHSi->getValue();
1717+
if (Step == 0)
1718+
PrintError(CurRec->getLoc(), "Step of !range can't be 0");
1719+
1720+
SmallVector<Init *, 8> Args;
1721+
if (Start < End && Step > 0) {
1722+
Args.reserve((End - Start) / Step);
1723+
for (auto I = Start; I < End; I += Step)
1724+
Args.push_back(IntInit::get(getRecordKeeper(), I));
1725+
} else if (Start > End && Step < 0) {
1726+
Args.reserve((Start - End) / -Step);
1727+
for (auto I = Start; I > End; I += Step)
1728+
Args.push_back(IntInit::get(getRecordKeeper(), I));
1729+
} else {
1730+
// Empty set
1731+
}
1732+
return ListInit::get(Args, LHSi->getType());
1733+
}
1734+
17071735
case SUBSTR: {
17081736
StringInit *LHSs = dyn_cast<StringInit>(LHS);
17091737
IntInit *MHSi = dyn_cast<IntInit>(MHS);
@@ -1823,6 +1851,9 @@ std::string TernOpInit::getAsString() const {
18231851
case FILTER: Result = "!filter"; UnquotedLHS = true; break;
18241852
case FOREACH: Result = "!foreach"; UnquotedLHS = true; break;
18251853
case IF: Result = "!if"; break;
1854+
case RANGE:
1855+
Result = "!range";
1856+
break;
18261857
case SUBST: Result = "!subst"; break;
18271858
case SUBSTR: Result = "!substr"; break;
18281859
case FIND: Result = "!find"; break;

0 commit comments

Comments
 (0)