Skip to content

Commit 4ddd4ed

Browse files
authored
[AIX][TOC] -mtocdata/-mno-tocdata fix non deterministic iteration order (#86840)
Failure with testcase toc-conf.c observed when building with LLVM_REVERSE_ITERATION=ON. Changing from using llvm::StringSet to std::set<llvm:StringRef> to ensure iteration order is deterministic. Note: the functionality of the feature does not require a specific iteration order, however, this will allow testing to be consistent. From llvm docs: The advantages of std::set are that its iterators are stable (deleting or inserting an element from the set does not affect iterators or pointers to other elements) and that iteration over the set is guaranteed to be in sorted order.
1 parent a042fcb commit 4ddd4ed

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

clang/lib/Driver/ToolChains/AIX.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static void addTocDataOptions(const llvm::opt::ArgList &Args,
471471
// the global setting of tocdata in TOCDataGloballyinEffect.
472472
// Those that have the opposite setting to TOCDataGloballyinEffect, are added
473473
// to ExplicitlySpecifiedGlobals.
474-
llvm::StringSet<> ExplicitlySpecifiedGlobals;
474+
std::set<llvm::StringRef> ExplicitlySpecifiedGlobals;
475475
for (const auto Arg :
476476
Args.filtered(options::OPT_mtocdata_EQ, options::OPT_mno_tocdata_EQ)) {
477477
TOCDataSetting ArgTocDataSetting =
@@ -486,7 +486,7 @@ static void addTocDataOptions(const llvm::opt::ArgList &Args,
486486
ExplicitlySpecifiedGlobals.erase(Val);
487487
}
488488

489-
auto buildExceptionList = [](const llvm::StringSet<> &ExplicitValues,
489+
auto buildExceptionList = [](const std::set<llvm::StringRef> &ExplicitValues,
490490
const char *OptionSpelling) {
491491
std::string Option(OptionSpelling);
492492
bool IsFirst = true;
@@ -495,7 +495,7 @@ static void addTocDataOptions(const llvm::opt::ArgList &Args,
495495
Option += ",";
496496

497497
IsFirst = false;
498-
Option += E.first();
498+
Option += E.str();
499499
}
500500
return Option;
501501
};

clang/test/Driver/toc-conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ void func() {
2323

2424
// CHECK-CONF1-NOT: warning:
2525
// CHECK-CONF1: "-cc1"{{.*}}" "-mno-tocdata"
26-
// CHECK-CONF1: "-mtocdata=g2,g1"
26+
// CHECK-CONF1: "-mtocdata=g1,g2"
2727

2828
// CHECK-CONF2-NOT: warning:
2929
// CHECK-CONF2: "-cc1"{{.*}}" "-mtocdata"

0 commit comments

Comments
 (0)