Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: Ia46b5c23e20089685c7c79db1e3207231ecc77bc
  • Loading branch information
Jenkins committed Nov 24, 2024
2 parents 3953171 + c4d656a commit d12b14c
Show file tree
Hide file tree
Showing 26 changed files with 285 additions and 80 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Analysis/ExprMutationAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ ExprMutationAnalyzer::Analyzer::findPointeeMutation(const Decl *Dec) {
const Stmt *ExprMutationAnalyzer::Analyzer::findMutationMemoized(
const Expr *Exp, llvm::ArrayRef<MutationFinder> Finders,
Memoized::ResultMap &MemoizedResults) {
// Assume Exp is not mutated before analyzing Exp.
auto [Memoized, Inserted] = MemoizedResults.try_emplace(Exp);
if (!Inserted)
return Memoized->second;

// Assume Exp is not mutated before analyzing Exp.
if (isUnevaluated(Exp))
return nullptr;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ StmtResult Parser::ParseLabeledStatement(ParsedAttributes &Attrs,
}

// If we've not parsed a statement yet, parse one now.
if (!SubStmt.isInvalid() && !SubStmt.isUsable())
if (SubStmt.isUnset())
SubStmt = ParseStatement(nullptr, StmtCtx);

// Broken substmt shouldn't prevent the label from being added to the AST.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DeadlockDetectorTLS {
u32 lock;
u32 stk;
};
LockWithContext all_locks_with_contexts_[64];
LockWithContext all_locks_with_contexts_[128];
uptr n_all_locks_;
};

Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,8 @@ void CheckUnwind() {
thr->ignore_reads_and_writes++;
atomic_store_relaxed(&thr->in_signal_handler, 0);
#endif
PrintCurrentStackSlow(StackTrace::GetCurrentPc());
PrintCurrentStack(StackTrace::GetCurrentPc(),
common_flags()->fast_unwind_on_fatal);
}

bool is_initialized;
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/tsan/rtl/tsan_rtl.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ bool IsExpectedReport(uptr addr, uptr size);
StackID CurrentStackId(ThreadState *thr, uptr pc);
ReportStack *SymbolizeStackId(StackID stack_id);
void PrintCurrentStack(ThreadState *thr, uptr pc);
void PrintCurrentStackSlow(uptr pc); // uses libunwind
void PrintCurrentStack(uptr pc, bool fast); // may uses libunwind
MBlock *JavaHeapBlock(uptr addr, uptr *start);

void Initialize(ThreadState *thr);
Expand Down
10 changes: 5 additions & 5 deletions compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,18 +828,18 @@ void PrintCurrentStack(ThreadState *thr, uptr pc) {
PrintStack(SymbolizeStack(trace));
}

