Skip to content

Commit eecf9f2

Browse files
authored
merge main into amd-staging (#749)
2 parents 3f26c0c + b6fe2a0 commit eecf9f2

File tree

47 files changed

+20836
-23093
lines changed

Some content is hidden

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

47 files changed

+20836
-23093
lines changed

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
6767
DiagnosticsEngine *Diags = nullptr,
6868
bool DefaultDiagColor = true);
6969

70-
unsigned getOptimizationLevel(llvm::opt::ArgList &Args, InputKind IK,
70+
unsigned getOptimizationLevel(const llvm::opt::ArgList &Args, InputKind IK,
7171
DiagnosticsEngine &Diags);
7272

73-
unsigned getOptimizationLevelSize(llvm::opt::ArgList &Args);
73+
unsigned getOptimizationLevelSize(const llvm::opt::ArgList &Args);
7474

7575
/// The base class of CompilerInvocation. It keeps individual option objects
7676
/// behind reference-counted pointers, which is useful for clients that want to

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "clang/Driver/ToolChain.h"
3636
#include "clang/Driver/Util.h"
3737
#include "clang/Driver/XRayArgs.h"
38+
#include "clang/Frontend/CompilerInvocation.h"
3839
#include "clang/Options/Options.h"
3940
#include "llvm/ADT/STLExtras.h"
4041
#include "llvm/ADT/SmallSet.h"
@@ -1121,27 +1122,14 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
11211122
CmdArgs.push_back(
11221123
Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash + "mcpu=" + CPU));
11231124

1124-
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
1125-
// The optimization level matches
1126-
// CompilerInvocation.cpp:getOptimizationLevel().
1127-
StringRef OOpt;
1128-
if (A->getOption().matches(options::OPT_O4) ||
1129-
A->getOption().matches(options::OPT_Ofast))
1130-
OOpt = "3";
1131-
else if (A->getOption().matches(options::OPT_O)) {
1132-
OOpt = A->getValue();
1133-
if (OOpt == "g")
1134-
OOpt = "1";
1135-
else if (OOpt == "s" || OOpt == "z")
1136-
OOpt = "2";
1137-
} else if (A->getOption().matches(options::OPT_O0))
1138-
OOpt = "0";
1139-
if (!OOpt.empty()) {
1125+
if (Args.getLastArg(options::OPT_O_Group)) {
1126+
unsigned OptimizationLevel =
1127+
getOptimizationLevel(Args, InputKind(), D.getDiags());
1128+
CmdArgs.push_back(Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash +
1129+
"O" + Twine(OptimizationLevel)));
1130+
if (IsAMDGCN)
11401131
CmdArgs.push_back(
1141-
Args.MakeArgString(Twine(PluginOptPrefix) + ExtraDash + "O" + OOpt));
1142-
if (IsAMDGCN)
1143-
CmdArgs.push_back(Args.MakeArgString(Twine("--lto-CGO") + OOpt));
1144-
}
1132+
Args.MakeArgString(Twine("--lto-CGO") + Twine(OptimizationLevel)));
11451133
}
11461134

11471135
if (Args.hasArg(options::OPT_gsplit_dwarf)) {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,7 +2673,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
26732673
return Diags->getNumErrors() == NumErrorsBefore;
26742674
}
26752675

