Skip to content

Commit

Permalink
Merged master:46db6068342 into amd-gfx:e5ca2af09e0
Browse files Browse the repository at this point in the history
Local branch amd-gfx e5ca2af Merged master:c4c464f8a50 into amd-gfx:de0adae431b
Remote branch master 46db606 AMDGPU: Avoid folding 2 constant operands into an SALU operation
  • Loading branch information
Sw authored and Sw committed Dec 4, 2019
2 parents e5ca2af + 46db606 commit 12ed18f
Show file tree
Hide file tree
Showing 55 changed files with 1,139 additions and 799 deletions.
26 changes: 10 additions & 16 deletions lldb/include/lldb/Core/ModuleSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,18 @@ class ModuleSpec {
if (match_module_spec.GetObjectName() &&
match_module_spec.GetObjectName() != GetObjectName())
return false;
if (match_module_spec.GetFileSpecPtr()) {
const FileSpec &fspec = match_module_spec.GetFileSpec();
if (!FileSpec::Equal(fspec, GetFileSpec(),
!fspec.GetDirectory().IsEmpty()))
return false;
}
if (GetPlatformFileSpec() && match_module_spec.GetPlatformFileSpecPtr()) {
const FileSpec &fspec = match_module_spec.GetPlatformFileSpec();
if (!FileSpec::Equal(fspec, GetPlatformFileSpec(),
!fspec.GetDirectory().IsEmpty()))
return false;
if (!FileSpec::Match(match_module_spec.GetFileSpec(), GetFileSpec()))
return false;
if (GetPlatformFileSpec() &&
!FileSpec::Match(match_module_spec.GetPlatformFileSpec(),
GetPlatformFileSpec())) {
return false;
}
// Only match the symbol file spec if there is one in this ModuleSpec
if (GetSymbolFileSpec() && match_module_spec.GetSymbolFileSpecPtr()) {
const FileSpec &fspec = match_module_spec.GetSymbolFileSpec();
if (!FileSpec::Equal(fspec, GetSymbolFileSpec(),
!fspec.GetDirectory().IsEmpty()))
return false;
if (GetSymbolFileSpec() &&
!FileSpec::Match(match_module_spec.GetSymbolFileSpec(),
GetSymbolFileSpec())) {
return false;
}
if (match_module_spec.GetArchitecturePtr()) {
if (exact_arch_match) {
Expand Down
2 changes: 0 additions & 2 deletions lldb/include/lldb/Core/SourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class SourceManager {

bool LineIsValid(uint32_t line);

bool FileSpecMatches(const FileSpec &file_spec);

const FileSpec &GetFileSpec() { return m_file_spec; }

uint32_t GetSourceMapModificationID() const { return m_source_map_mod_id; }
Expand Down
18 changes: 6 additions & 12 deletions lldb/include/lldb/Utility/FileSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,6 @@ class FileSpec {

explicit FileSpec(llvm::StringRef path, const llvm::Triple &triple);

/// Copy constructor
///
/// Makes a copy of the uniqued directory and filename strings from \a rhs
/// if it is not nullptr.
///
/// \param[in] rhs
/// A const FileSpec object pointer to copy if non-nullptr.
FileSpec(const FileSpec *rhs);

/// Destructor.
~FileSpec();

bool DirectoryEquals(const FileSpec &other) const;

bool FileEquals(const FileSpec &other) const;
Expand Down Expand Up @@ -195,6 +183,12 @@ class FileSpec {

static bool Equal(const FileSpec &a, const FileSpec &b, bool full);

/// Match FileSpec \a pattern against FileSpec \a file. If \a pattern has a
/// directory component, then the \a file must have the same directory
/// component. Otherwise, just it matches just the filename. An empty \a
/// pattern matches everything.
static bool Match(const FileSpec &pattern, const FileSpec &file);

/// Attempt to guess path style for a given path string. It returns a style,
/// if it was able to make a reasonable guess, or None if it wasn't. The guess
/// will be correct if the input path was a valid absolute path on the system
Expand Down
44 changes: 4 additions & 40 deletions lldb/include/lldb/Utility/Stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,46 +217,10 @@ class Stream {
Stream &operator<<(uint16_t uval) = delete;
Stream &operator<<(uint32_t uval) = delete;
Stream &operator<<(uint64_t uval) = delete;

/// Output a int8_t \a sval to the stream \a s.
///
/// \param[in] sval
/// A int8_t value.
///
/// \return
/// A reference to this class so multiple things can be streamed
/// in one statement.
Stream &operator<<(int8_t sval);

/// Output a int16_t \a sval to the stream \a s.
///
/// \param[in] sval
/// A int16_t value.
///
/// \return
/// A reference to this class so multiple things can be streamed
/// in one statement.
Stream &operator<<(int16_t sval);

/// Output a int32_t \a sval to the stream \a s.
///
/// \param[in] sval
/// A int32_t value.
///
/// \return
/// A reference to this class so multiple things can be streamed
/// in one statement.
Stream &operator<<(int32_t sval);

/// Output a int64_t \a sval to the stream \a s.
///
/// \param[in] sval
/// A int64_t value.
///
/// \return
/// A reference to this class so multiple things can be streamed
/// in one statement.
Stream &operator<<(int64_t sval);
Stream &operator<<(int8_t sval) = delete;
Stream &operator<<(int16_t sval) = delete;
Stream &operator<<(int32_t sval) = delete;
Stream &operator<<(int64_t sval) = delete;

/// Output an address value to this stream.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_to_start(self):
break_in_main = target.BreakpointCreateBySourceRegex(
'Break here to try targetted stepping', self.main_source_spec)
self.assertTrue(break_in_main, VALID_BREAKPOINT)
self.assertTrue(break_in_main.GetNumLocations() > 0, "Has locations.")
self.assertGreater(break_in_main.GetNumLocations(), 0, "Has locations.")

# Now launch the process, and do not stop at entry point.
process = target.LaunchSimple(
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_with_end_line(self):
thread.StepInto("lotsOfArgs", self.end_line, error)
frame = thread.frames[0]

self.assertTrue(frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.")
self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")

@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
def test_with_end_line_bad_name(self):
Expand All @@ -71,8 +71,7 @@ def test_with_end_line_bad_name(self):
error = lldb.SBError()
thread.StepInto("lotsOfArgssss", self.end_line, error)
frame = thread.frames[0]
self.assertTrue(
frame.line_entry.line == self.end_line,
self.assertEqual(frame.line_entry.line, self.end_line,
"Stepped to the block end.")

@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
Expand All @@ -84,7 +83,7 @@ def test_with_end_line_deeper(self):
error = lldb.SBError()
thread.StepInto("modifyInt", self.end_line, error)
frame = thread.frames[0]
self.assertTrue(frame.name == "modifyInt", "Stepped to modifyInt.")
self.assertEqual(frame.name, "modifyInt", "Stepped to modifyInt.")

@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
def test_with_command_and_block(self):
Expand All @@ -100,7 +99,7 @@ def test_with_command_and_block(self):
"thread step-in command succeeded.")

frame = thread.frames[0]
self.assertTrue(frame.name == "lotsOfArgs", "Stepped to lotsOfArgs.")
self.assertEqual(frame.name, "lotsOfArgs", "Stepped to lotsOfArgs.")

@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr32343")
def test_with_command_and_block_and_bad_name(self):
Expand All @@ -117,9 +116,8 @@ def test_with_command_and_block_and_bad_name(self):

frame = thread.frames[0]

self.assertTrue(frame.name == "main", "Stepped back out to main.")
self.assertEqual(frame.name, "main", "Stepped back out to main.")
# end_line is set to the line after the containing block. Check that
# we got there:
self.assertTrue(
frame.line_entry.line == self.end_line,
self.assertEqual(frame.line_entry.line, self.end_line,
"Got out of the block")
2 changes: 1 addition & 1 deletion lldb/source/API/SBThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) {

Thread *thread = exe_ctx.GetThreadPtr();

Status err = thread->JumpToLine(file_spec.get(), line, true);
Status err = thread->JumpToLine(file_spec.ref(), line, true);
sb_error.SetError(err);
return LLDB_RECORD_RESULT(sb_error);
}
Expand Down
4 changes: 2 additions & 2 deletions lldb/source/Breakpoint/Breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ static bool SymbolContextsMightBeEquivalent(SymbolContext &old_sc,
} else {
// Otherwise we will compare by name...
if (old_sc.comp_unit && new_sc.comp_unit) {
if (FileSpec::Equal(old_sc.comp_unit->GetPrimaryFile(),
new_sc.comp_unit->GetPrimaryFile(), true)) {
if (old_sc.comp_unit->GetPrimaryFile() ==
new_sc.comp_unit->GetPrimaryFile()) {
// Now check the functions:
if (old_sc.function && new_sc.function &&
(old_sc.function->GetName() == new_sc.function->GetName())) {
Expand Down
12 changes: 2 additions & 10 deletions lldb/source/Commands/CommandObjectSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
Target *target = m_exe_ctx.GetTargetPtr();

uint32_t num_matches = 0;
bool has_path = false;
if (file_spec) {
assert(file_spec.GetFilename().AsCString());
has_path = (file_spec.GetDirectory().AsCString() != nullptr);
}

// Dump all the line entries for the file in the list.
ConstString last_module_file_name;
uint32_t num_scs = sc_list.GetSize();
Expand All @@ -168,8 +162,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
if (module_list.GetSize() &&
module_list.GetIndexForModule(module) == LLDB_INVALID_INDEX32)
continue;
if (file_spec && !lldb_private::FileSpec::Equal(
file_spec, line_entry.file, has_path))
if (!FileSpec::Match(file_spec, line_entry.file))
continue;
if (start_line > 0 && line_entry.line < start_line)
continue;
Expand Down Expand Up @@ -250,8 +243,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed {
num_matches++;
if (num_lines > 0 && num_matches > num_lines)
break;
assert(lldb_private::FileSpec::Equal(cu_file_spec, line_entry.file,
has_path));
assert(cu_file_spec == line_entry.file);
if (!cu_header_printed) {
if (num_matches > 0)
strm << "\n\n";
Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Core/IOHandlerCursesGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3322,7 +3322,7 @@ class SourceFileWindowDelegate : public WindowDelegate {
if (context_changed)
m_selected_line = m_pc_line;

if (m_file_sp && m_file_sp->FileSpecMatches(m_sc.line_entry.file)) {
if (m_file_sp && m_file_sp->GetFileSpec() == m_sc.line_entry.file) {
// Same file, nothing to do, we should either have the lines or not
// (source file missing)
if (m_selected_line >= static_cast<size_t>(m_first_visible_line)) {
Expand Down
20 changes: 6 additions & 14 deletions lldb/source/Core/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,10 @@ void Module::FindCompileUnits(const FileSpec &path,
const size_t num_compile_units = GetNumCompileUnits();
SymbolContext sc;
sc.module_sp = shared_from_this();
const bool compare_directory = (bool)path.GetDirectory();
for (size_t i = 0; i < num_compile_units; ++i) {
sc.comp_unit = GetCompileUnitAtIndex(i).get();
if (sc.comp_unit) {
if (FileSpec::Equal(sc.comp_unit->GetPrimaryFile(), path,
compare_directory))
if (FileSpec::Match(path, sc.comp_unit->GetPrimaryFile()))
sc_list.Append(sc);
}
}
Expand Down Expand Up @@ -1561,19 +1559,13 @@ bool Module::MatchesModuleSpec(const ModuleSpec &module_ref) {
}

const FileSpec &file_spec = module_ref.GetFileSpec();
if (file_spec) {
if (!FileSpec::Equal(file_spec, m_file, (bool)file_spec.GetDirectory()) &&
!FileSpec::Equal(file_spec, m_platform_file,
(bool)file_spec.GetDirectory()))
return false;
}
if (!FileSpec::Match(file_spec, m_file) &&
!FileSpec::Match(file_spec, m_platform_file))
return false;

const FileSpec &platform_file_spec = module_ref.GetPlatformFileSpec();
if (platform_file_spec) {
if (!FileSpec::Equal(platform_file_spec, GetPlatformFileSpec(),
(bool)platform_file_spec.GetDirectory()))
return false;
}
if (!FileSpec::Match(platform_file_spec, GetPlatformFileSpec()))
return false;

const ArchSpec &arch = module_ref.GetArchitecture();
if (arch.IsValid()) {
Expand Down
9 changes: 3 additions & 6 deletions lldb/source/Core/SearchFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,13 +403,11 @@ SearchFilterByModule::~SearchFilterByModule() = default;

bool SearchFilterByModule::ModulePasses(const ModuleSP &module_sp) {
return (module_sp &&
FileSpec::Equal(module_sp->GetFileSpec(), m_module_spec, false));
FileSpec::Match(m_module_spec, module_sp->GetFileSpec()));
}

bool SearchFilterByModule::ModulePasses(const FileSpec &spec) {
// Do a full match only if "spec" has a directory
const bool full_match = (bool)spec.GetDirectory();
return FileSpec::Equal(spec, m_module_spec, full_match);
return FileSpec::Match(m_module_spec, spec);
}

bool SearchFilterByModule::AddressPasses(Address &address) {
Expand Down Expand Up @@ -443,8 +441,7 @@ void SearchFilterByModule::Search(Searcher &searcher) {
const size_t num_modules = target_modules.GetSize();
for (size_t i = 0; i < num_modules; i++) {
Module *module = target_modules.GetModulePointerAtIndexUnlocked(i);
const bool full_match = (bool)m_module_spec.GetDirectory();
if (FileSpec::Equal(m_module_spec, module->GetFileSpec(), full_match)) {
if (FileSpec::Match(m_module_spec, module->GetFileSpec())) {
SymbolContext matchingContext(m_target_sp, module->shared_from_this());
Searcher::CallbackReturn shouldContinue;

Expand Down
7 changes: 2 additions & 5 deletions lldb/source/Core/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ SourceManager::~SourceManager() {}

SourceManager::FileSP SourceManager::GetFile(const FileSpec &file_spec) {
bool same_as_previous =
m_last_file_sp && m_last_file_sp->FileSpecMatches(file_spec);
m_last_file_sp &&
FileSpec::Match(file_spec, m_last_file_sp->GetFileSpec());

DebuggerSP debugger_sp(m_debugger_wp.lock());
FileSP file_sp;
Expand Down Expand Up @@ -602,10 +603,6 @@ void SourceManager::File::FindLinesMatchingRegex(
}
}

bool SourceManager::File::FileSpecMatches(const FileSpec &file_spec) {
return FileSpec::Equal(m_file_spec, file_spec, false);
}

bool lldb_private::operator==(const SourceManager::File &lhs,
const SourceManager::File &rhs) {
if (lhs.m_file_spec != rhs.m_file_spec)
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Host/common/Editline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static int GetOperation(HistoryOperation op) {
case HistoryOperation::Newest:
return H_LAST;
}
llvm_unreachable("Fully covered switch!");
}


Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ const char *ObjectFilePECOFF::GetPluginDescriptionStatic() {
ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
DataBufferSP &data_sp,
lldb::offset_t data_offset,
const lldb_private::FileSpec *file,
const lldb_private::FileSpec *file_p,
lldb::offset_t file_offset,
lldb::offset_t length) {
FileSpec file = file_p ? *file_p : FileSpec();
if (!data_sp) {
data_sp = MapFileData(file, length, file_offset);
if (!data_sp)
Expand All @@ -135,7 +136,7 @@ ObjectFile *ObjectFilePECOFF::CreateInstance(const lldb::ModuleSP &module_sp,
}

auto objfile_up = std::make_unique<ObjectFilePECOFF>(
module_sp, data_sp, data_offset, file, file_offset, length);
module_sp, data_sp, data_offset, file_p, file_offset, length);
if (!objfile_up || !objfile_up->ParseHeader())
return nullptr;

Expand Down
2 changes: 1 addition & 1 deletion lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ static FileSpec GetXcodeSelectPath() {
std::string command_output;
Status status =
Host::RunShellCommand("/usr/bin/xcode-select --print-path",
nullptr, // current working directory
FileSpec(), // current working directory
&exit_status, &signo, &command_output,
std::chrono::seconds(2), // short timeout
false); // don't run in a shell
Expand Down
10 changes: 5 additions & 5 deletions lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) {
std::string output;
const char *command = "xcrun -sdk macosx --show-sdk-path";
lldb_private::Status error = RunShellCommand(
command, // shell command to run
nullptr, // current working directory
&status, // Put the exit status of the process in here
&signo, // Put the signal that caused the process to exit in
// here
command, // shell command to run
FileSpec(), // current working directory
&status, // Put the exit status of the process in here
&signo, // Put the signal that caused the process to exit in
// here
&output, // Get the output from the command and place it in this
// string
std::chrono::seconds(3));
Expand Down
Loading

0 comments on commit 12ed18f

Please sign in to comment.