Skip to content

Commit 592abf2

Browse files
committed
[Driver] BuildOffloadingActions: Actually stabilize iteration order
In ``` /tmp/StaticDebug/bin/clang -ccc-print-phases -lsomelib -fopenmp=libomp --target=powerpc64-ibm-linux-gnu -fopenmp-targets=x86_64-pc-linux-gnu,powerpc64-ibm-linux-gnu clang/test/Driver/openmp-offload.c clang/test/Driver/openmp-offload.c ``` Both ToolChains have one single empty arch. llvm::sort in LLVM_ENABLE_EXPENSIVE_CHECKS=on builds could swap the two entries. Fixes: 255986e
1 parent cf311a1 commit 592abf2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,10 +4597,13 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
45974597

45984598
// Get the product of all bound architectures and toolchains.
45994599
SmallVector<std::pair<const ToolChain *, StringRef>> TCAndArchs;
4600-
for (const ToolChain *TC : ToolChains)
4601-
for (StringRef Arch : getOffloadArchs(C, Args, Kind, TC))
4600+
for (const ToolChain *TC : ToolChains) {
4601+
llvm::DenseSet<StringRef> Arches = getOffloadArchs(C, Args, Kind, TC);
4602+
SmallVector<StringRef, 0> Sorted(Arches.begin(), Arches.end());
4603+
llvm::sort(Sorted);
4604+
for (StringRef Arch : Sorted)
46024605
TCAndArchs.push_back(std::make_pair(TC, Arch));
4603-
llvm::sort(TCAndArchs, llvm::less_second());
4606+
}
46044607

46054608
for (unsigned I = 0, E = TCAndArchs.size(); I != E; ++I)
46064609
DeviceActions.push_back(C.MakeAction<InputAction>(*InputArg, InputType));

0 commit comments

Comments
 (0)