Skip to content

Commit cb7b12c

Browse files
author
iclsrc
committed
Merge from 'master' to 'sycl-web'
2 parents 1fd087d + 429d792 commit cb7b12c

File tree

107 files changed

+1529
-605
lines changed

Some content is hidden

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

107 files changed

+1529
-605
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ def AlwaysInline : InheritableAttr {
682682

683683
def Artificial : InheritableAttr {
684684
let Spellings = [GCC<"artificial">];
685-
let Subjects = SubjectList<[InlineFunction], WarnDiag>;
685+
let Subjects = SubjectList<[InlineFunction]>;
686686
let Documentation = [ArtificialDocs];
687687
}
688688

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3502,7 +3502,7 @@ def warn_use_of_temp_in_invalid_state : Warning<
35023502
"invalid invocation of method '%0' on a temporary object while it is in the "
35033503
"'%1' state">, InGroup<Consumed>, DefaultIgnore;
35043504
def warn_attr_on_unconsumable_class : Warning<
3505-
"consumed analysis attribute is attached to member of class '%0' which isn't "
3505+
"consumed analysis attribute is attached to member of class %0 which isn't "
35063506
"marked as consumable">, InGroup<Consumed>, DefaultIgnore;
35073507
def warn_return_typestate_for_unconsumable_type : Warning<
35083508
"return state set for an unconsumable type '%0'">, InGroup<Consumed>,

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
10991099
AddBuiltinName(BuiltinName);
11001100
else
11011101
S.Diag(LiteralLoc, diag::warn_attribute_no_builtin_invalid_builtin_name)
1102-
<< BuiltinName << AL.getAttrName()->getName();
1102+
<< BuiltinName << AL;
11031103
}
11041104

11051105
// Repeating the same attribute is fine.
@@ -1110,7 +1110,7 @@ static void handleNoBuiltinAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
11101110
if (HasWildcard && Names.size() > 1)
11111111
S.Diag(D->getLocation(),
11121112
diag::err_attribute_no_builtin_wildcard_or_builtin_name)
1113-
<< AL.getAttrName()->getName();
1113+
<< AL;
11141114

11151115
if (D->hasAttr<NoBuiltinAttr>())
11161116
D->dropAttr<NoBuiltinAttr>();
@@ -1176,8 +1176,7 @@ static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD,
11761176

11771177
if (const CXXRecordDecl *RD = ThisType->getAsCXXRecordDecl()) {
11781178
if (!RD->hasAttr<ConsumableAttr>()) {
1179-
S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) <<
1180-
RD->getNameAsString();
1179+
S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) << RD;
11811180

