[llvm] [LLVM] Maintain element type of @llvm.compiler.used/@llvm.used if it already exists (PR #162660)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 19:32:41 PDT 2025
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/162660 at github.com>
================
@@ -5850,25 +5851,25 @@ static const char *getSectionNameForCommandline(const Triple &T) {
void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
bool EmbedBitcode, bool EmbedCmdline,
const std::vector<uint8_t> &CmdArgs) {
- // Save llvm.compiler.used and remove it.
- SmallVector<Constant *, 2> UsedArray;
- SmallVector<GlobalValue *, 4> UsedGlobals;
- GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true);
- Type *UsedElementType = Used ? Used->getValueType()->getArrayElementType()
- : PointerType::getUnqual(M.getContext());
- for (auto *GV : UsedGlobals) {
- if (GV->getName() != "llvm.embedded.module" &&
- GV->getName() != "llvm.cmdline")
- UsedArray.push_back(
- ConstantExpr::getPointerBitCastOrAddrSpaceCast(GV, UsedElementType));
- }
- if (Used)
- Used->eraseFromParent();
// Embed the bitcode for the llvm module.
std::string Data;
ArrayRef<uint8_t> ModuleData;
Triple T(M.getTargetTriple());
+ SmallVector<GlobalValue *, 2> NewGlobals;
+
+ auto IsCmdOrBitcode = [&](Constant *C) {
----------------
arsenm wrote:
This doesn't need to be a lambda
https://github.com/llvm/llvm-project/pull/162660
More information about the llvm-commits
mailing list