r248191 - Remove attributes minsize and optsize, which conflict with optnone.
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 21 11:52:25 PDT 2015
Author: ahatanak
Date: Mon Sep 21 13:52:24 2015
New Revision: 248191
URL: http://llvm.org/viewvc/llvm-project?rev=248191&view=rev
Log:
Remove attributes minsize and optsize, which conflict with optnone.
This commit fixes an assert that is triggered when optnone is being
added to an IR function that is already marked with minsize and optsize.
rdar://problem/22723716
Differential Revision: http://reviews.llvm.org/D13004
Added:
cfe/trunk/test/CodeGen/attr-func-def.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=248191&r1=248190&r2=248191&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 21 13:52:24 2015
@@ -827,10 +827,8 @@ void CodeGenModule::SetLLVMFunctionAttri
F->addFnAttr(llvm::Attribute::NoInline);
// OptimizeNone wins over OptimizeForSize, MinSize, AlwaysInline.
- assert(!F->hasFnAttribute(llvm::Attribute::OptimizeForSize) &&
- "OptimizeNone and OptimizeForSize on same function!");
- assert(!F->hasFnAttribute(llvm::Attribute::MinSize) &&
- "OptimizeNone and MinSize on same function!");
+ F->removeFnAttr(llvm::Attribute::OptimizeForSize);
+ F->removeFnAttr(llvm::Attribute::MinSize);
assert(!F->hasFnAttribute(llvm::Attribute::AlwaysInline) &&
"OptimizeNone and AlwaysInline on same function!");
Added: cfe/trunk/test/CodeGen/attr-func-def.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-func-def.c?rev=248191&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/attr-func-def.c (added)
+++ cfe/trunk/test/CodeGen/attr-func-def.c Mon Sep 21 13:52:24 2015
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10.0 -emit-llvm -Oz -o - %s | FileCheck %s
+
+// CHECK: define i32 @foo2(i32 %a) [[ATTRS2:#[0-9]+]] {
+// CHECK: define i32 @foo1(i32 %a) [[ATTRS1:#[0-9]+]] {
+
+int foo1(int);
+
+int foo2(int a) {
+ return foo1(a + 2);
+}
+
+__attribute__((optnone))
+int foo1(int a) {
+ return a + 1;
+}
+
+// CHECK: attributes [[ATTRS2]] = { {{.*}}optsize{{.*}} }
+// CHECK: attributes [[ATTRS1]] = { {{.*}}optnone{{.*}} }
More information about the cfe-commits
mailing list