11821181
return false;
11831182
}
@@ -3802,7 +3801,7 @@ void Sema::AddAlignValueAttr(Decl *D, const AttributeCommonInfo &CI, Expr *E) {
38023801
if (!T->isDependentType() && !T->isAnyPointerType() &&
38033802
!T->isReferenceType() && !T->isMemberPointerType()) {
38043803
Diag(AttrLoc, diag::warn_attribute_pointer_or_reference_only)
3805-
<< &TmpAttr /*TmpAttr.getName()*/ << T << D->getSourceRange();
3804+
<< &TmpAttr << T << D->getSourceRange();
38063805
return;
38073806
}
38083807

@@ -4059,8 +4058,7 @@ bool Sema::checkMSInheritanceAttrOnDefinition(
40594058

40604059
Diag(Range.getBegin(), diag::err_mismatched_ms_inheritance)
40614060
<< 0 /*definition*/;
4062-
Diag(RD->getDefinition()->getLocation(), diag::note_defined_here)
4063-
<< RD->getNameAsString();
4061+
Diag(RD->getDefinition()->getLocation(), diag::note_defined_here) << RD;
40644062
return true;
40654063
}
40664064

clang/test/Sema/no-builtin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy")))
1717

1818
/// Invalid builtin name.
1919
void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
20-
// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
20+
// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for 'no_builtin'}}
2121

2222
/// Can't use bare no_builtin with a named one.
2323
void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
24-
// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
24+
// expected-error@-1 {{empty 'no_builtin' cannot be composed with named ones}}
2525

2626
/// Can't attach attribute to a variable.
2727
int __attribute__((no_builtin)) variable;

clang/test/SemaCXX/member-pointer-ms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,11 @@ template <typename T> struct __multiple_inheritance A<T, T>;
239239
// expected-warning@-1 {{inheritance model ignored on partial specialization}}
240240
template <> struct __single_inheritance A<int, float>;
241241

242-
struct B {}; // expected-note {{B defined here}}
242+
struct B {}; // expected-note {{'B' defined here}}
243243
struct __multiple_inheritance B; // expected-error{{inheritance model does not match definition}}
244244

245245
struct __multiple_inheritance C {}; // expected-error{{inheritance model does not match definition}}
246-
// expected-note@-1 {{C defined here}}
246+
// expected-note@-1 {{'C' defined here}}
247247

248248
struct __virtual_inheritance D;
249249
struct D : virtual B {};

llvm/README.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,3 @@ documentation setup.
1515

1616
If you are writing a package for LLVM, see docs/Packaging.rst for our
1717
suggestions.
18-

llvm/examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ add_subdirectory(Fibonacci)
33
add_subdirectory(HowToUseJIT)
44
add_subdirectory(HowToUseLLJIT)
55
add_subdirectory(IRTransforms)
6-
add_subdirectory(LLJITExamples)
76
add_subdirectory(Kaleidoscope)
87
add_subdirectory(ModuleMaker)
8+
add_subdirectory(OrcV2Examples)
99
add_subdirectory(SpeculativeJIT)
1010
add_subdirectory(Bye)
1111
add_subdirectory(ThinLtoJIT)
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
//===-------- BasicOrcV2CBindings.c - Basic OrcV2 C Bindings Demo ---------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "llvm-c/Core.h"
10+
#include "llvm-c/Error.h"
11+
#include "llvm-c/Initialization.h"
12+
#include "llvm-c/Orc.h"
13+
#include "llvm-c/Support.h"
14+
#include "llvm-c/Target.h"
15+
16+
#include <stdio.h>
17+
18+
int handleError(LLVMErrorRef Err) {
19+
char *ErrMsg = LLVMGetErrorMessage(Err);
20+
fprintf(stderr, "Error: %s\n", ErrMsg);
21+
LLVMDisposeErrorMessage(ErrMsg);
22+
return 1;
23+
}
24+
25+
LLVMOrcThreadSafeModuleRef createDemoModule() {
26+
// Create a new ThreadSafeContext and underlying LLVMContext.
27+
LLVMOrcThreadSafeContextRef TSCtx = LLVMOrcCreateNewThreadSafeContext();
28+
29+
// Get a reference to the underlying LLVMContext.
30+
LLVMContextRef Ctx = LLVMOrcThreadSafeContextGetContext(TSCtx);
31+
32+
// Create a new LLVM module.
33+
LLVMModuleRef M = LLVMModuleCreateWithNameInContext("demo", Ctx);
34+
35+
// Add a "sum" function":
36+
// - Create the function type and function instance.
37+
LLVMTypeRef ParamTypes[] = {LLVMInt32Type(), LLVMInt32Type()};
38+
LLVMTypeRef SumFunctionType =
39+
LLVMFunctionType(LLVMInt32Type(), ParamTypes, 2, 0);
40+
LLVMValueRef SumFunction = LLVMAddFunction(M, "sum", SumFunctionType);
41+
42+
// - Add a basic block to the function.
43+
LLVMBasicBlockRef EntryBB = LLVMAppendBasicBlock(SumFunction, "entry");
44+
45+
// - Add an IR builder and point it at the end of the basic block.
46+
LLVMBuilderRef Builder = LLVMCreateBuilder();
47+
LLVMPositionBuilderAtEnd(Builder, EntryBB);
48+
49+
// - Get the two function arguments and use them co construct an "add"
50+
// instruction.
51+
LLVMValueRef SumArg0 = LLVMGetParam(SumFunction, 0);
52+
LLVMValueRef SumArg1 = LLVMGetParam(SumFunction, 1);
53+
LLVMValueRef Result = LLVMBuildAdd(Builder, SumArg0, SumArg1, "result");
54+
55+
// - Build the return instruction.
56+
LLVMBuildRet(Builder, Result);
57+
58+
// Our demo module is now complete. Wrap it and our ThreadSafeContext in a
59+
// ThreadSafeModule.
60+
LLVMOrcThreadSafeModuleRef TSM = LLVMOrcCreateNewThreadSafeModule(M, TSCtx);
61+
62+
// Dispose of our local ThreadSafeContext value. The underlying LLVMContext
63+
// will be kept alive by our ThreadSafeModule, TSM.
64+
LLVMOrcDisposeThreadSafeContext(TSCtx);
65+
66+
// Return the result.
67+
return TSM;
68+
}
69+
70+
int main(int argc, char *argv[]) {
71+
72+
int MainResult = 0;
73+
74+
// Parse command line arguments and initialize LLVM Core.
75+
LLVMParseCommandLineOptions(argc, (const char **)argv, "");
76+
LLVMInitializeCore(LLVMGetGlobalPassRegistry());
77+
78+
// Initialize native target codegen and asm printer.
79+
LLVMInitializeNativeTarget();
80+
LLVMInitializeNativeAsmPrinter();
81+
82+
// Create the JIT instance.
83+
LLVMOrcLLJITRef J;
84+
{
85+
LLVMErrorRef Err;
86+
if ((Err = LLVMOrcCreateDefaultLLJIT(&J))) {
87+
MainResult = handleError(Err);
88+
goto llvm_shutdown;
89+
}
90+
}
91+
92+
// Create our demo module.
93+
LLVMOrcThreadSafeModuleRef TSM = createDemoModule();
94+
95+
// Add our demo module to the JIT.
96+
{
97+
LLVMErrorRef Err;
98+
if ((Err = LLVMOrcLLJITAddLLVMIRModule(J, TSM))) {
99+
// If adding the ThreadSafeModule fails then we need to clean it up
100+
// ourselves. If adding it succeeds the JIT will manage the memory.
101+
LLVMOrcDisposeThreadSafeModule(TSM);
102+
MainResult = handleError(Err);
103+
goto jit_cleanup;
104+
}
105+
}
106+
107+
// Look up the address of our demo entry point.
108+
LLVMOrcJITTargetAddress SumAddr;
109+
{
110+
LLVMErrorRef Err;
111+
if ((Err = LLVMOrcLLJITLookup(J, &SumAddr, "sum"))) {
112+
MainResult = handleError(Err);
113+
goto jit_cleanup;
114+
}
115+
}
116+
117+
// If we made it here then everything succeeded. Execute our JIT'd code.
118+
int32_t (*Sum)(int32_t, int32_t) = (int32_t(*)(int32_t, int32_t))SumAddr;
119+
int32_t Result = Sum(1, 2);
120+
121+
// Print the result.
122+
printf("1 + 2 = %i\n", Result);
123+
124+
jit_cleanup:
125+
// Destroy our JIT instance. This will clean up any memory that the JIT has
126+
// taken ownership of. This operation is non-trivial (e.g. it may need to
127+
// JIT static destructors) and may also fail. In that case we want to render
128+
// the error to stderr, but not overwrite any existing return value.
129+
{
130+
LLVMErrorRef Err;
131+
if ((Err = LLVMOrcDisposeLLJIT(J))) {
132+
int NewFailureResult = handleError(Err);
133+
if (MainResult == 0)
134+
MainResult = NewFailureResult;
135+
}
136+
}
137+
138+
llvm_shutdown:
139+
// Shut down LLVM.
140+
LLVMShutdown();
141+
142+
return MainResult;
143+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set(LLVM_LINK_COMPONENTS
2+
Core
3+
ExecutionEngine
4+
IRReader
5+
JITLink
6+
MC
7+
OrcJIT
8+
Support
9+
Target
10+
nativecodegen
11+
)
12+
13+
add_llvm_example(BasicOrcV2CBindings
14+
BasicOrcV2CBindings.c
15+
)

llvm/examples/LLJITExamples/CMakeLists.txt renamed to llvm/examples/OrcV2Examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
add_subdirectory(BasicOrcV2CBindings)
12
add_subdirectory(LLJITDumpObjects)
23
add_subdirectory(LLJITWithObjectCache)
34
add_subdirectory(LLJITWithCustomObjectLinkingLayer)

llvm/include/llvm-c/Orc.h

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*===---------------- llvm-c/Orc.h - OrcV2 C bindings -----------*- C++ -*-===*\
2+
|* *|
3+
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4+
|* Exceptions. *|
5+
|* See https://llvm.org/LICENSE.txt for license information. *|
6+
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
7+
|* *|
8+
|*===----------------------------------------------------------------------===*|
9+
|* *|
10+
|* This header declares the C interface to libLLVMOrcJIT.a, which implements *|
11+
|* JIT compilation of LLVM IR. *|
12+
|* *|
13+
|* Many exotic languages can interoperate with C code but have a harder time *|
14+
|* with C++ due to name mangling. So in addition to C, this interface enables *|
15+
|* tools written in such languages. *|
16+
|* *|
17+
|* Note: This interface is experimental. It is *NOT* stable, and may be *|
18+
|* changed without warning. Only C API usage documentation is *|
19+
|* provided. See the C++ documentation for all higher level ORC API *|
20+
|* details. *|
21+
|* *|
22+
\*===----------------------------------------------------------------------===*/
23+
24+
#ifndef LLVM_C_ORC_H
25+
#define LLVM_C_ORC_H
26+
27+
#include "llvm-c/Error.h"
28+
#include "llvm-c/Types.h"
29+
30+
LLVM_C_EXTERN_C_BEGIN
31+
32+
typedef struct LLVMOrcOpaqueThreadSafeContext *LLVMOrcThreadSafeContextRef;
33+
typedef struct LLVMOrcOpaqueThreadSafeModule *LLVMOrcThreadSafeModuleRef;
34+
typedef struct LLVMOrcOpaqueLLJIT *LLVMOrcLLJITRef;
35+
typedef uint64_t LLVMOrcJITTargetAddress;
36+
37+
/**
38+
* Create a ThreadSafeContext containing a new LLVMContext.
39+
*/
40+
LLVMOrcThreadSafeContextRef LLVMOrcCreateNewThreadSafeContext(void);
41+
42+
/**
43+
* Get a reference to the wrapped LLVMContext.
44+
*/
45+
LLVMContextRef
46+
LLVMOrcThreadSafeContextGetContext(LLVMOrcThreadSafeContextRef TSCtx);
47+
48+
/**
49+
* Dispose of a ThreadSafeContext.
50+
*/
51+
void LLVMOrcDisposeThreadSafeContext(LLVMOrcThreadSafeContextRef TSCtx);
52+
53+
/**
54+
* Create a ThreadSafeModule wrapper around the given LLVM module. This takes
55+
* ownership of the M argument which should not be disposed of or referenced
56+
* after this function returns.
57+
*/
58+
LLVMOrcThreadSafeModuleRef
59+
LLVMOrcCreateNewThreadSafeModule(LLVMModuleRef M,
60+
LLVMOrcThreadSafeContextRef TSCtx);
61+
62+
/**
63+
* Dispose of a ThreadSafeModule.
64+
*/
65+
void LLVMOrcDisposeThreadSafeModule(LLVMOrcThreadSafeModuleRef TSM);
66+
67+
/**
68+
* Create an LLJIT instance using all default values.
69+
*/
70+
LLVMErrorRef LLVMOrcCreateDefaultLLJIT(LLVMOrcLLJITRef *Result);
71+
72+
/**
73+
* Dispose of an LLJIT instance.
74+
*/
75+
LLVMErrorRef LLVMOrcDisposeLLJIT(LLVMOrcLLJITRef J);
76+
77+
/**
78+
* Add an IR module to the main JITDylib of the given LLJIT instance. This
79+
* operation takes ownership of the TSM argument which should not be disposed
80+
* of or referenced once this function returns.
81+
*/
82+
LLVMErrorRef LLVMOrcLLJITAddLLVMIRModule(LLVMOrcLLJITRef J,
83+
LLVMOrcThreadSafeModuleRef TSM);
84+
/**
85+
* Look up the given symbol in the main JITDylib of the given LLJIT instance.
86+
*
87+
* This operation does not take ownership of the Name argument.
88+
*/
89+
LLVMErrorRef LLVMOrcLLJITLookup(LLVMOrcLLJITRef J,
90+
LLVMOrcJITTargetAddress *Result,
91+
const char *Name);
92+
93+
LLVM_C_EXTERN_C_END
94+
95+
#endif /* LLVM_C_ORC_H */

0 commit comments

Comments
 (0)