forked from OSchip/llvm-project
[Attributor] Use getFreedOperand() (NFC)
Track which operand is actually freed, to avoid the implicit assumption that it is the first call argument.
This commit is contained in:
parent
fd64a857ee
commit
3ac8587a2b
|
@ -5798,6 +5798,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
|
||||||
struct DeallocationInfo {
|
struct DeallocationInfo {
|
||||||
/// The call that deallocates the memory.
|
/// The call that deallocates the memory.
|
||||||
CallBase *const CB;
|
CallBase *const CB;
|
||||||
|
/// The value freed by the call.
|
||||||
|
Value *FreedOp;
|
||||||
|
|
||||||
/// Flag to indicate if we don't know all objects this deallocation might
|
/// Flag to indicate if we don't know all objects this deallocation might
|
||||||
/// free.
|
/// free.
|
||||||
|
@ -5829,8 +5831,8 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
|
||||||
CallBase *CB = dyn_cast<CallBase>(&I);
|
CallBase *CB = dyn_cast<CallBase>(&I);
|
||||||
if (!CB)
|
if (!CB)
|
||||||
return true;
|
return true;
|
||||||
if (isFreeCall(CB, TLI)) {
|
if (Value *FreedOp = getFreedOperand(CB, TLI)) {
|
||||||
DeallocationInfos[CB] = new (A.Allocator) DeallocationInfo{CB};
|
DeallocationInfos[CB] = new (A.Allocator) DeallocationInfo{CB, FreedOp};
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// To do heap to stack, we need to know that the allocation itself is
|
// To do heap to stack, we need to know that the allocation itself is
|
||||||
|
@ -6104,7 +6106,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Use the non-optimistic version to get the freed object.
|
// Use the non-optimistic version to get the freed object.
|
||||||
Value *Obj = getUnderlyingObject(DI.CB->getArgOperand(0));
|
Value *Obj = getUnderlyingObject(DI.FreedOp);
|
||||||
if (!Obj) {
|
if (!Obj) {
|
||||||
LLVM_DEBUG(dbgs() << "[H2S] Unknown underlying object for free!\n");
|
LLVM_DEBUG(dbgs() << "[H2S] Unknown underlying object for free!\n");
|
||||||
DI.MightFreeUnknownObjects = true;
|
DI.MightFreeUnknownObjects = true;
|
||||||
|
|
Loading…
Reference in New Issue