Skip to content

Commit 707e807

Browse files
authored
Merge branch 'main' into fix/92847
2 parents 33c24e3 + ff8f6ab commit 707e807

File tree

44 files changed

+544
-341
lines changed

Some content is hidden

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

44 files changed

+544
-341
lines changed

bolt/include/bolt/Core/BinarySection.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,9 @@ class BinarySection {
359359

360360
/// Add a new relocation at the given /p Offset.
361361
void addRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
362-
uint64_t Addend, uint64_t Value = 0,
363-
bool Pending = false) {
362+
uint64_t Addend, uint64_t Value = 0) {
364363
assert(Offset < getSize() && "offset not within section bounds");
365-
if (!Pending) {
366-
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
367-
} else {
368-
PendingRelocations.emplace_back(
369-
Relocation{Offset, Symbol, Type, Addend, Value});
370-
}
364+
Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
371365
}
372366

373367
/// Add a dynamic relocation at the given /p Offset.

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
9393
DataSize, 4);
9494
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
9595
ASSERT_TRUE(RelSymbol1);
96-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
96+
BS.addPendingRelocation(
97+
Relocation{8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0});
9798
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
9899
ASSERT_TRUE(RelSymbol2);
99-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
100+
BS.addPendingRelocation(
101+
Relocation{12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0});
100102

101-
std::error_code EC;
102103
SmallVector<char> Vect(DataSize);
103104
raw_svector_ostream OS(Vect);
104105

@@ -134,12 +135,13 @@ TEST_P(BinaryContextTester, FlushPendingRelocJUMP26) {
134135
(uint8_t *)Data, Size, 4);
135136
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
136137
ASSERT_TRUE(RelSymbol1);
137-
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0, true);
138+
BS.addPendingRelocation(
139+
Relocation{8, RelSymbol1, ELF::R_AARCH64_JUMP26, 0, 0});
138140
MCSymbol *RelSymbol2 = BC->getOrCreateGlobalSymbol(16, "Func2");
139141
ASSERT_TRUE(RelSymbol2);
140-
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0, true);
142+
BS.addPendingRelocation(
143+
Relocation{12, RelSymbol2, ELF::R_AARCH64_JUMP26, 0, 0});
141144

142-
std::error_code EC;
143145
SmallVector<char> Vect(Size);
144146
raw_svector_ostream OS(Vect);
145147

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,7 @@ def fno_objc_weak : Flag<["-"], "fno-objc-weak">, Group<f_Group>,
33973397
def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, Group<f_Group>,
33983398
Visibility<[ClangOption, FlangOption]>;
33993399
defm operator_names : BoolFOption<"operator-names",
3400-
LangOpts<"CXXOperatorNames">, Default<cplusplus.KeyPath>,
3400+
LangOpts<"CXXOperatorNames">, Default<!strconcat(cplusplus.KeyPath, " && !",hlsl.KeyPath)>,
34013401
NegFlag<SetFalse, [], [ClangOption, CC1Option],
34023402
"Do not treat C++ operator name keywords as synonyms for operators">,
34033403
PosFlag<SetTrue>>;

clang/lib/Analysis/LiveVariables.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include "clang/Analysis/AnalysisDeclContext.h"
1717
#include "clang/Analysis/CFG.h"
1818
#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
19+
#include "clang/Basic/SourceManager.h"
1920
#include "llvm/ADT/DenseMap.h"
21+
#include "llvm/ADT/STLExtras.h"
2022
#include "llvm/Support/raw_ostream.h"
2123
#include <algorithm>
2224
#include <optional>
@@ -662,12 +664,19 @@ void LiveVariables::dumpExprLiveness(const SourceManager &M) {
662664
}
663665

