[clang] [llvm] [clang][CodeGen] `used` globals && the payloads for global ctors & dtors are globals (PR #93601)
Matt Arsenault via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 10:24:27 PDT 2024
================
@@ -2922,18 +2922,19 @@ static void emitUsed(CodeGenModule &CGM, StringRef Name,
if (List.empty())
return;
+ llvm::Type *UsedPtrTy = llvm::PointerType::getUnqual(CGM.getLLVMContext());
+
// Convert List to what ConstantArray needs.
SmallVector<llvm::Constant*, 8> UsedArray;
UsedArray.resize(List.size());
for (unsigned i = 0, e = List.size(); i != e; ++i) {
- UsedArray[i] = llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
- cast<llvm::Constant>(&*List[i]), CGM.GlobalsInt8PtrTy);
+ UsedArray[i] = llvm::ConstantExpr::getPointerCast(
----------------
arsenm wrote:
Although we should get rid of it, getPointerBitCastOrAddrSpaceCast is the correct helper for now. We should have a getAddrSpaceCast that doesn't throw a fit on same typed pointers but getPointerCast will try to insert ptrtoint etc.
https://github.com/llvm/llvm-project/pull/93601
More information about the cfe-commits
mailing list