Remove OptimizeForSize global. Use function attribute optsize.
authorDevang Patel <dpatel@apple.com>
Wed, 1 Oct 2008 23:18:38 +0000 (23:18 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 1 Oct 2008 23:18:38 +0000 (23:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56937 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetOptions.h
lib/CodeGen/LLVMTargetMachine.cpp
lib/CodeGen/LoopAligner.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/TargetMachine.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
lib/Target/X86/X86ISelDAGToDAG.cpp
test/CodeGen/X86/vec_shuffle-23.ll
test/CodeGen/X86/vec_shuffle-24.ll [new file with mode: 0644]

index 42011d928c05145cd7628e27c892626c11184245..b7b27a47ed20d6ec6182e7e178f6c8efb1bb41f3 100644 (file)
@@ -83,10 +83,6 @@ namespace llvm {
   /// optimization (pop the caller's stack) providing it supports it.
   extern bool PerformTailCallOpt;
 
-  /// OptimizeForSize - When this flag is set, the code generator avoids 
-  /// optimizations that increase size.
-  extern bool OptimizeForSize;
-
   /// StackAlignment - Override default stack alignment for target.
   extern unsigned StackAlignment;
 
index bd8d499973510b3cb506a8f998ce8ed69d7035a3..cd444552f7ac21aaa9edf5419e97d8c92c68d43a 100644 (file)
@@ -81,7 +81,7 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   if (addPreEmitPass(PM, Fast) && PrintMachineCode)
     PM.add(createMachineFunctionPrinterPass(cerr));
 
-  if (!Fast && !OptimizeForSize)
+  if (!Fast)
     PM.add(createLoopAlignerPass());
 
   switch (FileType) {
index 6cca8e5badcb359e69328796bdc909dbe4d892c3..60e3f1943055cc7695fa982c223bccb9cf3d738c 100644 (file)
@@ -58,6 +58,10 @@ bool LoopAligner::runOnMachineFunction(MachineFunction &MF) {
   if (!Align)
     return false;  // Don't care about loop alignment.
 
+  const Function *F = MF.getFunction();
+  if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
+    return false;
+
   for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
     MachineBasicBlock *MBB = I;
     if (MLI->isLoopHeader(MBB))
index 53ba8803c7fd16add05ea7b2546b3992bab4ec93..d8451bd1b82b1a4b2613d44494e072c6e70480f8 100644 (file)
@@ -776,7 +776,7 @@ bool PPCDarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 
   printVisibility(CurrentFnName, F->getVisibility());
 
-  EmitAlignment(OptimizeForSize ? 2 : 4, F);
+  EmitAlignment(F->hasFnAttr(Attribute::OptimizeForSize) ? 2 : 4, F);
   O << CurrentFnName << ":\n";
 
   // Emit pre-function debug information.
index 600a120e867c559d70e7eb1ac597ad9de4ade752..90efb74bc91a02d378ccd7e79e5bc32c39ee3234 100644 (file)
@@ -35,7 +35,6 @@ namespace llvm {
   Reloc::Model RelocationModel;
   CodeModel::Model CMModel;
   bool PerformTailCallOpt;
-  bool OptimizeForSize;
   unsigned StackAlignment;
   bool RealignStack;
   bool VerboseAsm;
@@ -134,11 +133,6 @@ EnablePerformTailCallOpt("tailcallopt",
                          cl::desc("Turn on tail call optimization."),
                          cl::location(PerformTailCallOpt),
                          cl::init(false));
-static cl::opt<bool, true>
-EnableOptimizeForSize("optimize-size",
-                      cl::desc("Optimize for size."),
-                      cl::location(OptimizeForSize),
-                      cl::init(false));
 
 static cl::opt<unsigned, true>
 OverrideStackAlignment("stack-alignment",
index 366a5429a3ac1a53740c57394464687f56b23ae4..94158714423c9eac045128a3e3631dba330f77e4 100644 (file)
@@ -153,7 +153,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
 
   SwitchToSection(TAI->SectionForGlobal(F));
 
-  unsigned FnAlign = OptimizeForSize ? 1 : 4;
+  unsigned FnAlign = 4;
   if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
index c8199c59cfb3b3c8e0645cc9ac986a035aa4954d..fdec3bc71392786016afb9c2546cdb397a84c980 100644 (file)
@@ -140,7 +140,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 
   SwitchToTextSection("_text", F);
 
-  unsigned FnAlign = OptimizeForSize ? 1 : 4;
+  unsigned FnAlign = 4;
   if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
index 2b7bf15d845efeee764ef1c931b49d649b21a036..ea3dbad0eeff98191999b24bbd54d98366e2ebf3 100644 (file)
@@ -137,7 +137,7 @@ namespace {
         ContainsFPCode(false), TM(tm),
         X86Lowering(*TM.getTargetLowering()),
         Subtarget(&TM.getSubtarget<X86Subtarget>()),
-        OptForSize(OptimizeForSize) {}
+        OptForSize(false) {}
 
     virtual const char *getPassName() const {
       return "X86 DAG->DAG Instruction Selection";
index 34d84ef15f9cb39ce72a1b3551af02b778e680f0..7e8aa5dc4bf6f66fd9c955efc65c7a2f1f2fa318 100644 (file)
@@ -1,6 +1,5 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2                | not grep punpck
 ; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2                |     grep pshufd
-; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2 -optimize-size |     grep punpck
 
 define i32 @t() nounwind {
 entry:
diff --git a/test/CodeGen/X86/vec_shuffle-24.ll b/test/CodeGen/X86/vec_shuffle-24.ll
new file mode 100644 (file)
index 0000000..170ba35
--- /dev/null
@@ -0,0 +1,17 @@
+; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse2  |     grep punpck
+
+define i32 @t() nounwind optsize {
+entry:
+       %a = alloca <4 x i32>           ; <<4 x i32>*> [#uses=2]
+       %b = alloca <4 x i32>           ; <<4 x i32>*> [#uses=5]
+       volatile store <4 x i32> < i32 0, i32 1, i32 2, i32 3 >, <4 x i32>* %a
+       %tmp = load <4 x i32>* %a               ; <<4 x i32>> [#uses=1]
+       store <4 x i32> %tmp, <4 x i32>* %b
+       %tmp1 = load <4 x i32>* %b              ; <<4 x i32>> [#uses=1]
+       %tmp2 = load <4 x i32>* %b              ; <<4 x i32>> [#uses=1]
+       %punpckldq = shufflevector <4 x i32> %tmp1, <4 x i32> %tmp2, <4 x i32> < i32 0, i32 4, i32 1, i32 5 >           ; <<4 x i32>> [#uses=1]
+       store <4 x i32> %punpckldq, <4 x i32>* %b
+       %tmp3 = load <4 x i32>* %b              ; <<4 x i32>> [#uses=1]
+       %result = extractelement <4 x i32> %tmp3, i32 0         ; <i32> [#uses=1]
+       ret i32 %result
+}