// Always inlining PrintCurrentStackSlow, because LocatePcInTrace assumes
// Always inlining PrintCurrentStack, because LocatePcInTrace assumes
// __sanitizer_print_stack_trace exists in the actual unwinded stack, but
// tail-call to PrintCurrentStackSlow breaks this assumption because
// tail-call to PrintCurrentStack breaks this assumption because
// __sanitizer_print_stack_trace disappears after tail-call.
// However, this solution is not reliable enough, please see dvyukov's comment
// http://reviews.llvm.org/D19148#406208
// Also see PR27280 comment 2 and 3 for breaking examples and analysis.
ALWAYS_INLINE USED void PrintCurrentStackSlow(uptr pc) {
ALWAYS_INLINE USED void PrintCurrentStack(uptr pc, bool fast) {
#if !SANITIZER_GO
uptr bp = GET_CURRENT_FRAME();
auto *ptrace = New<BufferedStackTrace>();
ptrace->Unwind(pc, bp, nullptr, false);
ptrace->Unwind(pc, bp, nullptr, fast);

for (uptr i = 0; i < ptrace->size / 2; i++) {
uptr tmp = ptrace->trace_buffer[i];
Expand All @@ -857,6 +857,6 @@ using namespace __tsan;
extern "C" {
SANITIZER_INTERFACE_ATTRIBUTE
void __sanitizer_print_stack_trace() {
PrintCurrentStackSlow(StackTrace::GetCurrentPc());
PrintCurrentStack(StackTrace::GetCurrentPc(), false);
}
} // extern "C"
21 changes: 21 additions & 0 deletions compiler-rt/test/tsan/many_held_mutex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// RUN: %clangxx_tsan -O1 %s %link_libcxx_tsan -fsanitize=thread -o %t
// RUN: %run %t 128

#include <mutex>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
int num_of_mtx = std::atoi(argv[1]);

std::vector<std::mutex> mutexes(num_of_mtx);

for (auto &mu : mutexes) {
mu.lock();
}
for (auto &mu : mutexes) {
mu.unlock();
}

return 0;
}
2 changes: 2 additions & 0 deletions lld/Common/ErrorHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ void ErrorHandler::fatal(const Twine &msg) {
SyncStream::~SyncStream() {
os.flush();
switch (level) {
case DiagLevel::None:
break;
case DiagLevel::Log:
e.log(buf);
break;
Expand Down
78 changes: 39 additions & 39 deletions lld/ELF/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2715,21 +2715,6 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
ctx.symtab->wrap(w.sym, w.real, w.wrap);
}

static void reportMissingFeature(Ctx &ctx, StringRef config,
const Twine &report) {
if (config == "error")
ErrAlways(ctx) << report;
else if (config == "warning")
Warn(ctx) << report;
}

static void checkAndReportMissingFeature(Ctx &ctx, StringRef config,
uint32_t features, uint32_t mask,
const Twine &report) {
if (!(features & mask))
reportMissingFeature(ctx, config, report);
}

// To enable CET (x86's hardware-assisted control flow enforcement), each
// source file must be compiled with -fcf-protection. Object files compiled
// with the flag contain feature flags indicating that they are compatible
Expand Down Expand Up @@ -2762,28 +2747,43 @@ static void readSecurityNotes(Ctx &ctx) {
bool hasValidPauthAbiCoreInfo = llvm::any_of(
ctx.aarch64PauthAbiCoreInfo, [](uint8_t c) { return c != 0; });

auto report = [&](StringRef config) -> ELFSyncStream {
if (config == "error")
return {ctx, DiagLevel::Err};
else if (config == "warning")
return {ctx, DiagLevel::Warn};
return {ctx, DiagLevel::None};
};
auto reportUnless = [&](StringRef config, bool cond) -> ELFSyncStream {
if (cond)
return {ctx, DiagLevel::None};
return report(config);
};
for (ELFFileBase *f : ctx.objectFiles) {
uint32_t features = f->andFeatures;

checkAndReportMissingFeature(
ctx, ctx.arg.zBtiReport, features, GNU_PROPERTY_AARCH64_FEATURE_1_BTI,
toStr(ctx, f) + ": -z bti-report: file does not have "
"GNU_PROPERTY_AARCH64_FEATURE_1_BTI property");

checkAndReportMissingFeature(
ctx, ctx.arg.zGcsReport, features, GNU_PROPERTY_AARCH64_FEATURE_1_GCS,
toStr(ctx, f) + ": -z gcs-report: file does not have "
"GNU_PROPERTY_AARCH64_FEATURE_1_GCS property");

checkAndReportMissingFeature(
ctx, ctx.arg.zCetReport, features, GNU_PROPERTY_X86_FEATURE_1_IBT,
toStr(ctx, f) + ": -z cet-report: file does not have "
"GNU_PROPERTY_X86_FEATURE_1_IBT property");

checkAndReportMissingFeature(
ctx, ctx.arg.zCetReport, features, GNU_PROPERTY_X86_FEATURE_1_SHSTK,
toStr(ctx, f) + ": -z cet-report: file does not have "
"GNU_PROPERTY_X86_FEATURE_1_SHSTK property");
reportUnless(ctx.arg.zBtiReport,
features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
<< f
<< ": -z bti-report: file does not have "
"GNU_PROPERTY_AARCH64_FEATURE_1_BTI property";

reportUnless(ctx.arg.zGcsReport,
features & GNU_PROPERTY_AARCH64_FEATURE_1_GCS)
<< f
<< ": -z gcs-report: file does not have "
"GNU_PROPERTY_AARCH64_FEATURE_1_GCS property";

reportUnless(ctx.arg.zCetReport, features & GNU_PROPERTY_X86_FEATURE_1_IBT)
<< f
<< ": -z cet-report: file does not have "
"GNU_PROPERTY_X86_FEATURE_1_IBT property";

reportUnless(ctx.arg.zCetReport,
features & GNU_PROPERTY_X86_FEATURE_1_SHSTK)
<< f
<< ": -z cet-report: file does not have "
"GNU_PROPERTY_X86_FEATURE_1_SHSTK property";

if (ctx.arg.zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
Expand Down Expand Up @@ -2813,11 +2813,11 @@ static void readSecurityNotes(Ctx &ctx) {
continue;

if (f->aarch64PauthAbiCoreInfo.empty()) {
reportMissingFeature(ctx, ctx.arg.zPauthReport,
toStr(ctx, f) +
": -z pauth-report: file does not have AArch64 "
"PAuth core info while '" +
referenceFileName + "' has one");
report(ctx.arg.zPauthReport)
<< f
<< ": -z pauth-report: file does not have AArch64 "
"PAuth core info while '"
<< referenceFileName << "' has one";
continue;
}

Expand Down
2 changes: 2 additions & 0 deletions lld/ELF/InputSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ class PotentialSpillSection : public InputSection {
}
};

#ifndef _WIN32
static_assert(sizeof(InputSection) <= 152, "InputSection is too big");
#endif

class SyntheticSection : public InputSection {
public:
Expand Down
2 changes: 1 addition & 1 deletion lld/include/lld/Common/ErrorHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void message(const Twine &msg, llvm::raw_ostream &s = outs());
void warn(const Twine &msg);
uint64_t errorCount();

enum class DiagLevel { Log, Msg, Warn, Err, Fatal };
enum class DiagLevel { None, Log, Msg, Warn, Err, Fatal };

// A class that synchronizes thread writing to the same stream similar
// std::osyncstream.
Expand Down
7 changes: 7 additions & 0 deletions llvm/include/llvm/Target/TargetSelectionDAG.td
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ def SDTIntBinOp : SDTypeProfile<1, 2, [ // add, and, or, xor, udiv, etc.
def SDTIntShiftOp : SDTypeProfile<1, 2, [ // shl, sra, srl
SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisInt<2>
]>;
def SDTIntShiftPairOp : SDTypeProfile<2, 3, [ // shl_parts, sra_parts, srl_parts
SDTCisInt<0>, SDTCisSameAs<1, 0>,
SDTCisSameAs<2, 0>, SDTCisSameAs<3, 0>, SDTCisInt<4>
]>;
def SDTIntShiftDOp: SDTypeProfile<1, 3, [ // fshl, fshr
SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>, SDTCisInt<3>
]>;
Expand Down Expand Up @@ -422,6 +426,9 @@ def sra : SDNode<"ISD::SRA" , SDTIntShiftOp>;
def shl : SDNode<"ISD::SHL" , SDTIntShiftOp>;
def rotl : SDNode<"ISD::ROTL" , SDTIntShiftOp>;
def rotr : SDNode<"ISD::ROTR" , SDTIntShiftOp>;
def shl_parts : SDNode<"ISD::SHL_PARTS" , SDTIntShiftPairOp>;
def sra_parts : SDNode<"ISD::SRA_PARTS" , SDTIntShiftPairOp>;
def srl_parts : SDNode<"ISD::SRL_PARTS" , SDTIntShiftPairOp>;
def fshl : SDNode<"ISD::FSHL" , SDTIntShiftDOp>;
def fshr : SDNode<"ISD::FSHR" , SDTIntShiftDOp>;
def and : SDNode<"ISD::AND" , SDTIntBinOp,
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ def AMDGPUtc_return_chain: SDNode<"AMDGPUISD::TC_RETURN_CHAIN",
>;

def AMDGPUtrap : SDNode<"AMDGPUISD::TRAP",
SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>,
[SDNPHasChain, SDNPVariadic, SDNPSideEffect, SDNPInGlue]
SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>,
[SDNPHasChain, SDNPVariadic, SDNPSideEffect, SDNPOptInGlue]
>;

def AMDGPUconstdata_ptr : SDNode<
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/AVR/AVRInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def AVRasrbn : SDNode<"AVRISD::ASRBN", SDTIntBinOp>;
def AVRlslwn : SDNode<"AVRISD::LSLWN", SDTIntBinOp>;
def AVRlsrwn : SDNode<"AVRISD::LSRWN", SDTIntBinOp>;
def AVRasrwn : SDNode<"AVRISD::ASRWN", SDTIntBinOp>;
def AVRlslw : SDNode<"AVRISD::LSLW", SDTIntShiftDOp>;
def AVRlsrw : SDNode<"AVRISD::LSRW", SDTIntShiftDOp>;
def AVRasrw : SDNode<"AVRISD::ASRW", SDTIntShiftDOp>;
def AVRlslw : SDNode<"AVRISD::LSLW", SDTIntShiftPairOp>;
def AVRlsrw : SDNode<"AVRISD::LSRW", SDTIntShiftPairOp>;
def AVRasrw : SDNode<"AVRISD::ASRW", SDTIntShiftPairOp>;

// Pseudo shift nodes for non-constant shift amounts.
def AVRlslLoop : SDNode<"AVRISD::LSLLOOP", SDTIntShiftOp>;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ModuleSanitizerCoverage {
void InjectTraceForSwitch(Function &F,
ArrayRef<Instruction *> SwitchTraceTargets);
bool InjectCoverage(Function &F, ArrayRef<BasicBlock *> AllBlocks,
bool IsLeafFunc = true);
bool IsLeafFunc);
GlobalVariable *CreateFunctionLocalArrayInSection(size_t NumElements,
Function &F, Type *Ty,
const char *Section);
Expand All @@ -254,7 +254,7 @@ class ModuleSanitizerCoverage {
Instruction *I);
Value *CreateFunctionLocalGateCmp(IRBuilder<> &IRB);
void InjectCoverageAtBlock(Function &F, BasicBlock &BB, size_t Idx,
Value *&FunctionGateCmp, bool IsLeafFunc = true);
Value *&FunctionGateCmp, bool IsLeafFunc);
Function *CreateInitCallsForSections(Module &M, const char *CtorName,
const char *InitFunctionName, Type *Ty,
const char *Section);
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/Hexagon/widen-not-load.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; Test that double word post increment load is not generated.
; REQUIRES: asserts

; RUN: llc -march=hexagon -O2 -debug-only=hexagon-load-store-widening %s -o 2>&1 - | FileCheck %s

Expand Down
32 changes: 17 additions & 15 deletions mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
type.isVarArg());
});

// Helper function that checks if the given value range is a bare pointer.
auto isBarePointer = [](ValueRange values) {
return values.size() == 1 &&
isa<LLVM::LLVMPointerType>(values.front().getType());
};

// Argument materializations convert from the new block argument types
// (multiple SSA values that make up a memref descriptor) back to the
// original block argument type. The dialect conversion framework will then
Expand All @@ -161,11 +167,10 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
addArgumentMaterialization([&](OpBuilder &builder,
UnrankedMemRefType resultType,
ValueRange inputs, Location loc) {
if (inputs.size() == 1) {
// Bare pointers are not supported for unranked memrefs because a
// memref descriptor cannot be built just from a bare pointer.
// Note: Bare pointers are not supported for unranked memrefs because a
// memref descriptor cannot be built just from a bare pointer.
if (TypeRange(inputs) != getUnrankedMemRefDescriptorFields())
return Value();
}
Value desc =
UnrankedMemRefDescriptor::pack(builder, loc, *this, resultType, inputs);
// An argument materialization must return a value of type
Expand All @@ -177,20 +182,17 @@ LLVMTypeConverter::LLVMTypeConverter(MLIRContext *ctx,
addArgumentMaterialization([&](OpBuilder &builder, MemRefType resultType,
ValueRange inputs, Location loc) {
Value desc;
if (inputs.size() == 1) {
// This is a bare pointer. We allow bare pointers only for function entry
// blocks.
BlockArgument barePtr = dyn_cast<BlockArgument>(inputs.front());
if (!barePtr)
return Value();
Block *block = barePtr.getOwner();
if (!block->isEntryBlock() ||
!isa<FunctionOpInterface>(block->getParentOp()))
return Value();
if (isBarePointer(inputs)) {
desc = MemRefDescriptor::fromStaticShape(builder, loc, *this, resultType,
inputs[0]);
} else {
} else if (TypeRange(inputs) ==
getMemRefDescriptorFields(resultType,
/*unpackAggregates=*/true)) {
desc = MemRefDescriptor::pack(builder, loc, *this, resultType, inputs);
} else {
// The inputs are neither a bare pointer nor an unpacked memref
// descriptor. This materialization function cannot be used.
return Value();
}
// An argument materialization must return a value of type `resultType`,
// so insert a cast from the memref descriptor type (!llvm.struct) to the
Expand Down
Loading

0 comments on commit d12b14c

Please sign in to comment.