Skip to content

Commit fc8cad7

Browse files
authored
Merge branch 'main' into hjagasiaAMD-offload-tunnel-cmake
2 parents ec4e962 + b389adf commit fc8cad7

29 files changed

+274
-76
lines changed

clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,20 +615,20 @@ void CIRRecordLowering::determinePacked(bool nvBaseType) {
615615
continue;
616616
// If any member falls at an offset that it not a multiple of its alignment,
617617
// then the entire record must be packed.
618-
if (member.offset % getAlignment(member.data))
618+
if (!member.offset.isMultipleOf(getAlignment(member.data)))
619619
packed = true;
620620
if (member.offset < nvSize)
621621
nvAlignment = std::max(nvAlignment, getAlignment(member.data));
622622
alignment = std::max(alignment, getAlignment(member.data));
623623
}
624624
// If the size of the record (the capstone's offset) is not a multiple of the
625625
// record's alignment, it must be packed.
626-
if (members.back().offset % alignment)
626+
if (!members.back().offset.isMultipleOf(alignment))
627627
packed = true;
628628
// If the non-virtual sub-object is not a multiple of the non-virtual
629629
// sub-object's alignment, it must be packed. We cannot have a packed
630630
// non-virtual sub-object and an unpacked complete object or vise versa.
631-
if (nvSize % nvAlignment)
631+
if (!nvSize.isMultipleOf(nvAlignment))
632632
packed = true;
633633
// Update the alignment of the sentinel.
634634
if (!packed)
@@ -824,7 +824,7 @@ void CIRRecordLowering::lowerUnion() {
824824
appendPaddingBytes(layoutSize - getSize(storageType));
825825

826826
// Set packed if we need it.
827-
if (layoutSize % getAlignment(storageType))
827+
if (!layoutSize.isMultipleOf(getAlignment(storageType)))
828828
packed = true;
829829
}
830830

clang/test/CodeGenHLSL/RootSignature.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ void RootDescriptorsEntry() {}
8282
// checking minLOD, maxLOD
8383
// CHECK-SAME: float -1.280000e+02, float 1.280000e+02,
8484

85-
// checking register, space and visibility
86-
// CHECK-SAME: i32 42, i32 0, i32 0}
85+
// checking register, space, visibility and flags
86+
// CHECK-SAME: i32 42, i32 0, i32 0, i32 0}
8787

8888
#define SampleStaticSampler \
8989
"StaticSampler(s42, " \

llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct StaticSampler {
131131
float MaxLOD = std::numeric_limits<float>::max();
132132
uint32_t Space = 0;
133133
dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All;
134+
dxbc::StaticSamplerFlags Flags = dxbc::StaticSamplerFlags::None;
134135
};
135136

136137
/// Models RootElement : RootFlags | RootConstants | RootParam

llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ MDNode *MetadataBuilder::BuildStaticSampler(const StaticSampler &Sampler) {
218218
ConstantAsMetadata::get(Builder.getInt32(Sampler.Space)),
219219
ConstantAsMetadata::get(
220220
Builder.getInt32(to_underlying(Sampler.Visibility))),
221+
ConstantAsMetadata::get(Builder.getInt32(to_underlying(Sampler.Flags))),
221222
};
222223
return MDNode::get(Ctx, Operands);
223224
}
@@ -417,7 +418,7 @@ Error MetadataParser::parseDescriptorTable(mcdxbc::RootSignatureDesc &RSD,
417418

418419
Error MetadataParser::parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
419420
MDNode *StaticSamplerNode) {
420-
if (StaticSamplerNode->getNumOperands() != 14)
421+
if (StaticSamplerNode->getNumOperands() != 15)
421422
return make_error<InvalidRSMetadataFormat>("Static Sampler");
422423

423424
mcdxbc::StaticSampler Sampler;
@@ -501,6 +502,17 @@ Error MetadataParser::parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
501502
return Error(std::move(E));
502503
Sampler.ShaderVisibility = *Visibility;
503504

505+
if (RSD.Version < 3) {
506+
RSD.StaticSamplers.push_back(Sampler);
507+
return Error::success();
508+
}
509+
assert(RSD.Version >= 3);
510+
511+
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 14))
512+
Sampler.Flags = *Val;
513+
else
514+
return make_error<InvalidRSMetadataValue>("Static Sampler Flags");
515+
504516
RSD.StaticSamplers.push_back(Sampler);
505517
return Error::success();
506518
}

