[llvm] r175252 - Simplify the 'operator<' for the attribute object.

Bill Wendling isanbard at gmail.com
Thu Feb 14 21:25:26 PST 2013


Author: void
Date: Thu Feb 14 23:25:26 2013
New Revision: 175252

URL: http://llvm.org/viewvc/llvm-project?rev=175252&view=rev
Log:
Simplify the 'operator<' for the attribute object.

Modified:
    llvm/trunk/lib/IR/Attributes.cpp
    llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll

Modified: llvm/trunk/lib/IR/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Attributes.cpp?rev=175252&r1=175251&r2=175252&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Attributes.cpp (original)
+++ llvm/trunk/lib/IR/Attributes.cpp Thu Feb 14 23:25:26 2013
@@ -332,25 +332,23 @@ StringRef AttributeImpl::getValueAsStrin
 bool AttributeImpl::operator<(const AttributeImpl &AI) const {
   // This sorts the attributes with Attribute::AttrKinds coming first (sorted
   // relative to their enum value) and then strings.
-  if (isEnumAttribute())
-    if (AI.isAlignAttribute() || AI.isEnumAttribute())
-      return getKindAsEnum() < AI.getKindAsEnum();
-
-  if (isAlignAttribute()) {
-    if (!AI.isStringAttribute() && getKindAsEnum() < AI.getKindAsEnum())
-      return true;
-    if (AI.isAlignAttribute())
-      return getValueAsInt() < AI.getValueAsInt();
+  if (isEnumAttribute()) {
+    if (AI.isEnumAttribute()) return getKindAsEnum() < AI.getKindAsEnum();
+    if (AI.isAlignAttribute()) return true;
+    if (AI.isStringAttribute()) return true;
   }
 
-  if (isStringAttribute()) {
-    if (!AI.isStringAttribute()) return false;
-    if (getKindAsString() < AI.getKindAsString()) return true;
-    if (getKindAsString() == AI.getKindAsString())
-      return getValueAsString() < AI.getValueAsString();
+  if (isAlignAttribute()) {
+    if (AI.isEnumAttribute()) return false;
+    if (AI.isAlignAttribute()) return getValueAsInt() < AI.getValueAsInt();
+    if (AI.isStringAttribute()) return true;
   }
 
-  return false;
+  if (AI.isEnumAttribute()) return false;
+  if (AI.isAlignAttribute()) return false;
+  if (getKindAsString() == AI.getKindAsString())
+    return getValueAsString() < AI.getValueAsString();
+  return getKindAsString() < AI.getKindAsString();
 }
 
 uint64_t AttributeImpl::getAttrMask(Attribute::AttrKind Val) {

Modified: llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll?rev=175252&r1=175251&r2=175252&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll (original)
+++ llvm/trunk/test/Transforms/MemCpyOpt/memcpy.ll Thu Feb 14 23:25:26 2013
@@ -98,7 +98,7 @@ entry:
   ret i32 0
   ; CHECK: @test5(
   ; CHECK: store i8 4
-  ; CHECK: call void @test5a(%struct.S* align 16 byval %y)
+  ; CHECK: call void @test5a(%struct.S* byval align 16 %y)
 }
 
 ;; Noop memcpy should be zapped.
@@ -123,7 +123,7 @@ entry:
   %call = call i32 @g(%struct.p* align 8 byval %agg.tmp) nounwind
   ret i32 %call
 ; CHECK: @test7
-; CHECK: call i32 @g(%struct.p* align 8 byval %q) nounwind
+; CHECK: call i32 @g(%struct.p* byval align 8 %q) nounwind
 }
 
 declare i32 @g(%struct.p* align 8 byval)





More information about the llvm-commits mailing list