Skip to content

Commit 5e014a1

Browse files
committed
Rebase
Created using spr 1.3.5
2 parents 501ce30 + d18b1eb commit 5e014a1

File tree

38 files changed

+1265
-258
lines changed

38 files changed

+1265
-258
lines changed

clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ namespace clang::tidy::utils {
1414

1515
ExceptionSpecAnalyzer::State
1616
ExceptionSpecAnalyzer::analyze(const FunctionDecl *FuncDecl) {
17-
// Check if the function has already been analyzed and reuse that result.
18-
const auto CacheEntry = FunctionCache.find(FuncDecl);
19-
if (CacheEntry == FunctionCache.end()) {
17+
// Check if function exist in cache or add temporary value to cache to protect
18+
// against endless recursion.
19+
const auto [CacheEntry, NotFound] =
20+
FunctionCache.try_emplace(FuncDecl, State::NotThrowing);
21+
if (NotFound) {
2022
ExceptionSpecAnalyzer::State State = analyzeImpl(FuncDecl);
21-
22-
// Cache the result of the analysis.
23-
FunctionCache.try_emplace(FuncDecl, State);
23+
// Update result with calculated value
24+
FunctionCache[FuncDecl] = State;
2425
return State;
2526
}
2627

clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t -- -- -fexceptions
2+
// RUN: %check_clang_tidy -std=c++17 -check-suffixes=,ERR %s performance-noexcept-move-constructor %t \
3+
// RUN: -- --fix-errors -- -fexceptions -DENABLE_ERROR
24

35
namespace std
46
{
@@ -397,3 +399,18 @@ namespace gh68101
397399
Container(Container&&) noexcept(std::is_nothrow_move_constructible<T>::value);
398400
};
399401
} // namespace gh68101
402+
403+
namespace gh111436
404+
{
405+
406+
template <typename value_type> class set {
407+
set(set &&) = default;
408+
409+
#ifdef ENABLE_ERROR
410+
set(initializer_list<value_type> __l) {};
411+
// CHECK-MESSAGES-ERR: :[[@LINE-1]]:7: error: member 'initializer_list' cannot have template arguments [clang-diagnostic-error]
412+
// CHECK-MESSAGES-ERR: :[[@LINE-2]]:36: error: expected ')' [clang-diagnostic-error]
413+
#endif
414+
};
415+
416+
} // namespace gh111436

clang/tools/clang-scan-deps/ClangScanDeps.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,7 @@ class ResourceDirectoryCache {
308308
return "";
309309
StringRef Output = OutputBuf.get()->getBuffer().rtrim('\n');
310310

311-
Cache[ClangBinaryPath] = Output.str();
312-
return Cache[ClangBinaryPath];
311+
return Cache[ClangBinaryPath] = Output.str();
313312
}
314313

315314
private:

flang/lib/Optimizer/Analysis/AliasAnalysis.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,22 @@ static bool hasGlobalOpTargetAttr(mlir::Value v, fir::AddrOfOp op) {
5151
v, fir::GlobalOp::getTargetAttrName(globalOpName));
5252
}
5353

54-
static mlir::Value getOriginalDef(mlir::Value v) {
54+
static mlir::Value
55+
getOriginalDef(mlir::Value v,
56+
fir::AliasAnalysis::Source::Attributes &attributes,
57+
bool &isCapturedInInternalProcedure) {
5558
mlir::Operation *defOp;
5659
bool breakFromLoop = false;
5760
while (!breakFromLoop && (defOp = v.getDefiningOp())) {
5861
llvm::TypeSwitch<Operation *>(defOp)
5962
.Case<fir::ConvertOp>([&](fir::ConvertOp op) { v = op.getValue(); })
60-
.Case<fir::DeclareOp, hlfir::DeclareOp>(
61-
[&](auto op) { v = op.getMemref(); })
63+
.Case<fir::DeclareOp, hlfir::DeclareOp>([&](auto op) {
64+
v = op.getMemref();
65+
auto varIf = llvm::cast<fir::FortranVariableOpInterface>(defOp);
66+
attributes |= getAttrsFromVariable(varIf);
67+
isCapturedInInternalProcedure |=
68+
varIf.isCapturedInInternalProcedure();
69+
})
6270
.Default([&](auto op) { breakFromLoop = true; });
6371
}
6472
return v;
@@ -600,7 +608,8 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
600608
if (mlir::isa<fir::PointerType>(boxTy.getEleTy()))
601609
attributes.set(Attribute::Pointer);
602610

603-
auto def = getOriginalDef(op.getMemref());
611+
auto def = getOriginalDef(op.getMemref(), attributes,
612+
isCapturedInInternalProcedure);
604613
if (auto addrOfOp = def.template getDefiningOp<fir::AddrOfOp>()) {
605614
global = addrOfOp.getSymbol();
606615

@@ -609,13 +618,13 @@ AliasAnalysis::Source AliasAnalysis::getSource(mlir::Value v,
609618

610619
type = SourceKind::Global;
611620
}
612-
613-
// TODO: Add support to fir.alloca and fir.allocmem
614-
// if (auto allocOp = def.template getDefiningOp<fir::AllocaOp>()) {
615-
// ...
616-
// }
617-
618-
if (isDummyArgument(def)) {
621+
// TODO: Add support to fir.allocmem
622+
else if (auto allocOp =
623+
def.template getDefiningOp<fir::AllocaOp>()) {
624+
v = def;
625+
defOp = v.getDefiningOp();
626+
type = SourceKind::Allocate;
627+
} else if (isDummyArgument(def)) {
619628
defOp = nullptr;
620629
v = def;
621630
}

flang/runtime/pointer.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,18 @@ void RTDEF(PointerAssociateLowerBounds)(Descriptor &pointer,
8989
void RTDEF(PointerAssociateRemapping)(Descriptor &pointer,
9090
const Descriptor &target, const Descriptor &bounds, const char *sourceFile,
9191
int sourceLine) {
92-
pointer = target;
93-
pointer.raw().attribute = CFI_attribute_pointer;
9492
Terminator terminator{sourceFile, sourceLine};
9593
SubscriptValue byteStride{/*captured from first dimension*/};
9694
std::size_t boundElementBytes{bounds.ElementBytes()};
9795
std::size_t boundsRank{
9896
static_cast<std::size_t>(bounds.GetDimension(1).Extent())};
99-
pointer.raw().rank = boundsRank;
97+
// We cannot just assign target into pointer descriptor, because
98+
// the ranks may mismatch. Use target as a mold for initializing
99+
// the pointer descriptor.
100+
INTERNAL_CHECK(static_cast<std::size_t>(pointer.rank()) == boundsRank);
101+
pointer.ApplyMold(target, boundsRank);
102+
pointer.set_base_addr(target.raw().base_addr);
103+
pointer.raw().attribute = CFI_attribute_pointer;
100104
for (unsigned j{0}; j < boundsRank; ++j) {
101105
auto &dim{pointer.GetDimension(j)};
102106
dim.SetBounds(GetInt64(bounds.ZeroBasedIndexedElement<const char>(2 * j),
@@ -115,13 +119,6 @@ void RTDEF(PointerAssociateRemapping)(Descriptor &pointer,
115119
"pointer (%zd > %zd)",
116120
pointer.Elements(), target.Elements());
117121
}
118-
if (auto *pointerAddendum{pointer.Addendum()}) {
119-
if (const auto *targetAddendum{target.Addendum()}) {
120-
if (const auto *derived{targetAddendum->derivedType()}) {
121-
pointerAddendum->set_derivedType(derived);
122-
}
123-
}
124-
}
125122
}
126123

127124
RT_API_ATTRS void *AllocateValidatedPointerPayload(std::size_t byteSize) {

flang/test/Analysis/AliasAnalysis/alias-analysis-2.fir

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// They cannot physically alias
99
// CHECK-DAG: p1.addr#0 <-> p2.addr#0: NoAlias
1010

11-
// p1.addr and p2.addr could both be wrapped inside boxes
12-
// CHECK-DAG: p1.addr#0 <-> boxp1.addr#0: MayAlias
13-
// CHECK-DAG: p2.addr#0 <-> boxp1.addr#0: MayAlias
11+
// p1.addr is the address returned by an alloca. It does not have a target
12+
// attribute, and it is not the address retrieved from a pointer. It cannot
13+
// alias anything. Likewise for p2.addr.
14+
// CHECK-DAG: p1.addr#0 <-> boxp1.addr#0: NoAlias
15+
// CHECK-DAG: p2.addr#0 <-> boxp1.addr#0: NoAlias
1416

1517
// TODO: To really see aliasing, we should be looking at a load of p1.addr
1618
// p1.addr is just a local address holding the address to the data
@@ -27,10 +29,11 @@
2729
// CHECK-DAG: p2.addr#0 <-> func.region0#2: NoAlias
2830

2931
// All arguments are either pointers or targets
30-
// A pointer in a box may alias with both
32+
// The address *in* a local pointer may alias the address of a target
33+
// argument, but it does not alias the address *of* a pointer argument.
3134
// CHECK-DAG: boxp1.addr#0 <-> func.region0#0: MayAlias
3235
// CHECK-DAG: boxp1.addr#0 <-> func.region0#1: MayAlias
33-
// CHECK-DAG: boxp1.addr#0 <-> func.region0#2: MayAlias
36+
// CHECK-DAG: boxp1.addr#0 <-> func.region0#2: NoAlias
3437

3538
// A target dummy may alias with another target
3639
// CHECK-DAG: func.region0#0 <-> func.region0#1: MayAlias
@@ -54,7 +57,7 @@
5457

5558
// The addresses stored in two different pointers can alias, even if one has no
5659
// box. In this program, they happen to be the same address.
57-
// T4:
60+
// T4 from <https://github.com/llvm/llvm-project/pull/117785#discussion_r1924348480>.
5861
// CHECK-DAG: p1.tgt#0 <-> boxp1.addr#0: MayAlias
5962

6063
func.func @_QFPtest(%arg0: !fir.ref<f32> {fir.bindc_name = "v1", fir.target}, %arg1: !fir.ref<f32> {fir.bindc_name = "v2", fir.target}, %arg2: !fir.ref<!fir.box<!fir.ptr<f32>>> ) attributes {test.ptr = "func"} {

0 commit comments

Comments
 (0)