Skip to content

Commit 7a55743

Browse files
authored
Merge branch 'main' into main
2 parents f3b54b0 + bd39ae6 commit 7a55743

File tree

567 files changed

+6560
-5217
lines changed

Some content is hidden

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

567 files changed

+6560
-5217
lines changed

bolt/lib/Passes/FrameOptimizer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ Error FrameOptimizerPass::runOnFunctions(BinaryContext &BC) {
224224
if (opts::FrameOptimization == FOP_NONE)
225225
return Error::success();
226226

227+
if (!BC.isX86()) {
228+
BC.errs() << "BOLT-ERROR: " << getName() << " is supported only on X86\n";
229+
exit(1);
230+
}
231+
227232
std::unique_ptr<BinaryFunctionCallGraph> CG;
228233
std::unique_ptr<FrameAnalysis> FA;
229234
std::unique_ptr<RegAnalysis> RA;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Checks that non-fully supported passes on AArch64 are handled appropriately.
2+
3+
// REQUIRES: system-linux,asserts,target=aarch64{{.*}}
4+
5+
RUN: %clang %cflags %p/../Inputs/hello.c -o %t -Wl,-q
6+
RUN: not llvm-bolt %t -o %t.bolt --frame-opt=all 2>&1 | FileCheck %s
7+
8+
CHECK: BOLT-ERROR: frame-optimizer is supported only on X86

clang-tools-extra/clangd/ConfigFragment.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,15 +315,15 @@ struct Fragment {
315315
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
316316
/// AngledHeaders), system headers use <> and non-system headers use "".
317317
/// These can match any suffix of the header file in question.
318-
/// Matching is performed against the header text, not its absolute path
318+
/// Matching is performed against the absolute path of the header
319319
/// within the project.
320320
std::vector<Located<std::string>> QuotedHeaders;
321321
/// List of regexes for headers that should always be included with a
322322
/// <>-style include. By default, and in case of a conflict with
323323
/// AngledHeaders (i.e. a header matches a regex in both QuotedHeaders and
324324
/// AngledHeaders), system headers use <> and non-system headers use "".
325325
/// These can match any suffix of the header file in question.
326-
/// Matching is performed against the header text, not its absolute path
326+
/// Matching is performed against the absolute path of the header
327327
/// within the project.
328328
std::vector<Located<std::string>> AngledHeaders;
329329
};

clang-tools-extra/clangd/Headers.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,17 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
304304
// FIXME: should we allow (some limited number of) "../header.h"?
305305
if (llvm::sys::path::is_absolute(Suggested))
306306
return std::nullopt;
307+
auto HeaderPath = llvm::sys::path::convert_to_slash(InsertedHeader.File);
307308
bool IsAngled = false;
308309
for (auto &Filter : AngledHeaders) {
309-
if (Filter(Suggested)) {
310+
if (Filter(HeaderPath)) {
310311
IsAngled = true;
311312
break;
312313
}
313314
}
314315
bool IsQuoted = false;
315316
for (auto &Filter : QuotedHeaders) {
316-
if (Filter(Suggested)) {
317+
if (Filter(HeaderPath)) {
317318
IsQuoted = true;
318319
break;
319320
}
@@ -324,7 +325,7 @@ IncludeInserter::calculateIncludePath(const HeaderFile &InsertedHeader,
324325
if (IsAngled && IsQuoted) {
325326
elog("Header '{0}' matches both quoted and angled regexes, default will "
326327
"be used.",
327-
Suggested);
328+
HeaderPath);
328329
}
329330
IsAngled = IsAngledByDefault;
330331
}

clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
938938
{
939939
Config C;
940940
C.Style.AngledHeaders.push_back(
941-
[](auto header) { return header == "bar.h"; });
941+
[](auto header) { return header.contains("bar.h"); });
942942
WithContextValue WithCfg(Config::Key, std::move(C));
943943
Results = completions(TU, Test.point(), {Sym});
944944
EXPECT_THAT(Results.Completions,
@@ -947,7 +947,7 @@ TEST(CompletionTest, IncludeInsertionRespectsQuotedAngledConfig) {
947947
{
948948
Config C;
949949
C.Style.QuotedHeaders.push_back(
950-
[](auto header) { return header == "bar.h"; });
950+
[](auto header) { return header.contains("bar.h"); });
951951
WithContextValue WithCfg(Config::Key, std::move(C));
952952
Results = completions(TU, Test.point(), {Sym});
953953
EXPECT_THAT(Results.Completions,

clang-tools-extra/clangd/unittests/HeadersTests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,17 @@ TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketed) {
344344
EXPECT_EQ(calculate(BarHeader), "<sub/bar.h>");
345345
}
346346

347+
TEST_F(HeadersTest, ShortenIncludesInSearchPathBracketedFilterByFullPath) {
348+
// The filter receives the full path of the header, so it is able to filter by
349+
// the parent directory, even if it is part of the include search path
350+
AngledHeaders.push_back([](auto Path) {
351+
llvm::Regex Pattern("sub/.*");
352+
return Pattern.match(Path);
353+
});
354+
std::string BarHeader = testPath("sub/bar.h");
355+
EXPECT_EQ(calculate(BarHeader), "<bar.h>");
356+
}
357+
347358
TEST_F(HeadersTest, ShortenedIncludeNotInSearchPath) {
348359
std::string BarHeader =
349360
llvm::sys::path::convert_to_slash(testPath("sub-2/bar.h"));

clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct Header {
136136
}
137137
StringRef verbatim() const { return std::get<Verbatim>(Storage); }
138138

139-
/// For phiscal files, either absolute path or path relative to the execution
139+
/// For physical files, either absolute path or path relative to the execution
140140
/// root. Otherwise just the spelling without surrounding quotes/brackets.
141141
llvm::StringRef resolvedPath() const;
142142

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5985,8 +5985,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
59855985

59865986
// Create a temporary array to hold the sizes of local pointer arguments
59875987
// for the block. \p First is the position of the first size argument.
5988-
auto CreateArrayForSizeVar = [=](unsigned First)
5989-
-> std::tuple<llvm::Value *, llvm::Value *, llvm::Value *> {
5988+
auto CreateArrayForSizeVar =
5989+
[=](unsigned First) -> std::pair<llvm::Value *, llvm::Value *> {
59905990
llvm::APInt ArraySize(32, NumArgs - First);
59915991
QualType SizeArrayTy = getContext().getConstantArrayType(
59925992
getContext().getSizeType(), ArraySize, nullptr,
@@ -5999,9 +5999,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
59995999
// actually the Alloca ascasted to the default AS, hence the
60006000
// stripPointerCasts()
60016001
llvm::Value *Alloca = TmpPtr->stripPointerCasts();
6002-
llvm::Value *TmpSize = EmitLifetimeStart(
6003-
CGM.getDataLayout().getTypeAllocSize(Tmp.getElementType()), Alloca);
60046002
llvm::Value *ElemPtr;
6003+
EmitLifetimeStart(Alloca);
60056004
// Each of the following arguments specifies the size of the corresponding
60066005
// argument passed to the enqueued block.
60076006
auto *Zero = llvm::ConstantInt::get(IntTy, 0);
@@ -6018,7 +6017,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
60186017
}
60196018
// Return the Alloca itself rather than a potential ascast as this is only
60206019
// used by the paired EmitLifetimeEnd.
6021-
return {ElemPtr, TmpSize, Alloca};
6020+
return {ElemPtr, Alloca};
60226021
};
60236022

60246023
// Could have events and/or varargs.
@@ -6030,7 +6029,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
60306029
llvm::Value *Kernel =
60316030
Builder.CreatePointerCast(Info.KernelHandle, GenericVoidPtrTy);
60326031
auto *Block = Builder.CreatePointerCast(Info.BlockArg, GenericVoidPtrTy);
6033-
auto [ElemPtr, TmpSize, TmpPtr] = CreateArrayForSizeVar(4);
6032+
auto [ElemPtr, TmpPtr] = CreateArrayForSizeVar(4);
60346033

60356034
// Create a vector of the arguments, as well as a constant value to
60366035
// express to the runtime the number of variadic arguments.
@@ -6045,8 +6044,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
60456044
llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, ArgTys, false);
60466045
auto Call = RValue::get(
60476046
EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
6048-
if (TmpSize)
6049-
EmitLifetimeEnd(TmpSize, TmpPtr);
6047+
EmitLifetimeEnd(TmpPtr);
60506048
return Call;
60516049
}
60526050
// Any calls now have event arguments passed.
@@ -6111,15 +6109,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
61116109
ArgTys.push_back(Int32Ty);
61126110
Name = "__enqueue_kernel_events_varargs";
61136111

6114-
auto [ElemPtr, TmpSize, TmpPtr] = CreateArrayForSizeVar(7);
6112+
auto [ElemPtr, TmpPtr] = CreateArrayForSizeVar(7);
61156113
Args.push_back(ElemPtr);
61166114
ArgTys.push_back(ElemPtr->getType());
61176115

61186116
llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, ArgTys, false);
61196117
auto Call = RValue::get(
61206118
EmitRuntimeCall(CGM.CreateRuntimeFunction(FTy, Name), Args));
6121-
if (TmpSize)
6122-
EmitLifetimeEnd(TmpSize, TmpPtr);
6119+
EmitLifetimeEnd(TmpPtr);
61236120
return Call;
61246121
}
61256122
llvm_unreachable("Unexpected enqueue_kernel signature");

clang/lib/CodeGen/CGCall.cpp

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4319,10 +4319,7 @@ static void emitWriteback(CodeGenFunction &CGF,
43194319

43204320
if (writeback.WritebackExpr) {
43214321
CGF.EmitIgnoredExpr(writeback.WritebackExpr);
4322-
4323-
if (writeback.LifetimeSz)
4324-
CGF.EmitLifetimeEnd(writeback.LifetimeSz,
4325-
writeback.Temporary.getBasePointer());
4322+
CGF.EmitLifetimeEnd(writeback.Temporary.getBasePointer());
43264323
return;
43274324
}
43284325

@@ -5282,7 +5279,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
52825279
// If the call returns a temporary with struct return, create a temporary
52835280
// alloca to hold the result, unless one is given to us.
52845281
Address SRetPtr = Address::invalid();
5285-
llvm::Value *UnusedReturnSizePtr = nullptr;
5282+
bool NeedSRetLifetimeEnd = false;
52865283
if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
52875284
// For virtual function pointer thunks and musttail calls, we must always
52885285
// forward an incoming SRet pointer to the callee, because a local alloca
@@ -5296,11 +5293,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
52965293
SRetPtr = ReturnValue.getAddress();
52975294
} else {
52985295
SRetPtr = CreateMemTempWithoutCast(RetTy, "tmp");
5299-
if (HaveInsertPoint() && ReturnValue.isUnused()) {
5300-
llvm::TypeSize size =
5301-
CGM.getDataLayout().getTypeAllocSize(ConvertTypeForMem(RetTy));
5302-
UnusedReturnSizePtr = EmitLifetimeStart(size, SRetPtr.getBasePointer());
5303-
}
5296+
if (HaveInsertPoint() && ReturnValue.isUnused())
5297+
NeedSRetLifetimeEnd = EmitLifetimeStart(SRetPtr.getBasePointer());
53045298
}
53055299
if (IRFunctionArgs.hasSRetArg()) {
53065300
// A mismatch between the allocated return value's AS and the target's
@@ -5484,15 +5478,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
54845478
Val = Builder.CreateFreeze(Val);
54855479
IRCallArgs[FirstIRArg] = Val;
54865480

5487-
// Emit lifetime markers for the temporary alloca.
5488-
llvm::TypeSize ByvalTempElementSize =
5489-
CGM.getDataLayout().getTypeAllocSize(AI.getElementType());
5490-
llvm::Value *LifetimeSize =
5491-
EmitLifetimeStart(ByvalTempElementSize, AI.getPointer());
5492-
5493-
// Add cleanup code to emit the end lifetime marker after the call.
5494-
if (LifetimeSize) // In case we disabled lifetime markers.
5495-
CallLifetimeEndAfterCall.emplace_back(AI, LifetimeSize);
5481+
// Emit lifetime markers for the temporary alloca and add cleanup code to
5482+
// emit the end lifetime marker after the call.
5483+
if (EmitLifetimeStart(AI.getPointer()))
5484+
CallLifetimeEndAfterCall.emplace_back(AI);
54965485

54975486
// Generate the copy.
54985487
I->copyInto(*this, AI);
@@ -5653,9 +5642,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
56535642
auto unpaddedCoercionType = ArgInfo.getUnpaddedCoerceAndExpandType();
56545643
auto *unpaddedStruct = dyn_cast<llvm::StructType>(unpaddedCoercionType);
56555644

5656-
llvm::Value *tempSize = nullptr;
56575645
Address addr = Address::invalid();
56585646
RawAddress AllocaAddr = RawAddress::invalid();
5647+
bool NeedLifetimeEnd = false;
56595648
if (I->isAggregate()) {
56605649
addr = I->hasLValue() ? I->getKnownLValue().getAddress()
56615650
: I->getKnownRValue().getAggregateAddress();
@@ -5665,7 +5654,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
56655654
assert(RV.isScalar()); // complex should always just be direct
56665655

56675656
llvm::Type *scalarType = RV.getScalarVal()->getType();
5668-
auto scalarSize = CGM.getDataLayout().getTypeAllocSize(scalarType);
56695657
auto scalarAlign = CGM.getDataLayout().getPrefTypeAlign(scalarType);
56705658

56715659
// Materialize to a temporary.
@@ -5674,7 +5662,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
56745662
layout->getAlignment(), scalarAlign)),
56755663
"tmp",
56765664
/*ArraySize=*/nullptr, &AllocaAddr);
5677-
tempSize = EmitLifetimeStart(scalarSize, AllocaAddr.getPointer());
5665+
NeedLifetimeEnd = EmitLifetimeStart(AllocaAddr.getPointer());
56785666

56795667
Builder.CreateStore(RV.getScalarVal(), addr);
56805668
}
@@ -5699,10 +5687,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
56995687
}
57005688
assert(IRArgPos == FirstIRArg + NumIRArgs);
57015689

5702-
if (tempSize) {
5703-
EmitLifetimeEnd(tempSize, AllocaAddr.getPointer());
5704-
}
5705-
5690+
if (NeedLifetimeEnd)
5691+
EmitLifetimeEnd(AllocaAddr.getPointer());
57065692
break;
57075693
}
57085694

