Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from llvm:master #32

Merged
merged 9 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions lldb/packages/Python/lldbsuite/test/attic/dotest.pl

This file was deleted.

149 changes: 0 additions & 149 deletions lldb/packages/Python/lldbsuite/test/attic/tester.py

This file was deleted.

38 changes: 33 additions & 5 deletions lldb/source/Plugins/InstrumentationRuntime/TSan/TSanRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ extern "C"
// TODO: dlsym won't work on Windows.
void *dlsym(void* handle, const char* symbol);
int (*ptr__tsan_get_report_loc_object_type)(void *report, unsigned long idx, const char **object_type);
int (*ptr__tsan_get_report_tag)(void *report, unsigned long *tag);
}

const int REPORT_TRACE_SIZE = 128;
Expand All @@ -97,6 +98,7 @@ struct data {
void *report;
const char *description;
int report_count;
unsigned long tag;

void *sleep_trace[REPORT_TRACE_SIZE];

Expand Down Expand Up @@ -163,10 +165,14 @@ const char *thread_sanitizer_retrieve_report_data_command = R"(
data t = {0};

ptr__tsan_get_report_loc_object_type = (typeof(ptr__tsan_get_report_loc_object_type))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_loc_object_type");
ptr__tsan_get_report_tag = (typeof(ptr__tsan_get_report_tag))(void *)dlsym((void*)-2 /*RTLD_DEFAULT*/, "__tsan_get_report_tag");

t.report = __tsan_get_current_report();
__tsan_get_report_data(t.report, &t.description, &t.report_count, &t.stack_count, &t.mop_count, &t.loc_count, &t.mutex_count, &t.thread_count, &t.unique_tid_count, t.sleep_trace, REPORT_TRACE_SIZE);

if (ptr__tsan_get_report_tag)
ptr__tsan_get_report_tag(t.report, &t.tag);

if (t.stack_count > REPORT_ARRAY_SIZE) t.stack_count = REPORT_ARRAY_SIZE;
for (int i = 0; i < t.stack_count; i++) {
t.stacks[i].idx = i;
Expand Down Expand Up @@ -347,6 +353,9 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
->GetValueAsUnsigned(0));
dict->AddItem("sleep_trace", StructuredData::ObjectSP(CreateStackTrace(
main_value, ".sleep_trace")));
dict->AddIntegerItem(
"tag",
main_value->GetValueForExpressionPath(".tag")->GetValueAsUnsigned(0));

StructuredData::Array *stacks = ConvertToStructuredArray(
main_value, ".stacks", ".stack_count",
Expand Down Expand Up @@ -485,8 +494,8 @@ ThreadSanitizerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
return StructuredData::ObjectSP(dict);
}

std::string
ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
std::string ThreadSanitizerRuntime::FormatDescription(
StructuredData::ObjectSP report, bool &is_swift_access_race) {
std::string description = report->GetAsDictionary()
->GetValueForKey("issue_type")
->GetAsString()
Expand Down Expand Up @@ -521,8 +530,18 @@ ThreadSanitizerRuntime::FormatDescription(StructuredData::ObjectSP report) {
} else if (description == "lock-order-inversion") {
return "Lock order inversion (potential deadlock)";
} else if (description == "external-race") {
auto tag = report->GetAsDictionary()
->GetValueForKey("tag")
->GetAsInteger()
->GetValue();
static const unsigned long kSwiftAccessRaceTag = 0x1;
if (tag == kSwiftAccessRaceTag) {
is_swift_access_race = true;
return "Swift access race";
}
return "Race on a library object";
} else if (description == "swift-access-race") {
is_swift_access_race = true;
return "Swift access race";
}

Expand Down Expand Up @@ -616,9 +635,14 @@ ThreadSanitizerRuntime::GenerateSummary(StructuredData::ObjectSP report) {
->GetValueForKey("description")
->GetAsString()
->GetValue();
bool is_swift_access_race = report->GetAsDictionary()
->GetValueForKey("is_swift_access_race")
->GetAsBoolean()
->GetValue();

bool skip_one_frame =
report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
"external-race";
(report->GetObjectForDotSeparatedPath("issue_type")->GetStringValue() ==
"external-race") && (!is_swift_access_race);

addr_t pc = 0;
if (report->GetAsDictionary()
Expand Down Expand Up @@ -810,8 +834,12 @@ bool ThreadSanitizerRuntime::NotifyBreakpointHit(
instance->RetrieveReportData(context->exe_ctx_ref);
std::string stop_reason_description;
if (report) {
std::string issue_description = instance->FormatDescription(report);
bool is_swift_access_race = false;
std::string issue_description =
instance->FormatDescription(report, is_swift_access_race);
report->GetAsDictionary()->AddStringItem("description", issue_description);
report->GetAsDictionary()->AddBooleanItem("is_swift_access_race",
is_swift_access_race);
stop_reason_description = issue_description + " detected";
report->GetAsDictionary()->AddStringItem("stop_description",
stop_reason_description);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class ThreadSanitizerRuntime : public lldb_private::InstrumentationRuntime {

StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);

std::string FormatDescription(StructuredData::ObjectSP report);
std::string FormatDescription(StructuredData::ObjectSP report,
bool &is_swift_access_race);

std::string GenerateSummary(StructuredData::ObjectSP report);

Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ enum {
/// - Expected Intrinsic ID
GIM_CheckIntrinsicID,

/// Check the operand is a specific predicate
/// - InsnID - Instruction ID
/// - OpIdx - Operand index
/// - Expected predicate
GIM_CheckCmpPredicate,

/// Check the specified operand is an MBB
/// - InsnID - Instruction ID
/// - OpIdx - Operand index
Expand Down
16 changes: 15 additions & 1 deletion llvm/include/llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,21 @@ bool InstructionSelector::executeMatchTable(
return false;
break;
}

case GIM_CheckCmpPredicate: {
int64_t InsnID = MatchTable[CurrentIdx++];
int64_t OpIdx = MatchTable[CurrentIdx++];
int64_t Value = MatchTable[CurrentIdx++];
DEBUG_WITH_TYPE(TgtInstructionSelector::getName(),
dbgs() << CurrentIdx << ": GIM_CheckCmpPredicate(MIs["
<< InsnID << "]->getOperand(" << OpIdx
<< "), Value=" << Value << ")\n");
assert(State.MIs[InsnID] != nullptr && "Used insn before defined");
MachineOperand &MO = State.MIs[InsnID]->getOperand(OpIdx);
if (!MO.isPredicate() || MO.getPredicate() != Value)
if (handleReject() == RejectAndGiveUp)
return false;
break;
}
case GIM_CheckIsMBB: {
int64_t InsnID = MatchTable[CurrentIdx++];
int64_t OpIdx = MatchTable[CurrentIdx++];
Expand Down
9 changes: 9 additions & 0 deletions llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ class GINodeEquiv<Instruction i, SDNode node> {
// depending on the predicates on the node.
Instruction IfSignExtend = ?;
Instruction IfZeroExtend = ?;

// SelectionDAG has one setcc for all compares. This differentiates
// for G_ICMP and G_FCMP.
Instruction IfFloatingPoint = ?;
}

// These are defined in the same order as the G_* instructions.
Expand Down Expand Up @@ -122,6 +126,11 @@ def : GINodeEquiv<G_LOAD, ld> {
let IfSignExtend = G_SEXTLOAD;
let IfZeroExtend = G_ZEXTLOAD;
}

def : GINodeEquiv<G_ICMP, setcc> {
let IfFloatingPoint = G_FCMP;
}

// Broadly speaking G_STORE is equivalent to ISD::STORE but there are some
// complications that tablegen must take care of. For example, predicates such
// as isTruncStore require that this is not a perfect 1:1 mapping since a
Expand Down
Loading