Skip to content

Revert "Reland "[Clang] Propagate guaranteed alignment for malloc and… #3185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
4 changes: 2 additions & 2 deletions clang/include/clang/Basic/TargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,8 +620,8 @@ class TargetInfo : public virtual TransferrableTargetInfo,
}

/// Return the largest alignment for which a suitably-sized allocation with
/// '::operator new(size_t)' or 'malloc' is guaranteed to produce a
/// correctly-aligned pointer.
/// '::operator new(size_t)' is guaranteed to produce a correctly-aligned
/// pointer.
unsigned getNewAlign() const {
return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign);
}
Expand Down
18 changes: 0 additions & 18 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2060,24 +2060,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
// allows it to work on indirect virtual function calls.
if (AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>())
FuncAttrs.addAttribute(llvm::Attribute::NoMerge);

// Add known guaranteed alignment for allocation functions.
if (unsigned BuiltinID = Fn->getBuiltinID()) {
switch (BuiltinID) {
case Builtin::BIaligned_alloc:
case Builtin::BIcalloc:
case Builtin::BImalloc:
case Builtin::BImemalign:
case Builtin::BIrealloc:
case Builtin::BIstrdup:
case Builtin::BIstrndup:
RetAttrs.addAlignmentAttr(Context.getTargetInfo().getNewAlign() /
Context.getTargetInfo().getCharWidth());
break;
default:
break;
}
}
}

// 'const', 'pure' and 'noalias' attributed functions are also nounwind.
Expand Down
35 changes: 0 additions & 35 deletions clang/test/CodeGen/alloc-fns-alignment.c

This file was deleted.