Skip to content

Commit 1ab2a89

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:ab261eb38a6e into amd-gfx:716677fafc9c
Local branch amd-gfx 716677f Merged main:1e43975652e5 into amd-gfx:0f5dcae1ff2f Remote branch main ab261eb [flang] Do not stop on mismatched DATA substring length (llvm#69336)
2 parents 716677f + ab261eb commit 1ab2a89

File tree

25 files changed

+238
-181
lines changed

25 files changed

+238
-181
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Expected<std::unique_ptr<BinaryContext>>
118118
BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
119119
std::unique_ptr<DWARFContext> DwCtx) {
120120
StringRef ArchName = "";
121-
StringRef FeaturesStr = "";
121+
std::string FeaturesStr = "";
122122
switch (File->getArch()) {
123123
case llvm::Triple::x86_64:
124124
ArchName = "x86-64";
@@ -128,11 +128,20 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
128128
ArchName = "aarch64";
129129
FeaturesStr = "+all";
130130
break;
131-
case llvm::Triple::riscv64:
131+
case llvm::Triple::riscv64: {
132132
ArchName = "riscv64";
133-
// RV64GC
134-
FeaturesStr = "+m,+a,+f,+d,+zicsr,+zifencei,+c,+relax";
133+
Expected<SubtargetFeatures> Features = File->getFeatures();
134+
135+
if (auto E = Features.takeError())
136+
return E;
137+
138+
// We rely on relaxation for some transformations (e.g., promoting all calls
139+
// to PseudoCALL and then making JITLink relax them). Since the relax
140+
// feature is not stored in the object file, we manually enable it.
141+
Features->AddFeature("relax");
142+
FeaturesStr = Features->getString();
135143
break;
144+
}
136145
default:
137146
return createStringError(std::errc::not_supported,
138147
"BOLT-ERROR: Unrecognized machine in ELF file");

bolt/test/RISCV/call-annotations.s

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/// Test that annotations are properly carried over to fixed calls.
22
/// Note that --enable-bat is used to force offsets to be kept.
33

4-
// RUN: llvm-mc -triple riscv64 -filetype obj -o %t.o %s
4+
// RUN: llvm-mc -triple riscv64 -mattr=+c -filetype obj -o %t.o %s
55
// RUN: ld.lld --emit-relocs -o %t %t.o
66
// RUN: llvm-bolt --enable-bat --print-cfg --print-fix-riscv-calls \
77
// RUN: -o /dev/null %t | FileCheck %s
88

99
.text
10+
.option norvc
1011
.global f
1112
.p2align 1
1213
f:

bolt/test/RISCV/internal-func-reloc.s

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22
/// get transformed by BOLT. The tests rely on the "remove-nops" optimization:
33
/// if nops got removed from the function, it got transformed by BOLT.
44

5-
// RUN: %clang %cflags -o %t %s
5+
// RUN: llvm-mc -triple riscv64 -filetype=obj -o %t.o %s
6+
// RUN: ld.lld --emit-relocs -o %t %t.o
67
// RUN: llvm-bolt -o %t.bolt %t
78
// RUN: llvm-objdump -d %t.bolt | FileCheck %s
89

910
.text
10-
11-
/// These options are only used to make the assembler output easier to predict
12-
.option norelax
13-
.option norvc
14-
1511
.globl _start
16-
.p2align 1
12+
.p2align 2
1713
// CHECK: <_start>:
1814
// CHECK-NEXT: j 0x{{.*}} <_start>
1915
_start:
@@ -23,10 +19,10 @@ _start:
2319
.size _start, .-_start
2420

2521
.globl f
26-
.p2align 1
22+
.p2align 2
2723
// CHECK: <f>:
28-
// CHECK-NEXT: auipc a0, 0
29-
// CHECK-NEXT: addi a0, a0, 64
24+
// CHECK-NEXT: auipc a0, [[#]]
25+
// CHECK-NEXT: addi a0, a0, [[#]]
3026
f:
3127
nop
3228
1:
@@ -37,7 +33,7 @@ f:
3733
.size f, .-f
3834

3935
.globl g
40-
.p2align 1
36+
.p2align 2
4137
g:
4238
ret
4339
.size g, .-g

clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,6 @@ class DataflowAnalysisContext {
133133
/// identified by `Token` imply that `Val` is true.
134134
bool flowConditionImplies(Atom Token, const Formula &);
135135

136-
/// Returns true if and only if the constraints of the flow condition
137-
/// identified by `Token` are always true.
138-
bool flowConditionIsTautology(Atom Token);
139-
140136
/// Returns true if `Val1` is equivalent to `Val2`.
141137
/// Note: This function doesn't take into account constraints on `Val1` and
142138
/// `Val2` imposed by the flow condition.

clang/include/clang/Format/Format.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4861,6 +4861,8 @@ FormatStyle getGNUStyle();
48614861
/// https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference?view=vs-2017
48624862
FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language);
48634863

4864+
FormatStyle getClangFormatStyle();
4865+
48644866
/// Returns style indicating formatting should be not applied at all.
48654867
FormatStyle getNoStyle();
48664868

clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,6 @@ bool DataflowAnalysisContext::flowConditionImplies(Atom Token,
158158
return isUnsatisfiable(std::move(Constraints));
159159
}
160160

161-
bool DataflowAnalysisContext::flowConditionIsTautology(Atom Token) {
162-
// Returns true if and only if we cannot prove that the flow condition can
163-
// ever be false.
164-
llvm::SetVector<const Formula *> Constraints;
165-
Constraints.insert(&arena().makeNot(arena().makeAtomRef(Token)));
166-
addTransitiveFlowConditionConstraints(Token, Constraints);
167-
return isUnsatisfiable(std::move(Constraints));
168-
}
169-
170161
bool DataflowAnalysisContext::equivalentFormulas(const Formula &Val1,
171162
const Formula &Val2) {
172163
llvm::SetVector<const Formula *> Constraints;

clang/lib/Format/Format.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -834,8 +834,8 @@ template <> struct MappingTraits<FormatStyle> {
834834

835835
StringRef BasedOnStyle;
836836
if (IO.outputting()) {
837-
StringRef Styles[] = {"LLVM", "Google", "Chromium", "Mozilla",
838-
"WebKit", "GNU", "Microsoft"};
837+
StringRef Styles[] = {"LLVM", "Google", "Chromium", "Mozilla",
838+
"WebKit", "GNU", "Microsoft", "clang-format"};
839839
for (StringRef StyleName : Styles) {
840840
FormatStyle PredefinedStyle;
841841
if (getPredefinedStyle(StyleName, Style.Language, &PredefinedStyle) &&
@@ -1915,6 +1915,16 @@ FormatStyle getMicrosoftStyle(FormatStyle::LanguageKind Language) {
19151915
return Style;
19161916
}
19171917

1918+
FormatStyle getClangFormatStyle() {
1919+
FormatStyle Style = getLLVMStyle();
1920+
Style.InsertBraces = true;
1921+
Style.InsertNewlineAtEOF = true;
1922+
Style.LineEnding = FormatStyle::LE_LF;
1923+
Style.RemoveBracesLLVM = true;
1924+
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
1925+
return Style;
1926+
}
1927+
19181928
FormatStyle getNoStyle() {
19191929
FormatStyle NoStyle = getLLVMStyle();
19201930
NoStyle.DisableFormat = true;
@@ -1939,6 +1949,8 @@ bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
19391949
*Style = getGNUStyle();
19401950
else if (Name.equals_insensitive("microsoft"))
19411951
*Style = getMicrosoftStyle(Language);
1952+
else if (Name.equals_insensitive("clang-format"))
1953+
*Style = getClangFormatStyle();
19421954
else if (Name.equals_insensitive("none"))
19431955
*Style = getNoStyle();
19441956
else if (Name.equals_insensitive("inheritparentconfig"))

clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,33 +99,6 @@ TEST_F(DataflowAnalysisContextTest, JoinFlowConditions) {
9999
EXPECT_TRUE(Context.flowConditionImplies(FC3, C3));
100100
}
101101

102-
TEST_F(DataflowAnalysisContextTest, FlowConditionTautologies) {
103-
// Fresh flow condition with empty/no constraints is always true.
104-
Atom FC1 = A.makeFlowConditionToken();
105-
EXPECT_TRUE(Context.flowConditionIsTautology(FC1));
106-
107-
// Literal `true` is always true.
108-
Atom FC2 = A.makeFlowConditionToken();
109-
Context.addFlowConditionConstraint(FC2, A.makeLiteral(true));
110-
EXPECT_TRUE(Context.flowConditionIsTautology(FC2));
111-
112-
// Literal `false` is never true.
113-
Atom FC3 = A.makeFlowConditionToken();
114-
Context.addFlowConditionConstraint(FC3, A.makeLiteral(false));
115-
EXPECT_FALSE(Context.flowConditionIsTautology(FC3));
116-
117-
// We can't prove that an arbitrary bool A is always true...
118-
auto &C1 = A.makeAtomRef(A.makeAtom());
119-
Atom FC4 = A.makeFlowConditionToken();
120-
Context.addFlowConditionConstraint(FC4, C1);
121-
EXPECT_FALSE(Context.flowConditionIsTautology(FC4));
122-
123-
// ... but we can prove A || !A is true.
124-
Atom FC5 = A.makeFlowConditionToken();
125-
Context.addFlowConditionConstraint(FC5, A.makeOr(C1, A.makeNot(C1)));
126-
EXPECT_TRUE(Context.flowConditionIsTautology(FC5));
127-
}
128-
129102
TEST_F(DataflowAnalysisContextTest, EquivBoolVals) {
130103
auto &X = A.makeAtomRef(A.makeAtom());
131104
auto &Y = A.makeAtomRef(A.makeAtom());

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ TEST(ConfigParseTest, GetsPredefinedStyleByName) {
6363
EXPECT_TRUE(getPredefinedStyle("gnU", FormatStyle::LK_Cpp, &Styles[2]));
6464
EXPECT_ALL_STYLES_EQUAL(Styles);
6565

66+
Styles[0] = getClangFormatStyle();
67+
EXPECT_TRUE(
68+
getPredefinedStyle("clang-format", FormatStyle::LK_Cpp, &Styles[1]));
69+
EXPECT_TRUE(
70+
getPredefinedStyle("Clang-format", FormatStyle::LK_Cpp, &Styles[2]));
71+
EXPECT_ALL_STYLES_EQUAL(Styles);
72+
6673
EXPECT_FALSE(getPredefinedStyle("qwerty", FormatStyle::LK_Cpp, &Styles[0]));
6774
}
6875

clang/utils/TableGen/SveEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class Intrinsic {
195195
ArrayRef<SVEType> getTypes() const { return Types; }
196196
SVEType getParamType(unsigned I) const { return Types[I + 1]; }
197197
unsigned getNumParams() const {
198-
return Proto.size() - (2 * std::count(Proto.begin(), Proto.end(), '.')) - 1;
198+
return Proto.size() - (2 * llvm::count(Proto, '.')) - 1;
199199
}
200200

201201
uint64_t getFlags() const { return Flags; }

flang/include/flang/Evaluate/initial-image.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Fortran::evaluate {
2222

2323
class InitialImage {
2424
public:
25-
enum Result { Ok, NotAConstant, OutOfRange, SizeMismatch };
25+
enum Result { Ok, NotAConstant, OutOfRange, SizeMismatch, LengthMismatch };
2626

2727
explicit InitialImage(std::size_t bytes) : data_(bytes) {}
2828
InitialImage(InitialImage &&that) = default;
@@ -72,7 +72,7 @@ class InitialImage {
7272
auto scalar{x.At(at)}; // this is a std string; size() in chars
7373
auto scalarBytes{scalar.size() * KIND};
7474
if (scalarBytes != elementBytes) {
75-
result = SizeMismatch;
75+
result = LengthMismatch;
7676
}
7777
// Blank padding when short
7878
for (; scalarBytes < elementBytes; scalarBytes += KIND) {

flang/lib/Semantics/data-to-inits.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,11 @@ bool DataInitializationCompiler<DSV>::InitElement(
457457
folded.AsFortran(), DescribeElement());
458458
} else if (status == evaluate::InitialImage::OutOfRange) {
459459
OutOfRangeError();
460-
} else if (status == evaluate::InitialImage::SizeMismatch) {
460+
} else if (status == evaluate::InitialImage::LengthMismatch) {
461461
exprAnalyzer_.Say(
462462
"DATA statement value '%s' for '%s' has the wrong length"_warn_en_US,
463463
folded.AsFortran(), DescribeElement());
464+
return true;
464465
} else {
465466
CHECK(exprAnalyzer_.context().AnyFatalError());
466467
}

flang/test/Semantics/data19.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
! RUN: %flang_fc1 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
2+
! Test truncation/padding in DATA statement.
3+
4+
character(len=3) :: c1, c2, c3(2), c4(2)
5+
data c1(1:2), c1(3:3) /'123', '4'/
6+
data c2(1:2), c2(3:3) /'1', '2'/
7+
data c3(:)(1:2), c3(:)(3:3) /'123', '678', '4', '9'/
8+
data c4(:)(1:2), c4(:)(3:3) /'1', '6', '2', '7'/
9+
end
10+
!CHECK: c1 (InDataStmt) size=3 offset=0: ObjectEntity type: CHARACTER(3_4,1) init:"124"
11+
!CHECK: c2 (InDataStmt) size=3 offset=3: ObjectEntity type: CHARACTER(3_4,1) init:"1 2"
12+
!CHECK: c3 (InDataStmt) size=6 offset=6: ObjectEntity type: CHARACTER(3_4,1) shape: 1_8:2_8 init:[CHARACTER(KIND=1,LEN=3)::"124","679"]
13+
!CHECK: c4 (InDataStmt) size=6 offset=12: ObjectEntity type: CHARACTER(3_4,1) shape: 1_8:2_8 init:[CHARACTER(KIND=1,LEN=3)::"1 2","6 7"]

lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@ PlatformSP PlatformAppleSimulator::CreateInstance(
335335

336336
bool create = force;
337337
if (!create && arch && arch->IsValid()) {
338-
if (std::count(supported_arch.begin(), supported_arch.end(),
339-
arch->GetMachine())) {
338+
if (llvm::is_contained(supported_arch, arch->GetMachine())) {
340339
const llvm::Triple &triple = arch->GetTriple();
341340
switch (triple.getVendor()) {
342341
case llvm::Triple::Apple:

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 478314
19+
#define LLVM_MAIN_REVISION 478325
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/TextAPI/InterfaceFile.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,8 @@ class InterfaceFile {
352352
}
353353

354354
/// Add a symbol to the symbols list or extend an existing one.
355-
template <typename RangeT,
356-
typename ElT = typename std::remove_reference<
357-
decltype(*std::begin(std::declval<RangeT>()))>::type>
355+
template <typename RangeT, typename ElT = std::remove_reference_t<
356+
decltype(*std::begin(std::declval<RangeT>()))>>
358357
void addSymbol(SymbolKind Kind, StringRef Name, RangeT &&Targets,
359358
SymbolFlags Flags = SymbolFlags::None) {
360359
SymbolsSet->addGlobal(Kind, Name, Flags, Targets);

llvm/include/llvm/TextAPI/SymbolSet.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,8 @@ class SymbolSet {
9595
const Target &Targ);
9696
size_t size() const { return Symbols.size(); }
9797

98-
template <typename RangeT,
99-
typename ElT = typename std::remove_reference<
100-
decltype(*std::begin(std::declval<RangeT>()))>::type>
98+
template <typename RangeT, typename ElT = std::remove_reference_t<
99+
decltype(*std::begin(std::declval<RangeT>()))>>
101100
Symbol *addGlobal(SymbolKind Kind, StringRef Name, SymbolFlags Flags,
102101
RangeT &&Targets) {
103102
auto *Global = addGlobalImpl(Kind, Name, Flags);

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2878,6 +2878,11 @@ bool RISCVDAGToDAGISel::hasAllNBitUsers(SDNode *Node, unsigned Bits,
28782878
if (Depth >= SelectionDAG::MaxRecursionDepth)
28792879
return false;
28802880

2881+
// The PatFrags that call this may run before RISCVGenDAGISel.inc has checked
2882+
// the VT. Ensure the type is scalar to avoid wasting time on vectors.
2883+
if (!Node->getValueType(0).isScalarInteger())
2884+
return false;
2885+
28812886
for (auto UI = Node->use_begin(), UE = Node->use_end(); UI != UE; ++UI) {
28822887
SDNode *User = *UI;
28832888
// Users of this node should have already been instruction selected

llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,8 +2093,7 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
20932093
for (auto &Edge : CallerEdges) {
20942094
// Skip any that have been removed by an earlier recursive call.
20952095
if (Edge->Callee == nullptr && Edge->Caller == nullptr) {
2096-
assert(!std::count(Node->CallerEdges.begin(), Node->CallerEdges.end(),
2097-
Edge));
2096+
assert(!llvm::count(Node->CallerEdges, Edge));
20982097
continue;
20992098
}
21002099
// Ignore any caller we previously visited via another edge.

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,16 +1047,18 @@ bool isDimSequencePreserved(AffineMap map, ReassociationIndicesRef dimSequence);
10471047
bool areDimSequencesPreserved(ArrayRef<AffineMap> maps,
10481048
ArrayRef<ReassociationIndices> dimSequences);
10491049

1050-
/// Collapses dimensions of linalg.generic operation. A precondition to
1051-
/// calling this method is that for each list in `foldedIterationDim`, the
1050+
/// Collapses dimensions of linalg.generic/linalg.copy operation. A precondition
1051+
/// to calling this method is that for each list in `foldedIterationDim`, the
10521052
/// sequence of dimensions is contiguous in domains of all `indexing_maps` of
1053-
/// the `genericOp`. This can be checked using `areDimSequencePreserved` method.
1053+
/// the `linalgOp`. This can be checked using `areDimSequencePreserved` method.
10541054
/// When valid, the method also collapses the operands of the op. Returns
1055-
/// replacement values of the results of the original `genericOp` by inserting
1055+
/// replacement values of the results of the original `linalgOp` by inserting
10561056
/// reshapes to get back values of compatible types.
1057-
FailureOr<SmallVector<Value>> collapseGenericOpIterationDims(
1058-
GenericOp genericOp, ArrayRef<ReassociationIndices> foldedIterationDims,
1059-
RewriterBase &rewriter);
1057+
template <typename LinalgType>
1058+
FailureOr<SmallVector<Value>>
1059+
collapseOpIterationDims(LinalgType op,
1060+
ArrayRef<ReassociationIndices> foldedIterationDims,
1061+
RewriterBase &rewriter);
10601062

10611063
struct LowerPackResult {
10621064
tensor::PadOp padOp;
@@ -1515,7 +1517,7 @@ void populateEraseUnnecessaryInputsPatterns(RewritePatternSet &patterns);
15151517
/// to return an array of `ReassociationIndices` representing dimensions that
15161518
/// should be merged.
15171519
using GetCollapsableDimensionsFn =
1518-
std::function<SmallVector<ReassociationIndices>(linalg::GenericOp)>;
1520+
std::function<SmallVector<ReassociationIndices>(linalg::LinalgOp)>;
15191521

15201522
/// Pattern to collapse dimensions in a linalg.generic op. This will collapse
15211523
/// tensor operands when needed and expand back the result tensors.

0 commit comments

Comments
 (0)