return NewDecl;
}
-static bool isPointerCastOperator(const User *U) {
- return isa<AddrSpaceCastOperator>(U) || isa<BitCastOperator>(U);
-}
-
/// hasAddressTaken - returns true if there are any uses of this function
/// other than direct calls or invokes to it. Optionally ignores callback
/// uses, assume like pointer annotation calls, and references in llvm.used
const auto *Call = dyn_cast<CallBase>(FU);
if (!Call) {
- if (IgnoreAssumeLikeCalls && isPointerCastOperator(FU) &&
+ if (IgnoreAssumeLikeCalls &&
+ isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
all_of(FU->users(), [](const User *U) {
if (const auto *I = dyn_cast<IntrinsicInst>(U))
return I->isAssumeLikeIntrinsic();
if (IgnoreLLVMUsed && !FU->user_empty()) {
const User *FUU = FU;
- if (isa<BitCastOperator>(FU) && FU->hasOneUse() &&
- !FU->user_begin()->user_empty())
+ if (isa<BitCastOperator, AddrSpaceCastOperator>(FU) &&
+ FU->hasOneUse() && !FU->user_begin()->user_empty())
FUU = *FU->user_begin();
if (llvm::all_of(FUU->users(), [](const User *U) {
if (const auto *GV = dyn_cast<GlobalVariable>(U))
; CHECK: Call graph node <<null function>><<{{.*}}>> #uses=0
; CHECK-NEXT: CS<None> calls function 'used1'
; CHECK-NEXT: CS<None> calls function 'used2'
+; CHECK-NEXT: CS<None> calls function 'used_addrspace1'
; CHECK-NEXT: CS<None> calls function 'unused'
; CHECK-EMPTY:
; CHECK-NEXT: Call graph node for function: 'unused'<<{{.*}}>> #uses=1
; CHECK-EMPTY:
; CHECK-NEXT: Call graph node for function: 'used2'<<{{.*}}>> #uses=1
; CHECK-EMPTY:
+; CHECK-NEXT: Call graph node for function: 'used_addrspace1'<<{{.*}}>> #uses=1
+; CHECK-EMPTY:
-@llvm.used = appending global [1 x ptr] [ptr @used1]
+@llvm.used = appending global [2 x ptr] [ptr @used1, ptr addrspacecast (ptr addrspace(1) @used_addrspace1 to ptr)]
@llvm.compiler.used = appending global [1 x ptr] [ptr @used2]
@array = appending global [1 x ptr] [ptr @unused]
ret void
}
+define internal void @used_addrspace1() addrspace(1) {
+entry:
+ ret void
+}
+
define internal void @unused() {
entry:
ret void