Skip to content

Commit 5768383

Browse files
authored
[IR] Remove check for bitcast of called function in CallBase::has/getFnAttrOnCalledFunction (#91392)
With opaque pointers, we shouldn't have bitcasts between function pointer types.
1 parent a620697 commit 5768383

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

llvm/lib/IR/Instructions.cpp

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -454,24 +454,14 @@ bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
454454
}
455455

456456
bool CallBase::hasFnAttrOnCalledFunction(Attribute::AttrKind Kind) const {
457-
Value *V = getCalledOperand();
458-
if (auto *CE = dyn_cast<ConstantExpr>(V))
459-
if (CE->getOpcode() == BitCast)
460-
V = CE->getOperand(0);
461-
462-
if (auto *F = dyn_cast<Function>(V))
457+
if (auto *F = dyn_cast<Function>(getCalledOperand()))
463458
return F->getAttributes().hasFnAttr(Kind);
464459

465460
return false;
466461
}
467462

468463
bool CallBase::hasFnAttrOnCalledFunction(StringRef Kind) const {
469-
Value *V = getCalledOperand();
470-
if (auto *CE = dyn_cast<ConstantExpr>(V))
471-
if (CE->getOpcode() == BitCast)
472-
V = CE->getOperand(0);
473-
474-
if (auto *F = dyn_cast<Function>(V))
464+
if (auto *F = dyn_cast<Function>(getCalledOperand()))
475465
return F->getAttributes().hasFnAttr(Kind);
476466

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

488-
Value *V = getCalledOperand();
489-
if (auto *CE = dyn_cast<ConstantExpr>(V))
490-
if (CE->getOpcode() == BitCast)
491-
V = CE->getOperand(0);
492-
493-
if (auto *F = dyn_cast<Function>(V))
478+
if (auto *F = dyn_cast<Function>(getCalledOperand()))
494479
return F->getAttributes().getFnAttr(Kind);
495480

496481
return Attribute();

0 commit comments

Comments
 (0)