Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions llvm/include/llvm/IR/Function.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {

void clearArguments();

void deleteBodyImpl(bool ShouldDrop);
void deleteBodyImpl(bool ShouldDrop, bool PreserveMetadata);

/// Function ctor - If the (optional) Module argument is specified, the
/// function is automatically inserted into the end of the function list for
Expand Down Expand Up @@ -727,8 +727,8 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// deleteBody - This method deletes the body of the function, and converts
/// the linkage to external.
///
void deleteBody() {
deleteBodyImpl(/*ShouldDrop=*/false);
void deleteBody(bool PreserveMetadata = false) {
deleteBodyImpl(/*ShouldDrop=*/false, PreserveMetadata);
setLinkage(ExternalLinkage);
}

Expand Down Expand Up @@ -982,7 +982,7 @@ class LLVM_ABI Function : public GlobalObject, public ilist_node<Function> {
/// including any contained basic blocks.
///
void dropAllReferences() {
deleteBodyImpl(/*ShouldDrop=*/true);
deleteBodyImpl(/*ShouldDrop=*/true, /*PreserveMetadata=*/false);
}

/// hasAddressTaken - returns true if there are any uses of this function
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/IR/Function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ void Function::stealArgumentListFrom(Function &Src) {
Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
}

void Function::deleteBodyImpl(bool ShouldDrop) {
void Function::deleteBodyImpl(bool ShouldDrop, bool PreserveMetadata) {
setIsMaterializable(false);

for (BasicBlock &BB : *this)
Expand All @@ -627,7 +627,8 @@ void Function::deleteBodyImpl(bool ShouldDrop) {
}

// Metadata is stored in a side-table.
clearMetadata();
if (!PreserveMetadata)
clearMetadata();
}

void Function::addAttributeAtIndex(unsigned i, Attribute Attr) {
Expand Down