[ASAN] NFC: Use addrspace cast for pointers in non-zero addrspace
authorReshabh Sharma <Reshabhkumar.Sharma@amd.com>
Thu, 29 Apr 2021 05:34:23 +0000 (11:04 +0530)
committerReshabh Sharma <Reshabhkumar.Sharma@amd.com>
Thu, 29 Apr 2021 05:36:00 +0000 (11:06 +0530)
Pointers in non-zero address spaces need to be address space
casted before appending to the used list.

Reviewed by: vitalybuka

Differential Revision: https://reviews.llvm.org/D101363

llvm/lib/Transforms/Utils/ModuleUtils.cpp

index 4ad9837..8c6435b 100644 (file)
@@ -89,7 +89,7 @@ static void appendToUsedList(Module &M, StringRef Name, ArrayRef<GlobalValue *>
 
   Type *Int8PtrTy = llvm::Type::getInt8PtrTy(M.getContext());
   for (auto *V : Values) {
-    Constant *C = ConstantExpr::getBitCast(V, Int8PtrTy);
+    Constant *C = ConstantExpr::getPointerBitCastOrAddrSpaceCast(V, Int8PtrTy);
     if (InitAsSet.insert(C).second)
       Init.push_back(C);
   }