llvm/lib/Support/ScopedPrinter.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
#include "llvm/Support/ScopedPrinter.h"
1+
//===----------------------------------------------------------------------===//
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+
//===----------------------------------------------------------------------===//
28

9+
#include "llvm/Support/ScopedPrinter.h"
310
#include "llvm/Support/Format.h"
411

5-
using namespace llvm::support;
12+
using namespace llvm;
613

7-
namespace llvm {
8-
9-
raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) {
14+
raw_ostream &llvm::operator<<(raw_ostream &OS, const HexNumber &Value) {
1015
OS << "0x" << utohexstr(Value.Value);
1116
return OS;
1217
}
@@ -45,5 +50,3 @@ JSONScopedPrinter::JSONScopedPrinter(
4550
if (this->OuterScope)
4651
this->OuterScope->setPrinter(*this);
4752
}
48-
49-
} // namespace llvm

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3139,8 +3139,8 @@ bool RISCVTTIImpl::isProfitableToSinkOperands(
31393139
bool IsVPSplat = match(Op, m_Intrinsic<Intrinsic::experimental_vp_splat>(
31403140
m_Value(), m_Value(), m_Value()));
31413141
if (!IsVPSplat &&
3142-
!match(Op, m_Shuffle(m_InsertElt(m_Undef(), m_Value(), m_ZeroInt()),
3143-
m_Undef(), m_ZeroMask())))
3142+
!match(Op, m_Shuffle(m_InsertElt(m_Value(), m_Value(), m_ZeroInt()),
3143+
m_Value(), m_ZeroMask())))
31443144
continue;
31453145

31463146
// Don't sink i1 splats.

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,10 +2241,9 @@ class BoUpSLP {
22412241
/// TODO: If load combining is allowed in the IR optimizer, this analysis
22422242
/// may not be necessary.
22432243
bool isLoadCombineCandidate(ArrayRef<Value *> Stores) const;
2244-
bool isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
2245-
ArrayRef<unsigned> Order, const TargetTransformInfo &TTI,
2246-
const DataLayout &DL, ScalarEvolution &SE,
2247-
const int64_t Diff, StridedPtrInfo &SPtrInfo) const;
2244+
bool isStridedLoad(ArrayRef<Value *> PointerOps, Type *ScalarTy,
2245+
Align Alignment, const int64_t Diff, Value *Ptr0,
2246+
Value *PtrN, StridedPtrInfo &SPtrInfo) const;
22482247

22492248
/// Checks if the given array of loads can be represented as a vectorized,
22502249
/// scatter or just simple gather.
@@ -6824,13 +6823,10 @@ isMaskedLoadCompress(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
68246823
/// 4. Any pointer operand is an instruction with the users outside of the
68256824
/// current graph (for masked gathers extra extractelement instructions
68266825
/// might be required).
6827-
bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
6828-
ArrayRef<unsigned> Order,
6829-
const TargetTransformInfo &TTI,
6830-
const DataLayout &DL, ScalarEvolution &SE,
6831-
const int64_t Diff,
6832-
StridedPtrInfo &SPtrInfo) const {
6833-
const size_t Sz = VL.size();
6826+
bool BoUpSLP::isStridedLoad(ArrayRef<Value *> PointerOps, Type *ScalarTy,
6827+
Align Alignment, const int64_t Diff, Value *Ptr0,
6828+
Value *PtrN, StridedPtrInfo &SPtrInfo) const {
6829+
const size_t Sz = PointerOps.size();
68346830
if (Diff % (Sz - 1) != 0)
68356831
return false;
68366832

@@ -6842,7 +6838,6 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
68426838
});
68436839

