[llvm] [LLVM][NFC] Use `used`'s element type if available (PR #116804)
Alex Voicu via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 07:37:26 PST 2024
https://github.com/AlexVlx updated https://github.com/llvm/llvm-project/pull/116804
>From 02a607446bf23781255f401d880b67c705cf11fd Mon Sep 17 00:00:00 2001
From: Alex Voicu <alexandru.voicu at amd.com>
Date: Tue, 19 Nov 2024 13:42:54 +0000
Subject: [PATCH] Use `used`'s element type if it's available.
---
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 24a4c2e8303d5a..80e12bef502ace 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -5501,8 +5501,9 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
// Save llvm.compiler.used and remove it.
SmallVector<Constant *, 2> UsedArray;
SmallVector<GlobalValue *, 4> UsedGlobals;
- Type *UsedElementType = PointerType::getUnqual(M.getContext());
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")
More information about the llvm-commits
mailing list