Skip to content

Commit 8d41f1a

Browse files
committed
Fix GSYM tests to run the yaml files and fix test failures on some machines.
YAML files were not being run during lit testing as there was no lit.local.cfg file. Once this was fixed, some buildbots would fail due to a StringRef that pointed to a std::string inside of a temporary llvm::Triple object. These issues are fixed here by making a local triple object that stays around long enough so the StringRef points to valid data. Also fixed an issue where strings for files in the file table could be added in opposite order due to parameters to function calls not having a strong ordering, which caused tests to fail. Added new arch specfic directories so when targets are not enabled, we continue to function just fine. Differential Revision: https://reviews.llvm.org/D75390
1 parent b6b3fcd commit 8d41f1a

File tree

7 files changed

+21
-4
lines changed

7 files changed

+21
-4
lines changed

llvm/lib/DebugInfo/GSYM/GsymCreator.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ uint32_t GsymCreator::insertFile(StringRef Path,
2929
llvm::sys::path::Style Style) {
3030
llvm::StringRef directory = llvm::sys::path::parent_path(Path, Style);
3131
llvm::StringRef filename = llvm::sys::path::filename(Path, Style);
32-
FileEntry FE(insertString(directory), insertString(filename));
32+
// We must insert the strings first, then call the FileEntry constructor.
33+
// If we inline the insertString() function call into the constructor, the
34+
// call order is undefined due to parameter lists not having any ordering
35+
// requirements.
36+
const uint32_t Dir = insertString(directory);
37+
const uint32_t Base = insertString(filename);
38+
FileEntry FE(Dir, Base);
3339

3440
std::lock_guard<std::recursive_mutex> Guard(Mutex);
3541
const auto NextIndex = Files.size();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if not ('ARM' in config.root.targets and 'AArch64' in config.root.targets):
2+
config.unsupported = True
3+
4+
config.suffixes = ['.test', '.yaml']
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
if not 'X86' in config.root.targets:
2+
config.unsupported = True
3+
4+
config.suffixes = ['.test', '.yaml']

llvm/tools/llvm-gsym/llvm-gsymutil.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ static bool filterArch(MachOObjectFile &Obj) {
179179
if (ArchFilters.empty())
180180
return true;
181181

182-
StringRef ObjArch = Obj.getArchTriple().getArchName();
182+
Triple ObjTriple(Obj.getArchTriple());
183+
StringRef ObjArch = ObjTriple.getArchName();
183184

184185
for (auto Arch : ArchFilters) {
185186
// Match name.
@@ -350,7 +351,8 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
350351
error(Filename, errorToErrorCode(BinOrErr.takeError()));
351352

352353
if (auto *Obj = dyn_cast<ObjectFile>(BinOrErr->get())) {
353-
auto ArchName = Obj->makeTriple().getArchName();
354+
Triple ObjTriple(Obj->makeTriple());
355+
auto ArchName = ObjTriple.getArchName();
354356
outs() << "Output file (" << ArchName << "): " << OutFile << "\n";
355357
if (auto Err = handleObjectFile(*Obj, OutFile.c_str()))
356358
return Err;
@@ -374,7 +376,8 @@ static llvm::Error handleBuffer(StringRef Filename, MemoryBufferRef Buffer,
374376

375377
// Now handle each architecture we need to convert.
376378
for (auto &Obj: FilterObjs) {
377-
auto ArchName = Obj->getArchTriple().getArchName();
379+
Triple ObjTriple(Obj->getArchTriple());
380+
auto ArchName = ObjTriple.getArchName();
378381
std::string ArchOutFile(OutFile);
379382
// If we are only handling a single architecture, then we will use the
380383
// normal output file. If we are handling multiple architectures append

0 commit comments

Comments
 (0)