@@ -5871,9 +5857,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
58715857
// can't depend on being inside of an ExprWithCleanups, so we need to manually
58725858
// pop this cleanup later on. Being eager about this is OK, since this
58735859
// temporary is 'invisible' outside of the callee.
5874-
if (UnusedReturnSizePtr)
5875-
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetPtr,
5876-
UnusedReturnSizePtr);
5860+
if (NeedSRetLifetimeEnd)
5861+
pushFullExprCleanup<CallLifetimeEnd>(NormalEHLifetimeMarker, SRetPtr);
58775862

58785863
llvm::BasicBlock *InvokeDest = CannotThrow ? nullptr : getInvokeDest();
58795864

@@ -6007,7 +5992,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
60075992
// insertion point; this allows the rest of IRGen to discard
60085993
// unreachable code.
60095994
if (CI->doesNotReturn()) {
6010-
if (UnusedReturnSizePtr)
5995+
if (NeedSRetLifetimeEnd)
60115996
PopCleanupBlock();
60125997

60135998
// Strip away the noreturn attribute to better diagnose unreachable UB.
@@ -6122,7 +6107,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
61226107
case ABIArgInfo::InAlloca:
61236108
case ABIArgInfo::Indirect: {
61246109
RValue ret = convertTempToRValue(SRetPtr, RetTy, SourceLocation());
6125-
if (UnusedReturnSizePtr)
6110+
if (NeedSRetLifetimeEnd)
61266111
PopCleanupBlock();
61276112
return ret;
61286113
}

clang/lib/CodeGen/CGCall.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,6 @@ class CallArgList : public SmallVector<CallArg, 8> {
289289
/// An Expression (optional) that performs the writeback with any required
290290
/// casting.
291291
const Expr *WritebackExpr;
292-
293-
// Size for optional lifetime end on the temporary.
294-
llvm::Value *LifetimeSz;
295292
};
296293

297294
struct CallArgCleanup {
@@ -321,9 +318,8 @@ class CallArgList : public SmallVector<CallArg, 8> {
321318
}
322319

323320
void addWriteback(LValue srcLV, Address temporary, llvm::Value *toUse,
324-
const Expr *writebackExpr = nullptr,
325-
llvm::Value *lifetimeSz = nullptr) {
326-
Writeback writeback = {srcLV, temporary, toUse, writebackExpr, lifetimeSz};
321+
const Expr *writebackExpr = nullptr) {
322+
Writeback writeback = {srcLV, temporary, toUse, writebackExpr};
327323
Writebacks.push_back(writeback);
328324
}
329325

0 commit comments

Comments
 (0)