68446840
const uint64_t AbsoluteDiff = std::abs(Diff);
6845-
Type *ScalarTy = VL.front()->getType();
68466841
auto *VecTy = getWidenedType(ScalarTy, Sz);
68476842
if (IsAnyPointerUsedOutGraph ||
68486843
(AbsoluteDiff > Sz &&
@@ -6853,20 +6848,9 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
68536848
int64_t Stride = Diff / static_cast<int64_t>(Sz - 1);
68546849
if (Diff != Stride * static_cast<int64_t>(Sz - 1))
68556850
return false;
6856-
Align Alignment =
6857-
cast<LoadInst>(Order.empty() ? VL.front() : VL[Order.front()])
6858-
->getAlign();
6859-
if (!TTI.isLegalStridedLoadStore(VecTy, Alignment))
6851+
if (!TTI->isLegalStridedLoadStore(VecTy, Alignment))
68606852
return false;
6861-
Value *Ptr0;
6862-
Value *PtrN;
6863-
if (Order.empty()) {
6864-
Ptr0 = PointerOps.front();
6865-
PtrN = PointerOps.back();
6866-
} else {
6867-
Ptr0 = PointerOps[Order.front()];
6868-
PtrN = PointerOps[Order.back()];
6869-
}
6853+
68706854
// Iterate through all pointers and check if all distances are
68716855
// unique multiple of Dist.
68726856
SmallSet<int64_t, 4> Dists;
@@ -6875,14 +6859,14 @@ bool BoUpSLP::isStridedLoad(ArrayRef<Value *> VL, ArrayRef<Value *> PointerOps,
68756859
if (Ptr == PtrN)
68766860
Dist = Diff;
68776861
else if (Ptr != Ptr0)
6878-
Dist = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, DL, SE);
6862+
Dist = *getPointersDiff(ScalarTy, Ptr0, ScalarTy, Ptr, *DL, *SE);
68796863
// If the strides are not the same or repeated, we can't
68806864
// vectorize.
68816865
if (((Dist / Stride) * Stride) != Dist || !Dists.insert(Dist).second)
68826866
break;
68836867
}
68846868
if (Dists.size() == Sz) {
6885-
Type *StrideTy = DL.getIndexType(Ptr0->getType());
6869+
Type *StrideTy = DL->getIndexType(Ptr0->getType());
68866870
SPtrInfo.StrideVal = ConstantInt::get(StrideTy, Stride);
68876871
SPtrInfo.Ty = getWidenedType(ScalarTy, Sz);
68886872
return true;
@@ -6971,7 +6955,11 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
69716955
cast<Instruction>(V), UserIgnoreList);
69726956
}))
69736957
return LoadsState::CompressVectorize;
6974-
if (isStridedLoad(VL, PointerOps, Order, *TTI, *DL, *SE, *Diff, SPtrInfo))
6958+
Align Alignment =
6959+
cast<LoadInst>(Order.empty() ? VL.front() : VL[Order.front()])
6960+
->getAlign();
6961+
if (isStridedLoad(PointerOps, ScalarTy, Alignment, *Diff, Ptr0, PtrN,
6962+
SPtrInfo))
69756963
return LoadsState::StridedVectorize;
69766964
}
69776965
if (!TTI->isLegalMaskedGather(VecTy, CommonAlignment) ||

llvm/test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ set(LLVM_TEST_DEPENDS
7171
${LLVM_TEST_DEPENDS_COMMON}
7272
BugpointPasses
7373
LLVMWindowsDriver
74-
UnitTests
7574
bugpoint
7675
llc
7776
lli
@@ -270,10 +269,11 @@ add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR}
270269
${exclude_from_check_all}
271270
DEPENDS ${LLVM_TEST_DEPENDS}
272271
FOLDER "Tests/Subdirectories"
273-
SKIP "^FileCheck" "^TableGen"
272+
SKIP "^FileCheck" "^TableGen" "^Unit"
274273
)
275274
add_subdirectory(FileCheck)
276275
add_subdirectory(TableGen)
276+
add_subdirectory(Unit)
277277

278278
# Setup an alias for 'check-all'.
279279
add_custom_target(check)

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressU.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
1717
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
19-
!5 = !{ !"StaticSampler", i32 4, i32 666, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }
19+
!5 = !{ !"StaticSampler", i32 4, i32 666, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0, i32 0 }

llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers-Invalid-AddressV.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
1616
!dx.rootsignatures = !{!2} ; list of function/root signature pairs
1717
!2 = !{ ptr @main, !3, i32 2 } ; function, root signature
1818
!3 = !{ !5 } ; list of root signature elements
19-
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 666, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }
19+
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 666, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0, i32 0 }

0 commit comments

Comments
 (0)