[clang] [CUDA] Emit used function list in deterministic order. (PR #102661)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 9 11:52:37 PDT 2024
https://github.com/Artem-B created https://github.com/llvm/llvm-project/pull/102661
Fixes https://github.com/llvm/llvm-project/issues/101560
>From 6ee0add21bd2a9b25d28640c91de2fc6dab7fa72 Mon Sep 17 00:00:00 2001
From: Artem Belevich <tra at google.com>
Date: Fri, 9 Aug 2024 11:51:23 -0700
Subject: [PATCH] [CUDA] Emit used function list in deterministic order.
Fixes https://github.com/llvm/llvm-project/issues/101560
---
clang/lib/CodeGen/CodeGenModule.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 9aaf90ccfe04ff..aefedeffab614a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -950,6 +950,9 @@ void CodeGenModule::Release() {
UsedArray.push_back(llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
GetAddrOfGlobal(GD), Int8PtrTy));
}
+ // Sort decls by name to always emit them in deterministic order.
+ llvm::sort(UsedArray,
+ [](auto A, auto B) { return A->getName() < B->getName(); });
llvm::ArrayType *ATy = llvm::ArrayType::get(Int8PtrTy, UsedArray.size());
More information about the cfe-commits
mailing list