664666
void LiveVariablesImpl::dumpExprLiveness(const SourceManager &M) {
667+
auto ByBeginLoc = [&M](const Expr *L, const Expr *R) {
668+
return M.isBeforeInTranslationUnit(L->getBeginLoc(), R->getBeginLoc());
669+
};
670+
665671
// Don't iterate over blockEndsToLiveness directly because it's not sorted.
666672
for (const CFGBlock *B : *analysisContext.getCFG()) {
667673

668674
llvm::errs() << "\n[ B" << B->getBlockID()
669675
<< " (live expressions at block exit) ]\n";
670-
for (const Expr *E : blocksEndToLiveness[B].liveExprs) {
676+
std::vector<const Expr *> LiveExprs;
677+
llvm::append_range(LiveExprs, blocksEndToLiveness[B].liveExprs);
678+
llvm::sort(LiveExprs, ByBeginLoc);
679+
for (const Expr *E : LiveExprs) {
671680
llvm::errs() << "\n";
672681
E->dump();
673682
}

clang/lib/CodeGen/Targets/NVPTX.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,8 @@ void CodeGenModule::handleCUDALaunchBoundsAttr(llvm::Function *F,
375375
if (MinBlocks > 0) {
376376
if (MinBlocksVal)
377377
*MinBlocksVal = MinBlocks.getExtValue();
378-
if (F) {
379-
// Create !{<func-ref>, metadata !"minctasm", i32 <val>} node
380-
NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "minctasm",
381-
MinBlocks.getExtValue());
382-
}
378+
if (F)
379+
F->addFnAttr("nvvm.minctasm", llvm::utostr(MinBlocks.getExtValue()));
383380
}
384381
}
385382
if (Attr->getMaxBlocks()) {
@@ -388,11 +385,9 @@ void CodeGenModule::handleCUDALaunchBoundsAttr(llvm::Function *F,
388385
if (MaxBlocks > 0) {
389386
if (MaxClusterRankVal)
390387
*MaxClusterRankVal = MaxBlocks.getExtValue();
391-
if (F) {
392-
// Create !{<func-ref>, metadata !"maxclusterrank", i32 <val>} node
393-
NVPTXTargetCodeGenInfo::addNVVMMetadata(F, "maxclusterrank",
394-
MaxBlocks.getExtValue());
395-
}
388+
if (F)
389+
F->addFnAttr("nvvm.maxclusterrank",
390+
llvm::utostr(MaxBlocks.getExtValue()));
396391
}
397392
}
398393
}

clang/test/Analysis/live-stmts.cpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
// Flaky on aarch64: http://llvm.org/PR126619
2-
// UNSUPPORTED: target=aarch64{{.*}}
3-
41
// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
52
// RUN: | FileCheck %s
63

@@ -29,34 +26,36 @@ int testThatDumperWorks(int x, int y, int z) {
2926
// CHECK-EMPTY:
3027
// CHECK: [ B2 (live expressions at block exit) ]
3128
// CHECK-EMPTY:
32-
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
33-
// CHECK-EMPTY:
34-
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
35-
// CHECK-EMPTY:
3629
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
3730
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
3831
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
3932
// CHECK-EMPTY:
40-
// CHECK-EMPTY:
41-
// CHECK: [ B3 (live expressions at block exit) ]
42-
// CHECK-EMPTY:
4333
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
4434
// CHECK-EMPTY:
4535
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
4636
// CHECK-EMPTY:
37+
// CHECK-EMPTY:
38+
// CHECK: [ B3 (live expressions at block exit) ]
39+
// CHECK-EMPTY:
4740
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
4841
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
4942
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
50-
// CHECK: [ B4 (live expressions at block exit) ]
5143
// CHECK-EMPTY:
5244
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
5345
// CHECK-EMPTY:
5446
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
5547
// CHECK-EMPTY:
48+
// CHECK-EMPTY:
49+
// CHECK: [ B4 (live expressions at block exit) ]
50+
// CHECK-EMPTY:
5651
// CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
5752
// CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
5853
// CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
5954
// CHECK-EMPTY:
55+
// CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
56+
// CHECK-EMPTY:
57+
// CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
58+
// CHECK-EMPTY:
6059
// CHECK-EMPTY:
6160
// CHECK: [ B5 (live expressions at block exit) ]
6261
// CHECK-EMPTY:
@@ -226,15 +225,15 @@ int logicalOpInTernary(bool b) {
226225
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
227226
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
228227
// CHECK-EMPTY:
229-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
230-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
231-
// CHECK-EMPTY:
232228
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
233229
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
234230
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
235231
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
236232
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
237233
// CHECK-EMPTY:
234+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
235+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
236+
// CHECK-EMPTY:
238237
// CHECK: IntegerLiteral {{.*}} 'int' 0
239238
// CHECK-EMPTY:
240239
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -245,15 +244,15 @@ int logicalOpInTernary(bool b) {
245244
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
246245
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
247246
// CHECK-EMPTY:
248-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
249-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
250-
// CHECK-EMPTY:
251247
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
252248
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
253249
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
254250
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
255251
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
256252
// CHECK-EMPTY:
253+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
254+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
255+
// CHECK-EMPTY:
257256
// CHECK: IntegerLiteral {{.*}} 'int' 0
258257
// CHECK-EMPTY:
259258
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -264,15 +263,15 @@ int logicalOpInTernary(bool b) {
264263
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
265264
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
266265
// CHECK-EMPTY:
267-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
268-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
269-
// CHECK-EMPTY:
270266
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
271267
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
272268
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
273269
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
274270
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
275271
// CHECK-EMPTY:
272+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
273+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
274+
// CHECK-EMPTY:
276275
// CHECK: IntegerLiteral {{.*}} 'int' 0
277276
// CHECK-EMPTY:
278277
// CHECK: IntegerLiteral {{.*}} 'int' 1
@@ -283,15 +282,15 @@ int logicalOpInTernary(bool b) {
283282
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
284283
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
285284
// CHECK-EMPTY:
286-
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
287-
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
288-
// CHECK-EMPTY:
289285
// CHECK: BinaryOperator {{.*}} '_Bool' '||'
290286
// CHECK: |-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
291287
// CHECK: | `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
292288
// CHECK: `-ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
293289
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
294290
// CHECK-EMPTY:
291+
// CHECK: ImplicitCastExpr {{.*}} '_Bool' <LValueToRValue>
292+
// CHECK: `-DeclRefExpr {{.*}} '_Bool' lvalue ParmVar {{.*}} 'b' '_Bool'
293+
// CHECK-EMPTY:
295294
// CHECK: IntegerLiteral {{.*}} 'int' 0
296295
// CHECK-EMPTY:
297296
// CHECK: IntegerLiteral {{.*}} 'int' 1

0 commit comments

Comments
 (0)