When generating llvm.used, we may need an addrspacecast instead of a bitcast.
Summary: This is especially important for targets that use multiple address spaces, and commonly place global variables in address spaces other than zero. Fixes PR22383 Test Plan: New test case added: llvm-used.cu Reviewers: jingyue Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D7345 llvm-svn: 227861
This commit is contained in:
@@ -935,8 +935,8 @@ static void emitUsed(CodeGenModule &CGM, StringRef Name,
|
||||
UsedArray.resize(List.size());
|
||||
for (unsigned i = 0, e = List.size(); i != e; ++i) {
|
||||
UsedArray[i] =
|
||||
llvm::ConstantExpr::getBitCast(cast<llvm::Constant>(&*List[i]),
|
||||
CGM.Int8PtrTy);
|
||||
llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
|
||||
cast<llvm::Constant>(&*List[i]), CGM.Int8PtrTy);
|
||||
}
|
||||
|
||||
if (UsedArray.empty())
|
||||
|
||||
Reference in New Issue
Block a user