Skip to content

Commit 5cc5018

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW29) #4092
LLVM: llvm/llvm-project@6b16683 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@c8aaa5f
2 parents 226ed8b + 8cc1c7f commit 5cc5018

File tree

1,758 files changed

+119638
-44737
lines changed

Some content is hidden

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

1,758 files changed

+119638
-44737
lines changed

clang-tools-extra/clang-doc/HTMLGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ genHTML(const Index &Index, StringRef InfoPath, bool IsOutermostList) {
579579
if (!Index.JumpToSection)
580580
SpanBody->Children.emplace_back(genReference(Index, InfoPath));
581581
else
582-
SpanBody->Children.emplace_back(genReference(
583-
Index, InfoPath, StringRef{Index.JumpToSection.getValue()}));
582+
SpanBody->Children.emplace_back(
583+
genReference(Index, InfoPath, Index.JumpToSection.getValue().str()));
584584
}
585585
if (Index.Children.empty())
586586
return Out;

clang-tools-extra/clangd/JSONTransport.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ bool JSONTransport::readStandardMessage(std::string &JSON) {
230230
return false;
231231
InMirror << Line;
232232

233-
llvm::StringRef LineRef(Line);
233+
llvm::StringRef LineRef = Line;
234234

235235
// We allow comments in headers. Technically this isn't part
236236

@@ -298,7 +298,7 @@ bool JSONTransport::readDelimitedMessage(std::string &JSON) {
298298
llvm::SmallString<128> Line;
299299
while (readLine(In, Line)) {
300300
InMirror << Line;
301-
auto LineRef = llvm::StringRef(Line).trim();
301+
auto LineRef = Line.str().trim();
302302
if (LineRef.startswith("#")) // comment
303303
continue;
304304

clang-tools-extra/clangd/QueryDriverDatabase.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ extractSystemIncludesAndTarget(llvm::SmallString<128> Driver,
175175
auto CleanUp = llvm::make_scope_exit(
176176
[&StdErrPath]() { llvm::sys::fs::remove(StdErrPath); });
177177

178-
llvm::Optional<llvm::StringRef> Redirects[] = {
179-
{""}, {""}, llvm::StringRef(StdErrPath)};
178+
llvm::Optional<llvm::StringRef> Redirects[] = {{""}, {""}, StdErrPath.str()};
180179

181180
llvm::SmallVector<llvm::StringRef> Args = {Driver, "-E", "-x",
182181
Lang, "-", "-v"};

clang-tools-extra/clangd/Selection.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,7 @@ llvm::SmallString<256> abbreviatedString(DynTypedNode N,
771771
}
772772
auto Pos = Result.find('\n');
773773
if (Pos != llvm::StringRef::npos) {
774-
bool MoreText =
775-
!llvm::all_of(llvm::StringRef(Result).drop_front(Pos), llvm::isSpace);
774+
bool MoreText = !llvm::all_of(Result.str().drop_front(Pos), llvm::isSpace);
776775
Result.resize(Pos);
777776
if (MoreText)
778777
Result.append("");

clang-tools-extra/clangd/index/dex/Dex.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ namespace clangd {
3434
namespace dex {
3535

3636
/// In-memory Dex trigram-based index implementation.
37-
// FIXME(kbobyrev): Introduce serialization and deserialization of the symbol
38-
// index so that it can be loaded from the disk. Since static index is not
39-
// changed frequently, it's safe to assume that it has to be built only once
40-
// (when the clangd process starts). Therefore, it can be easier to store built
41-
// index on disk and then load it if available.
4237
class Dex : public SymbolIndex {
4338
public:
4439
// All data must outlive this index.

clang-tools-extra/clangd/support/Threading.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "llvm/ADT/ScopeExit.h"
44
#include "llvm/Support/FormatVariadic.h"
55
#include "llvm/Support/Threading.h"
6+
#include "llvm/Support/thread.h"
67
#include <atomic>
78
#include <thread>
89
#ifdef __USE_POSIX
@@ -95,8 +96,10 @@ void AsyncTaskRunner::runAsync(const llvm::Twine &Name,
9596
};
9697

9798
// Ensure our worker threads have big enough stacks to run clang.
98-
llvm::llvm_execute_on_thread_async(std::move(Task),
99-
/*clang::DesiredStackSize*/ 8 << 20);
99+
llvm::thread Thread(
100+
/*clang::DesiredStackSize*/ llvm::Optional<unsigned>(8 << 20),
101+
std::move(Task));
102+
Thread.detach();
100103
}
101104

102105
Deadline timeoutSeconds(llvm::Optional<double> Seconds) {

clang/docs/AddressSanitizer.rst

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ following types of bugs:
1414

1515
* Out-of-bounds accesses to heap, stack and globals
1616
* Use-after-free
17-
* Use-after-return (runtime flag `ASAN_OPTIONS=detect_stack_use_after_return=1`)
18-
* Use-after-scope (clang flag `-fsanitize-address-use-after-scope`)
17+
* Use-after-return (clang flag ``-fsanitize-address-use-after-return=(never|runtime|always)`` default: ``runtime``)
18+
* Enable ``runtime`` with: ``ASAN_OPTIONS=detect_stack_use_after_return=1``
19+
* Use-after-scope (clang flag ``-fsanitize-address-use-after-scope``)
1920
* Double-free, invalid free
2021
* Memory leaks (experimental)
2122

@@ -136,6 +137,26 @@ you should set environment variable
136137

137138
Note that this option is not supported on macOS.
138139

140+
Stack Use After Return (UAR)
141+
----------------------------
142+
143+
AddressSanitizer can optionally detect stack use after return problems.
144+
This is available by default, or explicitly
145+
(``-fsanitize-address-use-after-return=runtime``).
146+
To enable this check at runtime, set the environment variable
147+
``ASAN_OPTIONS=detect_stack_use_after_return=1``.
148+
149+
Enabling this check (``-fsanitize-address-use-after-return=always``) will
150+
reduce code size. The code size may be reduced further by completely
151+
eliminating this check (``-fsanitize-address-use-after-return=never``).
152+
153+
To summarize: ``-fsanitize-address-use-after-return=<mode>``
154+
* ``never``: Completely disables detection of UAR errors (reduces code size).
155+
* ``runtime``: Adds the code for detection, but must be enabled via the
156+
runtime environment (``ASAN_OPTIONS=detect_stack_use_after_return=1``).
157+
* ``always``: Enables detection of UAR errors in all cases. (reduces code
158+
size, but not as much as ``never``).
159+
139160
Memory leak detection
140161
---------------------
141162

clang/docs/DataFlowSanitizer.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,44 @@ the correct labels are propagated.
191191
return 0;
192192
}
193193

194+
Origin Tracking
195+
===============
196+
197+
DataFlowSanitizer can track origins of labeled values. This feature is enabled by
198+
``-mllvm -dfsan-track-origins=1``. For example,
199+
200+
.. code-block:: console
201+
202+
% cat test.cc
203+
#include <sanitizer/dfsan_interface.h>
204+
#include <stdio.h>
205+
206+
int main(int argc, char** argv) {
207+
int i = 0;
208+
dfsan_set_label(i_label, &i, sizeof(i));
209+
int j = i + 1;
210+
dfsan_print_origin_trace(&j, "A flow from i to j");
211+
return 0;
212+
}
213+
214+
% clang++ -fsanitize=dataflow -mllvm -dfsan-track-origins=1 -fno-omit-frame-pointer -g -O2 test.cc
215+
% ./a.out
216+
Taint value 0x1 (at 0x7ffd42bf415c) origin tracking (A flow from i to j)
217+
Origin value: 0x13900001, Taint value was stored to memory at
218+
#0 0x55676db85a62 in main test.cc:7:7
219+
#1 0x7f0083611bbc in __libc_start_main libc-start.c:285
220+
221+
Origin value: 0x9e00001, Taint value was created at
222+
#0 0x55676db85a08 in main test.cc:6:3
223+
#1 0x7f0083611bbc in __libc_start_main libc-start.c:285
224+
225+
By ``-mllvm -dfsan-track-origins=1`` DataFlowSanitizer collects only
226+
intermediate stores a labeled value went through. Origin tracking slows down
227+
program execution by a factor of 2x on top of the usual DataFlowSanitizer
228+
slowdown and increases memory overhead by 1x. By ``-mllvm -dfsan-track-origins=2``
229+
DataFlowSanitizer also collects intermediate loads a labeled value went through.
230+
This mode slows down program execution by a factor of 4x.
231+
194232
Current status
195233
==============
196234

clang/docs/LibASTMatchersTutorial.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,12 @@ CMakeLists.txt should have the following contents:
105105
)
106106
target_link_libraries(loop-convert
107107
PRIVATE
108-
clangTooling
109-
clangBasic
108+
clangAST
110109
clangASTMatchers
110+
clangBasic
111+
clangFrontend
112+
clangSerialization
113+
clangTooling
111114
)
112115

113116
With that done, Ninja will be able to compile our tool. Let's give it

clang/docs/UsersManual.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3744,6 +3744,8 @@ Execute ``clang-cl /?`` to see a list of supported options:
37443744
Enable linker dead stripping of globals in AddressSanitizer
37453745
-fsanitize-address-poison-custom-array-cookie
37463746
Enable poisoning array cookies when using custom operator new[] in AddressSanitizer
3747+
-fsanitize-address-use-after-return=<mode>
3748+
Select the mode of detecting stack use-after-return in AddressSanitizer: never | runtime (default) | always
37473749
-fsanitize-address-use-after-scope
37483750
Enable use-after-scope detection in AddressSanitizer
37493751
-fsanitize-address-use-odr-indicator

clang/include/clang-c/Index.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
3434
*/
3535
#define CINDEX_VERSION_MAJOR 0
36-
#define CINDEX_VERSION_MINOR 61
36+
#define CINDEX_VERSION_MINOR 62
3737

3838
#define CINDEX_VERSION_ENCODE(major, minor) (((major)*10000) + ((minor)*1))
3939

@@ -3432,6 +3432,7 @@ enum CXCallingConv {
34323432
CXCallingConv_PreserveMost = 14,
34333433
CXCallingConv_PreserveAll = 15,
34343434
CXCallingConv_AArch64VectorCall = 16,
3435+
CXCallingConv_SwiftAsync = 17,
34353436

34363437
CXCallingConv_Invalid = 100,
34373438
CXCallingConv_Unexposed = 200

clang/include/clang/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,6 +1495,9 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
14951495
NonParmVarDeclBits.EscapingByref = true;
14961496
}
14971497

1498+
/// Determines if this variable's alignment is dependent.
1499+
bool hasDependentAlignment() const;
1500+
14981501
/// Retrieve the variable declaration from which this variable could
14991502
/// be instantiated, if it is an instantiation (rather than a non-template).
15001503
VarDecl *getTemplateInstantiationPattern() const;

clang/include/clang/Analysis/AnalysisDeclContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ class AnalysisDeclContext {
200200
/// \returns Whether the root namespace of \p D is the \c std C++ namespace.
201201
static bool isInStdNamespace(const Decl *D);
202202

203+
static std::string getFunctionName(const Decl *D);
204+
203205
private:
204206
std::unique_ptr<ManagedAnalysis> &getAnalysisImpl(const void *tag);
205207

clang/include/clang/Basic/Attr.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3111,6 +3111,11 @@ def SwiftCall : DeclOrTypeAttr {
31113111
let Documentation = [SwiftCallDocs];
31123112
}
31133113

3114+
def SwiftAsyncCall : DeclOrTypeAttr {
3115+
let Spellings = [Clang<"swiftasynccall">];
3116+
let Documentation = [SwiftAsyncCallDocs];
3117+
}
3118+
31143119
def SwiftContext : ParameterABIAttr {
31153120
let Spellings = [Clang<"swift_context">];
31163121
let Documentation = [SwiftContextDocs];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,7 +5814,8 @@ def SwiftContextDocs : Documentation {
58145814
let Category = DocCatVariable;
58155815
let Content = [{
58165816
The ``swift_context`` attribute marks a parameter of a ``swiftcall``
5817-
function as having the special context-parameter ABI treatment.
5817+
or ``swiftasynccall`` function as having the special context-parameter
5818+
ABI treatment.
58185819

58195820
This treatment generally passes the context value in a special register
58205821
which is normally callee-preserved.
@@ -5827,14 +5828,39 @@ A context parameter must have pointer or reference type.
58275828
}];
58285829
}
58295830

5831+
def SwiftAsyncCallDocs : Documentation {
5832+
let Category = DocCatVariable;
5833+
let Content = [{
5834+
The ``swiftasynccall`` attribute indicates that a function is
5835+
compatible with the low-level conventions of Swift async functions,
5836+
provided it declares the right formal arguments.
5837+
5838+
In most respects, this is similar to the ``swiftcall`` attribute, except for
5839+
the following:
5840+
- A parameter may be marked ``swift_async_context``, ``swift_context``
5841+
or ``swift_indirect_result`` (with the same restrictions on parameter
5842+
ordering as ``swiftcall``) but the parameter attribute
5843+
``swift_error_result`` is not permitted.
5844+
- A ``swiftasynccall`` function must have return type ``void``.
5845+
- Within a ``swiftasynccall`` function, a call to a ``swiftasynccall``
5846+
function that is the immediate operand of a ``return`` statement is
5847+
guaranteed to be performed as a tail call. This syntax is allowed even
5848+
in C as an extension (a call to a void-returning function cannot be a
5849+
return operand in standard C). If something in the calling function would
5850+
semantically be performed after a guaranteed tail call, such as the
5851+
non-trivial destruction of a local variable or temporary,
5852+
then the program is ill-formed.
5853+
}];
5854+
}
5855+
58305856
def SwiftAsyncContextDocs : Documentation {
58315857
let Category = DocCatVariable;
58325858
let Content = [{
5833-
The ``swift_async_context`` attribute marks a parameter as having the
5834-
special asynchronous context-parameter ABI treatment.
5859+
The ``swift_async_context`` attribute marks a parameter of a ``swiftasynccall``
5860+
function as having the special asynchronous context-parameter ABI treatment.
58355861

5836-
This treatment generally passes the context value in a special register
5837-
which is normally callee-preserved.
5862+
If the function is not ``swiftasynccall``, this attribute only generates
5863+
extended frame information.
58385864

58395865
A context parameter must have pointer or reference type.
58405866
}];
@@ -5879,7 +5905,8 @@ def SwiftIndirectResultDocs : Documentation {
58795905
let Category = DocCatVariable;
58805906
let Content = [{
58815907
The ``swift_indirect_result`` attribute marks a parameter of a ``swiftcall``
5882-
function as having the special indirect-result ABI treatment.
5908+
or ``swiftasynccall`` function as having the special indirect-result ABI
5909+
treatment.
58835910

58845911
This treatment gives the parameter the target's normal indirect-result
58855912
ABI treatment, which may involve passing it differently from an ordinary

clang/include/clang/Basic/BuiltinsPPC.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")
5555
BUILTIN(__builtin_ppc_fetch_and_orlp, "ULiULiD*ULi", "")
5656
BUILTIN(__builtin_ppc_fetch_and_swap, "UiUiD*Ui", "")
5757
BUILTIN(__builtin_ppc_fetch_and_swaplp, "ULiULiD*ULi", "")
58+
BUILTIN(__builtin_ppc_ldarx, "LiLiD*", "")
59+
BUILTIN(__builtin_ppc_lwarx, "iiD*", "")
60+
BUILTIN(__builtin_ppc_stdcx, "iLiD*Li", "")
61+
BUILTIN(__builtin_ppc_stwcx, "iiD*i", "")
5862

5963
BUILTIN(__builtin_ppc_get_timebase, "ULLi", "n")
6064

clang/include/clang/Basic/BuiltinsWebAssembly.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ TARGET_BUILTIN(__builtin_wasm_narrow_u_i16x8_i32x4, "V8UsV4iV4i", "nc", "simd128
192192
TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
193193
TARGET_BUILTIN(__builtin_wasm_trunc_sat_zero_u_f64x2_i32x4, "V4UiV2d", "nc", "simd128")
194194
TARGET_BUILTIN(__builtin_wasm_demote_zero_f64x2_f32x4, "V4fV2d", "nc", "simd128")
195-
TARGET_BUILTIN(__builtin_wasm_promote_low_f32x4_f64x2, "V2dV4f", "nc", "simd128")
196195

197196
TARGET_BUILTIN(__builtin_wasm_load32_zero, "V4iiC*", "n", "simd128")
198197
TARGET_BUILTIN(__builtin_wasm_load64_zero, "V2LLiLLiC*", "n", "simd128")

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3193,7 +3193,8 @@ def warn_nsdictionary_duplicate_key : Warning<
31933193
def note_nsdictionary_duplicate_key_here : Note<
31943194
"previous equal key is here">;
31953195
def err_swift_param_attr_not_swiftcall : Error<
3196-
"'%0' parameter can only be used with swiftcall calling convention">;
3196+
"'%0' parameter can only be used with swiftcall%select{ or swiftasynccall|}1 "
3197+
"calling convention%select{|s}1">;
31973198
def err_swift_indirect_result_not_first : Error<
31983199
"'swift_indirect_result' parameters must be first parameters of function">;
31993200
def err_swift_error_result_not_after_swift_context : Error<

clang/include/clang/Basic/Features.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ FEATURE(memory_sanitizer,
9393
FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
9494
FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
9595
FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
96+
FEATURE(swiftasynccc,
97+
PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) ==
98+
clang::TargetInfo::CCCR_OK)
9699
// Objective-C features
97100
FEATURE(objc_arr, LangOpts.ObjCAutoRefCount) // FIXME: REMOVE?
98101
FEATURE(objc_arc, LangOpts.ObjCAutoRefCount)

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
5656
/// of a pointer to one of these classes.
5757
enum { IdentifierInfoAlignment = 8 };
5858

59-
static constexpr int ObjCOrBuiltinIDBits = 15;
59+
static constexpr int ObjCOrBuiltinIDBits = 16;
6060

6161
/// One of these records is kept for each identifier that
6262
/// is lexed. This contains information about whether the token was \#define'd,

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ BENIGN_LANGOPT(ModulesDebugInfo , 1, 0, "Modules debug info")
281281
BENIGN_LANGOPT(ElideConstructors , 1, 1, "C++ copy constructor elision")
282282
BENIGN_LANGOPT(DumpRecordLayouts , 1, 0, "dumping the layout of IRgen'd records")
283283
BENIGN_LANGOPT(DumpRecordLayoutsSimple , 1, 0, "dumping the layout of IRgen'd records in a simple form")
284+
BENIGN_LANGOPT(DumpRecordLayoutsCanonical , 1, 0, "dumping the AST layout of records using canonical field types")
284285
BENIGN_LANGOPT(DumpRecordLayoutsComplete , 1, 0, "dumping the AST layout of all complete records")
285286
BENIGN_LANGOPT(DumpVTableLayouts , 1, 0, "dumping the layouts of emitted vtables")
286287
LANGOPT(NoConstantCFStrings , 1, 0, "no constant CoreFoundation strings")

clang/include/clang/Basic/Specifiers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ namespace clang {
266266
CC_SpirFunction, // default for OpenCL functions on SPIR target
267267
CC_OpenCLKernel, // inferred for OpenCL kernels
268268
CC_Swift, // __attribute__((swiftcall))
269+
CC_SwiftAsync, // __attribute__((swiftasynccall))
269270
CC_PreserveMost, // __attribute__((preserve_most))
270271
CC_PreserveAll, // __attribute__((preserve_all))
271272
CC_AArch64VectorCall, // __attribute__((aarch64_vector_pcs))
@@ -284,6 +285,7 @@ namespace clang {
284285
case CC_SpirFunction:
285286
case CC_OpenCLKernel:
286287
case CC_Swift:
288+
case CC_SwiftAsync:
287289
return false;
288290
default:
289291
return true;

0 commit comments

Comments
 (0)