2676-
unsigned clang::getOptimizationLevel(ArgList &Args, InputKind IK,
2676+
unsigned clang::getOptimizationLevel(const ArgList &Args, InputKind IK,
26772677
DiagnosticsEngine &Diags) {
26782678
unsigned DefaultOpt = 0;
26792679
if ((IK.getLanguage() == Language::OpenCL ||
@@ -2712,7 +2712,7 @@ unsigned clang::getOptimizationLevel(ArgList &Args, InputKind IK,
27122712
return DefaultOpt;
27132713
}
27142714

2715-
unsigned clang::getOptimizationLevelSize(ArgList &Args) {
2715+
unsigned clang::getOptimizationLevelSize(const ArgList &Args) {
27162716
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
27172717
if (A->getOption().matches(options::OPT_O)) {
27182718
switch (A->getValue()[0]) {

libclc/opencl/include/clc/opencl/synchronization/utils.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
#include <clc/mem_fence/clc_mem_semantic.h>
1414
#include <clc/opencl/synchronization/cl_mem_fence_flags.h>
1515

16-
_CLC_INLINE int __opencl_get_memory_scope(cl_mem_fence_flags flag) {
17-
int memory_scope = 0;
16+
static _CLC_INLINE int __opencl_get_memory_scope(cl_mem_fence_flags flag) {
1817
if (flag & CLK_GLOBAL_MEM_FENCE)
19-
memory_scope |= __MEMORY_SCOPE_DEVICE;
18+
return __MEMORY_SCOPE_DEVICE;
2019
if (flag & CLK_LOCAL_MEM_FENCE)
21-
memory_scope |= __MEMORY_SCOPE_WRKGRP;
22-
return memory_scope;
20+
return __MEMORY_SCOPE_WRKGRP;
21+
return __MEMORY_SCOPE_SINGLE;
2322
}
2423

25-
_CLC_INLINE __CLC_MemorySemantics
24+
static _CLC_INLINE __CLC_MemorySemantics
2625
__opencl_get_memory_semantics(cl_mem_fence_flags flag) {
2726
if ((flag & CLK_LOCAL_MEM_FENCE) && (flag & CLK_GLOBAL_MEM_FENCE))
2827
return __CLC_MEMORY_LOCAL | __CLC_MEMORY_GLOBAL;

llvm/docs/LangRef.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31722,3 +31722,55 @@ Semantics:
3172231722

3172331723
The '``llvm.preserve.struct.access.index``' intrinsic produces the same result
3172431724
as a getelementptr with base ``base`` and access operands ``{0, gep_index}``.
31725+
31726+
'``llvm.protected.field.ptr``' Intrinsic
31727+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31728+
31729+
Syntax:
31730+
"""""""
31731+
31732+
::
31733+
31734+
declare ptr @llvm.protected.field.ptr(ptr ptr, i64 disc, i1 use_hw_encoding)
31735+
31736+
Overview:
31737+
"""""""""
31738+
31739+
The '``llvm.protected.field.ptr``' intrinsic returns a pointer to the
31740+
storage location of a pointer that has special properties as described
31741+
below.
31742+
31743+
Arguments:
31744+
""""""""""
31745+
31746+
The first argument is the pointer specifying the location to store the
31747+
pointer. The second argument is the discriminator, which is used as an
31748+
input for the pointer encoding. The third argument specifies whether to
31749+
use a target-specific mechanism to encode the pointer.
31750+
31751+
Semantics:
31752+
""""""""""
31753+
31754+
This intrinsic returns a pointer which may be used to store a
31755+
pointer at the specified address that is encoded using the specified
31756+
discriminator. Stores via the pointer will cause the stored pointer to be
31757+
blended with the second argument before being stored. The blend operation
31758+
shall be either a weak but cheap and target-independent operation (if
31759+
the third argument is 0) or a stronger target-specific operation (if the
31760+
third argument is 1). When loading from the pointer, the inverse operation
31761+
is done on the loaded pointer after it is loaded. Specifically, when the
31762+
third argument is 1, the pointer is signed (using pointer authentication
31763+
instructions or emulated PAC if not supported by the hardware) using
31764+
the discriminator before being stored, and authenticated after being
31765+
loaded. Note that it is currently unsupported to have the third argument
31766+
be 1 on targets other than AArch64, and it is also currently unsupported
31767+
to have the third argument be 0 at all.
31768+
31769+
If the pointer is used other than for loading or storing (e.g. its
31770+
address escapes), that will disable all blending operations using
31771+
the deactivation symbol specified in the intrinsic's operand bundle.
31772+
The deactivation symbol operand bundle is copied onto any sign and auth
31773+
intrinsics that this intrinsic is lowered into. The intent is that the
31774+
deactivation symbol represents a field identifier.
31775+
31776+
This intrinsic is used to implement structure protection.

llvm/include/llvm-c/OrcEE.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ typedef void (*LLVMMemoryManagerNotifyTerminatingCallback)(void *CtxCtx);
4343
* @{
4444
*/
4545

46+
/**
47+
* Create a ObjectLinkingLayer instance using the standard JITLink
48+
* InProcessMemoryManager for memory management.
49+
*/
50+
LLVM_C_ABI LLVMErrorRef
51+
LLVMOrcCreateObjectLinkingLayerWithInProcessMemoryManager(
52+
LLVMOrcObjectLayerRef *Result, LLVMOrcExecutionSessionRef ES);
53+
4654
/**
4755
* Create a RTDyldObjectLinkingLayer instance using the standard
4856
* SectionMemoryManager for memory management.

llvm/include/llvm/Analysis/Delinearization.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,15 @@ bool validateDelinearizationResult(ScalarEvolution &SE,
154154
///
155155
/// This function optimistically assumes the GEP references into a fixed size
156156
/// array. If this is actually true, this function returns a list of array
157-
/// subscript expressions in \p Subscripts and a list of integers describing
158-
/// the size of the individual array dimensions in \p Sizes. Both lists have
159-
/// either equal length or the size list is one element shorter in case there
160-
/// is no known size available for the outermost array dimension. Returns true
161-
/// if successful and false otherwise.
157+
/// subscript expressions in \p Subscripts and a list of SCEV expressions
158+
/// describing the size of the individual array dimensions in \p Sizes. Both
159+
/// lists have either equal length or the size list is one element shorter in
160+
/// case there is no known size available for the outermost array dimension.
161+
/// Returns true if successful and false otherwise.
162162
bool getIndexExpressionsFromGEP(ScalarEvolution &SE,
163163
const GetElementPtrInst *GEP,
164164
SmallVectorImpl<const SCEV *> &Subscripts,
165-
SmallVectorImpl<int> &Sizes);
165+
SmallVectorImpl<const SCEV *> &Sizes);
166166

167167
struct DelinearizationPrinterPass
168168
: public PassInfoMixin<DelinearizationPrinterPass> {

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -845,30 +845,6 @@ class TargetTransformInfoImplBase {
845845
return 1;
846846
}
847847

848-
virtual InstructionCost
849-
getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
850-
TTI::TargetCostKind CostKind) const {
851-
return 1;
852-
}
853-
854-
virtual InstructionCost
855-
getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA,
856-
TTI::TargetCostKind CostKind) const {
857-
return 1;
858-
}
859-
860-
virtual InstructionCost
861-
getExpandCompressMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
862-
TTI::TargetCostKind CostKind) const {
863-
return 1;
864-
}
865-
866-
virtual InstructionCost
867-
getStridedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
868-
TTI::TargetCostKind CostKind) const {
869-
return InstructionCost::getInvalid();
870-
}
871-
872848
virtual InstructionCost getInterleavedMemoryOpCost(
873849
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
874850
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
@@ -928,8 +904,20 @@ class TargetTransformInfoImplBase {
928904
virtual InstructionCost
929905
getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
930906
TTI::TargetCostKind CostKind) const {
931-
return 1;
907+
switch (MICA.getID()) {
908+
case Intrinsic::masked_scatter:
909+
case Intrinsic::masked_gather:
910+
case Intrinsic::masked_load:
911+
case Intrinsic::masked_store:
912+
case Intrinsic::vp_scatter:
913+
case Intrinsic::vp_gather:
914+
case Intrinsic::masked_compressstore:
915+
case Intrinsic::masked_expandload:
916+
return 1;
917+
}
918+
return InstructionCost::getInvalid();
932919
}
920+
933921
virtual InstructionCost getCallInstrCost(Function *F, Type *RetTy,
934922
ArrayRef<Type *> Tys,
935923
TTI::TargetCostKind CostKind) const {

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 42 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,64 +1557,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
15571557
return Cost;
15581558
}
15591559

1560-
InstructionCost
1561-
getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
1562-
TTI::TargetCostKind CostKind) const override {
1563-
Type *DataTy = MICA.getDataType();
1564-
Align Alignment = MICA.getAlignment();
1565-
unsigned Opcode = MICA.getID() == Intrinsic::masked_load
1566-
? Instruction::Load
1567-
: Instruction::Store;
1568-
// TODO: Pass on AddressSpace when we have test coverage.
1569-
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, true, false,
1570-
CostKind);
1571-
}
1572-
1573-
InstructionCost
1574-
getGatherScatterOpCost(const MemIntrinsicCostAttributes &MICA,
1575-
TTI::TargetCostKind CostKind) const override {
1576-
unsigned Opcode = (MICA.getID() == Intrinsic::masked_gather ||
1577-
MICA.getID() == Intrinsic::vp_gather)
1578-
? Instruction::Load
1579-
: Instruction::Store;
1580-
Type *DataTy = MICA.getDataType();
1581-
bool VariableMask = MICA.getVariableMask();
1582-
Align Alignment = MICA.getAlignment();
1583-
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, VariableMask,
1584-
true, CostKind);
1585-
}
1586-
1587-
InstructionCost
1588-
getExpandCompressMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
1589-
TTI::TargetCostKind CostKind) const override {
1590-
unsigned Opcode = MICA.getID() == Intrinsic::masked_expandload
1591-
? Instruction::Load
1592-
: Instruction::Store;
1593-
Type *DataTy = MICA.getDataType();
1594-
bool VariableMask = MICA.getVariableMask();
1595-
Align Alignment = MICA.getAlignment();
1596-
// Treat expand load/compress store as gather/scatter operation.
1597-
// TODO: implement more precise cost estimation for these intrinsics.
1598-
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, VariableMask,
1599-
/*IsGatherScatter*/ true, CostKind);
1600-
}
1601-
1602-
InstructionCost
1603-
getStridedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
1604-
TTI::TargetCostKind CostKind) const override {
1605-
// For a target without strided memory operations (or for an illegal
1606-
// operation type on one which does), assume we lower to a gather/scatter
1607-
// operation. (Which may in turn be scalarized.)
1608-
unsigned IID = MICA.getID() == Intrinsic::experimental_vp_strided_load
1609-
? Intrinsic::masked_gather
1610-
: Intrinsic::masked_scatter;
1611-
return thisT()->getGatherScatterOpCost(
1612-
MemIntrinsicCostAttributes(IID, MICA.getDataType(), MICA.getPointer(),
1613-
MICA.getVariableMask(), MICA.getAlignment(),
1614-
MICA.getInst()),
1615-
CostKind);
1616-
}
1617-
16181560
InstructionCost getInterleavedMemoryOpCost(
16191561
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
16201562
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
@@ -3062,22 +3004,56 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
30623004
getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
30633005
TTI::TargetCostKind CostKind) const override {
30643006
unsigned Id = MICA.getID();
3007+
Type *DataTy = MICA.getDataType();
3008+
bool VariableMask = MICA.getVariableMask();
3009+
Align Alignment = MICA.getAlignment();
30653010

30663011
switch (Id) {
30673012
case Intrinsic::experimental_vp_strided_load:
3068-
case Intrinsic::experimental_vp_strided_store:
3069-
return thisT()->getStridedMemoryOpCost(MICA, CostKind);
3013+
case Intrinsic::experimental_vp_strided_store: {
3014+
unsigned Opcode = Id == Intrinsic::experimental_vp_strided_load
3015+
? Instruction::Load
3016+
: Instruction::Store;
3017+
// For a target without strided memory operations (or for an illegal
3018+
// operation type on one which does), assume we lower to a gather/scatter
3019+
// operation. (Which may in turn be scalarized.)
3020+
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment,
3021+
VariableMask, true, CostKind);
3022+
}
30703023
case Intrinsic::masked_scatter:
30713024
case Intrinsic::masked_gather:
30723025
case Intrinsic::vp_scatter:
3073-
case Intrinsic::vp_gather:
3074-
return thisT()->getGatherScatterOpCost(MICA, CostKind);
3026+
case Intrinsic::vp_gather: {
3027+
unsigned Opcode = (MICA.getID() == Intrinsic::masked_gather ||
3028+
MICA.getID() == Intrinsic::vp_gather)
3029+
? Instruction::Load
3030+
: Instruction::Store;
3031+
3032+
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment,
3033+
VariableMask, true, CostKind);
3034+
}
3035+
case Intrinsic::vp_load:
3036+
case Intrinsic::vp_store:
3037+
return InstructionCost::getInvalid();
30753038
case Intrinsic::masked_load:
3076-
case Intrinsic::masked_store:
3077-
return thisT()->getMaskedMemoryOpCost(MICA, CostKind);
3039+
case Intrinsic::masked_store: {
3040+
unsigned Opcode =
3041+
Id == Intrinsic::masked_load ? Instruction::Load : Instruction::Store;
3042+
// TODO: Pass on AddressSpace when we have test coverage.
3043+
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment, true, false,
3044+
CostKind);
3045+
}
30783046
case Intrinsic::masked_compressstore:
3079-
case Intrinsic::masked_expandload:
3080-
return thisT()->getExpandCompressMemoryOpCost(MICA, CostKind);
3047+
case Intrinsic::masked_expandload: {
3048+
unsigned Opcode = MICA.getID() == Intrinsic::masked_expandload
3049+
? Instruction::Load
3050+
: Instruction::Store;
3051+
// Treat expand load/compress store as gather/scatter operation.
3052+
// TODO: implement more precise cost estimation for these intrinsics.
3053+
return getCommonMaskedMemoryOpCost(Opcode, DataTy, Alignment,
3054+
VariableMask,
3055+
/*IsGatherScatter*/ true, CostKind);
3056+
}
30813057
case Intrinsic::vp_load_ff:
30823058
return InstructionCost::getInvalid();
30833059
default:

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,6 +2931,13 @@ def int_experimental_convergence_anchor
29312931
def int_experimental_convergence_loop
29322932
: DefaultAttrsIntrinsic<[llvm_token_ty], [], [IntrNoMem, IntrConvergent]>;
29332933

2934+
//===----------------- Structure Protection Intrinsics --------------------===//
2935+
2936+
def int_protected_field_ptr :
2937+
DefaultAttrsIntrinsic<[llvm_anyptr_ty],
2938+
[LLVMMatchType<0>, llvm_i64_ty, llvm_i1_ty],
2939+
[IntrNoMem, ImmArg<ArgIndex<2>>]>;
2940+
29342941
//===----------------------------------------------------------------------===//
29352942
// Target-specific intrinsics
29362943
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)