Skip to content

Commit eaea0cb

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/zext-knownbits
2 parents a0fb8db + c6091cd commit eaea0cb

File tree

23 files changed

+798
-1592
lines changed

23 files changed

+798
-1592
lines changed

clang/lib/AST/ByteCode/DynamicAllocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class DynamicAllocator final {
9797
private:
9898
llvm::DenseMap<const Expr *, AllocationSite> AllocationSites;
9999

100-
using PoolAllocTy = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator>;
100+
using PoolAllocTy = llvm::BumpPtrAllocator;
101101
PoolAllocTy DescAllocator;
102102

103103
/// Allocates a new descriptor.

clang/lib/AST/ByteCode/Program.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Program final {
171171
llvm::DenseMap<const void *, unsigned> NativePointerIndices;
172172

173173
/// Custom allocator for global storage.
174-
using PoolAllocTy = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator>;
174+
using PoolAllocTy = llvm::BumpPtrAllocator;
175175

176176
/// Descriptor + storage for a global object.
177177
///

flang/include/flang/Common/Fortran.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ static constexpr IgnoreTKRSet ignoreTKRAll{IgnoreTKR::Type, IgnoreTKR::Kind,
118118
std::string AsFortran(IgnoreTKRSet);
119119

120120
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr>,
121-
std::optional<CUDADataAttr>, IgnoreTKRSet, bool allowUnifiedMatchingRule,
121+
std::optional<CUDADataAttr>, IgnoreTKRSet, std::optional<std::string> *,
122+
bool allowUnifiedMatchingRule,
122123
const LanguageFeatureControl *features = nullptr);
123124

124125
static constexpr char blankCommonObjectName[] = "__BLNK__";

flang/lib/Common/Fortran.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ std::string AsFortran(IgnoreTKRSet tkr) {
103103
/// dummy argument attribute while `y` represents the actual argument attribute.
104104
bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
105105
std::optional<CUDADataAttr> y, IgnoreTKRSet ignoreTKR,
106-
bool allowUnifiedMatchingRule, const LanguageFeatureControl *features) {
106+
std::optional<std::string> *warning, bool allowUnifiedMatchingRule,
107+
const LanguageFeatureControl *features) {
107108
bool isCudaManaged{features
108109
? features->IsEnabled(common::LanguageFeature::CudaManaged)
109110
: false};
@@ -134,8 +135,12 @@ bool AreCompatibleCUDADataAttrs(std::optional<CUDADataAttr> x,
134135
} else {
135136
if (*x == CUDADataAttr::Device) {
136137
if ((y &&
137-
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified)) ||
138+
(*y == CUDADataAttr::Managed || *y == CUDADataAttr::Unified ||
139+
*y == CUDADataAttr::Shared)) ||
138140
(!y && (isCudaUnified || isCudaManaged))) {
141+
if (y && *y == CUDADataAttr::Shared && warning) {
142+
*warning = "SHARED attribute ignored"s;
143+
}
139144
return true;
140145
}
141146
} else if (*x == CUDADataAttr::Managed) {

flang/lib/Evaluate/characteristics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ bool DummyDataObject::IsCompatibleWith(const DummyDataObject &actual,
371371
}
372372
if (!attrs.test(Attr::Value) &&
373373
!common::AreCompatibleCUDADataAttrs(cudaDataAttr, actual.cudaDataAttr,
374-
ignoreTKR,
374+
ignoreTKR, warning,
375375
/*allowUnifiedMatchingRule=*/false)) {
376376
if (whyNot) {
377377
*whyNot = "incompatible CUDA data attributes";
@@ -1771,7 +1771,7 @@ bool DistinguishUtils::Distinguishable(
17711771
x.intent != common::Intent::In) {
17721772
return true;
17731773
} else if (!common::AreCompatibleCUDADataAttrs(x.cudaDataAttr, y.cudaDataAttr,
1774-
x.ignoreTKR | y.ignoreTKR,
1774+
x.ignoreTKR | y.ignoreTKR, nullptr,
17751775
/*allowUnifiedMatchingRule=*/false)) {
17761776
return true;
17771777
} else if (features_.IsEnabled(

flang/lib/Semantics/check-call.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,9 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
976976
actualDataAttr = common::CUDADataAttr::Device;
977977
}
978978
}
979+
std::optional<std::string> warning;
979980
if (!common::AreCompatibleCUDADataAttrs(dummyDataAttr, actualDataAttr,
980-
dummy.ignoreTKR,
981+
dummy.ignoreTKR, &warning,
981982
/*allowUnifiedMatchingRule=*/true, &context.languageFeatures())) {
982983
auto toStr{[](std::optional<common::CUDADataAttr> x) {
983984
return x ? "ATTRIBUTES("s +
@@ -988,6 +989,10 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
988989
"%s has %s but its associated actual argument has %s"_err_en_US,
989990
dummyName, toStr(dummyDataAttr), toStr(actualDataAttr));
990991
}
992+
if (warning && context.ShouldWarn(common::UsageWarning::CUDAUsage)) {
993+
messages.Say(common::UsageWarning::CUDAUsage, "%s"_warn_en_US,
994+
std::move(*warning));
995+
}
991996
}
992997

993998
// Warning for breaking F'2023 change with character allocatables

flang/test/Semantics/cuf17.cuf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s 2>&1 | FileCheck %s
2+
3+
module mod1
4+
contains
5+
6+
attributes(device) subroutine sub1(adev)
7+
real, device :: adev(10)
8+
end
9+
10+
attributes(global) subroutine sub2()
11+
real, shared :: adev(10)
12+
!WARNING: SHARED attribute ignored
13+
call sub1(adev)
14+
end subroutine
15+
16+
end module
17+
18+
! CHECK: warning: SHARED attribute ignored

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ def binop_same_val: GICombineRule<
566566
// Fold (0 op x) - > 0
567567
def binop_left_to_zero: GICombineRule<
568568
(defs root:$root),
569-
(match (wip_match_opcode G_SDIV, G_UDIV, G_SREM, G_UREM):$root,
569+
(match (wip_match_opcode G_SHL, G_LSHR, G_ASHR, G_SDIV, G_UDIV, G_SREM,
570+
G_UREM):$root,
570571
[{ return Helper.matchOperandIsZero(*${root}, 1); }]),
571572
(apply [{ Helper.replaceSingleDefInstWithOperand(*${root}, 1); }])
572573
>;

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6713,11 +6713,11 @@ static bool isSameUnderlyingObjectInLoop(const PHINode *PN,
67136713
}
67146714

67156715
const Value *llvm::getUnderlyingObject(const Value *V, unsigned MaxLookup) {
6716-
if (!V->getType()->isPointerTy())
6717-
return V;
67186716
for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) {
67196717
if (auto *GEP = dyn_cast<GEPOperator>(V)) {
67206718
V = GEP->getPointerOperand();
6719+
if (!V->getType()->isPointerTy()) // Only handle scalar pointer base.
6720+
return nullptr;
67216721
} else if (Operator::getOpcode(V) == Instruction::BitCast ||
67226722
Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
67236723
Value *NewV = cast<Operator>(V)->getOperand(0);

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,9 +1339,9 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
13391339
ISD::VECTOR_SHUFFLE, ISD::VECTOR_COMPRESS},
13401340
VT, Custom);
13411341

1342-
// FIXME: mload, mstore, vp_gather/scatter can be
1343-
// hoisted to here.
1344-
setOperationAction({ISD::LOAD, ISD::STORE, ISD::MGATHER, ISD::MSCATTER},
1342+
// FIXME: vp_gather/scatter can be hoisted to here.
1343+
setOperationAction({ISD::LOAD, ISD::STORE, ISD::MLOAD, ISD::MSTORE,
1344+
ISD::MGATHER, ISD::MSCATTER},
13451345
VT, Custom);
13461346
setOperationAction({ISD::VP_LOAD, ISD::VP_STORE,
13471347
ISD::EXPERIMENTAL_VP_STRIDED_LOAD,
@@ -1409,8 +1409,6 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
14091409
setOperationAction({ISD::BUILD_VECTOR, ISD::SCALAR_TO_VECTOR}, VT,
14101410
Custom);
14111411

1412-
setOperationAction({ISD::MLOAD, ISD::MSTORE}, VT, Custom);
1413-
14141412
setOperationAction({ISD::VP_GATHER, ISD::VP_SCATTER}, VT, Custom);
14151413

14161414
setOperationAction({ISD::FADD, ISD::FSUB, ISD::FMUL, ISD::FDIV,

0 commit comments

Comments
 (0)