Skip to content

Commit

Permalink
[IR] Remove check for bitcast of called function in CallBase::has/get…
Browse files Browse the repository at this point in the history
…FnAttrOnCalledFunction (#91392)

With opaque pointers, we shouldn't have bitcasts between function
pointer types.
  • Loading branch information
aeubanks committed May 8, 2024
1 parent a620697 commit 5768383
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions llvm/lib/IR/Instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,24 +454,14 @@ bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
}

bool CallBase::hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const {
Value *V = getCalledOperand();
if (auto *CE = dyn_cast<ConstantExpr>(V))
if (CE->getOpcode() == BitCast)
V = CE->getOperand(0);

if (auto *F = dyn_cast<Function>(V))
if (auto *F = dyn_cast<Function>(getCalledOperand()))
return F->getAttributes().hasFnAttr(Kind);

return false;
}

bool CallBase::hasFnAttrOnCalledFunction(StringRef Kind) const {
Value *V = getCalledOperand();
if (auto *CE = dyn_cast<ConstantExpr>(V))
if (CE->getOpcode() == BitCast)
V = CE->getOperand(0);

if (auto *F = dyn_cast<Function>(V))
if (auto *F = dyn_cast<Function>(getCalledOperand()))
return F->getAttributes().hasFnAttr(Kind);

return false;
Expand All @@ -485,12 +475,7 @@ Attribute CallBase::getFnAttrOnCalledFunction(AK Kind) const {
assert(Kind != Attribute::Memory && "Use getMemoryEffects() instead");
}

Value *V = getCalledOperand();
if (auto *CE = dyn_cast<ConstantExpr>(V))
if (CE->getOpcode() == BitCast)
V = CE->getOperand(0);

if (auto *F = dyn_cast<Function>(V))
if (auto *F = dyn_cast<Function>(getCalledOperand()))
return F->getAttributes().getFnAttr(Kind);

return Attribute();
Expand Down

0 comments on commit 5768383

Please sign in to comment.