Instead of having -Os/-Oz add OptimizeForSize/MinSize first, and later
having OptimizeNone remove them again, just don't add them in the first place if the function already has OptimizeNone. Note that MinSize can still appear due to attributes on different declarations; a future patch will address that. llvm-svn: 224047
This commit is contained in:
@@ -725,7 +725,8 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
|
||||
}
|
||||
|
||||
if (D->hasAttr<ColdAttr>()) {
|
||||
B.addAttribute(llvm::Attribute::OptimizeForSize);
|
||||
if (!D->hasAttr<OptimizeNoneAttr>())
|
||||
B.addAttribute(llvm::Attribute::OptimizeForSize);
|
||||
B.addAttribute(llvm::Attribute::Cold);
|
||||
}
|
||||
|
||||
@@ -766,7 +767,9 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
|
||||
F->addFnAttr(llvm::Attribute::NoInline);
|
||||
|
||||
// OptimizeNone wins over OptimizeForSize, MinSize, AlwaysInline.
|
||||
F->removeFnAttr(llvm::Attribute::OptimizeForSize);
|
||||
assert(!F->hasFnAttribute(llvm::Attribute::OptimizeForSize) &&
|
||||
"OptimizeNone and OptimizeForSize on same function!");
|
||||
// FIXME: Change these to asserts.
|
||||
F->removeFnAttr(llvm::Attribute::MinSize);
|
||||
F->removeFnAttr(llvm::Attribute::AlwaysInline);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user