From baldrick at free.fr Mon Apr 25 01:21:43 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 25 Apr 2011 06:21:43 -0000 Subject: [llvm-commits] [llvm] r130120 - /llvm/trunk/lib/Target/Mips/MipsCallingConv.td Message-ID: <20110425062143.2E4852A6C12C@llvm.org> Author: baldrick Date: Mon Apr 25 01:21:43 2011 New Revision: 130120 URL: http://llvm.org/viewvc/llvm-project?rev=130120&view=rev Log: Fix comment typo. Noticed by Liu. Modified: llvm/trunk/lib/Target/Mips/MipsCallingConv.td Modified: llvm/trunk/lib/Target/Mips/MipsCallingConv.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsCallingConv.td?rev=130120&r1=130119&r2=130120&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsCallingConv.td (original) +++ llvm/trunk/lib/Target/Mips/MipsCallingConv.td Mon Apr 25 01:21:43 2011 @@ -48,7 +48,7 @@ CCIfType<[f32], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[F12, F14, F16, F18]>>>, - // The first 4 doubl fp arguments are passed in single fp registers. + // The first 4 double fp arguments are passed in single fp registers. CCIfType<[f64], CCIfSubtarget<"isNotSingleFloat()", CCAssignToReg<[D6, D7, D8, D9]>>>, From chandlerc at gmail.com Mon Apr 25 02:11:23 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Mon, 25 Apr 2011 07:11:23 -0000 Subject: [llvm-commits] [llvm] r130125 - in /llvm/trunk: lib/Target/MBlaze/MBlazeISelLowering.cpp test/MC/COFF/basic-coff.s test/MC/COFF/bss.s test/MC/COFF/simple-fixups.s test/MC/COFF/symbol-alias.s test/MC/COFF/symbol-fragment-offset.s test/MC/COFF/weak.s Message-ID: <20110425071123.4B6DC2A6C12D@llvm.org> Author: chandlerc Date: Mon Apr 25 02:11:23 2011 New Revision: 130125 URL: http://llvm.org/viewvc/llvm-project?rev=130125&view=rev Log: Remove some hard coded CR-LFs. Some of these were the entire files, one of these was just one line of a file. Explicitly set the eol-style property on the files to try and ensure this fix stays. Modified: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp (contents, props changed) llvm/trunk/test/MC/COFF/basic-coff.s (contents, props changed) llvm/trunk/test/MC/COFF/bss.s (contents, props changed) llvm/trunk/test/MC/COFF/simple-fixups.s (contents, props changed) llvm/trunk/test/MC/COFF/symbol-alias.s (contents, props changed) llvm/trunk/test/MC/COFF/symbol-fragment-offset.s (contents, props changed) llvm/trunk/test/MC/COFF/weak.s (contents, props changed) Modified: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp Mon Apr 25 02:11:23 2011 @@ -1103,7 +1103,7 @@ switch (*constraint) { default: weight = TargetLowering::getSingleConstraintMatchWeight(info, constraint); - break; + break; case 'd': case 'y': if (type->isIntegerTy()) Propchange: llvm/trunk/lib/Target/MBlaze/MBlazeISelLowering.cpp ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/basic-coff.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/basic-coff.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/basic-coff.s (original) +++ llvm/trunk/test/MC/COFF/basic-coff.s Mon Apr 25 02:11:23 2011 @@ -1,133 +1,133 @@ -// This test checks that the COFF object emitter works for the most basic -// programs. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s -// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s - -.def _main; - .scl 2; - .type 32; - .endef - .text - .globl _main - .align 16, 0x90 -_main: # @main -# BB#0: # %entry - subl $4, %esp - movl $L_.str, (%esp) - calll _printf - xorl %eax, %eax - addl $4, %esp - ret - - .data -L_.str: # @.str - .asciz "Hello World" - -// CHECK: { -// CHECK: MachineType = IMAGE_FILE_MACHINE_I386 (0x14C) -// CHECK: NumberOfSections = 2 -// CHECK: TimeDateStamp = {{[0-9]+}} -// CHECK: PointerToSymbolTable = 0x{{[0-9A-F]+}} -// CHECK: NumberOfSymbols = 6 -// CHECK: SizeOfOptionalHeader = 0 -// CHECK: Characteristics = 0x0 -// CHECK: Sections = [ -// CHECK: 1 = { -// CHECK: Name = .text -// CHECK: VirtualSize = 0 -// CHECK: VirtualAddress = 0 -// CHECK: SizeOfRawData = {{[0-9]+}} -// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} -// CHECK: PointerToRelocations = 0x{{[0-9A-F]+}} -// CHECK: PointerToLineNumbers = 0x0 -// CHECK: NumberOfRelocations = 2 -// CHECK: NumberOfLineNumbers = 0 -// CHECK: Charateristics = 0x60500020 -// CHECK: IMAGE_SCN_CNT_CODE -// CHECK: IMAGE_SCN_ALIGN_16BYTES -// CHECK: IMAGE_SCN_MEM_EXECUTE -// CHECK: IMAGE_SCN_MEM_READ -// CHECK: SectionData = -// CHECK: Relocations = [ -// CHECK: 0 = { -// CHECK: VirtualAddress = 0x{{[0-9A-F]+}} -// CHECK: SymbolTableIndex = 2 -// CHECK: Type = IMAGE_REL_I386_DIR32 (6) -// CHECK: SymbolName = .data -// CHECK: } -// CHECK: 1 = { -// CHECK: VirtualAddress = 0x{{[0-9A-F]+}} -// CHECK: SymbolTableIndex = 5 -// CHECK: Type = IMAGE_REL_I386_REL32 (20) -// CHECK: SymbolName = _printf -// CHECK: } -// CHECK: ] -// CHECK: } -// CHECK: 2 = { -// CHECK: Name = .data -// CHECK: VirtualSize = 0 -// CHECK: VirtualAddress = 0 -// CHECK: SizeOfRawData = {{[0-9]+}} -// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} -// CHECK: PointerToRelocations = 0x0 -// CHECK: PointerToLineNumbers = 0x0 -// CHECK: NumberOfRelocations = 0 -// CHECK: NumberOfLineNumbers = 0 -// CHECK: Charateristics = 0xC0300040 -// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA -// CHECK: IMAGE_SCN_ALIGN_4BYTES -// CHECK: IMAGE_SCN_MEM_READ -// CHECK: IMAGE_SCN_MEM_WRITE -// CHECK: SectionData = -// CHECK: 48 65 6C 6C 6F 20 57 6F - 72 6C 64 00 |Hello World.| -// CHECK: Relocations = None -// CHECK: } -// CHECK: ] -// CHECK: Symbols = [ -// CHECK: 0 = { -// CHECK: Name = .text -// CHECK: Value = 0 -// CHECK: SectionNumber = 1 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) -// CHECK: NumberOfAuxSymbols = 1 -// CHECK: AuxillaryData = -// CHECK: 15 00 00 00 02 00 00 00 - 00 00 00 00 01 00 00 00 |................| -// CHECK: 00 00 |..| -// CHECK: } -// CHECK: 2 = { -// CHECK: Name = .data -// CHECK: Value = 0 -// CHECK: SectionNumber = 2 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) -// CHECK: NumberOfAuxSymbols = 1 -// CHECK: AuxillaryData = -// CHECK: 0C 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |................| -// CHECK: 00 00 |..| -// CHECK: } -// CHECK: 4 = { -// CHECK: Name = _main -// CHECK: Value = 0 -// CHECK: SectionNumber = 1 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_FUNCTION (2) -// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK: NumberOfAuxSymbols = 0 -// CHECK: AuxillaryData = -// CHECK: } -// CHECK: 5 = { -// CHECK: Name = _printf -// CHECK: Value = 0 -// CHECK: SectionNumber = 0 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK: NumberOfAuxSymbols = 0 -// CHECK: AuxillaryData = -// CHECK: } -// CHECK: ] -// CHECK: } +// This test checks that the COFF object emitter works for the most basic +// programs. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s +// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s + +.def _main; + .scl 2; + .type 32; + .endef + .text + .globl _main + .align 16, 0x90 +_main: # @main +# BB#0: # %entry + subl $4, %esp + movl $L_.str, (%esp) + calll _printf + xorl %eax, %eax + addl $4, %esp + ret + + .data +L_.str: # @.str + .asciz "Hello World" + +// CHECK: { +// CHECK: MachineType = IMAGE_FILE_MACHINE_I386 (0x14C) +// CHECK: NumberOfSections = 2 +// CHECK: TimeDateStamp = {{[0-9]+}} +// CHECK: PointerToSymbolTable = 0x{{[0-9A-F]+}} +// CHECK: NumberOfSymbols = 6 +// CHECK: SizeOfOptionalHeader = 0 +// CHECK: Characteristics = 0x0 +// CHECK: Sections = [ +// CHECK: 1 = { +// CHECK: Name = .text +// CHECK: VirtualSize = 0 +// CHECK: VirtualAddress = 0 +// CHECK: SizeOfRawData = {{[0-9]+}} +// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} +// CHECK: PointerToRelocations = 0x{{[0-9A-F]+}} +// CHECK: PointerToLineNumbers = 0x0 +// CHECK: NumberOfRelocations = 2 +// CHECK: NumberOfLineNumbers = 0 +// CHECK: Charateristics = 0x60500020 +// CHECK: IMAGE_SCN_CNT_CODE +// CHECK: IMAGE_SCN_ALIGN_16BYTES +// CHECK: IMAGE_SCN_MEM_EXECUTE +// CHECK: IMAGE_SCN_MEM_READ +// CHECK: SectionData = +// CHECK: Relocations = [ +// CHECK: 0 = { +// CHECK: VirtualAddress = 0x{{[0-9A-F]+}} +// CHECK: SymbolTableIndex = 2 +// CHECK: Type = IMAGE_REL_I386_DIR32 (6) +// CHECK: SymbolName = .data +// CHECK: } +// CHECK: 1 = { +// CHECK: VirtualAddress = 0x{{[0-9A-F]+}} +// CHECK: SymbolTableIndex = 5 +// CHECK: Type = IMAGE_REL_I386_REL32 (20) +// CHECK: SymbolName = _printf +// CHECK: } +// CHECK: ] +// CHECK: } +// CHECK: 2 = { +// CHECK: Name = .data +// CHECK: VirtualSize = 0 +// CHECK: VirtualAddress = 0 +// CHECK: SizeOfRawData = {{[0-9]+}} +// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} +// CHECK: PointerToRelocations = 0x0 +// CHECK: PointerToLineNumbers = 0x0 +// CHECK: NumberOfRelocations = 0 +// CHECK: NumberOfLineNumbers = 0 +// CHECK: Charateristics = 0xC0300040 +// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA +// CHECK: IMAGE_SCN_ALIGN_4BYTES +// CHECK: IMAGE_SCN_MEM_READ +// CHECK: IMAGE_SCN_MEM_WRITE +// CHECK: SectionData = +// CHECK: 48 65 6C 6C 6F 20 57 6F - 72 6C 64 00 |Hello World.| +// CHECK: Relocations = None +// CHECK: } +// CHECK: ] +// CHECK: Symbols = [ +// CHECK: 0 = { +// CHECK: Name = .text +// CHECK: Value = 0 +// CHECK: SectionNumber = 1 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) +// CHECK: NumberOfAuxSymbols = 1 +// CHECK: AuxillaryData = +// CHECK: 15 00 00 00 02 00 00 00 - 00 00 00 00 01 00 00 00 |................| +// CHECK: 00 00 |..| +// CHECK: } +// CHECK: 2 = { +// CHECK: Name = .data +// CHECK: Value = 0 +// CHECK: SectionNumber = 2 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) +// CHECK: NumberOfAuxSymbols = 1 +// CHECK: AuxillaryData = +// CHECK: 0C 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |................| +// CHECK: 00 00 |..| +// CHECK: } +// CHECK: 4 = { +// CHECK: Name = _main +// CHECK: Value = 0 +// CHECK: SectionNumber = 1 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_FUNCTION (2) +// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK: NumberOfAuxSymbols = 0 +// CHECK: AuxillaryData = +// CHECK: } +// CHECK: 5 = { +// CHECK: Name = _printf +// CHECK: Value = 0 +// CHECK: SectionNumber = 0 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK: NumberOfAuxSymbols = 0 +// CHECK: AuxillaryData = +// CHECK: } +// CHECK: ] +// CHECK: } Propchange: llvm/trunk/test/MC/COFF/basic-coff.s ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/bss.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/bss.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/bss.s (original) +++ llvm/trunk/test/MC/COFF/bss.s Mon Apr 25 02:11:23 2011 @@ -1,15 +1,15 @@ -// The purpose of this test is to verify that bss sections are emited correctly. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s -// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s - - .bss - .globl _g0 - .align 4 -_g0: - .long 0 - -// CHECK: Name = .bss -// CHECK-NEXT: VirtualSize = 0 -// CHECK-NEXT: VirtualAddress = 0 -// CHECK-NEXT: SizeOfRawData = 4 +// The purpose of this test is to verify that bss sections are emited correctly. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s + + .bss + .globl _g0 + .align 4 +_g0: + .long 0 + +// CHECK: Name = .bss +// CHECK-NEXT: VirtualSize = 0 +// CHECK-NEXT: VirtualAddress = 0 +// CHECK-NEXT: SizeOfRawData = 4 Propchange: llvm/trunk/test/MC/COFF/bss.s ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/simple-fixups.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/simple-fixups.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/simple-fixups.s (original) +++ llvm/trunk/test/MC/COFF/simple-fixups.s Mon Apr 25 02:11:23 2011 @@ -1,50 +1,50 @@ -// The purpose of this test is to verify that we do not produce unneeded -// relocations when symbols are in the same section and we know their offset. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s -// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s - - .def _foo; - .scl 2; - .type 32; - .endef - .text - .globl _foo - .align 16, 0x90 -_foo: # @foo -# BB#0: # %e - .align 16, 0x90 -LBB0_1: # %i - # =>This Inner Loop Header: Depth=1 - jmp LBB0_1 - - .def _bar; - .scl 2; - .type 32; - .endef - .globl _bar - .align 16, 0x90 -_bar: # @bar -# BB#0: # %e - .align 16, 0x90 -LBB1_1: # %i - # =>This Inner Loop Header: Depth=1 - jmp LBB1_1 - - .def _baz; - .scl 2; - .type 32; - .endef - .globl _baz - .align 16, 0x90 -_baz: # @baz -# BB#0: # %e - subl $4, %esp -Ltmp0: - calll _baz - addl $4, %esp - ret - -// CHECK: Sections = [ -// CHECK-NOT: NumberOfRelocations = {{[^0]}} -// CHECK: Symbols = [ +// The purpose of this test is to verify that we do not produce unneeded +// relocations when symbols are in the same section and we know their offset. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s +// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s + + .def _foo; + .scl 2; + .type 32; + .endef + .text + .globl _foo + .align 16, 0x90 +_foo: # @foo +# BB#0: # %e + .align 16, 0x90 +LBB0_1: # %i + # =>This Inner Loop Header: Depth=1 + jmp LBB0_1 + + .def _bar; + .scl 2; + .type 32; + .endef + .globl _bar + .align 16, 0x90 +_bar: # @bar +# BB#0: # %e + .align 16, 0x90 +LBB1_1: # %i + # =>This Inner Loop Header: Depth=1 + jmp LBB1_1 + + .def _baz; + .scl 2; + .type 32; + .endef + .globl _baz + .align 16, 0x90 +_baz: # @baz +# BB#0: # %e + subl $4, %esp +Ltmp0: + calll _baz + addl $4, %esp + ret + +// CHECK: Sections = [ +// CHECK-NOT: NumberOfRelocations = {{[^0]}} +// CHECK: Symbols = [ Propchange: llvm/trunk/test/MC/COFF/simple-fixups.s ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/symbol-alias.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symbol-alias.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/symbol-alias.s (original) +++ llvm/trunk/test/MC/COFF/symbol-alias.s Mon Apr 25 02:11:23 2011 @@ -1,62 +1,62 @@ -// The purpose of this test is to verify that symbol aliases -// (@foo = alias @bar) generate the correct entries in the symbol table. -// They should be identical except for the name. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s -// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s - - .def _foo; - .scl 2; - .type 32; - .endef - .text - .globl _foo - .align 16, 0x90 -_foo: # @foo -# BB#0: # %entry - ret - - .data - .globl _bar # @bar - .align 4 -_bar: - .long 0 # 0x0 - - - .globl _foo_alias -_foo_alias = _foo - .globl _bar_alias -_bar_alias = _bar - -// CHECK: Name = {{_?}}foo -// CHECK-NEXT: Value = [[FOO_VALUE:.*$]] -// CHECK-NEXT: SectionNumber = [[FOO_SECTION_NUMBER:.*$]] -// CHECK-NEXT: SimpleType = [[FOO_SIMPLE_TYPE:.*$]] -// CHECK-NEXT: ComplexType = [[FOO_COMPLEX_TYPE:.*$]] -// CHECK-NEXT: StorageClass = [[FOO_STORAGE_CLASS:.*$]] -// CHECK-NEXT: NumberOfAuxSymbols = [[FOO_NUMBER_OF_AUX_SYMBOLS:.*$]] - -// CHECK: Name = {{_?}}bar -// CHECK-NEXT: Value = [[BAR_VALUE:.*$]] -// CHECK-NEXT: SectionNumber = [[BAR_SECTION_NUMBER:.*$]] -// CHECK-NEXT: SimpleType = [[BAR_SIMPLE_TYPE:.*$]] -// CHECK-NEXT: ComplexType = [[BAR_COMPLEX_TYPE:.*$]] -// CHECK-NEXT: StorageClass = [[BAR_STORAGE_CLASS:.*$]] -// CHECK-NEXT: NumberOfAuxSymbols = [[BAR_NUMBER_OF_AUX_SYMBOLS:.*$]] - -// CHECK: Name = {{_?}}foo_alias -// CHECK-NEXT: Value = [[FOO_VALUE]] -// CHECK-NEXT: SectionNumber = [[FOO_SECTION_NUMBER]] -// CHECK-NEXT: SimpleType = [[FOO_SIMPLE_TYPE]] -// CHECK-NEXT: ComplexType = [[FOO_COMPLEX_TYPE]] -// CHECK-NEXT: StorageClass = [[FOO_STORAGE_CLASS]] -// CHECK-NEXT: NumberOfAuxSymbols = [[FOO_NUMBER_OF_AUX_SYMBOLS]] - -// CHECK: Name = {{_?}}bar_alias -// CHECK-NEXT: Value = [[BAR_VALUE]] -// CHECK-NEXT: SectionNumber = [[BAR_SECTION_NUMBER]] -// CHECK-NEXT: SimpleType = [[BAR_SIMPLE_TYPE]] -// CHECK-NEXT: ComplexType = [[BAR_COMPLEX_TYPE]] -// CHECK-NEXT: StorageClass = [[BAR_STORAGE_CLASS]] -// CHECK-NEXT: NumberOfAuxSymbols = [[BAR_NUMBER_OF_AUX_SYMBOLS]] - +// The purpose of this test is to verify that symbol aliases +// (@foo = alias @bar) generate the correct entries in the symbol table. +// They should be identical except for the name. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | coff-dump.py | FileCheck %s + + .def _foo; + .scl 2; + .type 32; + .endef + .text + .globl _foo + .align 16, 0x90 +_foo: # @foo +# BB#0: # %entry + ret + + .data + .globl _bar # @bar + .align 4 +_bar: + .long 0 # 0x0 + + + .globl _foo_alias +_foo_alias = _foo + .globl _bar_alias +_bar_alias = _bar + +// CHECK: Name = {{_?}}foo +// CHECK-NEXT: Value = [[FOO_VALUE:.*$]] +// CHECK-NEXT: SectionNumber = [[FOO_SECTION_NUMBER:.*$]] +// CHECK-NEXT: SimpleType = [[FOO_SIMPLE_TYPE:.*$]] +// CHECK-NEXT: ComplexType = [[FOO_COMPLEX_TYPE:.*$]] +// CHECK-NEXT: StorageClass = [[FOO_STORAGE_CLASS:.*$]] +// CHECK-NEXT: NumberOfAuxSymbols = [[FOO_NUMBER_OF_AUX_SYMBOLS:.*$]] + +// CHECK: Name = {{_?}}bar +// CHECK-NEXT: Value = [[BAR_VALUE:.*$]] +// CHECK-NEXT: SectionNumber = [[BAR_SECTION_NUMBER:.*$]] +// CHECK-NEXT: SimpleType = [[BAR_SIMPLE_TYPE:.*$]] +// CHECK-NEXT: ComplexType = [[BAR_COMPLEX_TYPE:.*$]] +// CHECK-NEXT: StorageClass = [[BAR_STORAGE_CLASS:.*$]] +// CHECK-NEXT: NumberOfAuxSymbols = [[BAR_NUMBER_OF_AUX_SYMBOLS:.*$]] + +// CHECK: Name = {{_?}}foo_alias +// CHECK-NEXT: Value = [[FOO_VALUE]] +// CHECK-NEXT: SectionNumber = [[FOO_SECTION_NUMBER]] +// CHECK-NEXT: SimpleType = [[FOO_SIMPLE_TYPE]] +// CHECK-NEXT: ComplexType = [[FOO_COMPLEX_TYPE]] +// CHECK-NEXT: StorageClass = [[FOO_STORAGE_CLASS]] +// CHECK-NEXT: NumberOfAuxSymbols = [[FOO_NUMBER_OF_AUX_SYMBOLS]] + +// CHECK: Name = {{_?}}bar_alias +// CHECK-NEXT: Value = [[BAR_VALUE]] +// CHECK-NEXT: SectionNumber = [[BAR_SECTION_NUMBER]] +// CHECK-NEXT: SimpleType = [[BAR_SIMPLE_TYPE]] +// CHECK-NEXT: ComplexType = [[BAR_COMPLEX_TYPE]] +// CHECK-NEXT: StorageClass = [[BAR_STORAGE_CLASS]] +// CHECK-NEXT: NumberOfAuxSymbols = [[BAR_NUMBER_OF_AUX_SYMBOLS]] + Propchange: llvm/trunk/test/MC/COFF/symbol-alias.s ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/symbol-fragment-offset.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symbol-fragment-offset.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/symbol-fragment-offset.s (original) +++ llvm/trunk/test/MC/COFF/symbol-fragment-offset.s Mon Apr 25 02:11:23 2011 @@ -1,187 +1,187 @@ -// The purpose of this test is to see if the COFF object writer is emitting the -// proper relocations for multiple pieces of data in a single data fragment. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s -// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s - -.def _main; - .scl 2; - .type 32; - .endef - .text - .globl _main - .align 16, 0x90 -_main: # @main -# BB#0: # %entry - subl $4, %esp - movl $L_.str0, (%esp) - calll _printf - movl $L_.str1, (%esp) - calll _puts - movl $L_.str2, (%esp) - calll _puts - xorl %eax, %eax - addl $4, %esp - ret - - .data -L_.str0: # @.str0 - .asciz "Hello " - -L_.str1: # @.str1 - .asciz "World!" - - .align 16 # @.str2 -L_.str2: - .asciz "I'm The Last Line." - -// CHECK: { -// CHECK: MachineType = IMAGE_FILE_MACHINE_I386 (0x14C) -// CHECK: NumberOfSections = 2 -// CHECK: TimeDateStamp = {{[0-9]+}} -// CHECK: PointerToSymbolTable = 0x{{[0-9A-F]+}} -// CHECK: NumberOfSymbols = 7 -// CHECK: SizeOfOptionalHeader = 0 -// CHECK: Characteristics = 0x0 -// CHECK: Sections = [ -// CHECK: 1 = { -// CHECK: Name = .text -// CHECK: VirtualSize = 0 -// CHECK: VirtualAddress = 0 -// CHECK: SizeOfRawData = {{[0-9]+}} -// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} -// CHECK: PointerToRelocations = 0x{{[0-9A-F]+}} -// CHECK: PointerToLineNumbers = 0x0 -// CHECK: NumberOfRelocations = 6 -// CHECK: NumberOfLineNumbers = 0 -// CHECK: Charateristics = 0x60500020 -// CHECK: IMAGE_SCN_CNT_CODE -// CHECK: IMAGE_SCN_ALIGN_16BYTES -// CHECK: IMAGE_SCN_MEM_EXECUTE -// CHECK: IMAGE_SCN_MEM_READ -// CHECK: SectionData = -// CHECK: 83 EC 04 C7 04 24 00 00 - 00 00 E8 00 00 00 00 C7 |.....$..........| -// CHECK: 04 24 07 00 00 00 E8 00 - 00 00 00 C7 04 24 10 00 |.$...........$..| -// CHECK: 00 00 E8 00 00 00 00 31 - C0 83 C4 04 C3 |.......1.....| -// CHECK: Relocations = [ -// CHECK: 0 = { -// CHECK: VirtualAddress = 0x6 -// CHECK: SymbolTableIndex = 2 -// CHECK: Type = IMAGE_REL_I386_DIR32 (6) -// CHECK: SymbolName = .data -// CHECK: } -// CHECK: 1 = { -// CHECK: VirtualAddress = 0xB -// CHECK: SymbolTableIndex = 5 -// CHECK: Type = IMAGE_REL_I386_REL32 (20) -// CHECK: SymbolName = _printf -// CHECK: } -// CHECK: 2 = { -// CHECK: VirtualAddress = 0x12 -// CHECK: SymbolTableIndex = 2 -// CHECK: Type = IMAGE_REL_I386_DIR32 (6) -// CHECK: SymbolName = .data -// CHECK: } -// CHECK: 3 = { -// CHECK: VirtualAddress = 0x17 -// CHECK: SymbolTableIndex = 6 -// CHECK: Type = IMAGE_REL_I386_REL32 (20) -// CHECK: SymbolName = _puts -// CHECK: } -// CHECK: 4 = { -// CHECK: VirtualAddress = 0x1E -// CHECK: SymbolTableIndex = 2 -// CHECK: Type = IMAGE_REL_I386_DIR32 (6) -// CHECK: SymbolName = .data -// CHECK: } -// CHECK: 5 = { -// CHECK: VirtualAddress = 0x23 -// CHECK: SymbolTableIndex = 6 -// CHECK: Type = IMAGE_REL_I386_REL32 (20) -// CHECK: SymbolName = _puts -// CHECK: } -// CHECK: ] -// CHECK: } -// CHECK: 2 = { -// CHECK: Name = .data -// CHECK: VirtualSize = 0 -// CHECK: VirtualAddress = 0 -// CHECK: SizeOfRawData = {{[0-9]+}} -// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} -// CHECK: PointerToRelocations = 0x0 -// CHECK: PointerToLineNumbers = 0x0 -// CHECK: NumberOfRelocations = 0 -// CHECK: NumberOfLineNumbers = 0 -// CHECK: Charateristics = 0xC0500040 -// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA -// CHECK: IMAGE_SCN_ALIGN_16BYTES -// CHECK: IMAGE_SCN_MEM_READ -// CHECK: IMAGE_SCN_MEM_WRITE -// CHECK: SectionData = -// CHECK: 48 65 6C 6C 6F 20 00 57 - 6F 72 6C 64 21 00 00 00 |Hello .World!...| -// CHECK: 49 27 6D 20 54 68 65 20 - 4C 61 73 74 20 4C 69 6E |I'm The Last Lin| -// CHECK: 65 2E 00 |e..| -// CHECK: Relocations = None -// CHECK: } -// CHECK: ] -// CHECK: Symbols = [ -// CHECK: 0 = { -// CHECK: Name = .text -// CHECK: Value = 0 -// CHECK: SectionNumber = 1 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) -// CHECK: NumberOfAuxSymbols = 1 -// CHECK: AuxillaryData = -// CHECK: 2D 00 00 00 06 00 00 00 - 00 00 00 00 01 00 00 00 |-...............| -// CHECK: 00 00 |..| - -// CHECK: } -// CHECK: 2 = { -// CHECK: Name = .data -// CHECK: Value = 0 -// CHECK: SectionNumber = 2 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) -// CHECK: NumberOfAuxSymbols = 1 -// CHECK: AuxillaryData = -// CHECK: 23 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |#...............| -// CHECK: 00 00 |..| - -// CHECK: } -// CHECK: 4 = { -// CHECK: Name = _main -// CHECK: Value = 0 -// CHECK: SectionNumber = 1 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_FUNCTION (2) -// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK: NumberOfAuxSymbols = 0 -// CHECK: AuxillaryData = - -// CHECK: 5 = { -// CHECK: Name = _printf -// CHECK: Value = 0 -// CHECK: SectionNumber = 0 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK: NumberOfAuxSymbols = 0 -// CHECK: AuxillaryData = - -// CHECK: } -// CHECK: 6 = { -// CHECK: Name = _puts -// CHECK: Value = 0 -// CHECK: SectionNumber = 0 -// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK: NumberOfAuxSymbols = 0 -// CHECK: AuxillaryData = - -// CHECK: } -// CHECK: ] -// CHECK: } +// The purpose of this test is to see if the COFF object writer is emitting the +// proper relocations for multiple pieces of data in a single data fragment. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | coff-dump.py | FileCheck %s +// I WOULD RUN, BUT THIS FAILS: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s + +.def _main; + .scl 2; + .type 32; + .endef + .text + .globl _main + .align 16, 0x90 +_main: # @main +# BB#0: # %entry + subl $4, %esp + movl $L_.str0, (%esp) + calll _printf + movl $L_.str1, (%esp) + calll _puts + movl $L_.str2, (%esp) + calll _puts + xorl %eax, %eax + addl $4, %esp + ret + + .data +L_.str0: # @.str0 + .asciz "Hello " + +L_.str1: # @.str1 + .asciz "World!" + + .align 16 # @.str2 +L_.str2: + .asciz "I'm The Last Line." + +// CHECK: { +// CHECK: MachineType = IMAGE_FILE_MACHINE_I386 (0x14C) +// CHECK: NumberOfSections = 2 +// CHECK: TimeDateStamp = {{[0-9]+}} +// CHECK: PointerToSymbolTable = 0x{{[0-9A-F]+}} +// CHECK: NumberOfSymbols = 7 +// CHECK: SizeOfOptionalHeader = 0 +// CHECK: Characteristics = 0x0 +// CHECK: Sections = [ +// CHECK: 1 = { +// CHECK: Name = .text +// CHECK: VirtualSize = 0 +// CHECK: VirtualAddress = 0 +// CHECK: SizeOfRawData = {{[0-9]+}} +// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} +// CHECK: PointerToRelocations = 0x{{[0-9A-F]+}} +// CHECK: PointerToLineNumbers = 0x0 +// CHECK: NumberOfRelocations = 6 +// CHECK: NumberOfLineNumbers = 0 +// CHECK: Charateristics = 0x60500020 +// CHECK: IMAGE_SCN_CNT_CODE +// CHECK: IMAGE_SCN_ALIGN_16BYTES +// CHECK: IMAGE_SCN_MEM_EXECUTE +// CHECK: IMAGE_SCN_MEM_READ +// CHECK: SectionData = +// CHECK: 83 EC 04 C7 04 24 00 00 - 00 00 E8 00 00 00 00 C7 |.....$..........| +// CHECK: 04 24 07 00 00 00 E8 00 - 00 00 00 C7 04 24 10 00 |.$...........$..| +// CHECK: 00 00 E8 00 00 00 00 31 - C0 83 C4 04 C3 |.......1.....| +// CHECK: Relocations = [ +// CHECK: 0 = { +// CHECK: VirtualAddress = 0x6 +// CHECK: SymbolTableIndex = 2 +// CHECK: Type = IMAGE_REL_I386_DIR32 (6) +// CHECK: SymbolName = .data +// CHECK: } +// CHECK: 1 = { +// CHECK: VirtualAddress = 0xB +// CHECK: SymbolTableIndex = 5 +// CHECK: Type = IMAGE_REL_I386_REL32 (20) +// CHECK: SymbolName = _printf +// CHECK: } +// CHECK: 2 = { +// CHECK: VirtualAddress = 0x12 +// CHECK: SymbolTableIndex = 2 +// CHECK: Type = IMAGE_REL_I386_DIR32 (6) +// CHECK: SymbolName = .data +// CHECK: } +// CHECK: 3 = { +// CHECK: VirtualAddress = 0x17 +// CHECK: SymbolTableIndex = 6 +// CHECK: Type = IMAGE_REL_I386_REL32 (20) +// CHECK: SymbolName = _puts +// CHECK: } +// CHECK: 4 = { +// CHECK: VirtualAddress = 0x1E +// CHECK: SymbolTableIndex = 2 +// CHECK: Type = IMAGE_REL_I386_DIR32 (6) +// CHECK: SymbolName = .data +// CHECK: } +// CHECK: 5 = { +// CHECK: VirtualAddress = 0x23 +// CHECK: SymbolTableIndex = 6 +// CHECK: Type = IMAGE_REL_I386_REL32 (20) +// CHECK: SymbolName = _puts +// CHECK: } +// CHECK: ] +// CHECK: } +// CHECK: 2 = { +// CHECK: Name = .data +// CHECK: VirtualSize = 0 +// CHECK: VirtualAddress = 0 +// CHECK: SizeOfRawData = {{[0-9]+}} +// CHECK: PointerToRawData = 0x{{[0-9A-F]+}} +// CHECK: PointerToRelocations = 0x0 +// CHECK: PointerToLineNumbers = 0x0 +// CHECK: NumberOfRelocations = 0 +// CHECK: NumberOfLineNumbers = 0 +// CHECK: Charateristics = 0xC0500040 +// CHECK: IMAGE_SCN_CNT_INITIALIZED_DATA +// CHECK: IMAGE_SCN_ALIGN_16BYTES +// CHECK: IMAGE_SCN_MEM_READ +// CHECK: IMAGE_SCN_MEM_WRITE +// CHECK: SectionData = +// CHECK: 48 65 6C 6C 6F 20 00 57 - 6F 72 6C 64 21 00 00 00 |Hello .World!...| +// CHECK: 49 27 6D 20 54 68 65 20 - 4C 61 73 74 20 4C 69 6E |I'm The Last Lin| +// CHECK: 65 2E 00 |e..| +// CHECK: Relocations = None +// CHECK: } +// CHECK: ] +// CHECK: Symbols = [ +// CHECK: 0 = { +// CHECK: Name = .text +// CHECK: Value = 0 +// CHECK: SectionNumber = 1 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) +// CHECK: NumberOfAuxSymbols = 1 +// CHECK: AuxillaryData = +// CHECK: 2D 00 00 00 06 00 00 00 - 00 00 00 00 01 00 00 00 |-...............| +// CHECK: 00 00 |..| + +// CHECK: } +// CHECK: 2 = { +// CHECK: Name = .data +// CHECK: Value = 0 +// CHECK: SectionNumber = 2 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_STATIC (3) +// CHECK: NumberOfAuxSymbols = 1 +// CHECK: AuxillaryData = +// CHECK: 23 00 00 00 00 00 00 00 - 00 00 00 00 02 00 00 00 |#...............| +// CHECK: 00 00 |..| + +// CHECK: } +// CHECK: 4 = { +// CHECK: Name = _main +// CHECK: Value = 0 +// CHECK: SectionNumber = 1 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_FUNCTION (2) +// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK: NumberOfAuxSymbols = 0 +// CHECK: AuxillaryData = + +// CHECK: 5 = { +// CHECK: Name = _printf +// CHECK: Value = 0 +// CHECK: SectionNumber = 0 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK: NumberOfAuxSymbols = 0 +// CHECK: AuxillaryData = + +// CHECK: } +// CHECK: 6 = { +// CHECK: Name = _puts +// CHECK: Value = 0 +// CHECK: SectionNumber = 0 +// CHECK: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK: NumberOfAuxSymbols = 0 +// CHECK: AuxillaryData = + +// CHECK: } +// CHECK: ] +// CHECK: } Propchange: llvm/trunk/test/MC/COFF/symbol-fragment-offset.s ------------------------------------------------------------------------------ svn:eol-style = native Modified: llvm/trunk/test/MC/COFF/weak.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/weak.s?rev=130125&r1=130124&r2=130125&view=diff ============================================================================== --- llvm/trunk/test/MC/COFF/weak.s (original) +++ llvm/trunk/test/MC/COFF/weak.s Mon Apr 25 02:11:23 2011 @@ -1,51 +1,51 @@ -// This tests that default-null weak symbols (a GNU extension) are created -// properly via the .weak directive. - -// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 < %s | coff-dump.py | FileCheck %s - - .def _main; - .scl 2; - .type 32; - .endef - .text - .globl _main - .align 16, 0x90 -_main: # @main -# BB#0: # %entry - subl $4, %esp - movl $_test_weak, %eax - testl %eax, %eax - je LBB0_2 -# BB#1: # %if.then - calll _test_weak - movl $1, %eax - addl $4, %esp - ret -LBB0_2: # %return - xorl %eax, %eax - addl $4, %esp - ret - - .weak _test_weak - -// CHECK: Symbols = [ - -// CHECK: Name = _test_weak -// CHECK-NEXT: Value = 0 -// CHECK-NEXT: SectionNumber = 0 -// CHECK-NEXT: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK-NEXT: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK-NEXT: StorageClass = IMAGE_SYM_CLASS_WEAK_EXTERNAL (105) -// CHECK-NEXT: NumberOfAuxSymbols = 1 -// CHECK-NEXT: AuxillaryData = -// CHECK-NEXT: 05 00 00 00 02 00 00 00 - 00 00 00 00 00 00 00 00 |................| -// CHECK-NEXT: 00 00 |..| - -// CHECK: Name = .weak._test_weak.default -// CHECK-NEXT: Value = 0 -// CHECK-NEXT: SectionNumber = 65535 -// CHECK-NEXT: SimpleType = IMAGE_SYM_TYPE_NULL (0) -// CHECK-NEXT: ComplexType = IMAGE_SYM_DTYPE_NULL (0) -// CHECK-NEXT: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) -// CHECK-NEXT: NumberOfAuxSymbols = 0 -// CHECK-NEXT: AuxillaryData = +// This tests that default-null weak symbols (a GNU extension) are created +// properly via the .weak directive. + +// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 < %s | coff-dump.py | FileCheck %s + + .def _main; + .scl 2; + .type 32; + .endef + .text + .globl _main + .align 16, 0x90 +_main: # @main +# BB#0: # %entry + subl $4, %esp + movl $_test_weak, %eax + testl %eax, %eax + je LBB0_2 +# BB#1: # %if.then + calll _test_weak + movl $1, %eax + addl $4, %esp + ret +LBB0_2: # %return + xorl %eax, %eax + addl $4, %esp + ret + + .weak _test_weak + +// CHECK: Symbols = [ + +// CHECK: Name = _test_weak +// CHECK-NEXT: Value = 0 +// CHECK-NEXT: SectionNumber = 0 +// CHECK-NEXT: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK-NEXT: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK-NEXT: StorageClass = IMAGE_SYM_CLASS_WEAK_EXTERNAL (105) +// CHECK-NEXT: NumberOfAuxSymbols = 1 +// CHECK-NEXT: AuxillaryData = +// CHECK-NEXT: 05 00 00 00 02 00 00 00 - 00 00 00 00 00 00 00 00 |................| +// CHECK-NEXT: 00 00 |..| + +// CHECK: Name = .weak._test_weak.default +// CHECK-NEXT: Value = 0 +// CHECK-NEXT: SectionNumber = 65535 +// CHECK-NEXT: SimpleType = IMAGE_SYM_TYPE_NULL (0) +// CHECK-NEXT: ComplexType = IMAGE_SYM_DTYPE_NULL (0) +// CHECK-NEXT: StorageClass = IMAGE_SYM_CLASS_EXTERNAL (2) +// CHECK-NEXT: NumberOfAuxSymbols = 0 +// CHECK-NEXT: AuxillaryData = Propchange: llvm/trunk/test/MC/COFF/weak.s ------------------------------------------------------------------------------ svn:eol-style = native From baldrick at free.fr Mon Apr 25 02:40:38 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 25 Apr 2011 09:40:38 +0200 Subject: [llvm-commits] [llvm] r129800 - /llvm/trunk/include/llvm/ADT/Triple.h In-Reply-To: <20110419203007.BDF282A6C12C@llvm.org> References: <20110419203007.BDF282A6C12C@llvm.org> Message-ID: <4DB52576.7070900@free.fr> Hi Daniel, > --- llvm/trunk/include/llvm/ADT/Triple.h (original) > +++ llvm/trunk/include/llvm/ADT/Triple.h Tue Apr 19 15:30:07 2011 > @@ -249,6 +249,20 @@ > return getOSMajorVersion(); > } > > + bool isOSVersionLT(unsigned Major, unsigned B_Minor, unsigned Micro) { Why B_Minor? > + unsigned LHS[3]; > + getOSVersion(LHS[0], LHS[1], LHS[2]); > + > + if (LHS[0] != Major) > + return LHS[0]< Major; > + if (LHS[1] != Minor) > + return LHS[1]< Minor; > + if (LHS[2] != Micro) > + return LHS[1]< Micro; ^ Should be LHS[2]. Also, how about using symbolic names rather than LHS[0], LHS[1] etc? Ciao, Duncan. From benny.kra at googlemail.com Mon Apr 25 05:12:01 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Mon, 25 Apr 2011 10:12:01 -0000 Subject: [llvm-commits] [llvm] r130126 - in /llvm/trunk/test: Analysis/RegionInfo/next.ll CodeGen/ARM/crash-greedy.ll CodeGen/PTX/ld.ll CodeGen/Thumb2/bfi.ll CodeGen/Thumb2/thumb2-lsr3.ll CodeGen/X86/fast-isel-x86.ll CodeGen/X86/fp-trunc.ll CodeGen/X86/lsr-interesting-step.ll Message-ID: <20110425101201.DCB352A6C12D@llvm.org> Author: d0k Date: Mon Apr 25 05:12:01 2011 New Revision: 130126 URL: http://llvm.org/viewvc/llvm-project?rev=130126&view=rev Log: Make tests more useful. lit needs a linter ... Modified: llvm/trunk/test/Analysis/RegionInfo/next.ll llvm/trunk/test/CodeGen/ARM/crash-greedy.ll llvm/trunk/test/CodeGen/PTX/ld.ll llvm/trunk/test/CodeGen/Thumb2/bfi.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll llvm/trunk/test/CodeGen/X86/fp-trunc.ll llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll Modified: llvm/trunk/test/Analysis/RegionInfo/next.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/RegionInfo/next.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/Analysis/RegionInfo/next.ll (original) +++ llvm/trunk/test/Analysis/RegionInfo/next.ll Mon Apr 25 05:12:01 2011 @@ -32,8 +32,8 @@ ; CHECK-NOT: => ; CHECK: [0] entry => ; CHECK-NEXT: [1] __label_002001.outer => __label_000020 -; CHECK-NEXT; [2] bb197 => bb229 -; CHECK-NEXT; [3] bb224 => bb229 +; CHECK-NEXT: [2] bb197 => bb229 +; CHECK-NEXT: [3] bb224 => bb229 ; STAT: 4 region - The # of regions ; STAT: 1 region - The # of simple regions Modified: llvm/trunk/test/CodeGen/ARM/crash-greedy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/crash-greedy.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/crash-greedy.ll (original) +++ llvm/trunk/test/CodeGen/ARM/crash-greedy.ll Mon Apr 25 05:12:01 2011 @@ -6,7 +6,7 @@ declare double @exp(double) -; CHECK remat_subreg +; CHECK: remat_subreg define void @remat_subreg(float* nocapture %x, i32* %y, i32 %n, i32 %z, float %c, float %lambda, float* nocapture %ret_f, float* nocapture %ret_df) nounwind { entry: %conv16 = fpext float %lambda to double Modified: llvm/trunk/test/CodeGen/PTX/ld.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PTX/ld.ll (original) +++ llvm/trunk/test/CodeGen/PTX/ld.ll Mon Apr 25 05:12:01 2011 @@ -64,7 +64,7 @@ define ptx_device i16 @t1_u16(i16* %p) { entry: ;CHECK: ld.global.u16 rh0, [r1]; -;CHECK-NEXT; ret; +;CHECK-NEXT: ret; %x = load i16* %p ret i16 %x } Modified: llvm/trunk/test/CodeGen/Thumb2/bfi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/bfi.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/bfi.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/bfi.ll Mon Apr 25 05:12:01 2011 @@ -53,7 +53,7 @@ ; rdar://9177502 define i32 @f5(i32 %a, i32 %b) nounwind readnone { entry: -; CHECK f5 +; CHECK: f5 ; CHECK-NOT: bfi r0, r2, #0, #1 %and = and i32 %a, 2 %b.masked = and i32 %b, -2 Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll Mon Apr 25 05:12:01 2011 @@ -1,9 +1,9 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 +; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s define i1 @test1(i64 %poscnt, i32 %work) { entry: -; CHECK: rrx r0, r0 ; CHECK: lsrs.w r1, r1, #1 +; CHECK: rrx r0, r0 %0 = lshr i64 %poscnt, 1 %1 = icmp eq i64 %0, 0 ret i1 %1 @@ -11,8 +11,8 @@ define i1 @test2(i64 %poscnt, i32 %work) { entry: -; CHECK: rrx r0, r0 ; CHECK: asrs.w r1, r1, #1 +; CHECK: rrx r0, r0 %0 = ashr i64 %poscnt, 1 %1 = icmp eq i64 %0, 0 ret i1 %1 Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Mon Apr 25 05:12:01 2011 @@ -1,4 +1,4 @@ -; RUN: llc -march=x86 -relocation-model=pic < %s +; RUN: llc -fast-isel -O0 -march=x86 -relocation-model=pic < %s | FileCheck %s ; This should use flds to set the return value. ; CHECK: test0: Modified: llvm/trunk/test/CodeGen/X86/fp-trunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-trunc.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fp-trunc.ll (original) +++ llvm/trunk/test/CodeGen/X86/fp-trunc.ll Mon Apr 25 05:12:01 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=x86 -mattr=+sse2,-avx +; RUN: llc < %s -march=x86 -mattr=+sse2,-avx | FileCheck %s define <1 x float> @test1(<1 x double> %x) nounwind { ; CHECK: cvtsd2ss Modified: llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll?rev=130126&r1=130125&r2=130126&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll (original) +++ llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll Mon Apr 25 05:12:01 2011 @@ -1,9 +1,9 @@ -; RUN: llc < %s -march=x86-64 -relocation-model=static -mtriple=x86_64-unknown-linux-gnu +; RUN: llc < %s -march=x86-64 -relocation-model=static -mtriple=x86_64-unknown-linux-gnu -asm-verbose=0 | FileCheck %s ; The inner loop should require only one add (and no leas either). ; rdar://8100380 -; CHECK: BB0_4: +; CHECK: BB0_3: ; CHECK-NEXT: movb $0, flags(%rdx) ; CHECK-NEXT: addq %rcx, %rdx ; CHECK-NEXT: cmpq $8192, %rdx From baldrick at free.fr Mon Apr 25 07:13:51 2011 From: baldrick at free.fr (Duncan Sands) Date: Mon, 25 Apr 2011 12:13:51 -0000 Subject: [llvm-commits] [dragonegg] r130127 - in /dragonegg/trunk: README src/Types.cpp Message-ID: <20110425121351.CCA4F2A6C12D@llvm.org> Author: baldrick Date: Mon Apr 25 07:13:51 2011 New Revision: 130127 URL: http://llvm.org/viewvc/llvm-project?rev=130127&view=rev Log: Fix a few spelling errors. Modified: dragonegg/trunk/README dragonegg/trunk/src/Types.cpp Modified: dragonegg/trunk/README URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/README?rev=130127&r1=130126&r2=130127&view=diff ============================================================================== --- dragonegg/trunk/README (original) +++ dragonegg/trunk/README Mon Apr 25 07:13:51 2011 @@ -31,7 +31,7 @@ that LTO requires libelf, though in fact it does not when using dragonegg. See http://gcc.gnu.org/wiki/LinkTimeOptimization#Building_the_branch In theory the gcc you build can be a cross-compiler, and the plugin should work -and build code for the targetted platform. I don't think anyone has ever tried +and build code for the targeted platform. I don't think anyone has ever tried this though. Darwin special: the gcc configure script thinks darwin doesn't support dynamic Modified: dragonegg/trunk/src/Types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=130127&r1=130126&r2=130127&view=diff ============================================================================== --- dragonegg/trunk/src/Types.cpp (original) +++ dragonegg/trunk/src/Types.cpp Mon Apr 25 07:13:51 2011 @@ -316,7 +316,7 @@ // // This code is built to make sure that the TYPE_LLVM field on tree types are // updated when LLVM types are refined. This prevents dangling pointers from -// occuring due to type coallescing. +// occurring due to type coallescing. // namespace { class TypeRefinementDatabase : public AbstractTypeUser { @@ -1779,7 +1779,7 @@ } } - // Otherwise, this bitfield lives (potentially) partially in the preceeding + // Otherwise, this bitfield lives (potentially) partially in the preceding // field and in fields that exist after it. Add integer-typed fields to the // LLVM struct such that there are no holes in the struct where the bitfield // is: these holes would make it impossible to statically initialize a global @@ -1822,7 +1822,7 @@ uint64_t AvailableBits = FirstUnallocatedByte * 8 - StartOffsetInBits; // This field's starting point is already allocated. if (StartOffsetFromByteBoundry == 0) { - // This field starts at byte boundry. Need to allocate space + // This field starts at byte boundary. Need to allocate space // for additional bytes not yet allocated. unsigned NumBitsToAdd = FieldSizeInBits - AvailableBits; Info.addNewBitField(NumBitsToAdd, ExtraSizeInBits, FirstUnallocatedByte); @@ -1861,7 +1861,7 @@ unsigned PadBytes = 0; unsigned PadBits = 0; if (StartOffsetFromByteBoundry != 0) { - // New field does not start at byte boundry. + // New field does not start at byte boundary. PadBits = StartOffsetInBits - (FirstUnallocatedByte*8); PadBytes = PadBits/8; PadBits = PadBits - PadBytes*8; @@ -1877,7 +1877,7 @@ FirstUnallocatedByte = StartOffsetInBits/8; // This field will use some of the bits from this PadBytes, if - // starting offset is not at byte boundry. + // starting offset is not at byte boundary. if (StartOffsetFromByteBoundry != 0) FieldSizeInBits += PadBits; } From dpatel at apple.com Mon Apr 25 11:33:53 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 25 Apr 2011 16:33:53 -0000 Subject: [llvm-commits] [llvm] r130129 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp test/CodeGen/X86/dbg-declare-arg.ll Message-ID: <20110425163353.2AB9E2A6C12D@llvm.org> Author: dpatel Date: Mon Apr 25 11:33:52 2011 New Revision: 130129 URL: http://llvm.org/viewvc/llvm-project?rev=130129&view=rev Log: A dbg.declare may not be in entry block, even if it is referring to an incoming argument. However, It is appropriate to emit DBG_VALUE referring to this incoming argument in entry block in MachineFunction. Added: llvm/trunk/test/CodeGen/X86/dbg-declare-arg.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=130129&r1=130128&r2=130129&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Mon Apr 25 11:33:52 2011 @@ -4033,10 +4033,6 @@ if (DV.isInlinedFnArgument(MF.getFunction())) return false; - MachineBasicBlock *MBB = FuncInfo.MBB; - if (MBB != &MF.front()) - return false; - unsigned Reg = 0; if (Arg->hasByValAttr()) { // Byval arguments' frame index is recorded during argument lowering. Added: llvm/trunk/test/CodeGen/X86/dbg-declare-arg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/dbg-declare-arg.ll?rev=130129&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/dbg-declare-arg.ll (added) +++ llvm/trunk/test/CodeGen/X86/dbg-declare-arg.ll Mon Apr 25 11:33:52 2011 @@ -0,0 +1,123 @@ +; RUN: llc -O0 -fast-isel=false < %s | FileCheck %s +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-macosx10.6.7" +;Radar 9321650 + +;CHECK: ##DEBUG_VALUE: my_a + +%class.A = type { i32, i32, i32, i32 } + +define void @_Z3fooi(%class.A* sret %agg.result, i32 %i) ssp { +entry: + %i.addr = alloca i32, align 4 + %j = alloca i32, align 4 + %nrvo = alloca i1 + %cleanup.dest.slot = alloca i32 + store i32 %i, i32* %i.addr, align 4 + call void @llvm.dbg.declare(metadata !{i32* %i.addr}, metadata !26), !dbg !27 + call void @llvm.dbg.declare(metadata !{i32* %j}, metadata !28), !dbg !30 + store i32 0, i32* %j, align 4, !dbg !31 + %tmp = load i32* %i.addr, align 4, !dbg !32 + %cmp = icmp eq i32 %tmp, 42, !dbg !32 + br i1 %cmp, label %if.then, label %if.end, !dbg !32 + +if.then: ; preds = %entry + %tmp1 = load i32* %i.addr, align 4, !dbg !33 + %add = add nsw i32 %tmp1, 1, !dbg !33 + store i32 %add, i32* %j, align 4, !dbg !33 + br label %if.end, !dbg !35 + +if.end: ; preds = %if.then, %entry + store i1 false, i1* %nrvo, !dbg !36 + call void @llvm.dbg.declare(metadata !{%class.A* %agg.result}, metadata !37), !dbg !39 + %tmp2 = load i32* %j, align 4, !dbg !40 + %x = getelementptr inbounds %class.A* %agg.result, i32 0, i32 0, !dbg !40 + store i32 %tmp2, i32* %x, align 4, !dbg !40 + store i1 true, i1* %nrvo, !dbg !41 + store i32 1, i32* %cleanup.dest.slot + %nrvo.val = load i1* %nrvo, !dbg !42 + br i1 %nrvo.val, label %nrvo.skipdtor, label %nrvo.unused, !dbg !42 + +nrvo.unused: ; preds = %if.end + call void @_ZN1AD1Ev(%class.A* %agg.result), !dbg !42 + br label %nrvo.skipdtor, !dbg !42 + +nrvo.skipdtor: ; preds = %nrvo.unused, %if.end + ret void, !dbg !42 +} + +declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone + +define linkonce_odr void @_ZN1AD1Ev(%class.A* %this) unnamed_addr ssp align 2 { +entry: + %this.addr = alloca %class.A*, align 8 + store %class.A* %this, %class.A** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.A** %this.addr}, metadata !43), !dbg !44 + %this1 = load %class.A** %this.addr + call void @_ZN1AD2Ev(%class.A* %this1) + ret void, !dbg !45 +} + +define linkonce_odr void @_ZN1AD2Ev(%class.A* %this) unnamed_addr nounwind ssp align 2 { +entry: + %this.addr = alloca %class.A*, align 8 + store %class.A* %this, %class.A** %this.addr, align 8 + call void @llvm.dbg.declare(metadata !{%class.A** %this.addr}, metadata !46), !dbg !47 + %this1 = load %class.A** %this.addr + %x = getelementptr inbounds %class.A* %this1, i32 0, i32 0, !dbg !48 + store i32 1, i32* %x, align 4, !dbg !48 + ret void, !dbg !48 +} + +!llvm.dbg.sp = !{!0, !10, !14, !19, !22, !25} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"~A", metadata !"~A", metadata !"", metadata !3, i32 2, metadata !11, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589826, metadata !2, metadata !"A", metadata !3, i32 2, i64 128, i64 32, i32 0, i32 0, null, metadata !4, i32 0, null, null} ; [ DW_TAG_class_type ] +!2 = metadata !{i32 589841, i32 0, i32 4, metadata !"a.cc", metadata !"/private/tmp", metadata !"clang version 3.0 (trunk 130127)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589865, metadata !"a.cc", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ] +!4 = metadata !{metadata !5, metadata !7, metadata !8, metadata !9, metadata !0, metadata !10, metadata !14} +!5 = metadata !{i32 589837, metadata !3, metadata !"x", metadata !3, i32 2, i64 32, i64 32, i64 0, i32 0, metadata !6} ; [ DW_TAG_member ] +!6 = metadata !{i32 589860, metadata !2, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] +!7 = metadata !{i32 589837, metadata !3, metadata !"y", metadata !3, i32 2, i64 32, i64 32, i64 32, i32 0, metadata !6} ; [ DW_TAG_member ] +!8 = metadata !{i32 589837, metadata !3, metadata !"z", metadata !3, i32 2, i64 32, i64 32, i64 64, i32 0, metadata !6} ; [ DW_TAG_member ] +!9 = metadata !{i32 589837, metadata !3, metadata !"o", metadata !3, i32 2, i64 32, i64 32, i64 96, i32 0, metadata !6} ; [ DW_TAG_member ] +!10 = metadata !{i32 589870, i32 0, metadata !1, metadata !"A", metadata !"A", metadata !"", metadata !3, i32 2, metadata !11, i1 false, i1 false, i32 0, i32 0, null, i32 320, i1 false, null, null} ; [ DW_TAG_subprogram ] +!11 = metadata !{i32 589845, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !12, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!12 = metadata !{null, metadata !13} +!13 = metadata !{i32 589839, metadata !2, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !1} ; [ DW_TAG_pointer_type ] +!14 = metadata !{i32 589870, i32 0, metadata !1, metadata !"A", metadata !"A", metadata !"", metadata !3, i32 2, metadata !15, i1 false, i1 false, i32 0, i32 0, null, i32 320, i1 false, null, null} ; [ DW_TAG_subprogram ] +!15 = metadata !{i32 589845, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !16, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!16 = metadata !{null, metadata !13, metadata !17} +!17 = metadata !{i32 589840, metadata !2, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !18} ; [ DW_TAG_reference_type ] +!18 = metadata !{i32 589862, metadata !2, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !1} ; [ DW_TAG_const_type ] +!19 = metadata !{i32 589870, i32 0, metadata !3, metadata !"foo", metadata !"foo", metadata !"_Z3fooi", metadata !3, i32 4, metadata !20, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, void (%class.A*, i32)* @_Z3fooi, null, null} ; [ DW_TAG_subprogram ] +!20 = metadata !{i32 589845, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !21, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!21 = metadata !{metadata !1} +!22 = metadata !{i32 589870, i32 0, metadata !3, metadata !"~A", metadata !"~A", metadata !"_ZN1AD1Ev", metadata !3, i32 2, metadata !23, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, void (%class.A*)* @_ZN1AD1Ev, null, null} ; [ DW_TAG_subprogram ] +!23 = metadata !{i32 589845, metadata !3, metadata !"", metadata !3, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !24, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!24 = metadata !{null} +!25 = metadata !{i32 589870, i32 0, metadata !3, metadata !"~A", metadata !"~A", metadata !"_ZN1AD2Ev", metadata !3, i32 2, metadata !23, i1 false, i1 true, i32 0, i32 0, i32 0, i32 256, i1 false, void (%class.A*)* @_ZN1AD2Ev, null, null} ; [ DW_TAG_subprogram ] +!26 = metadata !{i32 590081, metadata !19, metadata !"i", metadata !3, i32 16777220, metadata !6, i32 0} ; [ DW_TAG_arg_variable ] +!27 = metadata !{i32 4, i32 11, metadata !19, null} +!28 = metadata !{i32 590080, metadata !29, metadata !"j", metadata !3, i32 5, metadata !6, i32 0} ; [ DW_TAG_auto_variable ] +!29 = metadata !{i32 589835, metadata !19, i32 4, i32 14, metadata !3, i32 0} ; [ DW_TAG_lexical_block ] +!30 = metadata !{i32 5, i32 7, metadata !29, null} +!31 = metadata !{i32 5, i32 12, metadata !29, null} +!32 = metadata !{i32 6, i32 3, metadata !29, null} +!33 = metadata !{i32 7, i32 5, metadata !34, null} +!34 = metadata !{i32 589835, metadata !29, i32 6, i32 16, metadata !3, i32 1} ; [ DW_TAG_lexical_block ] +!35 = metadata !{i32 8, i32 3, metadata !34, null} +!36 = metadata !{i32 9, i32 9, metadata !29, null} +!37 = metadata !{i32 590080, metadata !29, metadata !"my_a", metadata !3, i32 9, metadata !38, i32 0} ; [ DW_TAG_auto_variable ] +!38 = metadata !{i32 589840, metadata !2, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !1} ; [ DW_TAG_reference_type ] +!39 = metadata !{i32 9, i32 5, metadata !29, null} +!40 = metadata !{i32 10, i32 3, metadata !29, null} +!41 = metadata !{i32 11, i32 3, metadata !29, null} +!42 = metadata !{i32 12, i32 1, metadata !29, null} +!43 = metadata !{i32 590081, metadata !22, metadata !"this", metadata !3, i32 16777218, metadata !13, i32 64} ; [ DW_TAG_arg_variable ] +!44 = metadata !{i32 2, i32 47, metadata !22, null} +!45 = metadata !{i32 2, i32 61, metadata !22, null} +!46 = metadata !{i32 590081, metadata !25, metadata !"this", metadata !3, i32 16777218, metadata !13, i32 64} ; [ DW_TAG_arg_variable ] +!47 = metadata !{i32 2, i32 47, metadata !25, null} +!48 = metadata !{i32 2, i32 54, metadata !49, null} +!49 = metadata !{i32 589835, metadata !25, i32 2, i32 52, metadata !3, i32 2} ; [ DW_TAG_lexical_block ] From daniel at zuster.org Mon Apr 25 11:53:11 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 16:53:11 -0000 Subject: [llvm-commits] [zorg] r130130 - /zorg/trunk/lnt/lnt/testing/__init__.py Message-ID: <20110425165311.A7F682A6C12D@llvm.org> Author: ddunbar Date: Mon Apr 25 11:53:11 2011 New Revision: 130130 URL: http://llvm.org/viewvc/llvm-project?rev=130130&view=rev Log: lnt.testing.report: Override the default encoding to avoid the potential for UTF-8 encoding errors to break report rendering. Modified: zorg/trunk/lnt/lnt/testing/__init__.py Modified: zorg/trunk/lnt/lnt/testing/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/__init__.py?rev=130130&r1=130129&r2=130130&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/testing/__init__.py (original) +++ zorg/trunk/lnt/lnt/testing/__init__.py Mon Apr 25 11:53:11 2011 @@ -43,10 +43,13 @@ assert isinstance(t, TestSamples) def render(self, indent=4): + # Note that we specifically override the encoding to avoid the + # possibility of encoding errors. Clients which care about the text + # encoding should supply unicode string objects. return json.dumps({ 'Machine' : self.machine.render(), 'Run' : self.run.render(), 'Tests' : [t.render() for t in self.tests] }, - sort_keys=True, indent=indent) + sort_keys=True, indent=indent, encoding='latin-1') class Machine: """Information on the machine the test was run on. From ahatanak at gmail.com Mon Apr 25 12:10:46 2011 From: ahatanak at gmail.com (Akira Hatanaka) Date: Mon, 25 Apr 2011 17:10:46 -0000 Subject: [llvm-commits] [llvm] r130131 - in /llvm/trunk: lib/Target/Mips/MipsISelLowering.cpp lib/Target/Mips/MipsInstrInfo.td test/CodeGen/Mips/blockaddr.ll Message-ID: <20110425171046.1EE892A6C12D@llvm.org> Author: ahatanak Date: Mon Apr 25 12:10:45 2011 New Revision: 130131 URL: http://llvm.org/viewvc/llvm-project?rev=130131&view=rev Log: Lower BlockAddress node when relocation-model is static. Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.td llvm/trunk/test/CodeGen/Mips/blockaddr.ll Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=130131&r1=130130&r2=130131&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Mon Apr 25 12:10:45 2011 @@ -801,24 +801,30 @@ SDValue MipsTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const { + const BlockAddress *BA = cast(Op)->getBlockAddress(); + // FIXME there isn't actually debug info here + DebugLoc dl = Op.getDebugLoc(); + if (getTargetMachine().getRelocationModel() != Reloc::PIC_) { - assert(false && "implement LowerBlockAddress for -static"); - return SDValue(0, 0); - } - else { - // FIXME there isn't actually debug info here - DebugLoc dl = Op.getDebugLoc(); - const BlockAddress *BA = cast(Op)->getBlockAddress(); - SDValue BAGOTOffset = DAG.getBlockAddress(BA, MVT::i32, true, - MipsII::MO_GOT); - SDValue BALOOffset = DAG.getBlockAddress(BA, MVT::i32, true, - MipsII::MO_ABS_LO); - SDValue Load = DAG.getLoad(MVT::i32, dl, - DAG.getEntryNode(), BAGOTOffset, - MachinePointerInfo(), false, false, 0); - SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, BALOOffset); - return DAG.getNode(ISD::ADD, dl, MVT::i32, Load, Lo); - } + // %hi/%lo relocation + SDValue BAHi = DAG.getBlockAddress(BA, MVT::i32, true, + MipsII::MO_ABS_HI); + SDValue BALo = DAG.getBlockAddress(BA, MVT::i32, true, + MipsII::MO_ABS_LO); + SDValue Hi = DAG.getNode(MipsISD::Hi, dl, MVT::i32, BAHi); + SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, BALo); + return DAG.getNode(ISD::ADD, dl, MVT::i32, Hi, Lo); + } + + SDValue BAGOTOffset = DAG.getBlockAddress(BA, MVT::i32, true, + MipsII::MO_GOT); + SDValue BALOOffset = DAG.getBlockAddress(BA, MVT::i32, true, + MipsII::MO_ABS_LO); + SDValue Load = DAG.getLoad(MVT::i32, dl, + DAG.getEntryNode(), BAGOTOffset, + MachinePointerInfo(), false, false, 0); + SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, BALOOffset); + return DAG.getNode(ISD::ADD, dl, MVT::i32, Load, Lo); } SDValue MipsTargetLowering:: Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=130131&r1=130130&r2=130131&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Mon Apr 25 12:10:45 2011 @@ -557,6 +557,7 @@ // hi/lo relocs def : Pat<(MipsHi tglobaladdr:$in), (LUi tglobaladdr:$in)>; +def : Pat<(MipsHi tblockaddress:$in), (LUi tblockaddress:$in)>; def : Pat<(add CPURegs:$hi, (MipsLo tglobaladdr:$lo)), (ADDiu CPURegs:$hi, tglobaladdr:$lo)>; def : Pat<(add CPURegs:$hi, (MipsLo tblockaddress:$lo)), Modified: llvm/trunk/test/CodeGen/Mips/blockaddr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/blockaddr.ll?rev=130131&r1=130130&r2=130131&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/blockaddr.ll (original) +++ llvm/trunk/test/CodeGen/Mips/blockaddr.ll Mon Apr 25 12:10:45 2011 @@ -1,4 +1,5 @@ -; RUN: llc -march=mipsel < %s | FileCheck %s +; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s -check-prefix=CHECK-PIC +; RUN: llc -march=mipsel -relocation-model=static < %s | FileCheck %s -check-prefix=CHECK-STATIC @reg = common global i8* null, align 4 @@ -7,10 +8,14 @@ ret i8* %x } -; CHECK: lw $2, %got($tmp1)($gp) -; CHECK: addiu $4, $2, %lo($tmp1) -; CHECK: lw $2, %got($tmp2)($gp) -; CHECK: addiu $2, $2, %lo($tmp2) +; CHECK-PIC: lw $[[R0:[0-9]+]], %got($tmp1)($gp) +; CHECK-PIC: addiu ${{[0-9]+}}, $[[R0]], %lo($tmp1) +; CHECK-PIC: lw $[[R1:[0-9]+]], %got($tmp2)($gp) +; CHECK-PIC: addiu ${{[0-9]+}}, $[[R1]], %lo($tmp2) +; CHECK-STATIC: lui $[[R2:[0-9]+]], %hi($tmp1) +; CHECK-STATIC: addiu ${{[0-9]+}}, $[[R2]], %lo($tmp1) +; CHECK-STATIC: lui $[[R3:[0-9]+]], %hi($tmp2) +; CHECK-STATIC: addiu ${{[0-9]+}}, $[[R3]], %lo($tmp2) define void @f() nounwind { entry: %call = tail call i8* @dummy(i8* blockaddress(@f, %baz)) From gkistanova at gmail.com Mon Apr 25 13:35:33 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Mon, 25 Apr 2011 11:35:33 -0700 Subject: [llvm-commits] New clang cross builders added Message-ID: Hello everyone, Please note that we have 2 new clang cross builders now on http://google1.osuosl.org:8011/waterfall They build the next configurations: --build=x86_64-apple-darwin10 --host=i686-pc-mingw32 --target=i686-pc-mingw32 --build=x86_64-apple-darwin10 --host=x86_64-apple-darwin10 --target=i686-pc-mingw32 Here they are: http://google1.osuosl.org:8011/builders/clang-x86_64-darwin10-self-mingw32 http://google1.osuosl.org:8011/builders/clang-x86_64-darwin10-cross-mingw32 Thanks Galina From sabre at nondot.org Mon Apr 25 13:44:26 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 25 Apr 2011 18:44:26 -0000 Subject: [llvm-commits] [llvm] r130137 - /llvm/trunk/lib/Target/README.txt Message-ID: <20110425184427.017B52A6C12D@llvm.org> Author: lattner Date: Mon Apr 25 13:44:26 2011 New Revision: 130137 URL: http://llvm.org/viewvc/llvm-project?rev=130137&view=rev Log: add a missed bitfield instcombine. Modified: llvm/trunk/lib/Target/README.txt Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=130137&r1=130136&r2=130137&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Mon Apr 25 13:44:26 2011 @@ -2305,3 +2305,50 @@ //===---------------------------------------------------------------------===// +This code: + +typedef struct { +int f1:1; +int f2:1; +int f3:1; +int f4:29; +} t1; + +typedef struct { +int f1:1; +int f2:1; +int f3:30; +} t2; + +t1 s1; +t2 s2; + +void func1(void) +{ +s1.f1 = s2.f1; +s1.f2 = s2.f2; +} + +Compiles into this IR (on x86-64 at least): + +%struct.t1 = type { i8, [3 x i8] } + at s2 = global %struct.t1 zeroinitializer, align 4 + at s1 = global %struct.t1 zeroinitializer, align 4 +define void @func1() nounwind ssp noredzone { +entry: + %0 = load i32* bitcast (%struct.t1* @s2 to i32*), align 4 + %bf.val.sext5 = and i32 %0, 1 + %1 = load i32* bitcast (%struct.t1* @s1 to i32*), align 4 + %2 = and i32 %1, -4 + %3 = or i32 %2, %bf.val.sext5 + %bf.val.sext26 = and i32 %0, 2 + %4 = or i32 %3, %bf.val.sext26 + store i32 %4, i32* bitcast (%struct.t1* @s1 to i32*), align 4 + ret void +} + +The two or/and's should be merged into one each. + +//===---------------------------------------------------------------------===// + + From arushi987 at gmail.com Mon Apr 25 08:51:04 2011 From: arushi987 at gmail.com (Arushi Aggarwal) Date: Mon, 25 Apr 2011 08:51:04 -0500 Subject: [llvm-commits] [poolalloc] r130089 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp In-Reply-To: <4DB49324.9010005@mxc.ca> References: <20110424141322.9721F2A6C12C@llvm.org> <4DB49324.9010005@mxc.ca> Message-ID: It is to avoid compilation warnings on newer gcc versions. Arushi On Sun, Apr 24, 2011 at 4:16 PM, Nick Lewycky wrote: > Arushi Aggarwal wrote: >> >> Author: aggarwa4 >> Date: Sun Apr 24 09:13:22 2011 >> New Revision: 130089 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130089&view=rev >> Log: >> First convert to std::string and then compare. > > Why? getNameStr() returns an std::string not a char*, so this should have no > semantic change. > >> >> Modified: >> ? ? poolalloc/trunk/lib/AssistDS/TypeChecks.cpp >> >> Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp >> URL: >> http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130089&r1=130088&r2=130089&view=diff >> >> ============================================================================== >> --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) >> +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Sun Apr 24 09:13:22 2011 >> @@ -312,7 +312,7 @@ >> ? ? ? ? ?CallInst::Create(F, Args.begin(), Args.end(), "", I); >> ? ? ? ? ?break; >> ? ? ? ?} >> - ? ?} else if(F->getNameStr() == "realloc") { >> + ? ?} else if(F->getNameStr() == ?std::string("realloc")) { >> ? ? ? ?CastInst *BCI_Src = >> BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy); >> ? ? ? ?CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I, VoidPtrTy); >> ? ? ? ?BCI_Src->insertAfter(I); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > From evan.cheng at apple.com Mon Apr 25 15:04:03 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 25 Apr 2011 20:04:03 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c Message-ID: <20110425200403.569702A6C12D@llvm.org> Author: evancheng Date: Mon Apr 25 15:04:03 2011 New Revision: 130139 URL: http://llvm.org/viewvc/llvm-project?rev=130139&view=rev Log: Currently -Os and -Oz are the same. Change -Oz to significantly reduce inline threshold to make it useful for code that really cares about code size. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/opts.c Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=130139&r1=130138&r2=130139&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Apr 25 15:04:03 2011 @@ -81,6 +81,9 @@ #endif } +// Non-zero if -Oz is set. +extern "C" unsigned int optimize_size_z; + // Non-zero if bytecode from PCH is successfully read. int flag_llvm_pch_read; @@ -387,7 +390,7 @@ static unsigned GuessAtInliningThreshold() { if (optimize_size) // Reduce inline limit. - return 75; + return optimize_size_z ? 25 : 75; if (optimize >= 3) return 275; Modified: llvm-gcc-4.2/trunk/gcc/opts.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/opts.c?rev=130139&r1=130138&r2=130139&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/opts.c (original) +++ llvm-gcc-4.2/trunk/gcc/opts.c Mon Apr 25 15:04:03 2011 @@ -43,6 +43,11 @@ #include "hashtab.h" #include "tree-pass.h" +#ifdef ENABLE_LLVM +/* Non-zero if -Oz is specified. */ +unsigned int optimize_size_z; +#endif + /* Value of the -G xx switch, and whether it was passed or not. */ unsigned HOST_WIDE_INT g_switch_value; bool g_switch_set; @@ -590,10 +595,16 @@ { unsigned int i, lang_mask; /* APPLE LOCAL 4231773 */ +#ifndef ENABLE_LLVM unsigned int optimize_size_z = 0; +#endif /* APPLE LOCAL AV 3846092 */ int saved_flag_strict_aliasing; +#ifdef ENABLE_LLVM + optimize_size_z = 0; +#endif + /* Perform language-specific options initialization. */ lang_mask = lang_hooks.init_options (argc, argv); From daniel at zuster.org Mon Apr 25 15:05:02 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:05:02 -0000 Subject: [llvm-commits] [test-suite] r130140 - /test-suite/trunk/RunSafely.sh Message-ID: <20110425200502.2F1DE2A6C12D@llvm.org> Author: ddunbar Date: Mon Apr 25 15:05:02 2011 New Revision: 130140 URL: http://llvm.org/viewvc/llvm-project?rev=130140&view=rev Log: RunSafely: Change to use 'sh -c' when running remotely (like we do on the host). This is necessary if TIMEIT isn't a shell builtin. Modified: test-suite/trunk/RunSafely.sh Modified: test-suite/trunk/RunSafely.sh URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/RunSafely.sh?rev=130140&r1=130139&r2=130140&view=diff ============================================================================== --- test-suite/trunk/RunSafely.sh (original) +++ test-suite/trunk/RunSafely.sh Mon Apr 25 15:05:02 2011 @@ -148,7 +148,7 @@ rm -f "$PWD/${PROG}.command" rm -f "$PWD/${PROG}.remote" rm -f "$PWD/${PROG}.remote.time" - echo "$ULIMITCMD cd $PWD; ($TIMEIT -p ($COMMAND > $PWD/${OUTFILE}.remote 2>&1 < $INFILE;); echo exit \$?) > $PWD/${OUTFILE}.remote.time 2>&1" > "$PWD/${PROG}.command" + echo "$ULIMITCMD cd $PWD; ($TIMEIT -p sh -c '($COMMAND > $PWD/${OUTFILE}.remote 2>&1 < $INFILE;)'; echo exit \$?) > $PWD/${OUTFILE}.remote.time 2>&1" > "$PWD/${PROG}.command" chmod +x "$PWD/${PROG}.command" ( $RCLIENT -l $RUSER $RHOST $RPORT "ls $PWD/${PROG}.command" ) > /dev/null 2>&1 From daniel at zuster.org Mon Apr 25 15:05:06 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:05:06 -0000 Subject: [llvm-commits] [test-suite] r130141 - /test-suite/trunk/Makefile Message-ID: <20110425200506.1FFDE2A6C12E@llvm.org> Author: ddunbar Date: Mon Apr 25 15:05:05 2011 New Revision: 130141 URL: http://llvm.org/viewvc/llvm-project?rev=130141&view=rev Log: build: Fix "make tools" to work even when a TEST=... option is set. Modified: test-suite/trunk/Makefile Modified: test-suite/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile?rev=130141&r1=130140&r2=130141&view=diff ============================================================================== --- test-suite/trunk/Makefile (original) +++ test-suite/trunk/Makefile Mon Apr 25 15:05:05 2011 @@ -22,5 +22,5 @@ $(MAKE) tools: - $(MAKE) -C tools + $(MAKE) -C tools all .PHONY: tools From daniel at zuster.org Mon Apr 25 15:05:08 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:05:08 -0000 Subject: [llvm-commits] [test-suite] r130142 - in /test-suite/trunk: Makefile.config.in tools/Makefile Message-ID: <20110425200508.6962D2A6C12F@llvm.org> Author: ddunbar Date: Mon Apr 25 15:05:08 2011 New Revision: 130142 URL: http://llvm.org/viewvc/llvm-project?rev=130142&view=rev Log: build: Add support for building a version of the 'timeit' tool which will run on the target. Modified: test-suite/trunk/Makefile.config.in test-suite/trunk/tools/Makefile Modified: test-suite/trunk/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.config.in?rev=130142&r1=130141&r2=130142&view=diff ============================================================================== --- test-suite/trunk/Makefile.config.in (original) +++ test-suite/trunk/Makefile.config.in Mon Apr 25 15:05:08 2011 @@ -71,6 +71,9 @@ SourceDir=$(PROJ_SRC_DIR) endif +ORIGINAL_CC := $(CC) +ORIGINAL_CXX := $(CC) + ifdef TARGET_ARCH ARCH := $(TARGET_ARCH) endif Modified: test-suite/trunk/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/tools/Makefile?rev=130142&r1=130141&r2=130142&view=diff ============================================================================== --- test-suite/trunk/tools/Makefile (original) +++ test-suite/trunk/tools/Makefile Mon Apr 25 15:05:08 2011 @@ -1,10 +1,16 @@ LEVEL=.. include $(LEVEL)/Makefile.programs -all:: timeit fpcmp +all:: timeit timeit-target fpcmp timeit: timeit.c - $(CC) $(CFLAGS) -O3 -o $@ $< + $(ORIGINAL_CC) $(CFLAGS) -O3 -o $@ $< + +timeit-target: timeit.c + $(LD_ENV_OVERRIDES) $(LCC) -o $@ $< $(LDFLAGS) $(CFLAGS) $(TARGET_FLAGS) -O3 fpcmp: fpcmp.c - $(CC) $(CFLAGS) -O3 -o $@ $< + $(ORIGINAL_CC) $(CFLAGS) -O3 -o $@ $< + +clean:: + rm -f timeit timeit-target fpcmp From daniel at zuster.org Mon Apr 25 15:05:10 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:05:10 -0000 Subject: [llvm-commits] [test-suite] r130143 - in /test-suite/trunk: Makefile.programs Makefile.rules Message-ID: <20110425200510.7F9772A6C12D@llvm.org> Author: ddunbar Date: Mon Apr 25 15:05:10 2011 New Revision: 130143 URL: http://llvm.org/viewvc/llvm-project?rev=130143&view=rev Log: Update to use timeit-target when running with --without-llvm. Modified: test-suite/trunk/Makefile.programs test-suite/trunk/Makefile.rules Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=130143&r1=130142&r2=130143&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon Apr 25 15:05:10 2011 @@ -137,7 +137,7 @@ endif ifdef TIMEIT -RUNSAFELY := $(RUNSAFELY) -t "$(TIMEIT)" +RUNSAFELY := $(RUNSAFELY) -t "$(TIMEIT_TARGET)" RUNSAFELYLOCAL := $(RUNSAFELYLOCAL) -t "$(TIMEIT)" endif Modified: test-suite/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.rules?rev=130143&r1=130142&r2=130143&view=diff ============================================================================== --- test-suite/trunk/Makefile.rules (original) +++ test-suite/trunk/Makefile.rules Mon Apr 25 15:05:10 2011 @@ -330,7 +330,8 @@ ifeq ($(HAS_LLVM),0) # Not strictly related to HAS_LLVM, but otherwise in generally tools weren't # being built. -TIMEIT = $(PROJ_OBJ_ROOT)/tools/timeit +TIMEIT = $(PROJ_OBJ_ROOT)/tools/timeit +TIMEIT_TARGET = $(PROJ_OBJ_ROOT)/tools/timeit-target endif LCC := $(LLVMCC) From daniel at zuster.org Mon Apr 25 15:06:22 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:06:22 -0000 Subject: [llvm-commits] [zorg] r130144 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110425200622.E192E2A6C12D@llvm.org> Author: ddunbar Date: Mon Apr 25 15:06:22 2011 New Revision: 130144 URL: http://llvm.org/viewvc/llvm-project?rev=130144&view=rev Log: LNT/nt: Error out if the test suite sources don't exist (as opposed to more confusing error later down the line). Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130144&r1=130143&r2=130144&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Mon Apr 25 15:06:22 2011 @@ -841,6 +841,9 @@ if opts.test_suite_root is None: parser.error('--test-suite is required') + elif not os.path.exists(opts.test_suite_root): + parser.error("invalid --test-suite argument, does not exist: %r" % ( + opts.test_suite_root)) if opts.remote: if opts.remote_port is None: From daniel at zuster.org Mon Apr 25 15:06:25 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:06:25 -0000 Subject: [llvm-commits] [zorg] r130145 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110425200625.A14C82A6C12E@llvm.org> Author: ddunbar Date: Mon Apr 25 15:06:25 2011 New Revision: 130145 URL: http://llvm.org/viewvc/llvm-project?rev=130145&view=rev Log: LNT/nt: Remote stray print. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130145&r1=130144&r2=130145&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Mon Apr 25 15:06:25 2011 @@ -480,7 +480,6 @@ "-l", opts.remote_user, "-p", str(opts.remote_port), opts.remote_host] - print remote_args run_info['remote_uname'] = capture(remote_args + ["uname", "-a"], include_stderr=True).strip() From daniel at zuster.org Mon Apr 25 15:06:27 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 20:06:27 -0000 Subject: [llvm-commits] [zorg] r130146 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110425200628.02D1D2A6C12F@llvm.org> Author: ddunbar Date: Mon Apr 25 15:06:27 2011 New Revision: 130146 URL: http://llvm.org/viewvc/llvm-project?rev=130146&view=rev Log: LNT/nt: When building test tools, make sure to pass the same make args as we use when testing. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130146&r1=130145&r2=130146&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Mon Apr 25 15:06:27 2011 @@ -300,8 +300,13 @@ if opts.without_llvm: print >>sys.stderr, '%s: building test-suite tools' % (timestamp(),) args = ['make', 'tools'] + args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) build_tools_log_path = os.path.join(basedir, 'build-tools.log') build_tools_log = open(build_tools_log_path, 'w') + print >>build_tools_log, '%s: running: %s' % (timestamp(), + ' '.join('"%s"' % a + for a in args)) + build_tools_log.flush() p = subprocess.Popen(args=args, stdin=None, stdout=build_tools_log, stderr=subprocess.STDOUT, cwd=basedir, env=os.environ) From echristo at apple.com Mon Apr 25 15:23:04 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 25 Apr 2011 13:23:04 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c In-Reply-To: <20110425200403.569702A6C12D@llvm.org> References: <20110425200403.569702A6C12D@llvm.org> Message-ID: <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> On Apr 25, 2011, at 1:04 PM, Evan Cheng wrote: > Author: evancheng > Date: Mon Apr 25 15:04:03 2011 > New Revision: 130139 > > URL: http://llvm.org/viewvc/llvm-project?rev=130139&view=rev > Log: > Currently -Os and -Oz are the same. Change -Oz to significantly reduce inline threshold to make it useful for code that really cares about code size. > What kind of difference did you see here? -eric From evan.cheng at apple.com Mon Apr 25 15:33:33 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 25 Apr 2011 13:33:33 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c In-Reply-To: <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> References: <20110425200403.569702A6C12D@llvm.org> <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> Message-ID: <2E4A82D7-7601-4918-9BC4-837ED0FC9C47@apple.com> Inline threshold of 25 does very little automatic inlining. Evan On Apr 25, 2011, at 1:23 PM, Eric Christopher wrote: > > On Apr 25, 2011, at 1:04 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Mon Apr 25 15:04:03 2011 >> New Revision: 130139 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130139&view=rev >> Log: >> Currently -Os and -Oz are the same. Change -Oz to significantly reduce inline threshold to make it useful for code that really cares about code size. >> > > What kind of difference did you see here? > > -eric > From echristo at apple.com Mon Apr 25 15:53:54 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 25 Apr 2011 13:53:54 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c In-Reply-To: <2E4A82D7-7601-4918-9BC4-837ED0FC9C47@apple.com> References: <20110425200403.569702A6C12D@llvm.org> <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> <2E4A82D7-7601-4918-9BC4-837ED0FC9C47@apple.com> Message-ID: <3A40550B-E6BA-47FA-9E3C-0F3727D44292@apple.com> On Apr 25, 2011, at 1:33 PM, Evan Cheng wrote: > Inline threshold of 25 does very little automatic inlining. > *nod* I was just wondering what kind of space savings you saw. Last time I mucked around with it here I didn't see much if any. -eric From evan.cheng at apple.com Mon Apr 25 16:00:09 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 25 Apr 2011 14:00:09 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c In-Reply-To: <3A40550B-E6BA-47FA-9E3C-0F3727D44292@apple.com> References: <20110425200403.569702A6C12D@llvm.org> <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> <2E4A82D7-7601-4918-9BC4-837ED0FC9C47@apple.com> <3A40550B-E6BA-47FA-9E3C-0F3727D44292@apple.com> Message-ID: <0F2F153C-67E8-49D4-A475-AD8BE05155A4@apple.com> On Apr 25, 2011, at 1:53 PM, Eric Christopher wrote: > > On Apr 25, 2011, at 1:33 PM, Evan Cheng wrote: > >> Inline threshold of 25 does very little automatic inlining. >> > > *nod* I was just wondering what kind of space savings you saw. > Last time I mucked around with it here I didn't see much if any. It depends on the project. For deeply embedded project, it could make enough of a difference to matter. Evan > > -eric > From echristo at apple.com Mon Apr 25 16:00:55 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 25 Apr 2011 14:00:55 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r130139 - in /llvm-gcc-4.2/trunk/gcc: llvm-backend.cpp opts.c In-Reply-To: <0F2F153C-67E8-49D4-A475-AD8BE05155A4@apple.com> References: <20110425200403.569702A6C12D@llvm.org> <121EFC40-8E7C-4E08-9B48-953338DD976B@apple.com> <2E4A82D7-7601-4918-9BC4-837ED0FC9C47@apple.com> <3A40550B-E6BA-47FA-9E3C-0F3727D44292@apple.com> <0F2F153C-67E8-49D4-A475-AD8BE05155A4@apple.com> Message-ID: <2C8AE131-B3CB-4558-B299-16FE85CDD949@apple.com> On Apr 25, 2011, at 2:00 PM, Evan Cheng wrote: > > On Apr 25, 2011, at 1:53 PM, Eric Christopher wrote: > >> >> On Apr 25, 2011, at 1:33 PM, Evan Cheng wrote: >> >>> Inline threshold of 25 does very little automatic inlining. >>> >> >> *nod* I was just wondering what kind of space savings you saw. >> Last time I mucked around with it here I didn't see much if any. > > It depends on the project. For deeply embedded project, it could make enough of a difference to matter. *nod* I agree. I just hadn't seen anything. If you've seen some decent results in a couple of projects that really care then awesome :) -eric From sabre at nondot.org Mon Apr 25 15:58:50 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 25 Apr 2011 20:58:50 -0000 Subject: [llvm-commits] [llvm] r130151 - in /llvm/trunk: include/llvm/ADT/FoldingSet.h lib/Support/FoldingSet.cpp Message-ID: <20110425205850.5DCCB2A6C12D@llvm.org> Author: lattner Date: Mon Apr 25 15:58:50 2011 New Revision: 130151 URL: http://llvm.org/viewvc/llvm-project?rev=130151&view=rev Log: allow adding a FoldingSetNodeID to a FastFoldingSetNode, resolving PR9499, patch by Johannes Schaub! Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h llvm/trunk/lib/Support/FoldingSet.cpp Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FoldingSet.h?rev=130151&r1=130150&r2=130151&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/FoldingSet.h (original) +++ llvm/trunk/include/llvm/ADT/FoldingSet.h Mon Apr 25 15:58:50 2011 @@ -310,6 +310,7 @@ void AddInteger(unsigned long long I); void AddBoolean(bool B) { AddInteger(B ? 1U : 0U); } void AddString(StringRef String); + void AddNodeID(const FoldingSetNodeID &ID); template inline void Add(const T& x) { FoldingSetTrait::Profile(x, *this); } @@ -641,7 +642,7 @@ : data(a1,a2,a3,a4,a5) {} - void Profile(FoldingSetNodeID& ID) { FoldingSetTrait::Profile(data, ID); } + void Profile(FoldingSetNodeID &ID) { FoldingSetTrait::Profile(data, ID); } T& getValue() { return data; } const T& getValue() const { return data; } @@ -661,7 +662,9 @@ protected: explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {} public: - void Profile(FoldingSetNodeID& ID) const { ID = FastID; } + void Profile(FoldingSetNodeID& ID) const { + ID.AddNodeID(FastID); + } }; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Support/FoldingSet.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FoldingSet.cpp?rev=130151&r1=130150&r2=130151&view=diff ============================================================================== --- llvm/trunk/lib/Support/FoldingSet.cpp (original) +++ llvm/trunk/lib/Support/FoldingSet.cpp Mon Apr 25 15:58:50 2011 @@ -147,6 +147,11 @@ Bits.push_back(V); } +// AddNodeID - Adds the Bit data of another ID to *this. +void FoldingSetNodeID::AddNodeID(const FoldingSetNodeID &ID) { + Bits.append(ID.Bits.begin(), ID.Bits.end()); +} + /// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to /// lookup the node in the FoldingSetImpl. unsigned FoldingSetNodeID::ComputeHash() const { From sabre at nondot.org Mon Apr 25 16:02:12 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 25 Apr 2011 21:02:12 -0000 Subject: [llvm-commits] [llvm] r130153 - /llvm/trunk/include/llvm/ADT/FoldingSet.h Message-ID: <20110425210212.E335F2A6C12D@llvm.org> Author: lattner Date: Mon Apr 25 16:02:12 2011 New Revision: 130153 URL: http://llvm.org/viewvc/llvm-project?rev=130153&view=rev Log: Improve adherence to general style, use "foo_t &x" instead of "foo_t& x" Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FoldingSet.h?rev=130153&r1=130152&r2=130153&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/FoldingSet.h (original) +++ llvm/trunk/include/llvm/ADT/FoldingSet.h Mon Apr 25 16:02:12 2011 @@ -209,10 +209,10 @@ /// for FoldingSetTrait implementations. /// template struct DefaultFoldingSetTrait { - static void Profile(const T& X, FoldingSetNodeID& ID) { + static void Profile(const T &X, FoldingSetNodeID &ID) { X.Profile(ID); } - static void Profile(T& X, FoldingSetNodeID& ID) { + static void Profile(T &X, FoldingSetNodeID &ID) { X.Profile(ID); } @@ -267,7 +267,7 @@ /// is often much larger than necessary, and the possibility of heap /// allocation means it requires a non-trivial destructor call. class FoldingSetNodeIDRef { - const unsigned* Data; + const unsigned *Data; size_t Size; public: FoldingSetNodeIDRef() : Data(0), Size(0) {} @@ -313,7 +313,7 @@ void AddNodeID(const FoldingSetNodeID &ID); template - inline void Add(const T& x) { FoldingSetTrait::Profile(x, *this); } + inline void Add(const T &x) { FoldingSetTrait::Profile(x, *this); } /// clear - Clear the accumulated profile, allowing this FoldingSetNodeID /// object to be used to compute a new profile. @@ -549,7 +549,7 @@ return static_cast(NodePtr); } - inline FoldingSetIterator& operator++() { // Preincrement + inline FoldingSetIterator &operator++() { // Preincrement advance(); return *this; } @@ -597,10 +597,10 @@ FoldingSetBucketIterator(void **Bucket, bool) : FoldingSetBucketIteratorImpl(Bucket, true) {} - T& operator*() const { return *static_cast(Ptr); } - T* operator->() const { return static_cast(Ptr); } + T &operator*() const { return *static_cast(Ptr); } + T *operator->() const { return static_cast(Ptr); } - inline FoldingSetBucketIterator& operator++() { // Preincrement + inline FoldingSetBucketIterator &operator++() { // Preincrement advance(); return *this; } @@ -616,36 +616,36 @@ class FoldingSetNodeWrapper : public FoldingSetNode { T data; public: - explicit FoldingSetNodeWrapper(const T& x) : data(x) {} + explicit FoldingSetNodeWrapper(const T &x) : data(x) {} virtual ~FoldingSetNodeWrapper() {} template - explicit FoldingSetNodeWrapper(const A1& a1) + explicit FoldingSetNodeWrapper(const A1 &a1) : data(a1) {} template - explicit FoldingSetNodeWrapper(const A1& a1, const A2& a2) + explicit FoldingSetNodeWrapper(const A1 &a1, const A2 &a2) : data(a1,a2) {} template - explicit FoldingSetNodeWrapper(const A1& a1, const A2& a2, const A3& a3) + explicit FoldingSetNodeWrapper(const A1 &a1, const A2 &a2, const A3 &a3) : data(a1,a2,a3) {} template - explicit FoldingSetNodeWrapper(const A1& a1, const A2& a2, const A3& a3, - const A4& a4) + explicit FoldingSetNodeWrapper(const A1 &a1, const A2 &a2, const A3 &a3, + const A4 &a4) : data(a1,a2,a3,a4) {} template - explicit FoldingSetNodeWrapper(const A1& a1, const A2& a2, const A3& a3, - const A4& a4, const A5& a5) + explicit FoldingSetNodeWrapper(const A1 &a1, const A2 &a2, const A3 &a3, + const A4 &a4, const A5 &a5) : data(a1,a2,a3,a4,a5) {} void Profile(FoldingSetNodeID &ID) { FoldingSetTrait::Profile(data, ID); } - T& getValue() { return data; } - const T& getValue() const { return data; } + T &getValue() { return data; } + const T &getValue() const { return data; } operator T&() { return data; } operator const T&() const { return data; } @@ -662,7 +662,7 @@ protected: explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {} public: - void Profile(FoldingSetNodeID& ID) const { + void Profile(FoldingSetNodeID &ID) const { ID.AddNodeID(FastID); } }; @@ -671,13 +671,13 @@ // Partial specializations of FoldingSetTrait. template struct FoldingSetTrait { - static inline void Profile(const T* X, FoldingSetNodeID& ID) { + static inline void Profile(const T *X, FoldingSetNodeID &ID) { ID.AddPointer(X); } }; template struct FoldingSetTrait { - static inline void Profile(const T* X, FoldingSetNodeID& ID) { + static inline void Profile(const T *X, FoldingSetNodeID &ID) { ID.AddPointer(X); } }; From sabre at nondot.org Mon Apr 25 17:14:33 2011 From: sabre at nondot.org (Chris Lattner) Date: Mon, 25 Apr 2011 22:14:33 -0000 Subject: [llvm-commits] [llvm] r130160 - /llvm/trunk/lib/VMCore/Function.cpp Message-ID: <20110425221433.59D6E2A6C12D@llvm.org> Author: lattner Date: Mon Apr 25 17:14:33 2011 New Revision: 130160 URL: http://llvm.org/viewvc/llvm-project?rev=130160&view=rev Log: mark a large static table static. Pointed out by Michael Ilseman! Modified: llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=130160&r1=130159&r2=130160&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Apr 25 17:14:33 2011 @@ -328,7 +328,7 @@ std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); - const char * const Table[] = { + static const char * const Table[] = { "not_intrinsic", #define GET_INTRINSIC_NAME_TABLE #include "llvm/Intrinsics.gen" From echristo at apple.com Mon Apr 25 17:39:46 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 25 Apr 2011 22:39:46 -0000 Subject: [llvm-commits] [llvm] r130165 - /llvm/trunk/test/CodeGen/ARM/vst3.ll Message-ID: <20110425223946.DA7002A6C12D@llvm.org> Author: echristo Date: Mon Apr 25 17:39:46 2011 New Revision: 130165 URL: http://llvm.org/viewvc/llvm-project?rev=130165&view=rev Log: Make this test disable fast isel as it's not needed. Modified: llvm/trunk/test/CodeGen/ARM/vst3.ll Modified: llvm/trunk/test/CodeGen/ARM/vst3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/vst3.ll?rev=130165&r1=130164&r2=130165&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/vst3.ll (original) +++ llvm/trunk/test/CodeGen/ARM/vst3.ll Mon Apr 25 17:39:46 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -march=arm -mattr=+neon -O0 | FileCheck %s +; RUN: llc < %s -march=arm -mattr=+neon -disable-arm-fast-isel -O0 | FileCheck %s define void @vst3i8(i8* %A, <8 x i8>* %B) nounwind { ;CHECK: vst3i8: From gohman at apple.com Mon Apr 25 17:48:30 2011 From: gohman at apple.com (Dan Gohman) Date: Mon, 25 Apr 2011 22:48:30 -0000 Subject: [llvm-commits] [llvm] r130166 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20110425224830.2AAAD2A6C12D@llvm.org> Author: djg Date: Mon Apr 25 17:48:29 2011 New Revision: 130166 URL: http://llvm.org/viewvc/llvm-project?rev=130166&view=rev Log: Fix an iterator invalidation bug. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=130166&r1=130165&r2=130166&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Apr 25 17:48:29 2011 @@ -3788,19 +3788,20 @@ if (!Pair.second) return Pair.first->second; - BackedgeTakenInfo BECount = ComputeBackedgeTakenCount(L); - if (BECount.Exact != getCouldNotCompute()) { - assert(isLoopInvariant(BECount.Exact, L) && - isLoopInvariant(BECount.Max, L) && + BackedgeTakenInfo Result = getCouldNotCompute(); + BackedgeTakenInfo Computed = ComputeBackedgeTakenCount(L); + if (Computed.Exact != getCouldNotCompute()) { + assert(isLoopInvariant(Computed.Exact, L) && + isLoopInvariant(Computed.Max, L) && "Computed backedge-taken count isn't loop invariant for loop!"); ++NumTripCountsComputed; // Update the value in the map. - Pair.first->second = BECount; + Result = Computed; } else { - if (BECount.Max != getCouldNotCompute()) + if (Computed.Max != getCouldNotCompute()) // Update the value in the map. - Pair.first->second = BECount; + Result = Computed; if (isa(L->getHeader()->begin())) // Only count loops that have phi nodes as not being computable. ++NumTripCountsNotComputed; @@ -3811,7 +3812,7 @@ // conservative estimates made without the benefit of trip count // information. This is similar to the code in forgetLoop, except that // it handles SCEVUnknown PHI nodes specially. - if (BECount.hasAnyInfo()) { + if (Computed.hasAnyInfo()) { SmallVector Worklist; PushLoopPHIs(L, Worklist); @@ -3842,7 +3843,13 @@ PushDefUseChildren(I, Worklist); } } - return Pair.first->second; + + // Re-lookup the insert position, since the call to + // ComputeBackedgeTakenCount above could result in a + // recusive call to getBackedgeTakenInfo (on a different + // loop), which would invalidate the iterator computed + // earlier. + return BackedgeTakenCounts.find(L)->second = Result; } /// forgetLoop - This method should be called by the client when it has From dpatel at apple.com Mon Apr 25 17:52:55 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 25 Apr 2011 22:52:55 -0000 Subject: [llvm-commits] [llvm] r130167 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110425225255.607112A6C12D@llvm.org> Author: dpatel Date: Mon Apr 25 17:52:55 2011 New Revision: 130167 URL: http://llvm.org/viewvc/llvm-project?rev=130167&view=rev Log: Do not drop a variable's complex address if it is not based on frame base. Observed this while reading code, so I do not have a test case handy here. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130167&r1=130166&r2=130167&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 25 17:52:55 2011 @@ -709,7 +709,11 @@ } else { MachineLocation Location = Asm->getDebugValueLocation(DVInsn); if (Location.getReg()) { - TheCU->addAddress(VariableDie, dwarf::DW_AT_location, Location); + if (DV->getVariable().hasComplexAddress()) + TheCU->addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, + Location); + else + TheCU->addAddress(VariableDie, dwarf::DW_AT_location, Location); updated = true; } } From dpatel at apple.com Mon Apr 25 18:02:17 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 25 Apr 2011 23:02:17 -0000 Subject: [llvm-commits] [llvm] r130170 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h DwarfDebug.cpp Message-ID: <20110425230217.6B8272A6C12D@llvm.org> Author: dpatel Date: Mon Apr 25 18:02:17 2011 New Revision: 130170 URL: http://llvm.org/viewvc/llvm-project?rev=130170&view=rev Log: Rename a method to match what it really does. s/addVariableAddress/addFrameVariableAddress/g Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=130170&r1=130169&r2=130170&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Apr 25 18:02:17 2011 @@ -192,9 +192,10 @@ addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); } -/// addVariableAddress - Add DW_AT_location attribute for a DbgVariable based -/// on provided frame index. -void CompileUnit::addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI) { +/// addFrameVariableAddress - Add DW_AT_location attribute for a +/// DbgVariable based on provided frame index. +void CompileUnit::addFrameVariableAddress(DbgVariable *&DV, DIE *Die, + int64_t FI) { MachineLocation Location; unsigned FrameReg; const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=130170&r1=130169&r2=130170&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Mon Apr 25 18:02:17 2011 @@ -212,9 +212,9 @@ void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location); - /// addVariableAddress - Add DW_AT_location attribute for a DbgVariable based - /// on provided frame index. - void addVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI); + /// addFrameVariableAddress - Add DW_AT_location attribute for a DbgVariable + /// based on provided frame index. + void addFrameVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI); /// addToContextOwner - Add Die into the list of its context owner's children. void addToContextOwner(DIE *Die, DIDescriptor Context); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130170&r1=130169&r2=130170&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 25 18:02:17 2011 @@ -696,7 +696,8 @@ const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); if (DVInsn->getOperand(1).isImm() && TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { - TheCU->addVariableAddress(DV, VariableDie, DVInsn->getOperand(1).getImm()); + TheCU->addFrameVariableAddress(DV, VariableDie, + DVInsn->getOperand(1).getImm()); updated = true; } else updated = TheCU->addRegisterAddress(VariableDie, RegOp); @@ -730,7 +731,7 @@ // .. else use frame index, if available. int FI = 0; if (findVariableFrameIndex(DV, &FI)) - TheCU->addVariableAddress(DV, VariableDie, FI); + TheCU->addFrameVariableAddress(DV, VariableDie, FI); DV->setDIE(VariableDie); return VariableDie; From dpatel at apple.com Mon Apr 25 18:05:21 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 25 Apr 2011 23:05:21 -0000 Subject: [llvm-commits] [llvm] r130171 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20110425230521.E66FB2A6C12D@llvm.org> Author: dpatel Date: Mon Apr 25 18:05:21 2011 New Revision: 130171 URL: http://llvm.org/viewvc/llvm-project?rev=130171&view=rev Log: Rename a local variable. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130171&r1=130170&r2=130171&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Apr 25 18:05:21 2011 @@ -644,7 +644,7 @@ // Define variable debug information entry. DIE *VariableDie = new DIE(Tag); - CompileUnit *TheCU = getCompileUnit(DV->getVariable()); + CompileUnit *VariableCU = getCompileUnit(DV->getVariable()); DIE *AbsDIE = NULL; DenseMap::iterator V2AVI = VarToAbstractVarMap.find(DV); @@ -652,20 +652,23 @@ AbsDIE = V2AVI->second->getDIE(); if (AbsDIE) - TheCU->addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin, + VariableCU->addDIEEntry(VariableDie, dwarf::DW_AT_abstract_origin, dwarf::DW_FORM_ref4, AbsDIE); else { - TheCU->addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); - TheCU->addSourceLine(VariableDie, DV->getVariable()); + VariableCU->addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, + Name); + VariableCU->addSourceLine(VariableDie, DV->getVariable()); // Add variable type. - TheCU->addType(VariableDie, DV->getType()); + VariableCU->addType(VariableDie, DV->getType()); } if (Tag == dwarf::DW_TAG_formal_parameter && DV->getType().isArtificial()) - TheCU->addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); + VariableCU->addUInt(VariableDie, dwarf::DW_AT_artificial, + dwarf::DW_FORM_flag, 1); else if (DIVariable(DV->getVariable()).isArtificial()) - TheCU->addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); + VariableCU->addUInt(VariableDie, dwarf::DW_AT_artificial, + dwarf::DW_FORM_flag, 1); if (Scope->isAbstractScope()) { DV->setDIE(VariableDie); @@ -676,7 +679,7 @@ unsigned Offset = DV->getDotDebugLocOffset(); if (Offset != ~0U) { - TheCU->addLabel(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_data4, + VariableCU->addLabel(VariableDie, dwarf::DW_AT_location, dwarf::DW_FORM_data4, Asm->GetTempSymbol("debug_loc", Offset)); DV->setDIE(VariableDie); UseDotDebugLocEntry.insert(VariableDie); @@ -696,25 +699,26 @@ const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); if (DVInsn->getOperand(1).isImm() && TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { - TheCU->addFrameVariableAddress(DV, VariableDie, - DVInsn->getOperand(1).getImm()); + VariableCU->addFrameVariableAddress(DV, VariableDie, + DVInsn->getOperand(1).getImm()); updated = true; } else - updated = TheCU->addRegisterAddress(VariableDie, RegOp); + updated = VariableCU->addRegisterAddress(VariableDie, RegOp); } else if (DVInsn->getOperand(0).isImm()) - updated = TheCU->addConstantValue(VariableDie, DVInsn->getOperand(0)); + updated = VariableCU->addConstantValue(VariableDie, + DVInsn->getOperand(0)); else if (DVInsn->getOperand(0).isFPImm()) updated = - TheCU->addConstantFPValue(VariableDie, DVInsn->getOperand(0)); + VariableCU->addConstantFPValue(VariableDie, DVInsn->getOperand(0)); } else { MachineLocation Location = Asm->getDebugValueLocation(DVInsn); if (Location.getReg()) { if (DV->getVariable().hasComplexAddress()) - TheCU->addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, - Location); + VariableCU->addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, + Location); else - TheCU->addAddress(VariableDie, dwarf::DW_AT_location, Location); + VariableCU->addAddress(VariableDie, dwarf::DW_AT_location, Location); updated = true; } } @@ -731,7 +735,7 @@ // .. else use frame index, if available. int FI = 0; if (findVariableFrameIndex(DV, &FI)) - TheCU->addFrameVariableAddress(DV, VariableDie, FI); + VariableCU->addFrameVariableAddress(DV, VariableDie, FI); DV->setDIE(VariableDie); return VariableDie; From daniel at zuster.org Mon Apr 25 18:15:19 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Mon, 25 Apr 2011 23:15:19 -0000 Subject: [llvm-commits] [zorg] r130173 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110425231519.408992A6C12D@llvm.org> Author: ddunbar Date: Mon Apr 25 18:15:19 2011 New Revision: 130173 URL: http://llvm.org/viewvc/llvm-project?rev=130173&view=rev Log: LNT/nt: Always report a run_order, some parts of the server now depend on its presence. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130173&r1=130172&r2=130173&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Mon Apr 25 18:15:19 2011 @@ -539,6 +539,11 @@ elif run_info.get('llvm_revision','').isdigit(): run_info['run_order'] = run_info['llvm_revision'] + # Otherwise, force at least some value for run_order, as it is now + # generally required by parts of the "simple" schema. + else: + run_info['run_order'] = "0" + if 'run_order' in run_info: run_info['run_order'] = '%7d' % int(run_info['run_order']) From dpatel at apple.com Mon Apr 25 19:12:46 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 26 Apr 2011 00:12:46 -0000 Subject: [llvm-commits] [llvm] r130178 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMAsmPrinter.h Message-ID: <20110426001246.4A7A52A6C12D@llvm.org> Author: dpatel Date: Mon Apr 25 19:12:46 2011 New Revision: 130178 URL: http://llvm.org/viewvc/llvm-project?rev=130178&view=rev Log: Let dwarf writer allocate extra space in the debug location expression. This space, if requested, will be used for complex addresses of the Blocks' variables. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130178&r1=130177&r2=130178&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Mon Apr 25 19:12:46 2011 @@ -384,7 +384,8 @@ virtual unsigned getISAEncoding() { return 0; } /// EmitDwarfRegOp - Emit dwarf register operation. - virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; + virtual void EmitDwarfRegOp(const MachineLocation &MLoc, + unsigned ExtraExprSize = 0) const; //===------------------------------------------------------------------===// // Dwarf Lowering Routines Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130178&r1=130177&r2=130178&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Apr 25 19:12:46 2011 @@ -753,7 +753,8 @@ } /// EmitDwarfRegOp - Emit dwarf register operation. -void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { +void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc, + unsigned ExtraExprSize) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); unsigned Reg = RI->getDwarfRegNum(MLoc.getReg(), false); if (int Offset = MLoc.getOffset()) { @@ -761,7 +762,7 @@ // use DW_OP_fbreg. unsigned OffsetSize = Offset ? MCAsmInfo::getSLEB128Size(Offset) : 1; OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + OffsetSize); + EmitInt16(1 + OffsetSize + ExtraExprSize); OutStreamer.AddComment( dwarf::OperationEncodingString(dwarf::DW_OP_fbreg)); EmitInt8(dwarf::DW_OP_fbreg); @@ -776,7 +777,7 @@ EmitInt8(dwarf::DW_OP_reg0 + Reg); } else { OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + MCAsmInfo::getULEB128Size(Reg)); + EmitInt16(1 + MCAsmInfo::getULEB128Size(Reg) + ExtraExprSize); OutStreamer.AddComment( dwarf::OperationEncodingString(dwarf::DW_OP_regx)); EmitInt8(dwarf::DW_OP_regx); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=130178&r1=130177&r2=130178&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Mon Apr 25 19:12:46 2011 @@ -173,10 +173,11 @@ } /// EmitDwarfRegOp - Emit dwarf register operation. -void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { +void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc, + unsigned ExtraExprSize) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); if (RI->getDwarfRegNum(MLoc.getReg(), false) != -1) - AsmPrinter::EmitDwarfRegOp(MLoc); + AsmPrinter::EmitDwarfRegOp(MLoc, ExtraExprSize); else { unsigned Reg = MLoc.getReg(); if (Reg >= ARM::S0 && Reg <= ARM::S31) { @@ -191,7 +192,7 @@ OutStreamer.AddComment("Loc expr size"); // DW_OP_regx + ULEB + DW_OP_bit_piece + ULEB + ULEB // 1 + ULEB(Rx) + 1 + 1 + 1 - EmitInt16(4 + MCAsmInfo::getULEB128Size(Rx)); + EmitInt16(4 + MCAsmInfo::getULEB128Size(Rx) + ExtraExprSize); OutStreamer.AddComment("DW_OP_regx for S register"); EmitInt8(dwarf::DW_OP_regx); @@ -223,7 +224,8 @@ // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8) + // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8); // 6 + ULEB(D1) + ULEB(D2) - EmitInt16(6 + MCAsmInfo::getULEB128Size(D1) + MCAsmInfo::getULEB128Size(D2)); + EmitInt16(6 + MCAsmInfo::getULEB128Size(D1) + + MCAsmInfo::getULEB128Size(D2) + ExtraExprSize); OutStreamer.AddComment("DW_OP_regx for Q register: D1"); EmitInt8(dwarf::DW_OP_regx); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h?rev=130178&r1=130177&r2=130178&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h Mon Apr 25 19:12:46 2011 @@ -90,7 +90,8 @@ MachineLocation getDebugValueLocation(const MachineInstr *MI) const; /// EmitDwarfRegOp - Emit dwarf register operation. - virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; + virtual void EmitDwarfRegOp(const MachineLocation &MLoc, + unsigned ExtraExprSize = 0) const; virtual unsigned getISAEncoding() { // ARM/Darwin adds ISA to the DWARF info for each function. From sabre at nondot.org Mon Apr 25 20:21:15 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 01:21:15 -0000 Subject: [llvm-commits] [llvm] r130180 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll Message-ID: <20110426012115.805492A6C12D@llvm.org> Author: lattner Date: Mon Apr 25 20:21:15 2011 New Revision: 130180 URL: http://llvm.org/viewvc/llvm-project?rev=130180&view=rev Log: Enhance MemDep: When alias analysis returns a partial alias result, return it as a clobber. This allows GVN to do smart things. Enhance GVN to be smart about the case when a small load is clobbered by a larger overlapping load. In this case, forward the value. This allows us to compile stuff like this: int test(void *P) { int tmp = *(unsigned int*)P; return tmp+*((unsigned char*)P+1); } into: _test: ## @test movl (%rdi), %ecx movzbl %ch, %eax addl %ecx, %eax ret which has one load. We already handled the case where the smaller load was from a must-aliased base pointer. Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=130180&r1=130179&r2=130180&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Mon Apr 25 20:21:15 2011 @@ -48,6 +48,11 @@ /// this occurs when we see a may-aliased store to the memory location we /// care about. /// + /// There are several cases that may be interesting here: + /// 1. Loads are clobbered by may-alias stores. + /// 2. Loads are considered clobbered by partially-aliased loads. The + /// client may choose to analyze deeper into these cases. + /// /// A dependence query on the first instruction of the entry block will /// return a clobber(self) result. Clobber, Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=130180&r1=130179&r2=130180&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Mon Apr 25 20:21:15 2011 @@ -291,16 +291,26 @@ if (R == AliasAnalysis::NoAlias) continue; - // May-alias loads don't depend on each other without a dependence. - if (isLoad && R != AliasAnalysis::MustAlias) + if (isLoad) { + // Must aliased loads are defs of each other. + if (R == AliasAnalysis::MustAlias) + return MemDepResult::getDef(Inst); + + // If we have a partial alias, then return this as a clobber for the + // client to handle. + if (R == AliasAnalysis::PartialAlias) + return MemDepResult::getClobber(Inst); + + // Random may-alias loads don't depend on each other without a + // dependence. continue; + } // Stores don't alias loads from read-only memory. - if (!isLoad && AA->pointsToConstantMemory(LoadLoc)) + if (AA->pointsToConstantMemory(LoadLoc)) continue; - // Stores depend on may and must aliased loads, loads depend on must-alias - // loads. + // Stores depend on may/must aliased loads. return MemDepResult::getDef(Inst); } Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130180&r1=130179&r2=130180&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Mon Apr 25 20:21:15 2011 @@ -636,10 +636,9 @@ // If the store and reload are the same size, we can always reuse it. if (StoreSize == LoadSize) { - if (StoredValTy->isPointerTy() && LoadedTy->isPointerTy()) { - // Pointer to Pointer -> use bitcast. + // Pointer to Pointer -> use bitcast. + if (StoredValTy->isPointerTy() && LoadedTy->isPointerTy()) return new BitCastInst(StoredVal, LoadedTy, "", InsertPt); - } // Convert source pointers to integers, which can be bitcast. if (StoredValTy->isPointerTy()) { @@ -796,6 +795,22 @@ StorePtr, StoreSize, TD); } +/// AnalyzeLoadFromClobberingLoad - This function is called when we have a +/// memdep query of a load that ends up being clobbered by another load. See if +/// the other load can feed into the second load. +static int AnalyzeLoadFromClobberingLoad(const Type *LoadTy, Value *LoadPtr, + LoadInst *DepLI, const TargetData &TD){ + // Cannot handle reading from store of first-class aggregate yet. + if (DepLI->getType()->isStructTy() || DepLI->getType()->isArrayTy()) + return -1; + + Value *DepPtr = DepLI->getPointerOperand(); + uint64_t DepSize = TD.getTypeSizeInBits(DepLI->getType()); + return AnalyzeLoadFromClobberingWrite(LoadTy, LoadPtr, DepPtr, DepSize, TD); +} + + + static int AnalyzeLoadFromClobberingMemInst(const Type *LoadTy, Value *LoadPtr, MemIntrinsic *MI, const TargetData &TD) { @@ -1129,6 +1144,26 @@ } } } + + // Check to see if we have something like this: + // load i32* P + // load i8* (P+1) + // if we have this, replace the later with an extraction from the former. + if (LoadInst *DepLI = dyn_cast(DepInfo.getInst())) { + // If this is a clobber and L is the first instruction in its block, then + // we have the first instruction in the entry block. + if (DepLI != LI && Address && TD) { + int Offset = AnalyzeLoadFromClobberingLoad(LI->getType(), + LI->getPointerOperand(), + DepLI, *TD); + + if (Offset != -1) { + ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, DepLI, + Offset)); + continue; + } + } + } // If the clobbering value is a memset/memcpy/memmove, see if we can // forward a value on from it. @@ -1454,8 +1489,9 @@ // ... to a pointer that has been loaded from before... MemDepResult Dep = MD->getDependency(L); - // If the value isn't available, don't do anything! - if (Dep.isClobber()) { + // If we have a clobber and target data is around, see if this is a clobber + // that we can fix up through code synthesis. + if (Dep.isClobber() && TD) { // Check to see if we have something like this: // store i32 123, i32* %P // %A = bitcast i32* %P to i8* @@ -1467,26 +1503,40 @@ // completely covers this load. This sort of thing can happen in bitfield // access code. Value *AvailVal = 0; - if (StoreInst *DepSI = dyn_cast(Dep.getInst())) - if (TD) { - int Offset = AnalyzeLoadFromClobberingStore(L->getType(), - L->getPointerOperand(), - DepSI, *TD); - if (Offset != -1) - AvailVal = GetStoreValueForLoad(DepSI->getValueOperand(), Offset, - L->getType(), L, *TD); - } + if (StoreInst *DepSI = dyn_cast(Dep.getInst())) { + int Offset = AnalyzeLoadFromClobberingStore(L->getType(), + L->getPointerOperand(), + DepSI, *TD); + if (Offset != -1) + AvailVal = GetStoreValueForLoad(DepSI->getValueOperand(), Offset, + L->getType(), L, *TD); + } + + // Check to see if we have something like this: + // load i32* P + // load i8* (P+1) + // if we have this, replace the later with an extraction from the former. + if (LoadInst *DepLI = dyn_cast(Dep.getInst())) { + // If this is a clobber and L is the first instruction in its block, then + // we have the first instruction in the entry block. + if (DepLI == L) + return false; + + int Offset = AnalyzeLoadFromClobberingLoad(L->getType(), + L->getPointerOperand(), + DepLI, *TD); + if (Offset != -1) + AvailVal = GetStoreValueForLoad(DepLI, Offset, L->getType(), L, *TD); + } // If the clobbering value is a memset/memcpy/memmove, see if we can forward // a value on from it. if (MemIntrinsic *DepMI = dyn_cast(Dep.getInst())) { - if (TD) { - int Offset = AnalyzeLoadFromClobberingMemInst(L->getType(), - L->getPointerOperand(), - DepMI, *TD); - if (Offset != -1) - AvailVal = GetMemInstValueForLoad(DepMI, Offset, L->getType(), L,*TD); - } + int Offset = AnalyzeLoadFromClobberingMemInst(L->getType(), + L->getPointerOperand(), + DepMI, *TD); + if (Offset != -1) + AvailVal = GetMemInstValueForLoad(DepMI, Offset, L->getType(), L, *TD); } if (AvailVal) { @@ -1502,9 +1552,12 @@ ++NumGVNLoad; return true; } - + } + + // If the value isn't available, don't do anything! + if (Dep.isClobber()) { DEBUG( - // fast print dep, using operator<< on instruction would be too slow + // fast print dep, using operator<< on instruction is too slow. dbgs() << "GVN: load "; WriteAsOperand(dbgs(), L); Instruction *I = Dep.getInst(); @@ -1556,7 +1609,8 @@ // (depending on its type). if (DepLI->getType() != L->getType()) { if (TD) { - AvailableVal = CoerceAvailableValueToLoadType(DepLI, L->getType(), L,*TD); + AvailableVal = CoerceAvailableValueToLoadType(DepLI, L->getType(), + L, *TD); if (AvailableVal == 0) return false; Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=130180&r1=130179&r2=130180&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Mon Apr 25 20:21:15 2011 @@ -544,3 +544,30 @@ ; CHECK: ret i32 0 } + +;;===----------------------------------------------------------------------===;; +;; Load -> Load forwarding in partial alias case. +;;===----------------------------------------------------------------------===;; + +define i32 @load_load_partial_alias(i8* %P) nounwind ssp { +entry: + %0 = bitcast i8* %P to i32* + %tmp2 = load i32* %0 + %add.ptr = getelementptr inbounds i8* %P, i64 1 + %tmp5 = load i8* %add.ptr + %conv = zext i8 %tmp5 to i32 + %add = add nsw i32 %tmp2, %conv + ret i32 %add + +; CHECK: @load_load_partial_alias +; CHECK: load i32* +; CHECK-NOT: load +; CHECK: lshr i32 {{.*}}, 8 +; CHECK-NOT: load +; CHECK: trunc i32 {{.*}} to i8 +; CHECK-NOT: load +; CHECK: ret i32 +} + + + From rafael.espindola at gmail.com Mon Apr 25 21:17:58 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 26 Apr 2011 02:17:58 -0000 Subject: [llvm-commits] [llvm] r130181 - in /llvm/trunk/lib/MC: MCAssembler.cpp MCObjectStreamer.cpp Message-ID: <20110426021758.595952A6C12D@llvm.org> Author: rafael Date: Mon Apr 25 21:17:58 2011 New Revision: 130181 URL: http://llvm.org/viewvc/llvm-project?rev=130181&view=rev Log: No relocation produces a SLEB or ULEB, make sure they are handled in MC. Modified: llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=130181&r1=130180&r2=130181&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Mon Apr 25 21:17:58 2011 @@ -691,7 +691,9 @@ bool MCAssembler::RelaxLEB(MCAsmLayout &Layout, MCLEBFragment &LF) { int64_t Value = 0; uint64_t OldSize = LF.getContents().size(); - LF.getValue().EvaluateAsAbsolute(Value, Layout); + bool IsAbs = LF.getValue().EvaluateAsAbsolute(Value, Layout); + (void)IsAbs; + assert(IsAbs); SmallString<8> &Data = LF.getContents(); Data.clear(); raw_svector_ostream OSE(Data); Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=130181&r1=130180&r2=130181&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Mon Apr 25 21:17:58 2011 @@ -124,12 +124,23 @@ SD.setOffset(F->getContents().size()); } +static const MCExpr *ForceExpAbs(MCObjectStreamer *Streamer, + MCContext &Context, const MCExpr* Expr) { + if (Context.getAsmInfo().hasAggressiveSymbolFolding()) + return Expr; + + MCSymbol *ABS = Context.CreateTempSymbol(); + Streamer->EmitAssignment(ABS, Expr); + return MCSymbolRefExpr::Create(ABS, Context); +} + void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) { int64_t IntValue; if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { EmitULEB128IntValue(IntValue); return; } + Value = ForceExpAbs(this, getContext(), Value); new MCLEBFragment(*Value, false, getCurrentSectionData()); } @@ -139,6 +150,7 @@ EmitSLEB128IntValue(IntValue); return; } + Value = ForceExpAbs(this, getContext(), Value); new MCLEBFragment(*Value, true, getCurrentSectionData()); } @@ -208,16 +220,6 @@ return AddrDelta; } -static const MCExpr *ForceExpAbs(MCObjectStreamer *Streamer, - MCContext &Context, const MCExpr* Expr) { - if (Context.getAsmInfo().hasAggressiveSymbolFolding()) - return Expr; - - MCSymbol *ABS = Context.CreateTempSymbol(); - Streamer->EmitAssignment(ABS, Expr); - return MCSymbolRefExpr::Create(ABS, Context); -} - void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label) { From aggarwa4 at illinois.edu Mon Apr 25 21:37:55 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 26 Apr 2011 02:37:55 -0000 Subject: [llvm-commits] [poolalloc] r130182 - /poolalloc/trunk/test/Makefile Message-ID: <20110426023755.56F282A6C12D@llvm.org> Author: aggarwa4 Date: Mon Apr 25 21:37:55 2011 New Revision: 130182 URL: http://llvm.org/viewvc/llvm-project?rev=130182&view=rev Log: Allows using the AssistSO library in the lit tests. Modified: poolalloc/trunk/test/Makefile Modified: poolalloc/trunk/test/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/Makefile?rev=130182&r1=130181&r2=130182&view=diff ============================================================================== --- poolalloc/trunk/test/Makefile (original) +++ poolalloc/trunk/test/Makefile Mon Apr 25 21:37:55 2011 @@ -417,13 +417,16 @@ PADIR := $(LLVM_OBJ_ROOT)/projects/poolalloc # Pathame to the DSA pass dynamic library DSA_SO := $(PADIR)/$(CONFIGURATION)/lib/libLLVMDataStructure$(SHLIBEXT) +# Pathame to the Assist DSA pass dynamic library +ADSA_SO := $(PADIR)/$(CONFIGURATION)/lib/libAssistDS$(SHLIBEXT) # Pathname to the PA pass dynamic library PA_SO := $(PADIR)/$(CONFIGURATION)/lib/libpoolalloc$(SHLIBEXT) DSAOPT := $(PROJ_OBJ_ROOT)/test/tools/dsaopt +ADSAOPT := $(PROJ_OBJ_ROOT)/test/tools/adsaopt PAOPT := $(PROJ_OBJ_ROOT)/test/tools/paopt -TOOLS= $(DSAOPT) $(PAOPT) +TOOLS= $(DSAOPT) $(PAOPT) $(ADSAOPT) #wrapper script for 'opt' so we can avoid manually loading the dsa lib $(DSAOPT): @@ -433,6 +436,13 @@ @chmod +x $@.tmp @mv $@.tmp $@ +$(ADSAOPT): + @mkdir -p `dirname $@` + @echo "#!/bin/sh" >> $@.tmp + @echo 'opt -load $(DSA_SO) -load $(ADSA_SO) $$@' >> $@.tmp + @chmod +x $@.tmp + @mv $@.tmp $@ + #wrapper script for 'opt' that loads dsa and poolalloc $(PAOPT): @mkdir -p `dirname $@` From wdietz2 at illinois.edu Mon Apr 25 22:41:53 2011 From: wdietz2 at illinois.edu (Will Dietz) Date: Tue, 26 Apr 2011 03:41:53 -0000 Subject: [llvm-commits] [poolalloc] r130184 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110426034153.656C72A6C12D@llvm.org> Author: wdietz2 Date: Mon Apr 25 22:41:53 2011 New Revision: 130184 URL: http://llvm.org/viewvc/llvm-project?rev=130184&view=rev Log: TypeChecks.cpp: Add explicit braces to make compiler happy. No functionality changed. Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130184&r1=130183&r2=130184&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Mon Apr 25 22:41:53 2011 @@ -284,7 +284,7 @@ Instruction *I = CS.getInstruction(); // Special case handling of certain libc allocation functions here. - if (Function *F = dyn_cast(Callee)) + if (Function *F = dyn_cast(Callee)) { if (F->isIntrinsic()) { switch(F->getIntrinsicID()) { case Intrinsic::memcpy: @@ -326,6 +326,7 @@ CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); CI->insertAfter(BCI_Dest); } + } return true; From wdietz2 at illinois.edu Mon Apr 25 22:44:07 2011 From: wdietz2 at illinois.edu (Will Dietz) Date: Tue, 26 Apr 2011 03:44:07 -0000 Subject: [llvm-commits] [poolalloc] r130185 - /poolalloc/trunk/test/Makefile Message-ID: <20110426034407.235F92A6C12D@llvm.org> Author: wdietz2 Date: Mon Apr 25 22:44:06 2011 New Revision: 130185 URL: http://llvm.org/viewvc/llvm-project?rev=130185&view=rev Log: test/Makefile: Tiny touchup to the way we create tool scripts. Modified: poolalloc/trunk/test/Makefile Modified: poolalloc/trunk/test/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/Makefile?rev=130185&r1=130184&r2=130185&view=diff ============================================================================== --- poolalloc/trunk/test/Makefile (original) +++ poolalloc/trunk/test/Makefile Mon Apr 25 22:44:06 2011 @@ -431,14 +431,14 @@ #wrapper script for 'opt' so we can avoid manually loading the dsa lib $(DSAOPT): @mkdir -p `dirname $@` - @echo "#!/bin/sh" >> $@.tmp + @echo "#!/bin/sh" > $@.tmp @echo 'opt -load $(DSA_SO) $$@' >> $@.tmp @chmod +x $@.tmp @mv $@.tmp $@ $(ADSAOPT): @mkdir -p `dirname $@` - @echo "#!/bin/sh" >> $@.tmp + @echo "#!/bin/sh" > $@.tmp @echo 'opt -load $(DSA_SO) -load $(ADSA_SO) $$@' >> $@.tmp @chmod +x $@.tmp @mv $@.tmp $@ @@ -446,7 +446,7 @@ #wrapper script for 'opt' that loads dsa and poolalloc $(PAOPT): @mkdir -p `dirname $@` - @echo "#!/bin/sh" >> $@.tmp + @echo "#!/bin/sh" > $@.tmp @echo 'opt -load $(DSA_SO) -load $(PA_SO) $$@' >> $@.tmp @chmod +x $@.tmp @mv $@.tmp $@ From nicholas at mxc.ca Mon Apr 25 22:54:16 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 26 Apr 2011 03:54:16 -0000 Subject: [llvm-commits] [llvm] r130186 - in /llvm/trunk: lib/Transforms/Instrumentation/GCOVProfiling.cpp runtime/libprofile/GCDAProfiling.c runtime/libprofile/libprofile.exports Message-ID: <20110426035416.C9B812A6C12D@llvm.org> Author: nicholas Date: Mon Apr 25 22:54:16 2011 New Revision: 130186 URL: http://llvm.org/viewvc/llvm-project?rev=130186&view=rev Log: Rename everything to follow LLVM style ... I think. Add support for switch and indirectbr edges. This works by densely numbering all blocks which have such terminators, and then separately numbering the possible successors. The predecessors write down a number, the successor knows its own number (as a ConstantInt) and sends that and the pointer to the number the predecessor wrote down to the runtime, who looks up the counter in a per-function table. Coverage data should now be functional, but I haven't tested it on anything other than my 2-file synthetic test program for coverage. Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/runtime/libprofile/GCDAProfiling.c llvm/trunk/runtime/libprofile/libprofile.exports Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130186&r1=130185&r2=130186&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Apr 25 22:54:16 2011 @@ -58,28 +58,40 @@ private: // Create the GCNO files for the Module based on DebugInfo. - void EmitGCNO(DebugInfoFinder &DIF); + void emitGCNO(DebugInfoFinder &DIF); // Modify the program to track transitions along edges and call into the // profiling runtime to emit .gcda files when run. - bool EmitProfileArcs(DebugInfoFinder &DIF); + bool emitProfileArcs(DebugInfoFinder &DIF); // Get pointers to the functions in the runtime library. Constant *getStartFileFunc(); + Constant *getIncrementIndirectCounterFunc(); Constant *getEmitFunctionFunc(); Constant *getEmitArcsFunc(); Constant *getEndFileFunc(); + // Create or retrieve an i32 state value that is used to represent the + // pred block number for certain non-trivial edges. + GlobalVariable *getEdgeStateValue(); + + // Produce a table of pointers to counters, by predecessor and successor + // block number. + GlobalVariable *buildEdgeLookupTable(Function *F, + GlobalVariable *Counter, + const UniqueVector &Preds, + const UniqueVector &Succs); + // Add the function to write out all our counters to the global destructor // list. - void InsertCounterWriteout(DebugInfoFinder &, + void insertCounterWriteout(DebugInfoFinder &, SmallVector, 8> &); bool EmitNotes; bool EmitData; - Module *Mod; + Module *M; LLVMContext *Ctx; }; } @@ -92,59 +104,59 @@ return new GCOVProfiler(EmitNotes, EmitData); } -static DISubprogram FindSubprogram(DIScope scope) { - while (!scope.isSubprogram()) { - assert(scope.isLexicalBlock() && +static DISubprogram findSubprogram(DIScope Scope) { + while (!Scope.isSubprogram()) { + assert(Scope.isLexicalBlock() && "Debug location not lexical block or subprogram"); - scope = DILexicalBlock(scope).getContext(); + Scope = DILexicalBlock(Scope).getContext(); } - return DISubprogram(scope); + return DISubprogram(Scope); } namespace { class GCOVRecord { protected: - static const char *lines_tag; - static const char *function_tag; - static const char *block_tag; - static const char *edge_tag; + static const char *LinesTag; + static const char *FunctionTag; + static const char *BlockTag; + static const char *EdgeTag; GCOVRecord() {} - void WriteBytes(const char *b, int size) { - os->write(b, size); + void writeBytes(const char *Bytes, int Size) { + os->write(Bytes, Size); } - void Write(uint32_t i) { - WriteBytes(reinterpret_cast(&i), 4); + void write(uint32_t i) { + writeBytes(reinterpret_cast(&i), 4); } // Returns the length measured in 4-byte blocks that will be used to // represent this string in a GCOV file - unsigned LengthOfGCOVString(StringRef s) { + unsigned lengthOfGCOVString(StringRef s) { // A GCOV string is a length, followed by a NUL, then between 0 and 3 NULs // padding out to the next 4-byte word. The length is measured in 4-byte // words including padding, not bytes of actual string. return (s.size() + 5) / 4; } - void WriteGCOVString(StringRef s) { - uint32_t len = LengthOfGCOVString(s); - Write(len); - WriteBytes(s.data(), s.size()); + void writeGCOVString(StringRef s) { + uint32_t Len = lengthOfGCOVString(s); + write(Len); + writeBytes(s.data(), s.size()); // Write 1 to 4 bytes of NUL padding. assert((unsigned)(5 - ((s.size() + 1) % 4)) > 0); assert((unsigned)(5 - ((s.size() + 1) % 4)) <= 4); - WriteBytes("\0\0\0\0", 5 - ((s.size() + 1) % 4)); + writeBytes("\0\0\0\0", 5 - ((s.size() + 1) % 4)); } raw_ostream *os; }; - const char *GCOVRecord::lines_tag = "\0\0\x45\x01"; - const char *GCOVRecord::function_tag = "\0\0\0\1"; - const char *GCOVRecord::block_tag = "\0\0\x41\x01"; - const char *GCOVRecord::edge_tag = "\0\0\x43\x01"; + const char *GCOVRecord::LinesTag = "\0\0\x45\x01"; + const char *GCOVRecord::FunctionTag = "\0\0\0\1"; + const char *GCOVRecord::BlockTag = "\0\0\x41\x01"; + const char *GCOVRecord::EdgeTag = "\0\0\x43\x01"; class GCOVFunction; class GCOVBlock; @@ -154,24 +166,24 @@ // to the block. class GCOVLines : public GCOVRecord { public: - void AddLine(uint32_t line) { - lines.push_back(line); + void addLine(uint32_t Line) { + Lines.push_back(Line); } - uint32_t Length() { - return LengthOfGCOVString(filename) + 2 + lines.size(); + uint32_t length() { + return lengthOfGCOVString(Filename) + 2 + Lines.size(); } private: friend class GCOVBlock; - GCOVLines(std::string filename, raw_ostream *os) - : filename(filename) { + GCOVLines(std::string Filename, raw_ostream *os) + : Filename(Filename) { this->os = os; } - std::string filename; - SmallVector lines; + std::string Filename; + SmallVector Lines; }; // Represent a basic block in GCOV. Each block has a unique number in the @@ -179,56 +191,55 @@ // other blocks. class GCOVBlock : public GCOVRecord { public: - GCOVLines &GetFile(std::string filename) { - GCOVLines *&lines = lines_by_file[filename]; - if (!lines) { - lines = new GCOVLines(filename, os); - } - return *lines; - } - - void AddEdge(GCOVBlock &successor) { - out_edges.push_back(&successor); - } - - void WriteOut() { - uint32_t len = 3; - for (StringMap::iterator I = lines_by_file.begin(), - E = lines_by_file.end(); I != E; ++I) { - len += I->second->Length(); - } - - WriteBytes(lines_tag, 4); - Write(len); - Write(number); - for (StringMap::iterator I = lines_by_file.begin(), - E = lines_by_file.end(); I != E; ++I) { - Write(0); - WriteGCOVString(I->second->filename); - for (int i = 0, e = I->second->lines.size(); i != e; ++i) { - Write(I->second->lines[i]); + GCOVLines &getFile(std::string Filename) { + GCOVLines *&Lines = LinesByFile[Filename]; + if (!Lines) { + Lines = new GCOVLines(Filename, os); + } + return *Lines; + } + + void addEdge(GCOVBlock &Successor) { + OutEdges.push_back(&Successor); + } + + void writeOut() { + uint32_t Len = 3; + for (StringMap::iterator I = LinesByFile.begin(), + E = LinesByFile.end(); I != E; ++I) { + Len += I->second->length(); + } + + writeBytes(LinesTag, 4); + write(Len); + write(Number); + for (StringMap::iterator I = LinesByFile.begin(), + E = LinesByFile.end(); I != E; ++I) { + write(0); + writeGCOVString(I->second->Filename); + for (int i = 0, e = I->second->Lines.size(); i != e; ++i) { + write(I->second->Lines[i]); } } - Write(0); - Write(0); + write(0); + write(0); } ~GCOVBlock() { - DeleteContainerSeconds(lines_by_file); + DeleteContainerSeconds(LinesByFile); } private: friend class GCOVFunction; - GCOVBlock(uint32_t number, raw_ostream *os) - : number(number) { + GCOVBlock(uint32_t Number, raw_ostream *os) + : Number(Number) { this->os = os; } - uint32_t number; - BasicBlock *block; - StringMap lines_by_file; - SmallVector out_edges; + uint32_t Number; + StringMap LinesByFile; + SmallVector OutEdges; }; // A function has a unique identifier, a checksum (we leave as zero) and a @@ -242,90 +253,90 @@ Function *F = SP.getFunction(); uint32_t i = 0; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { - blocks[BB] = new GCOVBlock(i++, os); + Blocks[BB] = new GCOVBlock(i++, os); } - return_block = new GCOVBlock(i++, os); + ReturnBlock = new GCOVBlock(i++, os); - WriteBytes(function_tag, 4); - uint32_t block_len = 1 + 1 + 1 + LengthOfGCOVString(SP.getName()) + - 1 + LengthOfGCOVString(SP.getFilename()) + 1; - Write(block_len); - uint32_t ident = reinterpret_cast((MDNode*)SP); - Write(ident); - Write(0); // checksum - WriteGCOVString(SP.getName()); - WriteGCOVString(SP.getFilename()); - Write(SP.getLineNumber()); + writeBytes(FunctionTag, 4); + uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(SP.getName()) + + 1 + lengthOfGCOVString(SP.getFilename()) + 1; + write(BlockLen); + uint32_t Ident = reinterpret_cast((MDNode*)SP); + write(Ident); + write(0); // checksum + writeGCOVString(SP.getName()); + writeGCOVString(SP.getFilename()); + write(SP.getLineNumber()); } ~GCOVFunction() { - DeleteContainerSeconds(blocks); - delete return_block; + DeleteContainerSeconds(Blocks); + delete ReturnBlock; } - GCOVBlock &GetBlock(BasicBlock *BB) { - return *blocks[BB]; + GCOVBlock &getBlock(BasicBlock *BB) { + return *Blocks[BB]; } - GCOVBlock &GetReturnBlock() { - return *return_block; + GCOVBlock &getReturnBlock() { + return *ReturnBlock; } - void WriteOut() { + void writeOut() { // Emit count of blocks. - WriteBytes(block_tag, 4); - Write(blocks.size() + 1); - for (int i = 0, e = blocks.size() + 1; i != e; ++i) { - Write(0); // No flags on our blocks. + writeBytes(BlockTag, 4); + write(Blocks.size() + 1); + for (int i = 0, e = Blocks.size() + 1; i != e; ++i) { + write(0); // No flags on our blocks. } // Emit edges between blocks. - for (DenseMap::iterator I = blocks.begin(), - E = blocks.end(); I != E; ++I) { - GCOVBlock &block = *I->second; - if (block.out_edges.empty()) continue; - - WriteBytes(edge_tag, 4); - Write(block.out_edges.size() * 2 + 1); - Write(block.number); - for (int i = 0, e = block.out_edges.size(); i != e; ++i) { - Write(block.out_edges[i]->number); - Write(0); // no flags + for (DenseMap::iterator I = Blocks.begin(), + E = Blocks.end(); I != E; ++I) { + GCOVBlock &Block = *I->second; + if (Block.OutEdges.empty()) continue; + + writeBytes(EdgeTag, 4); + write(Block.OutEdges.size() * 2 + 1); + write(Block.Number); + for (int i = 0, e = Block.OutEdges.size(); i != e; ++i) { + write(Block.OutEdges[i]->Number); + write(0); // no flags } } // Emit lines for each block. - for (DenseMap::iterator I = blocks.begin(), - E = blocks.end(); I != E; ++I) { - I->second->WriteOut(); + for (DenseMap::iterator I = Blocks.begin(), + E = Blocks.end(); I != E; ++I) { + I->second->writeOut(); } } private: - DenseMap blocks; - GCOVBlock *return_block; + DenseMap Blocks; + GCOVBlock *ReturnBlock; }; } // Replace the stem of a file, or add one if missing. -static std::string ReplaceStem(std::string orig_filename, std::string new_stem){ - return (sys::path::stem(orig_filename) + "." + new_stem).str(); +static std::string replaceStem(std::string OrigFilename, std::string NewStem) { + return (sys::path::stem(OrigFilename) + "." + NewStem).str(); } bool GCOVProfiler::runOnModule(Module &M) { - Mod = &M; + this->M = &M; Ctx = &M.getContext(); DebugInfoFinder DIF; - DIF.processModule(*Mod); + DIF.processModule(M); - if (EmitNotes) EmitGCNO(DIF); - if (EmitData) return EmitProfileArcs(DIF); + if (EmitNotes) emitGCNO(DIF); + if (EmitData) return emitProfileArcs(DIF); return false; } -void GCOVProfiler::EmitGCNO(DebugInfoFinder &DIF) { - DenseMap gcno_files; +void GCOVProfiler::emitGCNO(DebugInfoFinder &DIF) { + DenseMap GcnoFiles; for (DebugInfoFinder::iterator I = DIF.compile_unit_begin(), E = DIF.compile_unit_end(); I != E; ++I) { // Each compile unit gets its own .gcno file. This means that whether we run @@ -333,153 +344,224 @@ // LTO, we'll generate the same .gcno files. DICompileUnit CU(*I); - raw_fd_ostream *&Out = gcno_files[CU]; + raw_fd_ostream *&out = GcnoFiles[CU]; std::string ErrorInfo; - Out = new raw_fd_ostream(ReplaceStem(CU.getFilename(), "gcno").c_str(), + out = new raw_fd_ostream(replaceStem(CU.getFilename(), "gcno").c_str(), ErrorInfo, raw_fd_ostream::F_Binary); - Out->write("oncg*404MVLL", 12); + out->write("oncg*404MVLL", 12); } for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(), SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) { DISubprogram SP(*SPI); - raw_fd_ostream *&os = gcno_files[SP.getCompileUnit()]; + raw_fd_ostream *&os = GcnoFiles[SP.getCompileUnit()]; - GCOVFunction function(SP, os); + GCOVFunction Func(SP, os); Function *F = SP.getFunction(); for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { - GCOVBlock &block = function.GetBlock(BB); + GCOVBlock &Block = Func.getBlock(BB); TerminatorInst *TI = BB->getTerminator(); if (int successors = TI->getNumSuccessors()) { for (int i = 0; i != successors; ++i) { - block.AddEdge(function.GetBlock(TI->getSuccessor(i))); + Block.addEdge(Func.getBlock(TI->getSuccessor(i))); } } else if (isa(TI)) { - block.AddEdge(function.GetReturnBlock()); + Block.addEdge(Func.getReturnBlock()); } - uint32_t line = 0; + uint32_t Line = 0; for (BasicBlock::iterator I = BB->begin(), IE = BB->end(); I != IE; ++I) { - const DebugLoc &loc = I->getDebugLoc(); - if (loc.isUnknown()) continue; - if (line == loc.getLine()) continue; - line = loc.getLine(); - if (SP != FindSubprogram(DIScope(loc.getScope(*Ctx)))) continue; + const DebugLoc &Loc = I->getDebugLoc(); + if (Loc.isUnknown()) continue; + if (Line == Loc.getLine()) continue; + Line = Loc.getLine(); + if (SP != findSubprogram(DIScope(Loc.getScope(*Ctx)))) continue; - GCOVLines &lines = block.GetFile(SP.getFilename()); - lines.AddLine(loc.getLine()); + GCOVLines &Lines = Block.getFile(SP.getFilename()); + Lines.addLine(Loc.getLine()); } } - function.WriteOut(); + Func.writeOut(); } for (DenseMap::iterator - I = gcno_files.begin(), E = gcno_files.end(); I != E; ++I) { - raw_fd_ostream *&Out = I->second; - Out->write("\0\0\0\0\0\0\0\0", 8); // EOF - Out->close(); - delete Out; + I = GcnoFiles.begin(), E = GcnoFiles.end(); I != E; ++I) { + raw_fd_ostream *&out = I->second; + out->write("\0\0\0\0\0\0\0\0", 8); // EOF + out->close(); + delete out; } } -bool GCOVProfiler::EmitProfileArcs(DebugInfoFinder &DIF) { +bool GCOVProfiler::emitProfileArcs(DebugInfoFinder &DIF) { if (DIF.subprogram_begin() == DIF.subprogram_end()) return false; - SmallVector, 8> counters_by_ident; + SmallVector, 8> CountersByIdent; for (DebugInfoFinder::iterator SPI = DIF.subprogram_begin(), SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) { DISubprogram SP(*SPI); Function *F = SP.getFunction(); - unsigned edges = 0; + unsigned Edges = 0; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { TerminatorInst *TI = BB->getTerminator(); if (isa(TI)) - ++edges; + ++Edges; else - edges += TI->getNumSuccessors(); + Edges += TI->getNumSuccessors(); } - const ArrayType *counter_type = - ArrayType::get(Type::getInt64Ty(*Ctx), edges); - GlobalVariable *counter = - new GlobalVariable(*Mod, counter_type, false, + const ArrayType *CounterTy = + ArrayType::get(Type::getInt64Ty(*Ctx), Edges); + GlobalVariable *Counters = + new GlobalVariable(*M, CounterTy, false, GlobalValue::InternalLinkage, - Constant::getNullValue(counter_type), + Constant::getNullValue(CounterTy), "__llvm_gcov_ctr", 0, false, 0); - counters_by_ident.push_back( - std::make_pair(counter, reinterpret_cast((MDNode*)SP))); + CountersByIdent.push_back( + std::make_pair(Counters, reinterpret_cast((MDNode*)SP))); - UniqueVector complex_edge_preds; - UniqueVector complex_edge_succs; + UniqueVector ComplexEdgePreds; + UniqueVector ComplexEdgeSuccs; - unsigned edge_num = 0; + unsigned Edge = 0; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { TerminatorInst *TI = BB->getTerminator(); - int successors = isa(TI) ? 1 : TI->getNumSuccessors(); - if (successors) { - IRBuilder<> builder(TI); - - if (successors == 1) { - Value *ctr = builder.CreateConstInBoundsGEP2_64(counter, 0, edge_num); - Value *count = builder.CreateLoad(ctr); - count = builder.CreateAdd(count, + int Successors = isa(TI) ? 1 : TI->getNumSuccessors(); + if (Successors) { + IRBuilder<> Builder(TI); + + if (Successors == 1) { + Value *Counter = Builder.CreateConstInBoundsGEP2_64(Counters, 0, + Edge); + Value *Count = Builder.CreateLoad(Counter); + Count = Builder.CreateAdd(Count, ConstantInt::get(Type::getInt64Ty(*Ctx),1)); - builder.CreateStore(count, ctr); + Builder.CreateStore(Count, Counter); } else if (BranchInst *BI = dyn_cast(TI)) { - Value *sel = builder.CreateSelect( + Value *Sel = Builder.CreateSelect( BI->getCondition(), - ConstantInt::get(Type::getInt64Ty(*Ctx), edge_num), - ConstantInt::get(Type::getInt64Ty(*Ctx), edge_num + 1)); - SmallVector idx; - idx.push_back(Constant::getNullValue(Type::getInt64Ty(*Ctx))); - idx.push_back(sel); - Value *ctr = builder.CreateInBoundsGEP(counter, - idx.begin(), idx.end()); - Value *count = builder.CreateLoad(ctr); - count = builder.CreateAdd(count, + ConstantInt::get(Type::getInt64Ty(*Ctx), Edge), + ConstantInt::get(Type::getInt64Ty(*Ctx), Edge + 1)); + SmallVector Idx; + Idx.push_back(Constant::getNullValue(Type::getInt64Ty(*Ctx))); + Idx.push_back(Sel); + Value *Counter = Builder.CreateInBoundsGEP(Counters, + Idx.begin(), Idx.end()); + Value *Count = Builder.CreateLoad(Counter); + Count = Builder.CreateAdd(Count, ConstantInt::get(Type::getInt64Ty(*Ctx),1)); - builder.CreateStore(count, ctr); + Builder.CreateStore(Count, Counter); } else { - complex_edge_preds.insert(BB); - for (int i = 0; i != successors; ++i) { - complex_edge_succs.insert(TI->getSuccessor(i)); - } + ComplexEdgePreds.insert(BB); + for (int i = 0; i != Successors; ++i) + ComplexEdgeSuccs.insert(TI->getSuccessor(i)); } - edge_num += successors; + Edge += Successors; } } - // TODO: support switch, invoke, indirectbr - if (!complex_edge_preds.empty()) { - // emit a [preds x [succs x i64*]]. - for (int i = 0, e = complex_edge_preds.size(); i != e; ++i) { - // call runtime to state save + if (!ComplexEdgePreds.empty()) { + GlobalVariable *EdgeTable = + buildEdgeLookupTable(F, Counters, + ComplexEdgePreds, ComplexEdgeSuccs); + GlobalVariable *EdgeState = getEdgeStateValue(); + + const Type *Int32Ty = Type::getInt32Ty(*Ctx); + for (int i = 0, e = ComplexEdgePreds.size(); i != e; ++i) { + IRBuilder<> Builder(ComplexEdgePreds[i+1]->getTerminator()); + Builder.CreateStore(ConstantInt::get(Int32Ty, i+1), EdgeState); } - for (int i = 0, e = complex_edge_succs.size(); i != e; ++i) { + for (int i = 0, e = ComplexEdgeSuccs.size(); i != e; ++i) { // call runtime to perform increment + IRBuilder<> Builder(ComplexEdgeSuccs[i+1]->getFirstNonPHI()); + Value *CounterPtrArray = + Builder.CreateConstInBoundsGEP2_64(EdgeTable, 0, + i * ComplexEdgePreds.size()); + Builder.CreateCall2(getIncrementIndirectCounterFunc(), + EdgeState, CounterPtrArray); + // clear the predecessor number + Builder.CreateStore(ConstantInt::get(Int32Ty, 0xffffffff), EdgeState); } } } - InsertCounterWriteout(DIF, counters_by_ident); + insertCounterWriteout(DIF, CountersByIdent); return true; } +// All edges with successors that aren't branches are "complex", because it +// requires complex logic to pick which counter to update. +GlobalVariable *GCOVProfiler::buildEdgeLookupTable( + Function *F, + GlobalVariable *Counters, + const UniqueVector &Preds, + const UniqueVector &Succs) { + // TODO: support invoke, threads. We rely on the fact that nothing can modify + // the whole-Module pred edge# between the time we set it and the time we next + // read it. Threads and invoke make this untrue. + + // emit [(succs * preds) x i64*], logically [succ x [pred x i64*]]. + const Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx); + const ArrayType *EdgeTableTy = ArrayType::get( + Int64PtrTy, Succs.size() * Preds.size()); + + Constant **EdgeTable = new Constant*[Succs.size() * Preds.size()]; + Constant *NullValue = Constant::getNullValue(Int64PtrTy); + for (int i = 0, ie = Succs.size() * Preds.size(); i != ie; ++i) + EdgeTable[i] = NullValue; + + unsigned Edge = 0; + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { + TerminatorInst *TI = BB->getTerminator(); + int Successors = isa(TI) ? 1 : TI->getNumSuccessors(); + if (Successors && !isa(TI) && !isa(TI)) { + for (int i = 0; i != Successors; ++i) { + BasicBlock *Succ = TI->getSuccessor(i); + IRBuilder<> builder(Succ); + Value *Counter = builder.CreateConstInBoundsGEP2_64(Counters, 0, + Edge + i); + EdgeTable[((Succs.idFor(Succ)-1) * Preds.size()) + + (Preds.idFor(BB)-1)] = cast(Counter); + } + } + Edge += Successors; + } + + GlobalVariable *EdgeTableGV = + new GlobalVariable( + *M, EdgeTableTy, true, GlobalValue::InternalLinkage, + ConstantArray::get(EdgeTableTy, + &EdgeTable[0], Succs.size() * Preds.size()), + "__llvm_gcda_edge_table"); + EdgeTableGV->setUnnamedAddr(true); + return EdgeTableGV; +} + Constant *GCOVProfiler::getStartFileFunc() { - const Type *Args[1] = { Type::getInt8PtrTy(*Ctx) }; + const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; + const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), + Args, false); + return M->getOrInsertFunction("llvm_gcda_start_file", FTy); +} + +Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { + const Type *Args[] = { + Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor + Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row + }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); - return Mod->getOrInsertFunction("llvm_gcda_start_file", FTy); + return M->getOrInsertFunction("llvm_gcda_increment_indirect_counter", FTy); } Constant *GCOVProfiler::getEmitFunctionFunc() { - const Type *Args[1] = { Type::getInt32Ty(*Ctx) }; + const Type *Args[] = { Type::getInt32Ty(*Ctx) }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); - return Mod->getOrInsertFunction("llvm_gcda_emit_function", FTy); + return M->getOrInsertFunction("llvm_gcda_emit_function", FTy); } Constant *GCOVProfiler::getEmitArcsFunc() { @@ -489,26 +571,38 @@ }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), Args, false); - return Mod->getOrInsertFunction("llvm_gcda_emit_arcs", FTy); + return M->getOrInsertFunction("llvm_gcda_emit_arcs", FTy); } Constant *GCOVProfiler::getEndFileFunc() { const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false); - return Mod->getOrInsertFunction("llvm_gcda_end_file", FTy); + return M->getOrInsertFunction("llvm_gcda_end_file", FTy); } -void GCOVProfiler::InsertCounterWriteout( - DebugInfoFinder &DIF, - SmallVector, 8> &counters_by_ident) { +GlobalVariable *GCOVProfiler::getEdgeStateValue() { + GlobalVariable *GV = M->getGlobalVariable("__llvm_gcov_global_state_pred"); + if (!GV) { + GV = new GlobalVariable(*M, Type::getInt32Ty(*Ctx), false, + GlobalValue::InternalLinkage, + ConstantInt::get(Type::getInt32Ty(*Ctx), + 0xffffffff), + "__llvm_gcov_global_state_pred"); + GV->setUnnamedAddr(true); + } + return GV; +} +void GCOVProfiler::insertCounterWriteout( + DebugInfoFinder &DIF, + SmallVector, 8> &CountersByIdent) { const FunctionType *WriteoutFTy = FunctionType::get(Type::getVoidTy(*Ctx), false); Function *WriteoutF = Function::Create(WriteoutFTy, GlobalValue::InternalLinkage, - "__llvm_gcda_writeout", Mod); + "__llvm_gcov_writeout", M); WriteoutF->setUnnamedAddr(true); BasicBlock *BB = BasicBlock::Create(*Ctx, "", WriteoutF); - IRBuilder<> builder(BB); + IRBuilder<> Builder(BB); Constant *StartFile = getStartFileFunc(); Constant *EmitFunction = getEmitFunctionFunc(); @@ -518,25 +612,24 @@ for (DebugInfoFinder::iterator CUI = DIF.compile_unit_begin(), CUE = DIF.compile_unit_end(); CUI != CUE; ++CUI) { DICompileUnit compile_unit(*CUI); - std::string filename_gcda = ReplaceStem(compile_unit.getFilename(), "gcda"); - builder.CreateCall(StartFile, - builder.CreateGlobalStringPtr(filename_gcda)); + std::string FilenameGcda = replaceStem(compile_unit.getFilename(), "gcda"); + Builder.CreateCall(StartFile, + Builder.CreateGlobalStringPtr(FilenameGcda)); for (SmallVector, 8>::iterator - I = counters_by_ident.begin(), E = counters_by_ident.end(); + I = CountersByIdent.begin(), E = CountersByIdent.end(); I != E; ++I) { - builder.CreateCall(EmitFunction, ConstantInt::get(Type::getInt32Ty(*Ctx), + Builder.CreateCall(EmitFunction, ConstantInt::get(Type::getInt32Ty(*Ctx), I->second)); GlobalVariable *GV = I->first; - unsigned num_arcs = + unsigned Arcs = cast(GV->getType()->getElementType())->getNumElements(); - builder.CreateCall2( - EmitArcs, - ConstantInt::get(Type::getInt32Ty(*Ctx), num_arcs), - builder.CreateConstGEP2_64(GV, 0, 0)); + Builder.CreateCall2(EmitArcs, + ConstantInt::get(Type::getInt32Ty(*Ctx), Arcs), + Builder.CreateConstGEP2_64(GV, 0, 0)); } - builder.CreateCall(EndFile); + Builder.CreateCall(EndFile); } - builder.CreateRetVoid(); + Builder.CreateRetVoid(); - InsertProfilingShutdownCall(WriteoutF, Mod); + InsertProfilingShutdownCall(WriteoutF, M); } Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130186&r1=130185&r2=130186&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Mon Apr 25 22:54:16 2011 @@ -15,6 +15,9 @@ |* are only close enough that LCOV will happily parse them. Anything that lcov |* ignores is missing. |* +|* TODO: gcov is multi-process safe by having each exit open the existing file +|* and append to it. We'd like to achieve that and be thread-safe too. +|* \*===----------------------------------------------------------------------===*/ #include "llvm/Support/DataTypes.h" @@ -58,13 +61,33 @@ fwrite("adcg*404MVLL", 12, 1, output_file); #ifdef DEBUG_GCDAPROFILING - printf("[%s]\n", filename); + printf("llvmgcda: [%s]\n", filename); +#endif +} + +/* Given an array of pointers to counters (counters), increment the n-th one, + * where we're also given a pointer to n (predecessor). + */ +void llvm_gcda_increment_indirect_counter(uint32_t *predecessor, + uint64_t **counters) { + uint64_t *counter; + if (*predecessor == 0xffffffff) + return; + + /* Don't crash if the pred# is out of sync. This can happen due to threads, + or because of a TODO in GCOVProfiling.cpp buildEdgeLookupTable(). */ + if ((counter = counters[*predecessor])) + ++*counter; +#ifdef DEBUG_GCDAPROFILING + else + printf("llvmgcda: increment_indirect_counter counters=%x, pred=%u\n", + state_table_row, *predecessor); #endif } void llvm_gcda_emit_function(uint32_t ident) { #ifdef DEBUG_GCDAPROFILING - printf("function id=%x\n", ident); + printf("llvmgcda: function id=%x\n", ident); #endif /* function tag */ @@ -84,9 +107,9 @@ } #ifdef DEBUG_GCDAPROFILING - printf(" %u arcs\n", num_counters); + printf("llvmgcda: %u arcs\n", num_counters); for (i = 0; i < num_counters; ++i) { - printf(" %llu\n", (unsigned long long)counters[i]); + printf("llvmgcda: %llu\n", (unsigned long long)counters[i]); } #endif } @@ -98,6 +121,6 @@ output_file = NULL; #ifdef DEBUG_GCDAPROFILING - printf("-----\n"); + printf("llvmgcda: -----\n"); #endif } Modified: llvm/trunk/runtime/libprofile/libprofile.exports URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/libprofile.exports?rev=130186&r1=130185&r2=130186&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/libprofile.exports (original) +++ llvm/trunk/runtime/libprofile/libprofile.exports Mon Apr 25 22:54:16 2011 @@ -6,6 +6,7 @@ llvm_increment_path_count llvm_decrement_path_count llvm_gcda_start_file +llvm_gcda_increment_indirect_counter llvm_gcda_emit_function llvm_gcda_emit_arcs llvm_gcda_end_file From rafael.espindola at gmail.com Mon Apr 25 22:58:56 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 26 Apr 2011 03:58:56 -0000 Subject: [llvm-commits] [llvm] r130187 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Target/X86/X86FrameLowering.cpp Message-ID: <20110426035856.794412A6C12D@llvm.org> Author: rafael Date: Mon Apr 25 22:58:56 2011 New Revision: 130187 URL: http://llvm.org/viewvc/llvm-project?rev=130187&view=rev Log: Print all the moves at a given label instead of just the first one. Remove previous DwarfCFI hack. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130187&r1=130186&r2=130187&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Apr 25 22:58:56 2011 @@ -607,16 +607,16 @@ const MachineFunction &MF = *MI.getParent()->getParent(); MachineModuleInfo &MMI = MF.getMMI(); std::vector &Moves = MMI.getFrameMoves(); - const MachineMove *Move = NULL; + bool FoundOne = false; + (void)FoundOne; for (std::vector::iterator I = Moves.begin(), E = Moves.end(); I != E; ++I) { if (I->getLabel() == Label) { - Move = &*I; - break; + EmitCFIFrameMove(*I); + FoundOne = true; } } - assert(Move); - EmitCFIFrameMove(*Move); + assert(FoundOne); } /// EmitFunctionBody - This method emits the body and trailer for a Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=130187&r1=130186&r2=130187&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Apr 25 22:58:56 2011 @@ -300,7 +300,7 @@ } else { assert(!Dst.isReg() && "Machine move not supported yet."); OutStreamer.EmitCFIOffset(RI->getDwarfRegNum(Src.getReg(), true), - -Dst.getOffset()); + Dst.getOffset()); } } Modified: llvm/trunk/lib/Target/X86/X86FrameLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FrameLowering.cpp?rev=130187&r1=130186&r2=130187&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FrameLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FrameLowering.cpp Mon Apr 25 22:58:56 2011 @@ -477,15 +477,6 @@ .addReg(StackPtr); if (needsFrameMoves) { - const MCAsmInfo &MAI = MMI.getContext().getAsmInfo(); - if (MAI.getExceptionHandlingType() == ExceptionHandling::DwarfCFI) { - MCSymbol *FrameLabel0 = MMI.getContext().CreateTempSymbol(); - BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(FrameLabel0); - MachineLocation FPSrc0(FramePtr); - MachineLocation FPDst0(FramePtr, -2 * stackGrowth); - Moves.push_back(MachineMove(FrameLabel0, FPDst0, FPSrc0)); - } - // Mark effective beginning of when frame pointer becomes valid. MCSymbol *FrameLabel = MMI.getContext().CreateTempSymbol(); BuildMI(MBB, MBBI, DL, TII.get(X86::PROLOG_LABEL)).addSym(FrameLabel); From evan.cheng at apple.com Mon Apr 25 23:57:37 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 26 Apr 2011 04:57:37 -0000 Subject: [llvm-commits] [llvm] r130190 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Message-ID: <20110426045737.961E02A6C12D@llvm.org> Author: evancheng Date: Mon Apr 25 23:57:37 2011 New Revision: 130190 URL: http://llvm.org/viewvc/llvm-project?rev=130190&view=rev Log: Fix typo Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=130190&r1=130189&r2=130190&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Mon Apr 25 23:57:37 2011 @@ -2235,7 +2235,7 @@ } } - // Prioritize by Seith-Ulmann number and push CopyToReg nodes down. + // Prioritize by Sethi-Ulmann number and push CopyToReg nodes down. unsigned LPriority = SPQ->getNodePriority(left); unsigned RPriority = SPQ->getNodePriority(right); if (LPriority != RPriority) { From nicholas at mxc.ca Tue Apr 26 00:48:41 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 26 Apr 2011 05:48:41 -0000 Subject: [llvm-commits] [llvm] r130191 - in /llvm/trunk: CMakeLists.txt runtime/CMakeLists.txt runtime/libprofile/CMakeLists.txt Message-ID: <20110426054841.5305E2A6C12D@llvm.org> Author: nicholas Date: Tue Apr 26 00:48:41 2011 New Revision: 130191 URL: http://llvm.org/viewvc/llvm-project?rev=130191&view=rev Log: Add cmakefiles to build profile_rt.so! Added: llvm/trunk/runtime/CMakeLists.txt llvm/trunk/runtime/libprofile/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=130191&r1=130190&r2=130191&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Tue Apr 26 00:48:41 2011 @@ -227,6 +227,13 @@ add_subdirectory(tools) endif() +option(LLVM_BUILD_RUNTIME + "Build the LLVM runtime libraries. If OFF, just generate build targets." OFF) +option(LLVM_INCLUDE_RUNTIME "Generate build targets for the LLVM runtimes" ON) +if( LLVM_INCLUDE_RUNTIME ) + add_subdirectory(runtime) +endif() + option(LLVM_BUILD_EXAMPLES "Build the LLVM example programs. If OFF, just generate build targets." OFF) option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON) @@ -235,7 +242,7 @@ endif() option(LLVM_BUILD_TESTS - "Build LLVM unit tests. If OFF, just generate build targes." OFF) + "Build LLVM unit tests. If OFF, just generate build targets." OFF) if( LLVM_INCLUDE_TESTS ) add_subdirectory(test) add_subdirectory(utils/unittest) Added: llvm/trunk/runtime/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/CMakeLists.txt?rev=130191&view=auto ============================================================================== --- llvm/trunk/runtime/CMakeLists.txt (added) +++ llvm/trunk/runtime/CMakeLists.txt Tue Apr 26 00:48:41 2011 @@ -0,0 +1 @@ +add_subdirectory(libprofile) Added: llvm/trunk/runtime/libprofile/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/CMakeLists.txt?rev=130191&view=auto ============================================================================== --- llvm/trunk/runtime/libprofile/CMakeLists.txt (added) +++ llvm/trunk/runtime/libprofile/CMakeLists.txt Tue Apr 26 00:48:41 2011 @@ -0,0 +1,9 @@ +add_llvm_loadable_module( profile_rt + BasicBlockTracing.c + CommonProfiling.c + GCDAProfiling.c + PathProfiling.c + EdgeProfiling.c + OptimalEdgeProfiling.c + Profiling.h + ) From sabre at nondot.org Tue Apr 26 01:14:13 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 06:14:13 -0000 Subject: [llvm-commits] [llvm] r130192 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/ARM/2010-12-15-elf-lcomm.ll Message-ID: <20110426061413.CE49C2A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 01:14:13 2011 New Revision: 130192 URL: http://llvm.org/viewvc/llvm-project?rev=130192&view=rev Log: don't emit the symbol name twice for local bss and common symbols. For example, don't emit: .comm _i,4,2 ## @i ## @i instead emit: .comm _i,4,2 ## @i Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130192&r1=130191&r2=130192&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Apr 26 01:14:13 2011 @@ -289,12 +289,6 @@ if (GVKind.isCommon() || GVKind.isBSSLocal()) { if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. - if (isVerbose()) { - WriteAsOperand(OutStreamer.GetCommentOS(), GV, - /*PrintType=*/false, GV->getParent()); - OutStreamer.GetCommentOS() << '\n'; - } - // Handle common symbols. if (GVKind.isCommon()) { unsigned Align = 1 << AlignLog; Modified: llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll?rev=130192&r1=130191&r2=130192&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2010-12-15-elf-lcomm.ll Tue Apr 26 01:14:13 2011 @@ -10,7 +10,7 @@ @STRIDE = internal global i32 8 ; ASM: .type array00,%object @ @array00 -; ASM-NEXT: .lcomm array00,80 @ @array00 +; ASM-NEXT: .lcomm array00,80 ; ASM-NEXT: .type _MergedGlobals,%object @ @_MergedGlobals From baldrick at free.fr Tue Apr 26 02:30:10 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 07:30:10 -0000 Subject: [llvm-commits] [llvm] r130193 - /llvm/trunk/lib/VMCore/Function.cpp Message-ID: <20110426073010.694FF2A6C12E@llvm.org> Author: baldrick Date: Tue Apr 26 02:30:10 2011 New Revision: 130193 URL: http://llvm.org/viewvc/llvm-project?rev=130193&view=rev Log: Another example of a static table that wasn't marked static. Modified: llvm/trunk/lib/VMCore/Function.cpp Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=130193&r1=130192&r2=130193&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Tue Apr 26 02:30:10 2011 @@ -363,7 +363,7 @@ } bool Intrinsic::isOverloaded(ID id) { - const bool OTable[] = { + static const bool OTable[] = { false, #define GET_INTRINSIC_OVERLOAD_TABLE #include "llvm/Intrinsics.gen" From baldrick at free.fr Tue Apr 26 03:16:57 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 08:16:57 -0000 Subject: [llvm-commits] [dragonegg] r130194 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110426081657.836172A6C12E@llvm.org> Author: baldrick Date: Tue Apr 26 03:16:57 2011 New Revision: 130194 URL: http://llvm.org/viewvc/llvm-project?rev=130194&view=rev Log: Avoid warnings about unused variables. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130194&r1=130193&r2=130194&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Tue Apr 26 03:16:57 2011 @@ -161,9 +161,11 @@ unsigned deltaFirst = R.getFirst() - r.getFirst(); unsigned deltaLast = r.getLast() - R.getLast(); if (BYTES_BIG_ENDIAN && deltaLast) { + (void)deltaFirst; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast); C = TheFolder->CreateShl(C, ShiftAmt); } else if (!BYTES_BIG_ENDIAN && deltaFirst) { + (void)deltaLast; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaFirst); C = TheFolder->CreateShl(C, ShiftAmt); } @@ -215,16 +217,17 @@ // The extra bits added when extending a slice may contain anything. In each // extended slice clear the bits corresponding to the other slice. - int HullFirst = Hull.getFirst(), HullLast = Hull.getLast(); unsigned HullWidth = Hull.getWidth(); // Compute masks with the bits for each slice set to 1. APInt ThisBits, OtherBits; if (BYTES_BIG_ENDIAN) { + int HullLast = Hull.getLast(); ThisBits = APInt::getBitsSet(HullWidth, HullLast - getLast(), HullLast - getFirst()); OtherBits = APInt::getBitsSet(HullWidth, HullLast - other.getLast(), HullLast - other.getFirst()); } else { + int HullFirst = Hull.getFirst(); ThisBits = APInt::getBitsSet(HullWidth, getFirst() - HullFirst, getLast() - HullFirst); OtherBits = APInt::getBitsSet(HullWidth, other.getFirst() - HullFirst, @@ -256,9 +259,11 @@ unsigned deltaFirst = r.getFirst() - R.getFirst(); unsigned deltaLast = R.getLast() - r.getLast(); if (BYTES_BIG_ENDIAN && deltaLast) { + (void)deltaFirst; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast); C = TheFolder->CreateLShr(C, ShiftAmt); } else if (!BYTES_BIG_ENDIAN && deltaFirst) { + (void)deltaLast; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaFirst); C = TheFolder->CreateLShr(C, ShiftAmt); } @@ -1122,9 +1127,9 @@ static Constant *ConvertBinOp_CST(tree exp) { Constant *LHS = ConvertInitializer(TREE_OPERAND(exp, 0)); - bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,0))); + bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); Constant *RHS = ConvertInitializer(TREE_OPERAND(exp, 1)); - bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp,1))); + bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 1))); Instruction::CastOps opcode; if (LHS->getType()->isPointerTy()) { const Type *IntPtrTy = getTargetData().getIntPtrType(Context); From baldrick at free.fr Tue Apr 26 03:26:50 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 08:26:50 -0000 Subject: [llvm-commits] [dragonegg] r130195 - /dragonegg/trunk/src/Debug.cpp Message-ID: <20110426082651.054A72A6C12D@llvm.org> Author: baldrick Date: Tue Apr 26 03:26:50 2011 New Revision: 130195 URL: http://llvm.org/viewvc/llvm-project?rev=130195&view=rev Log: Remove unused variable. Modified: dragonegg/trunk/src/Debug.cpp Modified: dragonegg/trunk/src/Debug.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Debug.cpp?rev=130195&r1=130194&r2=130195&view=diff ============================================================================== --- dragonegg/trunk/src/Debug.cpp (original) +++ dragonegg/trunk/src/Debug.cpp Tue Apr 26 03:26:50 2011 @@ -619,14 +619,8 @@ return DIType(); } - unsigned Tag = 0; - - if (TREE_CODE(type) == VECTOR_TYPE) { - Tag = DW_TAG_vector_type; + if (TREE_CODE(type) == VECTOR_TYPE) type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type))); - } - else - Tag = DW_TAG_array_type; // Add the dimensions of the array. FIXME: This loses CV qualifiers from // interior arrays, do we care? Why aren't nested arrays represented the From baldrick at free.fr Tue Apr 26 03:28:02 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 08:28:02 -0000 Subject: [llvm-commits] [dragonegg] r130196 - /dragonegg/trunk/src/Convert.cpp Message-ID: <20110426082802.77D992A6C12D@llvm.org> Author: baldrick Date: Tue Apr 26 03:28:02 2011 New Revision: 130196 URL: http://llvm.org/viewvc/llvm-project?rev=130196&view=rev Log: Avoid unused variable warning on 64 bit machines. Modified: dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=130196&r1=130195&r2=130196&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Tue Apr 26 03:28:02 2011 @@ -72,13 +72,13 @@ /// getINTEGER_CSTVal - Return the specified INTEGER_CST value as a uint64_t. /// uint64_t getINTEGER_CSTVal(tree exp) { - unsigned HOST_WIDE_INT HI = (unsigned HOST_WIDE_INT)TREE_INT_CST_HIGH(exp); unsigned HOST_WIDE_INT LO = (unsigned HOST_WIDE_INT)TREE_INT_CST_LOW(exp); if (HOST_BITS_PER_WIDE_INT == 64) { return (uint64_t)LO; } else { assert(HOST_BITS_PER_WIDE_INT == 32 && "Only 32- and 64-bit hosts supported!"); + unsigned HOST_WIDE_INT HI = (unsigned HOST_WIDE_INT)TREE_INT_CST_HIGH(exp); return ((uint64_t)HI << 32) | (uint64_t)LO; } } From baldrick at free.fr Tue Apr 26 05:11:50 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 10:11:50 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130197 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20110426101150.5C1C62A6C12D@llvm.org> Author: baldrick Date: Tue Apr 26 05:11:50 2011 New Revision: 130197 URL: http://llvm.org/viewvc/llvm-project?rev=130197&view=rev Log: Port commit 129003 from dragonegg. This fixes the llvm-gcc build on some platforms (PR9638). Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=130197&r1=130196&r2=130197&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Apr 26 05:11:50 2011 @@ -804,6 +804,9 @@ Value *E = Builder.CreateLoad(GEP, "mrv"); RetVals.push_back(E); } + // If the return type specifies an empty struct then return one. + if (RetVals.empty()) + RetVals.push_back(UndefValue::get(Fn->getReturnType())); } else { // Otherwise, this aggregate result must be something that is returned // in a scalar register for this target. We must bit convert the @@ -828,10 +831,9 @@ } if (RetVals.empty()) Builder.CreateRetVoid(); - else if (!Fn->getReturnType()->isAggregateType()) { - assert(RetVals.size() == 1 && "Non-aggregate return has multiple values!"); + else if (RetVals.size() == 1 && RetVals[0]->getType() == Fn->getReturnType()) Builder.CreateRet(RetVals[0]); - } else + else Builder.CreateAggregateRet(RetVals.data(), RetVals.size()); // Emit pending exception handling code. From rafael.espindola at gmail.com Tue Apr 26 09:17:42 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 26 Apr 2011 14:17:42 -0000 Subject: [llvm-commits] [llvm] r130198 - /llvm/trunk/test/CodeGen/X86/pr9743.ll Message-ID: <20110426141742.BA8AA2A6C12D@llvm.org> Author: rafael Date: Tue Apr 26 09:17:42 2011 New Revision: 130198 URL: http://llvm.org/viewvc/llvm-project?rev=130198&view=rev Log: Add test for PR9743. Added: llvm/trunk/test/CodeGen/X86/pr9743.ll Added: llvm/trunk/test/CodeGen/X86/pr9743.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr9743.ll?rev=130198&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/pr9743.ll (added) +++ llvm/trunk/test/CodeGen/X86/pr9743.ll Tue Apr 26 09:17:42 2011 @@ -0,0 +1,17 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -disable-fp-elim -asm-verbose=0 | FileCheck %s + +define void @f() { + ret void +} + +; CHECK: .cfi_startproc +; CHECK-NEXT: pushq +; CHECK-NEXT: : +; CHECK-NEXT: .cfi_def_cfa_offset 16 +; CHECK-NEXT: : +; CHECK-NEXT: .cfi_offset 6, -16 +; CHECK-NEXT: movq %rsp, %rbp +; CHECK-NEXT: : +; CHECK-NEXT: .cfi_def_cfa_register 6 +; CHECK-NEXT: popq %rbp +; CHECK-NEXT: ret From ofv at wanadoo.es Tue Apr 26 09:55:27 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 26 Apr 2011 14:55:27 -0000 Subject: [llvm-commits] [llvm] r130199 - in /llvm/trunk: cmake/modules/AddLLVM.cmake runtime/CMakeLists.txt Message-ID: <20110426145527.B3B682A6C12D@llvm.org> Author: ofv Date: Tue Apr 26 09:55:27 2011 New Revision: 130199 URL: http://llvm.org/viewvc/llvm-project?rev=130199&view=rev Log: Honor LLVM_BUILD_RUNTIME. Modified: llvm/trunk/cmake/modules/AddLLVM.cmake llvm/trunk/runtime/CMakeLists.txt Modified: llvm/trunk/cmake/modules/AddLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=130199&r1=130198&r2=130199&view=diff ============================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake (original) +++ llvm/trunk/cmake/modules/AddLLVM.cmake Tue Apr 26 09:55:27 2011 @@ -57,9 +57,13 @@ LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress") endif() - install(TARGETS ${name} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + if( EXCLUDE_FROM_ALL ) + set_target_properties(profile_rt PROPERTIES EXCLUDE_FROM_ALL ON) + else() + install(TARGETS ${name} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() endif() set_target_properties(${name} PROPERTIES FOLDER "Loadable modules") Modified: llvm/trunk/runtime/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/CMakeLists.txt?rev=130199&r1=130198&r2=130199&view=diff ============================================================================== --- llvm/trunk/runtime/CMakeLists.txt (original) +++ llvm/trunk/runtime/CMakeLists.txt Tue Apr 26 09:55:27 2011 @@ -1 +1,5 @@ +if( NOT LLVM_BUILD_RUNTIME ) + set(EXCLUDE_FROM_ALL ON) +endif() + add_subdirectory(libprofile) From aggarwa4 at illinois.edu Tue Apr 26 10:42:49 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 26 Apr 2011 15:42:49 -0000 Subject: [llvm-commits] [poolalloc] r130200 - in /poolalloc/trunk: lib/AssistDS/TypeChecks.cpp runtime/DynamicTypeChecks/TypeRuntime.c Message-ID: <20110426154249.148CA2A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 10:42:48 2011 New Revision: 130200 URL: http://llvm.org/viewvc/llvm-project?rev=130200&view=rev Log: Change type of num elements in globalArray to i64. Also added initial code to handle input functions Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=130200&r1=130199&r2=130200&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Tue Apr 26 10:42:48 2011 @@ -194,10 +194,10 @@ CastInst *BCI = BitCastInst::CreatePointerCast(&GV, VoidPtrTy, "", &I); std::vector Args; Args.push_back(BCI); - Args.push_back(ConstantInt::get(Int32Ty, t)); - Args.push_back(ConstantInt::get(Int32Ty, CA->getNumOperands())); + Args.push_back(ConstantInt::get(Int64Ty, t)); + Args.push_back(ConstantInt::get(Int64Ty, CA->getNumOperands())); Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); - Constant *F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, Int32Ty, Int32Ty, Int32Ty, NULL); + Constant *F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, Int64Ty, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &I); } else if(ConstantStruct *CS = dyn_cast(C)) { @@ -222,10 +222,10 @@ CastInst *BCI = BitCastInst::CreatePointerCast(&GV, VoidPtrTy, "", &I); std::vector Args; Args.push_back(BCI); - Args.push_back(ConstantInt::get(Int32Ty, t)); - Args.push_back(ConstantInt::get(Int32Ty, ATy->getNumElements())); + Args.push_back(ConstantInt::get(Int64Ty, t)); + Args.push_back(ConstantInt::get(Int64Ty, ATy->getNumElements())); Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); - Constant *F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, Int32Ty, Int32Ty, Int32Ty, NULL); + Constant *F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, Int64Ty, Int64Ty, Int32Ty, NULL); CallInst::Create(F, Args.begin(), Args.end(), "", &I); } else if(const StructType *STy = dyn_cast(Ty)) { const StructLayout *SL = TD->getStructLayout(STy); @@ -312,6 +312,26 @@ CallInst::Create(F, Args.begin(), Args.end(), "", I); break; } + } else if(F->getNameStr() == std::string("calloc")) { + CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy); + BCI->insertAfter(I); + std::vector Args; + Args.push_back(BCI); + Args.push_back(I->getOperand(2)); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy,I->getOperand(2)->getType(), Int32Ty, NULL); + CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); + CI->insertAfter(BCI); + std::vector Args1; + Args1.push_back(BCI); + Args1.push_back(I->getOperand(2)); + Args1.push_back(I->getOperand(1)); + Args1.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + F = M.getOrInsertFunction("trackGlobalArray", VoidTy, VoidPtrTy, I->getOperand(2)->getType(), I->getOperand(1)->getType(), Int32Ty, NULL); + CallInst *CI_Arr = CallInst::Create(F, Args1.begin(), Args1.end()); + CI_Arr->insertAfter(CI); + + } else if(F->getNameStr() == std::string("realloc")) { CastInst *BCI_Src = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy); CastInst *BCI_Dest = BitCastInst::CreatePointerCast(I, VoidPtrTy); @@ -325,12 +345,52 @@ Constant *F = M.getOrInsertFunction("copyTypeInfo", VoidTy, VoidPtrTy, VoidPtrTy, I->getOperand(2)->getType(), Int32Ty, NULL); CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); CI->insertAfter(BCI_Dest); + } else if(F->getNameStr() == std::string("fgets")) { + CastInst *BCI = BitCastInst::CreatePointerCast(I->getOperand(1), VoidPtrTy, "", I); + std::vector Args; + Args.push_back(BCI); + Args.push_back(I->getOperand(2)); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + Constant *F = M.getOrInsertFunction("trackInitInst", VoidTy, VoidPtrTy, I->getOperand(2)->getType(), Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", I); + } else if(F->getNameStr() == std::string("sscanf")) { + // FIXME: Need to look at the format string and check + unsigned i = 3; + while(i < I->getNumOperands()) { + visitInputFunctionValue(M, I->getOperand(i), I); + i++; + } + } else if(F->getNameStr() == std::string("fscanf")) { + unsigned i = 3; + while(i < I->getNumOperands()) { + visitInputFunctionValue(M, I->getOperand(i), I); + i++; + } } } return true; } +bool TypeChecks::visitInputFunctionValue(Module &M, Value *V, Instruction *CI) { + // Cast the pointer operand to i8* for the runtime function. + CastInst *BCI = BitCastInst::CreatePointerCast(V, VoidPtrTy, "", CI); + const PointerType *PTy = dyn_cast(V->getType()); + if(!PTy) + return false; + + std::vector Args; + Args.push_back(BCI); + Args.push_back(ConstantInt::get(Int8Ty, UsedTypes[PTy->getElementType()])); // SI.getValueOperand() + Args.push_back(ConstantInt::get(Int64Ty, TD->getTypeStoreSize(PTy->getElementType()))); + Args.push_back(ConstantInt::get(Int32Ty, tagCounter++)); + + // Create the call to the runtime check and place it before the store instruction. + Constant *F = M.getOrInsertFunction("trackStoreInst", VoidTy, VoidPtrTy, Int8Ty, Int64Ty, Int32Ty, NULL); + CallInst::Create(F, Args.begin(), Args.end(), "", CI); + + return true; +} // Insert runtime checks before all load instructions. bool TypeChecks::visitLoadInst(Module &M, LoadInst &LI) { Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c?rev=130200&r1=130199&r2=130200&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.c Tue Apr 26 10:42:48 2011 @@ -41,7 +41,7 @@ /** * Record the global type and address in the shadow memory. */ -void trackGlobal(void *ptr, uint8_t typeNumber, uint8_t size, uint32_t tag) { +void trackGlobal(void *ptr, uint8_t typeNumber, uint64_t size, uint32_t tag) { uintptr_t p = (uintptr_t)ptr; p &= 0xFFFFFFFF; shadow_begin[p] = typeNumber; @@ -53,7 +53,7 @@ /** * Record the type stored at ptr(of size size) and replicate it */ -void trackGlobalArray(void *ptr, uint32_t size, uint32_t count, uint32_t tag) { +void trackGlobalArray(void *ptr, uint64_t size, uint64_t count, uint32_t tag) { unsigned i; uintptr_t p = (uintptr_t)ptr; uintptr_t p1 = (uintptr_t)ptr; From aggarwa4 at illinois.edu Tue Apr 26 10:43:49 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 26 Apr 2011 15:43:49 -0000 Subject: [llvm-commits] [poolalloc] r130201 - /poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp Message-ID: <20110426154349.C8E692A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 10:43:49 2011 New Revision: 130201 URL: http://llvm.org/viewvc/llvm-project?rev=130201&view=rev Log: Do not change functions that have byval arguments. Is causing some attribute problems. Modified: poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp Modified: poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp?rev=130201&r1=130200&r2=130201&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp (original) +++ poolalloc/trunk/lib/AssistDS/StructReturnToPointer.cpp Tue Apr 26 10:43:49 2011 @@ -78,7 +78,6 @@ // Create the new function body and insert it into the module. Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName(), &M); - NF->copyAttributesFrom(F); DenseMap ValueMap; Function::arg_iterator NI = NF->arg_begin(); NI->setName("ret"); @@ -96,7 +95,7 @@ ae= NF->arg_end(); ai != ae; ++ai) { fargs.push_back(ai); } - NF->setAlignment(F->getAlignment()); + NF->setAlignment(F->getAlignment()); for (Function::iterator B = NF->begin(), FE = NF->end(); B != FE; ++B) { for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { ReturnInst * RI = dyn_cast(I++); @@ -115,9 +114,11 @@ continue; if(CI->getCalledFunction() != F) continue; + if(CI->hasByValArgument()) + continue; AllocaInst *AllocaNew = new AllocaInst(F->getReturnType(), 0, "", CI); SmallVector Args; - + Args.push_back(AllocaNew); for(unsigned j =1;jgetNumOperands();j++) { Args.push_back(CI->getOperand(j)); From aggarwa4 at illinois.edu Tue Apr 26 10:48:07 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 26 Apr 2011 15:48:07 -0000 Subject: [llvm-commits] [poolalloc] r130202 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Message-ID: <20110426154807.834C52A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 10:48:07 2011 New Revision: 130202 URL: http://llvm.org/viewvc/llvm-project?rev=130202&view=rev Log: Make sure that there are no stores between the load of the value, and the call inst. Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130202&r1=130201&r2=130202&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Tue Apr 26 10:48:07 2011 @@ -41,8 +41,6 @@ continue; // we are only interested in GEPs LoadInst *LI = cast(I); - if(LI->getType()->isPointerTy()) - continue; // If the GEP is not doing structure indexing, dont care. for (Value::use_iterator UI = LI->use_begin(),UE = LI->use_end(); UI != UE; ) { // check if GEP is used in a Call Inst @@ -52,6 +50,30 @@ if(CI->hasByValArgument()) continue; + + // It should be in the same basic block + if(LI->getParent() != CI->getParent()) + continue; + + // Also check that there is no store after the load. + // TODO: Check if the load/store do not alias. + BasicBlock::iterator bii = LI->getParent()->begin(); + Instruction *BII = bii; + while(BII != LI) { + ++bii; + BII = bii; + } + while(BII != CI) { + if(isa(BII)) + break; + ++bii; + BII = bii; + } + if(isa(bii)){ + continue; + } + + // if the GEP calls a function, that is externally defined, // or might be changed, ignore this call site. Function *F = CI->getCalledFunction(); @@ -69,18 +91,9 @@ if(LI == CI->getOperand(argNum)) break; - unsigned i = 1; - Function::arg_iterator II = F->arg_begin(); - for (; i!= argNum; ++II, ++i) { - ; - } if(F->paramHasAttr(argNum, Attribute::SExt) || F->paramHasAttr(argNum, Attribute::ZExt)) continue; - if(II->getNumUses() !=1) - continue; - if(!isa(II->use_begin())) - continue; // Construct the new Type // Appends the struct Type at the beginning std::vectorTP; @@ -93,7 +106,7 @@ const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); Function *NewF; numSimplified++; - if(numSimplified > 26) //26 + if(numSimplified > 50) //26 return true; NewF = Function::Create(NewFTy, @@ -135,7 +148,7 @@ Args.push_back(CI->getOperand(j)); } CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); + CallI->setCallingConv(CI->getCallingConv()); CI->replaceAllUsesWith(CallI); CI->eraseFromParent(); } From gohman at apple.com Tue Apr 26 12:18:34 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 26 Apr 2011 17:18:34 -0000 Subject: [llvm-commits] [llvm] r130205 - in /llvm/trunk: lib/CodeGen/SelectionDAG/FastISel.cpp test/CodeGen/X86/fast-isel.ll Message-ID: <20110426171834.34C742A6C12D@llvm.org> Author: djg Date: Tue Apr 26 12:18:34 2011 New Revision: 130205 URL: http://llvm.org/viewvc/llvm-project?rev=130205&view=rev Log: Fast-isel support for simple inline asms. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130205&r1=130204&r2=130205&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Apr 26 12:18:34 2011 @@ -482,14 +482,35 @@ } bool FastISel::SelectCall(const User *I) { - const Function *F = cast(I)->getCalledFunction(); + const CallInst *Call = cast(I); + + // Handle simple inline asms. + if (const InlineAsm *IA = dyn_cast(Call->getArgOperand(0))) { + // Don't attempt to handle constraints. + if (!IA->getConstraintString().empty()) + return false; + + unsigned ExtraInfo = 0; + if (IA->hasSideEffects()) + ExtraInfo |= InlineAsm::Extra_HasSideEffects; + if (IA->isAlignStack()) + ExtraInfo |= InlineAsm::Extra_IsAlignStack; + + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + TII.get(TargetOpcode::INLINEASM)) + .addExternalSymbol(IA->getAsmString().c_str()) + .addImm(ExtraInfo); + return true; + } + + const Function *F = Call->getCalledFunction(); if (!F) return false; // Handle selected intrinsic function calls. switch (F->getIntrinsicID()) { default: break; case Intrinsic::dbg_declare: { - const DbgDeclareInst *DI = cast(I); + const DbgDeclareInst *DI = cast(Call); if (!DIVariable(DI->getVariable()).Verify() || !FuncInfo.MF->getMMI().hasDebugInfo()) return true; @@ -521,7 +542,7 @@ } case Intrinsic::dbg_value: { // This form of DBG_VALUE is target-independent. - const DbgValueInst *DI = cast(I); + const DbgValueInst *DI = cast(Call); const TargetInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE); const Value *V = DI->getValue(); if (!V) { @@ -550,7 +571,7 @@ return true; } case Intrinsic::eh_exception: { - EVT VT = TLI.getValueType(I->getType()); + EVT VT = TLI.getValueType(Call->getType()); if (TLI.getOperationAction(ISD::EXCEPTIONADDR, VT)!=TargetLowering::Expand) break; @@ -561,18 +582,18 @@ unsigned ResultReg = createResultReg(RC); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), ResultReg).addReg(Reg); - UpdateValueMap(I, ResultReg); + UpdateValueMap(Call, ResultReg); return true; } case Intrinsic::eh_selector: { - EVT VT = TLI.getValueType(I->getType()); + EVT VT = TLI.getValueType(Call->getType()); if (TLI.getOperationAction(ISD::EHSELECTION, VT) != TargetLowering::Expand) break; if (FuncInfo.MBB->isLandingPad()) - AddCatchInfo(*cast(I), &FuncInfo.MF->getMMI(), FuncInfo.MBB); + AddCatchInfo(*Call, &FuncInfo.MF->getMMI(), FuncInfo.MBB); else { #ifndef NDEBUG - FuncInfo.CatchInfoLost.insert(cast(I)); + FuncInfo.CatchInfoLost.insert(Call); #endif // FIXME: Mark exception selector register as live in. Hack for PR1508. unsigned Reg = TLI.getExceptionSelectorRegister(); @@ -586,7 +607,7 @@ BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TargetOpcode::COPY), ResultReg).addReg(Reg); - bool ResultRegIsKill = hasTrivialKill(I); + bool ResultRegIsKill = hasTrivialKill(Call); // Cast the register to the type of the selector. if (SrcVT.bitsGT(MVT::i32)) @@ -599,7 +620,7 @@ // Unhandled operand. Halt "fast" selection and bail. return false; - UpdateValueMap(I, ResultReg); + UpdateValueMap(Call, ResultReg); return true; } Modified: llvm/trunk/test/CodeGen/X86/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel.ll?rev=130205&r1=130204&r2=130205&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel.ll Tue Apr 26 12:18:34 2011 @@ -20,6 +20,7 @@ %t6 = add i32 %t5, 2 %t7 = getelementptr i32* %y, i32 1 %t8 = getelementptr i32* %t7, i32 %t6 + call void asm sideeffect "hello world", ""() br label %exit exit: From sabre at nondot.org Tue Apr 26 12:41:02 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 17:41:02 -0000 Subject: [llvm-commits] [llvm] r130206 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/SimplifyCFG/2006-08-03-Crash.ll Message-ID: <20110426174102.E48DB2A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 12:41:02 2011 New Revision: 130206 URL: http://llvm.org/viewvc/llvm-project?rev=130206&view=rev Log: Improve the bail-out predicate to really only kick in when phi translation fails. We were bailing out in some cases that would cause us to miss GVN'ing some non-local cases away. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130206&r1=130205&r2=130206&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Apr 26 12:41:02 2011 @@ -1103,7 +1103,8 @@ // If we had a phi translation failure, we'll have a single entry which is a // clobber in the current block. Reject this early. - if (Deps.size() == 1 && Deps[0].getResult().isClobber()) { + if (Deps.size() == 1 && Deps[0].getResult().isClobber() && + Deps[0].getResult().getInst()->getParent() == LI->getParent()) { DEBUG( dbgs() << "GVN: non-local load "; WriteAsOperand(dbgs(), LI); Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=130206&r1=130205&r2=130206&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Tue Apr 26 12:41:02 2011 @@ -570,4 +570,27 @@ } +; Cross block partial alias case. +define i32 @load_load_partial_alias_cross_block(i8* %P) nounwind ssp { +entry: + %xx = bitcast i8* %P to i32* + %x1 = load i32* %xx, align 4 + %cmp = icmp eq i32 %x1, 127 + br i1 %cmp, label %land.lhs.true, label %if.end + +land.lhs.true: ; preds = %entry + %arrayidx4 = getelementptr inbounds i8* %P, i64 1 + %tmp5 = load i8* %arrayidx4, align 1 + %conv6 = zext i8 %tmp5 to i32 + ret i32 %conv6 + +if.end: + ret i32 52 +; CHECK: @load_load_partial_alias_cross_block +; CHECK: land.lhs.true: +; CHECK-NOT: load i8 +; CHECK: ret i32 %conv6 +} + + Modified: llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll?rev=130206&r1=130205&r2=130206&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll Tue Apr 26 12:41:02 2011 @@ -1,7 +1,5 @@ -; RUN: opt < %s -gvn -simplifycfg \ -; RUN: -disable-output +; RUN: opt < %s -gvn -simplifycfg -disable-output ; PR867 -; END. target datalayout = "E-p:32:32" target triple = "powerpc-apple-darwin8" From daniel at zuster.org Tue Apr 26 12:47:37 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:37 -0000 Subject: [llvm-commits] [zorg] r130209 - in /zorg/trunk/lnt: lnt/lnttool/__init__.py lnt/server/ lnt/server/__init__.py lnt/server/ui/ lnt/server/ui/__init__.py lnt/server/ui/app.py lnt/server/ui/static/ lnt/server/ui/static/favicon.ico lnt/server/ui/static/style.css lnt/server/ui/templates/ lnt/server/ui/templates/index.html lnt/server/ui/templates/layout.html lnt/server/ui/views.py setup.py Message-ID: <20110426174738.085F72A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:37 2011 New Revision: 130209 URL: http://llvm.org/viewvc/llvm-project?rev=130209&view=rev Log: LNT: Sketch outline for new Flask based server UI. Added: zorg/trunk/lnt/lnt/server/ zorg/trunk/lnt/lnt/server/__init__.py zorg/trunk/lnt/lnt/server/ui/ zorg/trunk/lnt/lnt/server/ui/__init__.py zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/server/ui/static/ zorg/trunk/lnt/lnt/server/ui/static/favicon.ico zorg/trunk/lnt/lnt/server/ui/static/style.css zorg/trunk/lnt/lnt/server/ui/templates/ zorg/trunk/lnt/lnt/server/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/templates/layout.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py zorg/trunk/lnt/setup.py Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=130209&r1=130208&r2=130209&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/__init__.py (original) +++ zorg/trunk/lnt/lnt/lnttool/__init__.py Tue Apr 26 12:47:37 2011 @@ -25,6 +25,9 @@ parser.add_option("", "--processes", dest="processes", type=int, metavar="N", help="number of processes to use [%default]", default=1) + parser.add_option("", "--use-flask-app", dest="use_flask_app", + help="use the Flask based UI [%default]", + action="store_true", default=False) (opts, args) = parser.parse_args(args) if len(args) != 1: @@ -41,11 +44,23 @@ if not config or not os.path.exists(config): raise SystemExit,"error: invalid config: %r" % config - from werkzeug import run_simple - from lnt.viewer import app - run_simple(opts.hostname, opts.port, app.create_app(config), - opts.reloader, opts.debugger, - False, None, 1, opts.threaded, opts.processes) + if opts.use_flask_app: + import lnt.server.ui.app + instance = lnt.server.ui.app.App.create_standalone( + config_path = config) + if opts.debugger: + instance.debug = True + instance.run(opts.hostname, opts.port, + use_reloader = opts.reloader, + use_debugger = opts.debugger, + threaded = opts.threaded, + processes = opts.processes) + else: + from werkzeug import run_simple + from lnt.viewer import app + run_simple(opts.hostname, opts.port, app.create_app(config), + opts.reloader, opts.debugger, + False, None, 1, opts.threaded, opts.processes) from create import action_create from convert import action_convert Added: zorg/trunk/lnt/lnt/server/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/__init__.py?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/__init__.py (added) +++ zorg/trunk/lnt/lnt/server/__init__.py Tue Apr 26 12:47:37 2011 @@ -0,0 +1 @@ +__all__ = [] Added: zorg/trunk/lnt/lnt/server/ui/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/__init__.py?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/__init__.py (added) +++ zorg/trunk/lnt/lnt/server/ui/__init__.py Tue Apr 26 12:47:37 2011 @@ -0,0 +1 @@ +__all__ = [] Added: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (added) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:47:37 2011 @@ -0,0 +1,34 @@ +import logging +import logging.handlers +import os + +import flask + +import lnt.server.ui.views + +# FIXME: Redesign this. +import lnt.viewer.Config + +class App(flask.Flask): + @staticmethod + def create_standalone(config_path): + # Construct the application. + app = App(__name__) + + # Load the application configuration. + app.load_config(config_path) + + # Load the application routes. + app.register_module(lnt.server.ui.views.frontend) + + return app + + def __init__(self, name): + super(App, self).__init__(name) + + def load_config(self, config_path): + config_data = {} + exec open(config_path) in config_data + + self.old_config = lnt.viewer.Config.Config.fromData( + config_path, config_data) Added: zorg/trunk/lnt/lnt/server/ui/static/favicon.ico URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/favicon.ico?rev=130209&view=auto ============================================================================== Binary files zorg/trunk/lnt/lnt/server/ui/static/favicon.ico (added) and zorg/trunk/lnt/lnt/server/ui/static/favicon.ico Tue Apr 26 12:47:37 2011 differ Added: zorg/trunk/lnt/lnt/server/ui/static/style.css URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/style.css?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/static/style.css (added) +++ zorg/trunk/lnt/lnt/server/ui/static/style.css Tue Apr 26 12:47:37 2011 @@ -0,0 +1,6 @@ +body { + background-color: #FFFFFF; + font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, + Helvetica, sans-serif; + font-size: small; +} Added: zorg/trunk/lnt/lnt/server/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/index.html?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/index.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/index.html Tue Apr 26 12:47:37 2011 @@ -0,0 +1,6 @@ +{% extends "layout.html" %} +{% block title %}LNT{% endblock %} +{% block body %} +WIP +{% endblock %} + Added: zorg/trunk/lnt/lnt/server/ui/templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/layout.html?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/layout.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/layout.html Tue Apr 26 12:47:37 2011 @@ -0,0 +1,13 @@ + + + + + {{ self.title() }} + + + +
{% block body %}{% endblock %}
+ + Added: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130209&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (added) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:47:37 2011 @@ -0,0 +1,14 @@ +import flask +from flask import redirect +from flask import render_template +from flask import url_for + +frontend = flask.Module(__name__) + + at frontend.route('/') +def index(): + return render_template("index.html") + + at frontend.route('/favicon.ico') +def favicon_ico(): + return redirect(url_for('.static', filename='favicon.ico')) Modified: zorg/trunk/lnt/setup.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/setup.py?rev=130209&r1=130208&r2=130209&view=diff ============================================================================== --- zorg/trunk/lnt/setup.py (original) +++ zorg/trunk/lnt/setup.py Tue Apr 26 12:47:37 2011 @@ -57,5 +57,5 @@ 'lnt = lnt.lnttool:main', ], }, - install_requires=['Quixote==2.7b2', 'SQLAlchemy', 'Werkzeug'], + install_requires=['Quixote==2.7b2', 'SQLAlchemy', 'Flask'], ) From daniel at zuster.org Tue Apr 26 12:47:43 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:43 -0000 Subject: [llvm-commits] [zorg] r130210 - in /zorg/trunk: llvmlab/llvmlab/ui/templates/index.html lnt/lnt/server/ui/app.py lnt/lnt/server/ui/filters.py lnt/lnt/server/ui/static/style.css lnt/lnt/server/ui/templates/index.html lnt/lnt/server/ui/templates/layout.html lnt/lnt/server/ui/views.py Message-ID: <20110426174743.495832A6C12E@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:43 2011 New Revision: 130210 URL: http://llvm.org/viewvc/llvm-project?rev=130210&view=rev Log: LNT/Flask: Migrate header, footer, and index. Added: zorg/trunk/lnt/lnt/server/ui/filters.py Modified: zorg/trunk/llvmlab/llvmlab/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/server/ui/static/style.css zorg/trunk/lnt/lnt/server/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/templates/layout.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/llvmlab/llvmlab/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/llvmlab/ui/templates/index.html?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/llvmlab/llvmlab/ui/templates/index.html (original) +++ zorg/trunk/llvmlab/llvmlab/ui/templates/index.html Tue Apr 26 12:47:43 2011 @@ -1,4 +1,5 @@ {% extends "layout.html" %} +{% set components = [] %} {% block title %}home{% endblock %} {% block body %} Modified: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (original) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:47:43 2011 @@ -1,20 +1,36 @@ import logging import logging.handlers import os +import time import flask +from flask import current_app +import lnt +import lnt.server.ui.filters import lnt.server.ui.views # FIXME: Redesign this. import lnt.viewer.Config +class Request(flask.Request): + def __init__(self, *args, **kwargs): + super(Request, self).__init__(*args, **kwargs) + + self.request_time = time.time() + + def elapsed_time(self): + return time.time() - self.request_time + class App(flask.Flask): @staticmethod def create_standalone(config_path): # Construct the application. app = App(__name__) + # Register additional filters. + lnt.server.ui.filters.register(app) + # Load the application configuration. app.load_config(config_path) @@ -25,6 +41,13 @@ def __init__(self, name): super(App, self).__init__(name) + self.start_time = time.time() + + # Override the request class. + self.request_class = Request + + # Store a few global things we want available to templates. + self.version = lnt.__version__ def load_config(self, config_path): config_data = {} @@ -32,3 +55,7 @@ self.old_config = lnt.viewer.Config.Config.fromData( config_path, config_data) + + self.jinja_env.globals.update( + app=current_app, + old_config=self.old_config) Added: zorg/trunk/lnt/lnt/server/ui/filters.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/filters.py?rev=130210&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/filters.py (added) +++ zorg/trunk/lnt/lnt/server/ui/filters.py Tue Apr 26 12:47:43 2011 @@ -0,0 +1,11 @@ +import datetime + +def filter_asusertime(time): + # FIXME: Support alternate timezones? + ts = datetime.datetime.fromtimestamp(time) + return ts.strftime('%Y-%m-%d %H:%M:%S %Z PST') + +def register(app): + for name,object in globals().items(): + if name.startswith('filter_'): + app.jinja_env.filters[name[7:]] = object Modified: zorg/trunk/lnt/lnt/server/ui/static/style.css URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/style.css?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/static/style.css (original) +++ zorg/trunk/lnt/lnt/server/ui/static/style.css Tue Apr 26 12:47:43 2011 @@ -1,6 +1,79 @@ +.zorg_navheader { + background-color: #cccccc; +} + +body { + color:#000000; + background-color:#ffffff +} + body { - background-color: #FFFFFF; - font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Verdana, - Helvetica, sans-serif; - font-size: small; + font-family: Helvetica, sans-serif; + font-size:9pt +} + +h1 { + font-size: 14pt; +} + +h2 { + font-size: 12pt; +} + +table { + font-size:9pt +} + +table { + border-spacing: 0px; + border: 1px solid black +} + +th, table thead { + background-color:#eee; + color:#666666; + font-weight: bold; + cursor: default; + text-align:center; + font-weight: bold; + font-family: Verdana; +} + +.W { + font-size:0px +} + +th, td { + padding:5px; + padding-left:8px; +} + +tbody.scrollContent { + overflow:auto +} + +.hideable { + border-width:thin; + border-color:background; + border-style:solid; + background: #F8F8FF; + padding:8px; +} + +/* Nested popups */ + +.hideable_1 { + border-width:thin; + border-color:background; + border-style:solid; + background: #F8F8FF; + padding:8px; +} + +.hideable_2 { + border-width:thin; + border-color:background; + border-style:solid; + background: #E8E8E8; + padding:8px; } Modified: zorg/trunk/lnt/lnt/server/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/index.html?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/index.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/index.html Tue Apr 26 12:47:43 2011 @@ -1,6 +1,14 @@ {% extends "layout.html" %} -{% block title %}LNT{% endblock %} +{% set components = [] %} +{% block title %}Overview{% endblock %} {% block body %} -WIP -{% endblock %} +{% if db_info.showGeneral %} +
+ +

General Database Access

+

Browse DB +

Submit Run +{% endif %} + +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/layout.html?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/layout.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/layout.html Tue Apr 26 12:47:43 2011 @@ -3,11 +3,76 @@ - {{ self.title() }} + + {{old_config.name}}{% + for short_name,_ in components + %} : {{short_name}}{% endfor %} - {{ self.title() }} + {% block head %}{% endblock %} + +{% if self.onload %} + +{% else %} -

{% block body %}{% endblock %}
+{% endif %} + +{# Header #} + +{# Database selection header. #} +
+
+ + + + + +
+ + [{{ db_name }}] + + + + Database: + + +
+
+
+ +{# Component links #} +

{{old_config.name}} +{% for short_name,path in components %} + : {{short_name}} +{% endfor %} + - {{ self.title() }}

+ +{# Actual body #} +
{% + block body %}{% endblock %} +
+ +{# Include any database log, if present. #} +{% if g.db_log %} +
+ +

SQL Log

+
{{g.db_log}}
+{% endif %} + +{# Footer #} +
+LNT Version: {{ app.version }}
+Server Started: {{ app.start_time|asusertime }}
+Generated: {{ request.request_time|asusertime }}
+Render Time: {{ "%.2fs" % request.elapsed_time() }}
Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130210&r1=130209&r2=130210&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:47:43 2011 @@ -1,14 +1,62 @@ +import os + import flask +from flask import abort +from flask import current_app from flask import redirect from flask import render_template +from flask import request from flask import url_for frontend = flask.Module(__name__) - at frontend.route('/') -def index(): - return render_template("index.html") +### +# Root-Only Routes @frontend.route('/favicon.ico') def favicon_ico(): return redirect(url_for('.static', filename='favicon.ico')) + + at frontend.route('/select_db') +def select_db(): + path = request.args.get('path') + db = request.args.get('db') + if path is None: + abort(400) + if db not in current_app.old_config.databases: + abort(404) + + # Rewrite the path. + new_path = "/db_%s" % db + if not path.startswith("/db_"): + new_path += path + else: + if '/' in path[1:]: + new_path += "/" + path.split("/", 2)[2] + return redirect(request.script_root + new_path) + +##### +# Per-Database Routes + + at frontend.route('/') + at frontend.route('/db_') + at frontend.route('/db_/') +def index(name = None): + name = name or "default" + db_info = current_app.old_config.databases.get(name) + return render_template("index.html", db_name=name, db_info=db_info) + +### +# Database Actions + + at frontend.route('/browse') +def browse(name = None): + name = name or "default" + db_info = current_app.old_config.databases.get(name) + raise NotImplementedError + + at frontend.route('/submitRun') +def submit_run(name = None): + name = name or "default" + db_info = current_app.old_config.databases.get(name) + raise NotImplementedError From daniel at zuster.org Tue Apr 26 12:47:46 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:46 -0000 Subject: [llvm-commits] [zorg] r130211 - in /zorg/trunk/lnt/lnt/server/ui: templates/index.html templates/layout.html views.py Message-ID: <20110426174746.731F92A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:46 2011 New Revision: 130211 URL: http://llvm.org/viewvc/llvm-project?rev=130211&view=rev Log: LNT/Flask: Add a decorator for defining per-db routes. Modified: zorg/trunk/lnt/lnt/server/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/templates/layout.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/index.html?rev=130211&r1=130210&r2=130211&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/index.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/index.html Tue Apr 26 12:47:46 2011 @@ -3,7 +3,7 @@ {% block title %}Overview{% endblock %} {% block body %} -{% if db_info.showGeneral %} +{% if g.db_info.showGeneral %}

General Database Access

Modified: zorg/trunk/lnt/lnt/server/ui/templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/layout.html?rev=130211&r1=130210&r2=130211&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/layout.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/layout.html Tue Apr 26 12:47:46 2011 @@ -30,7 +30,7 @@ - [{{ db_name }}] + [{{ g.db_name }}] Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130211&r1=130210&r2=130211&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:47:46 2011 @@ -3,6 +3,7 @@ import flask from flask import abort from flask import current_app +from flask import g from flask import redirect from flask import render_template from flask import request @@ -38,25 +39,43 @@ ##### # Per-Database Routes - at frontend.route('/') - at frontend.route('/db_') - at frontend.route('/db_/') -def index(name = None): - name = name or "default" - db_info = current_app.old_config.databases.get(name) - return render_template("index.html", db_name=name, db_info=db_info) +# Decorator for implementing per-database routes. +def db_route(rule, **options): + """ + LNT specific route for endpoints which always refer to some database + object. + + This decorator handles adding the routes for both the default and explicit + database, as well as initializing the global database information objects. + """ + def decorator(f): + def wrap(db_name = None, **args): + # Initialize the database parameters on the app globals object. + g.db_name = db_name or "default" + g.db_info = current_app.old_config.databases.get(g.db_name) + if g.db_info is None: + abort(404) + + return f(**args) + + frontend.add_url_rule(rule, f.__name__, wrap, **options) + frontend.add_url_rule("/db_" + rule, + f.__name__, wrap, **options) + + return wrap + return decorator + + at db_route('/') +def index(): + return render_template("index.html") ### # Database Actions - at frontend.route('/browse') -def browse(name = None): - name = name or "default" - db_info = current_app.old_config.databases.get(name) + at db_route('/browse') +def browse(): raise NotImplementedError - at frontend.route('/submitRun') -def submit_run(name = None): - name = name or "default" - db_info = current_app.old_config.databases.get(name) + at db_route('/submitRun') +def submit_run(): raise NotImplementedError From daniel at zuster.org Tue Apr 26 12:47:53 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:53 -0000 Subject: [llvm-commits] [zorg] r130213 - in /zorg/trunk/lnt/lnt: server/ui/app.py server/ui/templates/browse.html server/ui/templates/index.html server/ui/templates/layout.html server/ui/views.py viewer/PerfDB.py Message-ID: <20110426174754.0C2242A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:53 2011 New Revision: 130213 URL: http://llvm.org/viewvc/llvm-project?rev=130213&view=rev Log: LNT/Flask: Port browse page. Added: zorg/trunk/lnt/lnt/server/ui/templates/browse.html Modified: zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/server/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/templates/layout.html zorg/trunk/lnt/lnt/server/ui/views.py zorg/trunk/lnt/lnt/viewer/PerfDB.py Modified: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130213&r1=130212&r2=130213&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (original) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:47:53 2011 @@ -85,6 +85,7 @@ self.jinja_env.globals.update( app=current_app, + perfdb=PerfDB, old_config=self.old_config) def get_db_summary(self, db_name, db): Added: zorg/trunk/lnt/lnt/server/ui/templates/browse.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/browse.html?rev=130213&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/browse.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/browse.html Tue Apr 26 12:47:53 2011 @@ -0,0 +1,59 @@ +{% extends "layout.html" %} +{% set components = [] %} +{% block title %}Database Browser{% endblock %} +{% block body %} + +{% set db = request.get_db() %} +

Machines

+ + + + + + +{% for m in db.machines() %} + + + +{% endfor %} +
Name
{{m.name}}:{{m.number}}
+ +{# List runs. #} +

Run List

+ + + + + + + + + +{% for r,m in db.query(perfdb.Run, perfdb.Machine).join(perfdb.Machine) %} + + + + + + +{% endfor %} +
IDMachineStart TimeEnd Time
{{r.id}}{{m.name}}:{{m.number}}{{r.start_time}}{{r.end_time}}
+ +{# List tests. #} +

Test List

+ + + + + + + +{% for id,name in db.query(perfdb.Test.id, perfdb.Test.name) %} + + + + +{% endfor %} +
IDTest
{{id}}{{name}}
+ +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/index.html?rev=130213&r1=130212&r2=130213&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/index.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/index.html Tue Apr 26 12:47:53 2011 @@ -3,7 +3,6 @@ {% block title %}Overview{% endblock %} {% block body %} - {# Display available test result suites. #} {% set summary = request.get_db_summary() %}

Test Results

Modified: zorg/trunk/lnt/lnt/server/ui/templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/layout.html?rev=130213&r1=130212&r2=130213&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/layout.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/layout.html Tue Apr 26 12:47:53 2011 @@ -38,7 +38,7 @@ Database: Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130213&r1=130212&r2=130213&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:47:53 2011 @@ -74,7 +74,7 @@ @db_route('/browse') def browse(): - raise NotImplementedError + return render_template("browse.html") @db_route('/submitRun') def submit_run(): Modified: zorg/trunk/lnt/lnt/viewer/PerfDB.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/PerfDB.py?rev=130213&r1=130212&r2=130213&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/PerfDB.py (original) +++ zorg/trunk/lnt/lnt/viewer/PerfDB.py Tue Apr 26 12:47:53 2011 @@ -192,6 +192,9 @@ self.get_revision(r) self.commit() + # Add shortcut alias. + self.query = self.session.query + def get_revision(self, name): for r in self.session.query(Revision).filter_by(name=name): return r From daniel at zuster.org Tue Apr 26 12:47:49 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:49 -0000 Subject: [llvm-commits] [zorg] r130212 - in /zorg/trunk/lnt/lnt/server/ui: app.py templates/index.html templates/layout.html Message-ID: <20110426174749.C16B32A6C12F@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:49 2011 New Revision: 130212 URL: http://llvm.org/viewvc/llvm-project?rev=130212&view=rev Log: LNT/Flask: Finish porting index page. Modified: zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/server/ui/templates/index.html zorg/trunk/lnt/lnt/server/ui/templates/layout.html Modified: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130212&r1=130211&r2=130212&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (original) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:47:49 2011 @@ -5,6 +5,7 @@ import flask from flask import current_app +from flask import g import lnt import lnt.server.ui.filters @@ -12,16 +13,41 @@ # FIXME: Redesign this. import lnt.viewer.Config +from lnt.db import perfdbsummary +from lnt.viewer import PerfDB class Request(flask.Request): def __init__(self, *args, **kwargs): super(Request, self).__init__(*args, **kwargs) self.request_time = time.time() + self.db = None + self.db_summary = None def elapsed_time(self): return time.time() - self.request_time + # Utility Methods + + def get_db(self): + if self.db is None: + self.db = PerfDB.PerfDB(g.db_info.path) + + # Enable SQL logging with db_log. + # + # FIXME: Conditionalize on an is_production variable. + if self.args.get('db_log') or self.form.get('db_log'): + import logging, StringIO + g.db_log = StringIO.StringIO() + logger = logging.getLogger("sqlalchemy") + logger.addHandler(logging.StreamHandler(g.db_log)) + self.db.engine.echo = True + + return self.db + + def get_db_summary(self): + return current_app.get_db_summary(g.db_name, self.get_db()) + class App(flask.Flask): @staticmethod def create_standalone(config_path): @@ -42,6 +68,7 @@ def __init__(self, name): super(App, self).__init__(name) self.start_time = time.time() + self.db_summaries = {} # Override the request class. self.request_class = Request @@ -59,3 +86,11 @@ self.jinja_env.globals.update( app=current_app, old_config=self.old_config) + + def get_db_summary(self, db_name, db): + db_summary = self.db_summaries.get(db_name) + if db_summary is None or not db_summary.is_up_to_date(db): + self.db_summaries[db_name] = db_summary = \ + perfdbsummary.PerfDBSummary.fromdb(db) + return db_summary + Modified: zorg/trunk/lnt/lnt/server/ui/templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/index.html?rev=130212&r1=130211&r2=130212&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/index.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/index.html Tue Apr 26 12:47:49 2011 @@ -3,6 +3,14 @@ {% block title %}Overview{% endblock %} {% block body %} + +{# Display available test result suites. #} +{% set summary = request.get_db_summary() %} +

Test Results

+{% for suite in summary.suites %} + {{suite.name}}
+{% endfor %} + {% if g.db_info.showGeneral %}
Modified: zorg/trunk/lnt/lnt/server/ui/templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/layout.html?rev=130212&r1=130211&r2=130212&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/layout.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/layout.html Tue Apr 26 12:47:49 2011 @@ -65,7 +65,7 @@

SQL Log

-
{{g.db_log}}
+
{{g.db_log.getvalue()}}
{% endif %} {# Footer #} From daniel at zuster.org Tue Apr 26 12:47:57 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:47:57 -0000 Subject: [llvm-commits] [zorg] r130214 - in /zorg/trunk/lnt/lnt/server/ui: app.py templates/machine.html templates/run.html templates/test.html views.py Message-ID: <20110426174757.C6A8A2A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:47:57 2011 New Revision: 130214 URL: http://llvm.org/viewvc/llvm-project?rev=130214&view=rev Log: LNT/Flask: Port generic database views. Added: zorg/trunk/lnt/lnt/server/ui/templates/machine.html zorg/trunk/lnt/lnt/server/ui/templates/run.html zorg/trunk/lnt/lnt/server/ui/templates/test.html Modified: zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130214&r1=130213&r2=130214&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (original) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:47:57 2011 @@ -6,6 +6,7 @@ import flask from flask import current_app from flask import g +from flask import url_for import lnt import lnt.server.ui.filters @@ -48,6 +49,12 @@ def get_db_summary(self): return current_app.get_db_summary(g.db_name, self.get_db()) +def db_url_for(*args, **kwargs): + """ + Like url_for, but handles automatically providing the db_name argument. + """ + return url_for(*args, db_name=g.db_name, **kwargs) + class App(flask.Flask): @staticmethod def create_standalone(config_path): @@ -85,6 +92,7 @@ self.jinja_env.globals.update( app=current_app, + db_url_for=db_url_for, perfdb=PerfDB, old_config=self.old_config) Added: zorg/trunk/lnt/lnt/server/ui/templates/machine.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/machine.html?rev=130214&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/machine.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/machine.html Tue Apr 26 12:47:57 2011 @@ -0,0 +1,43 @@ +{% set db = request.get_db() %} +{% set machine = db.getMachine(id) %} + +{% extends "layout.html" %} +{% set components = [("browse", db_url_for("browse"))] %} +{% block title %}Machine: {{machine.name}}:{{machine.number}}{% endblock %} +{% block body %} + +{# Show the machine info dictionary. #} + + + + + + +{% for mi in machine.info.values() %} + + + + +{% endfor %} +
KeyValue
{{mi.key}}{{mi.value}}
+ +{# List associated runs. #} +

Associated Runs

+ + + + + + + + +{% for r in db.runs(machine=machine) %} + + + + + +{% endfor %} +
Run IDStart TimeEnd Time
{{r.id}}{{r.start_time}}{{r.end_time}}
+ +{% endblock %} Added: zorg/trunk/lnt/lnt/server/ui/templates/run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/run.html?rev=130214&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/run.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/run.html Tue Apr 26 12:47:57 2011 @@ -0,0 +1,41 @@ +{% set db = request.get_db() %} +{% set run = db.getRun(id) %} +{% set machine = db.getMachine(run.machine_id) %} + +{% extends "layout.html" %} +{% set components = [("browse", db_url_for("browse"))] %} +{% block title %}Run: {{run.id}}{% endblock %} +{% block body %} + + + + + + + + + + + + + +
MachineStart TimeEnd Time
{{ + machine.name}}{{machine.number}}{{run.start_time}}{{run.end_time}}
+ +{# Show the run info dictionary. #} +

Run Info

+ + + + + + +{% for mi in run.info.values() %} + + + + +{% endfor %} +
KeyValue
{{mi.key}}{{mi.value}}
+ +{% endblock %} Added: zorg/trunk/lnt/lnt/server/ui/templates/test.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/test.html?rev=130214&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/test.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/test.html Tue Apr 26 12:47:57 2011 @@ -0,0 +1,43 @@ +{% set db = request.get_db() %} +{% set test = db.getTest(id) %} + +{% extends "layout.html" %} +{% set components = [("browse", db_url_for("browse"))] %} +{% block title %}Test: {{test.name}}{% endblock %} +{% block body %} + + +{# Show the test info dictionary. #} +

Test Info

+ + + + + + +{% for key,value in test.info|dictsort %} + + + + +{% endfor %} +
KeyValue
{{key}}{{value}}
+ +{# List samples. #} +

Associated Samples

+ + + + + + + +{% for s in db.samples(test=test) %} + + + + +{% endfor %} +
Run IDValue
{{s.run_id}}{{s.value}}
+ +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130214&r1=130213&r2=130214&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:47:57 2011 @@ -79,3 +79,18 @@ @db_route('/submitRun') def submit_run(): raise NotImplementedError + +### +# Generic Database Views + + at db_route("/machines//") +def machine(id): + return render_template("machine.html", id=id) + + at db_route("/runs//") +def run(id): + return render_template("run.html", id=id) + + at db_route("/tests//") +def test(id): + return render_template("test.html", id=id) From daniel at zuster.org Tue Apr 26 12:48:05 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:05 -0000 Subject: [llvm-commits] [zorg] r130215 - in /zorg/trunk/lnt: lnt/db/perfdb.py lnt/db/perfdbsummary.py lnt/db/runinfo.py lnt/lnttool/__init__.py lnt/lnttool/create.py lnt/lnttool/import_data.py lnt/server/ui/app.py lnt/util/ImportData.py lnt/util/NTEmailReport.py lnt/viewer/GraphUtil.py lnt/viewer/NTStyleBrowser.ptl lnt/viewer/NTUtil.py lnt/viewer/PerfDB.py lnt/viewer/nightlytest.ptl lnt/viewer/root.ptl lnt/viewer/simple.ptl lnt/viewer/zview/zviewui.ptl tests/DB/Create.py tests/DB/Import.py Message-ID: <20110426174805.4E6652A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:04 2011 New Revision: 130215 URL: http://llvm.org/viewvc/llvm-project?rev=130215&view=rev Log: LNT: Move viewer.PerfDB -> db.perfdb. Added: zorg/trunk/lnt/lnt/db/perfdb.py - copied, changed from r130214, zorg/trunk/lnt/lnt/viewer/PerfDB.py Removed: zorg/trunk/lnt/lnt/viewer/PerfDB.py Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py zorg/trunk/lnt/lnt/db/runinfo.py zorg/trunk/lnt/lnt/lnttool/__init__.py zorg/trunk/lnt/lnt/lnttool/create.py zorg/trunk/lnt/lnt/lnttool/import_data.py zorg/trunk/lnt/lnt/server/ui/app.py zorg/trunk/lnt/lnt/util/ImportData.py zorg/trunk/lnt/lnt/util/NTEmailReport.py zorg/trunk/lnt/lnt/viewer/GraphUtil.py zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl zorg/trunk/lnt/lnt/viewer/NTUtil.py zorg/trunk/lnt/lnt/viewer/nightlytest.ptl zorg/trunk/lnt/lnt/viewer/root.ptl zorg/trunk/lnt/lnt/viewer/simple.ptl zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl zorg/trunk/lnt/tests/DB/Create.py zorg/trunk/lnt/tests/DB/Import.py Copied: zorg/trunk/lnt/lnt/db/perfdb.py (from r130214, zorg/trunk/lnt/lnt/viewer/PerfDB.py) URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdb.py?p2=zorg/trunk/lnt/lnt/db/perfdb.py&p1=zorg/trunk/lnt/lnt/viewer/PerfDB.py&r1=130214&r2=130215&rev=130215&view=diff ============================================================================== (empty) Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original) +++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Tue Apr 26 12:48:04 2011 @@ -2,7 +2,7 @@ Classes for caching metadata about a PerfDB instance. """ -from lnt.viewer.PerfDB import Run, RunInfo, Sample, Test +from lnt.db.perfdb import Run, RunInfo, Sample, Test class SuiteSummary: def __init__(self, name, path): Modified: zorg/trunk/lnt/lnt/db/runinfo.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/runinfo.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/runinfo.py (original) +++ zorg/trunk/lnt/lnt/db/runinfo.py Tue Apr 26 12:48:04 2011 @@ -1,6 +1,6 @@ from lnt.util import stats from lnt.viewer import Util -from lnt.viewer.PerfDB import Sample +from lnt.db.perfdb import Sample from lnt.testing import PASS, FAIL, XFAIL REGRESSED = 'REGRESSED' Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/__init__.py (original) +++ zorg/trunk/lnt/lnt/lnttool/__init__.py Tue Apr 26 12:48:04 2011 @@ -6,6 +6,7 @@ import StringIO from lnt import testing +from lnt.db import perfdb def action_runserver(name, args): """start a new development server""" @@ -78,10 +79,8 @@ if len(args) != 1: parser.error("incorrect number of argments") - from lnt.viewer import PerfDB - path, = args - db = PerfDB.PerfDB('sqlite:///%s' % path) + db = perfdb.PerfDB('sqlite:///%s' % path) db.commit() def action_checkformat(name, args): @@ -102,12 +101,11 @@ input = StringIO.StringIO(sys.stdin.read()) from lnt import formats - from lnt.viewer import PerfDB - db = PerfDB.PerfDB('sqlite:///:memory:') + db = perfdb.PerfDB('sqlite:///:memory:') data = formats.read_any(input, '') - PerfDB.importDataFromDict(db, data) + perfdb.importDataFromDict(db, data) def action_runtest(name, args): """run a builtin test application""" @@ -159,7 +157,7 @@ tmp.flush() # Construct a temporary database and import the result. - db = lnt.viewer.PerfDB.PerfDB("sqlite:///:memory:") + db = lnt.db.perfdb.PerfDB("sqlite:///:memory:") result = ImportData.import_and_report( None, None, db, tmp.name, 'json', commit = True) ImportData.print_report_result(result, sys.stdout, opts.verbose) @@ -203,8 +201,7 @@ ServerUtil.submitFiles(args[0], args[1:], opts.commit, opts.verbose) from lnt.db import perfdbsummary, runinfo -from lnt.viewer import PerfDB -from lnt.viewer.PerfDB import Run, Machine, Sample, Test +from lnt.db.perfdb import Run, Machine, Sample, Test from lnt.util import stats def print_table(rows): @@ -238,7 +235,7 @@ parser.error("incorrect number of argments") path,machine = args - db = PerfDB.PerfDB('sqlite:///%s' % path) + db = perfdb.PerfDB('sqlite:///%s' % path) # FIXME: Argument tag = "nts" Modified: zorg/trunk/lnt/lnt/lnttool/create.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/create.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/create.py (original) +++ zorg/trunk/lnt/lnt/lnttool/create.py Tue Apr 26 12:48:04 2011 @@ -73,6 +73,8 @@ ### +import lnt.db.perfdb + def action_create(name, args): """create an LLVM nightly test installation""" @@ -137,8 +139,7 @@ wsgi_file.write(kWSGITemplate % locals()) wsgi_file.close() - from lnt.viewer import PerfDB - db = PerfDB.PerfDB('sqlite:///' + db_path) + db = lnt.db.perfdb.PerfDB('sqlite:///' + db_path) db.commit() print 'created LNT configuration in %r' % basepath Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/import_data.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/import_data.py (original) +++ zorg/trunk/lnt/lnt/lnttool/import_data.py Tue Apr 26 12:48:04 2011 @@ -1,7 +1,8 @@ import os, pprint, sys, time +import lnt.db.perfdb from lnt import formats -from lnt.viewer import Config, PerfDB +from lnt.viewer import Config from lnt.util import ImportData def action_import(name, args): @@ -52,7 +53,7 @@ parser.error("invalid database name") # Load the database. - db = PerfDB.PerfDB(db_entry.path, echo=opts.show_sql) + db = lnt.db.perfdb.PerfDB(db_entry.path, echo=opts.show_sql) for file in args: result = ImportData.import_and_report( config, opts.database, db, file, Modified: zorg/trunk/lnt/lnt/server/ui/app.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/app.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/app.py (original) +++ zorg/trunk/lnt/lnt/server/ui/app.py Tue Apr 26 12:48:04 2011 @@ -15,7 +15,7 @@ # FIXME: Redesign this. import lnt.viewer.Config from lnt.db import perfdbsummary -from lnt.viewer import PerfDB +from lnt.db import perfdb class Request(flask.Request): def __init__(self, *args, **kwargs): @@ -32,7 +32,7 @@ def get_db(self): if self.db is None: - self.db = PerfDB.PerfDB(g.db_info.path) + self.db = perfdb.PerfDB(g.db_info.path) # Enable SQL logging with db_log. # @@ -93,7 +93,7 @@ self.jinja_env.globals.update( app=current_app, db_url_for=db_url_for, - perfdb=PerfDB, + perfdb=perfdb, old_config=self.old_config) def get_db_summary(self, db_name, db): Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Tue Apr 26 12:48:04 2011 @@ -1,9 +1,9 @@ import os, re, time +import lnt.db.perfdb from lnt import formats from lnt.db import runinfo from lnt.util import NTEmailReport -from lnt.viewer import PerfDB def import_and_report(config, db_name, db, file, format, commit=False, show_sample_count=False, disable_email=False): @@ -60,7 +60,7 @@ importStartTime = time.time() try: - success,run = PerfDB.importDataFromDict(db, data) + success,run = perfdb.importDataFromDict(db, data) except KeyboardInterrupt: raise except: Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Tue Apr 26 12:48:04 2011 @@ -17,10 +17,10 @@ from lnt.db import perfdbsummary from lnt.viewer import GraphUtil from lnt.viewer import Util -from lnt.viewer import PerfDB +from lnt.db import perfdb from lnt.viewer.NTUtil import * -from lnt.viewer.PerfDB import Run, Sample +from lnt.db.perfdb import Run, Sample def main(): global opts @@ -33,7 +33,7 @@ dbpath,runID,baseurl,host,from_,to = args - db = PerfDB.PerfDB(dbpath) + db = lnt.db.perfdb.PerfDB(dbpath) run = db.getRun(int(runID)) emailReport(db, run, baseurl, host, from_, to) @@ -485,7 +485,7 @@ # user we are crosses machines. if compareTo is None: compareCrossesMachine = True - q = db.session.query(PerfDB.Run).join(PerfDB.Machine) + q = db.session.query(perfdb.Run).join(perfdb.Machine) q = q.filter_by(name=machine.name) compareTo = findPreceedingRun(q, run) Modified: zorg/trunk/lnt/lnt/viewer/GraphUtil.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/GraphUtil.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/GraphUtil.py (original) +++ zorg/trunk/lnt/lnt/viewer/GraphUtil.py Tue Apr 26 12:48:04 2011 @@ -7,7 +7,7 @@ from lnt.util import stats from lnt.external.stats import stats as ext_stats -from PerfDB import Machine, Run, RunInfo, Sample, Test +from lnt.db.perfdb import Machine, Run, RunInfo, Sample, Test def get_test_plots(db, machine, test_ids, run_summary, ts_summary, show_mad_error = False, show_points = False, Modified: zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/NTStyleBrowser.ptl Tue Apr 26 12:48:04 2011 @@ -15,9 +15,9 @@ from quixote.errors import TraversalError import Util -from NTUtil import * +from lnt.db.NTUtil import * -from PerfDB import Machine, Run, RunInfo +from lnt.db.perfdb import Machine, Run, RunInfo class TestRunUI(Directory): def __init__(self, root, idstr): Modified: zorg/trunk/lnt/lnt/viewer/NTUtil.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/NTUtil.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/NTUtil.py (original) +++ zorg/trunk/lnt/lnt/viewer/NTUtil.py Tue Apr 26 12:48:04 2011 @@ -1,5 +1,5 @@ import Util -from PerfDB import Run, Sample, Test +from lnt.db.perfdb import Run, Sample, Test kPrefix = 'nightlytest' Removed: zorg/trunk/lnt/lnt/viewer/PerfDB.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/PerfDB.py?rev=130214&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/viewer/PerfDB.py (original) +++ zorg/trunk/lnt/lnt/viewer/PerfDB.py (removed) @@ -1,488 +0,0 @@ -#!/usr/bin/python - -### -# SQLAlchemy database layer - -import sqlalchemy -import sqlalchemy.ext.declarative -import sqlalchemy.orm -from sqlalchemy import * -from sqlalchemy.schema import Index -from sqlalchemy.orm import relation, backref -from sqlalchemy.orm.collections import attribute_mapped_collection - -Base = sqlalchemy.ext.declarative.declarative_base() -class Revision(Base): - __tablename__ = 'Revision' - - id = Column("ID", Integer, primary_key=True) - name = Column("Name", String(256)) - number = Column("Number", Integer) - - def __init__(self, name, number): - self.name = name - self.number = number - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.number)) - -class Machine(Base): - __tablename__ = 'Machine' - - id = Column("ID", Integer, primary_key=True) - name = Column("Name", String(256)) - number = Column("Number", Integer) - - info = relation('MachineInfo', - collection_class=attribute_mapped_collection('key'), - backref=backref('machine')) - - def __init__(self, name, number): - self.name = name - self.number = number - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, (self.name, self.number)) - -class MachineInfo(Base): - __tablename__ = 'MachineInfo' - - id = Column("ID", Integer, primary_key=True) - machine_id = Column("Machine", Integer, ForeignKey('Machine.ID')) - key = Column("Key", String(256)) - value = Column("Value", String(4096)) - - def __init__(self, machine, key, value): - self.machine = machine - self.key = key - self.value = value - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.machine, self.key, self.value)) - -class Run(Base): - __tablename__ = 'Run' - - id = Column("ID", Integer, primary_key=True) - machine_id = Column("MachineID", Integer, ForeignKey('Machine.ID')) - start_time = Column("StartTime", DateTime) - end_time = Column("EndTime", DateTime) - - machine = relation(Machine) - - info = relation('RunInfo', - collection_class=attribute_mapped_collection('key'), - backref=backref('run')) - - def __init__(self, machine, start_time, end_time): - self.machine = machine - self.start_time = start_time - self.end_time = end_time - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.machine, self.start_time, self.end_time)) - -class RunInfo(Base): - __tablename__ = 'RunInfo' - - id = Column("ID", Integer, primary_key=True) - run_id = Column("Run", Integer, ForeignKey('Run.ID')) - key = Column("Key", String(256)) - value = Column("Value", String(4096)) - - def __init__(self, run, key, value): - self.run = run - self.key = key - self.value = value - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.run, self.key, self.value)) - -class Test(Base): - __tablename__ = 'Test' - - id = Column("ID", Integer, primary_key=True) - name = Column("Name", String(512)) - - info = relation('TestInfo', - collection_class=attribute_mapped_collection('key'), - backref=backref('test')) - - def __init__(self, name): - self.name = name - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.name,)) - - def get_parameter_set(self): - items = [(k,v.value) for k,v in self.info.items()] - items.sort() - return tuple(items) - -class TestInfo(Base): - __tablename__ = 'TestInfo' - - id = Column("ID", Integer, primary_key=True) - test_id = Column("Test", Integer, ForeignKey('Test.ID')) - key = Column("Key", String(256)) - value = Column("Value", String(4096)) - - def __init__(self, test, key, value): - self.test = test - self.key = key - self.value = value - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.test, self.key, self.value)) - -class Sample(Base): - __tablename__ = 'Sample' - - id = Column("ID", Integer, primary_key=True) - run_id = Column("RunID", Integer, ForeignKey('Run.ID'), index=True) - test_id = Column("TestID", Integer, ForeignKey('Test.ID'), index=True) - value = Column("Value", Float) - - run = relation(Run) - test = relation(Test) - - def __init__(self, run, test, value): - self.run = run - self.test = test - self.value = value - - def __repr__(self): - return '%s%r' % (self.__class__.__name__, - (self.run, self.test, self.value)) - -# Define an additonal index on (RunID, TestID). -Index("ix_Sample_RunID_TestID", Sample.run_id, Sample.test_id) - -### -# PerfDB wrapper, to avoid direct SA dependency when possible. - -def info_eq(a, b): - a = list(a) - b = list(b) - a.sort() - b.sort() - return a == b - -class PerfDB: - def __init__(self, path, echo=False): - if (not path.startswith('mysql://') and - not path.startswith('sqlite://')): - path = 'sqlite:///' + path - self.path = path - self.engine = sqlalchemy.create_engine(path, echo=echo) - - # Create the tables in case this is a new database. - Base.metadata.create_all(self.engine) - - self.session = sqlalchemy.orm.sessionmaker(self.engine)() - self.modified_machine = self.modified_run = self.modified_test = False - - # Make sure revision numbers exists. - for r in ("Machine","MachineInfo","Run","RunInfo","Test","TestInfo"): - self.get_revision(r) - self.commit() - - # Add shortcut alias. - self.query = self.session.query - - def get_revision(self, name): - for r in self.session.query(Revision).filter_by(name=name): - return r - r = Revision(name, 0) - self.session.add(r) - return r - def get_revision_number(self, name): - return self.get_revision(name).number - - def machines(self, name=None): - q = self.session.query(Machine) - if name: - q = q.filter_by(name=name) - return q - - def tests(self, name=None): - q = self.session.query(Test) - if name: - q = q.filter_by(name=name) - return q - - def runs(self, machine=None): - q = self.session.query(Run) - if machine: - q = q.filter_by(machine=machine) - return q - - def samples(self, run=None, test=None): - q = self.session.query(Sample) - if run: - q = q.filter_by(run_id=run.id) - if test: - q = q.filter_by(test_id=test.id) - return q - - def getNumMachines(self): - return self.machines().count() - - def getNumRuns(self): - return self.runs().count() - - def getNumTests(self): - return self.tests().count() - - def getNumSamples(self): - return self.samples().count() - - def getMachine(self, id): - return self.session.query(Machine).filter_by(id=id).one() - - def getRun(self, id): - return self.session.query(Run).filter_by(id=id).one() - - def getTest(self, id): - return self.session.query(Test).filter_by(id=id).one() - - def getOrCreateMachine(self, name, info): - # FIXME: Not really the right way... - number = 1 - for m in self.machines(name=name): - if info_eq([(i.key, i.value) for i in m.info.values()], info): - return m,False - number += 1 - - # Make a new record - m = Machine(name, number) - m.info = dict((k,MachineInfo(m,k,v)) for k,v in info) - self.session.add(m) - self.modified_machine = True - return m,True - - def getOrCreateTest(self, name, info): - # FIXME: Not really the right way... - for t in self.tests(name): - if info_eq([(i.key, i.value) for i in t.info.values()], info): - return t,False - - t = Test(name) - t.info = dict((k,TestInfo(t,k,v)) for k,v in info) - self.session.add(t) - self.modified_test = True - return t,True - - def getOrCreateRun(self, machine, start_time, end_time, info): - from datetime import datetime - start_time = datetime.strptime(start_time, - "%Y-%m-%d %H:%M:%S") - end_time = datetime.strptime(end_time, - "%Y-%m-%d %H:%M:%S") - - # FIXME: Not really the right way... - for r in self.session.query(Run).filter_by(machine=machine): - # FIXME: Execute this filter in SQL, but resolve the - # normalization issue w.r.t. SQLAlchemy first. I think we - # may be running afoul of SQLite not normalizing the - # datetime. If I don't do this then sqlalchemy issues a - # query in the format YYYY-MM-DD HH:MM:SS.ssss which - # doesn't work. - if r.start_time != start_time or r.end_time != end_time: - continue - if info_eq([(i.key, i.value) for i in r.info.values()], info): - return r,False - - # Make a new record - r = Run(machine, start_time, end_time) - r.info = dict((k,RunInfo(r,k,v)) for k,v in info) - self.session.add(r) - self.modified_run = True - return r,True - - def addSample(self, run, test, value): - s = Sample(run, test, value) - self.session.add(s) - return s - - def addSamples(self, samples): - """addSamples([(run_id, test_id, value), ...]) -> None - - Batch insert a list of samples.""" - - # Flush to keep session consistent. - self.session.flush() - - for run_id,test_id,value in samples: - q = Sample.__table__.insert().values(RunID = run_id, - TestID = test_id, - Value = value) - self.session.execute(q) - - def commit(self): - if self.modified_machine: - self.get_revision("Machine").number += 1 - self.get_revision("MachineInfo").number += 1 - if self.modified_run: - self.get_revision("Run").number += 1 - self.get_revision("RunInfo").number += 1 - if self.modified_test: - self.get_revision("Test").number += 1 - self.get_revision("TestInfo").number += 1 - self.session.commit() - self.modified_machine = self.modified_test = self.modified_run = False - - def rollback(self): - self.session.rollback() - self.modified_machine = self.modified_test = self.modified_run = False - -def importDataFromDict(db, data): - # FIXME: Validate data - machineData = data['Machine'] - runData = data['Run'] - testsData = data['Tests'] - - # Get the machine - # FIXME: Validate machine - machine,_ = db.getOrCreateMachine(machineData['Name'], - machineData['Info'].items()) - - # Accept 'Time' as an alias for 'Start Time' - if 'Start Time' not in runData and 'Time' in runData: - import time - t = time.strptime(runData['Time'], - "%a, %d %b %Y %H:%M:%S -0700 (PDT)") - runData['Start Time'] = time.strftime('%Y-%m-%d %H:%M', t) - - # Create the run. - run,inserted = db.getOrCreateRun(machine, - runData.get('Start Time',''), - runData.get('End Time',''), - runData.get('Info',{}).items()) - if not inserted: - return False,run - - # Batch load the set of tests instead of repeatedly querying to unique. - # - # FIXME: Add explicit config object. - test_info = {} - for id,k,v in db.session.query(TestInfo.test_id, TestInfo.key, - TestInfo.value): - info = test_info[id] = test_info.get(id,{}) - info[str(k)] = str(v) - - testMap = {} - for test_id,test_name in db.session.query(Test.id, Test.name): - info = test_info.get(test_id,{}).items() - info.sort() - testMap[(str(test_name),tuple(info))] = test_id - - # Create the tests up front, so we can resolve IDs. - test_ids = [] - late_ids = [] - for i,testData in enumerate(testsData): - name = str(testData['Name']) - info = [(str(k),str(v)) for k,v in testData['Info'].items()] - info.sort() - test_id = testMap.get((name,tuple(info))) - if test_id is None: - test,created = db.getOrCreateTest(testData['Name'],info) - late_ids.append((i,test)) - test_ids.append(test_id) - - # Flush now to resolve test and run ids. - # - # FIXME: Surely there is a cleaner way to handle this? - db.session.flush() - - if late_ids: - for i,t in late_ids: - test_ids[i] = t.id - - db.addSamples([(run.id, test_id, value) - for test_id,testData in zip(test_ids, testsData) - for value in testData['Data']]) - return True,run - -def test_sa_db(dbpath): - if not dbpath.startswith('mysql://'): - dbpath = 'sqlite:///' + dbpath - engine = sqlalchemy.create_engine(dbpath) - - Session = sqlalchemy.orm.sessionmaker(engine) - Session.configure(bind=engine) - - session = Session() - - m = session.query(Machine).first() - print m - print m.info - - r = session.query(Run).first() - print r - print r.info - - t = session.query(Test)[20] - print t - print t.info - - s = session.query(Sample)[20] - print s - - import time - start = time.time() - print - q = session.query(Sample) - q = q.filter(Sample.run_id == 994) - print - res = session.execute(q) - print res - N = 0 - for row in res: - if N == 1: - print row - N += 1 - print N, time.time() - start - print - - start = time.time() - N = 0 - for row in q: - if N == 1: - print row - N += 1 - print N, time.time() - start - -def main(): - global opts - from optparse import OptionParser - parser = OptionParser("usage: %prog dbpath") - opts,args = parser.parse_args() - - if len(args) != 1: - parser.error("incorrect number of argments") - - dbpath, = args - - # Test the SQLAlchemy layer. - test_sa_db(dbpath) - - # Test the PerfDB wrapper. - db = PerfDB(dbpath) - - print "Opened %r" % dbpath - - for m in db.machines(): - print m - for r in db.runs(m): - print ' run - id:%r, start:%r,'\ - ' # samples: %d.' % (r.id, r.start_time, - db.samples(run=r).count()) - -if __name__ == '__main__': - main() Modified: zorg/trunk/lnt/lnt/viewer/nightlytest.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/nightlytest.ptl?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/nightlytest.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/nightlytest.ptl Tue Apr 26 12:48:04 2011 @@ -17,7 +17,7 @@ from Util import safediv from NTUtil import * -from PerfDB import Machine, Run +from lnt.db.perfdb import Machine, Run class NightlyTestRunUI(NTStyleBrowser.TestRunUI): _q_exports = ["", "graphSingle"] Modified: zorg/trunk/lnt/lnt/viewer/root.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/root.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/root.ptl Tue Apr 26 12:48:04 2011 @@ -19,8 +19,9 @@ import lnt from lnt.db import perfdbsummary from lnt.util import json -from lnt.viewer import PerfDB, Util -from lnt.viewer.PerfDB import Machine, Run +from lnt.db import perfdb +from lnt.viewer import Util +from lnt.db.perfdb import Machine, Run class RootDirectory(Resolving, Directory): _q_exports = ["", "resources", "js", "machines", "runs", "tests", @@ -41,7 +42,7 @@ self.db_summary = None def getDB(self): - db = PerfDB.PerfDB(self.dbInfo.path) + db = perfdb.PerfDB(self.dbInfo.path) # Enable SQL logging with db_log. # Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/simple.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/simple.ptl Tue Apr 26 12:48:04 2011 @@ -22,7 +22,7 @@ from Util import safediv from NTUtil import * -from PerfDB import Machine, Run, RunInfo, Test +from lnt.db.perfdb import Machine, Run, RunInfo, Test class SimpleRunUI(Directory): _q_exports = ["", "graph", "report", "text_report"] Modified: zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/zview/zviewui.ptl Tue Apr 26 12:48:04 2011 @@ -7,7 +7,7 @@ from quixote.directory import Directory from quixote.html import htmltext -from lnt.viewer.PerfDB import Machine, Run, Sample, Test +from lnt.db.perfdb import Machine, Run, Sample, Test from lnt.viewer import NTUtil from sqlalchemy import func Modified: zorg/trunk/lnt/tests/DB/Create.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/DB/Create.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/tests/DB/Create.py (original) +++ zorg/trunk/lnt/tests/DB/Create.py Tue Apr 26 12:48:04 2011 @@ -3,7 +3,7 @@ # RUN: python %s %t.db import sys -from lnt.viewer.PerfDB import PerfDB, Run +from lnt.db.perfdb import PerfDB, Run # Check creation. Modified: zorg/trunk/lnt/tests/DB/Import.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/DB/Import.py?rev=130215&r1=130214&r2=130215&view=diff ============================================================================== --- zorg/trunk/lnt/tests/DB/Import.py (original) +++ zorg/trunk/lnt/tests/DB/Import.py Tue Apr 26 12:48:04 2011 @@ -22,7 +22,7 @@ # RUN: python %s %t.install/data/lnt.db import datetime, sys -from lnt.viewer.PerfDB import PerfDB, Run, Test +from lnt.db.perfdb import PerfDB, Run, Test db = PerfDB(sys.argv[1]) From daniel at zuster.org Tue Apr 26 12:48:09 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:09 -0000 Subject: [llvm-commits] [zorg] r130216 - in /zorg/trunk/lnt/lnt: db/perfdb.py server/ui/templates/simple_overview.html server/ui/templates/test.html server/ui/views.py Message-ID: <20110426174809.459962A6C12E@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:09 2011 New Revision: 130216 URL: http://llvm.org/viewvc/llvm-project?rev=130216&view=rev Log: LNT/Flask: Port simple overview. Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_overview.html Modified: zorg/trunk/lnt/lnt/db/perfdb.py zorg/trunk/lnt/lnt/server/ui/templates/test.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/db/perfdb.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdb.py?rev=130216&r1=130215&r2=130216&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/perfdb.py (original) +++ zorg/trunk/lnt/lnt/db/perfdb.py Tue Apr 26 12:48:09 2011 @@ -89,7 +89,7 @@ id = Column("ID", Integer, primary_key=True) run_id = Column("Run", Integer, ForeignKey('Run.ID')) - key = Column("Key", String(256)) + key = Column("Key", String(256), index=True) value = Column("Value", String(4096)) def __init__(self, run, key, value): Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_overview.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_overview.html?rev=130216&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_overview.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_overview.html Tue Apr 26 12:48:09 2011 @@ -0,0 +1,73 @@ +{% set db = request.get_db() %} + +{% extends "layout.html" %} +{% set components = [(tag, db_url_for("simple_overview", tag=tag))] %} +{% block title %}Overview{% endblock %} +{% block body %} + +{# Find recent runs. #} +

Submission Overview

+ + + + + +
+
+

Active Machines

+ + + + + + + + + +{# Show the most active machines. #} +{% for machine_name,r in active_machines|dictsort %} + + + + + +{% endfor %} + +
Latest SubmissionMachineResults
{{r.start_time}}{{ + r.machine.name}}:{{r.machine.number}} + View Results
+
+
+
+

Recent Submissions

+ + + + + + + + + + + +{# Show the active submissions. #} +{% for r,run_order in active_submissions %} +{% set m = r.machine %} + + + + + + + +{% endfor %} +
Run OrderStart TimeEnd TimeMachineResults
{{run_order}}{{r.start_time}}{{r.end_time}}{{ + m.name}}:{{m.number}} + View Results
+
+
+ +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/templates/test.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/test.html?rev=130216&r1=130215&r2=130216&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/test.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/test.html Tue Apr 26 12:48:09 2011 @@ -6,7 +6,6 @@ {% block title %}Test: {{test.name}}{% endblock %} {% block body %} - {# Show the test info dictionary. #}

Test Info

Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130216&r1=130215&r2=130216&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:09 2011 @@ -9,6 +9,8 @@ from flask import request from flask import url_for +from lnt.db import perfdb + frontend = flask.Module(__name__) ### @@ -94,3 +96,47 @@ @db_route("/tests//") def test(id): return render_template("test.html", id=id) + +### +# Simple LNT Schema Viewer + +from lnt.db.perfdb import Machine, Run, RunInfo +from lnt.db import perfdbsummary + + at db_route("/simple/") +def simple_overview(tag): + db = request.get_db() + + # Get the most recent runs in this tag, we just arbitrarily limit to looking + # at the last 100 submission. + recent_runs = db.query(Run).\ + join(RunInfo).\ + order_by(Run.start_time.desc()).\ + filter(RunInfo.key == "tag").\ + filter(RunInfo.value == tag).limit(100) + recent_runs = list(recent_runs) + + # Compute the active machine list. + active_machines = dict((run.machine.name, run) + for run in recent_runs[::-1]) + + # Compute the active submission list. + N = 30 + active_run_orders = dict( + db.query(RunInfo.run_id, RunInfo.value).\ + filter(RunInfo.key == "run_order").\ + filter(RunInfo.run_id.in_(s.id for s in recent_runs[:N]))) + active_submissions = [(r, active_run_orders.get(r.id)) + for r in recent_runs[:N]] + + return render_template("simple_overview.html", tag=tag, + active_machines=active_machines, + active_submissions=active_submissions) + + at db_route("/simple//machines/") +def simple_machine(tag, id): + raise NotImplementedError + + at db_route("/simple//") +def simple_run(tag, id): + raise NotImplementedError From daniel at zuster.org Tue Apr 26 12:48:13 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:13 -0000 Subject: [llvm-commits] [zorg] r130217 - in /zorg/trunk/lnt/lnt: db/perfdbsummary.py server/ui/static/popup.js server/ui/templates/simple_machine.html server/ui/views.py Message-ID: <20110426174813.4D9E42A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:13 2011 New Revision: 130217 URL: http://llvm.org/viewvc/llvm-project?rev=130217&view=rev Log: LNT/Flask: Port simple schema's machine page. Added: zorg/trunk/lnt/lnt/server/ui/static/popup.js zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=130217&r1=130216&r2=130217&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original) +++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Tue Apr 26 12:48:13 2011 @@ -198,6 +198,10 @@ def get_run_order(self, run_id): return self.order_by_run.get(run_id) + def get_runs_on_machine(self, machine_id): + return [k for k,v in self.machine_id_by_run.items() + if v == machine_id] + def get_run_ordered_index(self, run_id): try: return self.runs_in_order.index(run_id) Added: zorg/trunk/lnt/lnt/server/ui/static/popup.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/popup.js?rev=130217&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/static/popup.js (added) +++ zorg/trunk/lnt/lnt/server/ui/static/popup.js Tue Apr 26 12:48:13 2011 @@ -0,0 +1,155 @@ +function ShowPop(id) +{ + if (document.getElementById) + { + document.getElementById(id).style.visibility = " visible"; + } + else if (document.all) + { + document.all[id].style.visibility = " visible"; + } + else if (document.layers) + { + document.layers[id].style.visibility = " visible"; + } +} + + + + + + +function HidePop(id) +{ + if (document.getElementById) + { + document.getElementById(id).style.visibility = " hidden"; + } + /*else if (document.all) + { + document.all[id].style.visibility = " hidden"; + } + else if (document.layers) + { + document.layers[id].style.visibility = " hidden"; + }*/ +} + + + +function TogglePop(id) +{ + if (document.getElementById) + { + if(document.getElementById(id).style.visibility == "visible"){ + document.getElementById(id).style.visibility = "hidden"; + } + else{ + document.getElementById(id).style.visibility = "visible"; + } + } + else if (document.all) + { + if(document.all[id].style.visibility == "visible"){ + document.all[id].style.visibility = "hidden"; + } + else{ + document.all[id].style.visibility = "visible"; + } + } + else if (document.layers) + { + if(document.layers[id].style.visibility == "visible"){ + document.layers[id].style.visibility = "hidden"; + } + else{ + document.layers[id].style.visibility = "visible"; + } + } +} + + +function toggleLayer(whichLayer) +{ + if (document.getElementById) + { + // this is the way the standards work + var style2 = document.getElementById(whichLayer).style; + style2.display = style2.display? "":"none"; + var link = document.getElementById(whichLayer+"_").innerHTML; + if(link.indexOf("(+)") >= 0){ + document.getElementById(whichLayer+"_").innerHTML="(-)"+link.substring(3,link.length); + } + else{ + document.getElementById(whichLayer+"_").innerHTML="(+)"+link.substring(3,link.length); + } + }//end if + else if (document.all) + { + // this is the way old msie versions work + var style2 = document.all[whichLayer].style; + style2.display = style2.display? "":"none"; + var link = document.all[wwhichLayer+"_"].innerHTML; + if(link.indexOf("(+)") >= 0){ + document.all[whichLayer+"_"].innerHTML="(-)"+link.substring(3,link.length); + } + else{ + document.all[whichLayer+"_"].innerHTML="(+)"+link.substring(3,link.length); + } + } + else if (document.layers) + { + // this is the way nn4 works + var style2 = document.layers[whichLayer].style; + style2.display = style2.display? "":"none"; + var link = document.layers[whichLayer+"_"].innerHTML; + if(link.indexOf("(+)") >= 0){ + document.layers[whichLayer+"_"].innerHTML="(-)"+link.substring(3,link.length); + } + else{ + document.layers[whichLayer+"_"].innerHTML="(+)"+link.substring(3,link.length); + } + } +}//end function + +var checkflag="false"; +function check(field) { + if (checkflag == "false") { + for (i = 0; i < field.length; i++) { + field[i].checked = true; + } + checkflag = "true"; + return "Uncheck all"; + } + else { + for (i = 0; i < field.length; i++) { + if(field[i].type == 'checkbox'){ + field[i].checked = false; + } + } + checkflag = "false"; + return "Check all"; + } +} + +function show_hide_column(tableName, columns) { + // Let's be clear hear, I have no idea how to write portable + // JavaScript. This works in Safari, yo. + var event = window.event; + var cb = event.target; + + var style = cb.checked ? "table-cell" : "none"; + + var tbl = document.getElementById(tableName); + var rows = tbl.getElementsByTagName('tr'); + + for (var row = 0; row < rows.length; ++row) { + var cells = rows[row].getElementsByTagName('td'); + + if (cells.length == 0) + cells = rows[row].getElementsByTagName('th'); + + for (var i = 0; i < columns.length; ++i) + cells[columns[i]].style.display = style; + } +} Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html?rev=130217&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html Tue Apr 26 12:48:13 2011 @@ -0,0 +1,92 @@ +{% macro render_popup_begin(id, title, hidden, depth) -%} +

+({{ + "-" if hidden else "+" }}) {{title}} +

+{%- endmacro %} +{% macro render_popup_end() -%} +
+{%- endmacro %} + +{% set db = request.get_db() %} +{% set machine = db.getMachine(id) %} + +{% extends "layout.html" %} +{% set components = [(tag, db_url_for("simple_overview", tag=tag))] %} +{% block head %} + +{% endblock %} +{% block title %}Machine: {{machine.name}}:{{machine.number}}{% endblock %} +{% block body %} + +
+ + + + +
+ Homepage +

Relatives:

+
    + +{# List all machines with this name. #} +{% for m in db.machines(name=machine.name) %} +
  • {{ + m.name}}:{{m.number}}
  • +{% endfor %} +
+
+ + + + + + + + + +
Nickname {{machine.name}}
Machine ID {{machine.id}}
+ + +{{ render_popup_begin('machine_info', 'Machine Info', true, 1) }} + +{% for key,item in machine.info|dictsort %} + + + + +{% endfor %} +
{{key}} {{item.value}}
+{{ render_popup_end() }} + +

+ + + + + + + + + +{% for order,runs in associated_runs|sort|reverse %} +{% for run in runs %} + +{% if loop.first %} + +{% endif %} + + + + +{% endfor %} +{% endfor %} +
Run OrderStart TimeEnd Time 
{{order}}{{ run.start_time }}{{ run.end_time }}s + View Results
+ + +

+ +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130217&r1=130216&r2=130217&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:13 2011 @@ -133,9 +133,25 @@ active_machines=active_machines, active_submissions=active_submissions) - at db_route("/simple//machines/") + at db_route("/simple//machines/") def simple_machine(tag, id): - raise NotImplementedError + db = request.get_db() + + # Get the run summary. + run_summary = perfdbsummary.SimpleSuiteRunSummary.get_summary(db, tag) + + # Compute the list of associated runs, grouped by order. + from lnt.viewer import Util + grouped_runs = Util.multidict( + (run_summary.get_run_order(run_id), run_id) + for run_id in run_summary.get_runs_on_machine(id)) + + associated_runs = [(order, [db.getRun(run_id) + for run_id in runs]) + for order,runs in grouped_runs.items()] + + return render_template("simple_machine.html", tag=tag, id=id, + associated_runs=associated_runs) @db_route("/simple//") def simple_run(tag, id): From daniel at zuster.org Tue Apr 26 12:48:21 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:21 -0000 Subject: [llvm-commits] [zorg] r130219 - in /zorg/trunk/lnt/lnt: db/perfdbsummary.py server/ui/filters.py server/ui/static/View2D.js server/ui/static/sorttable.js server/ui/templates/simple_run.html server/ui/templates/simple_utils.html server/ui/views.py Message-ID: <20110426174821.4BC4F2A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:21 2011 New Revision: 130219 URL: http://llvm.org/viewvc/llvm-project?rev=130219&view=rev Log: LNT/Flask: Port simple schema's results page. Added: zorg/trunk/lnt/lnt/server/ui/static/View2D.js (with props) zorg/trunk/lnt/lnt/server/ui/static/sorttable.js (with props) zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py zorg/trunk/lnt/lnt/server/ui/filters.py zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=130219&r1=130218&r2=130219&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original) +++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Tue Apr 26 12:48:21 2011 @@ -91,6 +91,7 @@ self.test_id_map = test_id_map self.parameter_keys = parameter_keys self.parameter_sets = parameter_sets + self.parameter_maps = map(dict, parameter_sets) self.test_info_map = dict([(v,k) for k,v in test_id_map.items()]) def is_up_to_date(self, db): Modified: zorg/trunk/lnt/lnt/server/ui/filters.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/filters.py?rev=130219&r1=130218&r2=130219&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/filters.py (original) +++ zorg/trunk/lnt/lnt/server/ui/filters.py Tue Apr 26 12:48:21 2011 @@ -1,10 +1,15 @@ import datetime +from lnt.viewer.Util import PctCell def filter_asusertime(time): # FIXME: Support alternate timezones? ts = datetime.datetime.fromtimestamp(time) return ts.strftime('%Y-%m-%d %H:%M:%S %Z PST') +def filter_aspctcell(value, *args, **kwargs): + cell = PctCell(value, *args, **kwargs) + return cell.render() + def register(app): for name,object in globals().items(): if name.startswith('filter_'): Added: zorg/trunk/lnt/lnt/server/ui/static/View2D.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/View2D.js?rev=130219&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/static/View2D.js (added) +++ zorg/trunk/lnt/lnt/server/ui/static/View2D.js Tue Apr 26 12:48:21 2011 @@ -0,0 +1 @@ +link ../../../viewer/js/View2D.js \ No newline at end of file Propchange: zorg/trunk/lnt/lnt/server/ui/static/View2D.js ------------------------------------------------------------------------------ svn:special = * Added: zorg/trunk/lnt/lnt/server/ui/static/sorttable.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/static/sorttable.js?rev=130219&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/static/sorttable.js (added) +++ zorg/trunk/lnt/lnt/server/ui/static/sorttable.js Tue Apr 26 12:48:21 2011 @@ -0,0 +1 @@ +link ../../../viewer/resources/sorttable.js \ No newline at end of file Propchange: zorg/trunk/lnt/lnt/server/ui/static/sorttable.js ------------------------------------------------------------------------------ svn:special = * Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html?rev=130219&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Tue Apr 26 12:48:21 2011 @@ -0,0 +1,208 @@ +{% import "simple_utils.html" as simple_utils %} +{% import "utils.html" as utils %} + +{% set db = request.get_db() %} +{% set run = db.getRun(id) %} +{% set machine = run.machine %} + +{% extends "layout.html" %} +{% set components = [(tag, db_url_for("simple_overview", tag=tag)), + ('machine', db_url_for("simple_machine", + tag=tag, id=machine.id))] %} +{% block head %} + + + +{% endblock %} +{ +{% block title %}Run Results{% endblock %} + +{# Add JS to run the init_report function, if embedded. #} +{% block onload %}init(){% endblock %} +{% block javascript %} +function init() { + if (init_report) { + init_report(); + } +} +{% endblock %} + +{% block body %} + +{% macro get_cell_value(cr) %} +{% set test_status = cr.get_test_status() %} +{% set value_status = cr.get_value_status() %} +{% set run_cell_value = "-" if cr.current is none else "%.4f" % cr.current %} + +{% set cell_color = none %} +{% if test_status == runinfo.REGRESSED %} + {% set cell_color = (233,128,128) %} +{% elif test_status == runinfo.IMPROVED %} + {% set cell_color = (143,223,95) %} +{% elif test_status == runinfo.UNCHANGED_FAIL %} + {% set cell_color = (255,195,67) %} +{% endif %} + +{% if cell_color %} + {{ + run_cell_value}} +{% else %} + {{run_cell_value}} +{% endif %} + +{% if (options.show_all or + value_status == runinfo.REGRESSED or + value_status == runinfo.IMPROVED) %} + {{ cr.pct_delta|aspctcell|safe }} +{% else %} + - +{% endif %} + +{% if options.show_delta %} + {{ "-" if cr.delta is none else "%.4f" % cr.delta }} +{% endif %} +{% if options.show_stddev %} + {{ "-" if cr.stddev is none else "%.4f" % cr.stddev }} +{% endif %} +{% if options.show_mad %} + {{ "-" if cr.MAD is none else "%.4f" % cr.MAD }} +{% endif %} +{% if options.show_all_samples %} + [ + {%- for v in cr.get_samples() -%} + {{ ", " if not loop.first }} + {{ "%.4f" % v }} + {%- endfor -%}] +{% endif %} + +{% if options.show_sample_counts %} + {{cr.get_samples()|length}} +{% endif %} + +{% endmacro %} + +{% call simple_utils.simple_run_page(machine, run, compare_to, + neighboring_runs) %} + +{{ utils.render_popup_begin('view_options', 'View Options', true) }} +
+Show Delta: +
+ +Show Standard Deviation: +
+ +Show Median Absolute Deviation: +
+ +Show All Values: +
+ +Show All Samples: +
+ +Show Sample Counts: +
+ +Number of Comparison Runs: +
+ +Show Report Graphs: +
+ + +
+{{ utils.render_popup_end() }} + +{{ utils.render_popup_begin('text_report', 'Report (Text)', true) }} +
{{ text_report }}
+{{ utils.render_popup_end() }} + +{{ utils.render_popup_begin('html_report', 'Report (HTML)', false) }} +{{html_report|safe}} +{{ utils.render_popup_end() }} + +

Parameter Sets

+ + + + + + +{% for key in ts_summary.parameter_keys %} + +{% endfor %} + + +{% for pmap in ts_summary.parameter_maps %} + + + {% for key in ts_summary.parameter_keys %} + {% set item = pmap.get(key) %} + + {% endfor %} + +{% endfor %} +
NameParameters
{{key}}
P{{loop.index0}}{{ "-" if item is none else item }}
+ +

Tests

+ +{% set pset_cols = ( + 2 + options.show_delta + options.show_stddev + options.show_mad + + options.show_all_samples + options.show_sample_counts) %} + +
+ + + + + +{% for key in ts_summary.parameter_sets %} + +{% endfor %} + + + + +{% for key in ts_summary.parameter_sets %} + +{% endfor %} + + {% if options.show_delta %} + + {% endif %} + {% if options.show_stddev %} + + {% endif %} + {% if options.show_mad %} + + {% endif %} + {% if options.show_all_samples %} + + {% endif %} + {% if options.show_sample_counts %} + + {% endif %} + + + +{% for name in test_names|sort %} + + + + {% for pset in ts_summary.parameter_sets %} + {% set cr = simple_run_info.get_run_comparison_result( + run, run_status_kind, compare_to, compare_to_status_kind, + name, pset, comparison_window) %} + {{ get_cell_value(cr) }} + {% endfor %} + +{% endfor %} +
NameP{{loop.index0}}
%ΔσMADSamplesN
{{name}}
+ +
+ +{% endcall %} + +{% endblock %} Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html?rev=130219&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Tue Apr 26 12:48:21 2011 @@ -0,0 +1,85 @@ +{% import "utils.html" as utils %} + +{% macro simple_run_page(machine, run, compare_to, + neighboring_runs) %} + +
+ + + + + + + + + +{% if compare_to %} + + + + +{% endif %} +
Machine:{{machine.name}}:{{machine.number}}
Run:{{run.start_time}} ({{ + run.info['run_order'].value}})
Compare To:{{compare_to.start_time}} ({{ + compare_to.info['run_order'].value}})
+
+

+ + + + + + +
+ Homepage +

Machine:

+ {{ + machine.name}}:{{machine.number}} +

Runs:

+
    + +{# Show a small number of neighboring runs. #} +{% for r in neighboring_runs %} +
  • {{ "

    "|safe if r.id == run.id }} + {{ + r.start_time}}{{ + "

    "|safe if r.id == run.id }} +{% endfor %} +
+
+ + + + + + + + + +
Nickname {{machine.name}}
Machine ID {{machine.id}}
+{{ utils.render_popup_begin('machine_info', 'Machine Info', true) }} + +{% for key,item in machine.info|dictsort(true) %} + + + + +{% endfor %} +
{{key}} {{item.value}}
+{{ utils.render_popup_end() }} + +{{ utils.render_popup_begin('run_info', 'Run Info', true) }} + +{% for key,item in run.info|dictsort(true) %} + + + + +{% endfor %} +
{{key}} {{item.value}}
+{{ utils.render_popup_end() }} +{{ caller() }} + +
+ +{% endmacro %} Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130219&r1=130218&r2=130219&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:21 2011 @@ -101,7 +101,9 @@ # Simple LNT Schema Viewer from lnt.db.perfdb import Machine, Run, RunInfo +from lnt.db import runinfo from lnt.db import perfdbsummary +from lnt.util import NTEmailReport @db_route("/simple/") def simple_overview(tag): @@ -155,4 +157,93 @@ @db_route("/simple//") def simple_run(tag, id): - raise NotImplementedError + db = request.get_db() + + run = db.getRun(id) + + # Get the run summary. + run_summary = perfdbsummary.SimpleSuiteRunSummary.get_summary(db, tag) + ts_summary = perfdbsummary.get_simple_suite_summary(db, tag) + sri = runinfo.SimpleRunInfo(db, ts_summary) + + # Get the comparison run. + compare_to = None + compare_to_id = request.args.get('compare') + if compare_to_id is not None: + try: + compare_to = db.getRun(int(compare_to_id)) + except: + pass + if compare_to is None: + prev_id = run_summary.get_previous_run_on_machine(run.id) + if prev_id is not None: + compare_to = db.getRun(prev_id) + + # Get the neighboring runs. + cur_id = run.id + for i in range(3): + next_id = run_summary.get_next_run_on_machine(cur_id) + if not next_id: + break + cur_id = next_id + neighboring_runs = [] + for i in range(6): + neighboring_runs.append(db.getRun(cur_id)) + cur_id = run_summary.get_previous_run_on_machine(cur_id) + if cur_id is None: + break + + # Parse the view options. + options = {} + options['show_graphs'] = bool(request.args.get('show_graphs')) + options['show_delta'] = bool(request.args.get('show_delta')) + options['show_stddev'] = bool(request.args.get('show_stddev')) + options['show_mad'] = bool(request.args.get('show_mad')) + options['show_all'] = bool(request.args.get('show_all')) + options['show_all_samples'] = bool(request.args.get('show_all_samples')) + options['show_sample_counts'] = bool(request.args.get('show_sample_counts')) + options['show_graphs'] = show_graphs = bool(request.args.get('show_graphs')) + try: + num_comparison_runs = int(request.args.get('num_comparison_runs')) + except: + num_comparison_runs = 10 + options['num_comparison_runs'] = num_comparison_runs + + _, text_report, html_report = NTEmailReport.getSimpleReport( + None, db, run, str("%s/db_%s/") % (current_app.old_config.zorgURL, + g.db_name), + True, True, only_html_body = True, show_graphs = show_graphs, + num_comparison_runs = num_comparison_runs) + + # Get the test status style used in each run. + run_status_kind = run_summary.get_run_status_kind(db, run.id) + if compare_to: + compare_to_status_kind = run_summary.get_run_status_kind( + db, compare_to.id) + else: + compare_to_status_kind = None + + # Get the list of tests we are interest in. + interesting_runs = [run.id] + if compare_to: + interesting_runs.append(compare_to.id) + test_names = ts_summary.get_test_names_in_runs(db, interesting_runs) + + # Gather the runs to use for statistical data, if enabled. + cur_id = run.id + comparison_window = [] + for i in range(num_comparison_runs): + cur_id = run_summary.get_previous_run_on_machine(cur_id) + if not cur_id: + break + comparison_window.append(cur_id) + + return render_template("simple_run.html", tag=tag, id=id, + compare_to=compare_to, + compare_to_status_kind=compare_to_status_kind, + run_summary=run_summary, ts_summary=ts_summary, + simple_run_info=sri, test_names=test_names, + neighboring_runs=neighboring_runs, + text_report=text_report, html_report=html_report, + options=options, runinfo=runinfo, + comparison_window=comparison_window) From daniel at zuster.org Tue Apr 26 12:48:16 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:16 -0000 Subject: [llvm-commits] [zorg] r130218 - in /zorg/trunk/lnt/lnt/server/ui/templates: simple_machine.html utils.html Message-ID: <20110426174816.8DD882A6C12E@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:16 2011 New Revision: 130218 URL: http://llvm.org/viewvc/llvm-project?rev=130218&view=rev Log: LNT/Flask: Move macros out to a separate template. Added: zorg/trunk/lnt/lnt/server/ui/templates/utils.html Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html?rev=130218&r1=130217&r2=130218&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_machine.html Tue Apr 26 12:48:16 2011 @@ -1,14 +1,4 @@ -{% macro render_popup_begin(id, title, hidden, depth) -%} -

-({{ - "-" if hidden else "+" }}) {{title}} -

-{%- endmacro %} -{% macro render_popup_end() -%} -
-{%- endmacro %} +{% import "utils.html" as utils %} {% set db = request.get_db() %} {% set machine = db.getMachine(id) %} @@ -48,7 +38,7 @@ -{{ render_popup_begin('machine_info', 'Machine Info', true, 1) }} +{{ utils.render_popup_begin('machine_info', 'Machine Info', true, 1) }} {% for key,item in machine.info|dictsort %} @@ -57,7 +47,7 @@ {% endfor %}
-{{ render_popup_end() }} +{{ utils.render_popup_end() }}

Added: zorg/trunk/lnt/lnt/server/ui/templates/utils.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/utils.html?rev=130218&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/utils.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/utils.html Tue Apr 26 12:48:16 2011 @@ -0,0 +1,12 @@ +{% macro render_popup_begin(id, title, hidden, depth=1) -%} +

+({{ + "-" if hidden else "+" }}) {{title}} +

+{%- endmacro %} + +{% macro render_popup_end() -%} +
+{%- endmacro %} From daniel at zuster.org Tue Apr 26 12:48:23 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:23 -0000 Subject: [llvm-commits] [zorg] r130220 - /zorg/trunk/lnt/lnt/server/ui/views.py Message-ID: <20110426174823.DE1112A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:23 2011 New Revision: 130220 URL: http://llvm.org/viewvc/llvm-project?rev=130220&view=rev Log: LNT/Flask: Port simple schema's report and text_report pages. Modified: zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130220&r1=130219&r2=130220&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:23 2011 @@ -4,6 +4,7 @@ from flask import abort from flask import current_app from flask import g +from flask import make_response from flask import redirect from flask import render_template from flask import request @@ -155,16 +156,13 @@ return render_template("simple_machine.html", tag=tag, id=id, associated_runs=associated_runs) - at db_route("/simple//") -def simple_run(tag, id): +def get_simple_run_info(tag, id): db = request.get_db() run = db.getRun(id) # Get the run summary. run_summary = perfdbsummary.SimpleSuiteRunSummary.get_summary(db, tag) - ts_summary = perfdbsummary.get_simple_suite_summary(db, tag) - sri = runinfo.SimpleRunInfo(db, ts_summary) # Get the comparison run. compare_to = None @@ -179,6 +177,41 @@ if prev_id is not None: compare_to = db.getRun(prev_id) + return db, run, run_summary, compare_to + + at db_route("/simple///report") +def simple_report(tag, id): + db, run, run_summary, compare_to = get_simple_run_info(tag, id) + + show_graphs = bool(request.args.get('show_graphs')) + _, _, html_report = NTEmailReport.getSimpleReport( + None, db, run, str("%s/db_%s/") % (current_app.old_config.zorgURL, + g.db_name), + True, True, show_graphs = show_graphs) + + return make_response(html_report) + + at db_route("/simple///text_report") +def simple_text_report(tag, id): + db, run, run_summary, compare_to = get_simple_run_info(tag, id) + + _, text_report, _ = NTEmailReport.getSimpleReport( + None, db, run, str("%s/db_%s/") % (current_app.old_config.zorgURL, + g.db_name), + True, True) + + response = make_response(text_report) + response.mimetype = "text/plain" + return response + + at db_route("/simple//") +def simple_run(tag, id): + db, run, run_summary, compare_to = get_simple_run_info(tag, id) + + # Get additional summaries. + ts_summary = perfdbsummary.get_simple_suite_summary(db, tag) + sri = runinfo.SimpleRunInfo(db, ts_summary) + # Get the neighboring runs. cur_id = run.id for i in range(3): @@ -195,7 +228,6 @@ # Parse the view options. options = {} - options['show_graphs'] = bool(request.args.get('show_graphs')) options['show_delta'] = bool(request.args.get('show_delta')) options['show_stddev'] = bool(request.args.get('show_stddev')) options['show_mad'] = bool(request.args.get('show_mad')) From daniel at zuster.org Tue Apr 26 12:48:26 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:26 -0000 Subject: [llvm-commits] [zorg] r130221 - in /zorg/trunk/lnt/lnt/server/ui/templates: simple_run.html simple_utils.html Message-ID: <20110426174827.02EFC2A6C12E@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:26 2011 New Revision: 130221 URL: http://llvm.org/viewvc/llvm-project?rev=130221&view=rev Log: LNT/Flask: Fix a few refactos. Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html?rev=130221&r1=130220&r2=130221&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Tue Apr 26 12:48:26 2011 @@ -81,7 +81,7 @@ {% endmacro %} -{% call simple_utils.simple_run_page(machine, run, compare_to, +{% call simple_utils.simple_run_page(tag, machine, run, compare_to, neighboring_runs) %} {{ utils.render_popup_begin('view_options', 'View Options', true) }} Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html?rev=130221&r1=130220&r2=130221&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_utils.html Tue Apr 26 12:48:26 2011 @@ -1,6 +1,6 @@ {% import "utils.html" as utils %} -{% macro simple_run_page(machine, run, compare_to, +{% macro simple_run_page(tag, machine, run, compare_to, neighboring_runs) %}
@@ -38,7 +38,7 @@ {# Show a small number of neighboring runs. #} {% for r in neighboring_runs %}
  • {{ "

    "|safe if r.id == run.id }} - {{ + {{ r.start_time}}{{ "

    "|safe if r.id == run.id }} {% endfor %} From daniel at zuster.org Tue Apr 26 12:48:30 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:30 -0000 Subject: [llvm-commits] [zorg] r130222 - in /zorg/trunk/lnt/lnt: __init__.py server/ui/templates/simple_graph.html server/ui/templates/simple_run.html server/ui/views.py Message-ID: <20110426174830.66CD02A6C12F@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:30 2011 New Revision: 130222 URL: http://llvm.org/viewvc/llvm-project?rev=130222&view=rev Log: LNT/Flask: Port simple graph page. Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_graph.html Modified: zorg/trunk/lnt/lnt/__init__.py zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/__init__.py?rev=130222&r1=130221&r2=130222&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/__init__.py (original) +++ zorg/trunk/lnt/lnt/__init__.py Tue Apr 26 12:48:30 2011 @@ -1,6 +1,6 @@ __author__ = 'Daniel Dunbar' __email__ = 'daniel at zuster.org' -__versioninfo__ = (0, 3, 0) +__versioninfo__ = (0, 3, 1) __version__ = '.'.join(map(str, __versioninfo__)) + 'dev' __all__ = [] Added: zorg/trunk/lnt/lnt/server/ui/templates/simple_graph.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_graph.html?rev=130222&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_graph.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_graph.html Tue Apr 26 12:48:30 2011 @@ -0,0 +1,147 @@ +{% import "simple_utils.html" as simple_utils %} +{% import "utils.html" as utils %} + +{% set db = request.get_db() %} +{% set run = db.getRun(id) %} +{% set machine = run.machine %} + +{% extends "layout.html" %} +{% set components = [(tag, db_url_for("simple_overview", tag=tag)), + ('machine', db_url_for("simple_machine", + tag=tag, id=machine.id)), + ('run', db_url_for("simple_run", + tag=tag, id=machine.id))] %} +{% block head %} + + + +{% endblock %} + +{% block title %}Run Results{% endblock %} + +{# Add JS to initialize the graph. #} +{% block onload %}init(){% endblock %} +{% block javascript %} +function init() { + graph = new Graph2D("graph"); + graph.clearColor = [1, 1, 1]; + + {{ graph_plots }} + + graph.xAxis.format = graph.xAxis.formats.normal; + graph.draw(); +} +{% endblock %} + +{% block body %} + +{% call simple_utils.simple_run_page(tag, machine, run, compare_to, + neighboring_runs) %} + +{{ utils.render_popup_begin('view_options', 'View Options', true) }} +
    +Show Median Absolute Deviation: +
    + +Show Standard Deviation: +
    + +Show Linear Regression: +
    + +{# Add all the hidden fields. #} +{% for name,value in request.args.items() %} + {% if name.startswith('test.') or name.startswith('pset.') %} +
    + {% endif %} +{% endfor %} + + + +{{ utils.render_popup_end() }} + +

    Graph

    +
  • + + + + +
    + + + + +{% for name,col in legend %} + + +{% endfor %} +
    Test
     {{name}}
    +
    + +Shift-Left Mouse: Pan
    +Alt/Meta-Left Mouse: Zoom
    +Wheel: Zoom (Shift Slows)
    +
    +
    +

    +Plots: {{ num_plots }}
    +Num Points: {{ num_points }}
    + +

    Deltas

    +{% for deltas in plot_deltas %} + {% set (name,col) = legend[loop.index0] %} +

    {{name}}

    + + + + + + + + + + + + + + + + + + + + + + + +{% for (pct,(r0,t0,mad0,med0),(r1,t1,mad1,med1)) in deltas %} + + + + {{pct|aspctcell(delta=true)|safe}} + + + + + + +{% endfor %} + +
    Revision ValueMADMed - Min
    CurrentPreviousDelta (%)CurrentPrevious# Revs CurrentPreviousCurrentPrevious
    {{r1}}{{r0}}{{ "%.4f" % t1 }}{{ "%.4f" % t0}}{{ r1 - r0 }} {{ "%.4f" % mad1 }}{{ "%.4f" % mad0 }}{{ "%.4f" % (med1-t1) }}{{ "%.4f" % (med0-t0) }}
    +{% endfor %} + +

    Revisions to Sample

    +{% for rev in new_sample_list %} + {{ rev }} +{% endfor %} +

    +

    Revisions to Resample

    +{% for rev in resample_list|sort %} + {{ rev }} +{% endfor %} +

    + +{% endcall %} + +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html?rev=130222&r1=130221&r2=130222&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Tue Apr 26 12:48:30 2011 @@ -14,7 +14,7 @@ {% endblock %} -{ + {% block title %}Run Results{% endblock %} {# Add JS to run the init_report function, if embedded. #} @@ -151,7 +151,8 @@ 2 + options.show_delta + options.show_stddev + options.show_mad + options.show_all_samples + options.show_sample_counts) %} -

    + Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130222&r1=130221&r2=130222&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:30 2011 @@ -106,7 +106,7 @@ from lnt.db import perfdbsummary from lnt.util import NTEmailReport - at db_route("/simple/") + at db_route("/simple//") def simple_overview(tag): db = request.get_db() @@ -204,7 +204,7 @@ response.mimetype = "text/plain" return response - at db_route("/simple//") + at db_route("/simple//") def simple_run(tag, id): db, run, run_summary, compare_to = get_simple_run_info(tag, id) @@ -279,3 +279,111 @@ text_report=text_report, html_report=html_report, options=options, runinfo=runinfo, comparison_window=comparison_window) + + at db_route("/simple///graph") +def simple_graph(tag, id): + from lnt.viewer import GraphUtil + from lnt.viewer import Util + + db, run, run_summary, compare_to = get_simple_run_info(tag, id) + + # Get additional summaries. + ts_summary = perfdbsummary.get_simple_suite_summary(db, tag) + + # Get the neighboring runs. + cur_id = run.id + for i in range(3): + next_id = run_summary.get_next_run_on_machine(cur_id) + if not next_id: + break + cur_id = next_id + neighboring_runs = [] + for i in range(6): + neighboring_runs.append(db.getRun(cur_id)) + cur_id = run_summary.get_previous_run_on_machine(cur_id) + if cur_id is None: + break + + # Parse the view options. + options = {} + show_mad = bool(request.args.get('show_mad', True)) + show_stddev = bool(request.args.get('show_stddev')) + show_linear_regression = bool( + request.args.get('show_linear_regression', True)) + + # Load the graph parameters. + graph_tests = [] + graph_psets = [] + for name,value in request.args.items(): + if name.startswith(str('test.')): + graph_tests.append(name[5:]) + elif name.startswith(str('pset.')): + graph_psets.append(ts_summary.parameter_sets[int(name[5:])]) + + # Get the test ids we want data for. + test_ids = [ts_summary.test_id_map[(name,pset)] + for name in graph_tests + for pset in graph_psets] + + # Build the graph data + pset_id_map = dict([(pset,i) + for i,pset in enumerate(ts_summary.parameter_sets)]) + legend = [] + num_points = 0 + plot_points = [] + plots = "" + plots_iter = GraphUtil.get_test_plots( + db, run.machine, test_ids, run_summary, ts_summary, + show_mad_error = show_mad, show_stddev = show_stddev, + show_linear_regression = show_linear_regression, show_points = True) + for test_id, plot_js, col, points, ext_points in plots_iter: + test = db.getTest(test_id) + name = test.name + pset = test.get_parameter_set() + + num_points += len(points) + legend.append(("%s : P%d" % (name, pset_id_map[pset]), tuple(col))) + plots += plot_js + plot_points.append(ext_points) + + # Build the sample info. + resample_list = set() + new_sample_list = [] + plot_deltas = [] + for (name,col),points in zip(legend,plot_points): + points.sort() + deltas = [(Util.safediv(p1[1], p0[1]), p0, p1) + for p0,p1 in Util.pairs(points)] + deltas.sort() + deltas.reverse() + plot_deltas.append(deltas[:20]) + for (pct,(r0,t0,mad0,med0),(r1,t1,mad1,med1)) in deltas[:20]: + # Find the best next revision to sample, unless we have + # sampled to the limit. To conserve resources, we try to + # align to the largest "nice" revision boundary that we can, + # so that we tend to sample the same revisions, even as we + # drill down. + assert r0 < r1 and r0 != r1 + if r0 + 1 != r1: + for align in [scale * boundary + for scale in (100000,10000,1000,100,10,1) + for boundary in (5, 1)]: + r = r0 + 1 + (r1 - r0)//2 + r = (r // align) * align + if r0 < r < r1: + new_sample_list.append(r) + break + + resample_list.add(r0) + resample_list.add(r1) + + return render_template("simple_graph.html", tag=tag, id=id, + compare_to=compare_to, + neighboring_runs=neighboring_runs, + run_summary=run_summary, ts_summary=ts_summary, + graph_plots=plots, legend=legend, + num_plots=len(test_ids), num_points=num_points, + new_sample_list=new_sample_list, + resample_list=resample_list, + plot_deltas=plot_deltas) + From daniel at zuster.org Tue Apr 26 12:48:33 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 26 Apr 2011 17:48:33 -0000 Subject: [llvm-commits] [zorg] r130223 - in /zorg/trunk/lnt/lnt: server/ui/templates/submit_run.html server/ui/views.py util/ImportData.py Message-ID: <20110426174834.076732A6C12D@llvm.org> Author: ddunbar Date: Tue Apr 26 12:48:33 2011 New Revision: 130223 URL: http://llvm.org/viewvc/llvm-project?rev=130223&view=rev Log: LNT/Flask: Port submit page. Added: zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html Modified: zorg/trunk/lnt/lnt/server/ui/views.py zorg/trunk/lnt/lnt/util/ImportData.py Added: zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html?rev=130223&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html (added) +++ zorg/trunk/lnt/lnt/server/ui/templates/submit_run.html Tue Apr 26 12:48:33 2011 @@ -0,0 +1,26 @@ +{% extends "layout.html" %} +{% set components = [] %} +{% block title %}Submit Run{% endblock %} +{% block body %} + +{% if error %} +

    {{ error }}

    +{% endif %} + + +Input File (plist):
    +
    + +

    Input Data (plist):
    + + +

    Commit*:
    +
    + +

    + + +{% endblock %} Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130223&r1=130222&r2=130223&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Tue Apr 26 12:48:33 2011 @@ -1,4 +1,6 @@ import os +import tempfile +import time import flask from flask import abort @@ -79,9 +81,48 @@ def browse(): return render_template("browse.html") - at db_route('/submitRun') + at db_route('/submitRun', methods=('GET', 'POST')) def submit_run(): - raise NotImplementedError + from lnt.util import ImportData + + if request.method == 'POST': + input_file = request.files.get('file') + input_data = request.form.get('input_data') + commit = int(request.form.get('commit', 0)) + + if not input_file.content_length and not input_data: + return render_template( + "submit_run.html", error="must provide input file or data") + if input_file.content_length and input_data: + return render_template( + "submit_run.html", error="cannot provide input file *and* data") + + if input_file.content_length: + data_value = input_file.read() + else: + data_value = input_data + + # Stash a copy of the raw submission. + prefix = time.strftime("data-%Y-%m-%d_%H-%M-%S") + fd,path = tempfile.mkstemp(prefix=prefix, + suffix='.plist', + dir=current_app.old_config.tempDir) + os.write(fd, data_value) + os.close(fd) + + # Get a DB connection. + db = request.get_db() + + # Import the data. + # + # FIXME: Gracefully handle formats failures and DOS attempts. We + # should at least reject overly large inputs. + result = ImportData.import_and_report( + current_app.old_config, g.db_name, db, path, '', commit) + + return flask.jsonify(data = result) + + return render_template("submit_run.html") ### # Generic Database Views Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=130223&r1=130222&r2=130223&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Tue Apr 26 12:48:33 2011 @@ -60,7 +60,7 @@ importStartTime = time.time() try: - success,run = perfdb.importDataFromDict(db, data) + success,run = lnt.db.perfdb.importDataFromDict(db, data) except KeyboardInterrupt: raise except: From dpatel at apple.com Tue Apr 26 13:24:39 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 26 Apr 2011 18:24:39 -0000 Subject: [llvm-commits] [llvm] r130225 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DIBuilder.cpp Message-ID: <20110426182439.3A8D72A6C12D@llvm.org> Author: dpatel Date: Tue Apr 26 13:24:39 2011 New Revision: 130225 URL: http://llvm.org/viewvc/llvm-project?rev=130225&view=rev Log: Fix an off by one error while accessing complex address element of a DIVariable. This worked untill now because stars are aligned (i.e. num of complex address elments are always 0 or 2+ and when it is 2+ at least two elements are access together) Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DIBuilder.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=130225&r1=130224&r2=130225&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Apr 26 13:24:39 2011 @@ -622,7 +622,9 @@ unsigned getNumAddrElements() const; uint64_t getAddrElement(unsigned Idx) const { - return getUInt64Field(Idx+6); + if (getVersion() <= llvm::LLVMDebugVersion8) + return getUInt64Field(Idx+6); + return getUInt64Field(Idx+7); } /// isBlockByrefVariable - Return true if the variable was declared as Modified: llvm/trunk/lib/Analysis/DIBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DIBuilder.cpp?rev=130225&r1=130224&r2=130225&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DIBuilder.cpp (original) +++ llvm/trunk/lib/Analysis/DIBuilder.cpp Tue Apr 26 13:24:39 2011 @@ -656,6 +656,7 @@ Elts.push_back(F); Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24)))); Elts.push_back(Ty); + Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext))); Elts.append(Addr.begin(), Addr.end()); return DIVariable(MDNode::get(VMContext, Elts)); From bob.wilson at apple.com Tue Apr 26 13:35:24 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 26 Apr 2011 11:35:24 -0700 Subject: [llvm-commits] [llvm] r130126 - in /llvm/trunk/test: Analysis/RegionInfo/next.ll CodeGen/ARM/crash-greedy.ll CodeGen/PTX/ld.ll CodeGen/Thumb2/bfi.ll CodeGen/Thumb2/thumb2-lsr3.ll CodeGen/X86/fast-isel-x86.ll CodeGen/X86/fp-trunc.ll CodeGen/X86/lsr-interesting-step.ll In-Reply-To: <20110425101201.DCB352A6C12D@llvm.org> References: <20110425101201.DCB352A6C12D@llvm.org> Message-ID: Benjamin, the fast-isel-x86 test is failing on the llvm-gcc-native-mingw32-win7 tester: http://google1.osuosl.org:8011/builders/llvm-gcc-native-mingw32-win7/builds/1736 Can you please fix it somehow? On Apr 25, 2011, at 3:12 AM, Benjamin Kramer wrote: > Author: d0k > Date: Mon Apr 25 05:12:01 2011 > New Revision: 130126 > > URL: http://llvm.org/viewvc/llvm-project?rev=130126&view=rev > Log: > Make tests more useful. > > lit needs a linter ... > > Modified: > llvm/trunk/test/Analysis/RegionInfo/next.ll > llvm/trunk/test/CodeGen/ARM/crash-greedy.ll > llvm/trunk/test/CodeGen/PTX/ld.ll > llvm/trunk/test/CodeGen/Thumb2/bfi.ll > llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll > llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll > llvm/trunk/test/CodeGen/X86/fp-trunc.ll > llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll > > Modified: llvm/trunk/test/Analysis/RegionInfo/next.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/RegionInfo/next.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/Analysis/RegionInfo/next.ll (original) > +++ llvm/trunk/test/Analysis/RegionInfo/next.ll Mon Apr 25 05:12:01 2011 > @@ -32,8 +32,8 @@ > ; CHECK-NOT: => > ; CHECK: [0] entry => > ; CHECK-NEXT: [1] __label_002001.outer => __label_000020 > -; CHECK-NEXT; [2] bb197 => bb229 > -; CHECK-NEXT; [3] bb224 => bb229 > +; CHECK-NEXT: [2] bb197 => bb229 > +; CHECK-NEXT: [3] bb224 => bb229 > > ; STAT: 4 region - The # of regions > ; STAT: 1 region - The # of simple regions > > Modified: llvm/trunk/test/CodeGen/ARM/crash-greedy.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/crash-greedy.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/crash-greedy.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/crash-greedy.ll Mon Apr 25 05:12:01 2011 > @@ -6,7 +6,7 @@ > > declare double @exp(double) > > -; CHECK remat_subreg > +; CHECK: remat_subreg > define void @remat_subreg(float* nocapture %x, i32* %y, i32 %n, i32 %z, float %c, float %lambda, float* nocapture %ret_f, float* nocapture %ret_df) nounwind { > entry: > %conv16 = fpext float %lambda to double > > Modified: llvm/trunk/test/CodeGen/PTX/ld.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/ld.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/PTX/ld.ll (original) > +++ llvm/trunk/test/CodeGen/PTX/ld.ll Mon Apr 25 05:12:01 2011 > @@ -64,7 +64,7 @@ > define ptx_device i16 @t1_u16(i16* %p) { > entry: > ;CHECK: ld.global.u16 rh0, [r1]; > -;CHECK-NEXT; ret; > +;CHECK-NEXT: ret; > %x = load i16* %p > ret i16 %x > } > > Modified: llvm/trunk/test/CodeGen/Thumb2/bfi.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/bfi.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/bfi.ll (original) > +++ llvm/trunk/test/CodeGen/Thumb2/bfi.ll Mon Apr 25 05:12:01 2011 > @@ -53,7 +53,7 @@ > ; rdar://9177502 > define i32 @f5(i32 %a, i32 %b) nounwind readnone { > entry: > -; CHECK f5 > +; CHECK: f5 > ; CHECK-NOT: bfi r0, r2, #0, #1 > %and = and i32 %a, 2 > %b.masked = and i32 %b, -2 > > Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll (original) > +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-lsr3.ll Mon Apr 25 05:12:01 2011 > @@ -1,9 +1,9 @@ > -; RUN: llc < %s -march=thumb -mattr=+thumb2 > +; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s > > define i1 @test1(i64 %poscnt, i32 %work) { > entry: > -; CHECK: rrx r0, r0 > ; CHECK: lsrs.w r1, r1, #1 > +; CHECK: rrx r0, r0 > %0 = lshr i64 %poscnt, 1 > %1 = icmp eq i64 %0, 0 > ret i1 %1 > @@ -11,8 +11,8 @@ > > define i1 @test2(i64 %poscnt, i32 %work) { > entry: > -; CHECK: rrx r0, r0 > ; CHECK: asrs.w r1, r1, #1 > +; CHECK: rrx r0, r0 > %0 = ashr i64 %poscnt, 1 > %1 = icmp eq i64 %0, 0 > ret i1 %1 > > Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll (original) > +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Mon Apr 25 05:12:01 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc -march=x86 -relocation-model=pic < %s > +; RUN: llc -fast-isel -O0 -march=x86 -relocation-model=pic < %s | FileCheck %s > > ; This should use flds to set the return value. > ; CHECK: test0: > > Modified: llvm/trunk/test/CodeGen/X86/fp-trunc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fp-trunc.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/fp-trunc.ll (original) > +++ llvm/trunk/test/CodeGen/X86/fp-trunc.ll Mon Apr 25 05:12:01 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -march=x86 -mattr=+sse2,-avx > +; RUN: llc < %s -march=x86 -mattr=+sse2,-avx | FileCheck %s > > define <1 x float> @test1(<1 x double> %x) nounwind { > ; CHECK: cvtsd2ss > > Modified: llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll?rev=130126&r1=130125&r2=130126&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll (original) > +++ llvm/trunk/test/CodeGen/X86/lsr-interesting-step.ll Mon Apr 25 05:12:01 2011 > @@ -1,9 +1,9 @@ > -; RUN: llc < %s -march=x86-64 -relocation-model=static -mtriple=x86_64-unknown-linux-gnu > +; RUN: llc < %s -march=x86-64 -relocation-model=static -mtriple=x86_64-unknown-linux-gnu -asm-verbose=0 | FileCheck %s > > ; The inner loop should require only one add (and no leas either). > ; rdar://8100380 > > -; CHECK: BB0_4: > +; CHECK: BB0_3: > ; CHECK-NEXT: movb $0, flags(%rdx) > ; CHECK-NEXT: addq %rcx, %rdx > ; CHECK-NEXT: cmpq $8192, %rdx > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From benny.kra at googlemail.com Tue Apr 26 13:47:43 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 26 Apr 2011 18:47:43 -0000 Subject: [llvm-commits] [llvm] r130226 - /llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Message-ID: <20110426184743.8C5982A6C12D@llvm.org> Author: d0k Date: Tue Apr 26 13:47:43 2011 New Revision: 130226 URL: http://llvm.org/viewvc/llvm-project?rev=130226&view=rev Log: Force a triple on this test to unbreak windows buildbots. Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll?rev=130226&r1=130225&r2=130226&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Tue Apr 26 13:47:43 2011 @@ -1,4 +1,4 @@ -; RUN: llc -fast-isel -O0 -march=x86 -relocation-model=pic < %s | FileCheck %s +; RUN: llc -fast-isel -O0 -mtriple=i386-apple-darwin10 -relocation-model=pic < %s | FileCheck %s ; This should use flds to set the return value. ; CHECK: test0: From benny.kra at googlemail.com Tue Apr 26 13:54:23 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Tue, 26 Apr 2011 20:54:23 +0200 Subject: [llvm-commits] [llvm] r130126 - in /llvm/trunk/test: Analysis/RegionInfo/next.ll CodeGen/ARM/crash-greedy.ll CodeGen/PTX/ld.ll CodeGen/Thumb2/bfi.ll CodeGen/Thumb2/thumb2-lsr3.ll CodeGen/X86/fast-isel-x86.ll CodeGen/X86/fp-trunc.ll CodeGen/X86/lsr-interesting-step.ll In-Reply-To: References: <20110425101201.DCB352A6C12D@llvm.org> Message-ID: <7347CA8F-3F7F-49A9-A08B-913DDAE8B8AA@googlemail.com> On 26.04.2011, at 20:35, Bob Wilson wrote: > Benjamin, the fast-isel-x86 test is failing on the llvm-gcc-native-mingw32-win7 tester: > > http://google1.osuosl.org:8011/builders/llvm-gcc-native-mingw32-win7/builds/1736 > > Can you please fix it somehow? Ugh, I guess PIC doesn't make much sense on windows. I'll force a triple on that test, that way it still tests more than without invoking FileCheck. Maybe Dan has an idea, svn says that he chcked in the broken "CodeGen/X86/fast-isel-x86.ll" test case. From stoklund at 2pi.dk Tue Apr 26 13:52:33 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 26 Apr 2011 18:52:33 -0000 Subject: [llvm-commits] [llvm] r130228 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMBaseRegisterInfo.h lib/Target/ARM/Thumb1RegisterInfo.cpp lib/Target/ARM/Thumb1RegisterInfo.h lib/Target/X86/X86RegisterInfo.cpp lib/Target/X86/X86RegisterInfo.h Message-ID: <20110426185233.C6ADA2A6C12D@llvm.org> Author: stoklund Date: Tue Apr 26 13:52:33 2011 New Revision: 130228 URL: http://llvm.org/viewvc/llvm-project?rev=130228&view=rev Log: Add a TRI::getLargestLegalSuperClass hook to provide an upper limit on register class inflation. The hook will be used by the register allocator when recomputing register classes after removing constraints. Thumb1 code doesn't allow anything larger than tGPR, and x86 needs to ensure that the spill size doesn't change. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.h Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Tue Apr 26 13:52:33 2011 @@ -604,6 +604,17 @@ return RC; } + /// getLargestLegalSuperClass - Returns the largest super class of RC that is + /// legal to use in the current sub-target and has the same spill size. + /// The returned register class can be used to create virtual registers which + /// means that all its registers can be copied and spilled. + virtual const TargetRegisterClass* + getLargestLegalSuperClass(const TargetRegisterClass *RC) const { + /// The default implementation is very conservative and doesn't allow the + /// register allocator to inflate register classes. + return RC; + } + /// getRegPressureLimit - Return the register pressure "high water mark" for /// the specific register class. The scheduler is in high register pressure /// mode (for the specific register class) if it goes over the limit. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Tue Apr 26 13:52:33 2011 @@ -342,6 +342,25 @@ return false; } +const TargetRegisterClass* +ARMBaseRegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC) + const { + const TargetRegisterClass *Super = RC; + TargetRegisterClass::sc_iterator I = RC->superclasses_begin(); + do { + switch (Super->getID()) { + case ARM::GPRRegClassID: + case ARM::SPRRegClassID: + case ARM::DPRRegClassID: + case ARM::QPRRegClassID: + case ARM::QQPRRegClassID: + case ARM::QQQQPRRegClassID: + return Super; + } + Super = *I++; + } while (Super); + return RC; +} const TargetRegisterClass * ARMBaseRegisterInfo::getPointerRegClass(unsigned Kind) const { Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.h Tue Apr 26 13:52:33 2011 @@ -128,6 +128,9 @@ const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const; + const TargetRegisterClass* + getLargestLegalSuperClass(const TargetRegisterClass *RC) const; + unsigned getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const; Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Tue Apr 26 13:52:33 2011 @@ -46,6 +46,14 @@ : ARMBaseRegisterInfo(tii, sti) { } +const TargetRegisterClass* +Thumb1RegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC) + const { + if (RC == ARM::tGPRRegisterClass || RC->hasSuperClass(ARM::tGPRRegisterClass)) + return ARM::tGPRRegisterClass; + return ARMBaseRegisterInfo::getLargestLegalSuperClass(RC); +} + const TargetRegisterClass * Thumb1RegisterInfo::getPointerRegClass(unsigned Kind) const { return ARM::tGPRRegisterClass; Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.h Tue Apr 26 13:52:33 2011 @@ -28,6 +28,9 @@ public: Thumb1RegisterInfo(const ARMBaseInstrInfo &tii, const ARMSubtarget &STI); + const TargetRegisterClass* + getLargestLegalSuperClass(const TargetRegisterClass *RC) const; + const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const; /// emitLoadConstPool - Emits a load from constpool to materialize the Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Tue Apr 26 13:52:33 2011 @@ -308,6 +308,33 @@ return 0; } +const TargetRegisterClass* +X86RegisterInfo::getLargestLegalSuperClass(const TargetRegisterClass *RC) const{ + const TargetRegisterClass *Super = RC; + TargetRegisterClass::sc_iterator I = RC->superclasses_begin(); + do { + switch (Super->getID()) { + case X86::GR8RegClassID: + case X86::GR16RegClassID: + case X86::GR32RegClassID: + case X86::GR64RegClassID: + case X86::FR32RegClassID: + case X86::FR64RegClassID: + case X86::RFP32RegClassID: + case X86::RFP64RegClassID: + case X86::RFP80RegClassID: + case X86::VR128RegClassID: + case X86::VR256RegClassID: + // Don't return a super-class that would shrink the spill size. + // That can happen with the vector and float classes. + if (Super->getSize() == RC->getSize()) + return Super; + } + Super = *I++; + } while (Super); + return RC; +} + const TargetRegisterClass * X86RegisterInfo::getPointerRegClass(unsigned Kind) const { switch (Kind) { Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=130228&r1=130227&r2=130228&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Tue Apr 26 13:52:33 2011 @@ -91,6 +91,9 @@ getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const; + const TargetRegisterClass* + getLargestLegalSuperClass(const TargetRegisterClass *RC) const; + /// getPointerRegClass - Returns a TargetRegisterClass used for pointer /// values. const TargetRegisterClass *getPointerRegClass(unsigned Kind = 0) const; From stoklund at 2pi.dk Tue Apr 26 13:52:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 26 Apr 2011 18:52:36 -0000 Subject: [llvm-commits] [llvm] r130229 - in /llvm/trunk: include/llvm/CodeGen/CalcSpillWeights.h lib/CodeGen/CalcSpillWeights.cpp Message-ID: <20110426185236.EA79E2A6C12E@llvm.org> Author: stoklund Date: Tue Apr 26 13:52:36 2011 New Revision: 130229 URL: http://llvm.org/viewvc/llvm-project?rev=130229&view=rev Log: Use the new TRI->getLargestLegalSuperClass hook to constrain register class inflation. This has two effects: 1. We never inflate to a larger register class than what the sub-target can handle. 2. Completely unconstrained virtual registers get the largest possible register class. Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h?rev=130229&r1=130228&r2=130229&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h (original) +++ llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h Tue Apr 26 13:52:36 2011 @@ -40,14 +40,14 @@ /// VirtRegAuxInfo - Calculate auxiliary information for a virtual /// register such as its spill weight and allocation hint. class VirtRegAuxInfo { - MachineFunction &mf_; - LiveIntervals &lis_; - const MachineLoopInfo &loops_; - DenseMap hint_; + MachineFunction &MF; + LiveIntervals &LIS; + const MachineLoopInfo &Loops; + DenseMap Hint; public: VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis, const MachineLoopInfo &loops) : - mf_(mf), lis_(lis), loops_(loops) {} + MF(mf), LIS(lis), Loops(loops) {} /// CalculateRegClass - recompute the register class for reg from its uses. /// Since the register class can affect the allocation hint, this function Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=130229&r1=130228&r2=130229&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Tue Apr 26 13:52:36 2011 @@ -87,8 +87,8 @@ } void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) { - MachineRegisterInfo &mri = mf_.getRegInfo(); - const TargetRegisterInfo &tri = *mf_.getTarget().getRegisterInfo(); + MachineRegisterInfo &mri = MF.getRegInfo(); + const TargetRegisterInfo &tri = *MF.getTarget().getRegisterInfo(); MachineBasicBlock *mbb = 0; MachineLoop *loop = 0; unsigned loopDepth = 0; @@ -118,7 +118,7 @@ // Get loop info for mi. if (mi->getParent() != mbb) { mbb = mi->getParent(); - loop = loops_.getLoopFor(mbb); + loop = Loops.getLoopFor(mbb); loopDepth = loop ? loop->getLoopDepth() : 0; isExiting = loop ? loop->isLoopExiting(mbb) : false; } @@ -129,7 +129,7 @@ weight = LiveIntervals::getSpillWeight(writes, reads, loopDepth); // Give extra weight to what looks like a loop induction variable update. - if (writes && isExiting && lis_.isLiveOutOfMBB(li, mbb)) + if (writes && isExiting && LIS.isLiveOutOfMBB(li, mbb)) weight *= 3; totalWeight += weight; @@ -141,9 +141,9 @@ unsigned hint = copyHint(mi, li.reg, tri, mri); if (!hint) continue; - float hweight = hint_[hint] += weight; + float hweight = Hint[hint] += weight; if (TargetRegisterInfo::isPhysicalRegister(hint)) { - if (hweight > bestPhys && lis_.isAllocatable(hint)) + if (hweight > bestPhys && LIS.isAllocatable(hint)) bestPhys = hweight, hintPhys = hint; } else { if (hweight > bestVirt) @@ -151,7 +151,7 @@ } } - hint_.clear(); + Hint.clear(); // Always prefer the physreg hint. if (unsigned hint = hintPhys ? hintPhys : hintVirt) { @@ -176,7 +176,7 @@ // FIXME: this gets much more complicated once we support non-trivial // re-materialization. bool isLoad = false; - if (lis_.isReMaterializable(li, 0, isLoad)) { + if (LIS.isReMaterializable(li, 0, isLoad)) { if (isLoad) totalWeight *= 0.9F; else @@ -187,50 +187,29 @@ } void VirtRegAuxInfo::CalculateRegClass(unsigned reg) { - MachineRegisterInfo &mri = mf_.getRegInfo(); - const TargetRegisterInfo *tri = mf_.getTarget().getRegisterInfo(); - const TargetRegisterClass *orc = mri.getRegClass(reg); - SmallPtrSet rcs; - - for (MachineRegisterInfo::reg_nodbg_iterator I = mri.reg_nodbg_begin(reg), - E = mri.reg_nodbg_end(); I != E; ++I) { - // The targets don't have accurate enough regclass descriptions that we can - // handle subregs. We need something similar to - // TRI::getMatchingSuperRegClass, but returning a super class instead of a - // sub class. - if (I.getOperand().getSubReg()) { - DEBUG(dbgs() << "Cannot handle subregs: " << I.getOperand() << '\n'); - return; - } - if (const TargetRegisterClass *rc = - I->getDesc().getRegClass(I.getOperandNo(), tri)) - rcs.insert(rc); - } + MachineRegisterInfo &MRI = MF.getRegInfo(); + const TargetRegisterInfo *TRI = MF.getTarget().getRegisterInfo(); + const TargetRegisterClass *OldRC = MRI.getRegClass(reg); + const TargetRegisterClass *NewRC = TRI->getLargestLegalSuperClass(OldRC); - // If we found no regclass constraints, just leave reg as is. - // In theory, we could inflate to the largest superclass of reg's existing - // class, but that might not be legal for the current cpu setting. - // This could happen if reg is only used by COPY instructions, so we may need - // to improve on this. - if (rcs.empty()) { + // Stop early if there is no room to grow. + if (NewRC == OldRC) return; - } - // Compute the intersection of all classes in rcs. - // This ought to be independent of iteration order, but if the target register - // classes don't form a proper algebra, it is possible to get different - // results. The solution is to make sure the intersection of any two register - // classes is also a register class or the null set. - const TargetRegisterClass *rc = 0; - for (SmallPtrSet::iterator I = rcs.begin(), - E = rcs.end(); I != E; ++I) { - rc = rc ? getCommonSubClass(rc, *I) : *I; - assert(rc && "Incompatible regclass constraints found"); + // Accumulate constraints from all uses. + for (MachineRegisterInfo::reg_nodbg_iterator I = MRI.reg_nodbg_begin(reg), + E = MRI.reg_nodbg_end(); I != E; ++I) { + // TRI doesn't have accurate enough information to model this yet. + if (I.getOperand().getSubReg()) + return; + const TargetRegisterClass *OpRC = + I->getDesc().getRegClass(I.getOperandNo(), TRI); + if (OpRC) + NewRC = getCommonSubClass(NewRC, OpRC); + if (!NewRC || NewRC == OldRC) + return; } - - if (rc == orc) - return; - DEBUG(dbgs() << "Inflating " << orc->getName() << ':' << PrintReg(reg) - << " to " << rc->getName() <<".\n"); - mri.setRegClass(reg, rc); + DEBUG(dbgs() << "Inflating " << OldRC->getName() << ':' << PrintReg(reg) + << " to " << NewRC->getName() <<".\n"); + MRI.setRegClass(reg, NewRC); } From aggarwa4 at illinois.edu Tue Apr 26 13:54:10 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 26 Apr 2011 18:54:10 -0000 Subject: [llvm-commits] [poolalloc] r130230 - /poolalloc/trunk/include/assistDS/TypeChecks.h Message-ID: <20110426185410.A67C02A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 13:54:10 2011 New Revision: 130230 URL: http://llvm.org/viewvc/llvm-project?rev=130230&view=rev Log: Add the correct prototype Modified: poolalloc/trunk/include/assistDS/TypeChecks.h Modified: poolalloc/trunk/include/assistDS/TypeChecks.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/TypeChecks.h?rev=130230&r1=130229&r2=130230&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/TypeChecks.h (original) +++ poolalloc/trunk/include/assistDS/TypeChecks.h Tue Apr 26 13:54:10 2011 @@ -63,7 +63,7 @@ Constant *C, Instruction &I, unsigned offset); bool visitStoreInst(Module &M, StoreInst &SI); bool visitCopyingStoreInst(Module &M, StoreInst &SI, Value *SS); - bool visitInputFunctionValue(Module &M, Value *V, CallInst *CI); + bool visitInputFunctionValue(Module &M, Value *V, Instruction *CI); // Return the map containing all of the types used in the module. const std::map &getTypes() const { From dpatel at apple.com Tue Apr 26 14:06:18 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 26 Apr 2011 19:06:18 -0000 Subject: [llvm-commits] [llvm] r130231 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h Message-ID: <20110426190618.D98082A6C12D@llvm.org> Author: dpatel Date: Tue Apr 26 14:06:18 2011 New Revision: 130231 URL: http://llvm.org/viewvc/llvm-project?rev=130231&view=rev Log: Refactor code. Keep dwarf register operation selection logic at one place. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=130231&r1=130230&r2=130231&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Apr 26 14:06:18 2011 @@ -210,6 +210,62 @@ addAddress(Die, dwarf::DW_AT_location, Location); } +/// addRegisterOp - Add register operand. +void CompileUnit::addRegisterOp(DIE *TheDie, unsigned Reg) { + const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); + unsigned DWReg = RI->getDwarfRegNum(Reg, false); + if (DWReg < 32) + addUInt(TheDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + DWReg); + else { + addUInt(TheDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_regx); + addUInt(TheDie, 0, dwarf::DW_FORM_udata, DWReg); + } +} + +/// addRegisterOffset - Add register offset. +void CompileUnit::addRegisterOffset(DIE *TheDie, unsigned Reg, + int64_t Offset) { + const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); + unsigned DWReg = RI->getDwarfRegNum(Reg, false); + const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); + if (Reg == TRI->getFrameRegister(*Asm->MF)) + // If variable offset is based in frame register then use fbreg. + addUInt(TheDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_fbreg); + else if (DWReg < 32) + addUInt(TheDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + DWReg); + else { + addUInt(TheDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx); + addUInt(TheDie, 0, dwarf::DW_FORM_udata, DWReg); + } + addSInt(TheDie, 0, dwarf::DW_FORM_sdata, Offset); +} + +/// addAddress - Add an address attribute to a die based on the location +/// provided. +void CompileUnit::addAddress(DIE *Die, unsigned Attribute, + const MachineLocation &Location) { + DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); + + if (Location.isReg()) + addRegisterOp(Block, Location.getReg()); + else + addRegisterOffset(Block, Location.getReg(), Location.getOffset()); + + // Now attach the location information to the DIE. + addBlock(Die, Attribute, 0, Block); +} + +/// addRegisterAddress - Add register location entry in variable DIE. +bool CompileUnit::addRegisterAddress(DIE *Die, const MachineOperand &MO) { + assert (MO.isReg() && "Invalid machine operand!"); + if (!MO.getReg()) + return false; + MachineLocation Location; + Location.set(MO.getReg()); + addAddress(Die, dwarf::DW_AT_location, Location); + return true; +} + /// addComplexAddress - Start with the address based on the location provided, /// and generate the DWARF information necessary to find the actual variable /// given the extra address information encoded in the DIVariable, starting from @@ -218,31 +274,12 @@ void CompileUnit::addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location) { - DIType Ty = DV->getType(); - - // Decode the original location, and use that as the start of the byref - // variable's location. - const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); - unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false); DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - if (Location.isReg()) { - if (Reg < 32) { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + Reg); - } else { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_regx); - addUInt(Block, 0, dwarf::DW_FORM_udata, Reg); - } - } else { - if (Reg < 32) - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg); - else { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx); - addUInt(Block, 0, dwarf::DW_FORM_udata, Reg); - } - - addUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset()); - } + if (Location.isReg()) + addRegisterOp(Block, Location.getReg()); + else + addRegisterOffset(Block, Location.getReg(), Location.getOffset()); for (unsigned i = 0, N = DV->getNumAddrElements(); i < N; ++i) { uint64_t Element = DV->getAddrElement(i); @@ -412,55 +449,6 @@ addBlock(Die, Attribute, 0, Block); } -/// addAddress - Add an address attribute to a die based on the location -/// provided. -void CompileUnit::addAddress(DIE *Die, unsigned Attribute, - const MachineLocation &Location) { - const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo(); - unsigned Reg = RI->getDwarfRegNum(Location.getReg(), false); - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - - if (RI->getFrameRegister(*Asm->MF) == Location.getReg() - && Location.getOffset()) { - // If variable offset is based in frame register then use fbreg. - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_fbreg); - addSInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset()); - addBlock(Die, Attribute, 0, Block); - return; - } - - if (Location.isReg()) { - if (Reg < 32) { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_reg0 + Reg); - } else { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_regx); - addUInt(Block, 0, dwarf::DW_FORM_udata, Reg); - } - } else { - if (Reg < 32) { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + Reg); - } else { - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_bregx); - addUInt(Block, 0, dwarf::DW_FORM_udata, Reg); - } - - addUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset()); - } - - addBlock(Die, Attribute, 0, Block); -} - -/// addRegisterAddress - Add register location entry in variable DIE. -bool CompileUnit::addRegisterAddress(DIE *Die, const MachineOperand &MO) { - assert (MO.isReg() && "Invalid machine operand!"); - if (!MO.getReg()) - return false; - MachineLocation Location; - Location.set(MO.getReg()); - addAddress(Die, dwarf::DW_AT_location, Location); - return true; -} - /// addConstantValue - Add constant value entry in variable DIE. bool CompileUnit::addConstantValue(DIE *Die, const MachineOperand &MO) { assert (MO.isImm() && "Invalid machine operand!"); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=130231&r1=130230&r2=130231&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Tue Apr 26 14:06:18 2011 @@ -194,6 +194,12 @@ /// addTemplateParams - Add template parameters in buffer. void addTemplateParams(DIE &Buffer, DIArray TParams); + /// addRegisterOp - Add register operand. + void addRegisterOp(DIE *TheDie, unsigned Reg); + + /// addRegisterOffset - Add register offset. + void addRegisterOffset(DIE *TheDie, unsigned Reg, int64_t Offset); + /// addComplexAddress - Start with the address based on the location provided, /// and generate the DWARF information necessary to find the actual variable /// (navigating the extra location information encoded in the type) based on From rdivacky at freebsd.org Tue Apr 26 14:14:01 2011 From: rdivacky at freebsd.org (Roman Divacky) Date: Tue, 26 Apr 2011 21:14:01 +0200 Subject: [llvm-commits] [llvm] r130206 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/SimplifyCFG/2006-08-03-Crash.ll In-Reply-To: <20110426174102.E48DB2A6C12D@llvm.org> References: <20110426174102.E48DB2A6C12D@llvm.org> Message-ID: <20110426191401.GA44622@freebsd.org> this is causing some strange regressions here (with greedy regalloc but otherwise vanilla llvm): before: cmpb $69, 41(%esp) after: movl %eax, %ecx movb %ch, %cl cmpb $69, %cl and some more you can get the before/after asm files at: http://lev.vlakno.cz/~rdivacky/boot2.after.s http://lev.vlakno.cz/~rdivacky/boot2.before.s On Tue, Apr 26, 2011 at 05:41:02PM -0000, Chris Lattner wrote: > Author: lattner > Date: Tue Apr 26 12:41:02 2011 > New Revision: 130206 > > URL: http://llvm.org/viewvc/llvm-project?rev=130206&view=rev > Log: > Improve the bail-out predicate to really only kick in when phi > translation fails. We were bailing out in some cases that would > cause us to miss GVN'ing some non-local cases away. > > Modified: > llvm/trunk/lib/Transforms/Scalar/GVN.cpp > llvm/trunk/test/Transforms/GVN/rle.ll > llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll > > Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130206&r1=130205&r2=130206&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Tue Apr 26 12:41:02 2011 > @@ -1103,7 +1103,8 @@ > > // If we had a phi translation failure, we'll have a single entry which is a > // clobber in the current block. Reject this early. > - if (Deps.size() == 1 && Deps[0].getResult().isClobber()) { > + if (Deps.size() == 1 && Deps[0].getResult().isClobber() && > + Deps[0].getResult().getInst()->getParent() == LI->getParent()) { > DEBUG( > dbgs() << "GVN: non-local load "; > WriteAsOperand(dbgs(), LI); > > Modified: llvm/trunk/test/Transforms/GVN/rle.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=130206&r1=130205&r2=130206&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/GVN/rle.ll (original) > +++ llvm/trunk/test/Transforms/GVN/rle.ll Tue Apr 26 12:41:02 2011 > @@ -570,4 +570,27 @@ > } > > > +; Cross block partial alias case. > +define i32 @load_load_partial_alias_cross_block(i8* %P) nounwind ssp { > +entry: > + %xx = bitcast i8* %P to i32* > + %x1 = load i32* %xx, align 4 > + %cmp = icmp eq i32 %x1, 127 > + br i1 %cmp, label %land.lhs.true, label %if.end > + > +land.lhs.true: ; preds = %entry > + %arrayidx4 = getelementptr inbounds i8* %P, i64 1 > + %tmp5 = load i8* %arrayidx4, align 1 > + %conv6 = zext i8 %tmp5 to i32 > + ret i32 %conv6 > + > +if.end: > + ret i32 52 > +; CHECK: @load_load_partial_alias_cross_block > +; CHECK: land.lhs.true: > +; CHECK-NOT: load i8 > +; CHECK: ret i32 %conv6 > +} > + > + > > > Modified: llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll?rev=130206&r1=130205&r2=130206&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll (original) > +++ llvm/trunk/test/Transforms/SimplifyCFG/2006-08-03-Crash.ll Tue Apr 26 12:41:02 2011 > @@ -1,7 +1,5 @@ > -; RUN: opt < %s -gvn -simplifycfg \ > -; RUN: -disable-output > +; RUN: opt < %s -gvn -simplifycfg -disable-output > ; PR867 > -; END. > > target datalayout = "E-p:32:32" > target triple = "powerpc-apple-darwin8" > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Tue Apr 26 14:17:08 2011 From: gohman at apple.com (Dan Gohman) Date: Tue, 26 Apr 2011 12:17:08 -0700 Subject: [llvm-commits] [llvm] r130126 - in /llvm/trunk/test: Analysis/RegionInfo/next.ll CodeGen/ARM/crash-greedy.ll CodeGen/PTX/ld.ll CodeGen/Thumb2/bfi.ll CodeGen/Thumb2/thumb2-lsr3.ll CodeGen/X86/fast-isel-x86.ll CodeGen/X86/fp-trunc.ll CodeGen/X86/lsr-interesting-step.ll In-Reply-To: <7347CA8F-3F7F-49A9-A08B-913DDAE8B8AA@googlemail.com> References: <20110425101201.DCB352A6C12D@llvm.org> <7347CA8F-3F7F-49A9-A08B-913DDAE8B8AA@googlemail.com> Message-ID: <232090EC-CDDD-4842-9135-C5EB1DB6C393@apple.com> On Apr 26, 2011, at 11:54 AM, Benjamin Kramer wrote: > > On 26.04.2011, at 20:35, Bob Wilson wrote: > >> Benjamin, the fast-isel-x86 test is failing on the llvm-gcc-native-mingw32-win7 tester: >> >> http://google1.osuosl.org:8011/builders/llvm-gcc-native-mingw32-win7/builds/1736 >> >> Can you please fix it somehow? > > Ugh, I guess PIC doesn't make much sense on windows. I'll force a triple on that test, that way it still tests more than without invoking FileCheck. > > Maybe Dan has an idea, svn says that he chcked in the broken "CodeGen/X86/fast-isel-x86.ll" test case. A forced triple is fine. Thanks, Dan From rafael.espindola at gmail.com Tue Apr 26 14:26:53 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 26 Apr 2011 19:26:53 -0000 Subject: [llvm-commits] [llvm] r130232 - /llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Message-ID: <20110426192653.32CED2A6C12D@llvm.org> Author: rafael Date: Tue Apr 26 14:26:53 2011 New Revision: 130232 URL: http://llvm.org/viewvc/llvm-project?rev=130232&view=rev Log: Print the label if we will use it in debug_frame. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130232&r1=130231&r2=130232&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Apr 26 14:26:53 2011 @@ -593,10 +593,13 @@ void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { MCSymbol *Label = MI.getOperand(0).getMCSymbol(); - if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) { + + if (MAI->doesDwarfRequireFrameSection() || + MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) OutStreamer.EmitLabel(Label); + + if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) return; - } const MachineFunction &MF = *MI.getParent()->getParent(); MachineModuleInfo &MMI = MF.getMMI(); From grosbach at apple.com Tue Apr 26 14:44:19 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 26 Apr 2011 19:44:19 -0000 Subject: [llvm-commits] [llvm] r130234 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h ARMInstrInfo.td Message-ID: <20110426194419.3D52F2A6C12D@llvm.org> Author: grosbach Date: Tue Apr 26 14:44:18 2011 New Revision: 130234 URL: http://llvm.org/viewvc/llvm-project?rev=130234&view=rev Log: ARM and Thumb2 support for atomic MIN/MAX/UMIN/UMAX loads. rdar://9326019 Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=130234&r1=130233&r2=130234&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Apr 26 14:44:18 2011 @@ -609,6 +609,18 @@ setOperationAction(ISD::ATOMIC_LOAD_NAND, MVT::i8, Expand); setOperationAction(ISD::ATOMIC_LOAD_NAND, MVT::i16, Expand); setOperationAction(ISD::ATOMIC_LOAD_NAND, MVT::i32, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MIN, MVT::i8, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MIN, MVT::i16, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MIN, MVT::i32, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MAX, MVT::i8, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MAX, MVT::i16, Expand); + setOperationAction(ISD::ATOMIC_LOAD_MAX, MVT::i32, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMIN, MVT::i8, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMIN, MVT::i16, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMIN, MVT::i32, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMAX, MVT::i8, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMAX, MVT::i16, Expand); + setOperationAction(ISD::ATOMIC_LOAD_UMAX, MVT::i32, Expand); // Since the libcalls include locking, fold in the fences setShouldFoldAtomicFences(true); } @@ -5031,6 +5043,109 @@ return BB; } +MachineBasicBlock * +ARMTargetLowering::EmitAtomicBinaryMinMax(MachineInstr *MI, + MachineBasicBlock *BB, + unsigned Size, + bool signExtend, + ARMCC::CondCodes Cond) const { + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + + const BasicBlock *LLVM_BB = BB->getBasicBlock(); + MachineFunction *MF = BB->getParent(); + MachineFunction::iterator It = BB; + ++It; + + unsigned dest = MI->getOperand(0).getReg(); + unsigned ptr = MI->getOperand(1).getReg(); + unsigned incr = MI->getOperand(2).getReg(); + unsigned oldval = dest; + DebugLoc dl = MI->getDebugLoc(); + + bool isThumb2 = Subtarget->isThumb2(); + unsigned ldrOpc, strOpc, extendOpc; + switch (Size) { + default: llvm_unreachable("unsupported size for AtomicCmpSwap!"); + case 1: + ldrOpc = isThumb2 ? ARM::t2LDREXB : ARM::LDREXB; + strOpc = isThumb2 ? ARM::t2STREXB : ARM::STREXB; + extendOpc = isThumb2 ? ARM::t2SXTBr : ARM::SXTBr; + break; + case 2: + ldrOpc = isThumb2 ? ARM::t2LDREXH : ARM::LDREXH; + strOpc = isThumb2 ? ARM::t2STREXH : ARM::STREXH; + extendOpc = isThumb2 ? ARM::t2SXTHr : ARM::SXTHr; + break; + case 4: + ldrOpc = isThumb2 ? ARM::t2LDREX : ARM::LDREX; + strOpc = isThumb2 ? ARM::t2STREX : ARM::STREX; + extendOpc = 0; + break; + } + + MachineBasicBlock *loopMBB = MF->CreateMachineBasicBlock(LLVM_BB); + MachineBasicBlock *exitMBB = MF->CreateMachineBasicBlock(LLVM_BB); + MF->insert(It, loopMBB); + MF->insert(It, exitMBB); + + // Transfer the remainder of BB and its successor edges to exitMBB. + exitMBB->splice(exitMBB->begin(), BB, + llvm::next(MachineBasicBlock::iterator(MI)), + BB->end()); + exitMBB->transferSuccessorsAndUpdatePHIs(BB); + + MachineRegisterInfo &RegInfo = MF->getRegInfo(); + unsigned scratch = RegInfo.createVirtualRegister(ARM::GPRRegisterClass); + unsigned scratch2 = RegInfo.createVirtualRegister(ARM::GPRRegisterClass); + + // thisMBB: + // ... + // fallthrough --> loopMBB + BB->addSuccessor(loopMBB); + + // loopMBB: + // ldrex dest, ptr + // (sign extend dest, if required) + // cmp dest, incr + // cmov.cond scratch2, dest, incr + // strex scratch, scratch2, ptr + // cmp scratch, #0 + // bne- loopMBB + // fallthrough --> exitMBB + BB = loopMBB; + AddDefaultPred(BuildMI(BB, dl, TII->get(ldrOpc), dest).addReg(ptr)); + + // Sign extend the value, if necessary. + if (signExtend && extendOpc) { + oldval = RegInfo.createVirtualRegister(ARM::GPRRegisterClass); + AddDefaultPred(BuildMI(BB, dl, TII->get(extendOpc), oldval).addReg(dest)); + } + + // Build compare and cmov instructions. + AddDefaultPred(BuildMI(BB, dl, TII->get(isThumb2 ? ARM::t2CMPrr : ARM::CMPrr)) + .addReg(oldval).addReg(incr)); + BuildMI(BB, dl, TII->get(isThumb2 ? ARM::t2MOVCCr : ARM::MOVCCr), scratch2) + .addReg(oldval).addReg(incr).addImm(Cond).addReg(ARM::CPSR); + + AddDefaultPred(BuildMI(BB, dl, TII->get(strOpc), scratch).addReg(scratch2) + .addReg(ptr)); + AddDefaultPred(BuildMI(BB, dl, TII->get(isThumb2 ? ARM::t2CMPri : ARM::CMPri)) + .addReg(scratch).addImm(0)); + BuildMI(BB, dl, TII->get(isThumb2 ? ARM::t2Bcc : ARM::Bcc)) + .addMBB(loopMBB).addImm(ARMCC::NE).addReg(ARM::CPSR); + + BB->addSuccessor(loopMBB); + BB->addSuccessor(exitMBB); + + // exitMBB: + // ... + BB = exitMBB; + + MI->eraseFromParent(); // The instruction is gone now. + + return BB; +} + static MachineBasicBlock *OtherSucc(MachineBasicBlock *MBB, MachineBasicBlock *Succ) { for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(), @@ -5162,6 +5277,34 @@ case ARM::ATOMIC_LOAD_SUB_I32: return EmitAtomicBinary(MI, BB, 4, isThumb2 ? ARM::t2SUBrr : ARM::SUBrr); + case ARM::ATOMIC_LOAD_MIN_I8: + return EmitAtomicBinaryMinMax(MI, BB, 1, true, ARMCC::LT); + case ARM::ATOMIC_LOAD_MIN_I16: + return EmitAtomicBinaryMinMax(MI, BB, 2, true, ARMCC::LT); + case ARM::ATOMIC_LOAD_MIN_I32: + return EmitAtomicBinaryMinMax(MI, BB, 4, true, ARMCC::LT); + + case ARM::ATOMIC_LOAD_MAX_I8: + return EmitAtomicBinaryMinMax(MI, BB, 1, true, ARMCC::GT); + case ARM::ATOMIC_LOAD_MAX_I16: + return EmitAtomicBinaryMinMax(MI, BB, 2, true, ARMCC::GT); + case ARM::ATOMIC_LOAD_MAX_I32: + return EmitAtomicBinaryMinMax(MI, BB, 4, true, ARMCC::GT); + + case ARM::ATOMIC_LOAD_UMIN_I8: + return EmitAtomicBinaryMinMax(MI, BB, 1, false, ARMCC::LO); + case ARM::ATOMIC_LOAD_UMIN_I16: + return EmitAtomicBinaryMinMax(MI, BB, 2, false, ARMCC::LO); + case ARM::ATOMIC_LOAD_UMIN_I32: + return EmitAtomicBinaryMinMax(MI, BB, 4, false, ARMCC::LO); + + case ARM::ATOMIC_LOAD_UMAX_I8: + return EmitAtomicBinaryMinMax(MI, BB, 1, false, ARMCC::HI); + case ARM::ATOMIC_LOAD_UMAX_I16: + return EmitAtomicBinaryMinMax(MI, BB, 2, false, ARMCC::HI); + case ARM::ATOMIC_LOAD_UMAX_I32: + return EmitAtomicBinaryMinMax(MI, BB, 4, false, ARMCC::HI); + case ARM::ATOMIC_SWAP_I8: return EmitAtomicBinary(MI, BB, 1, 0); case ARM::ATOMIC_SWAP_I16: return EmitAtomicBinary(MI, BB, 2, 0); case ARM::ATOMIC_SWAP_I32: return EmitAtomicBinary(MI, BB, 4, 0); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=130234&r1=130233&r2=130234&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Tue Apr 26 14:44:18 2011 @@ -484,6 +484,11 @@ MachineBasicBlock *BB, unsigned Size, unsigned BinOpcode) const; + MachineBasicBlock * EmitAtomicBinaryMinMax(MachineInstr *MI, + MachineBasicBlock *BB, + unsigned Size, + bool signExtend, + ARMCC::CondCodes Cond) const; bool RemapAddSubWithFlags(MachineInstr *MI, MachineBasicBlock *BB) const; }; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130234&r1=130233&r2=130234&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Apr 26 14:44:18 2011 @@ -3256,6 +3256,18 @@ def ATOMIC_LOAD_NAND_I8 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>; + def ATOMIC_LOAD_MIN_I8 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_MAX_I8 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMIN_I8 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMAX_I8 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>; def ATOMIC_LOAD_ADD_I16 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>; @@ -3274,6 +3286,18 @@ def ATOMIC_LOAD_NAND_I16 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>; + def ATOMIC_LOAD_MIN_I16 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_MAX_I16 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMIN_I16 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMAX_I16 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>; def ATOMIC_LOAD_ADD_I32 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>; @@ -3292,6 +3316,18 @@ def ATOMIC_LOAD_NAND_I32 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>; + def ATOMIC_LOAD_MIN_I32 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_MAX_I32 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMIN_I32 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>; + def ATOMIC_LOAD_UMAX_I32 : PseudoInst< + (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary, + [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>; def ATOMIC_SWAP_I8 : PseudoInst< (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, From sabre at nondot.org Tue Apr 26 14:50:40 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 19:50:40 -0000 Subject: [llvm-commits] [llvm] r130235 - /llvm/trunk/include/llvm/Support/PatternMatch.h Message-ID: <20110426195040.1BE692A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 14:50:39 2011 New Revision: 130235 URL: http://llvm.org/viewvc/llvm-project?rev=130235&view=rev Log: add an m_ConstantInt matching predicate that binds to a uint64_t, and add an m_OneUse() predicate that matches if the subexpr has a single use. Modified: llvm/trunk/include/llvm/Support/PatternMatch.h Modified: llvm/trunk/include/llvm/Support/PatternMatch.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PatternMatch.h?rev=130235&r1=130234&r2=130235&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/PatternMatch.h (original) +++ llvm/trunk/include/llvm/Support/PatternMatch.h Tue Apr 26 14:50:39 2011 @@ -40,6 +40,23 @@ return const_cast(P).match(V); } + +template +struct OneUse_match { + SubPattern_t SubPattern; + + OneUse_match(const SubPattern_t &SP) : SubPattern(SP) {} + + template + bool match(OpTy *V) { + return V->hasOneUse() && SubPattern.match(V); + } +}; + +template +inline OneUse_match m_OneUse(const T &SubPattern) { return SubPattern; } + + template struct class_match { template @@ -227,7 +244,25 @@ /// m_Specific - Match if we have a specific specified value. inline specificval_ty m_Specific(const Value *V) { return V; } +struct bind_const_intval_ty { + uint64_t &VR; + bind_const_intval_ty(uint64_t &V) : VR(V) {} + + template + bool match(ITy *V) { + if (ConstantInt *CV = dyn_cast(V)) + if (CV->getBitWidth() <= 64) { + VR = CV->getZExtValue(); + return true; + } + return false; + } +}; +/// m_ConstantInt - Match a ConstantInt and bind to its value. This does not +/// match ConstantInts wider than 64-bits. +inline bind_const_intval_ty m_ConstantInt(uint64_t &V) { return V; } + //===----------------------------------------------------------------------===// // Matchers for specific binary operators. // From baldrick at free.fr Tue Apr 26 15:00:59 2011 From: baldrick at free.fr (Duncan Sands) Date: Tue, 26 Apr 2011 20:00:59 -0000 Subject: [llvm-commits] [dragonegg] r130236 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110426200059.38D3E2A6C12D@llvm.org> Author: baldrick Date: Tue Apr 26 15:00:59 2011 New Revision: 130236 URL: http://llvm.org/viewvc/llvm-project?rev=130236&view=rev Log: Only do arithmetic on constants of "register type". The code for handling constants now has no assumptions about what ConvertType and ConvertInitializer return. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130236&r1=130235&r2=130236&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Tue Apr 26 15:00:59 2011 @@ -399,7 +399,7 @@ /// same constant as you would get by storing the bits of 'C' to memory (with /// the first bit stored being 'StartingBit') and then loading out a (constant) /// value of type 'Ty' from the stored to memory location. -Constant *InterpretAsType(Constant *C, const Type* Ty, int StartingBit) { +Constant *InterpretAsType(Constant *C, const Type* Ty, int StartingBit = 0) { if (C->getType() == Ty) return C; @@ -493,7 +493,7 @@ /// using LoadRegisterFromMemory to load a register value back out starting from /// byte StartingByte. Constant *ExtractRegisterFromConstant(Constant *C, tree type, int StartingByte) { - // NOTE: Needs to be kept in sync with getRegType. + // NOTE: Needs to be kept in sync with getRegType and EncapsulateRegister. int StartingBit = StartingByte * BITS_PER_UNIT; switch (TREE_CODE(type)) { @@ -515,8 +515,8 @@ } case COMPLEX_TYPE: { - tree elt_type = TREE_TYPE (type); - unsigned Stride = GET_MODE_BITSIZE (TYPE_MODE (elt_type)); + tree elt_type = TREE_TYPE(type); + unsigned Stride = GET_MODE_BITSIZE(TYPE_MODE(elt_type)); Constant *Vals[2] = { ExtractRegisterFromConstant(C, elt_type, StartingBit), ExtractRegisterFromConstant(C, elt_type, StartingBit + Stride) @@ -535,9 +535,9 @@ return InterpretAsType(C, getRegType(type), StartingBit); case VECTOR_TYPE: { - tree elt_type = TREE_TYPE (type); + tree elt_type = TREE_TYPE(type); unsigned NumElts = TYPE_VECTOR_SUBPARTS(type); - unsigned Stride = GET_MODE_BITSIZE (TYPE_MODE (elt_type)); + unsigned Stride = GET_MODE_BITSIZE(TYPE_MODE(elt_type)); SmallVector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) { Vals[i] = ExtractRegisterFromConstant(C, elt_type, StartingBit+i*Stride); @@ -559,6 +559,89 @@ // ... ConvertInitializer ... //===----------------------------------------------------------------------===// +/// EncapsulateRegister - Turn a constant of in-register type (corresponding +/// to the given GCC type) into an in-memory constant. The result has the +/// property that applying ExtractRegisterFromConstant to it gives you the +/// original in-register constant back again. +static Constant *EncapsulateRegister(Constant *C, tree type) { + // NOTE: Needs to be kept in sync with ExtractRegisterFromConstant. + assert(C->getType() == getRegType(type) && "Constant has wrong type!"); + Constant *Result; + + switch (TREE_CODE(type)) { + + default: + DieAbjectly("Unknown register type!", type); + + case BOOLEAN_TYPE: + case ENUMERAL_TYPE: + case INTEGER_TYPE: { + // For integral types extend to an integer with size equal to the type size. + // For example, when inserting a bool this probably extends it to an i8 or + // to an i32. This approach means we get the right result on both little + // and big endian machines. + uint64_t Size = getInt64(TYPE_SIZE(type), true); + const Type *MemTy = IntegerType::get(Context, Size); + // We can extend in any way, but get nicer IR by respecting signedness. + bool isSigned = !TYPE_UNSIGNED(type); + Result = isSigned ? TheFolder->CreateSExtOrBitCast(C, MemTy) : + TheFolder->CreateZExtOrBitCast(C, MemTy); + break; + } + + case COMPLEX_TYPE: { + tree elt_type = TREE_TYPE(type); + unsigned Idx[2] = {0, 1}; + Constant *Real = TheFolder->CreateExtractValue(C, Idx, 1); + Constant *Imag = TheFolder->CreateExtractValue(C, Idx + 1, 1); + Real = EncapsulateRegister(Real, elt_type); + Imag = EncapsulateRegister(Imag, elt_type); + Constant *Vals[2] = { Real, Imag }; + Result = ConstantStruct::get(Context, Vals, 2, false); + break; + } + + case OFFSET_TYPE: + case POINTER_TYPE: + case REFERENCE_TYPE: + Result = C; + break; + + case REAL_TYPE: + // NOTE: This might be wrong for floats with precision less than their alloc + // size on big-endian machines. + // If the float precision is less than the alloc size then it will be padded + // out below. + Result = C; + break; + + case VECTOR_TYPE: { + tree elt_type = TREE_TYPE(type); + unsigned NumElts = TYPE_VECTOR_SUBPARTS(type); + std::vector Vals(NumElts); + for (unsigned i = 0; i != NumElts; ++i) { + ConstantInt *Idx = ConstantInt::get(Type::getInt32Ty(Context), i); + Vals[i] = TheFolder->CreateExtractElement(C, Idx); + Vals[i] = EncapsulateRegister(Vals[i], elt_type); + } + // The elements may have funky types, so forming a vector may not always be + // possible. + Result = ConstantStruct::get(Context, Vals, false); + break; + } + + } + + // Ensure that the result satisfies the guarantees given by ConvertInitializer + // by turning it into a type with the right size and an appropriate alignment. + Result = InterpretAsType(Result, ConvertType(type)); + + assert(C == ExtractRegisterFromConstant(Result, type) && + "Register inserted wrong!"); + + return Result; +} + /// getAsRegister - Turn the given GCC scalar constant into an LLVM constant of /// register type. static Constant *getAsRegister(tree exp) { @@ -580,24 +663,29 @@ if (type == TREE_TYPE(exp) || AGGREGATE_TYPE_P(TREE_TYPE(exp)) || AGGREGATE_TYPE_P(type)) return C; - const Type *SrcTy = ConvertType(TREE_TYPE(exp)); - const Type *DestTy = ConvertType(type); - // LLVM types are often the same even when the GCC types differ. + // No cast is needed if the LLVM types are the same. This occurs often since + // many different GCC types usually map to the same LLVM type. + const Type *SrcTy = getRegType(TREE_TYPE(exp)); + const Type *DestTy = getRegType(type); if (SrcTy == DestTy) return C; - // First ensure that the initializer has a sensible type. Note that it would - // be wrong to interpret the constant as being of type DestTy here since that - // would not perform a value extension (adding extra zeros or sign bits when - // casting to a larger integer type for example): any extra bits would get an - // undefined value instead. - C = InterpretAsType(C, SrcTy, 0); - // Now cast to the desired type. + // Ensure that the initializer has a sensible type. Note that it would be + // wrong to just interpret the constant as being of type DestTy here since + // that would not perform a value extension (adding extra zeros or sign bits + // when casting to a larger integer type for example): any extra bits would + // wrongly get an undefined value instead. + C = ExtractRegisterFromConstant(C, TREE_TYPE(exp)); + + // Cast to the desired type. bool SrcIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); bool DestIsSigned = !TYPE_UNSIGNED(type); Instruction::CastOps opcode = CastInst::getCastOpcode(C, SrcIsSigned, DestTy, DestIsSigned); - return TheFolder->CreateCast(opcode, C, DestTy); + C = TheFolder->CreateCast(opcode, C, DestTy); + + // Turn the register constant back into an in-memory constant. + return EncapsulateRegister(C, type); } /// ConvertCST - Return the given simple constant as an array of bytes. For the @@ -927,7 +1015,7 @@ // The integer type used to hold the bits was too big (for example an i24 // typically occupies 32 bits so is too big for a range of 24 bits). Turn // it into an array of bytes instead. - C = InterpretAsType(C, GetUnitType(Context, Units), 0); + C = InterpretAsType(C, GetUnitType(Context, Units)); assert(isSafeToReturnContentsDirectly(TD) && "Unit over aligned?"); return C; } @@ -1126,9 +1214,9 @@ } static Constant *ConvertBinOp_CST(tree exp) { - Constant *LHS = ConvertInitializer(TREE_OPERAND(exp, 0)); + Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0)); bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); - Constant *RHS = ConvertInitializer(TREE_OPERAND(exp, 1)); + Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1)); bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 1))); Instruction::CastOps opcode; if (LHS->getType()->isPointerTy()) { @@ -1146,24 +1234,30 @@ case MINUS_EXPR: Result = TheFolder->CreateSub(LHS, RHS); break; } - const Type *Ty = ConvertType(TREE_TYPE(exp)); + const Type *Ty = getRegType(TREE_TYPE(exp)); bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); opcode = CastInst::getCastOpcode(Result, LHSIsSigned, Ty, TyIsSigned); - return TheFolder->CreateCast(opcode, Result, Ty); + Result = TheFolder->CreateCast(opcode, Result, Ty); + + // Turn the register constant back into an in-memory constant. + return EncapsulateRegister(Result, TREE_TYPE(exp)); } static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { - Constant *Ptr = ConvertInitializer(TREE_OPERAND(exp, 0)); // The pointer. - Constant *Idx = ConvertInitializer(TREE_OPERAND(exp, 1)); // Offset in units. + Constant *Ptr = getAsRegister(TREE_OPERAND(exp, 0)); // The pointer. + Constant *Idx = getAsRegister(TREE_OPERAND(exp, 1)); // Offset in units. // Convert the pointer into an i8* and add the offset to it. Ptr = TheFolder->CreateBitCast(Ptr, GetUnitPointerType(Context)); - Constant *GEP = POINTER_TYPE_OVERFLOW_UNDEFINED ? + Constant *Result = POINTER_TYPE_OVERFLOW_UNDEFINED ? TheFolder->CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : TheFolder->CreateGetElementPtr(Ptr, &Idx, 1); // The result may be of a different pointer type. - return TheFolder->CreateBitCast(GEP, ConvertType(TREE_TYPE(exp))); + Result = TheFolder->CreateBitCast(Result, getRegType(TREE_TYPE(exp))); + + // Turn the register constant back into an in-memory constant. + return EncapsulateRegister(Result, TREE_TYPE(exp)); } static Constant *ConvertVIEW_CONVERT_EXPR(tree exp) { @@ -1189,9 +1283,7 @@ case INTEGER_CST: case REAL_CST: case VECTOR_CST: - // Make the IR easier to read by converting the bunch of bytes returned by - // ConvertCST into a less surprising type. - Init = InterpretAsType(ConvertCST(exp), ConvertType(TREE_TYPE(exp)), 0); + Init = ConvertCST(exp); break; case STRING_CST: Init = ConvertSTRING_CST(exp); @@ -1218,6 +1310,11 @@ break; } + // Make the IR easier to read by converting the bunch of bytes returned by + // ConvertCST into a less surprising type when it is safe to do so. + if (!AGGREGATE_TYPE_P(TREE_TYPE(exp))) + Init = InterpretAsType(Init, ConvertType(TREE_TYPE(exp))); + #ifndef NDEBUG // Check that the guarantees we make about the returned value actually hold. // The initializer should always be at least as big as the constructor's type, @@ -1259,9 +1356,9 @@ // Create a new global variable. Slot = new GlobalVariable(*TheModule, Init->getType(), true, GlobalVariable::PrivateLinkage, Init, ".cst"); - unsigned align = TYPE_ALIGN (TREE_TYPE (exp)); + unsigned align = TYPE_ALIGN(TREE_TYPE(exp)); #ifdef CONSTANT_ALIGNMENT - align = CONSTANT_ALIGNMENT (exp, align); + align = CONSTANT_ALIGNMENT(exp, align); #endif Slot->setAlignment(align); @@ -1351,9 +1448,7 @@ /// AddressOfINDIRECT_REF - Return the address of a dereference. static Constant *AddressOfINDIRECT_REF(tree exp) { // The address is just the dereferenced operand. Get it as an LLVM constant. - Constant *C = ConvertInitializer(TREE_OPERAND(exp, 0)); - // Make no assumptions about the type of the constant. - return InterpretAsType(C, ConvertType(TREE_TYPE(TREE_OPERAND(exp, 0))), 0); + return getAsRegister(TREE_OPERAND(exp, 0)); } /// AddressOfLABEL_DECL - Return the address of a label. @@ -1401,7 +1496,7 @@ Addr = AddressOfCOMPONENT_REF(exp); break; case COMPOUND_LITERAL_EXPR: // FIXME: not gimple - defined by C front-end - Addr = AddressOf(DECL_EXPR_DECL (TREE_OPERAND (exp, 0))); + Addr = AddressOf(DECL_EXPR_DECL(TREE_OPERAND(exp, 0))); break; case CONST_DECL: case FUNCTION_DECL: From sabre at nondot.org Tue Apr 26 15:02:45 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 20:02:45 -0000 Subject: [llvm-commits] [llvm] r130237 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Message-ID: <20110426200245.C717B2A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 15:02:45 2011 New Revision: 130237 URL: http://llvm.org/viewvc/llvm-project?rev=130237&view=rev Log: some random cleanups, no functionality change. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=130237&r1=130236&r2=130237&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Apr 26 15:02:45 2011 @@ -1384,9 +1384,9 @@ if (Value *NegVal = dyn_castNegVal(BOp1)) return new ICmpInst(ICI.getPredicate(), BOp0, NegVal); - else if (Value *NegVal = dyn_castNegVal(BOp0)) + if (Value *NegVal = dyn_castNegVal(BOp0)) return new ICmpInst(ICI.getPredicate(), NegVal, BOp1); - else if (BO->hasOneUse()) { + if (BO->hasOneUse()) { Value *Neg = Builder->CreateNeg(BOp1); Neg->takeName(BO); return new ICmpInst(ICI.getPredicate(), BOp0, Neg); @@ -2483,9 +2483,8 @@ } // (X&Z) == (Y&Z) -> (X^Y) & Z == 0 - if (Op0->hasOneUse() && Op1->hasOneUse() && - match(Op0, m_And(m_Value(A), m_Value(B))) && - match(Op1, m_And(m_Value(C), m_Value(D)))) { + if (match(Op0, m_OneUse(m_And(m_Value(A), m_Value(B)))) && + match(Op1, m_OneUse(m_And(m_Value(C), m_Value(D))))) { Value *X = 0, *Y = 0, *Z = 0; if (A == C) { @@ -2506,6 +2505,7 @@ return &I; } } + } { From clattner at apple.com Tue Apr 26 15:08:57 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 26 Apr 2011 13:08:57 -0700 Subject: [llvm-commits] [llvm] r130206 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/SimplifyCFG/2006-08-03-Crash.ll In-Reply-To: <20110426191401.GA44622@freebsd.org> References: <20110426174102.E48DB2A6C12D@llvm.org> <20110426191401.GA44622@freebsd.org> Message-ID: <27430BD2-F24A-4DF1-B0B3-6EFE2C491FDB@apple.com> On Apr 26, 2011, at 12:14 PM, Roman Divacky wrote: > this is causing some strange regressions here (with greedy regalloc but > otherwise vanilla llvm): > > before: > > cmpb $69, 41(%esp) > > after: > > movl %eax, %ecx > movb %ch, %cl > cmpb $69, %cl > > and some more That is pretty nasty codegen, but GVN is doing the right thing here, it is trading a load for some trivial integer operations. This may not be the best for code size, but it is the right thing to do. FWIW, this is one in a long series of patches I'm working on to fix PR6627 for you. Here is what the code looked like before (after straightening out control flow): movl 40(%esp), %eax cmpw $267, %ax # imm = 0x10B jne .LBB7_9 ... .LBB7_9: # %if.else cmpb $127, %al jne .LBB7_4 # BB#10: # %land.lhs.true cmpb $69, 41(%esp) jne .LBB7_4 # BB#11: # %land.lhs.true49 cmpb $76, 42(%esp) jne .LBB7_4 # BB#12: # %land.lhs.true57 cmpb $70, 43(%esp) jne .LBB7_4 # BB#13: # %if.then65 Now we have: movl 40(%esp), %eax cmpw $267, %ax # imm = 0x10B jne .LBB7_9 ... .LBB7_9: # %if.else movl %eax, %ecx cmpb $127, %cl jne .LBB7_4 # BB#10: # %if.else movl %eax, %ecx movb %ch, %cl cmpb $69, %cl jne .LBB7_4 # BB#11: # %if.else movl %eax, %ecx shrl $16, %ecx cmpb $76, %cl jne .LBB7_4 # BB#12: # %land.lhs.true57 andl $-16777216, %eax # imm = 0xFFFFFFFFFF000000 cmpl $1174405120, %eax # imm = 0x46000000 jne .LBB7_4 This instcombine patch is the next step along the way (which will probably improve this, but not get us all the way to the goal), but is causing some codegen pessimizations that I have to deal with before it can land: -------------- next part -------------- A non-text attachment was scrubbed... Name: p.patch Type: application/octet-stream Size: 1099 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110426/9580a41a/attachment.obj -------------- next part -------------- -Chris From sabre at nondot.org Tue Apr 26 15:18:20 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 20:18:20 -0000 Subject: [llvm-commits] [llvm] r130238 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/InstCombine/InstCombineCompares.cpp test/Transforms/InstCombine/icmp.ll Message-ID: <20110426201820.D2F1B2A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 15:18:20 2011 New Revision: 130238 URL: http://llvm.org/viewvc/llvm-project?rev=130238&view=rev Log: Transform: "icmp eq (trunc (lshr(X, cst1)), cst" to "icmp (and X, mask), cst" when X has multiple uses. This is useful for exposing secondary optimizations, but the X86 backend isn't ready for this when X has a single use. For example, this can disable load folding. This is inching towards resolving PR6627. Modified: llvm/trunk/lib/Target/README.txt llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/test/Transforms/InstCombine/icmp.ll Modified: llvm/trunk/lib/Target/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/README.txt?rev=130238&r1=130237&r2=130238&view=diff ============================================================================== --- llvm/trunk/lib/Target/README.txt (original) +++ llvm/trunk/lib/Target/README.txt Tue Apr 26 15:18:20 2011 @@ -2259,52 +2259,6 @@ //===---------------------------------------------------------------------===// -We should optimize this: - - %tmp = load i16* %arrayidx, align 4, !tbaa !0 - %A = trunc i16 %tmp to i8 - %cmp = icmp eq i8 %A, 127 - %B.mask = and i16 %tmp, -256 - %cmp7 = icmp eq i16 %B.mask, 17664 - %or.cond = and i1 %cmp, %cmp7 - br i1 %or.cond, label %land.lhs.true9, label %if.end - -into: - - %tmp = load i16* %arrayidx, align 4, !tbaa !0 - %0 = icmp eq i16 %tmp, 17791 - br i1 %0, label %land.lhs.true9, label %if.end - -with this patch: -Index: InstCombine/InstCombineCompares.cpp -=================================================================== ---- InstCombine/InstCombineCompares.cpp (revision 129500) -+++ InstCombine/InstCombineCompares.cpp (working copy) -@@ -2506,6 +2506,18 @@ - return &I; - } - } -+ -+ // Transform "icmp eq (trunc X), cst" to "icmp (and X, mask), cst" -+ if (Op0->hasOneUse() && match(Op0, m_Trunc(m_Value(A))) && -+ isa(Op1)) { -+ APInt MaskV = APInt::getLowBitsSet(A->getType()->getPrimitiveSizeInBits(), -+ Op0->getType()->getPrimitiveSizeInBits()); -+ Value *Mask = -+ Builder->CreateAnd(A, ConstantInt::get(A->getContext(), MaskV)); -+ return new ICmpInst(I.getPredicate(), Mask, -+ ConstantExpr::getZExt(cast(Op1), -+ Mask->getType())); -+ } - } - - { - - -Not having this is blocking resolving PR6627. - -//===---------------------------------------------------------------------===// - This code: typedef struct { Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=130238&r1=130237&r2=130238&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Apr 26 15:18:20 2011 @@ -2506,6 +2506,31 @@ } } + // Transform "icmp eq (trunc (lshr(X, cst1)), cst" to + // "icmp (and X, mask), cst" + uint64_t ShAmt = 0; + ConstantInt *Cst1; + if (Op0->hasOneUse() && + match(Op0, m_Trunc(m_OneUse(m_LShr(m_Value(A), + m_ConstantInt(ShAmt))))) && + match(Op1, m_ConstantInt(Cst1)) && + // Only do this when A has multiple uses. This is most important to do + // when it exposes other optimizations. + !A->hasOneUse()) { + unsigned ASize =cast(A->getType())->getPrimitiveSizeInBits(); + + if (ShAmt < ASize) { + APInt MaskV = + APInt::getLowBitsSet(ASize, Op0->getType()->getPrimitiveSizeInBits()); + MaskV <<= ShAmt; + + APInt CmpV = Cst1->getValue().zext(ASize); + CmpV <<= ShAmt; + + Value *Mask = Builder->CreateAnd(A, Builder->getInt(MaskV)); + return new ICmpInst(I.getPredicate(), Mask, Builder->getInt(CmpV)); + } + } } { Modified: llvm/trunk/test/Transforms/InstCombine/icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/icmp.ll?rev=130238&r1=130237&r2=130238&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/icmp.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/icmp.ll Tue Apr 26 15:18:20 2011 @@ -494,3 +494,19 @@ %C = icmp sgt i32 %B, -1 ret i1 %C } + +; CHECK: @test52 +; CHECK-NEXT: and i32 %x1, 16711935 +; CHECK-NEXT: icmp eq i32 {{.*}}, 4980863 +; CHECK-NEXT: ret i1 +define i1 @test52(i32 %x1) nounwind { + %conv = and i32 %x1, 255 + %cmp = icmp eq i32 %conv, 127 + %tmp2 = lshr i32 %x1, 16 + %tmp3 = trunc i32 %tmp2 to i8 + %cmp15 = icmp eq i8 %tmp3, 76 + + %A = and i1 %cmp, %cmp15 + ret i1 %A +} + From rdivacky at freebsd.org Tue Apr 26 15:27:35 2011 From: rdivacky at freebsd.org (Roman Divacky) Date: Tue, 26 Apr 2011 22:27:35 +0200 Subject: [llvm-commits] [llvm] r130206 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/SimplifyCFG/2006-08-03-Crash.ll In-Reply-To: <27430BD2-F24A-4DF1-B0B3-6EFE2C491FDB@apple.com> References: <20110426174102.E48DB2A6C12D@llvm.org> <20110426191401.GA44622@freebsd.org> <27430BD2-F24A-4DF1-B0B3-6EFE2C491FDB@apple.com> Message-ID: <20110426202735.GA50194@freebsd.org> On Tue, Apr 26, 2011 at 01:08:57PM -0700, Chris Lattner wrote: > On Apr 26, 2011, at 12:14 PM, Roman Divacky wrote: > > this is causing some strange regressions here (with greedy regalloc but > > otherwise vanilla llvm): > > > > before: > > > > cmpb $69, 41(%esp) > > > > after: > > > > movl %eax, %ecx > > movb %ch, %cl > > cmpb $69, %cl > > > > and some more > > That is pretty nasty codegen, but GVN is doing the right thing here, it is trading a load for some trivial integer operations. This may not be the best for code size, but it is the right thing to do. FWIW, this is one in a long series of patches I'm working on to fix PR6627 for you. > > Here is what the code looked like before (after straightening out control flow): > > movl 40(%esp), %eax > cmpw $267, %ax # imm = 0x10B > jne .LBB7_9 > ... > .LBB7_9: # %if.else > cmpb $127, %al > jne .LBB7_4 > # BB#10: # %land.lhs.true > cmpb $69, 41(%esp) > jne .LBB7_4 > # BB#11: # %land.lhs.true49 > cmpb $76, 42(%esp) > jne .LBB7_4 > # BB#12: # %land.lhs.true57 > cmpb $70, 43(%esp) > jne .LBB7_4 > # BB#13: # %if.then65 > > Now we have: > > movl 40(%esp), %eax > cmpw $267, %ax # imm = 0x10B > jne .LBB7_9 > ... > .LBB7_9: # %if.else > movl %eax, %ecx > cmpb $127, %cl > jne .LBB7_4 > # BB#10: # %if.else > movl %eax, %ecx > movb %ch, %cl > cmpb $69, %cl > jne .LBB7_4 > # BB#11: # %if.else > movl %eax, %ecx > shrl $16, %ecx > cmpb $76, %cl > jne .LBB7_4 > # BB#12: # %land.lhs.true57 > andl $-16777216, %eax # imm = 0xFFFFFFFFFF000000 > cmpl $1174405120, %eax # imm = 0x46000000 > jne .LBB7_4 > > > This instcombine patch is the next step along the way (which will probably improve this, but not get us all the way to the goal), but is causing some codegen pessimizations that I have to deal with before it can land: Yes, I realized that this is actually an improvement after I sent the mail :) Anyway, on FreeBSD boot loader I am seeing GVN hurting the codesize. Removing GVN saves 84 bytes, disabling LoadPRE but keeping the rest of GVN saves 36 bytes. Thats 0.5% - 1%. I wonder what to do. If LoadPRE in GVN generally makes things worse codesize wise maybe it should be disabled when optimizing for size? Maybe disable GVN at -Os completely? What do you think? From clattner at apple.com Tue Apr 26 15:31:04 2011 From: clattner at apple.com (Chris Lattner) Date: Tue, 26 Apr 2011 13:31:04 -0700 Subject: [llvm-commits] [llvm] r130206 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/SimplifyCFG/2006-08-03-Crash.ll In-Reply-To: <20110426202735.GA50194@freebsd.org> References: <20110426174102.E48DB2A6C12D@llvm.org> <20110426191401.GA44622@freebsd.org> <27430BD2-F24A-4DF1-B0B3-6EFE2C491FDB@apple.com> <20110426202735.GA50194@freebsd.org> Message-ID: On Apr 26, 2011, at 1:27 PM, Roman Divacky wrote: >> This instcombine patch is the next step along the way (which will probably improve this, but not get us all the way to the goal), but is causing some codegen pessimizations that I have to deal with before it can land: > > Yes, I realized that this is actually an improvement after I sent the mail :) > > Anyway, on FreeBSD boot loader I am seeing GVN hurting the codesize. > Removing GVN saves 84 bytes, disabling LoadPRE but keeping the rest > of GVN saves 36 bytes. Thats 0.5% - 1%. > > I wonder what to do. If LoadPRE in GVN generally makes things worse > codesize wise maybe it should be disabled when optimizing for size? > Maybe disable GVN at -Os completely? I don't think that there is a general problem here, I think that it is specific to idioms in your code. As I mentioned, I'm working on PR6627. If I can get it down to the "optimal" code there, I think we'll have a clear win. -Chris From sabre at nondot.org Tue Apr 26 15:45:33 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 20:45:33 -0000 Subject: [llvm-commits] [llvm] r130241 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/Transforms/PhaseOrdering/ test/Transforms/PhaseOrdering/basic.ll test/Transforms/ScalarRepl/dg.exp Message-ID: <20110426204533.E64DB2A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 15:45:33 2011 New Revision: 130241 URL: http://llvm.org/viewvc/llvm-project?rev=130241&view=rev Log: make a couple of changes to the standard pass pipeline: 1. Only run the early (in the module pass pipe) instcombine/simplifycfg if the "unit at a time" passes they are cleaning up after runs. 2. Move the "clean up after the unroller" pass to the very end of the function-level pass pipeline. Loop unroll uses instsimplify now, so it doesn't create a ton of trash. Moving instcombine later allows it to clean up after opportunities are exposed by GVN, DSE, etc. 3. Introduce some phase ordering tests for things that are specifically intended to be simplified by the full optimizer as a whole. This resolves PR2338, and is progress towards PR6627, which will be generating code that looks similar to test2. Added: llvm/trunk/test/Transforms/PhaseOrdering/ llvm/trunk/test/Transforms/PhaseOrdering/basic.ll Modified: llvm/trunk/include/llvm/Support/StandardPasses.h llvm/trunk/test/Transforms/ScalarRepl/dg.exp Modified: llvm/trunk/include/llvm/Support/StandardPasses.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/StandardPasses.h?rev=130241&r1=130240&r2=130241&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/StandardPasses.h (original) +++ llvm/trunk/include/llvm/Support/StandardPasses.h Tue Apr 26 15:45:33 2011 @@ -72,6 +72,7 @@ Pass *InliningPass) { createStandardAliasAnalysisPasses(PM); + // If all optimizations are disabled, just run the always-inline pass. if (OptimizationLevel == 0) { if (InliningPass) PM->add(InliningPass); @@ -83,9 +84,10 @@ PM->add(createIPSCCPPass()); // IP SCCP PM->add(createDeadArgEliminationPass()); // Dead argument elimination + + PM->add(createInstructionCombiningPass());// Clean up after IPCP & DAE + PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE } - PM->add(createInstructionCombiningPass()); // Clean up after IPCP & DAE - PM->add(createCFGSimplificationPass()); // Clean up after IPCP & DAE // Start of CallGraph SCC passes. if (UnitAtATime && HaveExceptions) @@ -120,7 +122,6 @@ PM->add(createLoopDeletionPass()); // Delete dead loops if (UnrollLoops) PM->add(createLoopUnrollPass()); // Unroll small loops - PM->add(createInstructionCombiningPass()); // Clean up after the unroller if (OptimizationLevel > 1) PM->add(createGVNPass()); // Remove redundancies PM->add(createMemCpyOptPass()); // Remove memcpy / form memset @@ -134,6 +135,7 @@ PM->add(createDeadStoreEliminationPass()); // Delete dead stores PM->add(createAggressiveDCEPass()); // Delete dead instructions PM->add(createCFGSimplificationPass()); // Merge & remove BBs + PM->add(createInstructionCombiningPass()); // Clean up after everything. if (UnitAtATime) { PM->add(createStripDeadPrototypesPass()); // Get rid of dead prototypes Added: llvm/trunk/test/Transforms/PhaseOrdering/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PhaseOrdering/basic.ll?rev=130241&view=auto ============================================================================== --- llvm/trunk/test/Transforms/PhaseOrdering/basic.ll (added) +++ llvm/trunk/test/Transforms/PhaseOrdering/basic.ll Tue Apr 26 15:45:33 2011 @@ -0,0 +1,73 @@ +; RUN: opt -O3 -S %s | FileCheck %s + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-macosx10.6.7" + +declare i8* @malloc(i64) +declare void @free(i8*) + + +; PR2338 +define void @test1() nounwind ssp { + %retval = alloca i32, align 4 + %i = alloca i8*, align 8 + %call = call i8* @malloc(i64 1) + store i8* %call, i8** %i, align 8 + %tmp = load i8** %i, align 8 + store i8 1, i8* %tmp + %tmp1 = load i8** %i, align 8 + call void @free(i8* %tmp1) + ret void + +; CHECK: @test1 +; CHECK-NEXT: ret void +} + + +; PR6627 - This whole nasty sequence should be flattened down to a single +; 32-bit comparison. +define void @test2(i8* %arrayidx) nounwind ssp { +entry: + %xx = bitcast i8* %arrayidx to i32* + %x1 = load i32* %xx, align 4 + %tmp = trunc i32 %x1 to i8 + %conv = zext i8 %tmp to i32 + %cmp = icmp eq i32 %conv, 127 + br i1 %cmp, label %land.lhs.true, label %if.end + +land.lhs.true: ; preds = %entry + %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 + %tmp5 = load i8* %arrayidx4, align 1 + %conv6 = zext i8 %tmp5 to i32 + %cmp7 = icmp eq i32 %conv6, 69 + br i1 %cmp7, label %land.lhs.true9, label %if.end + +land.lhs.true9: ; preds = %land.lhs.true + %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 + %tmp13 = load i8* %arrayidx12, align 1 + %conv14 = zext i8 %tmp13 to i32 + %cmp15 = icmp eq i32 %conv14, 76 + br i1 %cmp15, label %land.lhs.true17, label %if.end + +land.lhs.true17: ; preds = %land.lhs.true9 + %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 + %tmp21 = load i8* %arrayidx20, align 1 + %conv22 = zext i8 %tmp21 to i32 + %cmp23 = icmp eq i32 %conv22, 70 + br i1 %cmp23, label %if.then, label %if.end + +if.then: ; preds = %land.lhs.true17 + %call25 = call i32 (...)* @doo() + br label %if.end + +if.end: ; preds = %if.then, %land.lhs.true17, %land.lhs.true9, %land.lhs.true, %entry + ret void + +; CHECK: @test2 +; CHECK: %x1 = load i32* %xx, align 4 +; CHECK-NEXT: icmp eq i32 %x1, 1179403647 +; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end +} + +declare i32 @doo(...) + Modified: llvm/trunk/test/Transforms/ScalarRepl/dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ScalarRepl/dg.exp?rev=130241&r1=130240&r2=130241&view=diff ============================================================================== --- llvm/trunk/test/Transforms/ScalarRepl/dg.exp (original) +++ llvm/trunk/test/Transforms/ScalarRepl/dg.exp Tue Apr 26 15:45:33 2011 @@ -1,3 +1,3 @@ load_lib llvm.exp -RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,c,cpp}]] +RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll}]] From evan.cheng at apple.com Tue Apr 26 16:09:04 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 26 Apr 2011 21:09:04 -0000 Subject: [llvm-commits] [llvm] r130243 - /llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll Message-ID: <20110426210904.2DFB02A6C12D@llvm.org> Author: evancheng Date: Tue Apr 26 16:09:04 2011 New Revision: 130243 URL: http://llvm.org/viewvc/llvm-project?rev=130243&view=rev Log: This test should be in MC. It breaks with changes to scheduling / register allocation so it's being removed. Removed: llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll Removed: llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll?rev=130242&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2010-12-13-reloc-pic.ll (removed) @@ -1,100 +0,0 @@ -; RUN: llc %s -mtriple=armv7-linux-gnueabi -relocation-model=pic -filetype=obj -o - | \ -; RUN: elf-dump --dump-section-data | FileCheck -check-prefix=PIC01 %s - -;; FIXME: Reduce this test further, or even better, -;; redo as .s -> .o test once ARM AsmParser is working better - -; ModuleID = 'large2.pnacl.bc' -target triple = "armv7-none-linux-gnueabi" - -%struct._Bigint = type { %struct._Bigint*, i32, i32, i32, i32, [1 x i32] } -%struct.__FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, %struct._reent*, i8*, i32 (%struct._reent*, i8*, i8*, i32)*, i32 (%struct._reent*, i8*, i8*, i32)*, i32 (%struct._reent*, i8*, i32, i32)*, i32 (%struct._reent*, i8*)*, %struct.__sbuf, i8*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i32, %struct._flock_t, %struct._mbstate_t, i32 } -%struct.__sbuf = type { i8*, i32 } -%struct.__tm = type { i32, i32, i32, i32, i32, i32, i32, i32, i32 } -%struct._atexit = type { %struct._atexit*, i32, [32 x void ()*], %struct._on_exit_args* } -%struct._flock_t = type { i32, i32, i32, i32, i32 } -%struct._glue = type { %struct._glue*, i32, %struct.__FILE* } -%struct._mbstate_t = type { i32, %union.anon } -%struct._misc_reent = type { i8*, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, [8 x i8], i32, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t, %struct._mbstate_t } -%struct._mprec = type { %struct._Bigint*, i32, %struct._Bigint*, %struct._Bigint** } -%struct._on_exit_args = type { [32 x i8*], [32 x i8*], i32, i32 } -%struct._rand48 = type { [3 x i16], [3 x i16], i16, i64 } -%struct._reent = type { %struct.__FILE*, %struct.__FILE*, %struct.__FILE*, i32, i32, i8*, i32, i32, i8*, %struct._mprec*, void (%struct._reent*)*, i32, i32, i8*, %struct._rand48*, %struct.__tm*, i8*, void (i32)**, %struct._atexit*, %struct._atexit, %struct._glue, %struct.__FILE*, %struct._misc_reent*, i8* } -%union.anon = type { i32 } - - at buf = constant [2 x i8] c"x\00", align 4 - at _impure_ptr = external thread_local global %struct._reent* - at .str = private constant [22 x i8] c"This should fault...\0A\00", align 4 - at .str1 = private constant [40 x i8] c"We're still running. This is not good.\0A\00", align 4 - -define i32 @main() nounwind { -entry: - %0 = load %struct._reent** @_impure_ptr, align 4 - %1 = getelementptr inbounds %struct._reent* %0, i32 0, i32 1 - %2 = load %struct.__FILE** %1, align 4 - %3 = bitcast %struct.__FILE* %2 to i8* - %4 = tail call i32 @fwrite(i8* getelementptr inbounds ([22 x i8]* @.str, i32 0, i32 0), i32 1, i32 21, i8* %3) nounwind - %5 = load %struct._reent** @_impure_ptr, align 4 - %6 = getelementptr inbounds %struct._reent* %5, i32 0, i32 1 - %7 = load %struct.__FILE** %6, align 4 - %8 = tail call i32 @fflush(%struct.__FILE* %7) nounwind - store i8 121, i8* getelementptr inbounds ([2 x i8]* @buf, i32 0, i32 0), align 4 - %9 = load %struct._reent** @_impure_ptr, align 4 - %10 = getelementptr inbounds %struct._reent* %9, i32 0, i32 1 - %11 = load %struct.__FILE** %10, align 4 - %12 = bitcast %struct.__FILE* %11 to i8* - %13 = tail call i32 @fwrite(i8* getelementptr inbounds ([40 x i8]* @.str1, i32 0, i32 0), i32 1, i32 39, i8* %12) nounwind - ret i32 1 -} - - -; PIC01: Relocation 0x00000000 -; PIC01-NEXT: 'r_offset', 0x0000001c -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x0000001b - - -; PIC01: Relocation 0x00000001 -; PIC01-NEXT: 'r_offset', 0x00000038 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x0000001b - -; PIC01: Relocation 0x00000002 -; PIC01-NEXT: 'r_offset', 0x00000044 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x0000001b - -; PIC01: Relocation 0x00000003 -; PIC01-NEXT: 'r_offset', 0x00000070 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x0000001b - -; PIC01: Relocation 0x00000004 -; PIC01-NEXT: 'r_offset', 0x0000007c -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x00000019 - - -; PIC01: Relocation 0x00000005 -; PIC01-NEXT: 'r_offset', 0x00000080 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x00000018 - -; PIC01: Relocation 0x00000006 -; PIC01-NEXT: 'r_offset', 0x00000084 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x00000068 - -; PIC01: Relocation 0x00000007 -; PIC01-NEXT: 'r_offset', 0x00000088 -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x0000001a - -; PIC01: Relocation 0x00000008 -; PIC01-NEXT: 'r_offset', 0x0000008c -; PIC01-NEXT: 'r_sym' -; PIC01-NEXT: 'r_type', 0x00000018 - -declare i32 @fwrite(i8* nocapture, i32, i32, i8* nocapture) nounwind - -declare i32 @fflush(%struct.__FILE* nocapture) nounwind From evan.cheng at apple.com Tue Apr 26 16:31:36 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 26 Apr 2011 21:31:36 -0000 Subject: [llvm-commits] [llvm] r130245 - in /llvm/trunk: include/llvm/CodeGen/ScheduleDAG.h lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp test/CodeGen/ARM/2011-04-26-SchedTweak.ll test/CodeGen/ARM/shifter_operand.ll test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll test/CodeGen/X86/pic.ll Message-ID: <20110426213136.431B72A6C12D@llvm.org> Author: evancheng Date: Tue Apr 26 16:31:35 2011 New Revision: 130245 URL: http://llvm.org/viewvc/llvm-project?rev=130245&view=rev Log: Be careful about scheduling nodes above previous calls. It increase usages of more callee-saved registers and introduce copies. Only allows it if scheduling a node above calls would end up lessen register pressure. Call operands also has added ABI restrictions for register allocation, so be extra careful with hoisting them above calls. rdar://9329627 Added: llvm/trunk/test/CodeGen/ARM/2011-04-26-SchedTweak.ll Removed: llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp llvm/trunk/test/CodeGen/ARM/shifter_operand.ll llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll llvm/trunk/test/CodeGen/X86/pic.ll Modified: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h (original) +++ llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h Tue Apr 26 16:31:35 2011 @@ -252,6 +252,7 @@ unsigned short Latency; // Node latency. bool isVRegCycle : 1; // May use and def the same vreg. bool isCall : 1; // Is a function call. + bool isCallOp : 1; // Is a function call operand. bool isTwoAddress : 1; // Is a two-address instruction. bool isCommutable : 1; // Is a commutable instruction. bool hasPhysRegDefs : 1; // Has physreg defs that are being used. @@ -280,7 +281,7 @@ : Node(node), Instr(0), OrigNode(0), NodeNum(nodenum), NodeQueueId(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0), NumRegDefsLeft(0), Latency(0), - isVRegCycle(false), isCall(false), isTwoAddress(false), + isVRegCycle(false), isCall(false), isCallOp(false), isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false), hasPhysRegClobbers(false), isPending(false), isAvailable(false), isScheduled(false), isScheduleHigh(false), isScheduleLow(false), isCloned(false), @@ -294,7 +295,7 @@ : Node(0), Instr(instr), OrigNode(0), NodeNum(nodenum), NodeQueueId(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0), NumRegDefsLeft(0), Latency(0), - isVRegCycle(false), isCall(false), isTwoAddress(false), + isVRegCycle(false), isCall(false), isCallOp(false), isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false), hasPhysRegClobbers(false), isPending(false), isAvailable(false), isScheduled(false), isScheduleHigh(false), isScheduleLow(false), isCloned(false), @@ -307,7 +308,7 @@ : Node(0), Instr(0), OrigNode(0), NodeNum(~0u), NodeQueueId(0), NumPreds(0), NumSuccs(0), NumPredsLeft(0), NumSuccsLeft(0), NumRegDefsLeft(0), Latency(0), - isVRegCycle(false), isCall(false), isTwoAddress(false), + isVRegCycle(false), isCall(false), isCallOp(false), isTwoAddress(false), isCommutable(false), hasPhysRegDefs(false), hasPhysRegClobbers(false), isPending(false), isAvailable(false), isScheduled(false), isScheduleHigh(false), isScheduleLow(false), isCloned(false), Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp Tue Apr 26 16:31:35 2011 @@ -1732,7 +1732,17 @@ // If SU does not have a register def, schedule it close to its uses // because it does not lengthen any live ranges. return 0; +#if 1 return SethiUllmanNumbers[SU->NodeNum]; +#else + unsigned Priority = SethiUllmanNumbers[SU->NodeNum]; + if (SU->isCallOp) { + // FIXME: This assumes all of the defs are used as call operands. + int NP = (int)Priority - SU->getNode()->getNumValues(); + return (NP > 0) ? NP : 0; + } + return Priority; +#endif } //===----------------------------------------------------------------------===// @@ -2238,11 +2248,35 @@ // Prioritize by Sethi-Ulmann number and push CopyToReg nodes down. unsigned LPriority = SPQ->getNodePriority(left); unsigned RPriority = SPQ->getNodePriority(right); + + // Be really careful about hoisting call operands above previous calls. + // Only allows it if it would reduce register pressure. + if (left->isCall && right->isCallOp) { + unsigned RNumVals = right->getNode()->getNumValues(); + RPriority = (RPriority > RNumVals) ? (RPriority - RNumVals) : 0; + } + if (right->isCall && left->isCallOp) { + unsigned LNumVals = left->getNode()->getNumValues(); + LPriority = (LPriority > LNumVals) ? (LPriority - LNumVals) : 0; + } + if (LPriority != RPriority) { DEBUG(++FactorCount[FactStatic]); return LPriority > RPriority; } + // One or both of the nodes are calls and their sethi-ullman numbers are the + // same, then keep source order. + if (left->isCall || right->isCall) { + unsigned LOrder = SPQ->getNodeOrdering(left); + unsigned ROrder = SPQ->getNodeOrdering(right); + + // Prefer an ordering where the lower the non-zero order number, the higher + // the preference. + if ((LOrder || ROrder) && LOrder != ROrder) + return LOrder != 0 && (LOrder < ROrder || ROrder == 0); + } + // Try schedule def + use closer when Sethi-Ullman numbers are the same. // e.g. // t1 = op t2, c1 @@ -2275,7 +2309,14 @@ return LScratch > RScratch; } - if (!DisableSchedCycles) { + // Comparing latency against a call makes little sense unless the node + // is register pressure-neutral. + if ((left->isCall && RPriority > 0) || (right->isCall && LPriority > 0)) + return (left->NodeQueueId > right->NodeQueueId); + + // Do not compare latencies when one or both of the nodes are calls. + if (!DisableSchedCycles && + !(left->isCall || right->isCall)) { int result = BUCompareLatency(left, right, false /*checkPref*/, SPQ); if (result != 0) return result > 0; Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Tue Apr 26 16:31:35 2011 @@ -83,6 +83,7 @@ SU->Latency = Old->Latency; SU->isVRegCycle = Old->isVRegCycle; SU->isCall = Old->isCall; + SU->isCallOp = Old->isCallOp; SU->isTwoAddress = Old->isTwoAddress; SU->isCommutable = Old->isCommutable; SU->hasPhysRegDefs = Old->hasPhysRegDefs; @@ -285,6 +286,7 @@ Worklist.push_back(DAG->getRoot().getNode()); Visited.insert(DAG->getRoot().getNode()); + SmallVector CallSUnits; while (!Worklist.empty()) { SDNode *NI = Worklist.pop_back_val(); @@ -337,6 +339,9 @@ if (!HasGlueUse) break; } + if (NodeSUnit->isCall) + CallSUnits.push_back(NodeSUnit); + // Schedule zero-latency TokenFactor below any nodes that may increase the // schedule height. Otherwise, ancestors of the TokenFactor may appear to // have false stalls. @@ -356,6 +361,20 @@ // Assign the Latency field of NodeSUnit using target-provided information. ComputeLatency(NodeSUnit); } + + // Find all call operands. + while (!CallSUnits.empty()) { + SUnit *SU = CallSUnits.pop_back_val(); + for (const SDNode *SUNode = SU->getNode(); SUNode; + SUNode = SUNode->getGluedNode()) { + if (SUNode->getOpcode() != ISD::CopyToReg) + continue; + SDNode *SrcN = SUNode->getOperand(2).getNode(); + if (isPassiveNode(SrcN)) continue; // Not scheduled. + SUnit *SrcSU = &SUnits[SrcN->getNodeId()]; + SrcSU->isCallOp = true; + } + } } void ScheduleDAGSDNodes::AddSchedEdges() { Added: llvm/trunk/test/CodeGen/ARM/2011-04-26-SchedTweak.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-04-26-SchedTweak.ll?rev=130245&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-04-26-SchedTweak.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2011-04-26-SchedTweak.ll Tue Apr 26 16:31:35 2011 @@ -0,0 +1,70 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-ios -relocation-model=pic -mcpu=cortex-a8 | FileCheck %s + +; Do not move the umull above previous call which would require use of +; more callee-saved registers and introduce copies. +; rdar://9329627 + +%struct.FF = type { i32 (i32*)*, i32 (i32*, i32*, i32, i32, i32, i32)*, i32 (i32, i32, i8*)*, void ()*, i32 (i32, i8*, i32*)*, i32 ()* } +%struct.BD = type { %struct.BD*, i32, i32, i32, i32, i64, i32 (%struct.BD*, i8*, i64, i32)*, i32 (%struct.BD*, i8*, i32, i32)*, i32 (%struct.BD*, i8*, i64, i32)*, i32 (%struct.BD*, i8*, i32, i32)*, i32 (%struct.BD*, i64, i32)*, [16 x i8], i64, i64 } + + at FuncPtr = external hidden unnamed_addr global %struct.FF* + at .str1 = external hidden unnamed_addr constant [6 x i8], align 4 + at G = external unnamed_addr global i32 + at .str2 = external hidden unnamed_addr constant [58 x i8], align 4 + at .str3 = external hidden unnamed_addr constant [58 x i8], align 4 + +define i32 @test() nounwind optsize ssp { +entry: +; CHECK: test: +; CHECK: push +; CHECK-NOT: push + %block_size = alloca i32, align 4 + %block_count = alloca i32, align 4 + %index_cache = alloca i32, align 4 + store i32 0, i32* %index_cache, align 4 + %tmp = load i32* @G, align 4 + %tmp1 = call i32 @bar(i32 0, i32 0, i32 %tmp) nounwind + switch i32 %tmp1, label %bb8 [ + i32 0, label %bb + i32 536870913, label %bb4 + i32 536870914, label %bb6 + ] + +bb: + %tmp2 = load i32* @G, align 4 + %tmp4 = icmp eq i32 %tmp2, 0 + br i1 %tmp4, label %bb1, label %bb8 + +bb1: +; CHECK: %bb1 +; CHECK-NOT: umull +; CHECK: blx _Get +; CHECK: umull +; CHECK: blx _foo + %tmp5 = load i32* %block_size, align 4 + %tmp6 = load i32* %block_count, align 4 + %tmp7 = call %struct.FF* @Get() nounwind + store %struct.FF* %tmp7, %struct.FF** @FuncPtr, align 4 + %tmp10 = zext i32 %tmp6 to i64 + %tmp11 = zext i32 %tmp5 to i64 + %tmp12 = mul nsw i64 %tmp10, %tmp11 + %tmp13 = call i32 @foo(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0), i64 %tmp12, i32 %tmp5) nounwind + br label %bb8 + +bb4: + ret i32 0 + +bb6: + ret i32 1 + +bb8: + ret i32 -1 +} + +declare i32 @printf(i8*, ...) + +declare %struct.FF* @Get() + +declare i32 @foo(i8*, i64, i32) + +declare i32 @bar(i32, i32, i32) Modified: llvm/trunk/test/CodeGen/ARM/shifter_operand.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/shifter_operand.ll?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/shifter_operand.ll (original) +++ llvm/trunk/test/CodeGen/ARM/shifter_operand.ll Tue Apr 26 16:31:35 2011 @@ -58,7 +58,7 @@ ; A8: str r2, [r0, r1, lsl #2] ; A9: test4: -; A9: add r0, r0, r4, lsl #2 +; A9: add r0, r0, r{{[0-9]+}}, lsl #2 ; A9: ldr r1, [r0] ; A9: str r1, [r0] %0 = tail call i8* (...)* @malloc(i32 undef) nounwind Removed: llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll?rev=130244&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/2010-01-15-local-alloc-spill-physical.ll (removed) @@ -1,20 +0,0 @@ -; RUN: llc < %s -regalloc=fast -relocation-model=pic | FileCheck %s - -target triple = "thumbv6-apple-darwin10" - - at fred = internal global i32 0 ; [#uses=1] - -define void @foo() nounwind { -entry: -; CHECK: str r0, [sp - %0 = call i32 (...)* @bar() nounwind ; [#uses=1] -; CHECK: blx _bar -; CHECK: ldr r1, [sp - store i32 %0, i32* @fred, align 4 - br label %return - -return: ; preds = %entry - ret void -} - -declare i32 @bar(...) Modified: llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/2009-10-15-ITBlockBranch.ll Tue Apr 26 16:31:35 2011 @@ -13,7 +13,7 @@ ; CHECK: _ZNKSs7compareERKSs: ; CHECK: it eq ; CHECK-NEXT: subeq r0, r{{[0-9]+}}, r{{[0-9]+}} -; CHECK-NEXT: ldmia.w sp!, {r4, r5, r6, r7, r8, pc} +; CHECK-NEXT: ldmia.w sp!, entry: %0 = tail call arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string,std::allocator >"* %this) ; [#uses=3] %1 = tail call arm_aapcs_vfpcc i32 @_ZNKSs4sizeEv(%"struct.std::basic_string,std::allocator >"* %__str) ; [#uses=3] Modified: llvm/trunk/test/CodeGen/X86/pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pic.ll?rev=130245&r1=130244&r2=130245&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/pic.ll Tue Apr 26 16:31:35 2011 @@ -79,8 +79,8 @@ ; LINUX-NEXT: .L3$pb: ; LINUX: popl ; LINUX: addl $_GLOBAL_OFFSET_TABLE_+(.L{{.*}}-.L3$pb), %[[REG3:e..]] -; LINUX: movl pfoo at GOT(%[[REG3]]), ; LINUX: calll afoo at PLT +; LINUX: movl pfoo at GOT(%[[REG3]]), ; LINUX: calll * } From sabre at nondot.org Tue Apr 26 16:50:51 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 21:50:51 -0000 Subject: [llvm-commits] [llvm] r130247 - in /llvm/trunk: lib/Analysis/MemoryDependenceAnalysis.cpp test/Transforms/GVN/invariant-simple.ll Message-ID: <20110426215051.38F932A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 16:50:51 2011 New Revision: 130247 URL: http://llvm.org/viewvc/llvm-project?rev=130247&view=rev Log: remove support for llvm.invariant.end from memdep. It is a work-in-progress that is not progressing, and it has issues. Removed: llvm/trunk/test/Transforms/GVN/invariant-simple.ll Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=130247&r1=130246&r2=130247&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Apr 26 16:50:51 2011 @@ -229,37 +229,14 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB) { - Value *InvariantTag = 0; - // Walk backwards through the basic block, looking for dependencies. while (ScanIt != BB->begin()) { Instruction *Inst = --ScanIt; - // If we're in an invariant region, no dependencies can be found before - // we pass an invariant-begin marker. - if (InvariantTag == Inst) { - InvariantTag = 0; - continue; - } - if (IntrinsicInst *II = dyn_cast(Inst)) { // Debug intrinsics don't (and can't) cause dependences. if (isa(II)) continue; - // If we pass an invariant-end marker, then we've just entered an - // invariant region and can start ignoring dependencies. - if (II->getIntrinsicID() == Intrinsic::invariant_end) { - // FIXME: This only considers queries directly on the invariant-tagged - // pointer, not on query pointers that are indexed off of them. It'd - // be nice to handle that at some point. - AliasAnalysis::AliasResult R = - AA->alias(AliasAnalysis::Location(II->getArgOperand(2)), MemLoc); - if (R == AliasAnalysis::MustAlias) - InvariantTag = II->getArgOperand(0); - - continue; - } - // If we reach a lifetime begin or end marker, then the query ends here // because the value is undefined. if (II->getIntrinsicID() == Intrinsic::lifetime_start) { @@ -274,13 +251,6 @@ } } - // If we're querying on a load and we're in an invariant region, we're done - // at this point. Nothing a load depends on can live in an invariant region. - // - // FIXME: this will prevent us from returning load/load must-aliases, so GVN - // won't remove redundant loads. - if (isLoad && InvariantTag) continue; - // Values depend on loads if the pointers are must aliased. This means that // a load depends on another must aliased load from the same value. if (LoadInst *LI = dyn_cast(Inst)) { @@ -315,10 +285,6 @@ } if (StoreInst *SI = dyn_cast(Inst)) { - // There can't be stores to the value we care about inside an - // invariant region. - if (InvariantTag) continue; - // If alias analysis can tell that this store is guaranteed to not modify // the query pointer, ignore it. Use getModRefInfo to handle cases where // the query pointer points to constant memory etc. @@ -363,9 +329,6 @@ // If the call has no effect on the queried pointer, just ignore it. continue; case AliasAnalysis::Mod: - // If we're in an invariant region, we can ignore calls that ONLY - // modify the pointer. - if (InvariantTag) continue; return MemDepResult::getClobber(Inst); case AliasAnalysis::Ref: // If the call is known to never store to the pointer, and if this is a Removed: llvm/trunk/test/Transforms/GVN/invariant-simple.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/invariant-simple.ll?rev=130246&view=auto ============================================================================== --- llvm/trunk/test/Transforms/GVN/invariant-simple.ll (original) +++ llvm/trunk/test/Transforms/GVN/invariant-simple.ll (removed) @@ -1,36 +0,0 @@ -; RUN: opt < %s -basicaa -gvn -S | FileCheck %s - -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" -target triple = "i386-apple-darwin7" - -define i8 @test(i8* %P) nounwind { -; CHECK: @test -; CHECK-NOT: load -; CHECK: ret i8 -entry: - store i8 1, i8* %P - %0 = call {}* @llvm.invariant.start(i64 32, i8* %P) - %1 = tail call i32 @foo(i8* %P) - call void @llvm.invariant.end({}* %0, i64 32, i8* %P) - %2 = load i8* %P - ret i8 %2 -} - -define i8 @test2(i8* %P) nounwind { -; CHECK: @test2 -; CHECK: store i8 1 -; CHECK: store i8 2 -; CHECK: ret i8 0 -entry: - store i8 1, i8* %P - %0 = call {}* @llvm.invariant.start(i64 32, i8* %P) - %1 = tail call i32 @bar(i8* %P) - call void @llvm.invariant.end({}* %0, i64 32, i8* %P) - store i8 2, i8* %P - ret i8 0 -} - -declare i32 @foo(i8*) nounwind -declare i32 @bar(i8*) nounwind readonly -declare {}* @llvm.invariant.start(i64 %S, i8* nocapture %P) readonly -declare void @llvm.invariant.end({}* %S, i64 %SS, i8* nocapture %P) From sabre at nondot.org Tue Apr 26 16:53:34 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 21:53:34 -0000 Subject: [llvm-commits] [llvm] r130248 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <20110426215334.B5E852A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 16:53:34 2011 New Revision: 130248 URL: http://llvm.org/viewvc/llvm-project?rev=130248&view=rev Log: use AA::isMustAlias to simplify some calls. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=130248&r1=130247&r2=130248&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Apr 26 16:53:34 2011 @@ -243,9 +243,8 @@ // FIXME: This only considers queries directly on the invariant-tagged // pointer, not on query pointers that are indexed off of them. It'd // be nice to handle that at some point. - AliasAnalysis::AliasResult R = - AA->alias(AliasAnalysis::Location(II->getArgOperand(1)), MemLoc); - if (R == AliasAnalysis::MustAlias) + if (AA->isMustAlias(AliasAnalysis::Location(II->getArgOperand(1)), + MemLoc)) return MemDepResult::getDef(II); continue; } @@ -317,8 +316,7 @@ (isa(Inst) && extractMallocCall(Inst))) { const Value *AccessPtr = GetUnderlyingObject(MemLoc.Ptr, TD); - if (AccessPtr == Inst || - AA->alias(Inst, 1, AccessPtr, 1) == AliasAnalysis::MustAlias) + if (AccessPtr == Inst || AA->isMustAlias(Inst, AccessPtr)) return MemDepResult::getDef(Inst); continue; } From lenny at Colorado.EDU Tue Apr 26 17:21:29 2011 From: lenny at Colorado.EDU (Lenny Maiorani) Date: Tue, 26 Apr 2011 16:21:29 -0600 Subject: [llvm-commits] [PATCH] review request - bounded case-insensitive StringRef compare Message-ID: <4DB74569.2060305@colorado.edu> This patch adds bounded case-insensitive compare to StringRef class, imitating strncasecmp(). Includes unit tests. Please review. -Lenny -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-bounded-case-insensitive-stringref-compare.diff Type: text/x-patch Size: 3144 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110426/82d289f0/attachment.bin From stoklund at 2pi.dk Tue Apr 26 17:33:12 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 26 Apr 2011 22:33:12 -0000 Subject: [llvm-commits] [llvm] r130249 - in /llvm/trunk/lib/CodeGen: RegAllocGreedy.cpp SplitKit.cpp SplitKit.h Message-ID: <20110426223312.9A6A32A6C12D@llvm.org> Author: stoklund Date: Tue Apr 26 17:33:12 2011 New Revision: 130249 URL: http://llvm.org/viewvc/llvm-project?rev=130249&view=rev Log: Add a safe-guard against repeated splitting for some rare cases. The number of blocks covered by a live range must be strictly decreasing when splitting, otherwise we can't allow repeated splitting. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=130249&r1=130248&r2=130249&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Tue Apr 26 17:33:12 2011 @@ -921,6 +921,7 @@ SmallVector IntvMap; SE->finish(&IntvMap); LRStage.resize(MRI->getNumVirtRegs()); + unsigned OrigBlocks = SA->getNumThroughBlocks() + SA->getUseBlocks().size(); // Sort out the new intervals created by splitting. We get four kinds: // - Remainder intervals should not be split again. @@ -941,9 +942,20 @@ continue; } - // Other intervals are treated as new. This includes the main interval, - // local intervals created for blocks with multiple uses, and anything - // created by DCE. + // Main interval. Allow repeated splitting as long as the number of live + // blocks is strictly decreasing. + if (IntvMap[i] == MainIntv) { + if (SA->countLiveBlocks(LREdit.get(i)) >= OrigBlocks) { + DEBUG(dbgs() << "Main interval covers the same " << OrigBlocks + << " blocks as original.\n"); + // Don't allow repeated splitting as a safe guard against looping. + LRStage[Reg] = RS_Global; + } + continue; + } + + // Other intervals are treated as new. This includes local intervals created + // for blocks with multiple uses, and anything created by DCE. } if (VerifyEnabled) Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=130249&r1=130248&r2=130249&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Apr 26 17:33:12 2011 @@ -221,6 +221,29 @@ return true; } +unsigned SplitAnalysis::countLiveBlocks(const LiveInterval *cli) const { + if (cli->empty()) + return 0; + LiveInterval *li = const_cast(cli); + LiveInterval::iterator LVI = li->begin(); + LiveInterval::iterator LVE = li->end(); + unsigned Count = 0; + + // Loop over basic blocks where li is live. + MachineFunction::const_iterator MFI = LIS.getMBBFromIndex(LVI->start); + SlotIndex Stop = LIS.getMBBEndIdx(MFI); + for (;;) { + ++Count; + LVI = li->advanceTo(LVI, Stop); + if (LVI == LVE) + return Count; + do { + ++MFI; + Stop = LIS.getMBBEndIdx(MFI); + } while (Stop <= LVI->start); + } +} + bool SplitAnalysis::isOriginalEndpoint(SlotIndex Idx) const { unsigned OrigReg = VRM.getOriginal(CurLI->reg); const LiveInterval &Orig = LIS.getInterval(OrigReg); Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=130249&r1=130248&r2=130249&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Apr 26 17:33:12 2011 @@ -150,6 +150,11 @@ /// getThroughBlocks - Return the set of through blocks. const BitVector &getThroughBlocks() const { return ThroughBlocks; } + /// countLiveBlocks - Return the number of blocks where li is live. + /// This is guaranteed to return the same number as getNumThroughBlocks() + + /// getUseBlocks().size() after calling analyze(li). + unsigned countLiveBlocks(const LiveInterval *li) const; + typedef SmallPtrSet BlockPtrSet; /// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from From sabre at nondot.org Tue Apr 26 17:42:01 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 26 Apr 2011 22:42:01 -0000 Subject: [llvm-commits] [llvm] r130250 - /llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Message-ID: <20110426224201.D6A402A6C12D@llvm.org> Author: lattner Date: Tue Apr 26 17:42:01 2011 New Revision: 130250 URL: http://llvm.org/viewvc/llvm-project?rev=130250&view=rev Log: Enhance memdep to return clobber relation between noalias loads when an earlier load could be widened to encompass a later load. For example, if we see: X = load i8* P, align 4 Y = load i8* (P+3), align 1 and we have a 32-bit native integer type, we can widen the former load to i32 which then makes the second load redundant. GVN can't actually do anything with this load/load relation yet, so this isn't testable, but it is the next step to resolving PR6627, and a fairly general class of "merge neighboring loads" missed optimizations. Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=130250&r1=130249&r2=130250&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Tue Apr 26 17:42:01 2011 @@ -16,6 +16,7 @@ #define DEBUG_TYPE "memdep" #include "llvm/Analysis/MemoryDependenceAnalysis.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" #include "llvm/Function.h" @@ -221,6 +222,75 @@ return MemDepResult::getClobber(ScanIt); } +/// isLoadLoadClobberIfExtendedToFullWidth - Return true if LI is a load that +/// would fully overlap MemLoc if done as a wider legal integer load. +/// +/// MemLocBase, MemLocOffset are lazily computed here the first time the +/// base/offs of memloc is needed. +static bool +isLoadLoadClobberIfExtendedToFullWidth(const AliasAnalysis::Location &MemLoc, + const Value *&MemLocBase, + int64_t &MemLocOffs, + const LoadInst *LI, TargetData *TD) { + // If we have no target data, we can't do this. + if (TD == 0) return false; + + // If we haven't already computed the base/offset of MemLoc, do so now. + if (MemLocBase == 0) + MemLocBase = GetPointerBaseWithConstantOffset(MemLoc.Ptr, MemLocOffs, *TD); + + // Get the base of this load. + int64_t LIOffs = 0; + const Value *LIBase = + GetPointerBaseWithConstantOffset(LI->getPointerOperand(), LIOffs, *TD); + + // If the two pointers are not based on the same pointer, we can't tell that + // they are related. + if (LIBase != MemLocBase) return false; + + // Okay, the two values are based on the same pointer, but returned as + // no-alias. This happens when we have things like two byte loads at "P+1" + // and "P+3". Check to see if increasing the size of the "LI" load up to its + // alignment (or the largest native integer type) will allow us to load all + // the bits required by MemLoc. + + // If MemLoc is before LI, then no widening of LI will help us out. + if (MemLocOffs < LIOffs) return false; + + // Get the alignment of the load in bytes. We assume that it is safe to load + // any legal integer up to this size without a problem. For example, if we're + // looking at an i8 load on x86-32 that is known 1024 byte aligned, we can + // widen it up to an i32 load. If it is known 2-byte aligned, we can widen it + // to i16. + unsigned LoadAlign = LI->getAlignment(); + + int64_t MemLocEnd = MemLocOffs+MemLoc.Size; + + // If no amount of rounding up will let MemLoc fit into LI, then bail out. + if (LIOffs+LoadAlign < MemLocEnd) return false; + + // This is the size of the load to try. Start with the next larger power of + // two. + unsigned NewLoadByteSize = LI->getType()->getPrimitiveSizeInBits()/8U; + NewLoadByteSize = NextPowerOf2(NewLoadByteSize); + + while (1) { + // If this load size is bigger than our known alignment or would not fit + // into a native integer register, then we fail. + if (NewLoadByteSize > LoadAlign || + !TD->fitsInLegalInteger(NewLoadByteSize*8)) + return false; + + // If a load of this width would include all of MemLoc, then we succeed. + if (LIOffs+NewLoadByteSize >= MemLocEnd) + return true; + + NewLoadByteSize <<= 1; + } + + return false; +} + /// getPointerDependencyFrom - Return the instruction on which a memory /// location depends. If isLoad is true, this routine ignores may-aliases with /// read-only operations. If isLoad is false, this routine ignores may-aliases @@ -229,6 +299,9 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad, BasicBlock::iterator ScanIt, BasicBlock *BB) { + const Value *MemLocBase = 0; + int64_t MemLocOffset = 0; + // Walk backwards through the basic block, looking for dependencies. while (ScanIt != BB->begin()) { Instruction *Inst = --ScanIt; @@ -242,7 +315,8 @@ if (II->getIntrinsicID() == Intrinsic::lifetime_start) { // FIXME: This only considers queries directly on the invariant-tagged // pointer, not on query pointers that are indexed off of them. It'd - // be nice to handle that at some point. + // be nice to handle that at some point (the right approach is to use + // GetPointerBaseWithConstantOffset). if (AA->isMustAlias(AliasAnalysis::Location(II->getArgOperand(1)), MemLoc)) return MemDepResult::getDef(II); @@ -257,10 +331,24 @@ // If we found a pointer, check if it could be the same as our pointer. AliasAnalysis::AliasResult R = AA->alias(LoadLoc, MemLoc); - if (R == AliasAnalysis::NoAlias) - continue; if (isLoad) { + if (R == AliasAnalysis::NoAlias) { + // If this is an over-aligned integer load (for example, + // "load i8* %P, align 4") see if it would obviously overlap with the + // queried location if widened to a larger load (e.g. if the queried + // location is 1 byte at P+1). If so, return it as a load/load + // clobber result, allowing the client to decide to widen the load if + // it wants to. + if (const IntegerType *ITy = dyn_cast(LI->getType())) + if (LI->getAlignment()*8 > ITy->getPrimitiveSizeInBits() && + isLoadLoadClobberIfExtendedToFullWidth(MemLoc, MemLocBase, + MemLocOffset, LI, TD)) + return MemDepResult::getClobber(Inst); + + continue; + } + // Must aliased loads are defs of each other. if (R == AliasAnalysis::MustAlias) return MemDepResult::getDef(Inst); @@ -275,6 +363,10 @@ continue; } + // Stores don't depend on other no-aliased accesses. + if (R == AliasAnalysis::NoAlias) + continue; + // Stores don't alias loads from read-only memory. if (AA->pointsToConstantMemory(LoadLoc)) continue; From aggarwa4 at illinois.edu Tue Apr 26 19:10:28 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:10:28 -0000 Subject: [llvm-commits] [poolalloc] r130260 - /poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Message-ID: <20110427001028.70C0B2A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:10:28 2011 New Revision: 130260 URL: http://llvm.org/viewvc/llvm-project?rev=130260&view=rev Log: 1. Only do replacement for arguments that are actually being used in the function. 2. If a gep is passed in as multiple arguments, do the transform only once. Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp?rev=130260&r1=130259&r2=130260&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (original) +++ poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Tue Apr 26 19:10:28 2011 @@ -56,19 +56,23 @@ continue; // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++) { + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) + continue; if (isa(CI->getOperand(argNum))) break; } - - if(argNum == CI->getNumOperands()) + + // if no argument was a GEP operator to be changed + if(ai == ae) continue; + GEPOperator *GEP = dyn_cast(CI->getOperand(argNum)); if(!GEP->hasAllConstantIndices()) continue; - // Construct the new Type // Appends the struct Type at the beginning std::vectorTP; @@ -81,7 +85,7 @@ const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); Function *NewF; numSimplified++; - if(numSimplified > 25) //26 + if(numSimplified > 1000) return true; NewF = Function::Create(NewFTy, @@ -119,6 +123,11 @@ Indices.append(GEP->op_begin()+1, GEP->op_end()); GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); fargs.at(argNum)->replaceAllUsesWith(GEP_new); + unsigned j = argNum + 1; + for(; j < CI->getNumOperands();j++) { + if(CI->getOperand(j) == GEP) + fargs.at(j)->replaceAllUsesWith(GEP_new); + } SmallVector Args; Args.push_back(GEP->getPointerOperand()); From aggarwa4 at illinois.edu Tue Apr 26 19:11:17 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:11:17 -0000 Subject: [llvm-commits] [poolalloc] r130261 - /poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Message-ID: <20110427001117.C2AEC2A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:11:17 2011 New Revision: 130261 URL: http://llvm.org/viewvc/llvm-project?rev=130261&view=rev Log: Restructure it to be similiar to GEPExprArgs. Iterate over CallInsts, instead of LoadInst. Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130261&r1=130260&r2=130261&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Tue Apr 26 19:11:17 2011 @@ -9,7 +9,7 @@ // // //===----------------------------------------------------------------------===// -#define DEBUG_TYPE "ldargs" +#define DEBUG_TYPE "ld-args" #include "llvm/Instructions.h" #include "llvm/Module.h" @@ -26,7 +26,8 @@ #include using namespace llvm; -STATISTIC(numSimplified, "Number of Calls Changed"); +STATISTIC(numSimplified, "Number of Calls Modified"); + namespace { class LoadArgs : public ModulePass { @@ -35,123 +36,121 @@ LoadArgs() : ModulePass(&ID) {} bool runOnModule(Module& M) { for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) { - if(!(isa(I))) - continue; - // we are only interested in GEPs - LoadInst *LI = cast(I); - // If the GEP is not doing structure indexing, dont care. - for (Value::use_iterator UI = LI->use_begin(),UE = LI->use_end(); UI != UE; ) { - // check if GEP is used in a Call Inst - CallInst *CI = dyn_cast(UI++); - if(!CI) - continue; + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + CallInst *CI = dyn_cast(I++); + if(!CI) + continue; - if(CI->hasByValArgument()) - continue; + if(CI->hasByValArgument()) + continue; + // if the GEP calls a function, that is externally defined, + // or might be changed, ignore this call site. + Function *F = CI->getCalledFunction(); - // It should be in the same basic block - if(LI->getParent() != CI->getParent()) - continue; + if (!F || (F->isDeclaration() || F->mayBeOverridden())) + continue; + if(F->hasStructRetAttr()) + continue; + if(F->isVarArg()) + continue; - // Also check that there is no store after the load. - // TODO: Check if the load/store do not alias. - BasicBlock::iterator bii = LI->getParent()->begin(); - Instruction *BII = bii; - while(BII != LI) { - ++bii; - BII = bii; - } - while(BII != CI) { - if(isa(BII)) - break; - ++bii; - BII = bii; - } - if(isa(bii)){ + // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); + unsigned argNum = 1; + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) continue; - } + if(F->paramHasAttr(argNum, Attribute::SExt) || + F->paramHasAttr(argNum, Attribute::ZExt)) + continue; + if (isa(CI->getOperand(argNum))) + break; + } + // if no argument was a GEP operator to be changed + if(ai == ae) + continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); + LoadInst *LI = dyn_cast(CI->getOperand(argNum)); + if(LI->getParent() != CI->getParent()) + continue; + // Also check that there is no store after the load. + // TODO: Check if the load/store do not alias. + BasicBlock::iterator bii = LI->getParent()->begin(); + Instruction *BII = bii; + while(BII != LI) { + ++bii; + BII = bii; + } + while(BII != CI) { + if(isa(BII)) + break; + ++bii; + BII = bii; + } + if(isa(bii)){ + continue; + } - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; + // Construct the new Type + // Appends the struct Type at the beginning + std::vectorTP; + TP.push_back(LI->getOperand(0)->getType()); + for(unsigned c = 1; c < CI->getNumOperands();c++) { + TP.push_back(CI->getOperand(c)->getType()); + } - // find the argument we must replace - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++) - if(LI == CI->getOperand(argNum)) - break; + //return type is same as that of original instruction + const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); + Function *NewF; + numSimplified++; + if(numSimplified > 500) //26 + return true; + + NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F->getNameStr() + ".TEST", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + NI->setName("Sarg"); + ++NI; + + DenseMap ValueMap; + + for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + ValueMap[II] = NI; + NI->setName(II->getName()); + } + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, F, ValueMap, Returns); + std::vector fargs; + for(Function::arg_iterator ai = NewF->arg_begin(), + ae= NewF->arg_end(); ai != ae; ++ai) { + fargs.push_back(ai); + } - if(F->paramHasAttr(argNum, Attribute::SExt) || - F->paramHasAttr(argNum, Attribute::ZExt)) - continue; - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(LI->getOperand(0)->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } - - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; - numSimplified++; - if(numSimplified > 50) //26 - return true; - - NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } - - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(LI_new); - - SmallVector Args; - Args.push_back(LI->getOperand(0)); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); - } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); + NewF->setAlignment(F->getAlignment()); + //Get the point to insert the GEP instr. + NI = NewF->arg_begin(); + SmallVector Ops(CI->op_begin()+1, CI->op_end()); + Instruction *InsertPoint; + for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} + + LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); + fargs.at(argNum)->replaceAllUsesWith(LI_new); + + SmallVector Args; + Args.push_back(LI->getOperand(0)); + for(unsigned j =1;jgetNumOperands();j++) { + Args.push_back(CI->getOperand(j)); } + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); } } } @@ -162,4 +161,4 @@ char LoadArgs::ID = 0; static RegisterPass -X("ld-args", "Find GEP into structs passed as args"); +X("ld-args", "Find Load Inst passed as args"); From aggarwa4 at illinois.edu Tue Apr 26 19:12:21 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:12:21 -0000 Subject: [llvm-commits] [poolalloc] r130262 - in /poolalloc/trunk/lib/AssistDS: CMakeLists.txt TestGEP.cpp Message-ID: <20110427001221.755912A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:12:21 2011 New Revision: 130262 URL: http://llvm.org/viewvc/llvm-project?rev=130262&view=rev Log: Remove TestGEP. GEPExprArg is useful for both GEPInst and ConstantExprGEPs. Removed: poolalloc/trunk/lib/AssistDS/TestGEP.cpp Modified: poolalloc/trunk/lib/AssistDS/CMakeLists.txt Modified: poolalloc/trunk/lib/AssistDS/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/CMakeLists.txt?rev=130262&r1=130261&r2=130262&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/CMakeLists.txt (original) +++ poolalloc/trunk/lib/AssistDS/CMakeLists.txt Tue Apr 26 19:12:21 2011 @@ -12,7 +12,6 @@ SimplifyGEP.cpp SimplifyInsertValue.cpp StructReturnToPointer.cpp - TestGEP.cpp TypeAnalysis.cpp TypeChecks.cpp VarArgsFunc.cpp Removed: poolalloc/trunk/lib/AssistDS/TestGEP.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TestGEP.cpp?rev=130261&view=auto ============================================================================== --- poolalloc/trunk/lib/AssistDS/TestGEP.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TestGEP.cpp (removed) @@ -1,149 +0,0 @@ -//===-- MergeGEP.cpp - Merge GEPs for indexing in arrays ------------ ----===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// -//===----------------------------------------------------------------------===// -#define DEBUG_TYPE "gepargs" - -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/Pass.h" -#include "llvm/Instructions.h" -#include "llvm/Constants.h" -#include "llvm/Support/GetElementPtrTypeIterator.h" -#include "llvm/Transforms/Utils/Cloning.h" -#include "llvm/ADT/Statistic.h" -#include "llvm/Support/FormattedStream.h" -#include "llvm/Support/Debug.h" -#include "llvm/Use.h" -#include -#include - -using namespace llvm; -STATISTIC(numSimplified, "Number of Calls Modified"); - - -namespace { - class GEPArgs : public ModulePass { - public: - static char ID; - GEPArgs() : ModulePass(&ID) {} - bool runOnModule(Module& M) { - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) { - if(!(isa(I))) - continue; - // we are only interested in GEPs - GetElementPtrInst *GEP = cast(I); - // Only GEPs that have constant indices, so we dont have - // to add more args - if(!GEP->hasAllConstantIndices()) - continue; - // If the GEP is not doing structure indexing, dont care. - const PointerType *PTy = cast(GEP->getPointerOperand()->getType()); - if(!PTy->getElementType()->isStructTy()) - continue; - for (Value::use_iterator UI = GEP->use_begin(),UE = GEP->use_end(); UI != UE; ) { - // check if GEP is used in a Call Inst - CallInst *CI = dyn_cast(UI++); - if(!CI) - continue; - - if(CI->hasByValArgument()) - continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); - - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; - - // find the argument we must replace - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++) - if(GEP == CI->getOperand(argNum)) - break; - - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(GEP->getPointerOperand()->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } - - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; - numSimplified++; - if(numSimplified > 25) //26 - return true; - - NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } - - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - SmallVector Ops(CI->op_begin()+1, CI->op_end()); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - SmallVector Indices; - Indices.append(GEP->op_begin()+1, GEP->op_end()); - GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(GEP_new); - - SmallVector Args; - Args.push_back(GEP->getPointerOperand()); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); - } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); - } - } - } - } - return true; - } - }; -} - -char GEPArgs::ID = 0; -static RegisterPass -X("gep-args", "Find GEP into structs passed as args"); From aggarwa4 at illinois.edu Tue Apr 26 19:18:51 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:18:51 -0000 Subject: [llvm-commits] [poolalloc] r130263 - in /poolalloc/trunk: lib/DSA/DynCount.cpp runtime/DynCount/ runtime/DynCount/DynCount.c runtime/DynCount/Makefile Message-ID: <20110427001851.0F7862A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:18:50 2011 New Revision: 130263 URL: http://llvm.org/viewvc/llvm-project?rev=130263&view=rev Log: Add the functions needed for counting number of dynamically safe LS instructions. Added: poolalloc/trunk/lib/DSA/DynCount.cpp poolalloc/trunk/runtime/DynCount/ poolalloc/trunk/runtime/DynCount/DynCount.c poolalloc/trunk/runtime/DynCount/Makefile (with props) Added: poolalloc/trunk/lib/DSA/DynCount.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DynCount.cpp?rev=130263&view=auto ============================================================================== --- poolalloc/trunk/lib/DSA/DynCount.cpp (added) +++ poolalloc/trunk/lib/DSA/DynCount.cpp Tue Apr 26 19:18:50 2011 @@ -0,0 +1,140 @@ +//===- Dyncount.cpp - Test pass for using constraints -----------*- C++ -*-===// +// +// The SAFECode Compiler +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements a test pass which helps test the generation of formulas +// and constraints. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Pass.h" +#include "llvm/Module.h" +#include "llvm/Instructions.h" +#include "llvm/Target/TargetData.h" +#include "dsa/TypeSafety.h" + +using namespace llvm; +class Dyncount : public ModulePass { +protected: + void instrumentLoad (GlobalVariable * Counter, LoadInst * LI); + void instrumentStore (GlobalVariable * Counter, StoreInst * SI); + dsa::TypeSafety *TS; + +public: + static char ID; + Dyncount () : ModulePass ((intptr_t) &ID) { } + const char *getPassName() const { + return "Count safe/unsafe load/store"; + } + virtual bool runOnModule (Module & M); + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + AU.addRequired >(); + }; +}; + +char Dyncount::ID = 0; +static RegisterPass +X ("dyncount", "Instrument code to count number of Load/Stores"); + + +void +Dyncount::instrumentLoad (GlobalVariable * Counter, LoadInst * LI) { + // + // Generate a load, increment, and store right before the GEP. + // + LLVMContext & Context = Counter->getParent()->getContext(); + ConstantInt * One = ConstantInt::get (Type::getInt64Ty(Context), 1); + LoadInst * Value = new LoadInst (Counter, "count", LI); + Instruction * NewValue = BinaryOperator::Create (BinaryOperator::Add, + Value, + One, + "count", + LI); + new StoreInst (NewValue, Counter, LI); + return; +} +void +Dyncount::instrumentStore (GlobalVariable * Counter, StoreInst * SI) { + // + // Generate a load, increment, and store right before the GEP. + // + LLVMContext & Context = Counter->getParent()->getContext(); + ConstantInt * One = ConstantInt::get (Type::getInt64Ty(Context), 1); + LoadInst * Value = new LoadInst (Counter, "count", SI); + Instruction * NewValue = BinaryOperator::Create (BinaryOperator::Add, + Value, + One, + "count", + SI); + new StoreInst (NewValue, Counter, SI); + return; +} + +// +// Method: runOnModule() +// +// Description: +// Entry point for this pass. +// +bool +Dyncount::runOnModule (Module & M) { + // + // Create two global counters within the module. + // + TS = &getAnalysis >(); + ConstantInt * Zero = ConstantInt::get (Type::getInt64Ty(M.getContext()), 0); + GlobalVariable * Total = new GlobalVariable (M, + Type::getInt64Ty(M.getContext()), + false, + GlobalValue::InternalLinkage, + Zero, + "Total"); + GlobalVariable * Safe = new GlobalVariable (M, + Type::getInt64Ty(M.getContext()), + false, + GlobalValue::InternalLinkage, + Zero, + "Safe"); + + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE; I++) { + if(LoadInst *LI = dyn_cast(I)) { + instrumentLoad(Total, LI); + if(TS->isTypeSafe(LI->getOperand(0),LI->getParent()->getParent())) + instrumentLoad(Safe, LI); + + // check if safe + } else if(StoreInst *SI = dyn_cast(I)) { + instrumentStore(Total, SI); + if(TS->isTypeSafe(SI->getOperand(1),SI->getParent()->getParent())) + instrumentStore(Safe, SI); + // check if safe + } + } + } + } + + // + // Add a call to main() that will record the values on exit(). + // + Function *MainFunc = M.getFunction("main") ? M.getFunction("main") + : M.getFunction ("MAIN__"); + + BasicBlock & BB = MainFunc->getEntryBlock(); + Constant * Setup = M.getOrInsertFunction ("DYN_COUNT_setup", Type::getVoidTy(M.getContext()), Total->getType(), Safe->getType(), NULL); + std::vector args; + args.push_back (Total); + args.push_back (Safe); + CallInst::Create (Setup, args.begin(), args.end(), "", BB.getFirstNonPHI()); + + + return true; +} + Added: poolalloc/trunk/runtime/DynCount/DynCount.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynCount/DynCount.c?rev=130263&view=auto ============================================================================== --- poolalloc/trunk/runtime/DynCount/DynCount.c (added) +++ poolalloc/trunk/runtime/DynCount/DynCount.c Tue Apr 26 19:18:50 2011 @@ -0,0 +1,25 @@ +#include +#include + +static unsigned long * Total = 0; +static unsigned long * Safe = 0; + +static void +printItAll (void) { + FILE * fp = fopen ("lsstats", "w"); + fprintf (fp, "%lu Safe \n", *Safe); + fprintf (fp, "%lu Total \n", *Total); + fflush (fp); + fclose (fp); + return; +} + +void +DYN_COUNT_setup (unsigned long * total, unsigned long * safe) { + Total = total; + Safe = safe; + atexit (printItAll); + return; +} + + Added: poolalloc/trunk/runtime/DynCount/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynCount/Makefile?rev=130263&view=auto ============================================================================== --- poolalloc/trunk/runtime/DynCount/Makefile (added) +++ poolalloc/trunk/runtime/DynCount/Makefile Tue Apr 26 19:18:50 2011 @@ -0,0 +1,25 @@ +LEVEL = ../.. +LIBRARYNAME=count +BYTECODE_LIBRARY=1 + +# +# Build shared libraries on all platforms except Cygwin and MingW (which do +# not support them). +# +ifneq ($(OS),Cygwin) +ifneq ($(OS),MingW) +SHARED_LIBRARY=1 +endif +endif + +ifeq ($(OS),Linux) +CXX.Flags += -march=native +else +CXX.Flags += -march=nocona +endif + +CXX.Flags += -fno-threadsafe-statics +include $(LEVEL)/Makefile.common + +# Always build optimized and debug versions +all:: $(LIBNAME_OBJO) $(LIBNAME_OBJG) Propchange: poolalloc/trunk/runtime/DynCount/Makefile ------------------------------------------------------------------------------ svn:executable = * From aggarwa4 at illinois.edu Tue Apr 26 19:19:12 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:19:12 -0000 Subject: [llvm-commits] [poolalloc] r130264 - /poolalloc/trunk/runtime/Makefile Message-ID: <20110427001912.EDC2E2A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:19:12 2011 New Revision: 130264 URL: http://llvm.org/viewvc/llvm-project?rev=130264&view=rev Log: Update the makefile to also build the dynamic count runtime library. Modified: poolalloc/trunk/runtime/Makefile Modified: poolalloc/trunk/runtime/Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/Makefile?rev=130264&r1=130263&r2=130264&view=diff ============================================================================== --- poolalloc/trunk/runtime/Makefile (original) +++ poolalloc/trunk/runtime/Makefile Tue Apr 26 19:19:12 2011 @@ -6,6 +6,6 @@ # # List all of the subdirectories that we will compile. # -DIRS=FreeListAllocator FL2Allocator PreRT DynamicTypeChecks +DIRS=FreeListAllocator FL2Allocator PreRT DynamicTypeChecks DynCount include $(LEVEL)/Makefile.common From aggarwa4 at illinois.edu Tue Apr 26 19:20:50 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:20:50 -0000 Subject: [llvm-commits] [poolalloc] r130265 - in /poolalloc/trunk/test: TEST.types.Makefile TEST.types.report Message-ID: <20110427002050.DEEB42A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:20:50 2011 New Revision: 130265 URL: http://llvm.org/viewvc/llvm-project?rev=130265&view=rev Log: 1. Update the makefiles to not use the gep-args pass. Merged with gep-expr-arg pass. 2. Update the tests to generate the dynamic typesafety numbers. Modified: poolalloc/trunk/test/TEST.types.Makefile poolalloc/trunk/test/TEST.types.report Modified: poolalloc/trunk/test/TEST.types.Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.Makefile?rev=130265&r1=130264&r2=130265&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.Makefile (original) +++ poolalloc/trunk/test/TEST.types.Makefile Tue Apr 26 19:20:50 2011 @@ -27,6 +27,7 @@ PASS := td TYPE_RT_O := $(PADIR)/$(CONFIGURATION)/lib/libtypechecks_rt.a +DYNCOUNT_RT_O := $(PADIR)/$(CONFIGURATION)/lib/libcount.a ANALYZE_OPTS := -stats -time-passes -disable-output -dsstats #ANALYZE_OPTS := -stats -time-passes -dsstats ANALYZE_OPTS += -instcount -disable-verify @@ -50,21 +51,51 @@ $(PROGRAMS_TO_TEST:%=Output/%.opt.bc): \ Output/%.opt.bc: Output/%.llvm1.bc $(LOPT) $(ASSIST_SO) - -$(RUNOPT) -load $(ASSIST_SO) -disable-opt -info-output-file=$(CURDIR)/$@.info -instnamer -internalize -mem2reg -dce -basiccg -inline -dce -dce -varargsfunc -indclone -funcspec -ipsccp -deadargelim -simplify-gep -die -die -mergearrgep -die -globaldce -simplifycfg -deadargelim -arg-simplify -die -varargsfunc -die -simplifycfg -globaldce -indclone -funcspec -deadargelim -globaldce -die -simplifycfg -gep-args -deadargelim -die -mergefunc -die -die -mergearrgep -die -globaldce -int2ptrcmp -die -dce -dce -inline -mem2reg -dce -arg-cast -dce -struct-ret -deadargelim -simplify-ev -simplify-iv -dce -ld-args -gep-args -deadargelim -mergefunc -globaldce -dce -typechecks -ipsccp -dce -stats -time-passes $< -f -o $@ + -$(RUNOPT) -load $(ASSIST_SO) -disable-opt -info-output-file=$(CURDIR)/$@.info -instnamer -internalize -mem2reg -dce -basiccg -inline -dce -varargsfunc -indclone -funcspec -ipsccp -deadargelim -simplify-gep -die -die -mergearrgep -die -globaldce -simplifycfg -deadargelim -arg-simplify -die -varargsfunc -die -simplifycfg -globaldce -indclone -funcspec -deadargelim -globaldce -die -simplifycfg -gep-expr-arg -deadargelim -die -mergefunc -die -die -mergearrgep -die -globaldce -int2ptrcmp -die -dce -inline -mem2reg -dce -arg-cast -dce -struct-ret -deadargelim -simplify-ev -simplify-iv -dce -ld-args -gep-expr-arg -deadargelim -mergefunc -dce -stats -time-passes $< -f -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.count.bc): \ +Output/%.count.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) + -$(RUNOPT) -enable-type-inference-opts -dsa-stdlib-no-fold -dyncount -disable-opt -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + +$(PROGRAMS_TO_TEST:%=Output/%.count1.bc): \ +Output/%.count1.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) + -$(RUNOPT) -dyncount -disable-opt -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + +$(PROGRAMS_TO_TEST:%=Output/%.tc.bc): \ +Output/%.tc.bc: Output/%.opt.bc $(LOPT) $(ASSIST_SO) + -$(RUNOPT) -load $(ASSIST_SO) -typechecks -dce -ipsccp -info-output-file=$(CURDIR)/$@.info $< -f -o $@ + +$(PROGRAMS_TO_TEST:%=Output/%.count.s): \ +Output/%.count.s: Output/%.count.bc $(LLC) + -$(LLC) -f $< -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.count1.s): \ +Output/%.count1.s: Output/%.count1.bc $(LLC) + -$(LLC) -f $< -o $@ $(PROGRAMS_TO_TEST:%=Output/%.opt.s): \ Output/%.opt.s: Output/%.opt.bc $(LLC) -$(LLC) -f $< -o $@ $(PROGRAMS_TO_TEST:%=Output/%.llvm1.s): \ Output/%.llvm1.s: Output/%.llvm1.bc $(LLC) -$(LLC) -f $< -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tc.s): \ +Output/%.tc.s: Output/%.tc.bc $(LLC) + -$(LLC) -f $< -o $@ $(PROGRAMS_TO_TEST:%=Output/%.opt): \ -Output/%.opt: Output/%.opt.s $(TYPE_RT_O) +Output/%.opt: Output/%.opt.s + -$(CC) $(CFLAGS) $< $(LLCLIBS) $(LDFLAGS) -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.tc): \ +Output/%.tc: Output/%.tc.s $(TYPE_RT_O) -$(CC) $(CFLAGS) $< $(LLCLIBS) $(TYPE_RT_O) $(LDFLAGS) -o $@ $(PROGRAMS_TO_TEST:%=Output/%.llvm1): \ Output/%.llvm1: Output/%.llvm1.s -$(CC) $(CFLAGS) $< $(LLCLIBS) $(LDFLAGS) -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.count): \ +Output/%.count: Output/%.count.s + -$(CC) $(CFLAGS) $< $(LLCLIBS) $(DYNCOUNT_RT_O) $(LDFLAGS) -o $@ +$(PROGRAMS_TO_TEST:%=Output/%.count1): \ +Output/%.count1: Output/%.count1.s + -$(CC) $(CFLAGS) $< $(LLCLIBS) $(DYNCOUNT_RT_O) $(LDFLAGS) -o $@ ifndef PROGRAMS_HAVE_CUSTOM_RUN_RULES @@ -74,6 +105,17 @@ $(PROGRAMS_TO_TEST:%=Output/%.llvm1.out): \ Output/%.llvm1.out: Output/%.llvm1 -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) +$(PROGRAMS_TO_TEST:%=Output/%.count1.out): \ +Output/%.count1.out: Output/%.count1 + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) + -cp lsstats lsstats1 +$(PROGRAMS_TO_TEST:%=Output/%.count.out): \ +Output/%.count.out: Output/%.count + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) + -cp lsstats lsstats2 +$(PROGRAMS_TO_TEST:%=Output/%.tc.out): \ +Output/%.tc.out: Output/%.tc + -$(RUNSAFELY) $(STDIN_FILENAME) $@ $< $(RUN_OPTIONS) else $(PROGRAMS_TO_TEST:%=Output/%.opt.out): \ @@ -88,8 +130,31 @@ -$(SPEC_SANDBOX) llvm1-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ ../../$< $(RUN_OPTIONS) - -(cd Output/opt-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ - -cp Output/opt-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + -(cd Output/llvm1-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/llvm1-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time +$(PROGRAMS_TO_TEST:%=Output/%.tc.out): \ +Output/%.tc.out: Output/%.tc + -$(SPEC_SANDBOX) tc-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/tc-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/tc-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time +$(PROGRAMS_TO_TEST:%=Output/%.count.out): \ +Output/%.count.out: Output/%.count + -$(SPEC_SANDBOX) count-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/count-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/count-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + -cp Output/count-$(RUN_TYPE)/lsstats lsstats2 +$(PROGRAMS_TO_TEST:%=Output/%.count1.out): \ +Output/%.count1.out: Output/%.count1 + -$(SPEC_SANDBOX) count1-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(RUNSAFELY) $(STDIN_FILENAME) $(STDOUT_FILENAME) \ + ../../$< $(RUN_OPTIONS) + -(cd Output/count1-$(RUN_TYPE); cat $(LOCAL_OUTPUTS)) > $@ + -cp Output/count1-$(RUN_TYPE)/$(STDOUT_FILENAME).time $@.time + -cp Output/count1-$(RUN_TYPE)/lsstats lsstats1 endif @@ -97,15 +162,28 @@ Output/%.opt.diff-nat: Output/%.out-nat Output/%.opt.out @cp Output/$*.out-nat Output/$*.opt.out-nat -$(DIFFPROG) nat $*.opt $(HIDEDIFF) +$(PROGRAMS_TO_TEST:%=Output/%.tc.diff-nat): \ +Output/%.tc.diff-nat: Output/%.out-nat Output/%.tc.out + @cp Output/$*.out-nat Output/$*.tc.out-nat + -$(DIFFPROG) nat $*.tc $(HIDEDIFF) $(PROGRAMS_TO_TEST:%=Output/%.llvm1.diff-nat): \ Output/%.llvm1.diff-nat: Output/%.out-nat Output/%.llvm1.out @cp Output/$*.out-nat Output/$*.llvm1.out-nat - -$(DIFFPROG) nat $*.opt $(HIDEDIFF) + -$(DIFFPROG) nat $*.llvm1 $(HIDEDIFF) + +$(PROGRAMS_TO_TEST:%=Output/%.count.diff-nat): \ +Output/%.count.diff-nat: Output/%.out-nat Output/%.count.out + @cp Output/$*.out-nat Output/$*.count.out-nat + -$(DIFFPROG) nat $*.count $(HIDEDIFF) +$(PROGRAMS_TO_TEST:%=Output/%.count1.diff-nat): \ +Output/%.count1.diff-nat: Output/%.out-nat Output/%.count1.out + @cp Output/$*.out-nat Output/$*.count1.out-nat + -$(DIFFPROG) nat $*.count1 $(HIDEDIFF) $(PROGRAMS_TO_TEST:%=Output/%.$(TEST).report.txt): \ -Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat +Output/%.$(TEST).report.txt: Output/%.opt.bc Output/%.LOC.txt $(LOPT) Output/%.out-nat Output/%.opt.diff-nat Output/%.count.diff-nat Output/%.count1.diff-nat @# Gather data -($(RUNOPT) -dsa-$(PASS) -enable-type-inference-opts -dsa-stdlib-no-fold $(ANALYZE_OPTS) $<)> $@.time.1 2>&1 -($(RUNOPT) -dsa-$(PASS) $(ANALYZE_OPTS) $<)> $@.time.2 2>&1 @@ -176,8 +254,8 @@ @/bin/echo -n "ACCESSES U: " >> $@ - at grep 'Number of loads/stores which are on unknown nodes' $@.time.1 >> $@ @echo >> $@ - @/bin/echo -n "STD_LIB_FOLD: " >> $@ - - at grep 'Number of nodes folded in std lib' $@.time.1 >> $@ + @/bin/echo -n "ACCESSES I2P: " >> $@ + - at grep 'Number of loads/stores which are on inttoptr nodes' $@.time.1 >> $@ @echo >> $@ @/bin/echo -n "I2PB: " >> $@ - at grep 'Number of inttoptr used only in cmp' $@.time.1 >> $@ @@ -226,6 +304,18 @@ @/bin/echo -n "INDCALLS: " >> $@ - at grep 'Number of unresolved IndCalls' $@.time.1 >> $@ @echo >> $@ + @/bin/echo -n "DTOTALO: " >> $@ + - at grep 'Total' lsstats2 >> $@ + @echo >> $@ + @/bin/echo -n "DSAFEO: " >> $@ + - at grep 'Safe' lsstats2 >> $@ + @echo >> $@ + @/bin/echo -n "DTOTAL: " >> $@ + - at grep 'Total' lsstats1 >> $@ + @echo >> $@ + @/bin/echo -n "DSAFE: " >> $@ + - at grep 'Safe' lsstats1 >> $@ + @echo >> $@ $(PROGRAMS_TO_TEST:%=test.$(TEST).%): \ @@ -238,5 +328,5 @@ # Define REPORT_DEPENDENCIES so that the report is regenerated if analyze or # dummylib is updated. # -REPORT_DEPENDENCIES := $(DUMMYLIB) $(LOPT) +REPORT_DEPENDENCIES := $(DUMMYLIB) $(LOPT) $(ASSIST_SO) Modified: poolalloc/trunk/test/TEST.types.report URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.types.report?rev=130265&r1=130264&r2=130265&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.types.report (original) +++ poolalloc/trunk/test/TEST.types.report Tue Apr 26 19:20:50 2011 @@ -15,7 +15,7 @@ my ($Cols, $Col) = @_; if ($Cols->[$Col-2] ne "*" and $Cols->[$Col-2] != "0") { - return $Cols->[$Col-1]/$Cols->[$Col-2]; + return sprintf("%4.1f%%", 100*($Cols->[$Col-1]/$Cols->[$Col-2])); } else { return "n/a"; } @@ -159,6 +159,7 @@ ["E", "ACCESSES E: *([0-9]+)"], ["F", "ACCESSES F: *([0-9]+)"], ["U", "ACCESSES U: *([0-9]+)"], + ["I2P", "ACCESSES I2P: *([0-9]+)"], # Nodes Folded [], ["VAFUNC", "VARARGS_CALLS: *([0-9]+)"], @@ -166,7 +167,6 @@ ["ARGSMPL", "ARG_SMPL: *([0-9]+)"], ["FUNCSPEC", "CLONED_FUNCSPEC: *([0-9]+)"], ["INDCLONE", "CLONED_INDCLONE: *([0-9]+)"], - ["StdLibFold", "STD_LIB_FOLD: *([0-9]+)"], ["I2PB", "I2PB: *([0-9]+)"], ["I2PS", "I2PS: *([0-9]+)"], ["EV", "EV: *([0-9]+)"], @@ -174,4 +174,12 @@ ["DE", "DEALLOC: *([0-9]+)"], ["CAST", "CAST: *([0-9]+)"], ["Calls", "INDCALLS: *([0-9]+)"], + [], + ["DTotal", "DTOTAL: *([0-9]+)"], + ["DSafe", "DSAFE: *([0-9]+)"], + ["DTS %" , sub { return Ratio(@_); }], + [], + ["DTotalO", "DTOTALO: *([0-9]+)"], + ["DSafeO", "DSAFEO: *([0-9]+)"], + ["DTS %" , sub { return Ratio(@_); }], ); From aggarwa4 at illinois.edu Tue Apr 26 19:37:00 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:37:00 -0000 Subject: [llvm-commits] [poolalloc] r130267 - /poolalloc/trunk/lib/DSA/StdLibPass.cpp Message-ID: <20110427003700.4E2E02A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:37:00 2011 New Revision: 130267 URL: http://llvm.org/viewvc/llvm-project?rev=130267&view=rev Log: Allow an option to turn off the Stdlib processing of graphs. This might help identify all external nodes, if ever needed. Also, might be useful for statistic measurements. Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=130267&r1=130266&r2=130267&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Apr 26 19:37:00 2011 @@ -31,6 +31,7 @@ static RegisterPass X("dsa-stdlib", "Standard Library Local Data Structure Analysis"); + STATISTIC(NumNodesFoldedInStdLib, "Number of nodes folded in std lib"); char StdLibDataStructures::ID; @@ -41,6 +42,10 @@ cl::desc("Don't fold nodes in std-lib."), cl::Hidden, cl::init(false)); + static cl::opt DisableStdLib("disable-dsa-stdlib", + cl::desc("Don't use DSA's stdlib pass."), + cl::Hidden, + cl::init(false)); } // @@ -442,48 +447,51 @@ eraseCallsTo(I); } - // - // Scan through the function summaries and process functions by summary. - // - for (int x = 0; recFuncs[x].name; ++x) - if (Function* F = M.getFunction(recFuncs[x].name)) - if (F->isDeclaration()) { - processFunction(x, F); - } + if(!DisableStdLib) { - std::set::iterator ai = AllocWrappersAnalysis->alloc_begin(); - std::set::iterator ae = AllocWrappersAnalysis->alloc_end(); - int x; - for (x = 0; recFuncs[x].name; ++x) { - if(recFuncs[x].name == std::string("malloc")) - break; - } + // + // Scan through the function summaries and process functions by summary. + // + for (int x = 0; recFuncs[x].name; ++x) + if (Function* F = M.getFunction(recFuncs[x].name)) + if (F->isDeclaration()) { + processFunction(x, F); + } - for(;ai != ae; ++ai) { - if(Function* F = M.getFunction(*ai)) - processFunction(x, F); - } + std::set::iterator ai = AllocWrappersAnalysis->alloc_begin(); + std::set::iterator ae = AllocWrappersAnalysis->alloc_end(); + int x; + for (x = 0; recFuncs[x].name; ++x) { + if(recFuncs[x].name == std::string("malloc")) + break; + } - ai = AllocWrappersAnalysis->dealloc_begin(); - ae = AllocWrappersAnalysis->dealloc_end(); - for (x = 0; recFuncs[x].name; ++x) { - if(recFuncs[x].name == std::string("free")) - break; - } + for(;ai != ae; ++ai) { + if(Function* F = M.getFunction(*ai)) + processFunction(x, F); + } - for(;ai != ae; ++ai) { - if(Function* F = M.getFunction(*ai)) - processFunction(x, F); - } + ai = AllocWrappersAnalysis->dealloc_begin(); + ae = AllocWrappersAnalysis->dealloc_end(); + for (x = 0; recFuncs[x].name; ++x) { + if(recFuncs[x].name == std::string("free")) + break; + } - // - // Merge return values and checked pointer values for SAFECode run-time - // checks. - // - processRuntimeCheck (M, "sc.boundscheck", 3); - processRuntimeCheck (M, "sc.boundscheckui", 3); - processRuntimeCheck (M, "sc.exactcheck2", 2); - processRuntimeCheck (M, "sc.get_actual_val", 2); + for(;ai != ae; ++ai) { + if(Function* F = M.getFunction(*ai)) + processFunction(x, F); + } + + // + // Merge return values and checked pointer values for SAFECode run-time + // checks. + // + processRuntimeCheck (M, "sc.boundscheck", 3); + processRuntimeCheck (M, "sc.boundscheckui", 3); + processRuntimeCheck (M, "sc.exactcheck2", 2); + processRuntimeCheck (M, "sc.get_actual_val", 2); + } // // In the Local DSA Pass, we marked nodes passed to/returned from 'StdLib' From aggarwa4 at illinois.edu Tue Apr 26 19:39:15 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 00:39:15 -0000 Subject: [llvm-commits] [poolalloc] r130268 - /poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Message-ID: <20110427003915.B897A2A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 19:39:15 2011 New Revision: 130268 URL: http://llvm.org/viewvc/llvm-project?rev=130268&view=rev Log: If the use is never used, dont count this as address taken. CallInst/InvokeInst/StoreInst which are relavant without subsequent uses of result, have already been checked. Modified: poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Modified: poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp?rev=130268&r1=130267&r2=130268&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp (original) +++ poolalloc/trunk/lib/DSA/AddressTakenAnalysis.cpp Tue Apr 26 19:39:15 2011 @@ -42,6 +42,8 @@ if(isa(U)) return true; if (!isa(U) && !isa(U)) { + if(U->use_empty()) + continue; if(isa(U)) { if(isAddressTaken(U)) return true; @@ -53,7 +55,6 @@ } } } - return true; } From aggarwa4 at illinois.edu Tue Apr 26 20:00:30 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 01:00:30 -0000 Subject: [llvm-commits] [poolalloc] r130269 - in /poolalloc/trunk/lib/DSA: Local.cpp TypeSafety.cpp Message-ID: <20110427010030.8B8082A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 20:00:30 2011 New Revision: 130269 URL: http://llvm.org/viewvc/llvm-project?rev=130269&view=rev Log: Teach local DSA to handle nested arrays inside structs. Teach the typesafety pass about cases when, we might be inferring array types at a given offset. Modified: poolalloc/trunk/lib/DSA/Local.cpp poolalloc/trunk/lib/DSA/TypeSafety.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=130269&r1=130268&r2=130269&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Tue Apr 26 20:00:30 2011 @@ -546,6 +546,22 @@ if((++I) == E) { break; } + // Check if we are still indexing into an array. + // We only record the topmost array type of any nested array. + // Keep skipping indexes till we reach a non-array type. + // J is the type of the next index. + // Uncomment the line below to get all the nested types. + gep_type_iterator J = I; + while(isa(*(++J))) { + // Value.getNode()->mergeTypeInfo(AT1, Value.getOffset() + Offset); + if((++I) == E) { + break; + } + J = I; + } + if((I) == E) { + break; + } } } } else if(const ArrayType *ATy = dyn_cast(*I)) { Modified: poolalloc/trunk/lib/DSA/TypeSafety.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TypeSafety.cpp?rev=130269&r1=130268&r2=130269&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TypeSafety.cpp (original) +++ poolalloc/trunk/lib/DSA/TypeSafety.cpp Tue Apr 26 20:00:30 2011 @@ -17,10 +17,12 @@ #include "dsa/TypeSafety.h" -#include "llvm/ADT/Statistic.h" #include "llvm/Module.h" +#include "llvm/DerivedTypes.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormattedStream.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" static RegisterPass > X ("typesafety-eqtd", "Find type-safe pointers"); @@ -31,6 +33,7 @@ namespace { //STATISTIC (TypeSafeNodes, "Type-safe DSNodes"); } +extern cl::opt TypeInferenceOptimize; namespace dsa { @@ -109,8 +112,9 @@ // // If there is no DSNode, claim that it is not type safe. // - if (DH.isNull()) + if (DH.isNull()) { return false; + } // // See if the DSNode is one that we think is type-safe. @@ -173,9 +177,23 @@ ne = TypeSet->end(); ni != ne; ++ni) { unsigned field_length = TD->getTypeStoreSize (*ni); if ((offset + field_length) > next_offset) { - DEBUG(errs() << " Found overlap at " << offset << " with " << next_offset << "\n"); overlaps = true; - break; + if(TypeInferenceOptimize) { + if(const ArrayType *AT = dyn_cast(*ni)) { + const Type *ElemTy = AT->getElementType(); + while(const ArrayType *AT1 = dyn_cast(ElemTy)) + ElemTy = AT1->getElementType(); + if(next_offset < (TD->getTypeStoreSize(ElemTy) + offset)) { + const StructType *ST = dyn_cast(ElemTy); + assert(ST && "Array Not of struct type ???? "); + overlaps = false; + } + } + } + if(overlaps) { + DEBUG(errs() << " Found overlap at " << offset << " with " << next_offset << "\n"); + break; + } } } } From aggarwa4 at illinois.edu Tue Apr 26 20:07:17 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 01:07:17 -0000 Subject: [llvm-commits] [poolalloc] r130270 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20110427010717.913E72A6C12D@llvm.org> Author: aggarwa4 Date: Tue Apr 26 20:07:17 2011 New Revision: 130270 URL: http://llvm.org/viewvc/llvm-project?rev=130270&view=rev Log: Formatting changes. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=130270&r1=130269&r2=130270&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Tue Apr 26 20:07:17 2011 @@ -15,18 +15,19 @@ #define DEBUG_TYPE "dsa-local" #include "dsa/DataStructure.h" #include "dsa/DSGraph.h" +#include "llvm/Use.h" +#include "llvm/InlineAsm.h" #include "llvm/Constants.h" +#include "llvm/Intrinsics.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" -#include "llvm/Intrinsics.h" -#include "llvm/InlineAsm.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "llvm/Target/TargetData.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/Timer.h" +#include "llvm/Target/TargetData.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/Triple.h" @@ -420,7 +421,6 @@ void GraphBuilder::visitBitCastInst(BitCastInst &I) { - if (!isa(I.getType())) return; // Only pointers DSNodeHandle Ptr = getValueDest(I.getOperand(0)); if (Ptr.isNull()) return; @@ -503,7 +503,7 @@ // Okay, no easy way out. Calculate the offset into the object being // indexed. // - + int Offset = 0; // FIXME: I am not sure if the code below is completely correct (especially @@ -511,7 +511,7 @@ // What if the array is indexed using a larger index than its declared // size? Does the LLVM verifier catch such issues? // - + // // Determine the offset (in bytes) between the result of the GEP and the // GEP's pointer operand. @@ -540,7 +540,6 @@ } Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo); if(TypeInferenceOptimize) { - if(const ArrayType* AT = dyn_cast(STy->getTypeAtIndex(FieldNo))) { Value.getNode()->mergeTypeInfo(AT, Value.getOffset() + Offset); if((++I) == E) { @@ -570,7 +569,7 @@ const Type *CurTy = ATy->getElementType(); if(!isa(CurTy) && - Value.getNode()->getSize() <= 0) { + Value.getNode()->getSize() <= 0) { Value.getNode()->growSize(TD.getTypeAllocSize(CurTy)); } else if(isa(CurTy) && Value.getNode()->getSize() <= 0){ const Type *ETy = (cast(CurTy))->getElementType(); @@ -583,7 +582,7 @@ // Find if the DSNode belongs to the array // If not fold. if((Value.getOffset() || Offset != 0) - || (!isa(CurTy) + || (!isa(CurTy) && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { Value.getNode()->foldNodeCompletely(); Value.getNode(); @@ -605,7 +604,7 @@ if (!isa(I.getOperand()) || !cast(I.getOperand())->isNullValue()) { Value.getNode()->setArrayMarker(); - + if(!isa(CurTy) && Value.getNode()->getSize() <= 0){ Value.getNode()->growSize(TD.getTypeAllocSize(CurTy)); From atrick at apple.com Tue Apr 26 20:21:26 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 27 Apr 2011 01:21:26 -0000 Subject: [llvm-commits] [llvm] r130271 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20110427012126.236E92A6C12D@llvm.org> Author: atrick Date: Tue Apr 26 20:21:25 2011 New Revision: 130271 URL: http://llvm.org/viewvc/llvm-project?rev=130271&view=rev Log: Fix for PR9633 [indvars] Assertion `isa(Val) && "cast() argument of incompatible type!"' failed. Added a type check in ScalarEvolution::computeSCEVAtScope to handle the case in which operands of an AddRecExpr in the current scope are folded. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=130271&r1=130270&r2=130271&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Apr 26 20:21:25 2011 @@ -4701,9 +4701,14 @@ for (++i; i != e; ++i) NewOps.push_back(getSCEVAtScope(AddRec->getOperand(i), L)); - AddRec = cast( + const SCEV *FoldedRec = getAddRecExpr(NewOps, AddRec->getLoop(), - AddRec->getNoWrapFlags(SCEV::FlagNW))); + AddRec->getNoWrapFlags(SCEV::FlagNW)); + AddRec = dyn_cast(FoldedRec); + // In cases with "undef" values, a loop's own recurrence may + // fold into a constant. Go ahead and return the optimistic value. + if (!AddRec) + return FoldedRec; break; } From eli.friedman at gmail.com Tue Apr 26 20:34:27 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 01:34:27 -0000 Subject: [llvm-commits] [llvm] r130272 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-i1.ll Message-ID: <20110427013427.405412A6C12D@llvm.org> Author: efriedma Date: Tue Apr 26 20:34:27 2011 New Revision: 130272 URL: http://llvm.org/viewvc/llvm-project?rev=130272&view=rev Log: Fix an edge case involving branches in fast-isel on x86. rdar://problem/9303306 . Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-i1.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130272&r1=130271&r2=130272&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Apr 26 20:34:27 2011 @@ -1098,11 +1098,13 @@ } // Otherwise do a clumsy setcc and re-test it. + // Note that i1 essentially gets ANY_EXTEND'ed to i8 where it isn't used + // in an explicit cast, so make sure to handle that correctly. unsigned OpReg = getRegForValue(BI->getCondition()); if (OpReg == 0) return false; - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::TEST8rr)) - .addReg(OpReg).addReg(OpReg); + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::TEST8ri)) + .addReg(OpReg).addImm(1); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::JNE_4)) .addMBB(TrueMBB); FastEmitBranch(FalseMBB, DL); Modified: llvm/trunk/test/CodeGen/X86/fast-isel-i1.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-i1.ll?rev=130272&r1=130271&r2=130272&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-i1.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-i1.ll Tue Apr 26 20:34:27 2011 @@ -1,19 +1,40 @@ -; RUN: llc < %s -march=x86 -fast-isel | grep {andb \$1, %} +; RUN: llc < %s -march=x86 -fast-isel | FileCheck %s -declare i64 @bar(i64) +declare i64 @test1a(i64) -define i32 @foo(i64 %x) nounwind { - %y = add i64 %x, -3 ; [#uses=1] - %t = call i64 @bar(i64 %y) ; [#uses=1] - %s = mul i64 %t, 77 ; [#uses=1] - %z = trunc i64 %s to i1 ; [#uses=1] +define i32 @test1(i64 %x) nounwind { +; CHECK: test1: +; CHECK: andb $1, % + %y = add i64 %x, -3 + %t = call i64 @test1a(i64 %y) + %s = mul i64 %t, 77 + %z = trunc i64 %s to i1 br label %next next: ; preds = %0 - %u = zext i1 %z to i32 ; [#uses=1] - %v = add i32 %u, 1999 ; [#uses=1] + %u = zext i1 %z to i32 + %v = add i32 %u, 1999 br label %exit exit: ; preds = %next ret i32 %v } + +define void @test2(i8* %a) nounwind { +entry: +; CHECK: test2: +; CHECK: movb {{.*}} %al +; CHECK-NEXT: xorb $1, %al +; CHECK-NEXT: testb $1 + %tmp = load i8* %a, align 1 + %tobool = trunc i8 %tmp to i1 + %tobool2 = xor i1 %tobool, true + br i1 %tobool2, label %if.then, label %if.end + +if.then: + call void @test2(i8* null) + br label %if.end + +if.end: + ret void +} From rafael.espindola at gmail.com Tue Apr 26 20:43:49 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 27 Apr 2011 01:43:49 -0000 Subject: [llvm-commits] [llvm] r130273 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110427014349.9A1AE2A6C12D@llvm.org> Author: rafael Date: Tue Apr 26 20:43:49 2011 New Revision: 130273 URL: http://llvm.org/viewvc/llvm-project?rev=130273&view=rev Log: Force some values to be absolute and align based on the FDE pointers size. A small step towards using .cfi_* on OS X. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130273&r1=130272&r2=130273&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Tue Apr 26 20:43:49 2011 @@ -622,14 +622,14 @@ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); const MCSection §ion = *asmInfo.getEHFrameSection(); streamer.SwitchSection(§ion); - MCSymbol *sectionStart = streamer.getContext().CreateTempSymbol(); + MCSymbol *sectionStart = context.CreateTempSymbol(); MCSymbol *sectionEnd = streamer.getContext().CreateTempSymbol(); // Length const MCExpr *Length = MakeStartMinusEndExpr(streamer, *sectionStart, *sectionEnd, 4); streamer.EmitLabel(sectionStart); - streamer.EmitValue(Length, 4); + streamer.EmitAbsValue(Length, 4); // CIE ID streamer.EmitIntValue(0, 4); @@ -715,13 +715,13 @@ // Length const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0); - streamer.EmitValue(Length, 4); + streamer.EmitAbsValue(Length, 4); streamer.EmitLabel(fdeStart); // CIE Pointer const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, 0); - streamer.EmitValue(offset, 4); + streamer.EmitAbsValue(offset, 4); unsigned fdeEncoding = asmInfo.getFDEEncoding(); unsigned size = getSizeForEncoding(streamer, fdeEncoding); @@ -731,7 +731,7 @@ // PC Range const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin, *frame.End, 0); - streamer.EmitValue(Range, size); + streamer.EmitAbsValue(Range, size); // Augmentation Data Length MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol(); @@ -751,7 +751,7 @@ EmitCFIInstructions(streamer, frame.Instructions, frame.Begin); // Padding - streamer.EmitValueToAlignment(4); + streamer.EmitValueToAlignment(size); return fdeEnd; } From eli.friedman at gmail.com Tue Apr 26 20:45:07 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 01:45:07 -0000 Subject: [llvm-commits] [llvm] r130274 - /llvm/trunk/lib/Target/X86/X86FastISel.cpp Message-ID: <20110427014507.6EF8A2A6C12D@llvm.org> Author: efriedma Date: Tue Apr 26 20:45:07 2011 New Revision: 130274 URL: http://llvm.org/viewvc/llvm-project?rev=130274&view=rev Log: Refactor out code to fast-isel a memcpy operation with a small constant length. (I'm planning to use this to implement byval.) Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130274&r1=130273&r2=130274&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Tue Apr 26 20:45:07 2011 @@ -132,6 +132,9 @@ } bool isTypeLegal(const Type *Ty, MVT &VT, bool AllowI1 = false); + + bool TryEmitSmallMemcpy(X86AddressMode DestAM, + X86AddressMode SrcAM, uint64_t Len); }; } // end anonymous namespace. @@ -1323,6 +1326,40 @@ return false; } +bool X86FastISel::TryEmitSmallMemcpy(X86AddressMode DestAM, + X86AddressMode SrcAM, uint64_t Len) { + // Make sure we don't bloat code by inlining very large memcpy's. + bool i64Legal = TLI.isTypeLegal(MVT::i64); + if (Len > (i64Legal ? 32 : 16)) return false; + + // We don't care about alignment here since we just emit integer accesses. + while (Len) { + MVT VT; + if (Len >= 8 && i64Legal) + VT = MVT::i64; + else if (Len >= 4) + VT = MVT::i32; + else if (Len >= 2) + VT = MVT::i16; + else { + assert(Len == 1); + VT = MVT::i8; + } + + unsigned Reg; + bool RV = X86FastEmitLoad(VT, SrcAM, Reg); + RV &= X86FastEmitStore(VT, Reg, DestAM); + assert(RV && "Failed to emit load or store??"); + + unsigned Size = VT.getSizeInBits()/8; + Len -= Size; + DestAM.Disp += Size; + SrcAM.Disp += Size; + } + + return true; +} + bool X86FastISel::X86VisitIntrinsicCall(const IntrinsicInst &I) { // FIXME: Handle more intrinsics. switch (I.getIntrinsicID()) { @@ -1332,45 +1369,16 @@ // Don't handle volatile or variable length memcpys. if (MCI.isVolatile() || !isa(MCI.getLength())) return false; - - // Don't inline super long memcpys. We could lower these to a memcpy call, - // but we might as well bail out. + uint64_t Len = cast(MCI.getLength())->getZExtValue(); - bool i64Legal = TLI.isTypeLegal(MVT::i64); - if (Len > (i64Legal ? 32 : 16)) return false; // Get the address of the dest and source addresses. X86AddressMode DestAM, SrcAM; if (!X86SelectAddress(MCI.getRawDest(), DestAM) || !X86SelectAddress(MCI.getRawSource(), SrcAM)) return false; - - // We don't care about alignment here since we just emit integer accesses. - while (Len) { - MVT VT; - if (Len >= 8 && i64Legal) - VT = MVT::i64; - else if (Len >= 4) - VT = MVT::i32; - else if (Len >= 2) - VT = MVT::i16; - else { - assert(Len == 1); - VT = MVT::i8; - } - - unsigned Reg; - bool RV = X86FastEmitLoad(VT, SrcAM, Reg); - RV &= X86FastEmitStore(VT, Reg, DestAM); - assert(RV && "Failed to emit load or store??"); - - unsigned Size = VT.getSizeInBits()/8; - Len -= Size; - DestAM.Disp += Size; - SrcAM.Disp += Size; - } - - return true; + + return TryEmitSmallMemcpy(DestAM, SrcAM, Len); } case Intrinsic::stackprotector: { From wdietz2 at illinois.edu Tue Apr 26 22:00:03 2011 From: wdietz2 at illinois.edu (Will Dietz) Date: Wed, 27 Apr 2011 03:00:03 -0000 Subject: [llvm-commits] [poolalloc] r130276 - in /poolalloc/trunk: include/dsa/DSSupport.h lib/DSA/DSGraph.cpp Message-ID: <20110427030003.A942E2A6C12D@llvm.org> Author: wdietz2 Date: Tue Apr 26 22:00:03 2011 New Revision: 130276 URL: http://llvm.org/viewvc/llvm-project?rev=130276&view=rev Log: Switch MappedSites from vector to set. Significantly reduces memory, runtime. If MappedSites is too expensive later/still, perhaps use SuperSet. Allows running -dsa-bu on 176.gcc in 85s and 4G on gravity. (Without this change, it ran for 24 minutes using 7G before I got bored) DSA still runs out of memory in -dsa-cbu on 176.gcc (so no poolalloc). Other than more appropriate datastructure, no functionality changed. Modified: poolalloc/trunk/include/dsa/DSSupport.h poolalloc/trunk/lib/DSA/DSGraph.cpp Modified: poolalloc/trunk/include/dsa/DSSupport.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSSupport.h?rev=130276&r1=130275&r2=130276&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSSupport.h (original) +++ poolalloc/trunk/include/dsa/DSSupport.h Tue Apr 26 22:00:03 2011 @@ -156,13 +156,16 @@ /// the DSNode handles for the function arguments. /// class DSCallSite { +public: + typedef std::set MappedSites_t; +private: CallSite Site; // Actual call site const Function *CalleeF; // The function called (direct call) DSNodeHandle CalleeN; // The function node called (indirect call) DSNodeHandle RetVal; // Returned value DSNodeHandle VarArgVal; // Merged var-arg val std::vector CallArgs; // The pointer arguments - std::vector MappedSites; // The merged callsites + MappedSites_t MappedSites; // The merged callsites static void InitNH(DSNodeHandle &NH, const DSNodeHandle &Src, const std::map &NodeMap) { @@ -226,9 +229,7 @@ CallArgs.resize(FromCall.CallArgs.size()); for (unsigned i = 0, e = FromCall.CallArgs.size(); i != e; ++i) InitNH(CallArgs[i], FromCall.CallArgs[i], NodeMap); - MappedSites.resize(FromCall.MappedSites.size()); - for (unsigned i = 0, e = FromCall.MappedSites.size(); i != e; ++i) - MappedSites[i] = FromCall.MappedSites[i]; + MappedSites = FromCall.MappedSites; } const DSCallSite &operator=(const DSCallSite &RHS) { @@ -278,14 +279,9 @@ return CallArgs[i]; } - CallSite &getMappedCallSite(unsigned i) { - assert(i < MappedSites.size() && "Argument to getMappedCallSite is out of range!"); - return MappedSites[i]; - } - const CallSite &getMappedCallSite(unsigned i) const { - assert(i < MappedSites.size() && "Argument to getMappedCallSite is out of range!"); - return MappedSites[i]; - } + + const MappedSites_t::iterator ms_begin() const { return MappedSites.begin(); } + const MappedSites_t::iterator ms_end() const { return MappedSites.end(); } void addPtrArg(const DSNodeHandle &NH) { CallArgs.push_back(NH); @@ -318,9 +314,8 @@ for (unsigned a = MinArgs, e = CS.getNumPtrArgs(); a != e; ++a) CallArgs.push_back(CS.getPtrArg(a)); - MappedSites.push_back(CS.getCallSite()); - for (unsigned a = 0, e = CS.MappedSites.size(); a != e; ++a) - MappedSites.push_back(CS.MappedSites[a]); + MappedSites.insert(CS.getCallSite()); + MappedSites.insert(CS.ms_begin(), CS.ms_end()); } /// markReachableNodes - This method recursively traverses the specified Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=130276&r1=130275&r2=130276&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DSGraph.cpp (original) +++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Apr 26 22:00:03 2011 @@ -1650,8 +1650,8 @@ // const std::list& Calls = getFunctionCalls(); for (std::list::const_iterator ii = Calls.begin(), - ee = Calls.end(); - ii != ee; ++ii) { + ee = Calls.end(); + ii != ee; ++ii) { // // Direct calls are easy. We know to where they go. // @@ -1685,18 +1685,20 @@ DCG.insert(CS, *Fi); else ++NumFiltered; - for (unsigned i = 0; i < ii->getNumMappedSites(); i++) { - CallSite MCS = ii->getMappedCallSite(i); - for (std::vector::iterator Fi = MaybeTargets.begin(), + for (DSCallSite::MappedSites_t::iterator I = ii->ms_begin(), + E = ii->ms_end(); I != E; ++I) { + CallSite MCS = *I; + for (std::vector::iterator Fi = MaybeTargets.begin(), Fe = MaybeTargets.end(); Fi != Fe; ++Fi) if (!filter || functionIsCallable(MCS, *Fi)) DCG.insert(MCS, *Fi); else ++NumFiltered; - } + } } } } + void DSGraph::buildCompleteCallGraph(DSCallGraph& DCG, std::vector& GlobalFunctionList, bool filter) const { // @@ -1724,10 +1726,12 @@ DCG.insert(CS, *Fi); else ++NumFiltered; - for (unsigned i = 0; i < ii->getNumMappedSites(); i++) { - CallSite MCS = ii->getMappedCallSite(i); + + for (DSCallSite::MappedSites_t::iterator I = ii->ms_begin(), + E = ii->ms_end(); I != E; ++I) { + CallSite MCS = *I; for (std::vector::iterator Fi = MaybeTargets.begin(), - Fe = MaybeTargets.end(); Fi != Fe; ++Fi){ + Fe = MaybeTargets.end(); Fi != Fe; ++Fi) { if (!filter || functionIsCallable(MCS, *Fi)) DCG.insert(MCS, *Fi); else From mttjwl at gmail.com Tue Apr 26 22:13:18 2011 From: mttjwl at gmail.com (Matthew Wala) Date: Wed, 27 Apr 2011 03:13:18 -0000 Subject: [llvm-commits] [poolalloc] r130278 - in /poolalloc/trunk: include/dsa/CStdLib.h include/poolalloc/PoolAllocate.h lib/DSA/StdLibPass.cpp lib/PoolAllocate/PoolAllocate.cpp Message-ID: <20110427031318.A09052A6C12D@llvm.org> Author: wala1 Date: Tue Apr 26 22:13:18 2011 New Revision: 130278 URL: http://llvm.org/viewvc/llvm-project?rev=130278&view=rev Log: Created a new table with C string function information that will be shared with SAFECode, and made pool allocation use this table for argument information. Also inserted transformed C string function information to StdLibPass. Added: poolalloc/trunk/include/dsa/CStdLib.h Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h poolalloc/trunk/lib/DSA/StdLibPass.cpp poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Added: poolalloc/trunk/include/dsa/CStdLib.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/CStdLib.h?rev=130278&view=auto ============================================================================== --- poolalloc/trunk/include/dsa/CStdLib.h (added) +++ poolalloc/trunk/include/dsa/CStdLib.h Tue Apr 26 22:13:18 2011 @@ -0,0 +1,48 @@ +//===- CStdLib.h - CStdLib Function Information ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Tables to hold information about transformed CStdLib functions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CSTDLIB_H +#define LLVM_CSTDLIB_H + +namespace llvm { + + const struct CStdLibPoolArgCountEntry { + const char *function; + unsigned pool_argc; + } \ + CStdLibPoolArgCounts[] = { + { "pool_strcpy", 2 }, + { "pool_stpcpy", 2 }, + { "pool_strncpy", 2 }, + { "pool_strlen", 1 }, + { "pool_strchr", 1 }, + { "pool_strrchr", 1 }, + { "pool_strcat", 2 }, + { "pool_strncat", 2 }, + { "pool_strstr", 2 }, + { "pool_strpbrk", 2 }, + { "pool_strcmp", 2 }, + { "pool_strcmp", 2 }, + { "pool_memcmp", 2 }, + { "pool_strcasecmp", 2 }, + { "pool_strncasecmp", 2 }, + { "pool_strspn", 2 }, + { "pool_strcspn", 2 }, + { "pool_memccpy", 2 }, + { "pool_memchr", 1 }, + { 0, 0 } + }; + +} // End llvm namespace + +#endif Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=130278&r1=130277&r2=130278&view=diff ============================================================================== --- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original) +++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Tue Apr 26 22:13:18 2011 @@ -210,9 +210,6 @@ // Map a cloned function to its original function std::map CloneToOrigMap; - // Map a CStdLib function name to its pool argument count. - StringMap CStdLibPoolArgs; - public: Constant *PoolInit, *PoolDestroy, *PoolAlloc, *PoolRealloc, *PoolMemAlign, *PoolThreadWrapper; @@ -248,7 +245,6 @@ lie_preserve_passes = SAFECodeEnabled ? LIE_PRESERVE_ALL : LIE_PRESERVE_DSA; dsa_pass_to_use = SAFECodeEnabled ? PASS_EQTD : PASS_BUEQ; - InitializeCStdLibPoolArgs(); } /*TODO: finish removing the SAFECode flag*/ @@ -272,7 +268,6 @@ else dsa_pass_to_use = dsa_pass_to_use_; - InitializeCStdLibPoolArgs(); } virtual bool runOnModule(Module &M); @@ -439,9 +434,6 @@ private: - /// Initialiaze the pool argument counts. - void InitializeCStdLibPoolArgs(); - /// MicroOptimizePoolCalls - Apply any microoptimizations to calls to pool /// allocation function calls that we can. void MicroOptimizePoolCalls(); Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=130278&r1=130277&r2=130278&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Tue Apr 26 22:13:18 2011 @@ -74,14 +74,17 @@ bool collapse; }; -#define NRET_NARGS {0,0,0,0,0,0,0,0,0,0} -#define YRET_NARGS {1,0,0,0,0,0,0,0,0,0} -#define NRET_YARGS {0,1,1,1,1,1,1,1,1,1} -#define YRET_YARGS {1,1,1,1,1,1,1,1,1,1} -#define NRET_NYARGS {0,0,1,1,1,1,1,1,1,1} -#define YRET_NYARGS {1,0,1,1,1,1,1,1,1,1} -#define NRET_YNARGS {0,1,0,0,0,0,0,0,0,0} -#define YRET_YNARGS {1,1,0,0,0,0,0,0,0,0} +#define NRET_NARGS {0,0,0,0,0,0,0,0,0,0} +#define YRET_NARGS {1,0,0,0,0,0,0,0,0,0} +#define NRET_YARGS {0,1,1,1,1,1,1,1,1,1} +#define YRET_YARGS {1,1,1,1,1,1,1,1,1,1} +#define NRET_NYARGS {0,0,1,1,1,1,1,1,1,1} +#define YRET_NYARGS {1,0,1,1,1,1,1,1,1,1} +#define NRET_YNARGS {0,1,0,0,0,0,0,0,0,0} +#define YRET_YNARGS {1,1,0,0,0,0,0,0,0,0} +#define YRET_NNYARGS {1,0,0,1,1,1,1,1,1,1} +#define NRET_NNYARGS {0,0,0,1,1,1,1,1,1,1} +#define YRET_NNYNARGS {1,0,0,1,0,0,0,0,0,0} const struct { const char* name; @@ -262,6 +265,29 @@ {"sc.pool_unregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"sc.pool_argvregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + // CStdLib Runtime Checks + {"pool_strncpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_stpcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strrchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strcat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strncat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strstr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, + {"pool_strpbrk", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, + {"pool_strspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, + {"pool_strcspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, + {"pool_memccpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_memchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strncmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strnlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_memcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strcasecmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strncasecmp",{NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + + #if 0 {"wait", {false, false, false, false, true, false, false, false, false}}, #endif Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=130278&r1=130277&r2=130278&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Apr 26 22:13:18 2011 @@ -16,6 +16,7 @@ #define DEBUG_TYPE "poolalloc" +#include "dsa/CStdLib.h" #include "dsa/DataStructure.h" #include "dsa/DSGraph.h" #include "poolalloc/Heuristic.h" @@ -1563,42 +1564,11 @@ } } -// Builds the StringMap that holds information about the pool -// argument counts of C standard library functions. -void PoolAllocate::InitializeCStdLibPoolArgs() -{ - CStdLibPoolArgs.GetOrCreateValue("pool_strcpy", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strncpy", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strlen", 1); - CStdLibPoolArgs.GetOrCreateValue("pool_strchr", 1); - CStdLibPoolArgs.GetOrCreateValue("pool_strrchr", 1); - CStdLibPoolArgs.GetOrCreateValue("pool_strcat", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strncat", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strstr", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strpbrk", 2); - - CStdLibPoolArgs.GetOrCreateValue("pool_strcmp", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strncmp", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_memcmp", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strcasecmp", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strncasecmp", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strspn", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_strcspn", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_memccpy", 2); - CStdLibPoolArgs.GetOrCreateValue("pool_memchr", 1); - //CStdLibPoolArgs.GetOrCreateValue("pool_strtok", 2); - //CStdLibPoolArgs.GetOrCreateValue("pool_strtok_r", 2); - //CStdLibPoolArgs.GetOrCreateValue("pool_strspn", 2); - //CStdLibPoolArgs.GetOrCreateValue("pool_strcspn", 2); -} - // Return the number of initial pool arguments for the specified CStdLib // function, or 0 if it is not found in the table. -unsigned PoolAllocate::getCStdLibPoolArguments(StringRef funcname) -{ - StringMap::const_iterator argc = CStdLibPoolArgs.find(funcname); - if (argc != CStdLibPoolArgs.end()) - return argc->getValue(); - else - return 0; +unsigned PoolAllocate::getCStdLibPoolArguments(StringRef funcname) { + const CStdLibPoolArgCountEntry *entries = &CStdLibPoolArgCounts[0]; + while (entries->function && entries->function != funcname) + entries++; + return entries->pool_argc; } From nicholas at mxc.ca Tue Apr 26 22:22:17 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 27 Apr 2011 03:22:17 -0000 Subject: [llvm-commits] [llvm] r130279 - /llvm/trunk/runtime/libprofile/PathProfiling.c Message-ID: <20110427032217.9E7752A6C12D@llvm.org> Author: nicholas Date: Tue Apr 26 22:22:17 2011 New Revision: 130279 URL: http://llvm.org/viewvc/llvm-project?rev=130279&view=rev Log: Use static inline to do the right thing when built in C99 mode. Of course, C89 doesn't have an inline keyword. Modified: llvm/trunk/runtime/libprofile/PathProfiling.c Modified: llvm/trunk/runtime/libprofile/PathProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/PathProfiling.c?rev=130279&r1=130278&r2=130279&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/PathProfiling.c (original) +++ llvm/trunk/runtime/libprofile/PathProfiling.c Tue Apr 26 22:22:17 2011 @@ -104,7 +104,7 @@ } } -inline uint32_t hash (uint32_t key) { +static inline uint32_t hash (uint32_t key) { /* this may benefit from a proper hash function */ return key%ARBITRARY_HASH_BIN_COUNT; } @@ -147,7 +147,8 @@ } /* Return a pointer to this path's specific path counter */ -inline uint32_t* getPathCounter(uint32_t functionNumber, uint32_t pathNumber) { +static inline uint32_t* getPathCounter(uint32_t functionNumber, + uint32_t pathNumber) { pathHashTable_t* hashTable; pathHashEntry_t* hashEntry; uint32_t index = hash(pathNumber); From wdietz2 at illinois.edu Tue Apr 26 23:47:40 2011 From: wdietz2 at illinois.edu (Will Dietz) Date: Wed, 27 Apr 2011 04:47:40 -0000 Subject: [llvm-commits] [poolalloc] r130287 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/DSGraph.cpp lib/DSA/TopDownClosure.cpp Message-ID: <20110427044740.2CFF52A6C12D@llvm.org> Author: wdietz2 Date: Tue Apr 26 23:47:39 2011 New Revision: 130287 URL: http://llvm.org/viewvc/llvm-project?rev=130287&view=rev Log: Use DenseSet instead of svset when marking nodes during graph traversal. Theoretically this should be much faster but use more memory... Experimentally this is significantly faster (~4x faster on 176.gcc TD), but uses essentially the same amount of memory. svset's are inferior here due to very slow insert (sorted vector insert) Modified: poolalloc/trunk/include/dsa/DataStructure.h poolalloc/trunk/lib/DSA/DSGraph.cpp poolalloc/trunk/lib/DSA/TopDownClosure.cpp Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=130287&r1=130286&r2=130287&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Tue Apr 26 23:47:39 2011 @@ -18,6 +18,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/CallSite.h" #include "llvm/ADT/EquivalenceClasses.h" +#include "llvm/ADT/DenseSet.h" #include "dsa/DSCallGraph.h" #include "dsa/svset.h" @@ -380,10 +381,10 @@ private: void markReachableFunctionsExternallyAccessible(DSNode *N, - svset &Visited); + DenseSet &Visited); void InlineCallersIntoGraph(DSGraph* G); - void ComputePostOrder(const Function &F, svset &Visited, + void ComputePostOrder(const Function &F, DenseSet &Visited, std::vector &PostOrder); }; Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=130287&r1=130286&r2=130287&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DSGraph.cpp (original) +++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Apr 26 23:47:39 2011 @@ -681,7 +681,7 @@ // markExternalNode -- Marks the specified node, and all that's reachable from it, // as external. Uses 'processedNodes' to track recursion. -static void markExternalNode(DSNode *N, svset & processedNodes) { +static void markExternalNode(DSNode *N, DenseSet & processedNodes) { // Stop recursion if no node, or if node already processed if (N == 0 || processedNodes.count(N) ) return; @@ -699,7 +699,7 @@ } // markExternal --marks the specified callsite external, using 'processedNodes' to track recursion. -static void markExternal(const DSCallSite &Call, svset & processedNodes) { +static void markExternal(const DSCallSite &Call, DenseSet & processedNodes) { markExternalNode(Call.getRetVal().getNode(), processedNodes); markExternalNode(Call.getVAVal().getNode(), processedNodes); @@ -711,7 +711,7 @@ // propagateExternal -- Walk the given DSGraph making sure that within this graph // everything reachable from an already-external node is also marked External. -static void propagateExternal(DSGraph * G, svset & processedNodes) { +static void propagateExternal(DSGraph * G, DenseSet & processedNodes) { DSGraph::node_iterator I = G->node_begin(), E = G->node_end(); for ( ; I != E; ++I ) { @@ -731,7 +731,7 @@ // computeExternalFlags -- mark all reachable from external as external void DSGraph::computeExternalFlags(unsigned Flags) { - svset processedNodes; + DenseSet processedNodes; // Reset if indicated if (Flags & ResetExternal) { Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=130287&r1=130286&r2=130287&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Tue Apr 26 23:47:39 2011 @@ -49,7 +49,7 @@ } void TDDataStructures::markReachableFunctionsExternallyAccessible(DSNode *N, - svset &Visited) { + DenseSet &Visited) { if (!N || Visited.count(N)) return; Visited.insert(N); @@ -93,7 +93,7 @@ // arguments are functions which are reachable by incomplete or external // nodes in the globals graph. const DSScalarMap &GGSM = GlobalsGraph->getScalarMap(); - svset Visited; + DenseSet Visited; for (DSScalarMap::global_iterator I=GGSM.global_begin(), E=GGSM.global_end(); I != E; ++I) { DSNode *N = GGSM.find(*I)->second.getNode(); @@ -130,7 +130,7 @@ // We want to traverse the call graph in reverse post-order. To do this, we // calculate a post-order traversal, then reverse it. - svset VisitedGraph; + DenseSet VisitedGraph; std::vector PostOrder; {TIME_REGION(XXX, "td:Compute postorder"); @@ -194,7 +194,7 @@ void TDDataStructures::ComputePostOrder(const Function &F, - svset &Visited, + DenseSet &Visited, std::vector &PostOrder) { if (F.isDeclaration()) return; DSGraph* G = getOrCreateGraph(&F); From atrick at apple.com Wed Apr 27 00:42:17 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 27 Apr 2011 05:42:17 -0000 Subject: [llvm-commits] [llvm] r130294 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll Message-ID: <20110427054217.4577B2A6C12D@llvm.org> Author: atrick Date: Wed Apr 27 00:42:17 2011 New Revision: 130294 URL: http://llvm.org/viewvc/llvm-project?rev=130294&view=rev Log: Test case and comment for PR9633. Added: llvm/trunk/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=130294&r1=130293&r2=130294&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Apr 27 00:42:17 2011 @@ -4705,8 +4705,9 @@ getAddRecExpr(NewOps, AddRec->getLoop(), AddRec->getNoWrapFlags(SCEV::FlagNW)); AddRec = dyn_cast(FoldedRec); - // In cases with "undef" values, a loop's own recurrence may - // fold into a constant. Go ahead and return the optimistic value. + // The addrec may be folded to a nonrecurrence, for example, if the + // induction variable is multiplied by zero after constant folding. Go + // ahead and return the folded value. if (!AddRec) return FoldedRec; break; Added: llvm/trunk/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll?rev=130294&view=auto ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll (added) +++ llvm/trunk/test/Analysis/ScalarEvolution/2011-04-26-FoldAddRec.ll Wed Apr 27 00:42:17 2011 @@ -0,0 +1,33 @@ +; RUN: opt < %s -analyze -iv-users +; PR9633: Tests that SCEV handles the mul.i2 recurrence being folded to +; constant zero. + +define signext i8 @func_14(i8 signext %p_18) nounwind readnone ssp { +entry: + br label %for.inc + +for.inc: + %p_17.addr.012 = phi i32 [ 0, %entry ], [ %add, %for.inc ] + %add = add nsw i32 %p_17.addr.012, 1 + br i1 false, label %for.inc, label %for.cond + +for.cond: + %tobool.i = icmp ult i32 %add, 8192 + %shl.i = select i1 %tobool.i, i32 13, i32 0 + %shl.left.i = shl i32 %add, %shl.i + %conv.i4 = trunc i32 %shl.left.i to i8 + br i1 undef, label %for.inc9, label %if.then + +for.inc9: + %p_18.addr.011 = phi i8 [ %add12, %for.inc9 ], [ %p_18, %for.cond ] + %add12 = add i8 %p_18.addr.011, 1 + %mul.i2 = mul i8 %add12, %conv.i4 + %mul.i2.lobit = lshr i8 %mul.i2, 7 + %lor.ext.shr.i = select i1 undef, i8 %mul.i2.lobit, i8 %mul.i2 + %tobool = icmp eq i8 %lor.ext.shr.i, 0 + br i1 %tobool, label %for.inc9, label %if.then + +if.then: + ret i8 0 + +} \ No newline at end of file From baldrick at free.fr Wed Apr 27 01:51:48 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 08:51:48 +0200 Subject: [llvm-commits] [llvm] r130272 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-i1.ll In-Reply-To: <20110427013427.405412A6C12D@llvm.org> References: <20110427013427.405412A6C12D@llvm.org> Message-ID: <4DB7BD04.7020303@free.fr> Hi Eli, > + // Note that i1 essentially gets ANY_EXTEND'ed to i8 where it isn't used > + // in an explicit cast, so make sure to handle that correctly. I don't understand this comment. An i1 branch condition is zero extended to i8 by the type legalizer on x86. Ciao, Duncan. > unsigned OpReg = getRegForValue(BI->getCondition()); > if (OpReg == 0) return false; > > - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::TEST8rr)) > - .addReg(OpReg).addReg(OpReg); > + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::TEST8ri)) > + .addReg(OpReg).addImm(1); > BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(X86::JNE_4)) > .addMBB(TrueMBB); > FastEmitBranch(FalseMBB, DL); From baldrick at free.fr Wed Apr 27 01:57:55 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 08:57:55 +0200 Subject: [llvm-commits] [llvm] r130241 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/Transforms/PhaseOrdering/ test/Transforms/PhaseOrdering/basic.ll test/Transforms/ScalarRepl/dg.exp In-Reply-To: <20110426204533.E64DB2A6C12D@llvm.org> References: <20110426204533.E64DB2A6C12D@llvm.org> Message-ID: <4DB7BE73.3070302@free.fr> Hi Chris, > 2. Move the "clean up after the unroller" pass to the very end of the > function-level pass pipeline. Loop unroll uses instsimplify now, > so it doesn't create a ton of trash. Moving instcombine later allows > it to clean up after opportunities are exposed by GVN, DSE, etc. am I right in thinking that there is no longer any point to having instcombine try to preserve LCSSA form? If so, I will rip that code out. Ciao, Duncan. From clattner at apple.com Wed Apr 27 02:27:51 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 27 Apr 2011 00:27:51 -0700 Subject: [llvm-commits] [llvm] r130241 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/Transforms/PhaseOrdering/ test/Transforms/PhaseOrdering/basic.ll test/Transforms/ScalarRepl/dg.exp In-Reply-To: <4DB7BE73.3070302@free.fr> References: <20110426204533.E64DB2A6C12D@llvm.org> <4DB7BE73.3070302@free.fr> Message-ID: <327B8B9E-6444-4B0B-AA5A-8BB2E86EC580@apple.com> On Apr 26, 2011, at 11:57 PM, Duncan Sands wrote: > Hi Chris, > >> 2. Move the "clean up after the unroller" pass to the very end of the >> function-level pass pipeline. Loop unroll uses instsimplify now, >> so it doesn't create a ton of trash. Moving instcombine later allows >> it to clean up after opportunities are exposed by GVN, DSE, etc. > > am I right in thinking that there is no longer any point to having instcombine > try to preserve LCSSA form? If so, I will rip that code out. Yep, I'm pretty sure that we haven't been running instcombine in the loop pass manager for quite a while. Cameron, is this true? -Chris From zwarich at apple.com Wed Apr 27 02:36:30 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 27 Apr 2011 00:36:30 -0700 Subject: [llvm-commits] [llvm] r130241 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/Transforms/PhaseOrdering/ test/Transforms/PhaseOrdering/basic.ll test/Transforms/ScalarRepl/dg.exp In-Reply-To: <327B8B9E-6444-4B0B-AA5A-8BB2E86EC580@apple.com> References: <20110426204533.E64DB2A6C12D@llvm.org> <4DB7BE73.3070302@free.fr> <327B8B9E-6444-4B0B-AA5A-8BB2E86EC580@apple.com> Message-ID: <89E1FFB7-F2F8-46C0-95C6-60891EED5E41@apple.com> On 2011-04-27, at 12:27 AM, Chris Lattner wrote: > On Apr 26, 2011, at 11:57 PM, Duncan Sands wrote: > >> Hi Chris, >> >>> 2. Move the "clean up after the unroller" pass to the very end of the >>> function-level pass pipeline. Loop unroll uses instsimplify now, >>> so it doesn't create a ton of trash. Moving instcombine later allows >>> it to clean up after opportunities are exposed by GVN, DSE, etc. >> >> am I right in thinking that there is no longer any point to having instcombine >> try to preserve LCSSA form? If so, I will rip that code out. > > Yep, I'm pretty sure that we haven't been running instcombine in the loop pass manager for quite a while. Cameron, is this true? Yeah, instcombine breaks the pipelining of the loop pass manager in the way that we were running it as a function pass, so there were two loop pass managers. Since loop passes can't be preserved across loop pass managers, LCSSA was always recomputed afterwards: Loop Invariant Code Motion Loop-Closed SSA Form Pass Unswitch loops Combine redundant instructions Scalar Evolution Analysis Loop Pass Manager Canonicalize natural loops Loop-Closed SSA Form Pass Cameron From geek4civic at gmail.com Wed Apr 27 02:48:50 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 27 Apr 2011 16:48:50 +0900 Subject: [llvm-commits] [PATCH] docs/doxygen.css: Tweak style for readability. Message-ID: A few styles are brought from http://llvm.org/test-doxygen/api/api.css --- docs/doxygen.css | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) --- Sample site is; http://t.pgr.jp/doxygen/html/ (Generated on Thu Dec 9 02:32:15 2010) May I commit it? ...Takumi -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-docs-doxygen.css-Tweak-style-for-readability.patch.txt Type: text/x-patch Size: 998 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110427/39886e65/attachment.bin From baldrick at free.fr Wed Apr 27 04:18:45 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 09:18:45 -0000 Subject: [llvm-commits] [dragonegg] r130300 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110427091845.36B5E2A6C12D@llvm.org> Author: baldrick Date: Wed Apr 27 04:18:45 2011 New Revision: 130300 URL: http://llvm.org/viewvc/llvm-project?rev=130300&view=rev Log: PLUS_EXPR and MINUS_EXPR no longer take pointer arguments (all pointer arithmetic uses POINTER_PLUS_EXPR) and it looks like the return type now always matches the argument types. Simplify binop handling using this. Note that if any of the above fails to hold then an assertion will fire. While there, rename a function. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130300&r1=130299&r2=130300&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Wed Apr 27 04:18:45 2011 @@ -493,7 +493,7 @@ /// using LoadRegisterFromMemory to load a register value back out starting from /// byte StartingByte. Constant *ExtractRegisterFromConstant(Constant *C, tree type, int StartingByte) { - // NOTE: Needs to be kept in sync with getRegType and EncapsulateRegister. + // NOTE: Needs to be kept in sync with getRegType and RepresentAsMemory. int StartingBit = StartingByte * BITS_PER_UNIT; switch (TREE_CODE(type)) { @@ -559,11 +559,18 @@ // ... ConvertInitializer ... //===----------------------------------------------------------------------===// -/// EncapsulateRegister - Turn a constant of in-register type (corresponding +/// getAsRegister - Turn the given GCC scalar constant into an LLVM constant of +/// register type. +static Constant *getAsRegister(tree exp) { + Constant *C = ConvertInitializer(exp); + return ExtractRegisterFromConstant(C, TREE_TYPE(exp)); +} + +/// RepresentAsMemory - Turn a constant of in-register type (corresponding /// to the given GCC type) into an in-memory constant. The result has the /// property that applying ExtractRegisterFromConstant to it gives you the /// original in-register constant back again. -static Constant *EncapsulateRegister(Constant *C, tree type) { +static Constant *RepresentAsMemory(Constant *C, tree type) { // NOTE: Needs to be kept in sync with ExtractRegisterFromConstant. assert(C->getType() == getRegType(type) && "Constant has wrong type!"); Constant *Result; @@ -594,8 +601,8 @@ unsigned Idx[2] = {0, 1}; Constant *Real = TheFolder->CreateExtractValue(C, Idx, 1); Constant *Imag = TheFolder->CreateExtractValue(C, Idx + 1, 1); - Real = EncapsulateRegister(Real, elt_type); - Imag = EncapsulateRegister(Imag, elt_type); + Real = RepresentAsMemory(Real, elt_type); + Imag = RepresentAsMemory(Imag, elt_type); Constant *Vals[2] = { Real, Imag }; Result = ConstantStruct::get(Context, Vals, 2, false); break; @@ -622,7 +629,7 @@ for (unsigned i = 0; i != NumElts; ++i) { ConstantInt *Idx = ConstantInt::get(Type::getInt32Ty(Context), i); Vals[i] = TheFolder->CreateExtractElement(C, Idx); - Vals[i] = EncapsulateRegister(Vals[i], elt_type); + Vals[i] = RepresentAsMemory(Vals[i], elt_type); } // The elements may have funky types, so forming a vector may not always be // possible. @@ -642,13 +649,6 @@ return Result; } -/// getAsRegister - Turn the given GCC scalar constant into an LLVM constant of -/// register type. -static Constant *getAsRegister(tree exp) { - Constant *C = ConvertInitializer(exp); - return ExtractRegisterFromConstant(C, TREE_TYPE(exp)); -} - /// ConvertInitializerWithCast - Convert the initial value for a global variable /// to an equivalent LLVM constant then cast to the given type if both the type /// and the initializer are scalar. This is convenient for making explicit the @@ -684,8 +684,7 @@ DestIsSigned); C = TheFolder->CreateCast(opcode, C, DestTy); - // Turn the register constant back into an in-memory constant. - return EncapsulateRegister(C, type); + return RepresentAsMemory(C, type); } /// ConvertCST - Return the given simple constant as an array of bytes. For the @@ -1213,34 +1212,16 @@ } } -static Constant *ConvertBinOp_CST(tree exp) { +static Constant *ConvertMINUS_EXPR(tree exp) { Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0)); - bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 0))); Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1)); - bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(TREE_OPERAND(exp, 1))); - Instruction::CastOps opcode; - if (LHS->getType()->isPointerTy()) { - const Type *IntPtrTy = getTargetData().getIntPtrType(Context); - opcode = CastInst::getCastOpcode(LHS, LHSIsSigned, IntPtrTy, false); - LHS = TheFolder->CreateCast(opcode, LHS, IntPtrTy); - opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, IntPtrTy, false); - RHS = TheFolder->CreateCast(opcode, RHS, IntPtrTy); - } - - Constant *Result; - switch (TREE_CODE(exp)) { - default: assert(0 && "Unexpected case!"); - case PLUS_EXPR: Result = TheFolder->CreateAdd(LHS, RHS); break; - case MINUS_EXPR: Result = TheFolder->CreateSub(LHS, RHS); break; - } - - const Type *Ty = getRegType(TREE_TYPE(exp)); - bool TyIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); - opcode = CastInst::getCastOpcode(Result, LHSIsSigned, Ty, TyIsSigned); - Result = TheFolder->CreateCast(opcode, Result, Ty); + return RepresentAsMemory(TheFolder->CreateSub(LHS, RHS), TREE_TYPE(exp)); +} - // Turn the register constant back into an in-memory constant. - return EncapsulateRegister(Result, TREE_TYPE(exp)); +static Constant *ConvertPLUS_EXPR(tree exp) { + Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0)); + Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1)); + return RepresentAsMemory(TheFolder->CreateAdd(LHS, RHS), TREE_TYPE(exp)); } static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { @@ -1256,8 +1237,7 @@ // The result may be of a different pointer type. Result = TheFolder->CreateBitCast(Result, getRegType(TREE_TYPE(exp))); - // Turn the register constant back into an in-memory constant. - return EncapsulateRegister(Result, TREE_TYPE(exp)); + return RepresentAsMemory(Result, TREE_TYPE(exp)); } static Constant *ConvertVIEW_CONVERT_EXPR(tree exp) { @@ -1299,8 +1279,10 @@ Init = ConvertInitializerWithCast(TREE_OPERAND(exp, 0), TREE_TYPE(exp)); break; case MINUS_EXPR: + Init = ConvertMINUS_EXPR(exp); + break; case PLUS_EXPR: - Init = ConvertBinOp_CST(exp); + Init = ConvertPLUS_EXPR(exp); break; case POINTER_PLUS_EXPR: Init = ConvertPOINTER_PLUS_EXPR(exp); From baldrick at free.fr Wed Apr 27 05:55:12 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 10:55:12 -0000 Subject: [llvm-commits] [llvm] r130301 - in /llvm/trunk/lib/Transforms/InstCombine: InstCombine.h InstCombinePHI.cpp InstructionCombining.cpp Message-ID: <20110427105512.7C28A2A6C12D@llvm.org> Author: baldrick Date: Wed Apr 27 05:55:12 2011 New Revision: 130301 URL: http://llvm.org/viewvc/llvm-project?rev=130301&view=rev Log: Stop trying to have instcombine preserve LCSSA form: this was not effective in avoiding recomputation of LCSSA form; the widespread use of instsimplify (which looks through phi nodes) means it was not preserving LCSSA form anyway; and instcombine is no longer scheduled in the middle of the loop passes so this doesn't matter anymore. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombine.h llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombine.h?rev=130301&r1=130300&r2=130301&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombine.h (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombine.h Wed Apr 27 05:55:12 2011 @@ -70,7 +70,6 @@ : public FunctionPass, public InstVisitor { TargetData *TD; - bool MustPreserveLCSSA; bool MadeIRChange; public: /// Worklist - All of the instructions that need to be simplified. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp?rev=130301&r1=130300&r2=130301&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombinePHI.cpp Wed Apr 27 05:55:12 2011 @@ -774,9 +774,6 @@ // PHINode simplification // Instruction *InstCombiner::visitPHINode(PHINode &PN) { - // If LCSSA is around, don't mess with Phi nodes - if (MustPreserveLCSSA) return 0; - if (Value *V = SimplifyInstruction(&PN, TD)) return ReplaceInstUsesWith(PN, V); Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=130301&r1=130300&r2=130301&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Apr 27 05:55:12 2011 @@ -76,7 +76,6 @@ "Combine redundant instructions", false, false) void InstCombiner::getAnalysisUsage(AnalysisUsage &AU) const { - AU.addPreservedID(LCSSAID); AU.setPreservesCFG(); } @@ -1637,7 +1636,6 @@ bool InstCombiner::runOnFunction(Function &F) { - MustPreserveLCSSA = mustPreserveAnalysisID(LCSSAID); TD = getAnalysisIfAvailable(); From baldrick at free.fr Wed Apr 27 06:53:52 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 13:53:52 +0200 Subject: [llvm-commits] [llvm] r130241 - in /llvm/trunk: include/llvm/Support/StandardPasses.h test/Transforms/PhaseOrdering/ test/Transforms/PhaseOrdering/basic.ll test/Transforms/ScalarRepl/dg.exp In-Reply-To: <89E1FFB7-F2F8-46C0-95C6-60891EED5E41@apple.com> References: <20110426204533.E64DB2A6C12D@llvm.org> <4DB7BE73.3070302@free.fr> <327B8B9E-6444-4B0B-AA5A-8BB2E86EC580@apple.com> <89E1FFB7-F2F8-46C0-95C6-60891EED5E41@apple.com> Message-ID: <4DB803D0.7070204@free.fr> Thanks Cameron. I've removed the LCSSA form preserving logic from instcombine. Ciao, Duncan. On 27/04/11 09:36, Cameron Zwarich wrote: > On 2011-04-27, at 12:27 AM, Chris Lattner wrote: > >> On Apr 26, 2011, at 11:57 PM, Duncan Sands wrote: >> >>> Hi Chris, >>> >>>> 2. Move the "clean up after the unroller" pass to the very end of the >>>> function-level pass pipeline. Loop unroll uses instsimplify now, >>>> so it doesn't create a ton of trash. Moving instcombine later allows >>>> it to clean up after opportunities are exposed by GVN, DSE, etc. >>> >>> am I right in thinking that there is no longer any point to having instcombine >>> try to preserve LCSSA form? If so, I will rip that code out. >> >> Yep, I'm pretty sure that we haven't been running instcombine in the loop pass manager for quite a while. Cameron, is this true? > > Yeah, instcombine breaks the pipelining of the loop pass manager in the way that we were running it as a function pass, so there were two loop pass managers. Since loop passes can't be preserved across loop pass managers, LCSSA was always recomputed afterwards: > > Loop Invariant Code Motion > Loop-Closed SSA Form Pass > Unswitch loops > Combine redundant instructions > Scalar Evolution Analysis > Loop Pass Manager > Canonicalize natural loops > Loop-Closed SSA Form Pass > > Cameron From baldrick at free.fr Wed Apr 27 09:21:53 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 14:21:53 -0000 Subject: [llvm-commits] [dragonegg] r130302 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110427142153.808E42A6C12D@llvm.org> Author: baldrick Date: Wed Apr 27 09:21:53 2011 New Revision: 130302 URL: http://llvm.org/viewvc/llvm-project?rev=130302&view=rev Log: Initializers for global variables are typically converted at least twice. Cache conversion results so that the work of conversion only needs to be done once. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130302&r1=130301&r2=130302&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Wed Apr 27 09:21:53 2011 @@ -26,6 +26,9 @@ #include "dragonegg/Trees.h" #include "dragonegg/ADT/IntervalList.h" #include "dragonegg/ADT/Range.h" +extern "C" { +#include "dragonegg/cache.h" +} // LLVM headers #include "llvm/GlobalVariable.h" @@ -1255,6 +1258,10 @@ /// initial value may exceed the alloc size of the LLVM memory type generated /// for the GCC type (see ConvertType); it is never smaller than the alloc size. Constant *ConvertInitializer(tree exp) { + // If we already converted the initializer then return the cached copy. + if (Constant *C = (Constant *)llvm_get_cached(exp)) + return C; + Constant *Init; switch (TREE_CODE(exp)) { default: @@ -1316,6 +1323,10 @@ DieAbjectly("Constant over aligned!", exp); #endif + // Cache the result of converting the initializer since the same tree is often + // converted multiple times. + llvm_set_cached(exp, Init); + return Init; } From eli.friedman at gmail.com Wed Apr 27 09:27:07 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 07:27:07 -0700 Subject: [llvm-commits] [llvm] r130272 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-i1.ll In-Reply-To: <4DB7BD04.7020303@free.fr> References: <20110427013427.405412A6C12D@llvm.org> <4DB7BD04.7020303@free.fr> Message-ID: On Tue, Apr 26, 2011 at 11:51 PM, Duncan Sands wrote: > Hi Eli, > >> + ?// Note that i1 essentially gets ANY_EXTEND'ed to i8 where it isn't used >> + ?// in an explicit cast, so make sure to handle that correctly. > > I don't understand this comment. ?An i1 branch condition is zero extended to > i8 by the type legalizer on x86. The type legalizer isn't relevant here: fast-isel skips type legalization for i1's. -Eli From baldrick at free.fr Wed Apr 27 09:27:56 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 16:27:56 +0200 Subject: [llvm-commits] [llvm] r130272 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-i1.ll In-Reply-To: References: <20110427013427.405412A6C12D@llvm.org> <4DB7BD04.7020303@free.fr> Message-ID: <4DB827EC.1050302@free.fr> On 27/04/11 16:27, Eli Friedman wrote: > On Tue, Apr 26, 2011 at 11:51 PM, Duncan Sands wrote: >> Hi Eli, >> >>> + // Note that i1 essentially gets ANY_EXTEND'ed to i8 where it isn't used >>> + // in an explicit cast, so make sure to handle that correctly. >> >> I don't understand this comment. An i1 branch condition is zero extended to >> i8 by the type legalizer on x86. > > The type legalizer isn't relevant here: fast-isel skips type > legalization for i1's. OK! Thanks for explaining. Ciao, Duncan. From baldrick at free.fr Wed Apr 27 10:13:55 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 27 Apr 2011 15:13:55 -0000 Subject: [llvm-commits] [dragonegg] r130304 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110427151355.881FB2A6C12D@llvm.org> Author: baldrick Date: Wed Apr 27 10:13:55 2011 New Revision: 130304 URL: http://llvm.org/viewvc/llvm-project?rev=130304&view=rev Log: Performance fix: in some cases we could end up doing a lot of APInt arithmetic (masking etc) when merging pieces of constants, taking up a visible amount of time. This can be avoided by simply ensuring that ExtendRange always zero extends. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130304&r1=130303&r2=130304&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Wed Apr 27 10:13:55 2011 @@ -73,6 +73,13 @@ getBitWidth() == Contents->getType()->getPrimitiveSizeInBits(); } + /// ExtendRange - Extend the slice to a wider range. All added bits are zero. + BitSlice ExtendRange(SignedRange r) const; + + /// ReduceRange - Reduce the slice to a smaller range discarding any bits that + /// do not belong to the new range. + BitSlice ReduceRange(SignedRange r) const; + public: /// BitSlice - Default constructor: empty bit range. BitSlice() : R(), Contents(0) {} @@ -132,22 +139,13 @@ /// (aka "Last-1"). Constant *getBits(SignedRange r) const; - /// ExtendRange - Extend the slice to a wider range. The value of the added - /// bits is undefined. - BitSlice ExtendRange(SignedRange r) const; - - /// ReduceRange - Reduce the slice to a smaller range discarding any bits that - /// do not belong to the new range. - BitSlice ReduceRange(SignedRange r) const; - /// Merge - Join the slice with another (which must be disjoint), forming the /// convex hull of the ranges. The bits in the range of one of the slices are /// those of that slice. Any other bits have an undefined value. void Merge(const BitSlice &other); }; -/// ExtendRange - Extend the slice to a wider range. The value of the added -/// bits is undefined. +/// ExtendRange - Extend the slice to a wider range. All added bits are zero. BitSlice BitSlice::ExtendRange(SignedRange r) const { assert(r.contains(R) && "Not an extension!"); // Quick exit if the range did not actually increase. @@ -155,9 +153,9 @@ return *this; assert(!r.empty() && "Empty ranges did not evaluate as equal?"); const Type *ExtTy = IntegerType::get(Context, r.getWidth()); - // If the slice contains no bits then every bit of the extension is undefined. + // If the slice contains no bits then every bit of the extension is zero. if (empty()) - return BitSlice(r, UndefValue::get(ExtTy)); + return BitSlice(r, Constant::getNullValue(ExtTy)); // Extend the contents to the new type. Constant *C = TheFolder->CreateZExtOrBitCast(Contents, ExtTy); // Position the old contents correctly inside the new contents. @@ -218,32 +216,10 @@ BitSlice ExtThis = ExtendRange(Hull); BitSlice ExtOther = other.ExtendRange(Hull); - // The extra bits added when extending a slice may contain anything. In each - // extended slice clear the bits corresponding to the other slice. - unsigned HullWidth = Hull.getWidth(); - // Compute masks with the bits for each slice set to 1. - APInt ThisBits, OtherBits; - if (BYTES_BIG_ENDIAN) { - int HullLast = Hull.getLast(); - ThisBits = APInt::getBitsSet(HullWidth, HullLast - getLast(), - HullLast - getFirst()); - OtherBits = APInt::getBitsSet(HullWidth, HullLast - other.getLast(), - HullLast - other.getFirst()); - } else { - int HullFirst = Hull.getFirst(); - ThisBits = APInt::getBitsSet(HullWidth, getFirst() - HullFirst, - getLast() - HullFirst); - OtherBits = APInt::getBitsSet(HullWidth, other.getFirst() - HullFirst, - other.getLast() - HullFirst); - } - // Clear bits which correspond to the other slice. - ConstantInt *ClearThis = ConstantInt::get(Context, ~ThisBits); - ConstantInt *ClearOther = ConstantInt::get(Context, ~OtherBits); - Constant *ThisPart = TheFolder->CreateAnd(ExtThis.Contents, ClearOther); - Constant *OtherPart = TheFolder->CreateAnd(ExtOther.Contents, ClearThis); - - // The slices can now be joined via a simple 'or'. - *this = BitSlice(Hull, TheFolder->CreateOr(ThisPart, OtherPart)); + // Since the slices are disjoint and all added bits are zero they can be + // joined via a simple 'or'. + *this = BitSlice(Hull, TheFolder->CreateOr(ExtThis.Contents, + ExtOther.Contents)); } /// ReduceRange - Reduce the slice to a smaller range discarding any bits that From rafael.espindola at gmail.com Wed Apr 27 10:21:19 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 27 Apr 2011 15:21:19 -0000 Subject: [llvm-commits] [llvm] r130305 - in /llvm/trunk: include/llvm/MC/MCDwarf.h include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCObjectStreamer.cpp lib/MC/MCStreamer.cpp Message-ID: <20110427152119.47E5B2A6C12D@llvm.org> Author: rafael Date: Wed Apr 27 10:21:19 2011 New Revision: 130305 URL: http://llvm.org/viewvc/llvm-project?rev=130305&view=rev Log: Factor a bit of code to MCStreamer::EmitLabel. Keep track of the last non private symbol. This will be use for handling foo: .cfi_startproc ... On OS X where we have to create a foo.eh symbol. Modified: llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=130305&r1=130304&r2=130305&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Wed Apr 27 10:21:19 2011 @@ -263,12 +263,13 @@ struct MCDwarfFrameInfo { MCDwarfFrameInfo() : Begin(0), End(0), Personality(0), Lsda(0), - Instructions(), PersonalityEncoding(0), + Function(0), Instructions(), PersonalityEncoding(), LsdaEncoding(0) {} MCSymbol *Begin; MCSymbol *End; const MCSymbol *Personality; const MCSymbol *Lsda; + const MCSymbol *Function; std::vector Instructions; unsigned PersonalityEncoding; unsigned LsdaEncoding; Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=130305&r1=130304&r2=130305&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Wed Apr 27 10:21:19 2011 @@ -57,6 +57,8 @@ MCDwarfFrameInfo *getCurrentFrameInfo(); void EnsureValidFrame(); + const MCSymbol* LastNonPrivate; + /// SectionStack - This is stack of current and previous section /// values saved by PushSection. SmallVectorisUndefined() && "Cannot define a symbol twice!"); - assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); - assert(getCurrentSection() && "Cannot emit before setting section!"); + MCStreamer::EmitLabel(Symbol); OS << *Symbol << MAI.getLabelSuffix(); EmitEOL(); - Symbol->setSection(*getCurrentSection()); } void MCAsmStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=130305&r1=130304&r2=130305&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Wed Apr 27 10:21:19 2011 @@ -107,10 +107,7 @@ } void MCObjectStreamer::EmitLabel(MCSymbol *Symbol) { - assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); - assert(getCurrentSection() && "Cannot emit before setting section!"); - - Symbol->setSection(*getCurrentSection()); + MCStreamer::EmitLabel(Symbol); MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=130305&r1=130304&r2=130305&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Wed Apr 27 10:21:19 2011 @@ -12,6 +12,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" +#include "llvm/MC/MCSymbol.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" @@ -153,12 +154,23 @@ report_fatal_error("No open frame"); } +void MCStreamer::EmitLabel(MCSymbol *Symbol) { + assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); + assert(getCurrentSection() && "Cannot emit before setting section!"); + Symbol->setSection(*getCurrentSection()); + + StringRef Prefix = getContext().getAsmInfo().getPrivateGlobalPrefix(); + if (!Symbol->getName().startswith(Prefix)) + LastNonPrivate = Symbol; +} + void MCStreamer::EmitCFIStartProc() { MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo(); if (CurFrame && !CurFrame->End) report_fatal_error("Starting a frame before finishing the previous one!"); MCDwarfFrameInfo Frame; Frame.Begin = getContext().CreateTempSymbol(); + Frame.Function = LastNonPrivate; EmitLabel(Frame.Begin); FrameInfos.push_back(Frame); } From clattner at apple.com Wed Apr 27 10:57:44 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 27 Apr 2011 08:57:44 -0700 Subject: [llvm-commits] [PATCH] docs/doxygen.css: Tweak style for readability. In-Reply-To: References: Message-ID: <61970259-416D-4EAA-9F6E-7E50F2E7DBC0@apple.com> On Apr 27, 2011, at 12:48 AM, NAKAMURA Takumi wrote: > A few styles are brought from http://llvm.org/test-doxygen/api/api.css > --- > docs/doxygen.css | 25 +++++++++++++++++++++++++ > 1 files changed, 25 insertions(+), 0 deletions(-) > > --- > Sample site is; http://t.pgr.jp/doxygen/html/ (Generated on Thu Dec 9 > 02:32:15 2010) > May I commit it? Sure, go for it! -Chris From aggarwa4 at illinois.edu Wed Apr 27 11:51:53 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 16:51:53 -0000 Subject: [llvm-commits] [poolalloc] r130308 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/DataStructure.cpp Message-ID: <20110427165153.7DBAB2A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 11:51:53 2011 New Revision: 130308 URL: http://llvm.org/viewvc/llvm-project?rev=130308&view=rev Log: Refactor mergeTypeInfo, into 2 parts. One that grows size of DSNode and one that does the actual merging of types. Modified: poolalloc/trunk/include/dsa/DSNode.h poolalloc/trunk/lib/DSA/DataStructure.cpp Modified: poolalloc/trunk/include/dsa/DSNode.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=130308&r1=130307&r2=130308&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DSNode.h (original) +++ poolalloc/trunk/include/dsa/DSNode.h Wed Apr 27 11:51:53 2011 @@ -206,6 +206,8 @@ assert(!isCollapsedNode() && "Growing a collapsed node"); Size = NSize; } + + void growSizeForType(const Type *Ty, unsigned Offset); /// hasLink - Return true if this memory object has a link in slot LinkNo /// Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=130308&r1=130307&r2=130308&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Wed Apr 27 11:51:53 2011 @@ -402,15 +402,11 @@ } } -/// mergeTypeInfo - This method merges the specified type into the current node -/// at the specified offset. This may update the current node's type record if -/// this gives more information to the node, it may do nothing to the node if -/// this information is already known, or it may merge the node completely (and -/// return true) if the information is incompatible with what is already known. -/// -/// This method returns true if the node is completely folded, otherwise false. -/// -void DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset) { +/// growSizeForType - This method increases the size of the node +/// to accomodate NewTy at the given offset. This is useful for +/// updating the size of a DSNode, without actually inferring a +/// Type. +void DSNode::growSizeForType(const Type *NewTy, unsigned Offset) { if (!NewTy || NewTy->isVoidTy()) return; @@ -422,6 +418,20 @@ if (Offset + TD.getTypeAllocSize(NewTy) >= getSize()) growSize(Offset + TD.getTypeAllocSize(NewTy)); +} + +/// mergeTypeInfo - This method merges the specified type into the current node +/// at the specified offset. This may update the current node's type record if +/// this gives more information to the node, it may do nothing to the node if +/// this information is already known, or it may merge the node completely (and +/// return true) if the information is incompatible with what is already known. +/// +/// This method returns true if the node is completely folded, otherwise false. +/// +void DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset) { + + growSizeForType(NewTy, Offset); + // Clang generates loads and stores of struct types. // %tmp12 = load %struct.demand* %retval, align 1 @@ -429,6 +439,7 @@ // individually(at the appropriate offset), instead of the // struct type. if(NewTy->isStructTy()) { + const TargetData &TD = getParentGraph()->getTargetData(); const StructType *STy = cast(NewTy); const StructLayout *SL = TD.getStructLayout(cast(STy)); unsigned count = 0; @@ -653,7 +664,6 @@ /// point to this node). /// void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) { - //DOUT << "mergeWith: " << this << " becomes " << NH.getNode() << "\n"; DSNode *N = NH.getNode(); if (N == this && NH.getOffset() == Offset) return; // Noop From aggarwa4 at illinois.edu Wed Apr 27 12:07:08 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 17:07:08 -0000 Subject: [llvm-commits] [poolalloc] r130309 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20110427170708.2DB902A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 12:07:08 2011 New Revision: 130309 URL: http://llvm.org/viewvc/llvm-project?rev=130309&view=rev Log: Do not infer types for loads/stores used for only copying data. Use these only to infer the size a DSNode must have, to indicate the size of the data being read/written. Helps reduce spurious type information. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=130309&r1=130308&r2=130309&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Wed Apr 27 12:07:08 2011 @@ -46,6 +46,7 @@ STATISTIC(NumIndirectCall, "Number of indirect calls added"); STATISTIC(NumAsmCall, "Number of asm calls collapsed/seen"); STATISTIC(NumIntrinsicCall, "Number of intrinsics called"); +STATISTIC(IgnoredInst, "Number of instructions ignored"); RegisterPass X("dsa-local", "Local Data Structure Analysis"); @@ -366,10 +367,20 @@ Ptr.getNode()->setReadMarker(); // Ensure a typerecord exists... - Ptr.getNode()->mergeTypeInfo(LI.getType(), Ptr.getOffset()); + Ptr.getNode()->growSizeForType(LI.getType(), Ptr.getOffset()); if (isa(LI.getType())) setDestTo(LI, getLink(Ptr)); + + // check that it is the inserted value + if(TypeInferenceOptimize) + if(LI.getNumUses() == 1) + if(StoreInst *SI = dyn_cast(LI.use_begin())) + if(SI->getOperand(0) == &LI) { + ++IgnoredInst; + return; + } + Ptr.getNode()->mergeTypeInfo(LI.getType(), Ptr.getOffset()); } void GraphBuilder::visitStoreInst(StoreInst &SI) { @@ -381,11 +392,19 @@ Dest.getNode()->setModifiedMarker(); // Ensure a type-record exists... - Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); + Dest.getNode()->growSizeForType(StoredTy, Dest.getOffset()); // Avoid adding edges from null, or processing non-"pointer" stores if (isa(StoredTy)) Dest.addEdgeTo(getValueDest(SI.getOperand(0))); + + if(TypeInferenceOptimize) + if(SI.getOperand(0)->getNumUses() == 1) + if(isa(SI.getOperand(0))){ + ++IgnoredInst; + return; + } + Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); } void GraphBuilder::visitReturnInst(ReturnInst &RI) { @@ -470,7 +489,7 @@ Offset += SL->getElementOffset(*i); STy = (cast(STy))->getTypeAtIndex(*i); } - + // Ensure a typerecord exists... Ptr.getNode()->mergeTypeInfo(I.getType(), Offset); @@ -494,7 +513,7 @@ // if (!Value.isNull() && - Value.getNode()->isNodeCompletelyFolded()) { + Value.getNode()->isNodeCompletelyFolded()) { setDestTo(GEP, Value); return; } From stoklund at 2pi.dk Wed Apr 27 12:42:32 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 27 Apr 2011 17:42:32 -0000 Subject: [llvm-commits] [llvm] r130313 - in /llvm/trunk: lib/CodeGen/VirtRegMap.cpp test/CodeGen/ARM/crash-greedy.ll Message-ID: <20110427174232.245742A6C12D@llvm.org> Author: stoklund Date: Wed Apr 27 12:42:31 2011 New Revision: 130313 URL: http://llvm.org/viewvc/llvm-project?rev=130313&view=rev Log: Also add operands for defined and dead super-registers when rewriting. We cannot rely on the operands added by LiveIntervals in all cases as demonstrated by the test case. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp llvm/trunk/test/CodeGen/ARM/crash-greedy.ll Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=130313&r1=130312&r2=130313&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Wed Apr 27 12:42:31 2011 @@ -260,6 +260,8 @@ << "********** Function: " << MF->getFunction()->getName() << '\n'); DEBUG(dump()); + SmallVector SuperDeads; + SmallVector SuperDefs; SmallVector SuperKills; for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end(); @@ -283,12 +285,13 @@ if (MO.getSubReg()) { // A virtual register kill refers to the whole register, so we may // have to add operands for the super-register. - if (MO.isUse() && MO.isKill() && !MO.isUndef()) - SuperKills.push_back(PhysReg); - - // We don't have to deal with sub-register defs because - // LiveIntervalAnalysis already added the necessary - // operands. + if (MO.isUse()) { + if (MO.isKill() && !MO.isUndef()) + SuperKills.push_back(PhysReg); + } else if (MO.isDead()) + SuperDeads.push_back(PhysReg); + else + SuperDefs.push_back(PhysReg); // PhysReg operands cannot have subregister indexes. PhysReg = TRI->getSubReg(PhysReg, MO.getSubReg()); @@ -305,6 +308,12 @@ while (!SuperKills.empty()) MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true); + while (!SuperDeads.empty()) + MI->addRegisterDead(SuperDeads.pop_back_val(), TRI, true); + + while (!SuperDefs.empty()) + MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI); + DEBUG(dbgs() << "> " << *MI); // Finally, remove any identity copies. Modified: llvm/trunk/test/CodeGen/ARM/crash-greedy.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/crash-greedy.ll?rev=130313&r1=130312&r2=130313&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/crash-greedy.ll (original) +++ llvm/trunk/test/CodeGen/ARM/crash-greedy.ll Wed Apr 27 12:42:31 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -regalloc=greedy -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s +; RUN: llc < %s -regalloc=greedy -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim -verify-machineinstrs | FileCheck %s ; ; ARM tests that crash or fail with the greedy register allocator. @@ -59,3 +59,26 @@ ret void } +; CHECK: insert_elem +; This test has a sub-register copy with a kill flag: +; %vreg6:ssub_3 = COPY %vreg6:ssub_2; QPR_VFP2:%vreg6 +; The rewriter must do something sensible with that, or the scavenger crashes. +define void @insert_elem() nounwind { +entry: + br i1 undef, label %if.end251, label %if.then84 + +if.then84: ; preds = %entry + br i1 undef, label %if.end251, label %if.then195 + +if.then195: ; preds = %if.then84 + %div = fdiv float 1.000000e+00, undef + %vecinit207 = insertelement <4 x float> undef, float %div, i32 1 + %vecinit208 = insertelement <4 x float> %vecinit207, float 1.000000e+00, i32 2 + %vecinit209 = insertelement <4 x float> %vecinit208, float 1.000000e+00, i32 3 + %mul216 = fmul <4 x float> zeroinitializer, %vecinit209 + store <4 x float> %mul216, <4 x float>* undef, align 16 + br label %if.end251 + +if.end251: ; preds = %if.then195, %if.then84, %entry + ret void +} From dpatel at apple.com Wed Apr 27 12:59:28 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 27 Apr 2011 17:59:28 -0000 Subject: [llvm-commits] [llvm] r130315 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyCFGPass.cpp test/Transforms/SimplifyCFG/trap-debugloc.ll Message-ID: <20110427175928.19B052A6C12D@llvm.org> Author: dpatel Date: Wed Apr 27 12:59:27 2011 New Revision: 130315 URL: http://llvm.org/viewvc/llvm-project?rev=130315&view=rev Log: Simplify cfg inserts a call to trap when unreachable code is detected. Assign DebugLoc to this new trap instruction. Added: llvm/trunk/test/Transforms/SimplifyCFG/trap-debugloc.ll Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=130315&r1=130314&r2=130315&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Wed Apr 27 12:59:27 2011 @@ -73,7 +73,8 @@ if (UseLLVMTrap) { Function *TrapFn = Intrinsic::getDeclaration(BB->getParent()->getParent(), Intrinsic::trap); - CallInst::Create(TrapFn, "", I); + CallInst *CallTrap = CallInst::Create(TrapFn, "", I); + CallTrap->setDebugLoc(I->getDebugLoc()); } new UnreachableInst(I->getContext(), I); Added: llvm/trunk/test/Transforms/SimplifyCFG/trap-debugloc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/trap-debugloc.ll?rev=130315&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/trap-debugloc.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/trap-debugloc.ll Wed Apr 27 12:59:27 2011 @@ -0,0 +1,19 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s +; Radar 9342286 +; Assign DebugLoc to trap instruction. +define void @foo() nounwind ssp { +; CHECK: call void @llvm.trap(), !dbg + store i32 42, i32* null, !dbg !5 + ret void, !dbg !7 +} + +!llvm.dbg.sp = !{!0} + +!0 = metadata !{i32 589870, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"", metadata !1, i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, i32 0, i32 0, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 589865, metadata !"foo.c", metadata !"/private/tmp", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 589841, i32 0, i32 12, metadata !"foo.c", metadata !"/private/tmp", metadata !"Apple clang version 3.0 (tags/Apple/clang-206.1) (based on LLVM 3.0svn)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 589845, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i32 0, i32 0, i32 0, metadata !4, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} +!5 = metadata !{i32 4, i32 2, metadata !6, null} +!6 = metadata !{i32 589835, metadata !0, i32 3, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] +!7 = metadata !{i32 5, i32 1, metadata !6, null} From atrick at apple.com Wed Apr 27 13:17:36 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 27 Apr 2011 18:17:36 -0000 Subject: [llvm-commits] [llvm] r130316 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20110427181736.EF8022A6C12D@llvm.org> Author: atrick Date: Wed Apr 27 13:17:36 2011 New Revision: 130316 URL: http://llvm.org/viewvc/llvm-project?rev=130316&view=rev Log: Corrects an old, old typo in a case that doesn't seem to be reached in practice. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=130316&r1=130315&r2=130316&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Apr 27 13:17:36 2011 @@ -2015,7 +2015,7 @@ } } // (A+B)/C --> (A/C + B/C) if safe and A/C and B/C can be folded. - if (const SCEVAddRecExpr *A = dyn_cast(LHS)) { + if (const SCEVAddExpr *A = dyn_cast(LHS)) { SmallVector Operands; for (unsigned i = 0, e = A->getNumOperands(); i != e; ++i) Operands.push_back(getZeroExtendExpr(A->getOperand(i), ExtTy)); From gohman at apple.com Wed Apr 27 13:39:03 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 27 Apr 2011 18:39:03 -0000 Subject: [llvm-commits] [llvm] r130317 - in /llvm/trunk: include/llvm/Intrinsics.td lib/Analysis/AliasAnalysis.cpp test/Analysis/BasicAA/intrinsics.ll test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll Message-ID: <20110427183903.73E702A6C12D@llvm.org> Author: djg Date: Wed Apr 27 13:39:03 2011 New Revision: 130317 URL: http://llvm.org/viewvc/llvm-project?rev=130317&view=rev Log: When analyzing functions known to only access argument pointees, only check arguments with pointer types. Update the documentation of IntrReadArgMem reflect this. While here, add support for TBAA tags on intrinsic calls. Added: llvm/trunk/test/Analysis/BasicAA/intrinsics.ll llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll Modified: llvm/trunk/include/llvm/Intrinsics.td llvm/trunk/lib/Analysis/AliasAnalysis.cpp Modified: llvm/trunk/include/llvm/Intrinsics.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.td?rev=130317&r1=130316&r2=130317&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.td (original) +++ llvm/trunk/include/llvm/Intrinsics.td Wed Apr 27 13:39:03 2011 @@ -30,7 +30,7 @@ def IntrNoMem : IntrinsicProperty; // IntrReadArgMem - This intrinsic reads only from memory that one of its -// arguments points to, but may read an unspecified amount. +// pointer-typed arguments points to, but may read an unspecified amount. def IntrReadArgMem : IntrinsicProperty; // IntrReadMem - This intrinsic reads from unspecified memory, so it cannot be Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=130317&r1=130316&r2=130317&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Wed Apr 27 13:39:03 2011 @@ -86,14 +86,20 @@ if (onlyAccessesArgPointees(MRB)) { bool doesAlias = false; - if (doesAccessArgPointees(MRB)) + if (doesAccessArgPointees(MRB)) { + MDNode *CSTag = CS.getInstruction()->getMetadata(LLVMContext::MD_tbaa); for (ImmutableCallSite::arg_iterator AI = CS.arg_begin(), AE = CS.arg_end(); - AI != AE; ++AI) - if (!isNoAlias(Location(*AI), Loc)) { + AI != AE; ++AI) { + const Value *Arg = *AI; + if (!Arg->getType()->isPointerTy()) + continue; + Location CSLoc(Arg, UnknownSize, CSTag); + if (!isNoAlias(CSLoc, Loc)) { doesAlias = true; break; } - + } + } if (!doesAlias) return NoModRef; } @@ -138,13 +144,19 @@ // CS2's arguments. if (onlyAccessesArgPointees(CS2B)) { AliasAnalysis::ModRefResult R = NoModRef; - if (doesAccessArgPointees(CS2B)) + if (doesAccessArgPointees(CS2B)) { + MDNode *CS2Tag = CS2.getInstruction()->getMetadata(LLVMContext::MD_tbaa); for (ImmutableCallSite::arg_iterator I = CS2.arg_begin(), E = CS2.arg_end(); I != E; ++I) { - R = ModRefResult((R | getModRefInfo(CS1, *I, UnknownSize)) & Mask); + const Value *Arg = *I; + if (!Arg->getType()->isPointerTy()) + continue; + Location CS2Loc(Arg, UnknownSize, CS2Tag); + R = ModRefResult((R | getModRefInfo(CS1, CS2Loc)) & Mask); if (R == Mask) break; } + } return R; } @@ -152,13 +164,20 @@ // any of the memory referenced by CS1's arguments. If not, return NoModRef. if (onlyAccessesArgPointees(CS1B)) { AliasAnalysis::ModRefResult R = NoModRef; - if (doesAccessArgPointees(CS1B)) + if (doesAccessArgPointees(CS1B)) { + MDNode *CS1Tag = CS1.getInstruction()->getMetadata(LLVMContext::MD_tbaa); for (ImmutableCallSite::arg_iterator - I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) - if (getModRefInfo(CS2, *I, UnknownSize) != NoModRef) { + I = CS1.arg_begin(), E = CS1.arg_end(); I != E; ++I) { + const Value *Arg = *I; + if (!Arg->getType()->isPointerTy()) + continue; + Location CS1Loc(Arg, UnknownSize, CS1Tag); + if (getModRefInfo(CS2, CS1Loc) != NoModRef) { R = Mask; break; } + } + } if (R == NoModRef) return R; } Added: llvm/trunk/test/Analysis/BasicAA/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/intrinsics.ll?rev=130317&view=auto ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/intrinsics.ll (added) +++ llvm/trunk/test/Analysis/BasicAA/intrinsics.ll Wed Apr 27 13:39:03 2011 @@ -0,0 +1,23 @@ +; RUN: opt -basicaa -gvn -S < %s | FileCheck %s + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" + +; BasicAA should prove that these calls don't interfere, since they are +; IntrArgReadMem and have noalias pointers. + +; CHECK: define <8 x i16> @test0(i8* noalias %p, i8* noalias %q, <8 x i16> %y) { +; CHECK-NEXT: entry: +; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind +; CHECK-NEXT: call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16) +; CHECK-NEXT: %c = add <8 x i16> %a, %a +define <8 x i16> @test0(i8* noalias %p, i8* noalias %q, <8 x i16> %y) { +entry: + %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind + call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16) + %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind + %c = add <8 x i16> %a, %b + ret <8 x i16> %c +} + +declare <8 x i16> @llvm.arm.neon.vld1.v8i16(i8*, i32) nounwind readonly +declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind Added: llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll?rev=130317&view=auto ============================================================================== --- llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll (added) +++ llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll Wed Apr 27 13:39:03 2011 @@ -0,0 +1,27 @@ +; RUN: opt -tbaa -basicaa -gvn -S < %s | FileCheck %s + +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:32-f32:32:32-f64:32:32-v64:32:64-v128:32:128-a0:0:32-n32" + +; TBAA should prove that these calls don't interfere, since they are +; IntrArgReadMem and have TBAA metadata. + +; CHECK: define <8 x i16> @test0(i8* %p, i8* %q, <8 x i16> %y) { +; CHECK-NEXT: entry: +; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind +; CHECK-NEXT: call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16) +; CHECK-NEXT: %c = add <8 x i16> %a, %a +define <8 x i16> @test0(i8* %p, i8* %q, <8 x i16> %y) { +entry: + %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind, !tbaa !2 + call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16), !tbaa !1 + %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind, !tbaa !2 + %c = add <8 x i16> %a, %b + ret <8 x i16> %c +} + +declare <8 x i16> @llvm.arm.neon.vld1.v8i16(i8*, i32) nounwind readonly +declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind + +!0 = metadata !{metadata !"tbaa root", null} +!1 = metadata !{metadata !"A", metadata !0} +!2 = metadata !{metadata !"B", metadata !0} From aggarwa4 at illinois.edu Wed Apr 27 14:21:44 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 19:21:44 -0000 Subject: [llvm-commits] [poolalloc] r130321 - /poolalloc/trunk/test/dsa/types/union.ll Message-ID: <20110427192144.DB2C92A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 14:21:44 2011 New Revision: 130321 URL: http://llvm.org/viewvc/llvm-project?rev=130321&view=rev Log: Updated test Modified: poolalloc/trunk/test/dsa/types/union.ll Modified: poolalloc/trunk/test/dsa/types/union.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union.ll?rev=130321&r1=130320&r2=130321&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union.ll (original) +++ poolalloc/trunk/test/dsa/types/union.ll Wed Apr 27 14:21:44 2011 @@ -1,11 +1,13 @@ ; ModuleID = 'union.bc' +; Makes use of unions. Also tests that we do not infer types for loads/stores when we use the type inference opts. +; Works only with type inference opts, as unions are interpreted with array inside the struct. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" -;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:tmp:0,func:c:0,func:s1:0 -;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:s1:8,func:x:8 -;RUN: dsaopt %s -dsa-local -analyze -check-type=func:s1,0:float|i32|i32*::8:i32* -;RUN: dsaopt %s -dsa-local -analyze -check-type=func:x,0:float::8:i32* +;RUN: adsaopt %s -mem2reg -mergearrgep -dce -o tt.bc +;RUN: dsaopt tt.bc -dsa-local -analyze -enable-type-inference-opts -check-same-node=func:s1:8,func:x:8 +;RUN: dsaopt tt.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:s1,0:i32* +;RUN: dsaopt tt.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:x,VOID %struct.StructType = type { float, i32* } %union.UnionType = type { %struct.StructType, [96 x i32] } From aggarwa4 at illinois.edu Wed Apr 27 14:28:26 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 19:28:26 -0000 Subject: [llvm-commits] [poolalloc] r130322 - /poolalloc/trunk/lib/DSA/DataStructure.cpp Message-ID: <20110427192826.186ED2A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 14:28:25 2011 New Revision: 130322 URL: http://llvm.org/viewvc/llvm-project?rev=130322&view=rev Log: Do not merge type info, if it is a collapsed node, or if they new type is a void type. Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=130322&r1=130321&r2=130322&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original) +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Wed Apr 27 14:28:25 2011 @@ -429,6 +429,8 @@ /// This method returns true if the node is completely folded, otherwise false. /// void DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset) { + if (!NewTy || NewTy->isVoidTy()) return; + if (isCollapsedNode()) return; growSizeForType(NewTy, Offset); From evan.cheng at apple.com Wed Apr 27 14:32:43 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 27 Apr 2011 19:32:43 -0000 Subject: [llvm-commits] [llvm] r130324 - in /llvm/trunk: lib/CodeGen/IfConversion.cpp test/CodeGen/ARM/2011-04-27-IfCvtBug.ll Message-ID: <20110427193243.6DCA02A6C12D@llvm.org> Author: evancheng Date: Wed Apr 27 14:32:43 2011 New Revision: 130324 URL: http://llvm.org/viewvc/llvm-project?rev=130324&view=rev Log: If converter was being too cute. It look for root BBs (which don't have successors) and use inverse depth first search to traverse the BBs. However that doesn't work when the CFG has infinite loops. Simply do a linear traversal of all BBs work just fine. rdar://9344645 Added: llvm/trunk/test/CodeGen/ARM/2011-04-27-IfCvtBug.ll Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=130324&r1=130323&r2=130324&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IfConversion.cpp (original) +++ llvm/trunk/lib/CodeGen/IfConversion.cpp Wed Apr 27 14:32:43 2011 @@ -27,7 +27,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/ADT/STLExtras.h" @@ -146,10 +145,6 @@ : BBI(b), Kind(k), NeedSubsumption(s), NumDups(d), NumDups2(d2) {} }; - /// Roots - Basic blocks that do not have successors. These are the starting - /// points of Graph traversal. - std::vector Roots; - /// BBAnalysis - Results of if-conversion feasibility analysis indexed by /// basic block number. std::vector BBAnalysis; @@ -287,11 +282,6 @@ MF.RenumberBlocks(); BBAnalysis.resize(MF.getNumBlockIDs()); - // Look for root nodes, i.e. blocks without successors. - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) - if (I->succ_empty()) - Roots.push_back(I); - std::vector Tokens; MadeChange = false; unsigned NumIfCvts = NumSimple + NumSimpleFalse + NumTriangle + @@ -406,7 +396,6 @@ } Tokens.clear(); - Roots.clear(); BBAnalysis.clear(); if (MadeChange && IfCvtBranchFold) { @@ -924,13 +913,9 @@ /// candidates. void IfConverter::AnalyzeBlocks(MachineFunction &MF, std::vector &Tokens) { - std::set Visited; - for (unsigned i = 0, e = Roots.size(); i != e; ++i) { - for (idf_ext_iterator I=idf_ext_begin(Roots[i],Visited), - E = idf_ext_end(Roots[i], Visited); I != E; ++I) { - MachineBasicBlock *BB = *I; - AnalyzeBlock(BB, Tokens); - } + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { + MachineBasicBlock *BB = I; + AnalyzeBlock(BB, Tokens); } // Sort to favor more complex ifcvt scheme. Added: llvm/trunk/test/CodeGen/ARM/2011-04-27-IfCvtBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-04-27-IfCvtBug.ll?rev=130324&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-04-27-IfCvtBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2011-04-27-IfCvtBug.ll Wed Apr 27 14:32:43 2011 @@ -0,0 +1,59 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-ios + +; If converter was being too cute. It look for root BBs (which don't have +; successors) and use inverse depth first search to traverse the BBs. However +; that doesn't work when the CFG has infinite loops. Simply do a linear +; traversal of all BBs work just fine. + +; rdar://9344645 + +%struct.hc = type { i32, i32, i32, i32 } + +define i32 @t(i32 %type) optsize { +entry: + br i1 undef, label %if.then, label %if.else + +if.then: + unreachable + +if.else: + br i1 undef, label %if.then15, label %if.else18 + +if.then15: + unreachable + +if.else18: + switch i32 %type, label %if.else173 [ + i32 3, label %if.then115 + i32 1, label %if.then102 + ] + +if.then102: + br i1 undef, label %cond.true10.i, label %t.exit + +cond.true10.i: + br label %t.exit + +t.exit: + unreachable + +if.then115: + br i1 undef, label %if.else163, label %if.else145 + +if.else145: + %call150 = call fastcc %struct.hc* @foo(%struct.hc* undef, i32 34865152) optsize + br label %while.body172 + +if.else163: + %call168 = call fastcc %struct.hc* @foo(%struct.hc* undef, i32 34078720) optsize + br label %while.body172 + +while.body172: + br label %while.body172 + +if.else173: + ret i32 -1 +} + +declare hidden fastcc %struct.hc* @foo(%struct.hc* nocapture, i32) nounwind optsize + From dpatel at apple.com Wed Apr 27 15:29:27 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 27 Apr 2011 20:29:27 -0000 Subject: [llvm-commits] [llvm] r130326 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMAsmPrinter.h Message-ID: <20110427202927.66BB12A6C12D@llvm.org> Author: dpatel Date: Wed Apr 27 15:29:27 2011 New Revision: 130326 URL: http://llvm.org/viewvc/llvm-project?rev=130326&view=rev Log: Revert r130178. It turned out to be not the optimal path to emit complex location expressions. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130326&r1=130325&r2=130326&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Apr 27 15:29:27 2011 @@ -384,8 +384,7 @@ virtual unsigned getISAEncoding() { return 0; } /// EmitDwarfRegOp - Emit dwarf register operation. - virtual void EmitDwarfRegOp(const MachineLocation &MLoc, - unsigned ExtraExprSize = 0) const; + virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; //===------------------------------------------------------------------===// // Dwarf Lowering Routines Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130326&r1=130325&r2=130326&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Apr 27 15:29:27 2011 @@ -750,8 +750,7 @@ } /// EmitDwarfRegOp - Emit dwarf register operation. -void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc, - unsigned ExtraExprSize) const { +void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); unsigned Reg = RI->getDwarfRegNum(MLoc.getReg(), false); if (int Offset = MLoc.getOffset()) { @@ -759,7 +758,7 @@ // use DW_OP_fbreg. unsigned OffsetSize = Offset ? MCAsmInfo::getSLEB128Size(Offset) : 1; OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + OffsetSize + ExtraExprSize); + EmitInt16(1 + OffsetSize); OutStreamer.AddComment( dwarf::OperationEncodingString(dwarf::DW_OP_fbreg)); EmitInt8(dwarf::DW_OP_fbreg); @@ -774,7 +773,7 @@ EmitInt8(dwarf::DW_OP_reg0 + Reg); } else { OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + MCAsmInfo::getULEB128Size(Reg) + ExtraExprSize); + EmitInt16(1 + MCAsmInfo::getULEB128Size(Reg)); OutStreamer.AddComment( dwarf::OperationEncodingString(dwarf::DW_OP_regx)); EmitInt8(dwarf::DW_OP_regx); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=130326&r1=130325&r2=130326&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed Apr 27 15:29:27 2011 @@ -173,11 +173,10 @@ } /// EmitDwarfRegOp - Emit dwarf register operation. -void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc, - unsigned ExtraExprSize) const { +void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); if (RI->getDwarfRegNum(MLoc.getReg(), false) != -1) - AsmPrinter::EmitDwarfRegOp(MLoc, ExtraExprSize); + AsmPrinter::EmitDwarfRegOp(MLoc); else { unsigned Reg = MLoc.getReg(); if (Reg >= ARM::S0 && Reg <= ARM::S31) { @@ -192,7 +191,7 @@ OutStreamer.AddComment("Loc expr size"); // DW_OP_regx + ULEB + DW_OP_bit_piece + ULEB + ULEB // 1 + ULEB(Rx) + 1 + 1 + 1 - EmitInt16(4 + MCAsmInfo::getULEB128Size(Rx) + ExtraExprSize); + EmitInt16(4 + MCAsmInfo::getULEB128Size(Rx)); OutStreamer.AddComment("DW_OP_regx for S register"); EmitInt8(dwarf::DW_OP_regx); @@ -224,8 +223,7 @@ // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8) + // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8); // 6 + ULEB(D1) + ULEB(D2) - EmitInt16(6 + MCAsmInfo::getULEB128Size(D1) - + MCAsmInfo::getULEB128Size(D2) + ExtraExprSize); + EmitInt16(6 + MCAsmInfo::getULEB128Size(D1) + MCAsmInfo::getULEB128Size(D2)); OutStreamer.AddComment("DW_OP_regx for Q register: D1"); EmitInt8(dwarf::DW_OP_regx); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h?rev=130326&r1=130325&r2=130326&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h Wed Apr 27 15:29:27 2011 @@ -90,8 +90,7 @@ MachineLocation getDebugValueLocation(const MachineInstr *MI) const; /// EmitDwarfRegOp - Emit dwarf register operation. - virtual void EmitDwarfRegOp(const MachineLocation &MLoc, - unsigned ExtraExprSize = 0) const; + virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; virtual unsigned getISAEncoding() { // ARM/Darwin adds ISA to the DWARF info for each function. From gohman at apple.com Wed Apr 27 15:44:28 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 27 Apr 2011 20:44:28 -0000 Subject: [llvm-commits] [llvm] r130327 - in /llvm/trunk: lib/Analysis/BasicAliasAnalysis.cpp test/Analysis/BasicAA/intrinsics.ll Message-ID: <20110427204428.3476B2A6C12D@llvm.org> Author: djg Date: Wed Apr 27 15:44:28 2011 New Revision: 130327 URL: http://llvm.org/viewvc/llvm-project?rev=130327&view=rev Log: Teach BasicAA about arm.neon.vld1 and vst1. Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp llvm/trunk/test/Analysis/BasicAA/intrinsics.ll Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=130327&r1=130326&r2=130327&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Apr 27 15:44:28 2011 @@ -779,6 +779,26 @@ return NoModRef; break; } + case Intrinsic::arm_neon_vld1: { + // LLVM's vld1 and vst1 intrinsics currently only support a single + // vector register. + uint64_t Size = + TD ? TD->getTypeStoreSize(II->getType()) : UnknownSize; + if (isNoAlias(Location(II->getArgOperand(0), Size, + II->getMetadata(LLVMContext::MD_tbaa)), + Loc)) + return NoModRef; + break; + } + case Intrinsic::arm_neon_vst1: { + uint64_t Size = + TD ? TD->getTypeStoreSize(II->getArgOperand(1)->getType()) : UnknownSize; + if (isNoAlias(Location(II->getArgOperand(0), Size, + II->getMetadata(LLVMContext::MD_tbaa)), + Loc)) + return NoModRef; + break; + } } // The AliasAnalysis base class has some smarts, lets use them. Modified: llvm/trunk/test/Analysis/BasicAA/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BasicAA/intrinsics.ll?rev=130327&r1=130326&r2=130327&view=diff ============================================================================== --- llvm/trunk/test/Analysis/BasicAA/intrinsics.ll (original) +++ llvm/trunk/test/Analysis/BasicAA/intrinsics.ll Wed Apr 27 15:44:28 2011 @@ -19,5 +19,21 @@ ret <8 x i16> %c } +; CHECK: define <8 x i16> @test1(i8* %p, <8 x i16> %y) { +; CHECK-NEXT: entry: +; CHECK-NEXT: %q = getelementptr i8* %p, i64 16 +; CHECK-NEXT: %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind +; CHECK-NEXT: call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16) +; CHECK-NEXT: %c = add <8 x i16> %a, %a +define <8 x i16> @test1(i8* %p, <8 x i16> %y) { +entry: + %q = getelementptr i8* %p, i64 16 + %a = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind + call void @llvm.arm.neon.vst1.v8i16(i8* %q, <8 x i16> %y, i32 16) + %b = call <8 x i16> @llvm.arm.neon.vld1.v8i16(i8* %p, i32 16) nounwind + %c = add <8 x i16> %a, %b + ret <8 x i16> %c +} + declare <8 x i16> @llvm.arm.neon.vld1.v8i16(i8*, i32) nounwind readonly declare void @llvm.arm.neon.vst1.v8i16(i8*, <8 x i16>, i32) nounwind From aggarwa4 at illinois.edu Wed Apr 27 15:48:35 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 20:48:35 -0000 Subject: [llvm-commits] [poolalloc] r130328 - in /poolalloc/trunk/test/dsa/types: array2struct.ll mrv.ll mrv1.ll union1.c union1.ll union2.ll union3.ll union4.ll union_arrays.ll Message-ID: <20110427204836.171252A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 15:48:35 2011 New Revision: 130328 URL: http://llvm.org/viewvc/llvm-project?rev=130328&view=rev Log: Updated tests to reflect the new type safety optimizations. Some fail due to incorrect parsing of array types. Modified: poolalloc/trunk/test/dsa/types/array2struct.ll poolalloc/trunk/test/dsa/types/mrv.ll poolalloc/trunk/test/dsa/types/mrv1.ll poolalloc/trunk/test/dsa/types/union1.c poolalloc/trunk/test/dsa/types/union1.ll poolalloc/trunk/test/dsa/types/union2.ll poolalloc/trunk/test/dsa/types/union3.ll poolalloc/trunk/test/dsa/types/union4.ll poolalloc/trunk/test/dsa/types/union_arrays.ll Modified: poolalloc/trunk/test/dsa/types/array2struct.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/array2struct.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/array2struct.ll (original) +++ poolalloc/trunk/test/dsa/types/array2struct.ll Wed Apr 27 15:48:35 2011 @@ -2,9 +2,11 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" ;RUN: dsaopt %s -dsa-local -analyze -check-type=tree,FoldedVOID +;RUN: dsaopt %s -dsa-local -enable-type-inference-opts -analyze -check-type=tree,12:\[8 x i32\]Array ; LLVM front end converts the type of tree, to a struct type instead of an array of the right type. ; even though structurally equivalent, DSA cant infer this yet. + %0 = type { %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %1, %1, %1, %1, %1, %1, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %struct..0tnode, %1 } %1 = type { i32, i32, i32, [32 x i8] } %struct..0tnode = type { i32, i32, i32, [8 x i32] } Modified: poolalloc/trunk/test/dsa/types/mrv.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/mrv.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/mrv.ll (original) +++ poolalloc/trunk/test/dsa/types/mrv.ll Wed Apr 27 15:48:35 2011 @@ -3,6 +3,11 @@ target triple = "x86_64-unknown-linux-gnu" ;RUN: dsaopt %s -dsa-local -analyze -check-type=main:s,0:float|double::4:float::8:float +;RUN: dsaopt %s -dsa-local -enable-type-inference-opts -analyze -check-type=main:s,0:float|double::4:float::8:float +;RUN: adsaopt %s -ld-args -deadargelim -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s,0:float::4:float::8:float +;RUN: adsaopt %s -ld-args -gep-expr-arg -deadargelim -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s,0:float::4:float::8:float ; Function foo, actually accepts an object of struct S. But as ; per calling conventions, the value is passed in registers, after Modified: poolalloc/trunk/test/dsa/types/mrv1.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/mrv1.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/mrv1.ll (original) +++ poolalloc/trunk/test/dsa/types/mrv1.ll Wed Apr 27 15:48:35 2011 @@ -6,6 +6,13 @@ ;RUN: dsaopt %s -dsa-local -analyze -check-type=main:s,0:float|double::4:float::8:float ;RUN: dsaopt %s -dsa-local -analyze -check-type=main:s1,0:float::4:float::8:float +;RUN: dsaopt %s -dsa-local -enable-type-inference-opts -analyze -check-type=main:s1,VOID +;RUN: adsaopt %s -ld-args -deadargelim -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s,0:float::4:float::8:float +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s1,VOID +;RUN: adsaopt %s -ld-args -gep-expr-arg -deadargelim -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s,0:float::4:float::8:float +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:s1,VOID %0 = type { double, float } %struct.S = type { float, float, float } Modified: poolalloc/trunk/test/dsa/types/union1.c URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union1.c?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union1.c (original) +++ poolalloc/trunk/test/dsa/types/union1.c Wed Apr 27 15:48:35 2011 @@ -1,4 +1,3 @@ - //--Make sure we can run DSA on it! //RUN: llvm-gcc %s -c --emit-llvm -o - | \ //RUN: dsaopt -dsa-bu -dsa-td -disable-output Modified: poolalloc/trunk/test/dsa/types/union1.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union1.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union1.ll (original) +++ poolalloc/trunk/test/dsa/types/union1.ll Wed Apr 27 15:48:35 2011 @@ -2,6 +2,10 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" +;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:s1,FoldedVOID +;RUN: adsaopt %s -mem2reg -mergearrgep -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:s1,0:i32* + %struct.NestedStructType = type { float, i32* } %struct.StructType = type { float, i32*, %struct.NestedStructType } %union.UnionType = type { %struct.StructType, [92 x i32] } Modified: poolalloc/trunk/test/dsa/types/union2.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union2.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union2.ll (original) +++ poolalloc/trunk/test/dsa/types/union2.ll Wed Apr 27 15:48:35 2011 @@ -2,6 +2,8 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" +;RUN: dsaopt %s -dsa-local -analyze -check-type=func:obj,0:i32::4:i16|i32::8:i32 +;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32::4:i32::8:i32 %struct.StructType1 = type { i32, i32, i32 } %struct.StructType2 = type { i32, i16, i32 } %union.UnionType = type { %struct.StructType1 } Modified: poolalloc/trunk/test/dsa/types/union3.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union3.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union3.ll (original) +++ poolalloc/trunk/test/dsa/types/union3.ll Wed Apr 27 15:48:35 2011 @@ -1,6 +1,8 @@ ; ModuleID = 'union3.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" +;RUN: dsaopt %s -dsa-local -analyze -check-type=func:obj,0:i32::4:i16|i32::6:i16::8:i32 +;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32::4:i32::8:i32 %struct.StructType1 = type { i32, i32, i32 } %struct.StructType2 = type { i32, i16, i16, i32 } Modified: poolalloc/trunk/test/dsa/types/union4.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union4.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union4.ll (original) +++ poolalloc/trunk/test/dsa/types/union4.ll Wed Apr 27 15:48:35 2011 @@ -1,6 +1,8 @@ ; ModuleID = 'union4.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" +;RUN: dsaopt %s -dsa-local -analyze -check-type=func:obj,0:i32::4:i16|i32::6:i16::8:i32 +;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32::4:i32::8:i32 %struct.StructType1 = type { i32, i32, i32 } %struct.StructType2 = type { i32, i16, i16, i32 } Modified: poolalloc/trunk/test/dsa/types/union_arrays.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union_arrays.ll?rev=130328&r1=130327&r2=130328&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union_arrays.ll (original) +++ poolalloc/trunk/test/dsa/types/union_arrays.ll Wed Apr 27 15:48:35 2011 @@ -1,6 +1,10 @@ ; ModuleID = 'union_arrays.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" +;RUN: dsaopt %s -dsa-local -analyze -check-type=func:obj,FoldedVOID +;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,FoldedVOID +;RUN: adsaopt %s -mem2reg -simplify-gep -mergearrgep -dce -o t.bc +;RUN: dsaopt t.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32|[10 x i32]::40:i16|[10 x i16]::60:i32|[10 x i32] %struct.StructType1 = type { [10 x i32], [10 x i16], [10 x i32] } %struct.StructType2 = type { [10 x i32], [10 x i32], [10 x i32] } From aggarwa4 at illinois.edu Wed Apr 27 15:49:17 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Wed, 27 Apr 2011 20:49:17 -0000 Subject: [llvm-commits] [poolalloc] r130329 - in /poolalloc/trunk/test/dsa: local/union.ll local/union_P2I.ll td/params1.ll td/params2.ll Message-ID: <20110427204917.CE99F2A6C12D@llvm.org> Author: aggarwa4 Date: Wed Apr 27 15:49:17 2011 New Revision: 130329 URL: http://llvm.org/viewvc/llvm-project?rev=130329&view=rev Log: Updated tests. Removed: poolalloc/trunk/test/dsa/local/union.ll poolalloc/trunk/test/dsa/td/params2.ll Modified: poolalloc/trunk/test/dsa/local/union_P2I.ll poolalloc/trunk/test/dsa/td/params1.ll Removed: poolalloc/trunk/test/dsa/local/union.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/union.ll?rev=130328&view=auto ============================================================================== --- poolalloc/trunk/test/dsa/local/union.ll (original) +++ poolalloc/trunk/test/dsa/local/union.ll (removed) @@ -1,64 +0,0 @@ -; ModuleID = 'union.bc' -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" -target triple = "x86_64-unknown-linux-gnu" - -;TODO: What exactly does this test? - -;Mark this as expected to fail since we don't plan on implementing this anytime soon. -;XFAIL: * - -;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:tmp:0,func:c:0,func:s1:0 -;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:s1:8,func:x:8 - -%struct.StructType = type { float, i32* } -%union.UnionType = type { %struct.StructType, [96 x i32] } - -define void @func() nounwind { -entry: - %tmp = alloca i32* ; [#uses=2] - %s1 = alloca %union.UnionType ; <%union.UnionType*> [#uses=5] - %c = alloca i32* ; [#uses=1] - %d = alloca i32 ; [#uses=1] - %arr = alloca i32 ; [#uses=1] - %x = alloca %struct.StructType ; <%struct.StructType*> [#uses=3] - %y = alloca float ; [#uses=1] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - %0 = call noalias i8* @malloc(i64 4) nounwind ; [#uses=1] - %1 = bitcast i8* %0 to i32* ; [#uses=1] - store i32* %1, i32** %tmp, align 8 - %2 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1] - %3 = bitcast %struct.StructType* %2 to i32** ; [#uses=1] - %4 = load i32** %tmp, align 8 ; [#uses=1] - store i32* %4, i32** %3, align 8 - %5 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1] - %6 = bitcast %struct.StructType* %5 to i32** ; [#uses=1] - %7 = load i32** %6, align 8 ; [#uses=1] - store i32* %7, i32** %c, align 8 - %8 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1] - %9 = bitcast %struct.StructType* %8 to i32* ; [#uses=1] - %10 = load i32* %9, align 8 ; [#uses=1] - store i32 %10, i32* %d, align 4 - %11 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1] - %12 = bitcast %struct.StructType* %11 to [100 x i32]* ; <[100 x i32]*> [#uses=1] - %13 = getelementptr inbounds [100 x i32]* %12, i64 0, i64 0 ; [#uses=1] - %14 = load i32* %13, align 4 ; [#uses=1] - store i32 %14, i32* %arr, align 4 - %15 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=2] - %16 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; [#uses=1] - %17 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 0 ; [#uses=1] - %18 = load float* %17, align 8 ; [#uses=1] - store float %18, float* %16, align 8 - %19 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 1 ; [#uses=1] - %20 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 1 ; [#uses=1] - %21 = load i32** %20, align 8 ; [#uses=1] - store i32* %21, i32** %19, align 8 - %22 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; [#uses=1] - %23 = load float* %22, align 8 ; [#uses=1] - store float %23, float* %y, align 4 - br label %return - -return: ; preds = %entry - ret void -} - -declare noalias i8* @malloc(i64) nounwind Modified: poolalloc/trunk/test/dsa/local/union_P2I.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/union_P2I.ll?rev=130329&r1=130328&r2=130329&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/local/union_P2I.ll (original) +++ poolalloc/trunk/test/dsa/local/union_P2I.ll Wed Apr 27 15:49:17 2011 @@ -1,7 +1,5 @@ ;checks that the PtrToInt and IntToPtr flag is set on unions that contain integer and pointer types -;Mark this as expected to fail since we don't plan on implementing this anytime soon. -;XFAIL: * ;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:ptr:0,main:obj:0 ;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:obj+UP2" Modified: poolalloc/trunk/test/dsa/td/params1.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/td/params1.ll?rev=130329&r1=130328&r2=130329&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/td/params1.ll (original) +++ poolalloc/trunk/test/dsa/td/params1.ll Wed Apr 27 15:49:17 2011 @@ -10,6 +10,8 @@ ;RUN: dsaopt %s -dsa-td -analyze -verify-flags "initialize:temp:0+HMRE-I" ;RUN: dsaopt %s -dsa-td -analyze -verify-flags "initialize:arr+SMRE-I" +;RUN: dsaopt %s -dsa-td -analyze -verify-flags "main:InfoArray:0+HMR-IE" + ; ModuleID = 'params1.bc' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" Removed: poolalloc/trunk/test/dsa/td/params2.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/td/params2.ll?rev=130328&view=auto ============================================================================== --- poolalloc/trunk/test/dsa/td/params2.ll (original) +++ poolalloc/trunk/test/dsa/td/params2.ll (removed) @@ -1,118 +0,0 @@ -; ModuleID = 'params2.bc' -;FIXME: Remove this test entirely or add a RUN line! -;XFAIL:* -;RUN: not -target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" -target triple = "x86_64-unknown-linux-gnu" - -%struct.InfoStruct = type { i32, i32, float } - -define void @initialize(%struct.InfoStruct** %arr, i32 %size) nounwind { -entry: - %arr_addr = alloca %struct.InfoStruct** ; <%struct.InfoStruct***> [#uses=3] - %size_addr = alloca i32 ; [#uses=2] - %temp = alloca %struct.InfoStruct* ; <%struct.InfoStruct**> [#uses=7] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - store %struct.InfoStruct** %arr, %struct.InfoStruct*** %arr_addr - store i32 %size, i32* %size_addr - %0 = load %struct.InfoStruct*** %arr_addr, align 8 ; <%struct.InfoStruct**> [#uses=1] - %1 = load %struct.InfoStruct** %0, align 8 ; <%struct.InfoStruct*> [#uses=1] - store %struct.InfoStruct* %1, %struct.InfoStruct** %temp, align 8 - br label %bb1 - -bb: ; preds = %bb1 - %2 = load %struct.InfoStruct** %temp, align 8 ; <%struct.InfoStruct*> [#uses=1] - %3 = getelementptr inbounds %struct.InfoStruct* %2, i32 0, i32 0 ; [#uses=1] - store i32 0, i32* %3, align 4 - %4 = load %struct.InfoStruct** %temp, align 8 ; <%struct.InfoStruct*> [#uses=1] - %5 = getelementptr inbounds %struct.InfoStruct* %4, i32 0, i32 1 ; [#uses=1] - store i32 0, i32* %5, align 4 - %6 = load %struct.InfoStruct** %temp, align 8 ; <%struct.InfoStruct*> [#uses=1] - %7 = getelementptr inbounds %struct.InfoStruct* %6, i32 0, i32 2 ; [#uses=1] - store float 0.000000e+00, float* %7, align 4 - %8 = load %struct.InfoStruct** %temp, align 8 ; <%struct.InfoStruct*> [#uses=1] - %9 = getelementptr inbounds %struct.InfoStruct* %8, i64 1 ; <%struct.InfoStruct*> [#uses=1] - store %struct.InfoStruct* %9, %struct.InfoStruct** %temp, align 8 - br label %bb1 - -bb1: ; preds = %bb, %entry - %10 = load %struct.InfoStruct*** %arr_addr, align 8 ; <%struct.InfoStruct**> [#uses=1] - %11 = load %struct.InfoStruct** %10, align 8 ; <%struct.InfoStruct*> [#uses=1] - %12 = load i32* %size_addr, align 4 ; [#uses=1] - %13 = sext i32 %12 to i64 ; [#uses=1] - %14 = getelementptr inbounds %struct.InfoStruct* %11, i64 %13 ; <%struct.InfoStruct*> [#uses=1] - %15 = load %struct.InfoStruct** %temp, align 8 ; <%struct.InfoStruct*> [#uses=1] - %16 = icmp ugt %struct.InfoStruct* %14, %15 ; [#uses=1] - br i1 %16, label %bb, label %bb2 - -bb2: ; preds = %bb1 - br label %return - -return: ; preds = %bb2 - ret void -} - -define void @process(%struct.InfoStruct** %arr, i32 %loc, i32 %count, float %fact) nounwind { -entry: - %arr_addr = alloca %struct.InfoStruct** ; <%struct.InfoStruct***> [#uses=2] - %loc_addr = alloca i32 ; [#uses=2] - %count_addr = alloca i32 ; [#uses=2] - %fact_addr = alloca float ; [#uses=2] - %ptr = alloca %struct.InfoStruct* ; <%struct.InfoStruct**> [#uses=2] - %obj = alloca %struct.InfoStruct ; <%struct.InfoStruct*> [#uses=6] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - store %struct.InfoStruct** %arr, %struct.InfoStruct*** %arr_addr - store i32 %loc, i32* %loc_addr - store i32 %count, i32* %count_addr - store float %fact, float* %fact_addr - %0 = load %struct.InfoStruct*** %arr_addr, align 8 ; <%struct.InfoStruct**> [#uses=1] - %1 = load %struct.InfoStruct** %0, align 8 ; <%struct.InfoStruct*> [#uses=1] - store %struct.InfoStruct* %1, %struct.InfoStruct** %ptr, align 8 - %2 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 0 ; [#uses=1] - %3 = load i32* %count_addr, align 4 ; [#uses=1] - store i32 %3, i32* %2, align 4 - %4 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 2 ; [#uses=1] - %5 = load float* %fact_addr, align 4 ; [#uses=1] - store float %5, float* %4, align 4 - %6 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 1 ; [#uses=1] - store i32 1, i32* %6, align 4 - %7 = load %struct.InfoStruct** %ptr, align 8 ; <%struct.InfoStruct*> [#uses=1] - %8 = load i32* %loc_addr, align 4 ; [#uses=1] - %9 = sext i32 %8 to i64 ; [#uses=1] - %10 = getelementptr inbounds %struct.InfoStruct* %7, i64 %9 ; <%struct.InfoStruct*> [#uses=3] - %11 = getelementptr inbounds %struct.InfoStruct* %10, i32 0, i32 0 ; [#uses=1] - %12 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 0 ; [#uses=1] - %13 = load i32* %12, align 1 ; [#uses=1] - store i32 %13, i32* %11, align 1 - %14 = getelementptr inbounds %struct.InfoStruct* %10, i32 0, i32 1 ; [#uses=1] - %15 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 1 ; [#uses=1] - %16 = load i32* %15, align 1 ; [#uses=1] - store i32 %16, i32* %14, align 1 - %17 = getelementptr inbounds %struct.InfoStruct* %10, i32 0, i32 2 ; [#uses=1] - %18 = getelementptr inbounds %struct.InfoStruct* %obj, i32 0, i32 2 ; [#uses=1] - %19 = load float* %18, align 1 ; [#uses=1] - store float %19, float* %17, align 1 - br label %return - -return: ; preds = %entry - ret void -} - -define i32 @main() nounwind { -entry: - %retval = alloca i32 ; [#uses=1] - %InfoArray = alloca %struct.InfoStruct* ; <%struct.InfoStruct**> [#uses=3] - %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] - %0 = call noalias i8* @malloc(i64 120) nounwind ; [#uses=1] - %1 = bitcast i8* %0 to %struct.InfoStruct* ; <%struct.InfoStruct*> [#uses=1] - store %struct.InfoStruct* %1, %struct.InfoStruct** %InfoArray, align 8 - call void @initialize(%struct.InfoStruct** %InfoArray, i32 10) nounwind - call void @process(%struct.InfoStruct** %InfoArray, i32 4, i32 3, float 5.500000e+00) nounwind - br label %return - -return: ; preds = %entry - %retval1 = load i32* %retval ; [#uses=1] - ret i32 %retval1 -} - -declare noalias i8* @malloc(i64) nounwind From enderby at apple.com Wed Apr 27 16:02:27 2011 From: enderby at apple.com (Kevin Enderby) Date: Wed, 27 Apr 2011 21:02:27 -0000 Subject: [llvm-commits] [llvm] r130330 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Message-ID: <20110427210227.AEEA62A6C12D@llvm.org> Author: enderby Date: Wed Apr 27 16:02:27 2011 New Revision: 130330 URL: http://llvm.org/viewvc/llvm-project?rev=130330&view=rev Log: Fix a bug in the case that there is no add or subtract symbol and the offset value is zero so it does not add a NULL expr operand. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=130330&r1=130329&r2=130330&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Apr 27 16:02:27 2011 @@ -3800,8 +3800,12 @@ Expr = MCBinaryExpr::CreateAdd(Add, Off, *Ctx); else Expr = Add; - } else - Expr = Off; + } else { + if (Off != 0) + Expr = Off; + else + Expr = MCConstantExpr::Create(0, *Ctx); + } if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_HI16) MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateUpper16(Expr, *Ctx))); From zwarich at apple.com Wed Apr 27 16:09:20 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 27 Apr 2011 14:09:20 -0700 Subject: [llvm-commits] [llvm] r130330 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp In-Reply-To: <20110427210227.AEEA62A6C12D@llvm.org> References: <20110427210227.AEEA62A6C12D@llvm.org> Message-ID: <75A53D80-256E-4E32-84B3-97DDF00DC30A@apple.com> Test case? Cameron On Apr 27, 2011, at 2:02 PM, Kevin Enderby wrote: > Author: enderby > Date: Wed Apr 27 16:02:27 2011 > New Revision: 130330 > > URL: http://llvm.org/viewvc/llvm-project?rev=130330&view=rev > Log: > Fix a bug in the case that there is no add or subtract symbol and the offset > value is zero so it does not add a NULL expr operand. > > Modified: > llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp > > Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=130330&r1=130329&r2=130330&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) > +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Apr 27 16:02:27 2011 > @@ -3800,8 +3800,12 @@ > Expr = MCBinaryExpr::CreateAdd(Add, Off, *Ctx); > else > Expr = Add; > - } else > - Expr = Off; > + } else { > + if (Off != 0) > + Expr = Off; > + else > + Expr = MCConstantExpr::Create(0, *Ctx); > + } > > if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_HI16) > MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateUpper16(Expr, *Ctx))); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From enderby at apple.com Wed Apr 27 16:14:24 2011 From: enderby at apple.com (Kevin Enderby) Date: Wed, 27 Apr 2011 14:14:24 -0700 Subject: [llvm-commits] [llvm] r130330 - /llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp In-Reply-To: <75A53D80-256E-4E32-84B3-97DDF00DC30A@apple.com> References: <20110427210227.AEEA62A6C12D@llvm.org> <75A53D80-256E-4E32-84B3-97DDF00DC30A@apple.com> Message-ID: This was found via using the public 'C' disassembler via otool(1). I don't have a test case for the 32-bit arm code. Kev On Apr 27, 2011, at 2:09 PM, Cameron Zwarich wrote: > Test case? > > Cameron > > On Apr 27, 2011, at 2:02 PM, Kevin Enderby wrote: > >> Author: enderby >> Date: Wed Apr 27 16:02:27 2011 >> New Revision: 130330 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130330&view=rev >> Log: >> Fix a bug in the case that there is no add or subtract symbol and the offset >> value is zero so it does not add a NULL expr operand. >> >> Modified: >> llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp >> >> Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=130330&r1=130329&r2=130330&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Apr 27 16:02:27 2011 >> @@ -3800,8 +3800,12 @@ >> Expr = MCBinaryExpr::CreateAdd(Add, Off, *Ctx); >> else >> Expr = Add; >> - } else >> - Expr = Off; >> + } else { >> + if (Off != 0) >> + Expr = Off; >> + else >> + Expr = MCConstantExpr::Create(0, *Ctx); >> + } >> >> if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_HI16) >> MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateUpper16(Expr, *Ctx))); >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From rafael.espindola at gmail.com Wed Apr 27 16:29:53 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 27 Apr 2011 21:29:53 -0000 Subject: [llvm-commits] [llvm] r130331 - /llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Message-ID: <20110427212953.1C6E82A6C12D@llvm.org> Author: rafael Date: Wed Apr 27 16:29:52 2011 New Revision: 130331 URL: http://llvm.org/viewvc/llvm-project?rev=130331&view=rev Log: Fix indentation. Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=130331&r1=130330&r2=130331&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Wed Apr 27 16:29:52 2011 @@ -186,27 +186,27 @@ void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, const MCSymbol *Sym) const { - MCSymbol *Label = getPersonalityPICSymbol(Sym->getName()); - Streamer.EmitSymbolAttribute(Label, MCSA_Hidden); - Streamer.EmitSymbolAttribute(Label, MCSA_Weak); - Twine SectionName = StringRef(".data.") + Label->getName(); - SmallString<64> NameData; - SectionName.toVector(NameData); - unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP; - const MCSection *Sec = getContext().getELFSection(NameData, - ELF::SHT_PROGBITS, - Flags, - SectionKind::getDataRel(), - 0, Label->getName()); - Streamer.SwitchSection(Sec); - Streamer.EmitValueToAlignment(8); - Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject); - const MCExpr *E = MCConstantExpr::Create(8, getContext()); - Streamer.EmitELFSize(Label, E); - Streamer.EmitLabel(Label); + MCSymbol *Label = getPersonalityPICSymbol(Sym->getName()); + Streamer.EmitSymbolAttribute(Label, MCSA_Hidden); + Streamer.EmitSymbolAttribute(Label, MCSA_Weak); + Twine SectionName = StringRef(".data.") + Label->getName(); + SmallString<64> NameData; + SectionName.toVector(NameData); + unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP; + const MCSection *Sec = getContext().getELFSection(NameData, + ELF::SHT_PROGBITS, + Flags, + SectionKind::getDataRel(), + 0, Label->getName()); + Streamer.SwitchSection(Sec); + Streamer.EmitValueToAlignment(8); + Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject); + const MCExpr *E = MCConstantExpr::Create(8, getContext()); + Streamer.EmitELFSize(Label, E); + Streamer.EmitLabel(Label); - unsigned Size = TM.getTargetData()->getPointerSize(); - Streamer.EmitSymbolValue(Sym, Size); + unsigned Size = TM.getTargetData()->getPointerSize(); + Streamer.EmitSymbolValue(Sym, Size); } static SectionKind From geek4civic at gmail.com Wed Apr 27 16:53:35 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 27 Apr 2011 21:53:35 -0000 Subject: [llvm-commits] [llvm] r130333 - /llvm/trunk/docs/doxygen.css Message-ID: <20110427215335.E48012A6C12D@llvm.org> Author: chapuni Date: Wed Apr 27 16:53:35 2011 New Revision: 130333 URL: http://llvm.org/viewvc/llvm-project?rev=130333&view=rev Log: docs/doxygen.css: Tweak style for readability. A few styles are brought from http://llvm.org/test-doxygen/api/api.css Modified: llvm/trunk/docs/doxygen.css Modified: llvm/trunk/docs/doxygen.css URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/doxygen.css?rev=130333&r1=130332&r2=130333&view=diff ============================================================================== --- llvm/trunk/docs/doxygen.css (original) +++ llvm/trunk/docs/doxygen.css Wed Apr 27 16:53:35 2011 @@ -370,9 +370,34 @@ H3 { font-size: 100%; } + +H2, H3 { + border-bottom: 2px solid; + margin-top: 2em; +} + A.qindex {} A.qindexRef {} A.el { text-decoration: none; font-weight: bold } A.elRef { font-weight: bold } A.code { text-decoration: none; font-weight: normal; color: #4444ee } A.codeRef { font-weight: normal; color: #4444ee } + +div.memitem { + border: 1px solid #999999; + margin-top: 1.0em; + margin-bottom: 1.0em; + -webkit-border-radius: 0.5em; + -webkit-box-shadow: 3px 3px 6px #777777; + -moz-border-radius: 0.5em; + -moz-box-shadow: black 3px 3px 3px; +} + +div.memproto { + background-color: #E3E4E5; + padding: 0.25em 0.5em; + -webkit-border-top-left-radius: 0.5em; + -webkit-border-top-right-radius: 0.5em; + -moz-border-radius-topleft: 0.5em; + -moz-border-radius-topright: 0.5em; +} From eli.friedman at gmail.com Wed Apr 27 17:21:02 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 22:21:02 -0000 Subject: [llvm-commits] [llvm] r130337 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp Message-ID: <20110427222102.AF8CC2A6C12D@llvm.org> Author: efriedma Date: Wed Apr 27 17:21:02 2011 New Revision: 130337 URL: http://llvm.org/viewvc/llvm-project?rev=130337&view=rev Log: Remove unused function. Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=130337&r1=130336&r2=130337&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Wed Apr 27 17:21:02 2011 @@ -204,15 +204,6 @@ unsigned Op0, bool Op0IsKill, uint64_t Imm, MVT ImmType); - /// FastEmit_rf_ - This method is a wrapper of FastEmit_rf. It first tries - /// to emit an instruction with an immediate operand using FastEmit_rf. - /// If that fails, it materializes the immediate into a register and try - /// FastEmit_rr instead. - unsigned FastEmit_rf_(MVT VT, - unsigned Opcode, - unsigned Op0, bool Op0IsKill, - const ConstantFP *FPImm, MVT ImmType); - /// FastEmit_i - This method is called by target-independent code /// to request that an instruction with the given type, opcode, and /// immediate operand be emitted. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130337&r1=130336&r2=130337&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Apr 27 17:21:02 2011 @@ -1035,53 +1035,6 @@ MaterialReg, /*Kill=*/true); } -/// FastEmit_rf_ - This method is a wrapper of FastEmit_ri. It first tries -/// to emit an instruction with a floating-point immediate operand using -/// FastEmit_rf. If that fails, it materializes the immediate into a register -/// and try FastEmit_rr instead. -unsigned FastISel::FastEmit_rf_(MVT VT, unsigned Opcode, - unsigned Op0, bool Op0IsKill, - const ConstantFP *FPImm, MVT ImmType) { - // First check if immediate type is legal. If not, we can't use the rf form. - unsigned ResultReg = FastEmit_rf(VT, VT, Opcode, Op0, Op0IsKill, FPImm); - if (ResultReg != 0) - return ResultReg; - - // Materialize the constant in a register. - unsigned MaterialReg = FastEmit_f(ImmType, ImmType, ISD::ConstantFP, FPImm); - if (MaterialReg == 0) { - // If the target doesn't have a way to directly enter a floating-point - // value into a register, use an alternate approach. - // TODO: The current approach only supports floating-point constants - // that can be constructed by conversion from integer values. This should - // be replaced by code that creates a load from a constant-pool entry, - // which will require some target-specific work. - const APFloat &Flt = FPImm->getValueAPF(); - EVT IntVT = TLI.getPointerTy(); - - uint64_t x[2]; - uint32_t IntBitWidth = IntVT.getSizeInBits(); - bool isExact; - (void) Flt.convertToInteger(x, IntBitWidth, /*isSigned=*/true, - APFloat::rmTowardZero, &isExact); - if (!isExact) - return 0; - APInt IntVal(IntBitWidth, 2, x); - - unsigned IntegerReg = FastEmit_i(IntVT.getSimpleVT(), IntVT.getSimpleVT(), - ISD::Constant, IntVal.getZExtValue()); - if (IntegerReg == 0) - return 0; - MaterialReg = FastEmit_r(IntVT.getSimpleVT(), VT, - ISD::SINT_TO_FP, IntegerReg, /*Kill=*/true); - if (MaterialReg == 0) - return 0; - } - return FastEmit_rr(VT, VT, Opcode, - Op0, Op0IsKill, - MaterialReg, /*Kill=*/true); -} - unsigned FastISel::createResultReg(const TargetRegisterClass* RC) { return MRI.createVirtualRegister(RC); } From eli.friedman at gmail.com Wed Apr 27 17:41:55 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 22:41:55 -0000 Subject: [llvm-commits] [llvm] r130338 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll Message-ID: <20110427224155.767CC2A6C12D@llvm.org> Author: efriedma Date: Wed Apr 27 17:41:55 2011 New Revision: 130338 URL: http://llvm.org/viewvc/llvm-project?rev=130338&view=rev Log: Make the fast-isel code for literal 0.0 a bit shorter/faster, since 0.0 is common. rdar://problem/9303592 . Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Modified: llvm/trunk/include/llvm/CodeGen/FastISel.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/FastISel.h?rev=130338&r1=130337&r2=130338&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/FastISel.h (original) +++ llvm/trunk/include/llvm/CodeGen/FastISel.h Wed Apr 27 17:41:55 2011 @@ -317,6 +317,10 @@ return 0; } + virtual unsigned TargetMaterializeFloatZero(const ConstantFP* CF) { + return 0; + } + private: bool SelectBinaryOp(const User *I, unsigned ISDOpcode); Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130338&r1=130337&r2=130338&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Apr 27 17:41:55 2011 @@ -164,8 +164,12 @@ Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext()))); } else if (const ConstantFP *CF = dyn_cast(V)) { - // Try to emit the constant directly. - Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); + if (CF->isZero()) { + Reg = TargetMaterializeFloatZero(CF); + } else { + // Try to emit the constant directly. + Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); + } if (!Reg) { // Try to emit the constant by using an integer constant with a cast. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130338&r1=130337&r2=130338&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Wed Apr 27 17:41:55 2011 @@ -124,6 +124,8 @@ unsigned TargetMaterializeAlloca(const AllocaInst *C); + unsigned TargetMaterializeFloatZero(const ConstantFP *CF); + /// isScalarFPTypeInSSEReg - Return true if the specified scalar FP type is /// computed in an SSE register, not on the X87 floating point stack. bool isScalarFPTypeInSSEReg(EVT VT) const { @@ -2049,6 +2051,45 @@ return ResultReg; } +unsigned X86FastISel::TargetMaterializeFloatZero(const ConstantFP *CF) { + MVT VT; + if (!isTypeLegal(CF->getType(), VT)) + return false; + + // Get opcode and regclass for the given zero. + unsigned Opc = 0; + const TargetRegisterClass *RC = NULL; + switch (VT.SimpleTy) { + default: return false; + case MVT::f32: + if (Subtarget->hasSSE1()) { + Opc = X86::FsFLD0SS; + RC = X86::FR32RegisterClass; + } else { + Opc = X86::LD_Fp032; + RC = X86::RFP32RegisterClass; + } + break; + case MVT::f64: + if (Subtarget->hasSSE2()) { + Opc = X86::FsFLD0SD; + RC = X86::FR64RegisterClass; + } else { + Opc = X86::LD_Fp064; + RC = X86::RFP64RegisterClass; + } + break; + case MVT::f80: + // No f80 support yet. + return false; + } + + unsigned ResultReg = createResultReg(RC); + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(Opc), ResultReg); + return ResultReg; +} + + /// TryToFoldLoad - The specified machine instr operand is a vreg, and that /// vreg is being provided by the specified load instruction. If possible, /// try to fold the load as an operand to the instruction, returning true if Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130338&r1=130337&r2=130338&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Wed Apr 27 17:41:55 2011 @@ -225,3 +225,16 @@ ; CHECK-NEXT: je } +; Check that 0.0 is materialized using pxor +define void @test18(float* %p1) { + store float 0.0, float* %p1 + ret void +; CHECK: test18: +; CHECK: pxor +} +define void @test19(double* %p1) { + store double 0.0, double* %p1 + ret void +; CHECK: test19: +; CHECK: pxor +} From dpatel at apple.com Wed Apr 27 17:45:24 2011 From: dpatel at apple.com (Devang Patel) Date: Wed, 27 Apr 2011 22:45:24 -0000 Subject: [llvm-commits] [llvm] r130339 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfCompileUnit.cpp DwarfCompileUnit.h DwarfDebug.cpp Message-ID: <20110427224524.47CEA2A6C12D@llvm.org> Author: dpatel Date: Wed Apr 27 17:45:24 2011 New Revision: 130339 URL: http://llvm.org/viewvc/llvm-project?rev=130339&view=rev Log: Simplify handling of variables with complex address (i.e. blocks variables) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=130339&r1=130338&r2=130339&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Apr 27 17:45:24 2011 @@ -192,16 +192,10 @@ addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); } -/// addFrameVariableAddress - Add DW_AT_location attribute for a -/// DbgVariable based on provided frame index. -void CompileUnit::addFrameVariableAddress(DbgVariable *&DV, DIE *Die, - int64_t FI) { - MachineLocation Location; - unsigned FrameReg; - const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); - int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg); - Location.set(FrameReg, Offset); - +/// addVariableAddress - Add DW_AT_location attribute for a +/// DbgVariable based on provided MachineLocation. +void CompileUnit::addVariableAddress(DbgVariable *&DV, DIE *Die, + MachineLocation Location) { if (DV->variableHasComplexAddress()) addComplexAddress(DV, Die, dwarf::DW_AT_location, Location); else if (DV->isBlockByrefVariable()) @@ -255,17 +249,6 @@ addBlock(Die, Attribute, 0, Block); } -/// addRegisterAddress - Add register location entry in variable DIE. -bool CompileUnit::addRegisterAddress(DIE *Die, const MachineOperand &MO) { - assert (MO.isReg() && "Invalid machine operand!"); - if (!MO.getReg()) - return false; - MachineLocation Location; - Location.set(MO.getReg()); - addAddress(Die, dwarf::DW_AT_location, Location); - return true; -} - /// addComplexAddress - Start with the address based on the location provided, /// and generate the DWARF information necessary to find the actual variable /// given the extra address information encoded in the DIVariable, starting from Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=130339&r1=130338&r2=130339&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Wed Apr 27 17:45:24 2011 @@ -181,9 +181,6 @@ void addAddress(DIE *Die, unsigned Attribute, const MachineLocation &Location); - /// addRegisterAddress - Add register location entry in variable DIE. - bool addRegisterAddress(DIE *Die, const MachineOperand &MO); - /// addConstantValue - Add constant value entry in variable DIE. bool addConstantValue(DIE *Die, const MachineOperand &MO); bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned); @@ -218,9 +215,9 @@ void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location); - /// addFrameVariableAddress - Add DW_AT_location attribute for a DbgVariable - /// based on provided frame index. - void addFrameVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI); + /// addVariableAddress - Add DW_AT_location attribute for a + /// DbgVariable based on provided MachineLocation. + void addVariableAddress(DbgVariable *&DV, DIE *Die, MachineLocation Location); /// addToContextOwner - Add Die into the list of its context owner's children. void addToContextOwner(DIE *Die, DIDescriptor Context); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130339&r1=130338&r2=130339&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 27 17:45:24 2011 @@ -699,11 +699,19 @@ const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo(); if (DVInsn->getOperand(1).isImm() && TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) { - VariableCU->addFrameVariableAddress(DV, VariableDie, - DVInsn->getOperand(1).getImm()); - updated = true; - } else - updated = VariableCU->addRegisterAddress(VariableDie, RegOp); + unsigned FrameReg = 0; + const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); + int Offset = + TFI->getFrameIndexReference(*Asm->MF, + DVInsn->getOperand(1).getImm(), + FrameReg); + MachineLocation Location(FrameReg, Offset); + VariableCU->addVariableAddress(DV, VariableDie, Location); + + } else if (RegOp.getReg()) + VariableCU->addVariableAddress(DV, VariableDie, + MachineLocation(RegOp.getReg())); + updated = true; } else if (DVInsn->getOperand(0).isImm()) updated = VariableCU->addConstantValue(VariableDie, @@ -712,15 +720,9 @@ updated = VariableCU->addConstantFPValue(VariableDie, DVInsn->getOperand(0)); } else { - MachineLocation Location = Asm->getDebugValueLocation(DVInsn); - if (Location.getReg()) { - if (DV->getVariable().hasComplexAddress()) - VariableCU->addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, - Location); - else - VariableCU->addAddress(VariableDie, dwarf::DW_AT_location, Location); - updated = true; - } + VariableCU->addVariableAddress(DV, VariableDie, + Asm->getDebugValueLocation(DVInsn)); + updated = true; } if (!updated) { // If variableDie is not updated then DBG_VALUE instruction does not @@ -734,9 +736,15 @@ // .. else use frame index, if available. int FI = 0; - if (findVariableFrameIndex(DV, &FI)) - VariableCU->addFrameVariableAddress(DV, VariableDie, FI); - + if (findVariableFrameIndex(DV, &FI)) { + unsigned FrameReg = 0; + const TargetFrameLowering *TFI = Asm->TM.getFrameLowering(); + int Offset = + TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg); + MachineLocation Location(FrameReg, Offset); + VariableCU->addVariableAddress(DV, VariableDie, Location); + } + DV->setDIE(VariableDie); return VariableDie; From atrick at apple.com Wed Apr 27 18:00:03 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 27 Apr 2011 23:00:03 -0000 Subject: [llvm-commits] [llvm] r130340 - in /llvm/trunk: lib/Transforms/Scalar/IndVarSimplify.cpp test/Transforms/IndVarSimplify/2009-04-27-Floating.ll Message-ID: <20110427230003.BC9532A6C12D@llvm.org> Author: atrick Date: Wed Apr 27 18:00:03 2011 New Revision: 130340 URL: http://llvm.org/viewvc/llvm-project?rev=130340&view=rev Log: Fixes PR9730: indvars: An asserting value handle still pointed to this value Modified LinearFunctionTestReplace to push the condition on the dead list instead of eagerly deleting it. This can cause unnecessary IV rewrites, which should have no effect on codegen and will not be an issue once we stop generating canonical IVs. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp llvm/trunk/test/Transforms/IndVarSimplify/2009-04-27-Floating.ll Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=130340&r1=130339&r2=130340&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Apr 27 18:00:03 2011 @@ -275,7 +275,7 @@ // update the branch to use the new comparison; in the common case this // will make old comparison dead. BI->setCondition(Cond); - RecursivelyDeleteTriviallyDeadInstructions(OrigCond); + DeadInsts.push_back(OrigCond); ++NumLFTR; Changed = true; Modified: llvm/trunk/test/Transforms/IndVarSimplify/2009-04-27-Floating.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IndVarSimplify/2009-04-27-Floating.ll?rev=130340&r1=130339&r2=130340&view=diff ============================================================================== --- llvm/trunk/test/Transforms/IndVarSimplify/2009-04-27-Floating.ll (original) +++ llvm/trunk/test/Transforms/IndVarSimplify/2009-04-27-Floating.ll Wed Apr 27 18:00:03 2011 @@ -1,4 +1,4 @@ -; RUN: opt < %s -indvars -S | grep icmp | grep next +; RUN: opt < %s -indvars -S | FileCheck %s ; PR4086 declare void @foo() @@ -6,13 +6,14 @@ entry: br label %loop_body -loop_body: - %i = phi float [ %nexti, %loop_body ], [ 0.0, %entry ] +loop_body: + %i = phi float [ %nexti, %loop_body ], [ 0.0, %entry ] tail call void @foo() %nexti = fadd float %i, 1.0 - %less = fcmp olt float %nexti, 2.0 + ; CHECK: icmp ne i32 %{{[a-zA-Z$._0-9]+}}, 2 + %less = fcmp olt float %nexti, 2.0 br i1 %less, label %loop_body, label %done -done: +done: ret void } From rafael.espindola at gmail.com Wed Apr 27 18:08:15 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 27 Apr 2011 23:08:15 -0000 Subject: [llvm-commits] [llvm] r130341 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfCFIException.cpp lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h Message-ID: <20110427230815.434F22A6C12D@llvm.org> Author: rafael Date: Wed Apr 27 18:08:15 2011 New Revision: 130341 URL: http://llvm.org/viewvc/llvm-project?rev=130341&view=rev Log: Rename getPersonalityPICSymbol to getCFIPersonalitySymbol, document it, and give it a bit more responsibility. Also implement it for MachO. If hacked to use cfi, 32 bit MachO will produce .cfi_personality 155, L___gxx_personality_v0$non_lazy_ptr and 64 bit will produce .cfi_presonality ___gxx_personality_v0 The general idea is that .cfi_personality gets passed the final symbol. It is up to codegen to produce it if using indirect representation (like 32 bit MachO), but it is up to MC to decide which relocations to create. Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Wed Apr 27 18:08:15 2011 @@ -58,7 +58,6 @@ virtual void Initialize(MCContext &Ctx, const TargetMachine &TM); virtual const MCSection *getEHFrameSection() const; - virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const; virtual void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, @@ -86,6 +85,11 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const; + + // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. + virtual MCSymbol * + getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, + Mangler *Mang, MachineModuleInfo *MMI) const; }; @@ -177,6 +181,11 @@ MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const; + // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. + virtual MCSymbol * + getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, + Mangler *Mang, MachineModuleInfo *MMI) const; + virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; virtual unsigned getFDEEncoding() const; Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Wed Apr 27 18:08:15 2011 @@ -140,7 +140,6 @@ const MCSection *getStaticDtorSection() const { return StaticDtorSection; } const MCSection *getLSDASection() const { return LSDASection; } virtual const MCSection *getEHFrameSection() const = 0; - virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const; virtual void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, const MCSymbol *Sym) const; @@ -222,6 +221,11 @@ MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const; + // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. + virtual MCSymbol * + getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, + Mangler *Mang, MachineModuleInfo *MMI) const; + /// const MCExpr * getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Wed Apr 27 18:08:15 2011 @@ -109,17 +109,8 @@ if (PerEncoding == dwarf::DW_EH_PE_omit || !Per) return; - const MCSymbol *Sym; - switch (PerEncoding & 0x70) { - default: - report_fatal_error("We do not support this DWARF encoding yet!"); - case dwarf::DW_EH_PE_absptr: - Sym = Asm->Mang->getSymbol(Per); - break; - case dwarf::DW_EH_PE_pcrel: - Sym = TLOF.getPersonalityPICSymbol(Per->getName()); - break; - } + const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, PerEncoding, + Asm->Mang, MMI); Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); } Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Wed Apr 27 18:08:15 2011 @@ -178,15 +178,29 @@ } MCSymbol * -TargetLoweringObjectFileELF::getPersonalityPICSymbol(StringRef Name) const { - Twine FullName = StringRef("DW.ref.") + Name; - return getContext().GetOrCreateSymbol(FullName); +TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV, + unsigned Encoding, + Mangler *Mang, + MachineModuleInfo *MMI) const { + switch (Encoding & 0x70) { + default: + report_fatal_error("We do not support this DWARF encoding yet!"); + case dwarf::DW_EH_PE_absptr: + return Mang->getSymbol(GV); + break; + case dwarf::DW_EH_PE_pcrel: { + Twine FullName = StringRef("DW.ref.") + Mang->getSymbol(GV)->getName(); + return getContext().GetOrCreateSymbol(FullName); + break; + } + } } void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, - const MCSymbol *Sym) const { - MCSymbol *Label = getPersonalityPICSymbol(Sym->getName()); + const MCSymbol *Sym) const { + Twine FullName = StringRef("DW.ref.") + Sym->getName(); + MCSymbol *Label = getContext().GetOrCreateSymbol(FullName); Streamer.EmitSymbolAttribute(Label, MCSA_Hidden); Streamer.EmitSymbolAttribute(Label, MCSA_Weak); Twine SectionName = StringRef(".data.") + Label->getName(); @@ -834,6 +848,29 @@ getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, Streamer); } +MCSymbol *TargetLoweringObjectFileMachO:: +getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, + MachineModuleInfo *MMI) const { + // The mach-o version of this method defaults to returning a stub reference. + MachineModuleInfoMachO &MachOMMI = + MMI->getObjFileInfo(); + + SmallString<128> Name; + Mang->getNameWithPrefix(Name, GV, true); + Name += "$non_lazy_ptr"; + + // Add information about the stub reference to MachOMMI so that the stub + // gets emitted by the asmprinter. + MCSymbol *SSym = getContext().GetOrCreateSymbol(Name.str()); + MachineModuleInfoImpl::StubValueTy &StubSym = MachOMMI.getGVStubEntry(SSym); + if (StubSym.getPointer() == 0) { + MCSymbol *Sym = Mang->getSymbol(GV); + StubSym = MachineModuleInfoImpl::StubValueTy(Sym, !GV->hasLocalLinkage()); + } + + return SSym; +} + unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const { return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; } Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Apr 27 18:08:15 2011 @@ -120,16 +120,15 @@ return false; } -MCSymbol * -TargetLoweringObjectFile::getPersonalityPICSymbol(StringRef Name) const { - assert(0 && "Not Available in this format."); - return 0; +MCSymbol *TargetLoweringObjectFile:: +getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, + MachineModuleInfo *MMI) const { + return Mang->getSymbol(GV); } void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, const MCSymbol *Sym) const { - assert(0 && "Not Available in this format."); } Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Wed Apr 27 18:08:15 2011 @@ -38,6 +38,12 @@ getExprForDwarfGlobalReference(GV, Mang, MMI, Encoding, Streamer); } +MCSymbol *X8664_MachoTargetObjectFile:: +getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, + MachineModuleInfo *MMI) const { + return Mang->getSymbol(GV); +} + unsigned X8632_ELFTargetObjectFile::getPersonalityEncoding() const { if (TM.getRelocationModel() == Reloc::PIC_) return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4; Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=130341&r1=130340&r2=130341&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Wed Apr 27 18:08:15 2011 @@ -25,6 +25,12 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const; + + // getCFIPersonalitySymbol - The symbol that gets passed to + // .cfi_personality. + virtual MCSymbol * + getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, + Mangler *Mang, MachineModuleInfo *MMI) const; }; class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { From rafael.espindola at gmail.com Wed Apr 27 18:17:57 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 27 Apr 2011 23:17:57 -0000 Subject: [llvm-commits] [llvm] r130343 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfCFIException.cpp lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h Message-ID: <20110427231758.0602B2A6C12F@llvm.org> Author: rafael Date: Wed Apr 27 18:17:57 2011 New Revision: 130343 URL: http://llvm.org/viewvc/llvm-project?rev=130343&view=rev Log: Remove unnecessary argument. Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Wed Apr 27 18:17:57 2011 @@ -88,8 +88,8 @@ // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. virtual MCSymbol * - getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, - Mangler *Mang, MachineModuleInfo *MMI) const; + getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI) const; }; @@ -183,8 +183,8 @@ // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. virtual MCSymbol * - getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, - Mangler *Mang, MachineModuleInfo *MMI) const; + getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI) const; virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Wed Apr 27 18:17:57 2011 @@ -223,8 +223,8 @@ // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. virtual MCSymbol * - getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, - Mangler *Mang, MachineModuleInfo *MMI) const; + getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI) const; /// const MCExpr * Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Wed Apr 27 18:17:57 2011 @@ -109,8 +109,7 @@ if (PerEncoding == dwarf::DW_EH_PE_omit || !Per) return; - const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, PerEncoding, - Asm->Mang, MMI); + const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, Asm->Mang, MMI); Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); } Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Wed Apr 27 18:17:57 2011 @@ -179,9 +179,9 @@ MCSymbol * TargetLoweringObjectFileELF::getCFIPersonalitySymbol(const GlobalValue *GV, - unsigned Encoding, Mangler *Mang, MachineModuleInfo *MMI) const { + unsigned Encoding = getPersonalityEncoding(); switch (Encoding & 0x70) { default: report_fatal_error("We do not support this DWARF encoding yet!"); @@ -849,7 +849,7 @@ } MCSymbol *TargetLoweringObjectFileMachO:: -getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, +getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI) const { // The mach-o version of this method defaults to returning a stub reference. MachineModuleInfoMachO &MachOMMI = Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed Apr 27 18:17:57 2011 @@ -121,7 +121,7 @@ } MCSymbol *TargetLoweringObjectFile:: -getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, +getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI) const { return Mang->getSymbol(GV); } Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Wed Apr 27 18:17:57 2011 @@ -39,7 +39,7 @@ } MCSymbol *X8664_MachoTargetObjectFile:: -getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, Mangler *Mang, +getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI) const { return Mang->getSymbol(GV); } Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=130343&r1=130342&r2=130343&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Wed Apr 27 18:17:57 2011 @@ -29,8 +29,8 @@ // getCFIPersonalitySymbol - The symbol that gets passed to // .cfi_personality. virtual MCSymbol * - getCFIPersonalitySymbol(const GlobalValue *GV, unsigned Encoding, - Mangler *Mang, MachineModuleInfo *MMI) const; + getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI) const; }; class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF { From johnny.chen at apple.com Wed Apr 27 18:29:21 2011 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 27 Apr 2011 23:29:21 -0000 Subject: [llvm-commits] [llvm] r130345 - in /llvm/trunk/test/MC/Disassembler/ARM: arm-tests.txt thumb-tests.txt Message-ID: <20110427232921.5D7862A6C12F@llvm.org> Author: johnny Date: Wed Apr 27 18:29:21 2011 New Revision: 130345 URL: http://llvm.org/viewvc/llvm-project?rev=130345&view=rev Log: Add tests for A8.6.110 NOP. Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=130345&r1=130344&r2=130345&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Wed Apr 27 18:29:21 2011 @@ -281,3 +281,6 @@ # CHECK: smmlareq r0, r0, r0, r0 0x30 0x00 0x50 0x07 + +# CHECK: nop +0x00 0xf0 0x20 0xe3 Modified: llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt?rev=130345&r1=130344&r2=130345&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/thumb-tests.txt Wed Apr 27 18:29:21 2011 @@ -256,3 +256,9 @@ # CHECK: mov pc, sp 0xef 0x46 + +# CHECK: nop +0x00 0xbf + +# CHECK: nop.w +0xaf 0xf3 0x00 0x80 From eli.friedman at gmail.com Wed Apr 27 18:58:53 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 27 Apr 2011 23:58:53 -0000 Subject: [llvm-commits] [llvm] r130348 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll Message-ID: <20110427235853.1F3462A6C12F@llvm.org> Author: efriedma Date: Wed Apr 27 18:58:52 2011 New Revision: 130348 URL: http://llvm.org/viewvc/llvm-project?rev=130348&view=rev Log: fast-isel sret. We actually don't need to do anything special on x86. :) rdar://problem/9303592 . Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130348&r1=130347&r2=130348&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Wed Apr 27 18:58:52 2011 @@ -1618,7 +1618,6 @@ // FIXME: Only handle *easy* calls for now. if (CS.paramHasAttr(AttrInd, Attribute::InReg) || - CS.paramHasAttr(AttrInd, Attribute::StructRet) || CS.paramHasAttr(AttrInd, Attribute::Nest) || CS.paramHasAttr(AttrInd, Attribute::ByVal)) return false; Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130348&r1=130347&r2=130348&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Wed Apr 27 18:58:52 2011 @@ -238,3 +238,16 @@ ; CHECK: test19: ; CHECK: pxor } + +; Check that we fast-isel sret +%struct.a = type { i64, i64, i64 } +define void @test20() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test20sret(%struct.a* sret %tmp) + ret void +; CHECK: test20: +; CHECK: leaq (%rsp), %rdi +; CHECK: callq _test20sret +} +declare void @test20sret(%struct.a* sret) From dpatel at apple.com Wed Apr 27 19:02:06 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 00:02:06 -0000 Subject: [llvm-commits] [debuginfo-tests] r130349 - /debuginfo-tests/trunk/sret.cpp Message-ID: <20110428000206.816B52A6C12F@llvm.org> Author: dpatel Date: Wed Apr 27 19:02:06 2011 New Revision: 130349 URL: http://llvm.org/viewvc/llvm-project?rev=130349&view=rev Log: Silence return-type warning. Modified: debuginfo-tests/trunk/sret.cpp Modified: debuginfo-tests/trunk/sret.cpp URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/sret.cpp?rev=130349&r1=130348&r2=130349&view=diff ============================================================================== --- debuginfo-tests/trunk/sret.cpp (original) +++ debuginfo-tests/trunk/sret.cpp Wed Apr 27 19:02:06 2011 @@ -2,7 +2,7 @@ // RUN: %clangxx %t.o -o %t.out // RUN: %test_debuginfo %s %t.out // Radar 8775834 -// DEBUGGER: break 60 +// DEBUGGER: break 61 // DEBUGGER: r // DEBUGGER: p a // CHECK: $1 = (A &) @@ -38,6 +38,7 @@ A::operator =(const A& rhs) { m_int = rhs.m_int; + return *this; } int A::get_int() From atrick at apple.com Wed Apr 27 19:13:59 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 28 Apr 2011 00:13:59 -0000 Subject: [llvm-commits] [llvm] r130350 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110428001359.4044D2A6C12F@llvm.org> Author: atrick Date: Wed Apr 27 19:13:59 2011 New Revision: 130350 URL: http://llvm.org/viewvc/llvm-project?rev=130350&view=rev Log: Reverting r130340 in the unlikely event that it's responsible for a llvm-gcc stage2 compiler error. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=130350&r1=130349&r2=130350&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Wed Apr 27 19:13:59 2011 @@ -275,7 +275,7 @@ // update the branch to use the new comparison; in the common case this // will make old comparison dead. BI->setCondition(Cond); - DeadInsts.push_back(OrigCond); + RecursivelyDeleteTriviallyDeadInstructions(OrigCond); ++NumLFTR; Changed = true; From justin.holewinski at gmail.com Wed Apr 27 19:19:51 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:51 -0000 Subject: [llvm-commits] [llvm] r130353 - in /llvm/trunk: lib/Target/PTX/PTXInstrInfo.td test/CodeGen/PTX/bitwise.ll Message-ID: <20110428001951.715252A6C131@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:51 2011 New Revision: 130353 URL: http://llvm.org/viewvc/llvm-project?rev=130353&view=rev Log: PTX: support for bitwise operations on predicates - selection of bitwise preds (AND, OR, XOR) - new bitwise.ll test Patch by Dan Bailey Added: llvm/trunk/test/CodeGen/PTX/bitwise.ll Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130353&r1=130352&r2=130353&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:51 2011 @@ -258,6 +258,14 @@ } multiclass PTX_LOGIC { + def ripreds : InstPTX<(outs Preds:$d), + (ins Preds:$a, i1imm:$b), + !strconcat(opcstr, ".pred\t$d, $a, $b"), + [(set Preds:$d, (opnode Preds:$a, imm:$b))]>; + def rrpreds : InstPTX<(outs Preds:$d), + (ins Preds:$a, Preds:$b), + !strconcat(opcstr, ".pred\t$d, $a, $b"), + [(set Preds:$d, (opnode Preds:$a, Preds:$b))]>; def rr16 : InstPTX<(outs RRegu16:$d), (ins RRegu16:$a, RRegu16:$b), !strconcat(opcstr, ".b16\t$d, $a, $b"), Added: llvm/trunk/test/CodeGen/PTX/bitwise.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PTX/bitwise.ll?rev=130353&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/PTX/bitwise.ll (added) +++ llvm/trunk/test/CodeGen/PTX/bitwise.ll Wed Apr 27 19:19:51 2011 @@ -0,0 +1,24 @@ +; RUN: llc < %s -march=ptx32 | FileCheck %s + +; preds + +define ptx_device i32 @t1_and_preds(i1 %x, i1 %y) { +; CHECK: and.pred p0, p1, p2 + %c = and i1 %x, %y + %d = zext i1 %c to i32 + ret i32 %d +} + +define ptx_device i32 @t1_or_preds(i1 %x, i1 %y) { +; CHECK: or.pred p0, p1, p2 + %a = or i1 %x, %y + %b = zext i1 %a to i32 + ret i32 %b +} + +define ptx_device i32 @t1_xor_preds(i1 %x, i1 %y) { +; CHECK: xor.pred p0, p1, p2 + %a = xor i1 %x, %y + %b = zext i1 %a to i32 + ret i32 %b +} From justin.holewinski at gmail.com Wed Apr 27 19:19:53 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:53 -0000 Subject: [llvm-commits] [llvm] r130355 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Message-ID: <20110428001953.940B52A6C133@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:53 2011 New Revision: 130355 URL: http://llvm.org/viewvc/llvm-project?rev=130355&view=rev Log: PTX: support for fneg - selection of FNEG instruction - new fneg.ll test Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130355&r1=130354&r2=130355&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:53 2011 @@ -182,6 +182,26 @@ // Instruction Class Templates //===----------------------------------------------------------------------===// +//===- Floating-Point Instructions - 2 Operand Form -----------------------===// +multiclass PTX_FLOAT_2OP { + def rr32 : InstPTX<(outs RRegf32:$d), + (ins RRegf32:$a), + !strconcat(opcstr, ".f32\t$d, $a"), + [(set RRegf32:$d, (opnode RRegf32:$a))]>; + def ri32 : InstPTX<(outs RRegf32:$d), + (ins f32imm:$a), + !strconcat(opcstr, ".f32\t$d, $a"), + [(set RRegf32:$d, (opnode fpimm:$a))]>; + def rr64 : InstPTX<(outs RRegf64:$d), + (ins RRegf64:$a), + !strconcat(opcstr, ".f64\t$d, $a"), + [(set RRegf64:$d, (opnode RRegf64:$a))]>; + def ri64 : InstPTX<(outs RRegf64:$d), + (ins f64imm:$a), + !strconcat(opcstr, ".f64\t$d, $a"), + [(set RRegf64:$d, (opnode fpimm:$a))]>; +} + //===- Floating-Point Instructions - 3 Operand Form -----------------------===// multiclass PTX_FLOAT_3OP { def rr32 : InstPTX<(outs RRegf32:$d), @@ -547,6 +567,9 @@ ///===- Floating-Point Arithmetic Instructions ----------------------------===// +// Standard Unary Operations +defm FNEG : PTX_FLOAT_2OP<"neg", fneg>; + // Standard Binary Operations defm FADD : PTX_FLOAT_3OP<"add", fadd>; defm FSUB : PTX_FLOAT_3OP<"sub", fsub>; From justin.holewinski at gmail.com Wed Apr 27 19:19:54 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:54 -0000 Subject: [llvm-commits] [llvm] r130356 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Message-ID: <20110428001954.B0DD02A6C134@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:54 2011 New Revision: 130356 URL: http://llvm.org/viewvc/llvm-project?rev=130356&view=rev Log: PTX: mov fix and rounding correction for cvt - fix typo in MOV - correct fp rounding on CVT - new cvt.ll test Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130356&r1=130355&r2=130356&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:54 2011 @@ -740,7 +740,7 @@ def MOVU32ri : InstPTX<(outs RRegu32:$d), (ins i32imm:$a), "mov.u32\t$d, $a", [(set RRegu32:$d, imm:$a)]>; - def MOVU164ri + def MOVU64ri : InstPTX<(outs RRegu64:$d), (ins i64imm:$a), "mov.u64\t$d, $a", [(set RRegu64:$d, imm:$a)]>; def MOVF32ri @@ -802,11 +802,11 @@ [(set Preds:$d, (trunc RRegu64:$a))]>; def CVT_pred_f32 - : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.pred.f32\t$d, $a", + : InstPTX<(outs Preds:$d), (ins RRegf32:$a), "cvt.rni.pred.f32\t$d, $a", [(set Preds:$d, (fp_to_uint RRegf32:$a))]>; def CVT_pred_f64 - : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.pred.f64\t$d, $a", + : InstPTX<(outs Preds:$d), (ins RRegf64:$a), "cvt.rni.pred.f64\t$d, $a", [(set Preds:$d, (fp_to_uint RRegf64:$a))]>; // Conversion to u16 @@ -824,11 +824,11 @@ [(set RRegu16:$d, (trunc RRegu64:$a))]>; def CVT_u16_f32 - : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.u16.f32\t$d, $a", + : InstPTX<(outs RRegu16:$d), (ins RRegf32:$a), "cvt.rni.u16.f32\t$d, $a", [(set RRegu16:$d, (fp_to_uint RRegf32:$a))]>; def CVT_u16_f64 - : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.u16.f64\t$d, $a", + : InstPTX<(outs RRegu16:$d), (ins RRegf64:$a), "cvt.rni.u16.f64\t$d, $a", [(set RRegu16:$d, (fp_to_uint RRegf64:$a))]>; // Conversion to u32 @@ -846,11 +846,11 @@ [(set RRegu32:$d, (trunc RRegu64:$a))]>; def CVT_u32_f32 - : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.u32.f32\t$d, $a", + : InstPTX<(outs RRegu32:$d), (ins RRegf32:$a), "cvt.rni.u32.f32\t$d, $a", [(set RRegu32:$d, (fp_to_uint RRegf32:$a))]>; def CVT_u32_f64 - : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.u32.f64\t$d, $a", + : InstPTX<(outs RRegu32:$d), (ins RRegf64:$a), "cvt.rni.u32.f64\t$d, $a", [(set RRegu32:$d, (fp_to_uint RRegf64:$a))]>; // Conversion to u64 @@ -868,51 +868,51 @@ [(set RRegu64:$d, (zext RRegu32:$a))]>; def CVT_u64_f32 - : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.u64.f32\t$d, $a", + : InstPTX<(outs RRegu64:$d), (ins RRegf32:$a), "cvt.rni.u64.f32\t$d, $a", [(set RRegu64:$d, (fp_to_uint RRegf32:$a))]>; def CVT_u64_f64 - : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.u64.f32\t$d, $a", + : InstPTX<(outs RRegu64:$d), (ins RRegf64:$a), "cvt.rni.u64.f64\t$d, $a", [(set RRegu64:$d, (fp_to_uint RRegf64:$a))]>; // Conversion to f32 def CVT_f32_pred - : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.f32.pred\t$d, $a", + : InstPTX<(outs RRegf32:$d), (ins Preds:$a), "cvt.rn.f32.pred\t$d, $a", [(set RRegf32:$d, (uint_to_fp Preds:$a))]>; def CVT_f32_u16 - : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.f32.u16\t$d, $a", + : InstPTX<(outs RRegf32:$d), (ins RRegu16:$a), "cvt.rn.f32.u16\t$d, $a", [(set RRegf32:$d, (uint_to_fp RRegu16:$a))]>; def CVT_f32_u32 - : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.f32.u32\t$d, $a", + : InstPTX<(outs RRegf32:$d), (ins RRegu32:$a), "cvt.rn.f32.u32\t$d, $a", [(set RRegf32:$d, (uint_to_fp RRegu32:$a))]>; def CVT_f32_u64 - : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.f32.u64\t$d, $a", + : InstPTX<(outs RRegf32:$d), (ins RRegu64:$a), "cvt.rn.f32.u64\t$d, $a", [(set RRegf32:$d, (uint_to_fp RRegu64:$a))]>; def CVT_f32_f64 - : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.f32.f64\t$d, $a", + : InstPTX<(outs RRegf32:$d), (ins RRegf64:$a), "cvt.rn.f32.f64\t$d, $a", [(set RRegf32:$d, (fround RRegf64:$a))]>; // Conversion to f64 def CVT_f64_pred - : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.f64.pred\t$d, $a", + : InstPTX<(outs RRegf64:$d), (ins Preds:$a), "cvt.rn.f64.pred\t$d, $a", [(set RRegf64:$d, (uint_to_fp Preds:$a))]>; def CVT_f64_u16 - : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.f64.u16\t$d, $a", + : InstPTX<(outs RRegf64:$d), (ins RRegu16:$a), "cvt.rn.f64.u16\t$d, $a", [(set RRegf64:$d, (uint_to_fp RRegu16:$a))]>; def CVT_f64_u32 - : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.f64.u32\t$d, $a", + : InstPTX<(outs RRegf64:$d), (ins RRegu32:$a), "cvt.rn.f64.u32\t$d, $a", [(set RRegf64:$d, (uint_to_fp RRegu32:$a))]>; def CVT_f64_u64 - : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.f64.u64\t$d, $a", + : InstPTX<(outs RRegf64:$d), (ins RRegu64:$a), "cvt.rn.f64.u64\t$d, $a", [(set RRegf64:$d, (uint_to_fp RRegu64:$a))]>; def CVT_f64_f32 From justin.holewinski at gmail.com Wed Apr 27 19:19:52 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:52 -0000 Subject: [llvm-commits] [llvm] r130354 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Message-ID: <20110428001952.7AA062A6C132@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:52 2011 New Revision: 130354 URL: http://llvm.org/viewvc/llvm-project?rev=130354&view=rev Log: PTX: support for zext loads and trunc stores - expansion of EXTLOAD and TRUNCSTORE instructions Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=130354&r1=130353&r2=130354&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Apr 27 19:19:52 2011 @@ -34,11 +34,23 @@ addRegisterClass(MVT::f32, PTX::RRegf32RegisterClass); addRegisterClass(MVT::f64, PTX::RRegf64RegisterClass); + setBooleanContents(ZeroOrOneBooleanContent); + setOperationAction(ISD::EXCEPTIONADDR, MVT::i32, Expand); setOperationAction(ISD::ConstantFP, MVT::f32, Legal); setOperationAction(ISD::ConstantFP, MVT::f64, Legal); - + + // Turn i16 (z)extload into load + (z)extend + setLoadExtAction(ISD::EXTLOAD, MVT::i16, Expand); + setLoadExtAction(ISD::ZEXTLOAD, MVT::i16, Expand); + + // Turn f32 extload into load + fextend + setLoadExtAction(ISD::EXTLOAD, MVT::f32, Expand); + + // Turn f64 truncstore into trunc + store. + setTruncStoreAction(MVT::f64, MVT::f32, Expand); + // Customize translation of memory addresses setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); setOperationAction(ISD::GlobalAddress, MVT::i64, Custom); From justin.holewinski at gmail.com Wed Apr 27 19:19:50 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:50 -0000 Subject: [llvm-commits] [llvm] r130352 - /llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Message-ID: <20110428001950.359E62A6C130@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:50 2011 New Revision: 130352 URL: http://llvm.org/viewvc/llvm-project?rev=130352&view=rev Log: PTX: patch to AsmPrinter - immediate value cast as long not int - handles initializer for constant array Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp?rev=130352&r1=130351&r2=130352&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXAsmPrinter.cpp Wed Apr 27 19:19:50 2011 @@ -226,7 +226,7 @@ OS << *Mang->getSymbol(MO.getGlobal()); break; case MachineOperand::MO_Immediate: - OS << (int) MO.getImm(); + OS << (long) MO.getImm(); break; case MachineOperand::MO_MachineBasicBlock: OS << *MO.getMBB()->getSymbol(); @@ -308,34 +308,59 @@ const PointerType* pointerTy = dyn_cast(gv->getType()); const Type* elementTy = pointerTy->getElementType(); - assert(elementTy->isArrayTy() && "Only pointers to arrays are supported"); - - const ArrayType* arrayTy = dyn_cast(elementTy); - elementTy = arrayTy->getElementType(); + decl += ".b8 "; + decl += gvsym->getName(); + decl += "["; + + if (elementTy->isArrayTy()) + { + assert(elementTy->isArrayTy() && "Only pointers to arrays are supported"); - unsigned numElements = arrayTy->getNumElements(); + const ArrayType* arrayTy = dyn_cast(elementTy); + elementTy = arrayTy->getElementType(); - while (elementTy->isArrayTy()) { + unsigned numElements = arrayTy->getNumElements(); + + while (elementTy->isArrayTy()) { - arrayTy = dyn_cast(elementTy); - elementTy = arrayTy->getElementType(); + arrayTy = dyn_cast(elementTy); + elementTy = arrayTy->getElementType(); - numElements *= arrayTy->getNumElements(); - } + numElements *= arrayTy->getNumElements(); + } - // FIXME: isPrimitiveType() == false for i16? - assert(elementTy->isSingleValueType() && - "Non-primitive types are not handled"); - - // Compute the size of the array, in bytes. - uint64_t arraySize = (elementTy->getPrimitiveSizeInBits() >> 3) - * numElements; + // FIXME: isPrimitiveType() == false for i16? + assert(elementTy->isSingleValueType() && + "Non-primitive types are not handled"); - decl += ".b8 "; - decl += gvsym->getName(); - decl += "["; - decl += utostr(arraySize); + // Compute the size of the array, in bytes. + uint64_t arraySize = (elementTy->getPrimitiveSizeInBits() >> 3) + * numElements; + + decl += utostr(arraySize); + } + decl += "]"; + + // handle string constants (assume ConstantArray means string) + + if (gv->hasInitializer()) + { + Constant *C = gv->getInitializer(); + if (const ConstantArray *CA = dyn_cast(C)) + { + decl += " = {"; + + for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) + { + if (i > 0) decl += ","; + + decl += "0x" + utohexstr(cast(CA->getOperand(i))->getZExtValue()); + } + + decl += "}"; + } + } } else { // Note: this is currently the fall-through case and most likely generates From justin.holewinski at gmail.com Wed Apr 27 19:19:56 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:56 -0000 Subject: [llvm-commits] [llvm] r130358 - in /llvm/trunk/lib/Target/PTX: PTXISelLowering.cpp PTXISelLowering.h Message-ID: <20110428001956.C82B12A6C136@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:56 2011 New Revision: 130358 URL: http://llvm.org/viewvc/llvm-project?rev=130358&view=rev Log: PTX: support for select_cc and fixes for setcc - expansion of SELECT_CC into SETCC - force SETCC result type to i1 - custom selection for handling i1 using SETCC Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp llvm/trunk/lib/Target/PTX/PTXISelLowering.h Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=130358&r1=130357&r2=130358&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Apr 27 19:19:56 2011 @@ -58,14 +58,28 @@ // Expand BR_CC into BRCOND setOperationAction(ISD::BR_CC, MVT::Other, Expand); + // Expand SELECT_CC into SETCC + setOperationAction(ISD::SELECT_CC, MVT::Other, Expand); + setOperationAction(ISD::SELECT_CC, MVT::f32, Expand); + setOperationAction(ISD::SELECT_CC, MVT::f64, Expand); + + // need to lower SETCC of Preds into bitwise logic + setOperationAction(ISD::SETCC, MVT::i1, Custom); + // Compute derived properties from the register classes computeRegisterProperties(); } +MVT::SimpleValueType PTXTargetLowering::getSetCCResultType(EVT VT) const { + return MVT::i1; +} + SDValue PTXTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { switch (Op.getOpcode()) { default: llvm_unreachable("Unimplemented operand"); + case ISD::SETCC: + return LowerSETCC(Op, DAG); case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG); } @@ -90,6 +104,28 @@ // Custom Lower Operation //===----------------------------------------------------------------------===// +SDValue PTXTargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const { + assert(Op.getValueType() == MVT::i1 && "SetCC type must be 1-bit integer"); + SDValue Op0 = Op.getOperand(0); + SDValue Op1 = Op.getOperand(1); + SDValue Op2 = Op.getOperand(2); + DebugLoc dl = Op.getDebugLoc(); + ISD::CondCode CC = cast(Op.getOperand(2))->get(); + + // Look for X == 0, X == 1, X != 0, or X != 1 + // We can simplify these to bitwise logic + + if (Op1.getOpcode() == ISD::Constant && + (cast(Op1)->getZExtValue() == 1 || + cast(Op1)->isNullValue()) && + (CC == ISD::SETEQ || CC == ISD::SETNE)) { + + return DAG.getNode(ISD::AND, dl, MVT::i1, Op0, Op1); + } + + return DAG.getNode(ISD::SETCC, dl, MVT::i1, Op0, Op1, Op2); +} + SDValue PTXTargetLowering:: LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const { EVT PtrVT = getPointerTy(); Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.h?rev=130358&r1=130357&r2=130358&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.h (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.h Wed Apr 27 19:19:56 2011 @@ -42,6 +42,8 @@ virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; + virtual SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const; + virtual SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, @@ -59,7 +61,9 @@ const SmallVectorImpl &OutVals, DebugLoc dl, SelectionDAG &DAG) const; - + + virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const; + private: SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; }; // class PTXTargetLowering From justin.holewinski at gmail.com Wed Apr 27 19:19:55 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Thu, 28 Apr 2011 00:19:55 -0000 Subject: [llvm-commits] [llvm] r130357 - /llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Message-ID: <20110428001955.C45112A6C135@llvm.org> Author: jholewinski Date: Wed Apr 27 19:19:55 2011 New Revision: 130357 URL: http://llvm.org/viewvc/llvm-project?rev=130357&view=rev Log: PTX: support for select - selection of SELP instruction - new selp.ll test Patch by Dan Bailey Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Modified: llvm/trunk/lib/Target/PTX/PTXInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXInstrInfo.td?rev=130357&r1=130356&r2=130357&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXInstrInfo.td (original) +++ llvm/trunk/lib/Target/PTX/PTXInstrInfo.td Wed Apr 27 19:19:55 2011 @@ -483,6 +483,13 @@ [(set Preds:$p, (xor (setcc RC:$a, RC:$b, ocmp), (not Preds:$c)))]>; } +multiclass PTX_SELP { + def rr + : InstPTX<(outs RC:$r), (ins Preds:$a, RC:$b, RC:$c), + !strconcat("selp.", regclsname, "\t$r, $b, $c, $a"), + [(set RC:$r, (select Preds:$a, RC:$b, RC:$c))]>; +} + multiclass PTX_LD { def rr32 : InstPTX<(outs RC:$d), (ins MEMri32:$a), @@ -703,6 +710,14 @@ defm SETPGTf64 : PTX_SETP_FP; defm SETPGEf64 : PTX_SETP_FP; +// .selp + +defm PTX_SELPu16 : PTX_SELP; +defm PTX_SELPu32 : PTX_SELP; +defm PTX_SELPu64 : PTX_SELP; +defm PTX_SELPf32 : PTX_SELP; +defm PTX_SELPf64 : PTX_SELP; + ///===- Logic and Shift Instructions --------------------------------------===// defm SHL : INT3ntnc<"shl.b", PTXshl>; From eli.friedman at gmail.com Wed Apr 27 19:42:03 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 00:42:03 -0000 Subject: [llvm-commits] [llvm] r130360 - in /llvm/trunk: lib/CodeGen/SelectionDAG/FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll Message-ID: <20110428004203.B9A942A6C130@llvm.org> Author: efriedma Date: Wed Apr 27 19:42:03 2011 New Revision: 130360 URL: http://llvm.org/viewvc/llvm-project?rev=130360&view=rev Log: Fix a silly mistake in r130338. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130360&r1=130359&r2=130360&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Wed Apr 27 19:42:03 2011 @@ -164,7 +164,7 @@ Reg = getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext()))); } else if (const ConstantFP *CF = dyn_cast(V)) { - if (CF->isZero()) { + if (CF->isNullValue()) { Reg = TargetMaterializeFloatZero(CF); } else { // Try to emit the constant directly. Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130360&r1=130359&r2=130360&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Wed Apr 27 19:42:03 2011 @@ -251,3 +251,12 @@ ; CHECK: callq _test20sret } declare void @test20sret(%struct.a* sret) + +; Check that -0.0 is not materialized using pxor +define void @test21(double* %p1) { + store double -0.0, double* %p1 + ret void +; CHECK: test21: +; CHECK-NOT: pxor +; CHECK: movsd LCPI +} From daniel at zuster.org Wed Apr 27 19:55:17 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 28 Apr 2011 00:55:17 -0000 Subject: [llvm-commits] [zorg] r130361 - /zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Message-ID: <20110428005517.875462A6C130@llvm.org> Author: ddunbar Date: Wed Apr 27 19:55:17 2011 New Revision: 130361 URL: http://llvm.org/viewvc/llvm-project?rev=130361&view=rev Log: LNT/Flask: Fix a misplaced endfor, which only shows up with suites which have multiple parameter sets. Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Modified: zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html?rev=130361&r1=130360&r2=130361&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html (original) +++ zorg/trunk/lnt/lnt/server/ui/templates/simple_run.html Wed Apr 27 19:55:17 2011 @@ -168,7 +168,6 @@ {% for key in ts_summary.parameter_sets %}

    -{% endfor %} {% if options.show_delta %} @@ -185,6 +184,7 @@ {% if options.show_sample_counts %} {% endif %} +{% endfor %} From daniel at zuster.org Wed Apr 27 19:55:20 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 28 Apr 2011 00:55:20 -0000 Subject: [llvm-commits] [zorg] r130362 - /zorg/trunk/lnt/lnt/server/ui/views.py Message-ID: <20110428005520.70B542A6C131@llvm.org> Author: ddunbar Date: Wed Apr 27 19:55:20 2011 New Revision: 130362 URL: http://llvm.org/viewvc/llvm-project?rev=130362&view=rev Log: LNT/Flask: Accept trailing slash on run views, for compatibility. Modified: zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130362&r1=130361&r2=130362&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Apr 27 19:55:20 2011 @@ -246,6 +246,7 @@ return response @db_route("/simple//") + at db_route("/simple///") def simple_run(tag, id): db, run, run_summary, compare_to = get_simple_run_info(tag, id) From daniel at zuster.org Wed Apr 27 19:55:22 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 28 Apr 2011 00:55:22 -0000 Subject: [llvm-commits] [zorg] r130363 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20110428005522.E70382A6C132@llvm.org> Author: ddunbar Date: Wed Apr 27 19:55:22 2011 New Revision: 130363 URL: http://llvm.org/viewvc/llvm-project?rev=130363&view=rev Log: LNT: Fix a variable scoping issue which generated weird reports when used with multiple parameter sets. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=130363&r1=130362&r2=130363&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Wed Apr 27 19:55:22 2011 @@ -307,8 +307,8 @@ print >>html_report, """

    Changes Detail

    """ - for name,items,show_perf in items_info: - if not items or name == 'Unchanged Tests': + for test_name,items,show_perf in items_info: + if not items or test_name == 'Unchanged Tests': continue show_pset = items.items()[0][0] or len(items) > 1 @@ -316,8 +316,8 @@ (pset, 'pset.%d' % i) for i,pset in enumerate(ts_summary.parameter_sets)) print >>report - print >>report, name - print >>report, '-' * len(name) + print >>report, test_name + print >>report, '-' * len(test_name) for pset,tests in items.items(): if show_perf: tests.sort(key = lambda (_,cr): -abs(cr.pct_delta)) @@ -332,7 +332,6 @@ (get_last_component(t), t) for t in tests) - test_name = name for group,grouped_tests in Util.sorted(grouped.items()): group_name = { "" : "(ungrouped)", From sabre at nondot.org Wed Apr 27 19:55:53 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 00:55:53 -0000 Subject: [llvm-commits] [llvm] r130364 - /llvm/trunk/include/llvm/ADT/DenseMap.h Message-ID: <20110428005553.511922A6C130@llvm.org> Author: lattner Date: Wed Apr 27 19:55:53 2011 New Revision: 130364 URL: http://llvm.org/viewvc/llvm-project?rev=130364&view=rev Log: silence some -Wnon-pod-memset warnings, since std::pair is not POD. Modified: llvm/trunk/include/llvm/ADT/DenseMap.h Modified: llvm/trunk/include/llvm/ADT/DenseMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=130364&r1=130363&r2=130364&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMap.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMap.h Wed Apr 27 19:55:53 2011 @@ -73,7 +73,7 @@ } #ifndef NDEBUG if (NumBuckets) - memset(Buckets, 0x5a, sizeof(BucketT)*NumBuckets); + memset((void*)Buckets, 0x5a, sizeof(BucketT)*NumBuckets); #endif operator delete(Buckets); } @@ -426,7 +426,7 @@ #ifndef NDEBUG if (OldNumBuckets) - memset(OldBuckets, 0x5a, sizeof(BucketT)*OldNumBuckets); + memset((void*)OldBuckets, 0x5a, sizeof(BucketT)*OldNumBuckets); #endif // Free the old table. operator delete(OldBuckets); From clattner at apple.com Wed Apr 27 20:16:36 2011 From: clattner at apple.com (Chris Lattner) Date: Wed, 27 Apr 2011 18:16:36 -0700 Subject: [llvm-commits] [PATCH] review request - bounded case-insensitive StringRef compare In-Reply-To: <4DB74569.2060305@colorado.edu> References: <4DB74569.2060305@colorado.edu> Message-ID: <540D8AD0-93C2-45DF-BE89-38828BCFEF1B@apple.com> On Apr 26, 2011, at 3:21 PM, Lenny Maiorani wrote: > This patch adds bounded case-insensitive compare to StringRef class, imitating strncasecmp(). Includes unit tests. I'm still dubious about the 'n' functions being in StringRef, I don't understand why clients can't substr() the string before calling non-'n' versions. -Chris From dpatel at apple.com Wed Apr 27 21:22:40 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 02:22:40 -0000 Subject: [llvm-commits] [llvm] r130373 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMAsmPrinter.h test/CodeGen/ARM/2010-08-04-StackVariable.ll test/CodeGen/X86/2010-08-04-StackVariable.ll Message-ID: <20110428022240.51C8E2A6C135@llvm.org> Author: dpatel Date: Wed Apr 27 21:22:40 2011 New Revision: 130373 URL: http://llvm.org/viewvc/llvm-project?rev=130373&view=rev Log: Teach dwarf writer to handle complex address expression for .debug_loc entries. This fixes clang generated blocks' variables' debug info. Radar 9279956. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Wed Apr 27 21:22:40 2011 @@ -379,6 +379,10 @@ /// operands. virtual MachineLocation getDebugValueLocation(const MachineInstr *MI) const; + /// getDwarfRegOpSize - get size required to emit given machine location + /// using dwarf encoding. + virtual unsigned getDwarfRegOpSize(const MachineLocation &MLoc) const; + /// getISAEncoding - Get the value for DW_AT_APPLE_isa. Zero if no isa /// encoding specified. virtual unsigned getISAEncoding() { return 0; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Apr 27 21:22:40 2011 @@ -749,33 +749,49 @@ return MachineLocation(); } +/// getDwarfRegOpSize - get size required to emit given machine location using +/// dwarf encoding. +unsigned AsmPrinter::getDwarfRegOpSize(const MachineLocation &MLoc) const { + const TargetRegisterInfo *RI = TM.getRegisterInfo(); + unsigned DWReg = RI->getDwarfRegNum(MLoc.getReg(), false); + if (int Offset = MLoc.getOffset()) { + // If the value is at a certain offset from frame register then + // use DW_OP_breg. + if (DWReg < 32) + return 1 + MCAsmInfo::getSLEB128Size(Offset); + else + return 1 + MCAsmInfo::getULEB128Size(MLoc.getReg()) + + MCAsmInfo::getSLEB128Size(Offset); + } + if (DWReg < 32) + return 1; + + return 1 + MCAsmInfo::getULEB128Size(DWReg); +} + /// EmitDwarfRegOp - Emit dwarf register operation. void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { - const TargetRegisterInfo *RI = TM.getRegisterInfo(); - unsigned Reg = RI->getDwarfRegNum(MLoc.getReg(), false); + const TargetRegisterInfo *TRI = TM.getRegisterInfo(); + unsigned Reg = TRI->getDwarfRegNum(MLoc.getReg(), false); if (int Offset = MLoc.getOffset()) { - // If the value is at a certain offset from frame register then - // use DW_OP_fbreg. - unsigned OffsetSize = Offset ? MCAsmInfo::getSLEB128Size(Offset) : 1; - OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + OffsetSize); - OutStreamer.AddComment( - dwarf::OperationEncodingString(dwarf::DW_OP_fbreg)); - EmitInt8(dwarf::DW_OP_fbreg); - OutStreamer.AddComment("Offset"); + if (Reg < 32) { + OutStreamer.AddComment( + dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg)); + EmitInt8(dwarf::DW_OP_breg0 + Reg); + } else { + OutStreamer.AddComment("DW_OP_bregx"); + EmitInt8(dwarf::DW_OP_bregx); + OutStreamer.AddComment(Twine(Reg)); + EmitULEB128(Reg); + } EmitSLEB128(Offset); } else { if (Reg < 32) { - OutStreamer.AddComment("Loc expr size"); - EmitInt16(1); OutStreamer.AddComment( dwarf::OperationEncodingString(dwarf::DW_OP_reg0 + Reg)); EmitInt8(dwarf::DW_OP_reg0 + Reg); } else { - OutStreamer.AddComment("Loc expr size"); - EmitInt16(1 + MCAsmInfo::getULEB128Size(Reg)); - OutStreamer.AddComment( - dwarf::OperationEncodingString(dwarf::DW_OP_regx)); + OutStreamer.AddComment("DW_OP_regx"); EmitInt8(dwarf::DW_OP_regx); OutStreamer.AddComment(Twine(Reg)); EmitULEB128(Reg); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Apr 27 21:22:40 2011 @@ -258,15 +258,22 @@ unsigned Attribute, const MachineLocation &Location) { DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - - if (Location.isReg()) - addRegisterOp(Block, Location.getReg()); + unsigned N = DV->getNumAddrElements(); + unsigned i = 0; + if (Location.isReg()) { + if (N >= 2 && DV->getAddrElement(0) == DIBuilder::OpPlus) { + // If first address element is OpPlus then emit + // DW_OP_breg + Offset instead of DW_OP_reg + Offset. + addRegisterOffset(Block, Location.getReg(), DV->getAddrElement(1)); + i = 2; + } else + addRegisterOp(Block, Location.getReg()); + } else addRegisterOffset(Block, Location.getReg(), Location.getOffset()); - for (unsigned i = 0, N = DV->getNumAddrElements(); i < N; ++i) { + for (;i < N; ++i) { uint64_t Element = DV->getAddrElement(i); - if (Element == DIBuilder::OpPlus) { addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); addUInt(Block, 0, dwarf::DW_FORM_udata, DV->getAddrElement(++i)); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Apr 27 21:22:40 2011 @@ -1466,7 +1466,7 @@ } // The value is valid until the next DBG_VALUE or clobber. - DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc)); + DotDebugLocEntries.push_back(DotDebugLocEntry(FLabel, SLabel, MLoc, Var)); } DotDebugLocEntries.push_back(DotDebugLocEntry()); } @@ -2721,7 +2721,39 @@ } else { Asm->OutStreamer.EmitSymbolValue(Entry.Begin, Size, 0); Asm->OutStreamer.EmitSymbolValue(Entry.End, Size, 0); - Asm->EmitDwarfRegOp(Entry.Loc); + DIVariable DV(Entry.Variable); + if (DV.hasComplexAddress()) { + unsigned N = DV.getNumAddrElements(); + unsigned i = 0; + Asm->OutStreamer.AddComment("Loc expr size"); + if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) { + // If first address element is OpPlus then emit + // DW_OP_breg + Offset instead of DW_OP_reg + Offset. + MachineLocation Loc(Entry.Loc.getReg(), DV.getAddrElement(1)); + Asm->EmitInt16(Asm->getDwarfRegOpSize(Loc) + N - 2); + Asm->EmitDwarfRegOp(Loc); +// Asm->EmitULEB128(DV.getAddrElement(1)); + i = 2; + } else { + Asm->EmitInt16(Asm->getDwarfRegOpSize(Entry.Loc) + N); + Asm->EmitDwarfRegOp(Entry.Loc); + } + + // Emit remaining complex address elements. + for (; i < N; ++i) { + uint64_t Element = DV.getAddrElement(i); + if (Element == DIBuilder::OpPlus) { + Asm->EmitInt8(dwarf::DW_OP_plus_uconst); + Asm->EmitULEB128(DV.getAddrElement(++i)); + } else if (Element == DIBuilder::OpDeref) + Asm->EmitInt8(dwarf::DW_OP_deref); + else llvm_unreachable("unknown Opcode found in complex address"); + } + } else { + Asm->OutStreamer.AddComment("Loc expr size"); + Asm->EmitInt16(Asm->getDwarfRegOpSize(Entry.Loc)); + Asm->EmitDwarfRegOp(Entry.Loc); + } } } } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Apr 27 21:22:40 2011 @@ -66,10 +66,12 @@ const MCSymbol *Begin; const MCSymbol *End; MachineLocation Loc; + const MDNode *Variable; bool Merged; - DotDebugLocEntry() : Begin(0), End(0), Merged(false) {} - DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L) - : Begin(B), End(E), Loc(L), Merged(false) {} + DotDebugLocEntry() : Begin(0), End(0), Variable(0), Merged(false) {} + DotDebugLocEntry(const MCSymbol *B, const MCSymbol *E, MachineLocation &L, + const MDNode *V) + : Begin(B), End(E), Loc(L), Variable(V), Merged(false) {} /// Empty entries are also used as a trigger to emit temp label. Such /// labels are referenced is used to find debug_loc offset for a given DIE. bool isEmpty() { return Begin == 0 && End == 0; } Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed Apr 27 21:22:40 2011 @@ -172,6 +172,47 @@ return Location; } +/// getDwarfRegOpSize - get size required to emit given machine location using +/// dwarf encoding. +unsigned ARMAsmPrinter::getDwarfRegOpSize(const MachineLocation &MLoc) const { + const TargetRegisterInfo *RI = TM.getRegisterInfo(); + if (RI->getDwarfRegNum(MLoc.getReg(), false) != -1) + return AsmPrinter::getDwarfRegOpSize(MLoc); + else { + unsigned Reg = MLoc.getReg(); + if (Reg >= ARM::S0 && Reg <= ARM::S31) { + assert(ARM::S0 + 31 == ARM::S31 && "Unexpected ARM S register numbering"); + // S registers are described as bit-pieces of a register + // S[2x] = DW_OP_regx(256 + (x>>1)) DW_OP_bit_piece(32, 0) + // S[2x+1] = DW_OP_regx(256 + (x>>1)) DW_OP_bit_piece(32, 32) + + unsigned SReg = Reg - ARM::S0; + unsigned Rx = 256 + (SReg >> 1); + OutStreamer.AddComment("Loc expr size"); + // DW_OP_regx + ULEB + DW_OP_bit_piece + ULEB + ULEB + // 1 + ULEB(Rx) + 1 + 1 + 1 + return 4 + MCAsmInfo::getULEB128Size(Rx); + } + + if (Reg >= ARM::Q0 && Reg <= ARM::Q15) { + assert(ARM::Q0 + 15 == ARM::Q15 && "Unexpected ARM Q register numbering"); + // Q registers Q0-Q15 are described by composing two D registers together. + // Qx = DW_OP_regx(256+2x) DW_OP_piece(8) DW_OP_regx(256+2x+1) DW_OP_piece(8) + + unsigned QReg = Reg - ARM::Q0; + unsigned D1 = 256 + 2 * QReg; + unsigned D2 = D1 + 1; + + OutStreamer.AddComment("Loc expr size"); + // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8) + + // DW_OP_regx + ULEB + DW_OP_piece + ULEB(8); + // 6 + ULEB(D1) + ULEB(D2) + return 6 + MCAsmInfo::getULEB128Size(D1) + MCAsmInfo::getULEB128Size(D2); + } + } + return 0; +} + /// EmitDwarfRegOp - Emit dwarf register operation. void ARMAsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const { const TargetRegisterInfo *RI = TM.getRegisterInfo(); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.h Wed Apr 27 21:22:40 2011 @@ -89,6 +89,10 @@ MachineLocation getDebugValueLocation(const MachineInstr *MI) const; + /// getDwarfRegOpSize - get size required to emit given machine location + /// using dwarf encoding. + virtual unsigned getDwarfRegOpSize(const MachineLocation &MLoc) const; + /// EmitDwarfRegOp - Emit dwarf register operation. virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; Modified: llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2010-08-04-StackVariable.ll Wed Apr 27 21:22:40 2011 @@ -1,5 +1,5 @@ -; RUN: llc -O0 -mtriple=arm-apple-darwin < %s | grep DW_OP_fbreg -; Use DW_OP_fbreg in variable's location expression if the variable is in a stack slot. +; RUN: llc -O0 -mtriple=arm-apple-darwin < %s | grep DW_OP_breg +; Use DW_OP_breg in variable's location expression if the variable is in a stack slot. %struct.SVal = type { i8*, i32 } Modified: llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll?rev=130373&r1=130372&r2=130373&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-08-04-StackVariable.ll Wed Apr 27 21:22:40 2011 @@ -1,5 +1,5 @@ -; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s | grep DW_OP_fbreg -; Use DW_OP_fbreg in variable's location expression if the variable is in a stack slot. +; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s | grep DW_OP_breg7 +; Use DW_OP_breg7 in variable's location expression if the variable is in a stack slot. %struct.SVal = type { i8*, i32 } From dpatel at apple.com Wed Apr 27 21:23:17 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 02:23:17 -0000 Subject: [llvm-commits] [debuginfo-tests] r130374 - /debuginfo-tests/trunk/blocks.m Message-ID: <20110428022317.6457F2A6C135@llvm.org> Author: dpatel Date: Wed Apr 27 21:23:17 2011 New Revision: 130374 URL: http://llvm.org/viewvc/llvm-project?rev=130374&view=rev Log: Test case for r130373. Added: debuginfo-tests/trunk/blocks.m Added: debuginfo-tests/trunk/blocks.m URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/blocks.m?rev=130374&view=auto ============================================================================== --- debuginfo-tests/trunk/blocks.m (added) +++ debuginfo-tests/trunk/blocks.m Wed Apr 27 21:23:17 2011 @@ -0,0 +1,40 @@ +// RUN: %clang -O0 -g %s -c -o %t.o +// RUN: %clang %t.o -o %t.out -framework Foundation +// RUN: %test_debuginfo %s %t.out +// Radar 9279956 +// DEBUGGER: break 28 +// DEBUGGER: r +// DEBUGGER: p m2 +// DEBUGGER: p dbTransaction +// DEBUGGER: p master +// CHECK: $1 = 1 +// CHECK: $2 = 0 +// CHECK: $3 = 0 + +#include + +extern void foo(void(^)(void)); + + at interface A:NSObject @end + at implementation A +- (void) helper { + int master = 0; + __block int m2 = 0; + __block int dbTransaction = 0; + int (^x)(void) = ^(void) { (void) self; + (void) master; + (void) dbTransaction; + m2++; + return m2; + }; + master = x(); +} + at end + +void foo(void(^x)(void)) {} + +int main() { + A *a = [A alloc]; + [a helper]; + return 0; +} From rafael.espindola at gmail.com Wed Apr 27 21:46:42 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 02:46:42 -0000 Subject: [llvm-commits] [llvm] r130375 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/MC/MCDwarf.cpp Message-ID: <20110428024642.C47FF2A6C135@llvm.org> Author: rafael Date: Wed Apr 27 21:46:42 2011 New Revision: 130375 URL: http://llvm.org/viewvc/llvm-project?rev=130375&view=rev Log: Forward isFunctionEHFrameSymbolPrivate. If it is false, produce the foo.eh symbols. Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=130375&r1=130374&r2=130375&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Wed Apr 27 21:46:42 2011 @@ -62,6 +62,10 @@ return TLOF->getFDEEncoding(); } + bool isFunctionEHFrameSymbolPrivate() const { + return TLOF->isFunctionEHFrameSymbolPrivate(); + } + unsigned getDwarfRARegNum(bool isEH) const { return TRI->getDwarfRegNum(TRI->getRARegister(), isEH); } Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130375&r1=130374&r2=130375&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Apr 27 21:46:42 2011 @@ -17,6 +17,7 @@ #include "llvm/MC/MCContext.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -713,6 +714,12 @@ MCSymbol *fdeEnd = context.CreateTempSymbol(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); + if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { + Twine EHName = frame.Function->getName() + Twine(".eh"); + MCSymbol *EHSym = context.GetOrCreateSymbol(EHName); + streamer.EmitLabel(EHSym); + } + // Length const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0); streamer.EmitAbsValue(Length, 4); From rafael.espindola at gmail.com Wed Apr 27 22:26:11 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 03:26:11 -0000 Subject: [llvm-commits] [llvm] r130378 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110428032611.6DB2C2A6C135@llvm.org> Author: rafael Date: Wed Apr 27 22:26:11 2011 New Revision: 130378 URL: http://llvm.org/viewvc/llvm-project?rev=130378&view=rev Log: Produce the EH_frame# symbols if needed. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130378&r1=130377&r2=130378&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Apr 27 22:26:11 2011 @@ -494,9 +494,10 @@ namespace { class FrameEmitterImpl { int CFAOffset; + int CIENum; public: - FrameEmitterImpl() : CFAOffset(0) { + FrameEmitterImpl() : CFAOffset(0), CIENum(0) { } const MCSymbol &EmitCIE(MCStreamer &streamer, @@ -623,7 +624,15 @@ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); const MCSection §ion = *asmInfo.getEHFrameSection(); streamer.SwitchSection(§ion); - MCSymbol *sectionStart = context.CreateTempSymbol(); + + MCSymbol *sectionStart; + if (asmInfo.isFunctionEHFrameSymbolPrivate()) + sectionStart = context.CreateTempSymbol(); + else + sectionStart = context.GetOrCreateSymbol(Twine("EH_frame") + Twine(CIENum)); + + CIENum++; + MCSymbol *sectionEnd = streamer.getContext().CreateTempSymbol(); // Length From rafael.espindola at gmail.com Wed Apr 27 23:04:14 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 04:04:14 -0000 Subject: [llvm-commits] [llvm] r130379 - in /llvm/trunk: include/llvm/MC/MCDwarf.h lib/MC/MCAssembler.cpp lib/MC/MCDwarf.cpp Message-ID: <20110428040414.601552A6C135@llvm.org> Author: rafael Date: Wed Apr 27 23:04:14 2011 New Revision: 130379 URL: http://llvm.org/viewvc/llvm-project?rev=130379&view=rev Log: Add a small temporary hack for producing identical eh_frame sections on OS X. This removes one of the main advantages of moving eh_frame to MC, but makes the transition a lot easier to debug (run md5). Modified: llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/lib/MC/MCAssembler.cpp llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=130379&r1=130378&r2=130379&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Wed Apr 27 23:04:14 2011 @@ -23,6 +23,7 @@ #include namespace llvm { + class TargetAsmInfo; class MachineMove; class MCContext; class MCExpr; @@ -282,7 +283,8 @@ // static void Emit(MCStreamer &streamer); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); - static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS); + static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS, + const TargetAsmInfo &AsmInfo); }; } // end namespace llvm Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=130379&r1=130378&r2=130379&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Wed Apr 27 23:04:14 2011 @@ -732,7 +732,8 @@ SmallString<8> &Data = DF.getContents(); Data.clear(); raw_svector_ostream OSE(Data); - MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OSE); + const TargetAsmInfo &AsmInfo = getContext().getTargetAsmInfo(); + MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OSE, AsmInfo); OSE.flush(); return OldSize != Data.size(); } Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130379&r1=130378&r2=130379&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Apr 27 23:04:14 2011 @@ -843,21 +843,28 @@ uint64_t AddrDelta) { SmallString<256> Tmp; raw_svector_ostream OS(Tmp); - MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OS); + const TargetAsmInfo &AsmInfo = Streamer.getContext().getTargetAsmInfo(); + MCDwarfFrameEmitter::EncodeAdvanceLoc(AddrDelta, OS, AsmInfo); Streamer.EmitBytes(OS.str(), /*AddrSpace=*/0); } void MCDwarfFrameEmitter::EncodeAdvanceLoc(uint64_t AddrDelta, - raw_ostream &OS) { + raw_ostream &OS, + const TargetAsmInfo &AsmInfo) { + // This is a small hack to facilitate the transition to CFI on OS X. It + // relaxes all address advances which lets us produces identical output + // to the one produce by CodeGen. + const bool Relax = !AsmInfo.isFunctionEHFrameSymbolPrivate(); + // FIXME: Assumes the code alignment factor is 1. if (AddrDelta == 0) { - } else if (isUIntN(6, AddrDelta)) { + } else if (isUIntN(6, AddrDelta) && !Relax) { uint8_t Opcode = dwarf::DW_CFA_advance_loc | AddrDelta; OS << Opcode; - } else if (isUInt<8>(AddrDelta)) { + } else if (isUInt<8>(AddrDelta) && !Relax) { OS << uint8_t(dwarf::DW_CFA_advance_loc1); OS << uint8_t(AddrDelta); - } else if (isUInt<16>(AddrDelta)) { + } else if (isUInt<16>(AddrDelta) && !Relax) { // FIXME: check what is the correct behavior on a big endian machine. OS << uint8_t(dwarf::DW_CFA_advance_loc2); OS << uint8_t( AddrDelta & 0xff); From kremenek at apple.com Wed Apr 27 23:52:57 2011 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 28 Apr 2011 04:52:57 -0000 Subject: [llvm-commits] [llvm] r130382 - /llvm/trunk/include/llvm/ADT/DenseMap.h Message-ID: <20110428045258.06B912A6C135@llvm.org> Author: kremenek Date: Wed Apr 27 23:52:57 2011 New Revision: 130382 URL: http://llvm.org/viewvc/llvm-project?rev=130382&view=rev Log: Add utility method to DenseMap to return the amount of memory used for its buckets. Modified: llvm/trunk/include/llvm/ADT/DenseMap.h Modified: llvm/trunk/include/llvm/ADT/DenseMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=130382&r1=130381&r2=130382&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMap.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMap.h Wed Apr 27 23:52:57 2011 @@ -466,6 +466,15 @@ NumEntries = 0; } + +public: + /// Return the approximate size (in bytes) of the actual map. + /// This is just the raw memory used by DenseMap. + /// If entries are pointers to objects, the size of the referenced objects + /// are not included. + size_t getMemorySize() const { + return NumBuckets * sizeof(BucketT); + } }; template Author: lattner Date: Thu Apr 28 00:33:16 2011 New Revision: 130385 URL: http://llvm.org/viewvc/llvm-project?rev=130385&view=rev Log: move PR9803 to this readme. Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=130385&r1=130384&r2=130385&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Thu Apr 28 00:33:16 2011 @@ -2032,3 +2032,31 @@ with -ffast-math. //===---------------------------------------------------------------------===// + +This function (from PR9803): + +int clamp2(int a) { + if (a > 5) + a = 5; + if (a < 0) + return 0; + return a; +} + +Compiles to: + +_clamp2: ## @clamp2 + pushq %rbp + movq %rsp, %rbp + cmpl $5, %edi + movl $5, %ecx + cmovlel %edi, %ecx + testl %ecx, %ecx + movl $0, %eax + cmovnsl %ecx, %eax + popq %rbp + ret + +The move of 0 could be scheduled above the test to make it is xor reg,reg. + +//===---------------------------------------------------------------------===// From echristo at apple.com Thu Apr 28 00:49:05 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 28 Apr 2011 05:49:05 -0000 Subject: [llvm-commits] [llvm] r130386 - in /llvm/trunk: include/llvm/Target/TargetSelectionDAG.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/ARMInstrThumb2.td Message-ID: <20110428054905.232582A6C135@llvm.org> Author: echristo Date: Thu Apr 28 00:49:04 2011 New Revision: 130386 URL: http://llvm.org/viewvc/llvm-project?rev=130386&view=rev Log: Let the immediate leaf pattern take transforms and switch the signed immediate patterns in arm to using the pattern. Handles rdar://9299434 Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/include/llvm/Target/TargetSelectionDAG.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelectionDAG.td?rev=130386&r1=130385&r2=130386&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetSelectionDAG.td (original) +++ llvm/trunk/include/llvm/Target/TargetSelectionDAG.td Thu Apr 28 00:49:04 2011 @@ -543,8 +543,8 @@ // If FastIsel should ignore all instructions that have an operand of this type, // the FastIselShouldIgnore flag can be set. This is an optimization to reduce // the code size of the generated fast instruction selector. -class ImmLeaf - : PatFrag<(ops), (vt imm)> { +class ImmLeaf + : PatFrag<(ops), (vt imm), [{}], xform> { let ImmediateCode = pred; bit FastIselShouldIgnore = 0; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130386&r1=130385&r2=130386&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Apr 28 00:49:04 2011 @@ -203,13 +203,13 @@ }]>; /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15]. -def imm1_15 : PatLeaf<(i32 imm), [{ - return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16; +def imm1_15 : ImmLeaf= 1 && (int32_t)Imm < 16; }]>; /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31]. -def imm16_31 : PatLeaf<(i32 imm), [{ - return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32; +def imm16_31 : ImmLeaf= 16 && (int32_t)Imm < 32; }]>; def so_imm_neg : @@ -239,8 +239,8 @@ /// imm0_65535 predicate - True if the 32-bit immediate is in the range /// [0.65535]. -def imm0_65535 : PatLeaf<(i32 imm), [{ - return (uint32_t)N->getZExtValue() < 65536; +def imm0_65535 : ImmLeaf= 0 && Imm < 65536; }]>; class BinOpFrag : PatFrag<(ops node:$LHS, node:$RHS), res>; @@ -375,8 +375,8 @@ } // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24. -def rot_imm : Operand, PatLeaf<(i32 imm), [{ - int32_t v = (int32_t)N->getZExtValue(); +def rot_imm : Operand, ImmLeaf { let EncoderMethod = "getRotImmOpValue"; } @@ -433,13 +433,13 @@ }]>; /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31]. -def imm0_31 : Operand, PatLeaf<(imm), [{ - return (int32_t)N->getZExtValue() < 32; +def imm0_31 : Operand, ImmLeaf= 0 && Imm < 32; }]>; /// imm0_31_m1 - Matches and prints like imm0_31, but encodes as 'value - 1'. -def imm0_31_m1 : Operand, PatLeaf<(imm), [{ - return (int32_t)N->getZExtValue() < 32; +def imm0_31_m1 : Operand, ImmLeaf= 0 && Imm < 32; }]> { let EncoderMethod = "getImmMinusOneOpValue"; } @@ -462,13 +462,13 @@ } /// lsb_pos_imm - position of the lsb bit, used by BFI4p and t2BFI4p -def lsb_pos_imm : Operand, PatLeaf<(imm), [{ - return isInt<5>(N->getSExtValue()); +def lsb_pos_imm : Operand, ImmLeaf(Imm); }]>; /// width_imm - number of bits to be copied, used by BFI4p and t2BFI4p -def width_imm : Operand, PatLeaf<(imm), [{ - return N->getSExtValue() > 0 && N->getSExtValue() <= 32; +def width_imm : Operand, ImmLeaf 0 && Imm <= 32; }] > { let EncoderMethod = "getMsbOpValue"; } @@ -3021,8 +3021,8 @@ return CurDAG->getTargetConstant(Sh, MVT::i32); }]>; -def lsl_amt : PatLeaf<(i32 imm), [{ - return (N->getZExtValue() < 32); +def lsl_amt : ImmLeaf 0 && Imm < 32; }], lsl_shift_imm>; def PKHBT : APKHI<0b01101000, 0, (outs GPR:$Rd), @@ -3044,8 +3044,8 @@ return CurDAG->getTargetConstant(Sh, MVT::i32); }]>; -def asr_amt : PatLeaf<(i32 imm), [{ - return (N->getZExtValue() <= 32); +def asr_amt : ImmLeaf 0 && Imm <= 32; }], asr_shift_imm>; // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=130386&r1=130385&r2=130386&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Thu Apr 28 00:49:04 2011 @@ -27,22 +27,22 @@ }]>; /// imm0_7 predicate - True if the 32-bit immediate is in the range [0,7]. -def imm0_7 : PatLeaf<(i32 imm), [{ - return (uint32_t)N->getZExtValue() < 8; +def imm0_7 : ImmLeaf= 0 && Imm < 8; }]>; def imm0_7_neg : PatLeaf<(i32 imm), [{ return (uint32_t)-N->getZExtValue() < 8; }], imm_neg_XFORM>; -def imm0_255 : PatLeaf<(i32 imm), [{ - return (uint32_t)N->getZExtValue() < 256; +def imm0_255 : ImmLeaf= 0 && Imm < 256; }]>; def imm0_255_comp : PatLeaf<(i32 imm), [{ return ~((uint32_t)N->getZExtValue()) < 256; }]>; -def imm8_255 : PatLeaf<(i32 imm), [{ - return (uint32_t)N->getZExtValue() >= 8 && (uint32_t)N->getZExtValue() < 256; +def imm8_255 : ImmLeaf= 8 && Imm < 256; }]>; def imm8_255_neg : PatLeaf<(i32 imm), [{ unsigned Val = -N->getZExtValue(); Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130386&r1=130385&r2=130386&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Thu Apr 28 00:49:04 2011 @@ -62,14 +62,14 @@ }], t2_so_imm_neg_XFORM>; /// imm1_31 predicate - True if the 32-bit immediate is in the range [1,31]. -def imm1_31 : PatLeaf<(i32 imm), [{ - return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 32; +def imm1_31 : ImmLeaf= 1 && (int32_t)Imm < 32; }]>; /// imm0_4095 predicate - True if the 32-bit immediate is in the range [0.4095]. def imm0_4095 : Operand, - PatLeaf<(i32 imm), [{ - return (uint32_t)N->getZExtValue() < 4096; + ImmLeaf= 0 && Imm < 4096; }]>; def imm0_4095_neg : PatLeaf<(i32 imm), [{ From sabre at nondot.org Thu Apr 28 02:29:08 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 07:29:08 -0000 Subject: [llvm-commits] [llvm] r130390 - in /llvm/trunk: include/llvm/Analysis/MemoryDependenceAnalysis.h lib/Analysis/MemoryDependenceAnalysis.cpp lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll Message-ID: <20110428072909.085B92A6C135@llvm.org> Author: lattner Date: Thu Apr 28 02:29:08 2011 New Revision: 130390 URL: http://llvm.org/viewvc/llvm-project?rev=130390&view=rev Log: teach GVN to widen integer loads when they are overaligned, when doing an wider load would allow elimination of subsequent loads, and when the wider load is still a native integer type. This eliminates a ton of loads on various benchmarks involving struct fields, though it is somewhat hobbled by clang not being very aggressive about field alignment. This is yet another step along the way towards resolving PR6627. Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll Modified: llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h?rev=130390&r1=130389&r2=130390&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h (original) +++ llvm/trunk/include/llvm/Analysis/MemoryDependenceAnalysis.h Thu Apr 28 02:29:08 2011 @@ -355,6 +355,20 @@ BasicBlock::iterator ScanIt, BasicBlock *BB); + + /// getLoadLoadClobberFullWidthSize - This is a little bit of analysis that + /// looks at a memory location for a load (specified by MemLocBase, Offs, + /// and Size) and compares it against a load. If the specified load could + /// be safely widened to a larger integer load that is 1) still efficient, + /// 2) safe for the target, and 3) would provide the specified memory + /// location value, then this function returns the size in bytes of the + /// load width to use. If not, this returns zero. + static unsigned getLoadLoadClobberFullWidthSize(const Value *MemLocBase, + int64_t MemLocOffs, + unsigned MemLocSize, + const LoadInst *LI, + const TargetData &TD); + private: MemDepResult getCallSiteDependencyFrom(CallSite C, bool isReadOnlyCall, BasicBlock::iterator ScanIt, Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=130390&r1=130389&r2=130390&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original) +++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Thu Apr 28 02:29:08 2011 @@ -231,7 +231,8 @@ isLoadLoadClobberIfExtendedToFullWidth(const AliasAnalysis::Location &MemLoc, const Value *&MemLocBase, int64_t &MemLocOffs, - const LoadInst *LI, TargetData *TD) { + const LoadInst *LI, + const TargetData *TD) { // If we have no target data, we can't do this. if (TD == 0) return false; @@ -239,14 +240,34 @@ if (MemLocBase == 0) MemLocBase = GetPointerBaseWithConstantOffset(MemLoc.Ptr, MemLocOffs, *TD); + unsigned Size = MemoryDependenceAnalysis:: + getLoadLoadClobberFullWidthSize(MemLocBase, MemLocOffs, MemLoc.Size, + LI, *TD); + return Size != 0; +} + +/// getLoadLoadClobberFullWidthSize - This is a little bit of analysis that +/// looks at a memory location for a load (specified by MemLocBase, Offs, +/// and Size) and compares it against a load. If the specified load could +/// be safely widened to a larger integer load that is 1) still efficient, +/// 2) safe for the target, and 3) would provide the specified memory +/// location value, then this function returns the size in bytes of the +/// load width to use. If not, this returns zero. +unsigned MemoryDependenceAnalysis:: +getLoadLoadClobberFullWidthSize(const Value *MemLocBase, int64_t MemLocOffs, + unsigned MemLocSize, const LoadInst *LI, + const TargetData &TD) { + // We can only extend non-volatile integer loads. + if (!isa(LI->getType()) || LI->isVolatile()) return 0; + // Get the base of this load. int64_t LIOffs = 0; const Value *LIBase = - GetPointerBaseWithConstantOffset(LI->getPointerOperand(), LIOffs, *TD); + GetPointerBaseWithConstantOffset(LI->getPointerOperand(), LIOffs, TD); // If the two pointers are not based on the same pointer, we can't tell that // they are related. - if (LIBase != MemLocBase) return false; + if (LIBase != MemLocBase) return 0; // Okay, the two values are based on the same pointer, but returned as // no-alias. This happens when we have things like two byte loads at "P+1" @@ -255,7 +276,7 @@ // the bits required by MemLoc. // If MemLoc is before LI, then no widening of LI will help us out. - if (MemLocOffs < LIOffs) return false; + if (MemLocOffs < LIOffs) return 0; // Get the alignment of the load in bytes. We assume that it is safe to load // any legal integer up to this size without a problem. For example, if we're @@ -264,10 +285,10 @@ // to i16. unsigned LoadAlign = LI->getAlignment(); - int64_t MemLocEnd = MemLocOffs+MemLoc.Size; + int64_t MemLocEnd = MemLocOffs+MemLocSize; // If no amount of rounding up will let MemLoc fit into LI, then bail out. - if (LIOffs+LoadAlign < MemLocEnd) return false; + if (LIOffs+LoadAlign < MemLocEnd) return 0; // This is the size of the load to try. Start with the next larger power of // two. @@ -278,17 +299,17 @@ // If this load size is bigger than our known alignment or would not fit // into a native integer register, then we fail. if (NewLoadByteSize > LoadAlign || - !TD->fitsInLegalInteger(NewLoadByteSize*8)) - return false; + !TD.fitsInLegalInteger(NewLoadByteSize*8)) + return 0; // If a load of this width would include all of MemLoc, then we succeed. if (LIOffs+NewLoadByteSize >= MemLocEnd) - return true; + return NewLoadByteSize; NewLoadByteSize <<= 1; } - return false; + return 0; } /// getPointerDependencyFrom - Return the instruction on which a memory Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130390&r1=130389&r2=130390&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 02:29:08 2011 @@ -629,10 +629,11 @@ if (!CanCoerceMustAliasedValueToLoad(StoredVal, LoadedTy, TD)) return 0; + // If this is already the right type, just return it. const Type *StoredValTy = StoredVal->getType(); uint64_t StoreSize = TD.getTypeStoreSizeInBits(StoredValTy); - uint64_t LoadSize = TD.getTypeSizeInBits(LoadedTy); + uint64_t LoadSize = TD.getTypeStoreSizeInBits(LoadedTy); // If the store and reload are the same size, we can always reuse it. if (StoreSize == LoadSize) { @@ -806,7 +807,21 @@ Value *DepPtr = DepLI->getPointerOperand(); uint64_t DepSize = TD.getTypeSizeInBits(DepLI->getType()); - return AnalyzeLoadFromClobberingWrite(LoadTy, LoadPtr, DepPtr, DepSize, TD); + int R = AnalyzeLoadFromClobberingWrite(LoadTy, LoadPtr, DepPtr, DepSize, TD); + if (R != -1) return R; + + // If we have a load/load clobber an DepLI can be widened to cover this load, + // then we should widen it! + int64_t LoadOffs = 0; + const Value *LoadBase = + GetPointerBaseWithConstantOffset(LoadPtr, LoadOffs, TD); + unsigned LoadSize = TD.getTypeStoreSize(LoadTy); + + unsigned Size = MemoryDependenceAnalysis:: + getLoadLoadClobberFullWidthSize(LoadBase, LoadOffs, LoadSize, DepLI, TD); + if (Size == 0) return -1; + + return AnalyzeLoadFromClobberingWrite(LoadTy, LoadPtr, DepPtr, Size*8, TD); } @@ -858,9 +873,9 @@ /// GetStoreValueForLoad - This function is called when we have a /// memdep query of a load that ends up being a clobbering store. This means -/// that the store *may* provide bits used by the load but we can't be sure -/// because the pointers don't mustalias. Check this case to see if there is -/// anything more we can do before we give up. +/// that the store provides bits used by the load but we the pointers don't +/// mustalias. Check this case to see if there is anything more we can do +/// before we give up. static Value *GetStoreValueForLoad(Value *SrcVal, unsigned Offset, const Type *LoadTy, Instruction *InsertPt, const TargetData &TD){ @@ -896,6 +911,60 @@ return CoerceAvailableValueToLoadType(SrcVal, LoadTy, InsertPt, TD); } +/// GetStoreValueForLoad - This function is called when we have a +/// memdep query of a load that ends up being a clobbering load. This means +/// that the load *may* provide bits used by the load but we can't be sure +/// because the pointers don't mustalias. Check this case to see if there is +/// anything more we can do before we give up. +static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset, + const Type *LoadTy, + Instruction *InsertPt, const TargetData &TD, + MemoryDependenceAnalysis &MD) { + // If Offset+LoadTy exceeds the size of SrcVal, then we must be wanting to + // widen SrcVal out to a larger load. + unsigned SrcValSize = TD.getTypeStoreSize(SrcVal->getType()); + unsigned LoadSize = TD.getTypeStoreSize(LoadTy); + if (Offset+LoadSize > SrcValSize) { + assert(!SrcVal->isVolatile() && "Cannot widen volatile load!"); + assert(isa(SrcVal->getType())&&"Can't widen non-integer load"); + // If we have a load/load clobber an DepLI can be widened to cover this + // load, then we should widen it to the next power of 2 size big enough! + unsigned NewLoadSize = Offset+LoadSize; + if (!isPowerOf2_32(NewLoadSize)) + NewLoadSize = NextPowerOf2(NewLoadSize); + + Value *PtrVal = SrcVal->getPointerOperand(); + + IRBuilder<> Builder(SrcVal->getParent(), SrcVal); + const Type *DestPTy = + IntegerType::get(LoadTy->getContext(), NewLoadSize*8); + DestPTy = PointerType::get(DestPTy, + cast(PtrVal->getType())->getAddressSpace()); + + PtrVal = Builder.CreateBitCast(PtrVal, DestPTy); + LoadInst *NewLoad = Builder.CreateLoad(PtrVal); + NewLoad->takeName(SrcVal); + NewLoad->setAlignment(SrcVal->getAlignment()); + + DEBUG(dbgs() << "GVN WIDENED LOAD: " << *SrcVal << "\n"); + DEBUG(dbgs() << "TO: " << *NewLoad << "\n"); + + // Replace uses of the original load with the wider load. On a big endian + // system, we need to shift down to get the relevant bits. + Value *RV = NewLoad; + if (TD.isBigEndian()) + RV = Builder.CreateLShr(RV, + NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits()); + RV = Builder.CreateTrunc(RV, SrcVal->getType()); + SrcVal->replaceAllUsesWith(RV); + MD.removeInstruction(SrcVal); + SrcVal = NewLoad; + } + + return GetStoreValueForLoad(SrcVal, Offset, LoadTy, InsertPt, TD); +} + + /// GetMemInstValueForLoad - This function is called when we have a /// memdep query of a load that ends up being a clobbering mem intrinsic. static Value *GetMemInstValueForLoad(MemIntrinsic *SrcInst, unsigned Offset, @@ -958,11 +1027,12 @@ BasicBlock *BB; enum ValType { SimpleVal, // A simple offsetted value that is accessed. + LoadVal, // A value produced by a load. MemIntrin // A memory intrinsic which is loaded from. }; /// V - The value that is live out of the block. - PointerIntPair Val; + PointerIntPair Val; /// Offset - The byte offset in Val that is interesting for the load query. unsigned Offset; @@ -987,21 +1057,40 @@ return Res; } + static AvailableValueInBlock getLoad(BasicBlock *BB, LoadInst *LI, + unsigned Offset = 0) { + AvailableValueInBlock Res; + Res.BB = BB; + Res.Val.setPointer(LI); + Res.Val.setInt(LoadVal); + Res.Offset = Offset; + return Res; + } + bool isSimpleValue() const { return Val.getInt() == SimpleVal; } + bool isCoercedLoadValue() const { return Val.getInt() == LoadVal; } + bool isMemIntrinValue() const { return Val.getInt() == MemIntrin; } + Value *getSimpleValue() const { assert(isSimpleValue() && "Wrong accessor"); return Val.getPointer(); } + LoadInst *getCoercedLoadValue() const { + assert(isCoercedLoadValue() && "Wrong accessor"); + return cast(Val.getPointer()); + } + MemIntrinsic *getMemIntrinValue() const { - assert(!isSimpleValue() && "Wrong accessor"); + assert(isMemIntrinValue() && "Wrong accessor"); return cast(Val.getPointer()); } /// MaterializeAdjustedValue - Emit code into this block to adjust the value /// defined here to the specified type. This handles various coercion cases. Value *MaterializeAdjustedValue(const Type *LoadTy, - const TargetData *TD) const { + const TargetData *TD, + MemoryDependenceAnalysis &MD) const { Value *Res; if (isSimpleValue()) { Res = getSimpleValue(); @@ -1010,14 +1099,27 @@ Res = GetStoreValueForLoad(Res, Offset, LoadTy, BB->getTerminator(), *TD); - DEBUG(errs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " " + DEBUG(dbgs() << "GVN COERCED NONLOCAL VAL:\nOffset: " << Offset << " " << *getSimpleValue() << '\n' << *Res << '\n' << "\n\n\n"); } + } else if (isCoercedLoadValue()) { + LoadInst *Load = getCoercedLoadValue(); + if (Load->getType() == LoadTy && Offset == 0) { + Res = Load; + } else { + assert(TD && "Need target data to handle type mismatch case"); + Res = GetLoadValueForLoad(Load, Offset, LoadTy, BB->getTerminator(), + *TD, MD); + + DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " + << *getCoercedLoadValue() << '\n' + << *Res << '\n' << "\n\n\n"); + } } else { Res = GetMemInstValueForLoad(getMemIntrinValue(), Offset, LoadTy, BB->getTerminator(), *TD); - DEBUG(errs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset + DEBUG(dbgs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset << " " << *getMemIntrinValue() << '\n' << *Res << '\n' << "\n\n\n"); } @@ -1025,7 +1127,7 @@ } }; -} +} // end anonymous namespace /// ConstructSSAForLoadSet - Given a set of loads specified by ValuesPerBlock, /// construct SSA form, allowing us to eliminate LI. This returns the value @@ -1034,12 +1136,13 @@ SmallVectorImpl &ValuesPerBlock, const TargetData *TD, const DominatorTree &DT, - AliasAnalysis *AA) { + AliasAnalysis *AA, + MemoryDependenceAnalysis &MD) { // Check for the fully redundant, dominating load case. In this case, we can // just use the dominating value directly. if (ValuesPerBlock.size() == 1 && DT.properlyDominates(ValuesPerBlock[0].BB, LI->getParent())) - return ValuesPerBlock[0].MaterializeAdjustedValue(LI->getType(), TD); + return ValuesPerBlock[0].MaterializeAdjustedValue(LI->getType(), TD, MD); // Otherwise, we have to construct SSA form. SmallVector NewPHIs; @@ -1055,7 +1158,7 @@ if (SSAUpdate.HasValueForBlock(BB)) continue; - SSAUpdate.AddAvailableValue(BB, AV.MaterializeAdjustedValue(LoadTy, TD)); + SSAUpdate.AddAvailableValue(BB, AV.MaterializeAdjustedValue(LoadTy, TD,MD)); } // Perform PHI construction. @@ -1159,8 +1262,8 @@ DepLI, *TD); if (Offset != -1) { - ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, DepLI, - Offset)); + ValuesPerBlock.push_back(AvailableValueInBlock::getLoad(DepBB,DepLI, + Offset)); continue; } } @@ -1223,7 +1326,7 @@ continue; } } - ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB, LD)); + ValuesPerBlock.push_back(AvailableValueInBlock::getLoad(DepBB, LD)); continue; } @@ -1243,7 +1346,7 @@ // Perform PHI construction. Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, TD, *DT, - VN.getAliasAnalysis()); + VN.getAliasAnalysis(), *MD); LI->replaceAllUsesWith(V); if (isa(V)) @@ -1466,7 +1569,7 @@ // Perform PHI construction. Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, TD, *DT, - VN.getAliasAnalysis()); + VN.getAliasAnalysis(), *MD); LI->replaceAllUsesWith(V); if (isa(V)) V->takeName(LI); @@ -1527,7 +1630,7 @@ L->getPointerOperand(), DepLI, *TD); if (Offset != -1) - AvailVal = GetStoreValueForLoad(DepLI, Offset, L->getType(), L, *TD); + AvailVal = GetLoadValueForLoad(DepLI, Offset, L->getType(), L, *TD, *MD); } // If the clobbering value is a memset/memcpy/memmove, see if we can forward Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=130390&r1=130389&r2=130390&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Thu Apr 28 02:29:08 2011 @@ -1,7 +1,7 @@ ; RUN: opt < %s -basicaa -gvn -S | FileCheck %s ; 32-bit little endian target. -target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" ;; Trivial RLE test. define i32 @test0(i32 %V, i32* %P) { @@ -593,4 +593,27 @@ } +;;===----------------------------------------------------------------------===;; +;; Load Widening +;;===----------------------------------------------------------------------===;; + +%widening1 = type { i32, i8, i8 } + + at f = global %widening1 zeroinitializer, align 4 + +define i32 @test_widening1() nounwind ssp noredzone { +entry: + %tmp = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 1), align 4 + %conv = zext i8 %tmp to i32 + %tmp1 = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 2), align 1 + %conv2 = zext i8 %tmp1 to i32 + %add = add nsw i32 %conv, %conv2 + ret i32 %add +; CHECK: @test_widening1 +; CHECK-NOT: load +; CHECK: load i16* +; CHECK-NOT: load +; CHECK-ret i32 +} + From geek4civic at gmail.com Thu Apr 28 03:13:38 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Thu, 28 Apr 2011 17:13:38 +0900 Subject: [llvm-commits] [PATCH] docs/doxygen.css: Tweak style for readability. In-Reply-To: <61970259-416D-4EAA-9F6E-7E50F2E7DBC0@apple.com> References: <61970259-416D-4EAA-9F6E-7E50F2E7DBC0@apple.com> Message-ID: Committed in r130333 and confirmed just now, thank you! ...Takumi From fvbommel at gmail.com Thu Apr 28 03:21:15 2011 From: fvbommel at gmail.com (Frits van Bommel) Date: Thu, 28 Apr 2011 10:21:15 +0200 Subject: [llvm-commits] [llvm] r130338 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll In-Reply-To: <20110427224155.767CC2A6C12D@llvm.org> References: <20110427224155.767CC2A6C12D@llvm.org> Message-ID: On Thu, Apr 28, 2011 at 12:41 AM, Eli Friedman wrote: > + ?virtual unsigned TargetMaterializeFloatZero(const ConstantFP* CF) { > + ? ?return 0; > + ?} > getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext()))); > ? } else if (const ConstantFP *CF = dyn_cast(V)) { > - ? ?// Try to emit the constant directly. > - ? ?Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); > + ? ?if (CF->isZero()) { > + ? ? ?Reg = TargetMaterializeFloatZero(CF); > + ? ?} else { > + ? ? ?// Try to emit the constant directly. > + ? ? ?Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); > + ? ?} This doesn't seem to handle the case where FastEmit_f() would work but TargetMaterializeFloatZero() isn't overridden, which would be the "obvious" way to implement a target that doesn't need to handle 0.0 specially. IMHO, this should either try TargetMaterializeFloatZero() first and fall back to FastEmit_f if it returns 0, or the default TargetMaterializeFloatZero() implementation should be changed to call FastEmit_f(). From chandlerc at gmail.com Thu Apr 28 03:17:05 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Thu, 28 Apr 2011 08:17:05 -0000 Subject: [llvm-commits] [llvm] r130391 - /llvm/trunk/tools/CMakeLists.txt Message-ID: <20110428081705.DBA182A6C136@llvm.org> Author: chandlerc Date: Thu Apr 28 03:17:05 2011 New Revision: 130391 URL: http://llvm.org/viewvc/llvm-project?rev=130391&view=rev Log: nuke gold Modified: llvm/trunk/tools/CMakeLists.txt Modified: llvm/trunk/tools/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/CMakeLists.txt?rev=130391&r1=130390&r2=130391&view=diff ============================================================================== --- llvm/trunk/tools/CMakeLists.txt (original) +++ llvm/trunk/tools/CMakeLists.txt Thu Apr 28 03:17:05 2011 @@ -51,13 +51,6 @@ add_subdirectory(lto) endif() -if( LLVM_ENABLE_PIC ) - # TODO: support other systems: - if( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) - add_subdirectory(gold) - endif() -endif() - if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/clang/CMakeLists.txt ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/clang ) endif( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/clang/CMakeLists.txt ) From chandlerc at gmail.com Thu Apr 28 03:17:08 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Thu, 28 Apr 2011 08:17:08 -0000 Subject: [llvm-commits] [llvm] r130392 - /llvm/trunk/include/llvm/ADT/DenseMap.h Message-ID: <20110428081708.ADC772A6C138@llvm.org> Author: chandlerc Date: Thu Apr 28 03:17:08 2011 New Revision: 130392 URL: http://llvm.org/viewvc/llvm-project?rev=130392&view=rev Log: Fix more -Wnon-pod-memset warnings. Modified: llvm/trunk/include/llvm/ADT/DenseMap.h Modified: llvm/trunk/include/llvm/ADT/DenseMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=130392&r1=130391&r2=130392&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/DenseMap.h (original) +++ llvm/trunk/include/llvm/ADT/DenseMap.h Thu Apr 28 03:17:08 2011 @@ -252,7 +252,7 @@ if (NumBuckets) { #ifndef NDEBUG - memset(Buckets, 0x5a, sizeof(BucketT)*NumBuckets); + memset((void*)Buckets, 0x5a, sizeof(BucketT)*NumBuckets); #endif operator delete(Buckets); } @@ -459,7 +459,7 @@ } #ifndef NDEBUG - memset(OldBuckets, 0x5a, sizeof(BucketT)*OldNumBuckets); + memset((void*)OldBuckets, 0x5a, sizeof(BucketT)*OldNumBuckets); #endif // Free the old table. operator delete(OldBuckets); From chandlerc at gmail.com Thu Apr 28 03:18:22 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Thu, 28 Apr 2011 08:18:22 -0000 Subject: [llvm-commits] [llvm] r130393 - /llvm/trunk/tools/CMakeLists.txt Message-ID: <20110428081822.A9BB32A6C136@llvm.org> Author: chandlerc Date: Thu Apr 28 03:18:22 2011 New Revision: 130393 URL: http://llvm.org/viewvc/llvm-project?rev=130393&view=rev Log: Revert an unintended commit. Very sorry for this one. Modified: llvm/trunk/tools/CMakeLists.txt Modified: llvm/trunk/tools/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/CMakeLists.txt?rev=130393&r1=130392&r2=130393&view=diff ============================================================================== --- llvm/trunk/tools/CMakeLists.txt (original) +++ llvm/trunk/tools/CMakeLists.txt Thu Apr 28 03:18:22 2011 @@ -51,6 +51,13 @@ add_subdirectory(lto) endif() +if( LLVM_ENABLE_PIC ) + # TODO: support other systems: + if( CMAKE_SYSTEM_NAME STREQUAL "Linux" ) + add_subdirectory(gold) + endif() +endif() + if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/clang/CMakeLists.txt ) add_subdirectory( ${CMAKE_CURRENT_SOURCE_DIR}/clang ) endif( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/clang/CMakeLists.txt ) From chandlerc at gmail.com Thu Apr 28 03:37:19 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Thu, 28 Apr 2011 08:37:19 -0000 Subject: [llvm-commits] [llvm] r130395 - /llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <20110428083719.2AA002A6C133@llvm.org> Author: chandlerc Date: Thu Apr 28 03:37:18 2011 New Revision: 130395 URL: http://llvm.org/viewvc/llvm-project?rev=130395&view=rev Log: Fix the last -Wnon-pod-memset I'm seeing. This is benign, but appears a bit more sinister as the memset doesn't do what the constructor does. There seems to be a cleaner solution than a cast here though, instead we can point the memset destination into the union its actually trying to clear. An alternative is to point to the Untyped member of this union. Review appreciated, and if that is cleaner I'm happy to switch. All of these should be functionally equivalent to the original code. Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=130395&r1=130394&r2=130395&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Thu Apr 28 03:37:18 2011 @@ -839,7 +839,7 @@ case Type::PointerTyID: // Ensure 64 bit target pointers are fully initialized on 32 bit hosts. if (StoreBytes != sizeof(PointerTy)) - memset(Ptr, 0, StoreBytes); + memset(&(Ptr->PointerVal), 0, StoreBytes); *((PointerTy*)Ptr) = Val.PointerVal; break; From jay.foad at gmail.com Thu Apr 28 04:12:47 2011 From: jay.foad at gmail.com (Jay Foad) Date: Thu, 28 Apr 2011 09:12:47 -0000 Subject: [llvm-commits] [llvm] r130396 - /llvm/trunk/include/llvm/Pass.h Message-ID: <20110428091247.633772A6C135@llvm.org> Author: foad Date: Thu Apr 28 04:12:47 2011 New Revision: 130396 URL: http://llvm.org/viewvc/llvm-project?rev=130396&view=rev Log: Fix typos in comments. Modified: llvm/trunk/include/llvm/Pass.h Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=130396&r1=130395&r2=130396&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Thu Apr 28 04:12:47 2011 @@ -114,7 +114,7 @@ void dump() const; // dump - Print to stderr. /// createPrinterPass - Get a Pass appropriate to print the IR this - /// pass operates one (Module, Function or MachineFunction). + /// pass operates on (Module, Function or MachineFunction). virtual Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const = 0; @@ -320,7 +320,7 @@ public: explicit BasicBlockPass(char &pid) : Pass(PT_BasicBlock, pid) {} - /// createPrinterPass - Get a function printer pass. + /// createPrinterPass - Get a basic block printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const; /// doInitialization - Virtual method overridden by subclasses to do From rafael.espindola at gmail.com Thu Apr 28 07:50:37 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 12:50:37 -0000 Subject: [llvm-commits] [llvm] r130397 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCDwarf.cpp lib/MC/MCMachOStreamer.cpp lib/MC/MCStreamer.cpp Message-ID: <20110428125038.091A32A6C135@llvm.org> Author: rafael Date: Thu Apr 28 07:50:37 2011 New Revision: 130397 URL: http://llvm.org/viewvc/llvm-project?rev=130397&view=rev Log: Mark the EH symbol global or weak if the corresponding function is. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=130397&r1=130396&r2=130397&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Thu Apr 28 07:50:37 2011 @@ -184,6 +184,9 @@ /// used in an assignment. virtual void EmitLabel(MCSymbol *Symbol); + virtual void EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol); + /// EmitAssemblerFlag - Note in the output the specified @p Flag virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130397&r1=130396&r2=130397&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 28 07:50:37 2011 @@ -726,6 +726,7 @@ if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { Twine EHName = frame.Function->getName() + Twine(".eh"); MCSymbol *EHSym = context.GetOrCreateSymbol(EHName); + streamer.EmitEHSymAttributes(frame.Function, EHSym); streamer.EmitLabel(EHSym); } Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=130397&r1=130396&r2=130397&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Thu Apr 28 07:50:37 2011 @@ -44,6 +44,8 @@ virtual void InitSections(); virtual void EmitLabel(MCSymbol *Symbol); + virtual void EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol); virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); virtual void EmitThumbFunc(MCSymbol *Func); virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value); @@ -101,6 +103,16 @@ } +void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol) { + MCSymbolData &SD = + getAssembler().getOrCreateSymbolData(*Symbol); + if (SD.isExternal()) + EmitSymbolAttribute(EHSymbol, MCSA_Global); + if (SD.getFlags() & SF_WeakDefinition) + EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition); +} + void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) { assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=130397&r1=130396&r2=130397&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Thu Apr 28 07:50:37 2011 @@ -154,6 +154,10 @@ report_fatal_error("No open frame"); } +void MCStreamer::EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol) { +} + void MCStreamer::EmitLabel(MCSymbol *Symbol) { assert(!Symbol->isVariable() && "Cannot emit a variable symbol!"); assert(getCurrentSection() && "Cannot emit before setting section!"); From lenny at Colorado.EDU Thu Apr 28 10:20:12 2011 From: lenny at Colorado.EDU (Lenny Maiorani) Date: Thu, 28 Apr 2011 09:20:12 -0600 Subject: [llvm-commits] [PATCH] review request - bounded case-insensitive StringRef compare In-Reply-To: <540D8AD0-93C2-45DF-BE89-38828BCFEF1B@apple.com> References: <4DB74569.2060305@colorado.edu> <540D8AD0-93C2-45DF-BE89-38828BCFEF1B@apple.com> Message-ID: <4DB985AC.4090601@colorado.edu> On 04/27/2011 07:16 PM, Chris Lattner wrote: > On Apr 26, 2011, at 3:21 PM, Lenny Maiorani wrote: > >> This patch adds bounded case-insensitive compare to StringRef class, imitating strncasecmp(). Includes unit tests. > I'm still dubious about the 'n' functions being in StringRef, I don't understand why clients can't substr() the string before calling non-'n' versions. > > -Chris Chris, I understand your desire to keep the feature creep to a minimum. I can implement the features I want using substr(). Should I also back-out r129582 where I added a bounded version of compare()? I would need to back-out a change in the Clang SA and use substr() instead prior to backing this out. -Lenny From clattner at apple.com Thu Apr 28 10:41:14 2011 From: clattner at apple.com (Chris Lattner) Date: Thu, 28 Apr 2011 08:41:14 -0700 Subject: [llvm-commits] [PATCH] review request - bounded case-insensitive StringRef compare In-Reply-To: <4DB985AC.4090601@colorado.edu> References: <4DB74569.2060305@colorado.edu> <540D8AD0-93C2-45DF-BE89-38828BCFEF1B@apple.com> <4DB985AC.4090601@colorado.edu> Message-ID: <5896D176-6314-4873-B1DF-1CC276EAA2DF@apple.com> On Apr 28, 2011, at 8:20 AM, Lenny Maiorani wrote: > On 04/27/2011 07:16 PM, Chris Lattner wrote: >> On Apr 26, 2011, at 3:21 PM, Lenny Maiorani wrote: >> >>> This patch adds bounded case-insensitive compare to StringRef class, imitating strncasecmp(). Includes unit tests. >> I'm still dubious about the 'n' functions being in StringRef, I don't understand why clients can't substr() the string before calling non-'n' versions. >> >> -Chris > Chris, > > I understand your desire to keep the feature creep to a minimum. I can implement the features I want using substr(). Should I also back-out r129582 where I added a bounded version of compare()? I would need to back-out a change in the Clang SA and use substr() instead prior to backing this out. Yes, that sounds like a better approach. Given that all StringRef operations are implicitly length bounded, I think that having the few clients that need "n" functionality do this is the right way to go. Thanks! -Chris From rafael.espindola at gmail.com Thu Apr 28 11:09:09 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 16:09:09 -0000 Subject: [llvm-commits] [llvm] r130400 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCAsmInfoDarwin.h lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCDwarf.cpp lib/Target/X86/X86MCAsmInfo.cpp lib/Target/X86/X86MCAsmInfo.h lib/Target/X86/X86TargetMachine.cpp Message-ID: <20110428160909.BF9192A6C135@llvm.org> Author: rafael Date: Thu Apr 28 11:09:09 2011 New Revision: 130400 URL: http://llvm.org/viewvc/llvm-project?rev=130400&view=rev Log: Add a getExprForPersonalitySymbol method to MCAsmInfo. Use it when converting the symbol passed to .cfi_personality into bytes is the file. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.h llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Thu Apr 28 11:09:09 2011 @@ -20,7 +20,10 @@ #include namespace llvm { + class MCExpr; class MCSection; + class MCStreamer; + class MCSymbol; class MCContext; /// MCAsmInfo - This class is intended to be used as a base class for asm @@ -321,6 +324,10 @@ return 0; } + virtual const MCExpr * + getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const; + bool usesSunStyleELFSectionSwitchSyntax() const { return SunStyleELFSectionSwitchSyntax; } Modified: llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h Thu Apr 28 11:09:09 2011 @@ -25,6 +25,9 @@ struct MCAsmInfoDarwin : public MCAsmInfo { explicit MCAsmInfoDarwin(); + virtual const MCExpr * + getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const; }; } Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Thu Apr 28 11:09:09 2011 @@ -13,6 +13,8 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCStreamer.h" #include "llvm/Support/DataTypes.h" #include #include @@ -106,3 +108,9 @@ } while (IsMore); return Size; } + +const MCExpr * +MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { + return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); +} Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Thu Apr 28 11:09:09 2011 @@ -13,6 +13,9 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfoDarwin.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCStreamer.h" using namespace llvm; MCAsmInfoDarwin::MCAsmInfoDarwin() { @@ -57,3 +60,13 @@ DwarfUsesLabelOffsetForRanges = false; } +const MCExpr * +MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { + MCContext &Context = Streamer.getContext(); + const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); + MCSymbol *PCSym = Context.CreateTempSymbol(); + Streamer.EmitLabel(PCSym); + const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); + return MCBinaryExpr::CreateSub(Res, PC, Context); +} Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 28 11:09:09 2011 @@ -480,6 +480,19 @@ } } +static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, + unsigned symbolEncoding) { + MCContext &context = streamer.getContext(); + const MCAsmInfo &asmInfo = context.getAsmInfo(); + const MCExpr *v = asmInfo.getExprForPersonalitySymbol(&symbol, streamer); + unsigned size = getSizeForEncoding(streamer, symbolEncoding); + unsigned application = symbolEncoding & 0x70; + if (isa(v) && application == dwarf::DW_EH_PE_pcrel) + streamer.EmitPCRelValue(v, size); + else + streamer.EmitValue(v, size); +} + static const MachineLocation TranslateMachineLocation( const TargetAsmInfo &AsmInfo, const MachineLocation &Loc) { @@ -681,7 +694,7 @@ // Personality Encoding streamer.EmitIntValue(personalityEncoding, 1); // Personality - EmitSymbol(streamer, *personality, personalityEncoding); + EmitPersonality(streamer, *personality, personalityEncoding); } if (lsda) { // LSDA Encoding Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Thu Apr 28 11:09:09 2011 @@ -15,7 +15,9 @@ #include "X86TargetMachine.h" #include "llvm/ADT/Triple.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCStreamer.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ELF.h" using namespace llvm; @@ -72,6 +74,20 @@ ExceptionsType = ExceptionHandling::DwarfTable; } +const MCExpr * +X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { + MCContext &Context = Streamer.getContext(); + const MCExpr *Res = + MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_GOTPCREL, Context); + const MCExpr *Four = MCConstantExpr::Create(4, Context); + return MCBinaryExpr::CreateAdd(Res, Four, Context); +} + +X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple) + : X86MCAsmInfoDarwin(Triple) { +} + X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) { AsmTransCBE = x86_asm_table; AssemblerDialect = AsmWriterFlavor; Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.h?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.h Thu Apr 28 11:09:09 2011 @@ -25,6 +25,13 @@ explicit X86MCAsmInfoDarwin(const Triple &Triple); }; + struct X86_64MCAsmInfoDarwin : public X86MCAsmInfoDarwin { + explicit X86_64MCAsmInfoDarwin(const Triple &Triple); + virtual const MCExpr * + getExprForPersonalitySymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const; + }; + struct X86ELFMCAsmInfo : public MCAsmInfo { explicit X86ELFMCAsmInfo(const Triple &Triple); virtual const MCSection *getNonexecutableStackSection(MCContext &Ctx) const; Modified: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetMachine.cpp?rev=130400&r1=130399&r2=130400&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp Thu Apr 28 11:09:09 2011 @@ -27,8 +27,12 @@ static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); - if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) - return new X86MCAsmInfoDarwin(TheTriple); + if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) { + if (TheTriple.getArch() == Triple::x86_64) + return new X86_64MCAsmInfoDarwin(TheTriple); + else + return new X86MCAsmInfoDarwin(TheTriple); + } if (TheTriple.isOSWindows()) return new X86MCAsmInfoCOFF(TheTriple); From sabre at nondot.org Thu Apr 28 11:18:53 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 16:18:53 -0000 Subject: [llvm-commits] [llvm] r130401 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <20110428161853.1BFE92A6C135@llvm.org> Author: lattner Date: Thu Apr 28 11:18:52 2011 New Revision: 130401 URL: http://llvm.org/viewvc/llvm-project?rev=130401&view=rev Log: Promote toErase to be an ivar of the GVN class. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130401&r1=130400&r2=130401&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 11:18:52 2011 @@ -418,6 +418,8 @@ DenseMap LeaderTable; BumpPtrAllocator TableAllocator; + SmallVector InstrsToErase; + /// addToLeaderTable - Push a new Value to the LeaderTable onto the list for /// its value number. void addToLeaderTable(uint32_t N, Value *V, BasicBlock *BB) { @@ -477,16 +479,13 @@ // Helper fuctions // FIXME: eliminate or document these better - bool processLoad(LoadInst* L, - SmallVectorImpl &toErase); - bool processInstruction(Instruction *I, - SmallVectorImpl &toErase); - bool processNonLocalLoad(LoadInst* L, - SmallVectorImpl &toErase); + bool processLoad(LoadInst *L); + bool processInstruction(Instruction *I); + bool processNonLocalLoad(LoadInst *L); bool processBlock(BasicBlock *BB); - void dump(DenseMap& d); + void dump(DenseMap &d); bool iterateOnFunction(Function &F); - bool performPRE(Function& F); + bool performPRE(Function &F); Value *findLeader(BasicBlock *BB, uint32_t num); void cleanupGlobalSets(); void verifyRemoved(const Instruction *I) const; @@ -1189,8 +1188,7 @@ /// processNonLocalLoad - Attempt to eliminate a load whose dependencies are /// non-local by performing PHI construction. -bool GVN::processNonLocalLoad(LoadInst *LI, - SmallVectorImpl &toErase) { +bool GVN::processNonLocalLoad(LoadInst *LI) { // Find the non-local dependencies of the load. SmallVector Deps; AliasAnalysis::Location Loc = VN.getAliasAnalysis()->getLocation(LI); @@ -1354,7 +1352,7 @@ if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); VN.erase(LI); - toErase.push_back(LI); + InstrsToErase.push_back(LI); ++NumGVNLoad; return true; } @@ -1576,14 +1574,14 @@ if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); VN.erase(LI); - toErase.push_back(LI); + InstrsToErase.push_back(LI); ++NumPRELoad; return true; } /// processLoad - Attempt to eliminate a load, first by eliminating it /// locally, and then attempting non-local elimination if that fails. -bool GVN::processLoad(LoadInst *L, SmallVectorImpl &toErase) { +bool GVN::processLoad(LoadInst *L) { if (!MD) return false; @@ -1652,7 +1650,7 @@ if (AvailVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(AvailVal); VN.erase(L); - toErase.push_back(L); + InstrsToErase.push_back(L); ++NumGVNLoad; return true; } @@ -1672,7 +1670,7 @@ // If it is defined in another block, try harder. if (Dep.isNonLocal()) - return processNonLocalLoad(L, toErase); + return processNonLocalLoad(L); Instruction *DepInst = Dep.getInst(); if (StoreInst *DepSI = dyn_cast(DepInst)) { @@ -1700,7 +1698,7 @@ if (StoredVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(StoredVal); VN.erase(L); - toErase.push_back(L); + InstrsToErase.push_back(L); ++NumGVNLoad; return true; } @@ -1730,7 +1728,7 @@ if (DepLI->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(DepLI); VN.erase(L); - toErase.push_back(L); + InstrsToErase.push_back(L); ++NumGVNLoad; return true; } @@ -1741,7 +1739,7 @@ if (isa(DepInst) || isMalloc(DepInst)) { L->replaceAllUsesWith(UndefValue::get(L->getType())); VN.erase(L); - toErase.push_back(L); + InstrsToErase.push_back(L); ++NumGVNLoad; return true; } @@ -1752,7 +1750,7 @@ if (II->getIntrinsicID() == Intrinsic::lifetime_start) { L->replaceAllUsesWith(UndefValue::get(L->getType())); VN.erase(L); - toErase.push_back(L); + InstrsToErase.push_back(L); ++NumGVNLoad; return true; } @@ -1792,8 +1790,7 @@ /// processInstruction - When calculating availability, handle an instruction /// by inserting it into the appropriate sets -bool GVN::processInstruction(Instruction *I, - SmallVectorImpl &toErase) { +bool GVN::processInstruction(Instruction *I) { // Ignore dbg info intrinsics. if (isa(I)) return false; @@ -1807,19 +1804,17 @@ if (MD && V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); VN.erase(I); - toErase.push_back(I); + InstrsToErase.push_back(I); return true; } if (LoadInst *LI = dyn_cast(I)) { - bool Changed = processLoad(LI, toErase); - - if (!Changed) { - unsigned Num = VN.lookup_or_add(LI); - addToLeaderTable(Num, LI, LI->getParent()); - } + if (processLoad(LI)) + return true; - return Changed; + unsigned Num = VN.lookup_or_add(LI); + addToLeaderTable(Num, LI, LI->getParent()); + return false; } // For conditions branches, we can perform simple conditional propagation on @@ -1882,7 +1877,7 @@ I->replaceAllUsesWith(repl); if (MD && repl->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(repl); - toErase.push_back(I); + InstrsToErase.push_back(I); return true; } @@ -1939,35 +1934,36 @@ bool GVN::processBlock(BasicBlock *BB) { - // FIXME: Kill off toErase by doing erasing eagerly in a helper function (and - // incrementing BI before processing an instruction). - SmallVector toErase; + // FIXME: Kill off InstrsToErase by doing erasing eagerly in a helper function + // (and incrementing BI before processing an instruction). + assert(InstrsToErase.empty() && + "We expect InstrsToErase to be empty across iterations"); bool ChangedFunction = false; for (BasicBlock::iterator BI = BB->begin(), BE = BB->end(); BI != BE;) { - ChangedFunction |= processInstruction(BI, toErase); - if (toErase.empty()) { + ChangedFunction |= processInstruction(BI); + if (InstrsToErase.empty()) { ++BI; continue; } // If we need some instructions deleted, do it now. - NumGVNInstr += toErase.size(); + NumGVNInstr += InstrsToErase.size(); // Avoid iterator invalidation. bool AtStart = BI == BB->begin(); if (!AtStart) --BI; - for (SmallVector::iterator I = toErase.begin(), - E = toErase.end(); I != E; ++I) { + for (SmallVector::iterator I = InstrsToErase.begin(), + E = InstrsToErase.end(); I != E; ++I) { DEBUG(dbgs() << "GVN removed: " << **I << '\n'); if (MD) MD->removeInstruction(*I); (*I)->eraseFromParent(); DEBUG(verifyRemoved(*I)); } - toErase.clear(); + InstrsToErase.clear(); if (AtStart) BI = BB->begin(); From sabre at nondot.org Thu Apr 28 11:36:48 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 16:36:48 -0000 Subject: [llvm-commits] [llvm] r130403 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <20110428163648.AEDFC2A6C135@llvm.org> Author: lattner Date: Thu Apr 28 11:36:48 2011 New Revision: 130403 URL: http://llvm.org/viewvc/llvm-project?rev=130403&view=rev Log: centralize "marking for deletion" into a helper function. Pass GVN around to static functions instead of passing around tons of random ivars. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130403&r1=130402&r2=130403&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 11:36:48 2011 @@ -392,20 +392,13 @@ namespace { class GVN : public FunctionPass { - bool runOnFunction(Function &F); - public: - static char ID; // Pass identification, replacement for typeid - explicit GVN(bool noloads = false) - : FunctionPass(ID), NoLoads(noloads), MD(0) { - initializeGVNPass(*PassRegistry::getPassRegistry()); - } - - private: bool NoLoads; + public: MemoryDependenceAnalysis *MD; + private: DominatorTree *DT; - const TargetData* TD; - + const TargetData *TD; + ValueTable VN; /// LeaderTable - A mapping from value numbers to lists of Value*'s that @@ -419,7 +412,26 @@ BumpPtrAllocator TableAllocator; SmallVector InstrsToErase; + public: + static char ID; // Pass identification, replacement for typeid + explicit GVN(bool noloads = false) + : FunctionPass(ID), NoLoads(noloads), MD(0) { + initializeGVNPass(*PassRegistry::getPassRegistry()); + } + + bool runOnFunction(Function &F); + + /// markInstructionForDeletion - This removes the specified instruction from + /// our various maps and marks it for deletion. + void markInstructionForDeletion(Instruction *I) { + VN.erase(I); + InstrsToErase.push_back(I); + } + const TargetData *getTargetData() const { return TD; } + DominatorTree &getDominatorTree() const { return *DT; } + AliasAnalysis *getAliasAnalysis() const { return VN.getAliasAnalysis(); } + private: /// addToLeaderTable - Push a new Value to the LeaderTable onto the list for /// its value number. void addToLeaderTable(uint32_t N, Value *V, BasicBlock *BB) { @@ -476,6 +488,7 @@ AU.addPreserved(); AU.addPreserved(); } + // Helper fuctions // FIXME: eliminate or document these better @@ -916,9 +929,9 @@ /// because the pointers don't mustalias. Check this case to see if there is /// anything more we can do before we give up. static Value *GetLoadValueForLoad(LoadInst *SrcVal, unsigned Offset, - const Type *LoadTy, - Instruction *InsertPt, const TargetData &TD, - MemoryDependenceAnalysis &MD) { + const Type *LoadTy, Instruction *InsertPt, + GVN &gvn) { + const TargetData &TD = *gvn.getTargetData(); // If Offset+LoadTy exceeds the size of SrcVal, then we must be wanting to // widen SrcVal out to a larger load. unsigned SrcValSize = TD.getTypeStoreSize(SrcVal->getType()); @@ -956,7 +969,8 @@ NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits()); RV = Builder.CreateTrunc(RV, SrcVal->getType()); SrcVal->replaceAllUsesWith(RV); - MD.removeInstruction(SrcVal); + gvn.MD->removeInstruction(SrcVal); + //gvn.markInstructionForDeletion(SrcVal); SrcVal = NewLoad; } @@ -1087,13 +1101,12 @@ /// MaterializeAdjustedValue - Emit code into this block to adjust the value /// defined here to the specified type. This handles various coercion cases. - Value *MaterializeAdjustedValue(const Type *LoadTy, - const TargetData *TD, - MemoryDependenceAnalysis &MD) const { + Value *MaterializeAdjustedValue(const Type *LoadTy, GVN &gvn) const { Value *Res; if (isSimpleValue()) { Res = getSimpleValue(); if (Res->getType() != LoadTy) { + const TargetData *TD = gvn.getTargetData(); assert(TD && "Need target data to handle type mismatch case"); Res = GetStoreValueForLoad(Res, Offset, LoadTy, BB->getTerminator(), *TD); @@ -1107,15 +1120,16 @@ if (Load->getType() == LoadTy && Offset == 0) { Res = Load; } else { - assert(TD && "Need target data to handle type mismatch case"); Res = GetLoadValueForLoad(Load, Offset, LoadTy, BB->getTerminator(), - *TD, MD); + gvn); DEBUG(dbgs() << "GVN COERCED NONLOCAL LOAD:\nOffset: " << Offset << " " << *getCoercedLoadValue() << '\n' << *Res << '\n' << "\n\n\n"); } } else { + const TargetData *TD = gvn.getTargetData(); + assert(TD && "Need target data to handle type mismatch case"); Res = GetMemInstValueForLoad(getMemIntrinValue(), Offset, LoadTy, BB->getTerminator(), *TD); DEBUG(dbgs() << "GVN COERCED NONLOCAL MEM INTRIN:\nOffset: " << Offset @@ -1133,15 +1147,13 @@ /// that should be used at LI's definition site. static Value *ConstructSSAForLoadSet(LoadInst *LI, SmallVectorImpl &ValuesPerBlock, - const TargetData *TD, - const DominatorTree &DT, - AliasAnalysis *AA, - MemoryDependenceAnalysis &MD) { + GVN &gvn) { // Check for the fully redundant, dominating load case. In this case, we can // just use the dominating value directly. if (ValuesPerBlock.size() == 1 && - DT.properlyDominates(ValuesPerBlock[0].BB, LI->getParent())) - return ValuesPerBlock[0].MaterializeAdjustedValue(LI->getType(), TD, MD); + gvn.getDominatorTree().properlyDominates(ValuesPerBlock[0].BB, + LI->getParent())) + return ValuesPerBlock[0].MaterializeAdjustedValue(LI->getType(), gvn); // Otherwise, we have to construct SSA form. SmallVector NewPHIs; @@ -1157,14 +1169,16 @@ if (SSAUpdate.HasValueForBlock(BB)) continue; - SSAUpdate.AddAvailableValue(BB, AV.MaterializeAdjustedValue(LoadTy, TD,MD)); + SSAUpdate.AddAvailableValue(BB, AV.MaterializeAdjustedValue(LoadTy, gvn)); } // Perform PHI construction. Value *V = SSAUpdate.GetValueInMiddleOfBlock(LI->getParent()); // If new PHI nodes were created, notify alias analysis. - if (V->getType()->isPointerTy()) + if (V->getType()->isPointerTy()) { + AliasAnalysis *AA = gvn.getAliasAnalysis(); + for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i) AA->copyValue(LI, NewPHIs[i]); @@ -1176,6 +1190,7 @@ for (unsigned ii = 0, ee = P->getNumIncomingValues(); ii != ee; ++ii) AA->addEscapingUse(P->getOperandUse(2*ii)); } + } return V; } @@ -1343,16 +1358,14 @@ DEBUG(dbgs() << "GVN REMOVING NONLOCAL LOAD: " << *LI << '\n'); // Perform PHI construction. - Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, TD, *DT, - VN.getAliasAnalysis(), *MD); + Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, *this); LI->replaceAllUsesWith(V); if (isa(V)) V->takeName(LI); if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); - VN.erase(LI); - InstrsToErase.push_back(LI); + markInstructionForDeletion(LI); ++NumGVNLoad; return true; } @@ -1566,15 +1579,13 @@ } // Perform PHI construction. - Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, TD, *DT, - VN.getAliasAnalysis(), *MD); + Value *V = ConstructSSAForLoadSet(LI, ValuesPerBlock, *this); LI->replaceAllUsesWith(V); if (isa(V)) V->takeName(LI); if (V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); - VN.erase(LI); - InstrsToErase.push_back(LI); + markInstructionForDeletion(LI); ++NumPRELoad; return true; } @@ -1628,7 +1639,7 @@ L->getPointerOperand(), DepLI, *TD); if (Offset != -1) - AvailVal = GetLoadValueForLoad(DepLI, Offset, L->getType(), L, *TD, *MD); + AvailVal = GetLoadValueForLoad(DepLI, Offset, L->getType(), L, *this); } // If the clobbering value is a memset/memcpy/memmove, see if we can forward @@ -1649,8 +1660,7 @@ L->replaceAllUsesWith(AvailVal); if (AvailVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(AvailVal); - VN.erase(L); - InstrsToErase.push_back(L); + markInstructionForDeletion(L); ++NumGVNLoad; return true; } @@ -1697,8 +1707,7 @@ L->replaceAllUsesWith(StoredVal); if (StoredVal->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(StoredVal); - VN.erase(L); - InstrsToErase.push_back(L); + markInstructionForDeletion(L); ++NumGVNLoad; return true; } @@ -1727,8 +1736,7 @@ L->replaceAllUsesWith(AvailableVal); if (DepLI->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(DepLI); - VN.erase(L); - InstrsToErase.push_back(L); + markInstructionForDeletion(L); ++NumGVNLoad; return true; } @@ -1738,19 +1746,17 @@ // intervening stores, for example. if (isa(DepInst) || isMalloc(DepInst)) { L->replaceAllUsesWith(UndefValue::get(L->getType())); - VN.erase(L); - InstrsToErase.push_back(L); + markInstructionForDeletion(L); ++NumGVNLoad; return true; } // If this load occurs either right after a lifetime begin, // then the loaded value is undefined. - if (IntrinsicInst* II = dyn_cast(DepInst)) { + if (IntrinsicInst *II = dyn_cast(DepInst)) { if (II->getIntrinsicID() == Intrinsic::lifetime_start) { L->replaceAllUsesWith(UndefValue::get(L->getType())); - VN.erase(L); - InstrsToErase.push_back(L); + markInstructionForDeletion(L); ++NumGVNLoad; return true; } @@ -1803,8 +1809,7 @@ I->replaceAllUsesWith(V); if (MD && V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); - VN.erase(I); - InstrsToErase.push_back(I); + markInstructionForDeletion(I); return true; } @@ -1873,11 +1878,10 @@ } // Remove it! - VN.erase(I); I->replaceAllUsesWith(repl); if (MD && repl->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(repl); - InstrsToErase.push_back(I); + markInstructionForDeletion(I); return true; } From echristo at apple.com Thu Apr 28 11:52:09 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 28 Apr 2011 16:52:09 -0000 Subject: [llvm-commits] [llvm] r130404 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110428165209.E7DD42A6C135@llvm.org> Author: echristo Date: Thu Apr 28 11:52:09 2011 New Revision: 130404 URL: http://llvm.org/viewvc/llvm-project?rev=130404&view=rev Log: Be more layout aware here and swap the successor and branch condition if it means we get a fallthrough. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130404&r1=130403&r2=130404&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Apr 28 11:52:09 2011 @@ -1132,9 +1132,16 @@ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TstOpc)) .addReg(CmpReg).addImm(1)); + + unsigned CCMode = ARMCC::NE; + if (FuncInfo.MBB->isLayoutSuccessor(TBB)) { + std::swap(TBB, FBB); + CCMode = ARMCC::EQ; + } + unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc; BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc)) - .addMBB(TBB).addImm(ARMCC::NE).addReg(ARM::CPSR); + .addMBB(TBB).addImm(CCMode).addReg(ARM::CPSR); FastEmitBranch(FBB, DL); FuncInfo.MBB->addSuccessor(TBB); return true; From benny.kra at googlemail.com Thu Apr 28 11:58:40 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 28 Apr 2011 16:58:40 -0000 Subject: [llvm-commits] [llvm] r130405 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/merge-icmp.ll Message-ID: <20110428165840.461172A6C135@llvm.org> Author: d0k Date: Thu Apr 28 11:58:40 2011 New Revision: 130405 URL: http://llvm.org/viewvc/llvm-project?rev=130405&view=rev Log: InstCombine: Merge "(trunc x) == C1 & (and x, CA) == C2" into a single and+icmp. This happens when GVN widens loads. Part of PR6627. Added: llvm/trunk/test/Transforms/InstCombine/merge-icmp.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=130405&r1=130404&r2=130405&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 28 11:58:40 2011 @@ -769,6 +769,42 @@ return Builder->CreateICmp(LHSCC, NewOr, LHSCst); } } + + // (trunc x) == C1 & (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 + // where CMAX is the all ones value for the truncated type, + // iff the lower bits of CA are zero. + if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) && + LHS->hasOneUse() && RHS->hasOneUse()) { + Value *V; + ConstantInt *AndCst, *SmallCst = 0, *BigCst = 0; + + // (trunc x) == C1 & (and x, CA) == C2 + if (match(Val2, m_Trunc(m_Value(V))) && + match(Val, m_And(m_Specific(V), m_ConstantInt(AndCst)))) { + SmallCst = RHSCst; + BigCst = LHSCst; + } + // (and x, CA) == C2 & (trunc x) == C1 + else if (match(Val, m_Trunc(m_Value(V))) && + match(Val2, m_And(m_Specific(V), m_ConstantInt(AndCst)))) { + SmallCst = LHSCst; + BigCst = RHSCst; + } + + if (SmallCst && BigCst) { + unsigned BigBitSize = BigCst->getType()->getBitWidth(); + unsigned SmallBitSize = SmallCst->getType()->getBitWidth(); + + // Check that the low bits are zero. + APInt Low = APInt::getLowBitsSet(BigBitSize, SmallBitSize); + if ((Low & AndCst->getValue()) == 0) { + Value *NewAnd = Builder->CreateAnd(V, Low | AndCst->getValue()); + APInt N = SmallCst->getValue().zext(BigBitSize) | BigCst->getValue(); + Value *NewVal = ConstantInt::get(AndCst->getType()->getContext(), N); + return Builder->CreateICmp(LHSCC, NewAnd, NewVal); + } + } + } // From here on, we only handle: // (icmp1 A, C1) & (icmp2 A, C2) --> something simpler. Added: llvm/trunk/test/Transforms/InstCombine/merge-icmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/merge-icmp.ll?rev=130405&view=auto ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/merge-icmp.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/merge-icmp.ll Thu Apr 28 11:58:40 2011 @@ -0,0 +1,29 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s + +define i1 @test1(i16* %x) { + %load = load i16* %x, align 4 + %trunc = trunc i16 %load to i8 + %cmp1 = icmp eq i8 %trunc, 127 + %and = and i16 %load, -256 + %cmp2 = icmp eq i16 %and, 17664 + %or = and i1 %cmp1, %cmp2 + ret i1 %or +; CHECK: @test1 +; CHECK-NEXT: load i16 +; CHECK-NEXT: icmp eq i16 %load, 17791 +; CHECK-NEXT: ret i1 +} + +define i1 @test2(i16* %x) { + %load = load i16* %x, align 4 + %and = and i16 %load, -256 + %cmp1 = icmp eq i16 %and, 32512 + %trunc = trunc i16 %load to i8 + %cmp2 = icmp eq i8 %trunc, 69 + %or = and i1 %cmp1, %cmp2 + ret i1 %or +; CHECK: @test2 +; CHECK-NEXT: load i16 +; CHECK-NEXT: icmp eq i16 %load, 32581 +; CHECK-NEXT: ret i1 +} From stuart at apple.com Thu Apr 28 11:59:08 2011 From: stuart at apple.com (Stuart Hastings) Date: Thu, 28 Apr 2011 16:59:08 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130406 - in /llvm-gcc-4.2/trunk/gcc: config/arm/llvm-arm-target.h config/arm/llvm-arm.cpp config/i386/llvm-i386-target.h config/mips/llvm-mips-target.h config/rs6000/rs6000.h config/sparc/sparc.h llvm-abi-default.cpp llvm-abi.h llvm-convert.cpp Message-ID: <20110428165908.6C0502A6C135@llvm.org> Author: stuart Date: Thu Apr 28 11:59:08 2011 New Revision: 130406 URL: http://llvm.org/viewvc/llvm-project?rev=130406&view=rev Log: Enable byval for ARM in LLVM-GCC. rdar://problem/7662569 Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h llvm-gcc-4.2/trunk/gcc/config/sparc/sparc.h llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Thu Apr 28 11:59:08 2011 @@ -98,6 +98,14 @@ #define LLVM_SHOULD_NOT_USE_SHADOW_RETURN(X, CC) \ llvm_arm_should_pass_or_return_aggregate_in_regs((X), (CC)) +extern +bool llvm_arm_should_pass_aggregate_using_byval_attr(tree, const Type *, + CallingConv::ID &CC); + +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ + (llvm_arm_should_pass_aggregate_using_byval_attr((X), (TY), (CC))) + + /* Vectors bigger than 128 are returned using sret. */ #define LLVM_SHOULD_RETURN_VECTOR_AS_SHADOW(X, isBuiltin) \ (TREE_INT_CST_LOW(TYPE_SIZE(X)) > 128) Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Thu Apr 28 11:59:08 2011 @@ -2873,4 +2873,19 @@ return result && !TREE_ADDRESSABLE(TreeType); } +/* Target hook for llvm-abi.h. It returns true if an aggregate of the + specified type should be passed with the 'byval' attribute. */ +bool llvm_arm_should_pass_aggregate_using_byval_attr(tree TreeType, + const Type *Ty, + CallingConv::ID &CC) { + if (CC == CallingConv::ARM_APCS) { + enum machine_mode Mode = TYPE_MODE(TreeType); + HOST_WIDE_INT Bytes = + (Mode == BLKmode) ? int_size_in_bytes(TreeType) : (int) GET_MODE_SIZE(Mode); + + return Bytes > 32; + } else + return false; +} + /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Thu Apr 28 11:59:08 2011 @@ -227,7 +227,7 @@ extern bool llvm_x86_should_pass_aggregate_in_memory(tree, const Type *); -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_x86_should_pass_aggregate_in_memory(X, TY) Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips-target.h Thu Apr 28 11:59:08 2011 @@ -27,7 +27,7 @@ /* LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR - Return true if this aggregate value should be passed by value, i.e. passing its address with the byval attribute bit set. The default is false. */ -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_mips_should_pass_aggregate_in_memory(X, TY) extern bool Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Thu Apr 28 11:59:08 2011 @@ -3499,7 +3499,7 @@ extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *); -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_rs6000_should_pass_aggregate_byval((X), (TY)) extern bool llvm_rs6000_should_pass_vector_in_integer_regs(tree); Modified: llvm-gcc-4.2/trunk/gcc/config/sparc/sparc.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/sparc/sparc.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/sparc/sparc.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/sparc/sparc.h Thu Apr 28 11:59:08 2011 @@ -2488,7 +2488,7 @@ */ #define LLVM_TARGET_NAME Sparc -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ true #endif /* ENABLE_LLVM */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Thu Apr 28 11:59:08 2011 @@ -117,7 +117,7 @@ Attribute::constructAlignmentFromInt(LLVM_BYVAL_ALIGNMENT(type)); } } - } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) { + } else if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty, C.getCallingConv())) { C.HandleByValArgument(Ty, type); if (Attributes) { *Attributes |= Attribute::ByVal; @@ -144,7 +144,7 @@ // (We know there currently are no other such cases active because // they would hit the assert in FunctionPrologArgumentConversion:: // HandleByValArgument.) - if (!LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(Ftype, FTy)) { + if (!LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(Ftype, FTy, C.getCallingConv())) { C.EnterField(FNo, Ty); HandleArgument(getDeclaredType(Field), ScalarElts); C.ExitField(); Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Thu Apr 28 11:59:08 2011 @@ -274,7 +274,7 @@ // value should be passed by value, i.e. passing its address with the byval // attribute bit set. The default is false. #ifndef LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ false #endif Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=130406&r1=130405&r2=130406&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Thu Apr 28 11:59:08 2011 @@ -437,7 +437,7 @@ static bool isPassedByVal(tree type, const Type *Ty, std::vector &ScalarArgs, CallingConv::ID &CC) { - if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty)) + if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty, CC)) return true; std::vector Args; From atrick at apple.com Thu Apr 28 12:30:04 2011 From: atrick at apple.com (Andrew Trick) Date: Thu, 28 Apr 2011 17:30:04 -0000 Subject: [llvm-commits] [llvm] r130408 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110428173004.E7D732A6C135@llvm.org> Author: atrick Date: Thu Apr 28 12:30:04 2011 New Revision: 130408 URL: http://llvm.org/viewvc/llvm-project?rev=130408&view=rev Log: Reapply r130340: Fix for PR9730. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=130408&r1=130407&r2=130408&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Thu Apr 28 12:30:04 2011 @@ -275,7 +275,7 @@ // update the branch to use the new comparison; in the common case this // will make old comparison dead. BI->setCondition(Cond); - RecursivelyDeleteTriviallyDeadInstructions(OrigCond); + DeadInsts.push_back(OrigCond); ++NumLFTR; Changed = true; From dpatel at apple.com Thu Apr 28 12:41:38 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 17:41:38 -0000 Subject: [llvm-commits] [llvm] r130409 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <20110428174138.4D5332A6C135@llvm.org> Author: dpatel Date: Thu Apr 28 12:41:38 2011 New Revision: 130409 URL: http://llvm.org/viewvc/llvm-project?rev=130409&view=rev Log: Add command line option to print debug info in human readable form as comment in llvm IR output. This, i.e -enable-debug-info-comment, is very useful if you want to easily find out which optimization pass is losing line number information. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=130409&r1=130408&r2=130409&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Thu Apr 28 12:41:38 2011 @@ -32,6 +32,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/ErrorHandling.h" @@ -41,6 +42,11 @@ #include using namespace llvm; +static cl::opt +EnableDebugInfoComment("enable-debug-info-comment", cl::Hidden, + cl::desc("Enable debug info comments")); + + // Make virtual table appear in this compilation unit. AssemblyAnnotationWriter::~AssemblyAnnotationWriter() {} @@ -1729,6 +1735,18 @@ if (AnnotationWriter) AnnotationWriter->emitBasicBlockEndAnnot(BB, Out); } +/// printDebugLoc - Print DebugLoc. +static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) { + OS << DL.getLine() << ":" << DL.getCol(); + if (MDNode *N = DL.getInlinedAt(getGlobalContext())) { + DebugLoc IDL = DebugLoc::getFromDILocation(N); + if (!IDL.isUnknown()) { + OS << "@"; + printDebugLoc(IDL,OS); + } + } +} + /// printInfoComment - Print a little comment after the instruction indicating /// which slot it occupies. /// @@ -1736,6 +1754,43 @@ if (AnnotationWriter) { AnnotationWriter->printInfoComment(V, Out); return; + } else if (EnableDebugInfoComment) { + bool Padded = false; + if (const Instruction *I = dyn_cast(&V)) { + const DebugLoc &DL = I->getDebugLoc(); + if (!DL.isUnknown()) { + if (!Padded) { + Out.PadToColumn(50); + Padded = true; + Out << ";"; + } + Out << " [debug line = "; + printDebugLoc(DL,Out); + Out << "]"; + } + if (const DbgDeclareInst *DDI = dyn_cast(I)) { + const MDNode *Var = DDI->getVariable(); + if (!Padded) { + Out.PadToColumn(50); + Padded = true; + Out << ";"; + } + if (Var && Var->getNumOperands() >= 2) + if (MDString *MDS = dyn_cast_or_null(Var->getOperand(2))) + Out << " [debug variable = " << MDS->getString() << "]"; + } + else if (const DbgValueInst *DVI = dyn_cast(I)) { + const MDNode *Var = DVI->getVariable(); + if (!Padded) { + Out.PadToColumn(50); + Padded = true; + Out << ";"; + } + if (Var && Var->getNumOperands() >= 2) + if (MDString *MDS = dyn_cast_or_null(Var->getOperand(2))) + Out << " [debug variable = " << MDS->getString() << "]"; + } + } } } From resistor at mac.com Thu Apr 28 12:51:45 2011 From: resistor at mac.com (Owen Anderson) Date: Thu, 28 Apr 2011 17:51:45 -0000 Subject: [llvm-commits] [llvm] r130410 - /llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Message-ID: <20110428175145.CF8502A6C135@llvm.org> Author: resistor Date: Thu Apr 28 12:51:45 2011 New Revision: 130410 URL: http://llvm.org/viewvc/llvm-project?rev=130410&view=rev Log: Fix a bug in tblgen that caused incorrect encodings on instructions that specified operands with "bit" instead of "bits<1>". Unfortunately, my only testcase for this is fragile, and the ARM AsmParser can't round trip the instruction in question. Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=130410&r1=130409&r2=130410&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Thu Apr 28 12:51:45 2011 @@ -63,10 +63,14 @@ // return the variable bit position. Otherwise return -1. int CodeEmitterGen::getVariableBit(const std::string &VarName, BitsInit *BI, int bit) { - if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) + if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { if (VarInit *VI = dynamic_cast(VBI->getVariable())) if (VI->getName() == VarName) return VBI->getBitNum(); + } else if (VarInit *VI = dynamic_cast(BI->getBit(bit))) { + if (VI->getName() == VarName) + return 0; + } return -1; } From eli.friedman at gmail.com Thu Apr 28 13:06:10 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 18:06:10 -0000 Subject: [llvm-commits] [llvm] r130412 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll Message-ID: <20110428180610.CDAF32A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 13:06:10 2011 New Revision: 130412 URL: http://llvm.org/viewvc/llvm-project?rev=130412&view=rev Log: Revert r130348; causing buildbot issues on x86-32. Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130412&r1=130411&r2=130412&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Apr 28 13:06:10 2011 @@ -1618,6 +1618,7 @@ // FIXME: Only handle *easy* calls for now. if (CS.paramHasAttr(AttrInd, Attribute::InReg) || + CS.paramHasAttr(AttrInd, Attribute::StructRet) || CS.paramHasAttr(AttrInd, Attribute::Nest) || CS.paramHasAttr(AttrInd, Attribute::ByVal)) return false; Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130412&r1=130411&r2=130412&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Thu Apr 28 13:06:10 2011 @@ -260,3 +260,16 @@ ; CHECK-NOT: pxor ; CHECK: movsd LCPI } + +; Check that we fast-isel sret +%struct.a = type { i64, i64, i64 } +define void @test20() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test20sret(%struct.a* sret %tmp) + ret void +; CHECK: test20: +; CHECK: leaq (%rsp), %rdi +; CHECK: callq _test20sret +} +declare void @test20sret(%struct.a* sret) From sabre at nondot.org Thu Apr 28 13:08:21 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 18:08:21 -0000 Subject: [llvm-commits] [llvm] r130414 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <20110428180822.0515B2A6C135@llvm.org> Author: lattner Date: Thu Apr 28 13:08:21 2011 New Revision: 130414 URL: http://llvm.org/viewvc/llvm-project?rev=130414&view=rev Log: code cleanups only. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130414&r1=130413&r2=130414&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 13:08:21 2011 @@ -63,50 +63,48 @@ namespace { struct Expression { uint32_t opcode; - const Type* type; + const Type *type; SmallVector varargs; - Expression() { } - Expression(uint32_t o) : opcode(o) { } + Expression(uint32_t o = ~2U) : opcode(o) { } bool operator==(const Expression &other) const { if (opcode != other.opcode) return false; - else if (opcode == ~0U || opcode == ~1U) + if (opcode == ~0U || opcode == ~1U) return true; - else if (type != other.type) + if (type != other.type) return false; - else if (varargs != other.varargs) + if (varargs != other.varargs) return false; return true; } }; class ValueTable { - private: - DenseMap valueNumbering; - DenseMap expressionNumbering; - AliasAnalysis* AA; - MemoryDependenceAnalysis* MD; - DominatorTree* DT; - - uint32_t nextValueNumber; - - Expression create_expression(Instruction* I); - uint32_t lookup_or_add_call(CallInst* C); - public: - ValueTable() : nextValueNumber(1) { } - uint32_t lookup_or_add(Value *V); - uint32_t lookup(Value *V) const; - void add(Value *V, uint32_t num); - void clear(); - void erase(Value *v); - void setAliasAnalysis(AliasAnalysis* A) { AA = A; } - AliasAnalysis *getAliasAnalysis() const { return AA; } - void setMemDep(MemoryDependenceAnalysis* M) { MD = M; } - void setDomTree(DominatorTree* D) { DT = D; } - uint32_t getNextUnusedValueNumber() { return nextValueNumber; } - void verifyRemoved(const Value *) const; + DenseMap valueNumbering; + DenseMap expressionNumbering; + AliasAnalysis *AA; + MemoryDependenceAnalysis *MD; + DominatorTree *DT; + + uint32_t nextValueNumber; + + Expression create_expression(Instruction* I); + uint32_t lookup_or_add_call(CallInst* C); + public: + ValueTable() : nextValueNumber(1) { } + uint32_t lookup_or_add(Value *V); + uint32_t lookup(Value *V) const; + void add(Value *V, uint32_t num); + void clear(); + void erase(Value *v); + void setAliasAnalysis(AliasAnalysis* A) { AA = A; } + AliasAnalysis *getAliasAnalysis() const { return AA; } + void setMemDep(MemoryDependenceAnalysis* M) { MD = M; } + void setDomTree(DominatorTree* D) { DT = D; } + uint32_t getNextUnusedValueNumber() { return nextValueNumber; } + void verifyRemoved(const Value *) const; }; } @@ -364,14 +362,14 @@ return VI->second; } -/// clear - Remove all entries from the ValueTable +/// clear - Remove all entries from the ValueTable. void ValueTable::clear() { valueNumbering.clear(); expressionNumbering.clear(); nextValueNumber = 1; } -/// erase - Remove a value from the value numbering +/// erase - Remove a value from the value numbering. void ValueTable::erase(Value *V) { valueNumbering.erase(V); } @@ -393,9 +391,7 @@ class GVN : public FunctionPass { bool NoLoads; - public: MemoryDependenceAnalysis *MD; - private: DominatorTree *DT; const TargetData *TD; @@ -431,6 +427,7 @@ const TargetData *getTargetData() const { return TD; } DominatorTree &getDominatorTree() const { return *DT; } AliasAnalysis *getAliasAnalysis() const { return VN.getAliasAnalysis(); } + MemoryDependenceAnalysis &getMemDep() const { return *MD; } private: /// addToLeaderTable - Push a new Value to the LeaderTable onto the list for /// its value number. @@ -969,8 +966,7 @@ NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits()); RV = Builder.CreateTrunc(RV, SrcVal->getType()); SrcVal->replaceAllUsesWith(RV); - gvn.MD->removeInstruction(SrcVal); - //gvn.markInstructionForDeletion(SrcVal); + gvn.getMemDep().removeInstruction(SrcVal); SrcVal = NewLoad; } From aggarwa4 at illinois.edu Thu Apr 28 13:11:37 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 28 Apr 2011 18:11:37 -0000 Subject: [llvm-commits] [poolalloc] r130415 - in /poolalloc/trunk/lib/AssistDS: GEPExprArg.cpp LoadArgs.cpp Message-ID: <20110428181137.BACFE2A6C135@llvm.org> Author: aggarwa4 Date: Thu Apr 28 13:11:37 2011 New Revision: 130415 URL: http://llvm.org/viewvc/llvm-project?rev=130415&view=rev Log: Repeat in a loop, to find more cases. Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Modified: poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp?rev=130415&r1=130414&r2=130415&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp (original) +++ poolalloc/trunk/lib/AssistDS/GEPExprArg.cpp Thu Apr 28 13:11:37 2011 @@ -35,112 +35,117 @@ static char ID; GEPExprArg() : ModulePass(&ID) {} bool runOnModule(Module& M) { - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - CallInst *CI = dyn_cast(I++); - if(!CI) - continue; - - if(CI->hasByValArgument()) - continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); - - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; - - // find the argument we must replace - Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++, ++ai) { - if(ai->use_empty()) + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + CallInst *CI = dyn_cast(I++); + if(!CI) continue; - if (isa(CI->getOperand(argNum))) - break; - } - // if no argument was a GEP operator to be changed - if(ai == ae) - continue; - - GEPOperator *GEP = dyn_cast(CI->getOperand(argNum)); - if(!GEP->hasAllConstantIndices()) - continue; - - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(GEP->getPointerOperand()->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } + if(CI->hasByValArgument()) + continue; + // if the GEP calls a function, that is externally defined, + // or might be changed, ignore this call site. + Function *F = CI->getCalledFunction(); - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; - numSimplified++; - if(numSimplified > 1000) - return true; - - NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } + if (!F || (F->isDeclaration() || F->mayBeOverridden())) + continue; + if(F->hasStructRetAttr()) + continue; + if(F->isVarArg()) + continue; - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - SmallVector Ops(CI->op_begin()+1, CI->op_end()); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - SmallVector Indices; - Indices.append(GEP->op_begin()+1, GEP->op_end()); - GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(GEP_new); - unsigned j = argNum + 1; - for(; j < CI->getNumOperands();j++) { - if(CI->getOperand(j) == GEP) - fargs.at(j)->replaceAllUsesWith(GEP_new); - } + // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); + unsigned argNum = 1; + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) + continue; + if (isa(CI->getOperand(argNum))) + break; + } + + // if no argument was a GEP operator to be changed + if(ai == ae) + continue; + + GEPOperator *GEP = dyn_cast(CI->getOperand(argNum)); + if(!GEP->hasAllConstantIndices()) + continue; - SmallVector Args; - Args.push_back(GEP->getPointerOperand()); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); + // Construct the new Type + // Appends the struct Type at the beginning + std::vectorTP; + TP.push_back(GEP->getPointerOperand()->getType()); + for(unsigned c = 1; c < CI->getNumOperands();c++) { + TP.push_back(CI->getOperand(c)->getType()); + } + + //return type is same as that of original instruction + const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); + Function *NewF; + numSimplified++; + if(numSimplified > 1000) + return true; + + NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F->getNameStr() + ".TEST", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + NI->setName("Sarg"); + ++NI; + + DenseMap ValueMap; + + for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + ValueMap[II] = NI; + NI->setName(II->getName()); + } + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, F, ValueMap, Returns); + std::vector fargs; + for(Function::arg_iterator ai = NewF->arg_begin(), + ae= NewF->arg_end(); ai != ae; ++ai) { + fargs.push_back(ai); + } + + NewF->setAlignment(F->getAlignment()); + //Get the point to insert the GEP instr. + NI = NewF->arg_begin(); + SmallVector Ops(CI->op_begin()+1, CI->op_end()); + Instruction *InsertPoint; + for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} + + SmallVector Indices; + Indices.append(GEP->op_begin()+1, GEP->op_end()); + GetElementPtrInst *GEP_new = GetElementPtrInst::Create(cast(NI), Indices.begin(), Indices.end(), "", InsertPoint); + fargs.at(argNum)->replaceAllUsesWith(GEP_new); + unsigned j = argNum + 1; + for(; j < CI->getNumOperands();j++) { + if(CI->getOperand(j) == GEP) + fargs.at(j)->replaceAllUsesWith(GEP_new); + } + + SmallVector Args; + Args.push_back(GEP->getPointerOperand()); + for(unsigned j =1;jgetNumOperands();j++) { + Args.push_back(CI->getOperand(j)); + } + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); + changed = true; } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); } } - } + } while(changed); return true; } }; Modified: poolalloc/trunk/lib/AssistDS/LoadArgs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/LoadArgs.cpp?rev=130415&r1=130414&r2=130415&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/LoadArgs.cpp (original) +++ poolalloc/trunk/lib/AssistDS/LoadArgs.cpp Thu Apr 28 13:11:37 2011 @@ -35,125 +35,130 @@ static char ID; LoadArgs() : ModulePass(&ID) {} bool runOnModule(Module& M) { - for (Module::iterator F = M.begin(); F != M.end(); ++F){ - for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { - for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { - CallInst *CI = dyn_cast(I++); - if(!CI) - continue; - - if(CI->hasByValArgument()) - continue; - // if the GEP calls a function, that is externally defined, - // or might be changed, ignore this call site. - Function *F = CI->getCalledFunction(); - - if (!F || (F->isDeclaration() || F->mayBeOverridden())) - continue; - if(F->hasStructRetAttr()) - continue; - if(F->isVarArg()) - continue; - - // find the argument we must replace - Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); - unsigned argNum = 1; - for(; argNum < CI->getNumOperands();argNum++, ++ai) { - if(ai->use_empty()) + bool changed; + do { + changed = false; + for (Module::iterator F = M.begin(); F != M.end(); ++F){ + for (Function::iterator B = F->begin(), FE = F->end(); B != FE; ++B) { + for (BasicBlock::iterator I = B->begin(), BE = B->end(); I != BE;) { + CallInst *CI = dyn_cast(I++); + if(!CI) continue; - if(F->paramHasAttr(argNum, Attribute::SExt) || - F->paramHasAttr(argNum, Attribute::ZExt)) + + if(CI->hasByValArgument()) continue; - if (isa(CI->getOperand(argNum))) - break; - } + // if the GEP calls a function, that is externally defined, + // or might be changed, ignore this call site. + Function *F = CI->getCalledFunction(); - // if no argument was a GEP operator to be changed - if(ai == ae) - continue; - - LoadInst *LI = dyn_cast(CI->getOperand(argNum)); - if(LI->getParent() != CI->getParent()) - continue; - // Also check that there is no store after the load. - // TODO: Check if the load/store do not alias. - BasicBlock::iterator bii = LI->getParent()->begin(); - Instruction *BII = bii; - while(BII != LI) { - ++bii; - BII = bii; - } - while(BII != CI) { - if(isa(BII)) - break; - ++bii; - BII = bii; - } - if(isa(bii)){ - continue; - } + if (!F || (F->isDeclaration() || F->mayBeOverridden())) + continue; + if(F->hasStructRetAttr()) + continue; + if(F->isVarArg()) + continue; - // Construct the new Type - // Appends the struct Type at the beginning - std::vectorTP; - TP.push_back(LI->getOperand(0)->getType()); - for(unsigned c = 1; c < CI->getNumOperands();c++) { - TP.push_back(CI->getOperand(c)->getType()); - } + // find the argument we must replace + Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); + unsigned argNum = 1; + for(; argNum < CI->getNumOperands();argNum++, ++ai) { + if(ai->use_empty()) + continue; + if(F->paramHasAttr(argNum, Attribute::SExt) || + F->paramHasAttr(argNum, Attribute::ZExt)) + continue; + if (isa(CI->getOperand(argNum))) + break; + } - //return type is same as that of original instruction - const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); - Function *NewF; - numSimplified++; - if(numSimplified > 500) //26 - return true; - - NewF = Function::Create(NewFTy, - GlobalValue::InternalLinkage, - F->getNameStr() + ".TEST", - &M); - - Function::arg_iterator NI = NewF->arg_begin(); - NI->setName("Sarg"); - ++NI; - - DenseMap ValueMap; - - for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { - ValueMap[II] = NI; - NI->setName(II->getName()); - } - // Perform the cloning. - SmallVector Returns; - CloneFunctionInto(NewF, F, ValueMap, Returns); - std::vector fargs; - for(Function::arg_iterator ai = NewF->arg_begin(), - ae= NewF->arg_end(); ai != ae; ++ai) { - fargs.push_back(ai); - } + // if no argument was a GEP operator to be changed + if(ai == ae) + continue; + + LoadInst *LI = dyn_cast(CI->getOperand(argNum)); + if(LI->getParent() != CI->getParent()) + continue; + // Also check that there is no store after the load. + // TODO: Check if the load/store do not alias. + BasicBlock::iterator bii = LI->getParent()->begin(); + Instruction *BII = bii; + while(BII != LI) { + ++bii; + BII = bii; + } + while(BII != CI) { + if(isa(BII)) + break; + ++bii; + BII = bii; + } + if(isa(bii)){ + continue; + } - NewF->setAlignment(F->getAlignment()); - //Get the point to insert the GEP instr. - NI = NewF->arg_begin(); - SmallVector Ops(CI->op_begin()+1, CI->op_end()); - Instruction *InsertPoint; - for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} - - LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); - fargs.at(argNum)->replaceAllUsesWith(LI_new); - - SmallVector Args; - Args.push_back(LI->getOperand(0)); - for(unsigned j =1;jgetNumOperands();j++) { - Args.push_back(CI->getOperand(j)); + // Construct the new Type + // Appends the struct Type at the beginning + std::vectorTP; + TP.push_back(LI->getOperand(0)->getType()); + for(unsigned c = 1; c < CI->getNumOperands();c++) { + TP.push_back(CI->getOperand(c)->getType()); + } + + //return type is same as that of original instruction + const FunctionType *NewFTy = FunctionType::get(CI->getType(), TP, false); + Function *NewF; + numSimplified++; + if(numSimplified > 500) //26 + return true; + + NewF = Function::Create(NewFTy, + GlobalValue::InternalLinkage, + F->getNameStr() + ".TEST", + &M); + + Function::arg_iterator NI = NewF->arg_begin(); + NI->setName("Sarg"); + ++NI; + + DenseMap ValueMap; + + for (Function::arg_iterator II = F->arg_begin(); NI != NewF->arg_end(); ++II, ++NI) { + ValueMap[II] = NI; + NI->setName(II->getName()); + } + // Perform the cloning. + SmallVector Returns; + CloneFunctionInto(NewF, F, ValueMap, Returns); + std::vector fargs; + for(Function::arg_iterator ai = NewF->arg_begin(), + ae= NewF->arg_end(); ai != ae; ++ai) { + fargs.push_back(ai); + } + + NewF->setAlignment(F->getAlignment()); + //Get the point to insert the GEP instr. + NI = NewF->arg_begin(); + SmallVector Ops(CI->op_begin()+1, CI->op_end()); + Instruction *InsertPoint; + for (BasicBlock::iterator insrt = NewF->front().begin(); isa(InsertPoint = insrt); ++insrt) {;} + + LoadInst *LI_new = new LoadInst(cast(NI), "", InsertPoint); + fargs.at(argNum)->replaceAllUsesWith(LI_new); + + SmallVector Args; + Args.push_back(LI->getOperand(0)); + for(unsigned j =1;jgetNumOperands();j++) { + Args.push_back(CI->getOperand(j)); + } + CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); + CallI->setCallingConv(CI->getCallingConv()); + CI->replaceAllUsesWith(CallI); + CI->eraseFromParent(); + changed = true; } - CallInst *CallI = CallInst::Create(NewF,Args.begin(), Args.end(),"", CI); - CallI->setCallingConv(CI->getCallingConv()); - CI->replaceAllUsesWith(CallI); - CI->eraseFromParent(); } } - } + } while(changed); return true; } }; From sabre at nondot.org Thu Apr 28 13:15:48 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 18:15:48 -0000 Subject: [llvm-commits] [llvm] r130416 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/PhaseOrdering/basic.ll Message-ID: <20110428181548.2175C2A6C135@llvm.org> Author: lattner Date: Thu Apr 28 13:15:47 2011 New Revision: 130416 URL: http://llvm.org/viewvc/llvm-project?rev=130416&view=rev Log: final step needed to resolve PR6627, which allows us to flatten the code down to a nice and tidy: %x1 = load i32* %0, align 4 %1 = icmp eq i32 %x1, 1179403647 br i1 %1, label %if.then, label %if.end instead of doing lots of loads and branches. May the FreeBSD bootloader long fit in its allocated space. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/rle.ll llvm/trunk/test/Transforms/PhaseOrdering/basic.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130416&r1=130415&r2=130416&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 13:15:47 2011 @@ -432,14 +432,14 @@ /// addToLeaderTable - Push a new Value to the LeaderTable onto the list for /// its value number. void addToLeaderTable(uint32_t N, Value *V, BasicBlock *BB) { - LeaderTableEntry& Curr = LeaderTable[N]; + LeaderTableEntry &Curr = LeaderTable[N]; if (!Curr.Val) { Curr.Val = V; Curr.BB = BB; return; } - LeaderTableEntry* Node = TableAllocator.Allocate(); + LeaderTableEntry *Node = TableAllocator.Allocate(); Node->Val = V; Node->BB = BB; Node->Next = Curr.Next; @@ -944,7 +944,10 @@ Value *PtrVal = SrcVal->getPointerOperand(); - IRBuilder<> Builder(SrcVal->getParent(), SrcVal); + // Insert the new load after the old load. This ensures that subsequent + // memdep queries will find the new load. We can't easily remove the old + // load completely because it is already in the value numbering table. + IRBuilder<> Builder(SrcVal->getParent(), ++BasicBlock::iterator(SrcVal)); const Type *DestPTy = IntegerType::get(LoadTy->getContext(), NewLoadSize*8); DestPTy = PointerType::get(DestPTy, @@ -967,6 +970,7 @@ RV = Builder.CreateTrunc(RV, SrcVal->getType()); SrcVal->replaceAllUsesWith(RV); gvn.getMemDep().removeInstruction(SrcVal); + //gvn.markInstructionForDeletion(SrcVal); SrcVal = NewLoad; } Modified: llvm/trunk/test/Transforms/GVN/rle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/rle.ll?rev=130416&r1=130415&r2=130416&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/rle.ll (original) +++ llvm/trunk/test/Transforms/GVN/rle.ll Thu Apr 28 13:15:47 2011 @@ -1,4 +1,4 @@ -; RUN: opt < %s -basicaa -gvn -S | FileCheck %s +; RUN: opt < %s -basicaa -gvn -S -die | FileCheck %s ; 32-bit little endian target. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32" @@ -597,11 +597,11 @@ ;; Load Widening ;;===----------------------------------------------------------------------===;; -%widening1 = type { i32, i8, i8 } +%widening1 = type { i32, i8, i8, i8, i8 } @f = global %widening1 zeroinitializer, align 4 -define i32 @test_widening1() nounwind ssp noredzone { +define i32 @test_widening1(i8* %P) nounwind ssp noredzone { entry: %tmp = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 1), align 4 %conv = zext i8 %tmp to i32 @@ -616,4 +616,27 @@ ; CHECK-ret i32 } +define i32 @test_widening2() nounwind ssp noredzone { +entry: + %tmp = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 1), align 4 + %conv = zext i8 %tmp to i32 + %tmp1 = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 2), align 1 + %conv2 = zext i8 %tmp1 to i32 + %add = add nsw i32 %conv, %conv2 + + %tmp2 = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 3), align 2 + %conv3 = zext i8 %tmp2 to i32 + %add2 = add nsw i32 %add, %conv3 + + %tmp3 = load i8* getelementptr inbounds (%widening1* @f, i64 0, i32 4), align 1 + %conv4 = zext i8 %tmp3 to i32 + %add3 = add nsw i32 %add2, %conv3 + + ret i32 %add3 +; CHECK: @test_widening2 +; CHECK-NOT: load +; CHECK: load i32* +; CHECK-NOT: load +; CHECK-ret i32 +} Modified: llvm/trunk/test/Transforms/PhaseOrdering/basic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PhaseOrdering/basic.ll?rev=130416&r1=130415&r2=130416&view=diff ============================================================================== --- llvm/trunk/test/Transforms/PhaseOrdering/basic.ll (original) +++ llvm/trunk/test/Transforms/PhaseOrdering/basic.ll Thu Apr 28 13:15:47 2011 @@ -60,7 +60,7 @@ %call25 = call i32 (...)* @doo() br label %if.end -if.end: ; preds = %if.then, %land.lhs.true17, %land.lhs.true9, %land.lhs.true, %entry +if.end: ret void ; CHECK: @test2 @@ -71,3 +71,47 @@ declare i32 @doo(...) +; PR6627 - This should all be flattened down to one compare. This is the same +; as test2, except that the initial load is done as an i8 instead of i32, thus +; requiring widening. +define void @test2a(i8* %arrayidx) nounwind ssp { +entry: + %x1 = load i8* %arrayidx, align 4 + %conv = zext i8 %x1 to i32 + %cmp = icmp eq i32 %conv, 127 + br i1 %cmp, label %land.lhs.true, label %if.end + +land.lhs.true: ; preds = %entry + %arrayidx4 = getelementptr inbounds i8* %arrayidx, i64 1 + %tmp5 = load i8* %arrayidx4, align 1 + %conv6 = zext i8 %tmp5 to i32 + %cmp7 = icmp eq i32 %conv6, 69 + br i1 %cmp7, label %land.lhs.true9, label %if.end + +land.lhs.true9: ; preds = %land.lhs.true + %arrayidx12 = getelementptr inbounds i8* %arrayidx, i64 2 + %tmp13 = load i8* %arrayidx12, align 1 + %conv14 = zext i8 %tmp13 to i32 + %cmp15 = icmp eq i32 %conv14, 76 + br i1 %cmp15, label %land.lhs.true17, label %if.end + +land.lhs.true17: ; preds = %land.lhs.true9 + %arrayidx20 = getelementptr inbounds i8* %arrayidx, i64 3 + %tmp21 = load i8* %arrayidx20, align 1 + %conv22 = zext i8 %tmp21 to i32 + %cmp23 = icmp eq i32 %conv22, 70 + br i1 %cmp23, label %if.then, label %if.end + +if.then: ; preds = %land.lhs.true17 + %call25 = call i32 (...)* @doo() + br label %if.end + +if.end: + ret void + +; CHECK: @test2a +; CHECK: %x1 = load i32* {{.*}}, align 4 +; CHECK-NEXT: icmp eq i32 %x1, 1179403647 +; CHECK-NEXT: br i1 {{.*}}, label %if.then, label %if.end +} + From eli.friedman at gmail.com Thu Apr 28 13:20:24 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 18:20:24 -0000 Subject: [llvm-commits] [llvm] r130418 - /llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Message-ID: <20110428182024.7EE532A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 13:20:24 2011 New Revision: 130418 URL: http://llvm.org/viewvc/llvm-project?rev=130418&view=rev Log: Actually revert r130348 correctly. Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130418&r1=130417&r2=130418&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Thu Apr 28 13:20:24 2011 @@ -239,19 +239,6 @@ ; CHECK: pxor } -; Check that we fast-isel sret -%struct.a = type { i64, i64, i64 } -define void @test20() nounwind ssp { -entry: - %tmp = alloca %struct.a, align 8 - call void @test20sret(%struct.a* sret %tmp) - ret void -; CHECK: test20: -; CHECK: leaq (%rsp), %rdi -; CHECK: callq _test20sret -} -declare void @test20sret(%struct.a* sret) - ; Check that -0.0 is not materialized using pxor define void @test21(double* %p1) { store double -0.0, double* %p1 @@ -259,17 +246,4 @@ ; CHECK: test21: ; CHECK-NOT: pxor ; CHECK: movsd LCPI -} - -; Check that we fast-isel sret -%struct.a = type { i64, i64, i64 } -define void @test20() nounwind ssp { -entry: - %tmp = alloca %struct.a, align 8 - call void @test20sret(%struct.a* sret %tmp) - ret void -; CHECK: test20: -; CHECK: leaq (%rsp), %rdi -; CHECK: callq _test20sret -} -declare void @test20sret(%struct.a* sret) +} \ No newline at end of file From dpatel at apple.com Thu Apr 28 13:43:39 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 18:43:39 -0000 Subject: [llvm-commits] [llvm] r130419 - /llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Message-ID: <20110428184339.48C472A6C135@llvm.org> Author: dpatel Date: Thu Apr 28 13:43:39 2011 New Revision: 130419 URL: http://llvm.org/viewvc/llvm-project?rev=130419&view=rev Log: Do not lose line number info while eliminating tail call. Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=130419&r1=130418&r2=130419&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Thu Apr 28 13:43:39 2011 @@ -573,7 +573,9 @@ // Now that all of the PHI nodes are in place, remove the call and // ret instructions, replacing them with an unconditional branch. - BranchInst::Create(OldEntry, Ret); + BranchInst *NewBI = BranchInst::Create(OldEntry, Ret); + NewBI->setDebugLoc(CI->getDebugLoc()); + BB->getInstList().erase(Ret); // Remove return. BB->getInstList().erase(CI); // Remove call. ++NumEliminated; From baldrick at free.fr Thu Apr 28 14:57:41 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 28 Apr 2011 21:57:41 +0200 Subject: [llvm-commits] [llvm] r130416 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/PhaseOrdering/basic.ll In-Reply-To: <20110428181548.2175C2A6C135@llvm.org> References: <20110428181548.2175C2A6C135@llvm.org> Message-ID: <4DB9C6B5.7070002@free.fr> Hi Chris, > --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 13:15:47 2011 > @@ -967,6 +970,7 @@ > RV = Builder.CreateTrunc(RV, SrcVal->getType()); > SrcVal->replaceAllUsesWith(RV); > gvn.getMemDep().removeInstruction(SrcVal); > + //gvn.markInstructionForDeletion(SrcVal); > SrcVal = NewLoad; > } I guess you didn't mean to commit this bit :) Ciao, Duncan. From baldrick at free.fr Thu Apr 28 15:03:02 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 28 Apr 2011 22:03:02 +0200 Subject: [llvm-commits] [llvm] r130405 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/merge-icmp.ll In-Reply-To: <20110428165840.461172A6C135@llvm.org> References: <20110428165840.461172A6C135@llvm.org> Message-ID: <4DB9C7F6.9000506@free.fr> Hi Benjamin, > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 28 11:58:40 2011 > @@ -769,6 +769,42 @@ > return Builder->CreateICmp(LHSCC, NewOr, LHSCst); > } > } > + > + // (trunc x) == C1& (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 I guess this should be: (and x, CA|CMAX) == C1|C2 Ciao, Duncan. From sabre at nondot.org Thu Apr 28 15:02:57 2011 From: sabre at nondot.org (Chris Lattner) Date: Thu, 28 Apr 2011 20:02:57 -0000 Subject: [llvm-commits] [llvm] r130426 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp Message-ID: <20110428200257.BAC042A6C135@llvm.org> Author: lattner Date: Thu Apr 28 15:02:57 2011 New Revision: 130426 URL: http://llvm.org/viewvc/llvm-project?rev=130426&view=rev Log: improve comment. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=130426&r1=130425&r2=130426&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 15:02:57 2011 @@ -969,8 +969,13 @@ NewLoadSize*8-SrcVal->getType()->getPrimitiveSizeInBits()); RV = Builder.CreateTrunc(RV, SrcVal->getType()); SrcVal->replaceAllUsesWith(RV); + + // We would like to use gvn.markInstructionForDeletion here, but we can't + // because the load is already memoized into the leader map table that GVN + // tracks. It is potentially possible to remove the load from the table, + // but then there all of the operations based on it would need to be + // rehashed. Just leave the dead load around. gvn.getMemDep().removeInstruction(SrcVal); - //gvn.markInstructionForDeletion(SrcVal); SrcVal = NewLoad; } From clattner at apple.com Thu Apr 28 15:07:57 2011 From: clattner at apple.com (Chris Lattner) Date: Thu, 28 Apr 2011 13:07:57 -0700 Subject: [llvm-commits] [llvm] r130416 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/rle.ll test/Transforms/PhaseOrdering/basic.ll In-Reply-To: <4DB9C6B5.7070002@free.fr> References: <20110428181548.2175C2A6C135@llvm.org> <4DB9C6B5.7070002@free.fr> Message-ID: On Apr 28, 2011, at 12:57 PM, Duncan Sands wrote: > Hi Chris, > >> --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Apr 28 13:15:47 2011 >> @@ -967,6 +970,7 @@ >> RV = Builder.CreateTrunc(RV, SrcVal->getType()); >> SrcVal->replaceAllUsesWith(RV); >> gvn.getMemDep().removeInstruction(SrcVal); >> + //gvn.markInstructionForDeletion(SrcVal); >> SrcVal = NewLoad; >> } > > I guess you didn't mean to commit this bit :) Fixed in r130426, thanks. -Chris From benny.kra at googlemail.com Thu Apr 28 15:09:57 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 28 Apr 2011 20:09:57 -0000 Subject: [llvm-commits] [llvm] r130428 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Message-ID: <20110428200957.62B842A6C135@llvm.org> Author: d0k Date: Thu Apr 28 15:09:57 2011 New Revision: 130428 URL: http://llvm.org/viewvc/llvm-project?rev=130428&view=rev Log: Fix a comment. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=130428&r1=130427&r2=130428&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 28 15:09:57 2011 @@ -770,7 +770,7 @@ } } - // (trunc x) == C1 & (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 + // (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2 // where CMAX is the all ones value for the truncated type, // iff the lower bits of CA are zero. if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) && From benny.kra at googlemail.com Thu Apr 28 15:15:16 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 28 Apr 2011 22:15:16 +0200 Subject: [llvm-commits] [llvm] r130405 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/merge-icmp.ll In-Reply-To: <4DB9C7F6.9000506@free.fr> References: <20110428165840.461172A6C135@llvm.org> <4DB9C7F6.9000506@free.fr> Message-ID: On 28.04.2011, at 22:03, Duncan Sands wrote: > Hi Benjamin, > >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 28 11:58:40 2011 >> @@ -769,6 +769,42 @@ >> return Builder->CreateICmp(LHSCC, NewOr, LHSCst); >> } >> } >> + >> + // (trunc x) == C1& (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 > > I guess this should be: (and x, CA|CMAX) == C1|C2 Yes, of course. Fixed in r130428. From baldrick at free.fr Thu Apr 28 15:20:04 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 28 Apr 2011 22:20:04 +0200 Subject: [llvm-commits] [llvm] r130428 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp In-Reply-To: <20110428200957.62B842A6C135@llvm.org> References: <20110428200957.62B842A6C135@llvm.org> Message-ID: <4DB9CBF4.60203@free.fr> Hi Benjamin, > - // (trunc x) == C1& (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 > + // (trunc x) == C1& (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2 > // where CMAX is the all ones value for the truncated type, > // iff the lower bits of CA are zero. don't you need the lower bits of C2 to also be zero? Ciao, Duncan. PS: Of course, if they are not zero then "(and x, CA) == C2" can be folded to false, so probably you will never hit this in practice. From eli.friedman at gmail.com Thu Apr 28 15:19:12 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 20:19:12 -0000 Subject: [llvm-commits] [llvm] r130429 - in /llvm/trunk: lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll test/CodeGen/X86/fast-isel-x86.ll Message-ID: <20110428201912.6EE2F2A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 15:19:12 2011 New Revision: 130429 URL: http://llvm.org/viewvc/llvm-project?rev=130429&view=rev Log: fast-isel sret calls, try 2. We actually do need to do something on x86-32. rdar://problem/9303592 . Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Modified: llvm/trunk/lib/Target/X86/X86FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86FastISel.cpp?rev=130429&r1=130428&r2=130429&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86FastISel.cpp (original) +++ llvm/trunk/lib/Target/X86/X86FastISel.cpp Thu Apr 28 15:19:12 2011 @@ -1618,7 +1618,6 @@ // FIXME: Only handle *easy* calls for now. if (CS.paramHasAttr(AttrInd, Attribute::InReg) || - CS.paramHasAttr(AttrInd, Attribute::StructRet) || CS.paramHasAttr(AttrInd, Attribute::Nest) || CS.paramHasAttr(AttrInd, Attribute::ByVal)) return false; @@ -1811,8 +1810,11 @@ // Issue CALLSEQ_END unsigned AdjStackUp = TM.getRegisterInfo()->getCallFrameDestroyOpcode(); + unsigned NumBytesCallee = 0; + if (!Subtarget->is64Bit() && CS.paramHasAttr(1, Attribute::StructRet)) + NumBytesCallee = 4; BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(AdjStackUp)) - .addImm(NumBytes).addImm(0); + .addImm(NumBytes).addImm(NumBytesCallee); // Now handle call return value (if any). SmallVector UsedRegs; Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll?rev=130429&r1=130428&r2=130429&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86-64.ll Thu Apr 28 15:19:12 2011 @@ -239,6 +239,19 @@ ; CHECK: pxor } +; Check that we fast-isel sret +%struct.a = type { i64, i64, i64 } +define void @test20() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test20sret(%struct.a* sret %tmp) + ret void +; CHECK: test20: +; CHECK: leaq (%rsp), %rdi +; CHECK: callq _test20sret +} +declare void @test20sret(%struct.a* sret) + ; Check that -0.0 is not materialized using pxor define void @test21(double* %p1) { store double -0.0, double* %p1 Modified: llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll?rev=130429&r1=130428&r2=130429&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll (original) +++ llvm/trunk/test/CodeGen/X86/fast-isel-x86.ll Thu Apr 28 15:19:12 2011 @@ -31,3 +31,18 @@ %t = load i32* @HHH ret i32 %t } + +; Check that we fast-isel sret, and handle the callee-pops behavior correctly. +%struct.a = type { i64, i64, i64 } +define void @test3() nounwind ssp { +entry: + %tmp = alloca %struct.a, align 8 + call void @test3sret(%struct.a* sret %tmp) + ret void +; CHECK: test3: +; CHECK: subl $44 +; CHECK: leal 16(%esp) +; CHECK: calll _test3sret +; CHECK: addl $40 +} +declare void @test3sret(%struct.a* sret) From lenny at colorado.edu Thu Apr 28 15:20:12 2011 From: lenny at colorado.edu (Lenny Maiorani) Date: Thu, 28 Apr 2011 20:20:12 -0000 Subject: [llvm-commits] [llvm] r130430 - in /llvm/trunk: include/llvm/ADT/StringRef.h lib/Support/StringRef.cpp unittests/ADT/StringRefTest.cpp Message-ID: <20110428202012.C61CB2A6C135@llvm.org> Author: lenny Date: Thu Apr 28 15:20:12 2011 New Revision: 130430 URL: http://llvm.org/viewvc/llvm-project?rev=130430&view=rev Log: Remove bounded StringRef::compare() since nothing but Clang SA was using it and it is just as easy to use StringRef::substr() preceding StringRef::compare() to achieve the same thing. Modified: llvm/trunk/include/llvm/ADT/StringRef.h llvm/trunk/lib/Support/StringRef.cpp llvm/trunk/unittests/ADT/StringRefTest.cpp Modified: llvm/trunk/include/llvm/ADT/StringRef.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/StringRef.h?rev=130430&r1=130429&r2=130430&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/StringRef.h (original) +++ llvm/trunk/include/llvm/ADT/StringRef.h Thu Apr 28 15:20:12 2011 @@ -125,12 +125,6 @@ return Length < RHS.Length ? -1 : 1; } - /// compare - Compare two strings; the result is -1, 0, or 1 if this string - /// is lexicographically less than, equal to, or greater than the \arg RHS. - /// This is different than compare with no size specified as it only - /// compares at most the first n bytes. - int compare(StringRef RHS, size_t n) const; - /// compare_lower - Compare two strings, ignoring case. int compare_lower(StringRef RHS) const; Modified: llvm/trunk/lib/Support/StringRef.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/StringRef.cpp?rev=130430&r1=130429&r2=130430&view=diff ============================================================================== --- llvm/trunk/lib/Support/StringRef.cpp (original) +++ llvm/trunk/lib/Support/StringRef.cpp Thu Apr 28 15:20:12 2011 @@ -29,27 +29,6 @@ return x >= '0' && x <= '9'; } -/// compare - Compare two strings; the result is -1, 0, or 1 if this string -/// is lexicographically less than, equal to, or greater than the \arg RHS. -/// This is different than compare with no size specified as it only -/// compares at most the first n bytes. -int StringRef::compare(StringRef RHS, size_t n) const { - // Check the prefix for a mismatch. - size_t maxToCmp = min(Length, RHS.Length); - maxToCmp = min(maxToCmp, n); - if (int Res = memcmp(Data, RHS.Data, maxToCmp)) - return Res < 0 ? -1 : 1; - - // Otherwise the prefixes match, so we only need to check the lengths. - // Be mindful that if the n is less than or equal to the length of either - // string, that is the same as the strings matching because in that case - // we only care about the prefix. - if (((n <= Length) && (n <= RHS.Length)) || - (Length == RHS.Length)) - return 0; - return Length < RHS.Length ? -1 : 1; -} - /// compare_lower - Compare strings, ignoring case. int StringRef::compare_lower(StringRef RHS) const { for (size_t I = 0, E = min(Length, RHS.Length); I != E; ++I) { Modified: llvm/trunk/unittests/ADT/StringRefTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/StringRefTest.cpp?rev=130430&r1=130429&r2=130430&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/StringRefTest.cpp (original) +++ llvm/trunk/unittests/ADT/StringRefTest.cpp Thu Apr 28 15:20:12 2011 @@ -55,19 +55,6 @@ EXPECT_EQ( 1, StringRef("aab").compare("aa")); EXPECT_EQ( 1, StringRef("\xFF").compare("\1")); - EXPECT_EQ(-1, StringRef("aab").compare("aad", 3)); - EXPECT_EQ( 0, StringRef("aab").compare("aab", 3)); - EXPECT_EQ( 1, StringRef("aab").compare("aaa", 3)); - EXPECT_EQ(-1, StringRef("aab").compare("aabb", 4)); - EXPECT_EQ( 1, StringRef("aab").compare("aa", 3)); - EXPECT_EQ( 1, StringRef("\xFF").compare("\1", 3)); - EXPECT_EQ( 0, StringRef("aab").compare("aad", 2)); - EXPECT_EQ( 0, StringRef("aab").compare("aab", 2)); - EXPECT_EQ( 0, StringRef("aab").compare("aab", 4)); - EXPECT_EQ( 0, StringRef("aab").compare("aaa", 2)); - EXPECT_EQ( 0, StringRef("aab").compare("aabb", 3)); - EXPECT_EQ( 0, StringRef("aab").compare("aa", 2)); - EXPECT_EQ(-1, StringRef("AaB").compare_lower("aAd")); EXPECT_EQ( 0, StringRef("AaB").compare_lower("aab")); EXPECT_EQ( 1, StringRef("AaB").compare_lower("AAA")); From dpatel at apple.com Thu Apr 28 15:32:02 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 20:32:02 -0000 Subject: [llvm-commits] [llvm] r130431 - /llvm/trunk/lib/Transforms/Utils/Local.cpp Message-ID: <20110428203202.9691C2A6C135@llvm.org> Author: dpatel Date: Thu Apr 28 15:32:02 2011 New Revision: 130431 URL: http://llvm.org/viewvc/llvm-project?rev=130431&view=rev Log: Remove DbgDeclare only if all uses are converted. Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=130431&r1=130430&r2=130431&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Thu Apr 28 15:32:02 2011 @@ -838,14 +838,18 @@ E = Dbgs.end(); I != E; ++I) { DbgDeclareInst *DDI = *I; if (AllocaInst *AI = dyn_cast_or_null(DDI->getAddress())) { + bool RemoveDDI = true; for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E; ++UI) if (StoreInst *SI = dyn_cast(*UI)) ConvertDebugDeclareToDebugValue(DDI, SI, DIB); else if (LoadInst *LI = dyn_cast(*UI)) ConvertDebugDeclareToDebugValue(DDI, LI, DIB); + else + RemoveDDI = false; + if (RemoveDDI) + DDI->eraseFromParent(); } - DDI->eraseFromParent(); } return true; } From kremenek at apple.com Thu Apr 28 15:34:18 2011 From: kremenek at apple.com (Ted Kremenek) Date: Thu, 28 Apr 2011 20:34:18 -0000 Subject: [llvm-commits] [llvm] r130432 - in /llvm/trunk: include/llvm/Support/MemoryBuffer.h lib/Support/MemoryBuffer.cpp Message-ID: <20110428203418.CBCC92A6C135@llvm.org> Author: kremenek Date: Thu Apr 28 15:34:18 2011 New Revision: 130432 URL: http://llvm.org/viewvc/llvm-project?rev=130432&view=rev Log: Add MemoryBuffer::getBufferKind() to report whether a memory buffer uses malloc'ed or mmap'ed memory. This is for performance analysis. Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h llvm/trunk/lib/Support/MemoryBuffer.cpp Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=130432&r1=130431&r2=130432&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original) +++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Thu Apr 28 15:34:18 2011 @@ -119,6 +119,21 @@ static error_code getFileOrSTDIN(const char *Filename, OwningPtr &result, int64_t FileSize = -1); + + + //===--------------------------------------------------------------------===// + // Provided for performance analysis. + //===--------------------------------------------------------------------===// + + /// The kind of memory backing used to support the MemoryBuffer. + enum BufferKind { + MemoryBuffer_Malloc, + MemoryBuffer_MMap + }; + + /// Return information on the memory mechanism used to support the + /// MemoryBuffer. + virtual BufferKind getBufferKind() const = 0; }; } // end namespace llvm Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=130432&r1=130431&r2=130432&view=diff ============================================================================== --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original) +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Thu Apr 28 15:34:18 2011 @@ -86,6 +86,10 @@ // The name is stored after the class itself. return reinterpret_cast(this + 1); } + + virtual BufferKind getBufferKind() const { + return MemoryBuffer_Malloc; + } }; } @@ -191,6 +195,10 @@ sys::Path::UnMapFilePages(reinterpret_cast(RealStart), RealSize); } + + virtual BufferKind getBufferKind() const { + return MemoryBuffer_MMap; + } }; } From aggarwa4 at illinois.edu Thu Apr 28 15:44:08 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 28 Apr 2011 20:44:08 -0000 Subject: [llvm-commits] [poolalloc] r130434 - /poolalloc/trunk/test/dsa/local/union_P2I.ll Message-ID: <20110428204408.B244D2A6C135@llvm.org> Author: aggarwa4 Date: Thu Apr 28 15:44:08 2011 New Revision: 130434 URL: http://llvm.org/viewvc/llvm-project?rev=130434&view=rev Log: Updated test. Modified: poolalloc/trunk/test/dsa/local/union_P2I.ll Modified: poolalloc/trunk/test/dsa/local/union_P2I.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/union_P2I.ll?rev=130434&r1=130433&r2=130434&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/local/union_P2I.ll (original) +++ poolalloc/trunk/test/dsa/local/union_P2I.ll Thu Apr 28 15:44:08 2011 @@ -1,9 +1,9 @@ ;checks that the PtrToInt and IntToPtr flag is set on unions that contain integer and pointer types - ;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:ptr:0,main:obj:0 -;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:obj+UP2" -;RUN: dsaopt %s -dsa-local -analyze -check-type=main:obj,0:i32|%\struct.StructType* +;RUN: dsaopt %s -dsa-local -analyze -check-type=main:obj,FoldedVOID +;RUN: adsaopt %s -simplify-gep -mergearrgep -o t.bc +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:obj,0:i32|[100 x %struct.StructType] ; ModuleID = 'union_P2.bc' From dpatel at apple.com Thu Apr 28 15:46:18 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 20:46:18 -0000 Subject: [llvm-commits] [llvm] r130435 - /llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Message-ID: <20110428204619.06E532A6C135@llvm.org> Author: dpatel Date: Thu Apr 28 15:46:18 2011 New Revision: 130435 URL: http://llvm.org/viewvc/llvm-project?rev=130435&view=rev Log: Beautify debug info probe output. Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugInfoProbe.cpp?rev=130435&r1=130434&r2=130435&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugInfoProbe.cpp (original) +++ llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Thu Apr 28 15:46:18 2011 @@ -136,7 +136,9 @@ unsigned LineNo = *I; if (LineNos2.count(LineNo) == 0) { DEBUG(dbgs() - << "DebugInfoProbe: Losing dbg info for source line " + << "DebugInfoProbe(" + << PassName + << "): Losing dbg info for source line " << LineNo << "\n"); ++NumDbgLineLost; } @@ -162,9 +164,16 @@ for (std::set::iterator I = DbgVariables.begin(), E = DbgVariables.end(); I != E; ++I) { - if (DbgVariables2.count(*I) == 0) { - DEBUG(dbgs() << "DebugInfoProbe: Losing dbg info for variable: "); - DEBUG((*I)->print(dbgs())); + if (DbgVariables2.count(*I) == 0 && (*I)->getNumOperands() >= 2) { + DEBUG(dbgs() + << "DebugInfoProbe(" + << PassName + << "): Losing dbg info for variable: "); + if (MDString *MDS = dyn_cast_or_null((*I)->getOperand(2))) + DEBUG(dbgs() << MDS->getString()); + else + DEBUG(dbgs() << "..."); + DEBUG(dbgs() << "\n"); ++NumDbgValueLost; } } From rafael.espindola at gmail.com Thu Apr 28 16:04:39 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Thu, 28 Apr 2011 21:04:39 -0000 Subject: [llvm-commits] [llvm] r130437 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCAsmInfoDarwin.h lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCDwarf.cpp Message-ID: <20110428210439.E956D2A6C135@llvm.org> Author: rafael Date: Thu Apr 28 16:04:39 2011 New Revision: 130437 URL: http://llvm.org/viewvc/llvm-project?rev=130437&view=rev Log: Add the getExprForFDESymbol method that responsible for computing the expressions used in the FDE to refer to symbols. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130437&r1=130436&r2=130437&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Thu Apr 28 16:04:39 2011 @@ -328,6 +328,9 @@ getExprForPersonalitySymbol(const MCSymbol *Sym, MCStreamer &Streamer) const; + virtual const MCExpr * + getExprForFDESymbol(const MCSymbol *Sym, MCStreamer &Streamer) const; + bool usesSunStyleELFSectionSwitchSyntax() const { return SunStyleELFSectionSwitchSyntax; } Modified: llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h?rev=130437&r1=130436&r2=130437&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h Thu Apr 28 16:04:39 2011 @@ -26,8 +26,7 @@ struct MCAsmInfoDarwin : public MCAsmInfo { explicit MCAsmInfoDarwin(); virtual const MCExpr * - getExprForPersonalitySymbol(const MCSymbol *Sym, - MCStreamer &Streamer) const; + getExprForFDESymbol(const MCSymbol *Sym, MCStreamer &Streamer) const; }; } Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130437&r1=130436&r2=130437&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Thu Apr 28 16:04:39 2011 @@ -112,5 +112,11 @@ const MCExpr * MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, MCStreamer &Streamer) const { + return getExprForFDESymbol(Sym, Streamer); +} + +const MCExpr * +MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); } Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=130437&r1=130436&r2=130437&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Thu Apr 28 16:04:39 2011 @@ -61,8 +61,8 @@ } const MCExpr * -MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, - MCStreamer &Streamer) const { +MCAsmInfoDarwin::getExprForFDESymbol(const MCSymbol *Sym, + MCStreamer &Streamer) const { MCContext &Context = Streamer.getContext(); const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); MCSymbol *PCSym = Context.CreateTempSymbol(); Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130437&r1=130436&r2=130437&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 28 16:04:39 2011 @@ -465,19 +465,16 @@ static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding) { + MCContext &context = streamer.getContext(); + const MCAsmInfo &asmInfo = context.getAsmInfo(); + const MCExpr *v = asmInfo.getExprForFDESymbol(&symbol, + streamer); unsigned size = getSizeForEncoding(streamer, symbolEncoding); unsigned application = symbolEncoding & 0x70; - switch (application) { - default: - assert(0 && "Unknown Encoding"); - break; - case 0: - streamer.EmitSymbolValue(&symbol, size); - break; - case dwarf::DW_EH_PE_pcrel: - streamer.EmitPCRelSymbolValue(&symbol, size); - break; - } + if (isa(v) && application == dwarf::DW_EH_PE_pcrel) + streamer.EmitPCRelValue(v, size); + else + streamer.EmitAbsValue(v, size); } static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, @@ -756,7 +753,7 @@ unsigned size = getSizeForEncoding(streamer, fdeEncoding); // PC Begin - streamer.EmitPCRelSymbolValue(frame.Begin, size); + EmitSymbol(streamer, *frame.Begin, fdeEncoding); // PC Range const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin, From daniel at zuster.org Thu Apr 28 16:23:31 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 28 Apr 2011 21:23:31 -0000 Subject: [llvm-commits] [llvm] r130438 - /llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Message-ID: <20110428212331.489052A6C135@llvm.org> Author: ddunbar Date: Thu Apr 28 16:23:31 2011 New Revision: 130438 URL: http://llvm.org/viewvc/llvm-project?rev=130438&view=rev Log: Target/X86/MC: Add an option for disabling arith relaxation, for my own testing purposes. Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=130438&r1=130437&r2=130438&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original) +++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Thu Apr 28 16:23:31 2011 @@ -21,6 +21,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/Object/MachOFormat.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -28,6 +29,13 @@ #include "llvm/Target/TargetAsmBackend.h" using namespace llvm; +// Option to allow disabling arithmetic relaxation to workaround PR9807, which +// is useful when running bitwise comparison experiments on Darwin. We should be +// able to remove this once PR9807 is resolved. +static cl::opt +MCDisableArithRelaxation("mc-x86-disable-arith-relaxation", + cl::desc("Disable relaxation of arithmetic instruction for X86")); + static unsigned getFixupKindLog2Size(unsigned Kind) { switch (Kind) { default: assert(0 && "invalid fixup kind!"); @@ -201,6 +209,9 @@ if (getRelaxedOpcodeBranch(Inst.getOpcode()) != Inst.getOpcode()) return true; + if (MCDisableArithRelaxation) + return false; + // Check if this instruction is ever relaxable. if (getRelaxedOpcodeArith(Inst.getOpcode()) == Inst.getOpcode()) return false; From benny.kra at googlemail.com Thu Apr 28 16:40:13 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 28 Apr 2011 23:40:13 +0200 Subject: [llvm-commits] [llvm] r130428 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp In-Reply-To: <4DB9CBF4.60203@free.fr> References: <20110428200957.62B842A6C135@llvm.org> <4DB9CBF4.60203@free.fr> Message-ID: <6540D482-FF57-4590-AAB7-B2A5EED697A9@googlemail.com> On 28.04.2011, at 22:20, Duncan Sands wrote: > Hi Benjamin, > >> - // (trunc x) == C1& (and x, CA) == C2 -> (and CA|CMAX) == C1|C2 >> + // (trunc x) == C1& (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2 >> // where CMAX is the all ones value for the truncated type, >> // iff the lower bits of CA are zero. > > don't you need the lower bits of C2 to also be zero? > > Ciao, > > Duncan. > > PS: Of course, if they are not zero then "(and x, CA) == C2" can be folded to > false, so probably you will never hit this in practice. We do require the bits of C2 to be zero. This should be folded away earlier, however I was bitten by this before, it's possible to create test cases where SimplifyDemandedBits hits the recursion limit and doesn't fold things that should be folded, I'll add a check to be safe. From nicholas at mxc.ca Thu Apr 28 16:35:49 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 28 Apr 2011 21:35:49 -0000 Subject: [llvm-commits] [llvm] r130443 - in /llvm/trunk: lib/Transforms/Instrumentation/GCOVProfiling.cpp runtime/libprofile/GCDAProfiling.c Message-ID: <20110428213549.DE84F2A6C135@llvm.org> Author: nicholas Date: Thu Apr 28 16:35:49 2011 New Revision: 130443 URL: http://llvm.org/viewvc/llvm-project?rev=130443&view=rev Log: Only read *predecessor once so as to fix a theoretical issue where it changes between two reads (threading). Fix an off-by-one in the indirect counter table that I meant to revert after an earlier experiment. Whoops! Implement GCOV_PREFIX. Doesn't handle GCOV_PREFIX_STRIP yet. Fix an off-by-one in string emission. Extra whoops! Tolerate DISubprograms that have null Function*'s attached to them. I don't yet understand what this means, but it happens when you have a global static with a non-trivial constructor/destructor. Fix a crash on switch statements with a single successor (default-only). Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/runtime/libprofile/GCDAProfiling.c Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=130443&r1=130442&r2=130443&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Thu Apr 28 16:35:49 2011 @@ -146,9 +146,9 @@ writeBytes(s.data(), s.size()); // Write 1 to 4 bytes of NUL padding. - assert((unsigned)(5 - ((s.size() + 1) % 4)) > 0); - assert((unsigned)(5 - ((s.size() + 1) % 4)) <= 4); - writeBytes("\0\0\0\0", 5 - ((s.size() + 1) % 4)); + assert((unsigned)(4 - (s.size() % 4)) > 0); + assert((unsigned)(4 - (s.size() % 4)) <= 4); + writeBytes("\0\0\0\0", 4 - (s.size() % 4)); } raw_ostream *os; @@ -263,7 +263,7 @@ write(BlockLen); uint32_t Ident = reinterpret_cast((MDNode*)SP); write(Ident); - write(0); // checksum + write(0); // checksum writeGCOVString(SP.getName()); writeGCOVString(SP.getFilename()); write(SP.getLineNumber()); @@ -356,8 +356,10 @@ DISubprogram SP(*SPI); raw_fd_ostream *&os = GcnoFiles[SP.getCompileUnit()]; - GCOVFunction Func(SP, os); Function *F = SP.getFunction(); + if (!F) continue; + GCOVFunction Func(SP, os); + for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { GCOVBlock &Block = Func.getBlock(BB); TerminatorInst *TI = BB->getTerminator(); @@ -402,6 +404,7 @@ SPE = DIF.subprogram_end(); SPI != SPE; ++SPI) { DISubprogram SP(*SPI); Function *F = SP.getFunction(); + if (!F) continue; unsigned Edges = 0; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { @@ -471,7 +474,7 @@ const Type *Int32Ty = Type::getInt32Ty(*Ctx); for (int i = 0, e = ComplexEdgePreds.size(); i != e; ++i) { IRBuilder<> Builder(ComplexEdgePreds[i+1]->getTerminator()); - Builder.CreateStore(ConstantInt::get(Int32Ty, i+1), EdgeState); + Builder.CreateStore(ConstantInt::get(Int32Ty, i), EdgeState); } for (int i = 0, e = ComplexEdgeSuccs.size(); i != e; ++i) { // call runtime to perform increment @@ -517,7 +520,7 @@ for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { TerminatorInst *TI = BB->getTerminator(); int Successors = isa(TI) ? 1 : TI->getNumSuccessors(); - if (Successors && !isa(TI) && !isa(TI)) { + if (Successors > 1 && !isa(TI) && !isa(TI)) { for (int i = 0; i != Successors; ++i) { BasicBlock *Succ = TI->getSuccessor(i); IRBuilder<> builder(Succ); Modified: llvm/trunk/runtime/libprofile/GCDAProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/GCDAProfiling.c?rev=130443&r1=130442&r2=130443&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/GCDAProfiling.c (original) +++ llvm/trunk/runtime/libprofile/GCDAProfiling.c Thu Apr 28 16:35:49 2011 @@ -46,6 +46,24 @@ write_int32(hi); } +static char *mangle_filename(const char *orig_filename) { + /* TODO: handle GCOV_PREFIX_STRIP */ + const char *prefix; + char *filename = 0; + + prefix = getenv("GCOV_PREFIX"); + + if (!prefix) + return strdup(filename); + + filename = malloc(strlen(prefix) + 1 + strlen(orig_filename) + 1); + strcpy(filename, prefix); + strcat(filename, "/"); + strcat(filename, orig_filename); + + return filename; +} + /* * --- LLVM line counter API --- */ @@ -54,15 +72,19 @@ * profiling enabled will emit to a different file. Only one file may be * started at a time. */ -void llvm_gcda_start_file(const char *filename) { - output_file = fopen(filename, "w+"); +void llvm_gcda_start_file(const char *orig_filename) { + char *filename; + filename = mangle_filename(orig_filename); + output_file = fopen(filename, "wb"); /* gcda file, version 404*, stamp LLVM. */ fwrite("adcg*404MVLL", 12, 1, output_file); #ifdef DEBUG_GCDAPROFILING - printf("llvmgcda: [%s]\n", filename); + printf("llvmgcda: [%s]\n", orig_filename); #endif + + free(filename); } /* Given an array of pointers to counters (counters), increment the n-th one, @@ -71,12 +93,16 @@ void llvm_gcda_increment_indirect_counter(uint32_t *predecessor, uint64_t **counters) { uint64_t *counter; - if (*predecessor == 0xffffffff) + uint32_t pred; + + pred = *predecessor; + if (pred == 0xffffffff) return; + counter = counters[pred]; /* Don't crash if the pred# is out of sync. This can happen due to threads, or because of a TODO in GCOVProfiling.cpp buildEdgeLookupTable(). */ - if ((counter = counters[*predecessor])) + if (counter) ++*counter; #ifdef DEBUG_GCDAPROFILING else From aggarwa4 at illinois.edu Thu Apr 28 16:36:26 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 28 Apr 2011 21:36:26 -0000 Subject: [llvm-commits] [poolalloc] r130445 - in /poolalloc/trunk: lib/DSA/DSTest.cpp test/dsa/local/union_P2I.ll test/dsa/types/array2struct.ll test/dsa/types/union_arrays.ll Message-ID: <20110428213626.8ACE52A6C135@llvm.org> Author: aggarwa4 Date: Thu Apr 28 16:36:26 2011 New Revision: 130445 URL: http://llvm.org/viewvc/llvm-project?rev=130445&view=rev Log: Fix Tcl lexer errors. Modified: poolalloc/trunk/lib/DSA/DSTest.cpp poolalloc/trunk/test/dsa/local/union_P2I.ll poolalloc/trunk/test/dsa/types/array2struct.ll poolalloc/trunk/test/dsa/types/union_arrays.ll Modified: poolalloc/trunk/lib/DSA/DSTest.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSTest.cpp?rev=130445&r1=130444&r2=130445&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/DSTest.cpp (original) +++ poolalloc/trunk/lib/DSA/DSTest.cpp Thu Apr 28 16:36:26 2011 @@ -281,7 +281,6 @@ if (N->isNodeCompletelyFolded()) { O << "Folded"; } - // Go through all the types, and just dump them. // FIXME: Lifted from Printer.cpp, probably should be shared bool firstType = true; @@ -472,10 +471,12 @@ NodeValue NV(*I, M, DS); std::string *type = new std::string(); llvm::raw_string_ostream *test= new llvm::raw_string_ostream(*type); - printTypesForNode(*test, NV); + std::string type1 = test->str(); + type1.erase(remove_if(type1.begin(), type1.end(), isspace), type1.end()); + typeRef.erase(remove_if(typeRef.begin(), typeRef.end(), isspace), typeRef.end()); - if(test->str()!=typeRef) { + if(type1 != typeRef) { errs() << "ERROR: Testing for type : \t" << typeRef << "\n"; errs() << " But found this type :\t" << Modified: poolalloc/trunk/test/dsa/local/union_P2I.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/union_P2I.ll?rev=130445&r1=130444&r2=130445&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/local/union_P2I.ll (original) +++ poolalloc/trunk/test/dsa/local/union_P2I.ll Thu Apr 28 16:36:26 2011 @@ -3,7 +3,7 @@ ;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:ptr:0,main:obj:0 ;RUN: dsaopt %s -dsa-local -analyze -check-type=main:obj,FoldedVOID ;RUN: adsaopt %s -simplify-gep -mergearrgep -o t.bc -;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:obj,0:i32|[100 x %struct.StructType] +;RUN: dsaopt t.bc -dsa-local -enable-type-inference-opts -analyze -check-type=main:obj,0:i32|\\\[100x%\struct.StructType\\\] ; ModuleID = 'union_P2.bc' Modified: poolalloc/trunk/test/dsa/types/array2struct.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/array2struct.ll?rev=130445&r1=130444&r2=130445&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/array2struct.ll (original) +++ poolalloc/trunk/test/dsa/types/array2struct.ll Thu Apr 28 16:36:26 2011 @@ -2,7 +2,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-unknown-linux-gnu" ;RUN: dsaopt %s -dsa-local -analyze -check-type=tree,FoldedVOID -;RUN: dsaopt %s -dsa-local -enable-type-inference-opts -analyze -check-type=tree,12:\[8 x i32\]Array +;RUN: dsaopt %s -dsa-local -enable-type-inference-opts -analyze -check-type=tree,12:\\\[8xi32\\\]Array ; LLVM front end converts the type of tree, to a struct type instead of an array of the right type. ; even though structurally equivalent, DSA cant infer this yet. Modified: poolalloc/trunk/test/dsa/types/union_arrays.ll URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union_arrays.ll?rev=130445&r1=130444&r2=130445&view=diff ============================================================================== --- poolalloc/trunk/test/dsa/types/union_arrays.ll (original) +++ poolalloc/trunk/test/dsa/types/union_arrays.ll Thu Apr 28 16:36:26 2011 @@ -4,7 +4,7 @@ ;RUN: dsaopt %s -dsa-local -analyze -check-type=func:obj,FoldedVOID ;RUN: dsaopt %s -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,FoldedVOID ;RUN: adsaopt %s -mem2reg -simplify-gep -mergearrgep -dce -o t.bc -;RUN: dsaopt t.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32|[10 x i32]::40:i16|[10 x i16]::60:i32|[10 x i32] +;RUN: dsaopt t.bc -dsa-local -analyze -enable-type-inference-opts -check-type=func:obj,0:i32|\\\[10xi32\\\]::40:i16|\\\[10xi16\\\]::60:i32|\\\[10xi32\\\] %struct.StructType1 = type { [10 x i32], [10 x i16], [10 x i32] } %struct.StructType2 = type { [10 x i32], [10 x i32], [10 x i32] } From benny.kra at googlemail.com Thu Apr 28 16:38:51 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 28 Apr 2011 21:38:51 -0000 Subject: [llvm-commits] [llvm] r130446 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Message-ID: <20110428213851.850002A6C135@llvm.org> Author: d0k Date: Thu Apr 28 16:38:51 2011 New Revision: 130446 URL: http://llvm.org/viewvc/llvm-project?rev=130446&view=rev Log: We require threse bits to be zero, too. This shouldn't happen in practice because the icmp would be a constant. Add a check so we don't miscompile code if something goes wrong. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=130446&r1=130445&r2=130446&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Apr 28 16:38:51 2011 @@ -772,7 +772,7 @@ // (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2 // where CMAX is the all ones value for the truncated type, - // iff the lower bits of CA are zero. + // iff the lower bits of C2 and CA are zero. if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) && LHS->hasOneUse() && RHS->hasOneUse()) { Value *V; @@ -797,7 +797,7 @@ // Check that the low bits are zero. APInt Low = APInt::getLowBitsSet(BigBitSize, SmallBitSize); - if ((Low & AndCst->getValue()) == 0) { + if ((Low & AndCst->getValue()) == 0 && (Low & BigCst->getValue()) == 0) { Value *NewAnd = Builder->CreateAnd(V, Low | AndCst->getValue()); APInt N = SmallCst->getValue().zext(BigBitSize) | BigCst->getValue(); Value *NewVal = ConstantInt::get(AndCst->getType()->getContext(), N); From stuart at apple.com Thu Apr 28 16:47:42 2011 From: stuart at apple.com (Stuart Hastings) Date: Thu, 28 Apr 2011 21:47:42 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130447 - /llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Message-ID: <20110428214743.0AB4F2A6C135@llvm.org> Author: stuart Date: Thu Apr 28 16:47:42 2011 New Revision: 130447 URL: http://llvm.org/viewvc/llvm-project?rev=130447&view=rev Log: Raise ARM byval minimum size from 32 to 64, addressing a performance regression in mason. rdar://problem/7662569 Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=130447&r1=130446&r2=130447&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Thu Apr 28 16:47:42 2011 @@ -2883,7 +2883,7 @@ HOST_WIDE_INT Bytes = (Mode == BLKmode) ? int_size_in_bytes(TreeType) : (int) GET_MODE_SIZE(Mode); - return Bytes > 32; + return Bytes > 64; } else return false; } From matthewbg at google.com Thu Apr 28 17:26:05 2011 From: matthewbg at google.com (Matt Beaumont-Gay) Date: Thu, 28 Apr 2011 22:26:05 -0000 Subject: [llvm-commits] [llvm] r130448 - /llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Message-ID: <20110428222606.024F82A6C135@llvm.org> Author: matthewbg Date: Thu Apr 28 17:26:05 2011 New Revision: 130448 URL: http://llvm.org/viewvc/llvm-project?rev=130448&view=rev Log: Coalesce some DEBUGs (moving an only-used-in-DEBUG variable's declaration into the DEBUG) Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugInfoProbe.cpp?rev=130448&r1=130447&r2=130448&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugInfoProbe.cpp (original) +++ llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Thu Apr 28 17:26:05 2011 @@ -168,12 +168,13 @@ DEBUG(dbgs() << "DebugInfoProbe(" << PassName - << "): Losing dbg info for variable: "); - if (MDString *MDS = dyn_cast_or_null((*I)->getOperand(2))) - DEBUG(dbgs() << MDS->getString()); - else - DEBUG(dbgs() << "..."); - DEBUG(dbgs() << "\n"); + << "): Losing dbg info for variable: "; + if (MDString *MDS = dyn_cast_or_null( + (*I)->getOperand(2))) + dbgs() << MDS->getString(); + else + dbgs() << "..."; + dbgs() << "\n"); ++NumDbgValueLost; } } From aggarwa4 at illinois.edu Thu Apr 28 17:35:30 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Thu, 28 Apr 2011 22:35:30 -0000 Subject: [llvm-commits] [poolalloc] r130449 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20110428223530.6C28C2A6C135@llvm.org> Author: aggarwa4 Date: Thu Apr 28 17:35:30 2011 New Revision: 130449 URL: http://llvm.org/viewvc/llvm-project?rev=130449&view=rev Log: Recognize Int2Ptr and Ptr2Int instructions used only for comparisons, never returned, never stored into memory. These don't need to be marked type-unsafe. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=130449&r1=130448&r2=130449&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Thu Apr 28 17:35:30 2011 @@ -46,7 +46,9 @@ STATISTIC(NumIndirectCall, "Number of indirect calls added"); STATISTIC(NumAsmCall, "Number of asm calls collapsed/seen"); STATISTIC(NumIntrinsicCall, "Number of intrinsics called"); -STATISTIC(IgnoredInst, "Number of instructions ignored"); +STATISTIC(NumBoringIntToPtr, "Number of inttoptr used only in cmp"); +//STATISTIC(NumSimpleIntToPtr, "Number of inttoptr from ptrtoint"); +STATISTIC(NumIgnoredInst, "Number of instructions ignored"); RegisterPass X("dsa-local", "Local Data Structure Analysis"); @@ -377,7 +379,7 @@ if(LI.getNumUses() == 1) if(StoreInst *SI = dyn_cast(LI.use_begin())) if(SI->getOperand(0) == &LI) { - ++IgnoredInst; + ++NumIgnoredInst; return; } Ptr.getNode()->mergeTypeInfo(LI.getType(), Ptr.getOffset()); @@ -401,7 +403,7 @@ if(TypeInferenceOptimize) if(SI.getOperand(0)->getNumUses() == 1) if(isa(SI.getOperand(0))){ - ++IgnoredInst; + ++NumIgnoredInst; return; } Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); @@ -430,11 +432,50 @@ } void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) { - setDestTo(I, createNode()->setUnknownMarker()->setIntToPtrMarker()); + DSNode *N = createNode(); + if(TypeInferenceOptimize) { + if(I.getNumUses() == 1) { + if(isa(I.use_begin())) { + NumBoringIntToPtr++; + return; + } + } + } else { + N->setIntToPtrMarker(); + N->setUnknownMarker(); + } + setDestTo(I, N); } void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) { - if (DSNode* N = getValueDest(I.getOperand(0)).getNode()) + DSNode* N = getValueDest(I.getOperand(0)).getNode(); + if(TypeInferenceOptimize) { + if(I.getNumUses() == 1) { + if(isa(I.use_begin())) { + NumBoringIntToPtr++; + return; + } + } + } + if(TypeInferenceOptimize) { + if(I.getNumUses() == 1) { + Value *V = dyn_cast(I.use_begin()); + while(V && V->getNumUses() == 1) { + if(isa(V)) + break; + if(isa(V)) + break; + if(isa(V)) + break; + V = dyn_cast(V->use_begin()); + } + if(isa(V)){ + NumBoringIntToPtr++; + return; + } + } + } + if(N) N->setPtrToIntMarker(); } @@ -602,7 +643,7 @@ // If not fold. if((Value.getOffset() || Offset != 0) || (!isa(CurTy) - && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { + && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { Value.getNode()->foldNodeCompletely(); Value.getNode(); Offset = 0; @@ -636,7 +677,7 @@ } if(Value.getOffset() || Offset != 0 || (!isa(CurTy) - && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { + && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) { Value.getNode()->foldNodeCompletely(); Value.getNode(); Offset = 0; @@ -714,33 +755,33 @@ // For the architectures we support, build dsnodes that match // how we know va_list is used. switch (Arch) { - case Triple::x86: - // On x86, we have: - // va_list as a pointer to an array of pointers to the variable arguments - if (N->getSize() < 1) - N->growSize(1); - N->setLink(0, VAArray); - break; - case Triple::x86_64: - // On x86_64, we have va_list as a struct {i32, i32, i8*, i8* } - // The first i8* is where arguments generally go, but the second i8* can - // be used also to pass arguments by register. - // We model this by having both the i8*'s point to an array of pointers - // to the arguments. - if (N->getSize() < 24) - N->growSize(24); //sizeof the va_list struct mentioned above - N->setLink(8,VAArray); //first i8* - N->setLink(16,VAArray); //second i8* - break; - default: - // FIXME: For now we abort if we don't know how to handle this arch - // Either add support for other architectures, or at least mark the - // nodes unknown/incomplete or whichever results in the correct - // conservative behavior in the general case - assert(0 && "VAstart not supported on this architecture!"); - //XXX: This might be good enough in those cases that we don't know - //what the arch does - N->setIncompleteMarker()->setUnknownMarker()->foldNodeCompletely(); + case Triple::x86: + // On x86, we have: + // va_list as a pointer to an array of pointers to the variable arguments + if (N->getSize() < 1) + N->growSize(1); + N->setLink(0, VAArray); + break; + case Triple::x86_64: + // On x86_64, we have va_list as a struct {i32, i32, i8*, i8* } + // The first i8* is where arguments generally go, but the second i8* can + // be used also to pass arguments by register. + // We model this by having both the i8*'s point to an array of pointers + // to the arguments. + if (N->getSize() < 24) + N->growSize(24); //sizeof the va_list struct mentioned above + N->setLink(8,VAArray); //first i8* + N->setLink(16,VAArray); //second i8* + break; + default: + // FIXME: For now we abort if we don't know how to handle this arch + // Either add support for other architectures, or at least mark the + // nodes unknown/incomplete or whichever results in the correct + // conservative behavior in the general case + assert(0 && "VAstart not supported on this architecture!"); + //XXX: This might be good enough in those cases that we don't know + //what the arch does + N->setIncompleteMarker()->setUnknownMarker()->foldNodeCompletely(); } // XXX: We used to set the alloca marker for the DSNode passed to va_start. @@ -777,9 +818,9 @@ } case Intrinsic::stackrestore: getValueDest(CS.getInstruction()).getNode()->setAllocaMarker() - ->setIncompleteMarker() - ->setUnknownMarker() - ->foldNodeCompletely(); + ->setIncompleteMarker() + ->setUnknownMarker() + ->foldNodeCompletely(); return true; case Intrinsic::vaend: case Intrinsic::memory_barrier: @@ -810,8 +851,8 @@ case Intrinsic::eh_selector: { for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); - I != E; ++I) { - if (isa((*I)->getType())) { + I != E; ++I) { + if (isa((*I)->getType())) { DSNodeHandle Ptr = getValueDest(*I); if(Ptr.getNode()) { Ptr.getNode()->setReadMarker(); From dpatel at apple.com Thu Apr 28 17:48:14 2011 From: dpatel at apple.com (Devang Patel) Date: Thu, 28 Apr 2011 22:48:14 -0000 Subject: [llvm-commits] [llvm] r130450 - /llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Message-ID: <20110428224815.0A67C2A6C135@llvm.org> Author: dpatel Date: Thu Apr 28 17:48:14 2011 New Revision: 130450 URL: http://llvm.org/viewvc/llvm-project?rev=130450&view=rev Log: Preserve line number information. Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=130450&r1=130449&r2=130450&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Thu Apr 28 17:48:14 2011 @@ -217,6 +217,7 @@ ValueRankMap.erase(Neg); Res->takeName(Neg); Neg->replaceAllUsesWith(Res); + Res->setDebugLoc(Neg->getDebugLoc()); Neg->eraseFromParent(); return Res; } @@ -506,6 +507,7 @@ // Everyone now refers to the add instruction. ValueRankMap.erase(Sub); Sub->replaceAllUsesWith(New); + New->setDebugLoc(Sub->getDebugLoc()); Sub->eraseFromParent(); DEBUG(dbgs() << "Negated: " << *New << '\n'); @@ -531,6 +533,7 @@ ValueRankMap.erase(Shl); Mul->takeName(Shl); Shl->replaceAllUsesWith(Mul); + Mul->setDebugLoc(Shl->getDebugLoc()); Shl->eraseFromParent(); return Mul; } @@ -1052,6 +1055,8 @@ // eliminate it. DEBUG(dbgs() << "Reassoc to scalar: " << *V << '\n'); I->replaceAllUsesWith(V); + if (Instruction *VI = dyn_cast(V)) + VI->setDebugLoc(I->getDebugLoc()); RemoveDeadBinaryOp(I); ++NumAnnihil; return V; @@ -1075,6 +1080,8 @@ // This expression tree simplified to something that isn't a tree, // eliminate it. I->replaceAllUsesWith(Ops[0].Op); + if (Instruction *OI = dyn_cast(Ops[0].Op)) + OI->setDebugLoc(I->getDebugLoc()); RemoveDeadBinaryOp(I); return Ops[0].Op; } From eli.friedman at gmail.com Thu Apr 28 18:03:25 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 23:03:25 -0000 Subject: [llvm-commits] [llvm] r130454 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-redefinition.ll Message-ID: <20110428230325.AC28C2A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 18:03:25 2011 New Revision: 130454 URL: http://llvm.org/viewvc/llvm-project?rev=130454&view=rev Log: Fix a rather obscure crash caused by ARM fast-isel generating code which redefines a register. rdar://problem/9338332 . Added: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130454&r1=130453&r2=130454&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Apr 28 18:03:25 2011 @@ -822,26 +822,9 @@ // Since the offset is too large for the load/store instruction // get the reg+offset into a register. if (needsLowering) { - ARMCC::CondCodes Pred = ARMCC::AL; - unsigned PredReg = 0; - - TargetRegisterClass *RC = isThumb ? ARM::tGPRRegisterClass : - ARM::GPRRegisterClass; - unsigned BaseReg = createResultReg(RC); - - if (!isThumb) - emitARMRegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, - BaseReg, Addr.Base.Reg, Addr.Offset, - Pred, PredReg, - static_cast(TII)); - else { - assert(AFI->isThumb2Function()); - emitT2RegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, - BaseReg, Addr.Base.Reg, Addr.Offset, Pred, PredReg, - static_cast(TII)); - } + Addr.Base.Reg = FastEmit_ri_(MVT::i32, ISD::ADD, Addr.Base.Reg, + /*Op0IsKill*/false, Addr.Offset, MVT::i32); Addr.Offset = 0; - Addr.Base.Reg = BaseReg; } } Added: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll?rev=130454&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Thu Apr 28 18:03:25 2011 @@ -0,0 +1,11 @@ +; RUN: llc -O0 -regalloc=linearscan | grep "ldr r0" +; This isn't exactly a useful set of command-line options, but check that it +; doesn't crash. (It was crashing because a register was getting redefined.) + +target triple = "thumbv7-apple-macosx10.6.7" + +define i32 @f(i32* %x) nounwind ssp { + %y = getelementptr inbounds i32* %x, i32 5000 + %tmp103 = load i32* %y, align 4 + ret i32 %tmp103 +} From eli.friedman at gmail.com Thu Apr 28 18:12:24 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 23:12:24 -0000 Subject: [llvm-commits] [llvm] r130455 - /llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Message-ID: <20110428231224.48BF22A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 18:12:24 2011 New Revision: 130455 URL: http://llvm.org/viewvc/llvm-project?rev=130455&view=rev Log: Fix runline. Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll?rev=130455&r1=130454&r2=130455&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Thu Apr 28 18:12:24 2011 @@ -1,4 +1,4 @@ -; RUN: llc -O0 -regalloc=linearscan | grep "ldr r0" +; RUN: llc -O0 -regalloc=linearscan < %s ; This isn't exactly a useful set of command-line options, but check that it ; doesn't crash. (It was crashing because a register was getting redefined.) From fjahanian at apple.com Thu Apr 28 18:44:12 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Thu, 28 Apr 2011 23:44:12 -0000 Subject: [llvm-commits] [test-suite] r130459 - /test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Message-ID: <20110428234412.7F6F72A6C135@llvm.org> Author: fjahanian Date: Thu Apr 28 18:44:12 2011 New Revision: 130459 URL: http://llvm.org/viewvc/llvm-project?rev=130459&view=rev Log: Excutable test case for use of ms_struct attribute in clang. // rdar://8823265. Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Added: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c?rev=130459&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c (added) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Thu Apr 28 18:44:12 2011 @@ -0,0 +1,66 @@ +#include + +#define ATTR __attribute__((__ms_struct__)) + +struct +{ + char foo; + long : 0; + char : 0; + int : 0; + char bar; +} ATTR t1 = {'a', 'b'}; + +struct +{ + char bar0; + long : 0; + int : 0; + char bar1; + char bar2; + long : 0; + char bar3; + char bar4; + char : 0; + char bar5; + char bar6; + char : 0; + char bar7; + char bar8; +} ATTR t2 = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'}; + +struct { + int : 0; + int i1; + int : 0; + int i2; + int : 0; + int i3; + int : 0; + int i4; +} t3 = {1,2,3,4}; + +int main() { + if (sizeof(t1) != 2) + abort(); + if (t1.foo != 'a') + abort(); + if (t1.bar != 'b') + abort(); + t1.foo = 'c'; + t1.bar = 'd'; + if (t1.foo != 'c') + abort(); + if (t1.bar != 'd') + abort(); + if (sizeof(t2) != 9) + abort(); + if (t2.bar0 != 'a' || t2.bar8 != 'i') + abort(); + if (sizeof(t3) != 16) + abort(); + if (t3.i1 != 1 || t3.i4 != 4) + abort(); + return 0; +} + From echristo at apple.com Thu Apr 28 18:51:29 2011 From: echristo at apple.com (Eric Christopher) Date: Thu, 28 Apr 2011 16:51:29 -0700 Subject: [llvm-commits] [llvm] r130454 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-redefinition.ll In-Reply-To: <20110428230325.AC28C2A6C135@llvm.org> References: <20110428230325.AC28C2A6C135@llvm.org> Message-ID: <65DD4F1A-1C27-4AF1-AEC9-48E4C97F89EA@apple.com> On Apr 28, 2011, at 4:03 PM, Eli Friedman wrote: > Author: efriedma > Date: Thu Apr 28 18:03:25 2011 > New Revision: 130454 > > URL: http://llvm.org/viewvc/llvm-project?rev=130454&view=rev > Log: > Fix a rather obscure crash caused by ARM fast-isel generating code which redefines a register. > rdar://problem/9338332 . This will, and does, break the bigstack test in SingleSource/Regression/C because it's not able to lower the offset correctly and needs another register. -eric From eli.friedman at gmail.com Thu Apr 28 18:55:14 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 23:55:14 -0000 Subject: [llvm-commits] [llvm] r130462 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-redefinition.ll Message-ID: <20110428235514.E83E52A6C135@llvm.org> Author: efriedma Date: Thu Apr 28 18:55:14 2011 New Revision: 130462 URL: http://llvm.org/viewvc/llvm-project?rev=130462&view=rev Log: Revert r130454; apparently this doesn't actually work. Removed: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130462&r1=130461&r2=130462&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Apr 28 18:55:14 2011 @@ -822,9 +822,26 @@ // Since the offset is too large for the load/store instruction // get the reg+offset into a register. if (needsLowering) { - Addr.Base.Reg = FastEmit_ri_(MVT::i32, ISD::ADD, Addr.Base.Reg, - /*Op0IsKill*/false, Addr.Offset, MVT::i32); + ARMCC::CondCodes Pred = ARMCC::AL; + unsigned PredReg = 0; + + TargetRegisterClass *RC = isThumb ? ARM::tGPRRegisterClass : + ARM::GPRRegisterClass; + unsigned BaseReg = createResultReg(RC); + + if (!isThumb) + emitARMRegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + BaseReg, Addr.Base.Reg, Addr.Offset, + Pred, PredReg, + static_cast(TII)); + else { + assert(AFI->isThumb2Function()); + emitT2RegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + BaseReg, Addr.Base.Reg, Addr.Offset, Pred, PredReg, + static_cast(TII)); + } Addr.Offset = 0; + Addr.Base.Reg = BaseReg; } } Removed: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll?rev=130461&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (removed) @@ -1,11 +0,0 @@ -; RUN: llc -O0 -regalloc=linearscan < %s -; This isn't exactly a useful set of command-line options, but check that it -; doesn't crash. (It was crashing because a register was getting redefined.) - -target triple = "thumbv7-apple-macosx10.6.7" - -define i32 @f(i32* %x) nounwind ssp { - %y = getelementptr inbounds i32* %x, i32 5000 - %tmp103 = load i32* %y, align 4 - ret i32 %tmp103 -} From echristo at apple.com Thu Apr 28 19:03:10 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 00:03:10 -0000 Subject: [llvm-commits] [llvm] r130463 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110429000310.5D3FB2A6C135@llvm.org> Author: echristo Date: Thu Apr 28 19:03:10 2011 New Revision: 130463 URL: http://llvm.org/viewvc/llvm-project?rev=130463&view=rev Log: Whitespace. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130463&r1=130462&r2=130463&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Apr 28 19:03:10 2011 @@ -231,16 +231,16 @@ bool ARMFastISel::isARMNEONPred(const MachineInstr *MI) { const TargetInstrDesc &TID = MI->getDesc(); - + // If we're a thumb2 or not NEON function we were handled via isPredicable. if ((TID.TSFlags & ARMII::DomainMask) != ARMII::DomainNEON || AFI->isThumb2Function()) return false; - + for (unsigned i = 0, e = TID.getNumOperands(); i != e; ++i) if (TID.OpInfo[i].isPredicate()) return true; - + return false; } @@ -258,7 +258,7 @@ // we're not predicable but add it anyways. if (TII.isPredicable(MI) || isARMNEONPred(MI)) AddDefaultPred(MIB); - + // Do we optionally set a predicate? Preds is size > 0 iff the predicate // defines CPSR. All other OptionalDefines in ARM are the CCR register. bool CPSR = false; @@ -728,7 +728,7 @@ FuncInfo.MBBMap[cast(Op)->getParent()] == FuncInfo.MBB) && isa(cast(Op)->getOperand(1))) { - // An add (in the same block) with a constant operand. Fold the + // An add (in the same block) with a constant operand. Fold the // constant. ConstantInt *CI = cast(cast(Op)->getOperand(1)); @@ -736,7 +736,7 @@ // Iterate on the other operand. Op = cast(Op)->getOperand(0); continue; - } + } // Unsupported goto unsupported_gep; } @@ -852,7 +852,7 @@ if (VT.getSimpleVT().SimpleTy == MVT::f32 || VT.getSimpleVT().SimpleTy == MVT::f64) Addr.Offset /= 4; - + // Frame base works a bit differently. Handle it separately. if (Addr.BaseType == Address::FrameIndexBase) { int FI = Addr.Base.FI; @@ -874,7 +874,7 @@ } else { // Now add the rest of the operands. MIB.addReg(Addr.Base.Reg); - + // ARM halfword load/stores need an additional operand. if (!isThumb && VT.getSimpleVT().SimpleTy == MVT::i16) MIB.addReg(0); @@ -1132,7 +1132,7 @@ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TstOpc)) .addReg(CmpReg).addImm(1)); - + unsigned CCMode = ARMCC::NE; if (FuncInfo.MBB->isLayoutSuccessor(TBB)) { std::swap(TBB, FBB); @@ -1838,7 +1838,7 @@ // TODO: For now if we have long calls specified we don't handle the call. if (EnableARMLongCalls) return false; - + // Set up the argument vectors. SmallVector Args; SmallVector ArgRegs; @@ -1902,7 +1902,7 @@ MIB = AddDefaultPred(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(CallOpc)) .addGlobalAddress(GV, 0, 0)); - + // Add implicit physical register uses to the call. for (unsigned i = 0, e = RegArgs.size(); i != e; ++i) MIB.addReg(RegArgs[i]); From echristo at apple.com Thu Apr 28 19:07:20 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 00:07:20 -0000 Subject: [llvm-commits] [llvm] r130464 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110429000720.E08242A6C135@llvm.org> Author: echristo Date: Thu Apr 28 19:07:20 2011 New Revision: 130464 URL: http://llvm.org/viewvc/llvm-project?rev=130464&view=rev Log: Update comments and checks to match reality. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130464&r1=130463&r2=130464&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Thu Apr 28 19:07:20 2011 @@ -1731,9 +1731,6 @@ else if (!isTypeLegal(RetTy, RetVT)) return false; - // For now we're using BLX etc on the assumption that we have v5t ops. - if (!Subtarget->hasV5TOps()) return false; - // TODO: For now if we have long calls specified we don't handle the call. if (EnableARMLongCalls) return false; @@ -1771,7 +1768,7 @@ if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags, RegArgs, CC, NumBytes)) return false; - // Issue the call, BLXr9 for darwin, BLX otherwise. This uses V5 ops. + // Issue the call, BLr9 for darwin, BL otherwise. // TODO: Turn this into the table of arm call ops. MachineInstrBuilder MIB; unsigned CallOpc = ARMSelectCallOp(NULL); @@ -1832,10 +1829,6 @@ else if (!isTypeLegal(RetTy, RetVT)) return false; - // For now we're using BLX etc on the assumption that we have v5t ops. - // TODO: Maybe? - if (!Subtarget->hasV5TOps()) return false; - // TODO: For now if we have long calls specified we don't handle the call. if (EnableARMLongCalls) return false; @@ -1887,7 +1880,7 @@ if (!ProcessCallArgs(Args, ArgRegs, ArgVTs, ArgFlags, RegArgs, CC, NumBytes)) return false; - // Issue the call, BLXr9 for darwin, BLX otherwise. This uses V5 ops. + // Issue the call, BLr9 for darwin, BL otherwise. // TODO: Turn this into the table of arm call ops. MachineInstrBuilder MIB; unsigned CallOpc = ARMSelectCallOp(GV); From daniel at zuster.org Thu Apr 28 19:28:42 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 00:28:42 -0000 Subject: [llvm-commits] [zorg] r130465 - /zorg/trunk/lnt/lnt/viewer/GraphUtil.py Message-ID: <20110429002842.A4CE02A6C135@llvm.org> Author: ddunbar Date: Thu Apr 28 19:28:42 2011 New Revision: 130465 URL: http://llvm.org/viewvc/llvm-project?rev=130465&view=rev Log: LNT: Fix a possible zero division error. Modified: zorg/trunk/lnt/lnt/viewer/GraphUtil.py Modified: zorg/trunk/lnt/lnt/viewer/GraphUtil.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/GraphUtil.py?rev=130465&r1=130464&r2=130465&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/GraphUtil.py (original) +++ zorg/trunk/lnt/lnt/viewer/GraphUtil.py Thu Apr 28 19:28:42 2011 @@ -85,8 +85,11 @@ # We compute the regression line in terms of a normalized X scale. x_min, x_max = min(xs), max(xs) - norm_xs = [(x - x_min) / (x_max - x_min) - for x in xs] + try: + norm_xs = [(x - x_min) / (x_max - x_min) + for x in xs] + except ZeroDivisionError: + norm_xs = xs try: info = ext_stats.linregress(norm_xs, ys) From daniel at zuster.org Thu Apr 28 19:29:42 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 00:29:42 -0000 Subject: [llvm-commits] [zorg] r130466 - /zorg/trunk/lnt/setup.py Message-ID: <20110429002942.0EA112A6C135@llvm.org> Author: ddunbar Date: Thu Apr 28 19:29:41 2011 New Revision: 130466 URL: http://llvm.org/viewvc/llvm-project?rev=130466&view=rev Log: LNT/Flask: Update to install Flask resource files. Modified: zorg/trunk/lnt/setup.py Modified: zorg/trunk/lnt/setup.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/setup.py?rev=130466&r1=130465&r2=130466&view=diff ============================================================================== --- zorg/trunk/lnt/setup.py (original) +++ zorg/trunk/lnt/setup.py Thu Apr 28 19:29:41 2011 @@ -45,6 +45,12 @@ 'js/*.js', 'resources/*.css', 'resources/*.js'], + + 'lnt.server.ui': ['static/*.ico', + 'static/*.js', + 'static/*.css', + 'templates/*.html'], + 'lnt.util': ['NTAuxSubmit'], }, From nicholas at mxc.ca Thu Apr 28 21:12:06 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 29 Apr 2011 02:12:06 -0000 Subject: [llvm-commits] [llvm] r130470 - in /llvm/trunk: CMakeLists.txt cmake/modules/AddLLVM.cmake cmake/modules/LLVMLibDeps.cmake runtime/libprofile/CMakeLists.txt runtime/libprofile/Makefile utils/profile.pl Message-ID: <20110429021206.D59FD2A6C135@llvm.org> Author: nicholas Date: Thu Apr 28 21:12:06 2011 New Revision: 130470 URL: http://llvm.org/viewvc/llvm-project?rev=130470&view=rev Log: Rename profile_rt.so to libprofile_rt.so under configure+make (it already was under cmake). Add libprofile_rt.a so that we can tell clang to link against it in --coverage mode. Also turn it on by default in cmake builds. Oscar, this touches a change you made for EXCLUDE_FROM_ALL support -- I think I've done the right thing, but please let me know (or fix and commit) if not! Modified: llvm/trunk/CMakeLists.txt llvm/trunk/cmake/modules/AddLLVM.cmake llvm/trunk/cmake/modules/LLVMLibDeps.cmake llvm/trunk/runtime/libprofile/CMakeLists.txt llvm/trunk/runtime/libprofile/Makefile llvm/trunk/utils/profile.pl Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Thu Apr 28 21:12:06 2011 @@ -228,7 +228,7 @@ endif() option(LLVM_BUILD_RUNTIME - "Build the LLVM runtime libraries. If OFF, just generate build targets." OFF) + "Build the LLVM runtime libraries. If OFF, just generate build targets." ON) option(LLVM_INCLUDE_RUNTIME "Generate build targets for the LLVM runtimes" ON) if( LLVM_INCLUDE_RUNTIME ) add_subdirectory(runtime) Modified: llvm/trunk/cmake/modules/AddLLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/cmake/modules/AddLLVM.cmake (original) +++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Apr 28 21:12:06 2011 @@ -17,9 +17,13 @@ # list. Without this, linking the unit tests on MinGW fails. link_system_libs( ${name} ) - install(TARGETS ${name} - LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + if( EXCLUDE_FROM_ALL ) + set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) + else() + install(TARGETS ${name} + LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} + ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) + endif() # The LLVM Target library shall be built before its sublibraries # (asmprinter, etc) because those may use tablegenned files which # generation is triggered by the main LLVM target library. Necessary @@ -58,7 +62,7 @@ endif() if( EXCLUDE_FROM_ALL ) - set_target_properties(profile_rt PROPERTIES EXCLUDE_FROM_ALL ON) + set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) else() install(TARGETS ${name} LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Thu Apr 28 21:12:06 2011 @@ -30,10 +30,10 @@ set(MSVC_LIB_DEPS_LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMBlazeAsmPrinter LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMBlazeCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMBlazeAsmPrinter LLVMMBlazeInfo LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget) -set(MSVC_LIB_DEPS_LLVMMBlazeDisassembler LLVMMBlazeCodeGen LLVMMBlazeInfo LLVMMC LLVMSupport) +set(MSVC_LIB_DEPS_LLVMMBlazeDisassembler LLVMMBlazeCodeGen LLVMMBlazeInfo LLVMMC) set(MSVC_LIB_DEPS_LLVMMBlazeInfo LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMC LLVMSupport) -set(MSVC_LIB_DEPS_LLVMMCDisassembler LLVMARMAsmParser LLVMARMCodeGen LLVMARMDisassembler LLVMARMInfo LLVMAlphaCodeGen LLVMAlphaInfo LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCBackend LLVMCBackendInfo LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCppBackend LLVMCppBackendInfo LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeDisassembler LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMMSP430CodeGen LLVMMSP430Info LLVMMipsCodeGen LLVMMipsInfo LLVMPTXCodeGen LLVMPTXInfo LLVMPowerPCCodeGen LLVMPowerPCInfo LLVMSparcCodeGen LLVMSparcInfo LLVMSupport LLVMSystemZCodeGen LLVMSystemZInfo LLVMX86AsmParser LLVMX86CodeGen LLVMX86Disassembler LLVMX86Info LLVMXCoreCodeGen LLVMXCoreInfo) +set(MSVC_LIB_DEPS_LLVMMCDisassembler LLVMARMAsmParser LLVMARMCodeGen LLVMARMDisassembler LLVMARMInfo LLVMAlphaCodeGen LLVMAlphaInfo LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCBackend LLVMCBackendInfo LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCppBackend LLVMCppBackendInfo LLVMMBlazeAsmParser LLVMMBlazeCodeGen LLVMMBlazeDisassembler LLVMMBlazeInfo LLVMMC LLVMMCParser LLVMMSP430CodeGen LLVMMSP430Info LLVMMipsCodeGen LLVMMipsInfo LLVMPTXCodeGen LLVMPTXInfo LLVMPowerPCCodeGen LLVMPowerPCInfo LLVMSparcCodeGen LLVMSparcInfo LLVMSupport LLVMSystemZCodeGen LLVMSystemZInfo LLVMTarget LLVMX86AsmParser LLVMX86CodeGen LLVMX86Disassembler LLVMX86Info LLVMXCoreCodeGen LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMMCJIT LLVMCore LLVMExecutionEngine LLVMRuntimeDyld LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMCParser LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMMC LLVMSupport) Modified: llvm/trunk/runtime/libprofile/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/CMakeLists.txt?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/CMakeLists.txt (original) +++ llvm/trunk/runtime/libprofile/CMakeLists.txt Thu Apr 28 21:12:06 2011 @@ -1,4 +1,4 @@ -add_llvm_loadable_module( profile_rt +set(SOURCES BasicBlockTracing.c CommonProfiling.c GCDAProfiling.c @@ -7,3 +7,13 @@ OptimalEdgeProfiling.c Profiling.h ) + +add_llvm_library( profile_rt-static ${SOURCES} ) +set_target_properties( profile_rt-static + PROPERTIES + OUTPUT_NAME "profile_rt" ) + +add_llvm_loadable_module( profile_rt-shared ${SOURCES} ) +set_target_properties( profile_rt-shared + PROPERTIES + OUTPUT_NAME "profile_rt" ) Modified: llvm/trunk/runtime/libprofile/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/Makefile?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/Makefile (original) +++ llvm/trunk/runtime/libprofile/Makefile Thu Apr 28 21:12:06 2011 @@ -13,9 +13,9 @@ ifneq ($(strip $(LLVMCC)),) BYTECODE_LIBRARY = 1 endif -SHARED_LIBRARY = 1 -LOADABLE_MODULE = 1 LIBRARYNAME = profile_rt +LINK_LIBS_IN_SHARED = 1 +SHARED_LIBRARY = 1 EXTRA_DIST = libprofile.exports EXPORTED_SYMBOL_FILE = $(PROJ_SRC_DIR)/libprofile.exports Modified: llvm/trunk/utils/profile.pl URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/profile.pl?rev=130470&r1=130469&r2=130470&view=diff ============================================================================== --- llvm/trunk/utils/profile.pl (original) +++ llvm/trunk/utils/profile.pl Thu Apr 28 21:12:06 2011 @@ -65,7 +65,7 @@ my $libdir = `llvm-config --libdir`; chomp $libdir; -my $LibProfPath = $libdir . "/profile_rt.so"; +my $LibProfPath = $libdir . "/libprofile_rt.so"; system "opt -q -f $ProfilePass $BytecodeFile -o $BytecodeFile.inst"; system "lli -fake-argv0 '$BytecodeFile' -load $LibProfPath " . From rafael.espindola at gmail.com Thu Apr 28 21:42:28 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 02:42:28 -0000 Subject: [llvm-commits] [llvm] r130471 - in /llvm/trunk: include/llvm/MC/MCDwarf.h lib/MC/MCDwarf.cpp Message-ID: <20110429024228.5EABA2A6C135@llvm.org> Author: rafael Date: Thu Apr 28 21:42:28 2011 New Revision: 130471 URL: http://llvm.org/viewvc/llvm-project?rev=130471&view=rev Log: Add an alternative implementation of CIE and FDE emission that outputs them in the same order as the one in CodeGen. Modified: llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=130471&r1=130470&r2=130471&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Thu Apr 28 21:42:28 2011 @@ -282,6 +282,7 @@ // This emits the frame info section. // static void Emit(MCStreamer &streamer); + static void EmitDarwin(MCStreamer &streamer); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS, const TargetAsmInfo &AsmInfo); Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130471&r1=130470&r2=130471&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 28 21:42:28 2011 @@ -824,9 +824,67 @@ }; } +// This is an implementation of CIE and FDE emission that is bug by bug +// compatible with the one in CodeGen. It is useful during the transition +// to make it easy to compare the outputs, but should probably be removed +// afterwards. +void MCDwarfFrameEmitter::EmitDarwin(MCStreamer &streamer) { + FrameEmitterImpl Emitter; + DenseMap Personalities; + const MCSymbol *aCIE = NULL; + const MCDwarfFrameInfo *aFrame = NULL; + + for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { + const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); + if (!frame.Personality) + continue; + if (Personalities.count(frame.Personality)) + continue; + + const MCSymbol *cieStart = &Emitter.EmitCIE(streamer, frame.Personality, + frame.PersonalityEncoding, + frame.Lsda, + frame.LsdaEncoding); + aCIE = cieStart; + aFrame = &frame; + Personalities[frame.Personality] = cieStart; + } + + if (Personalities.empty()) { + const MCDwarfFrameInfo &frame = streamer.getFrameInfo(0); + aCIE = &Emitter.EmitCIE(streamer, frame.Personality, + frame.PersonalityEncoding, frame.Lsda, + frame.LsdaEncoding); + aFrame = &frame; + } + + MCSymbol *fdeEnd = NULL; + for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { + const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); + const MCSymbol *cieStart = Personalities[frame.Personality]; + if (!cieStart) + cieStart = aCIE; + + fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame); + if (i != n - 1) + streamer.EmitLabel(fdeEnd); + } + + const MCContext &context = streamer.getContext(); + const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); + streamer.EmitValueToAlignment(asmInfo.getPointerSize()); + if (fdeEnd) + streamer.EmitLabel(fdeEnd); +} + void MCDwarfFrameEmitter::Emit(MCStreamer &streamer) { const MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); + if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { + EmitDarwin(streamer); + return; + } + MCSymbol *fdeEnd = NULL; DenseMap CIEStarts; FrameEmitterImpl Emitter; From rafael.espindola at gmail.com Thu Apr 28 22:06:30 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 03:06:30 -0000 Subject: [llvm-commits] [llvm] r130472 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110429030630.1217B2A6C135@llvm.org> Author: rafael Date: Thu Apr 28 22:06:29 2011 New Revision: 130472 URL: http://llvm.org/viewvc/llvm-project?rev=130472&view=rev Log: Last bit by bit compatibility patch to MCDwarf.cpp: If a FDE with no LSDA is assigned to a CIE that requires one, just output a 0. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130472&r1=130471&r2=130472&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 28 22:06:29 2011 @@ -517,7 +517,8 @@ unsigned lsdaEncoding); MCSymbol *EmitFDE(MCStreamer &streamer, const MCSymbol &cieStart, - const MCDwarfFrameInfo &frame); + const MCDwarfFrameInfo &frame, + bool forceLsda); void EmitCFIInstructions(MCStreamer &streamer, const std::vector &Instrs, MCSymbol *BaseLabel); @@ -727,7 +728,8 @@ MCSymbol *FrameEmitterImpl::EmitFDE(MCStreamer &streamer, const MCSymbol &cieStart, - const MCDwarfFrameInfo &frame) { + const MCDwarfFrameInfo &frame, + bool forceLsda) { MCContext &context = streamer.getContext(); MCSymbol *fdeStart = context.CreateTempSymbol(); MCSymbol *fdeEnd = context.CreateTempSymbol(); @@ -770,8 +772,15 @@ // Augmentation Data streamer.EmitLabel(augmentationStart); + + // When running in "CodeGen compatibility mode" a FDE with no LSDA can be + // assigned to a CIE that requires one. In that case we output a 0 (as does + // CodeGen). if (frame.Lsda) EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding); + else if (forceLsda) + streamer.EmitIntValue(0, size); + streamer.EmitLabel(augmentationEnd); // Call Frame Instructions @@ -862,10 +871,16 @@ for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); const MCSymbol *cieStart = Personalities[frame.Personality]; - if (!cieStart) + bool hasLSDA; + if (!cieStart) { cieStart = aCIE; + hasLSDA = aFrame->Lsda; + } else { + hasLSDA = true; + } - fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame); + fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame, + hasLSDA); if (i != n - 1) streamer.EmitLabel(fdeEnd); } @@ -898,7 +913,7 @@ cieStart = &Emitter.EmitCIE(streamer, frame.Personality, frame.PersonalityEncoding, frame.Lsda, frame.LsdaEncoding); - fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame); + fdeEnd = Emitter.EmitFDE(streamer, *cieStart, frame, false); if (i != n - 1) streamer.EmitLabel(fdeEnd); } From ofv at wanadoo.es Thu Apr 28 22:33:01 2011 From: ofv at wanadoo.es (=?utf-8?Q?=C3=93scar_Fuentes?=) Date: Fri, 29 Apr 2011 05:33:01 +0200 Subject: [llvm-commits] [llvm] r130470 - in /llvm/trunk: CMakeLists.txt cmake/modules/AddLLVM.cmake cmake/modules/LLVMLibDeps.cmake runtime/libprofile/CMakeLists.txt runtime/libprofile/Makefile utils/profile.pl References: <20110429021206.D59FD2A6C135@llvm.org> Message-ID: <87d3k591g2.fsf@wanadoo.es> Hello Nick. Nick Lewycky writes: [snip] > Oscar, this touches a change you made for EXCLUDE_FROM_ALL support -- I think > I've done the right thing, but please let me know (or fix and commit) if not! [snip] > - set_target_properties(profile_rt PROPERTIES EXCLUDE_FROM_ALL ON) > + set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON) That was a copy&pasto. Thanks for fixing it. The rest of the change looks ok, but please commit modifications to the library dependencies (LLVMLibDeps.txt) on its own revision, or together with the changes that produces the modification on the dependencies. [snip] From eli.friedman at gmail.com Thu Apr 28 23:08:36 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Thu, 28 Apr 2011 21:08:36 -0700 Subject: [llvm-commits] [llvm] r130338 - in /llvm/trunk: include/llvm/CodeGen/FastISel.h lib/CodeGen/SelectionDAG/FastISel.cpp lib/Target/X86/X86FastISel.cpp test/CodeGen/X86/fast-isel-x86-64.ll In-Reply-To: References: <20110427224155.767CC2A6C12D@llvm.org> Message-ID: On Thu, Apr 28, 2011 at 1:21 AM, Frits van Bommel wrote: > On Thu, Apr 28, 2011 at 12:41 AM, Eli Friedman wrote: >> + ?virtual unsigned TargetMaterializeFloatZero(const ConstantFP* CF) { >> + ? ?return 0; >> + ?} > >> getRegForValue(Constant::getNullValue(TD.getIntPtrType(V->getContext()))); >> ? } else if (const ConstantFP *CF = dyn_cast(V)) { >> - ? ?// Try to emit the constant directly. >> - ? ?Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); >> + ? ?if (CF->isZero()) { >> + ? ? ?Reg = TargetMaterializeFloatZero(CF); >> + ? ?} else { >> + ? ? ?// Try to emit the constant directly. >> + ? ? ?Reg = FastEmit_f(VT, VT, ISD::ConstantFP, CF); >> + ? ?} > > This doesn't seem to handle the case where FastEmit_f() would work but > TargetMaterializeFloatZero() isn't overridden, which would be the > "obvious" way to implement a target that doesn't need to handle 0.0 > specially. > IMHO, this should either try TargetMaterializeFloatZero() first and > fall back to FastEmit_f if it returns 0, or the default > TargetMaterializeFloatZero() implementation should be changed to call > FastEmit_f(). Maybe... in practice, it doesn't matter at the moment, and this stuff will disappear if we add support for fast-isel matching specific immediates. -Eli From sabre at nondot.org Fri Apr 29 00:24:07 2011 From: sabre at nondot.org (Chris Lattner) Date: Fri, 29 Apr 2011 05:24:07 -0000 Subject: [llvm-commits] [llvm] r130473 - /llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Message-ID: <20110429052407.A5D902A6C135@llvm.org> Author: lattner Date: Fri Apr 29 00:24:07 2011 New Revision: 130473 URL: http://llvm.org/viewvc/llvm-project?rev=130473&view=rev Log: add a missing operator that caused us to have to use (*MIB).foo everywhere. Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Modified: llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h?rev=130473&r1=130472&r2=130473&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineInstrBuilder.h Fri Apr 29 00:24:07 2011 @@ -48,6 +48,7 @@ /// Allow automatic conversion to the machine instruction we are working on. /// operator MachineInstr*() const { return MI; } + MachineInstr *operator->() const { return MI; } operator MachineBasicBlock::iterator() const { return MI; } /// addReg - Add a new virtual register operand... From sabre at nondot.org Fri Apr 29 00:24:29 2011 From: sabre at nondot.org (Chris Lattner) Date: Fri, 29 Apr 2011 05:24:29 -0000 Subject: [llvm-commits] [llvm] r130474 - in /llvm/trunk/lib/Target/ARM: ARMBaseInstrInfo.cpp ARMExpandPseudoInsts.cpp ARMLoadStoreOptimizer.cpp Thumb2SizeReduction.cpp Message-ID: <20110429052430.002BD2A6C135@llvm.org> Author: lattner Date: Fri Apr 29 00:24:29 2011 New Revision: 130474 URL: http://llvm.org/viewvc/llvm-project?rev=130474&view=rev Log: use the MachineInstrBuilder operator-> to simplify some code. There are probably more instances of this floating around. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=130474&r1=130473&r2=130474&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Fri Apr 29 00:24:29 2011 @@ -1021,7 +1021,7 @@ MachineInstrBuilder MIB = BuildMI(MBB, I, Orig->getDebugLoc(), get(Opcode), DestReg) .addConstantPoolIndex(CPI).addImm(PCLabelId); - (*MIB).setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); + MIB->setMemRefs(Orig->memoperands_begin(), Orig->memoperands_end()); break; } } Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=130474&r1=130473&r2=130474&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Fri Apr 29 00:24:29 2011 @@ -457,7 +457,7 @@ TransferImpOps(MI, MIB, MIB); // Transfer memoperands. - (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MI.eraseFromParent(); } @@ -500,13 +500,12 @@ MIB.addOperand(MI.getOperand(OpIdx++)); MIB.addOperand(MI.getOperand(OpIdx++)); - if (SrcIsKill) - // Add an implicit kill for the super-reg. - (*MIB).addRegisterKilled(SrcReg, TRI, true); + if (SrcIsKill) // Add an implicit kill for the super-reg. + MIB->addRegisterKilled(SrcReg, TRI, true); TransferImpOps(MI, MIB, MIB); // Transfer memoperands. - (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MI.eraseFromParent(); } @@ -630,9 +629,8 @@ MIB.addOperand(MI.getOperand(OpIdx++)); MIB.addOperand(MI.getOperand(OpIdx++)); - if (SrcIsKill) - // Add an implicit kill for the super-reg. - (*MIB).addRegisterKilled(SrcReg, TRI, true); + if (SrcIsKill) // Add an implicit kill for the super-reg. + MIB->addRegisterKilled(SrcReg, TRI, true); TransferImpOps(MI, MIB, MIB); MI.eraseFromParent(); } @@ -663,8 +661,8 @@ unsigned SOImmValV2 = ARM_AM::getSOImmTwoPartSecond(ImmVal); LO16 = LO16.addImm(SOImmValV1); HI16 = HI16.addImm(SOImmValV2); - (*LO16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); - (*HI16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + LO16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + HI16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); LO16.addImm(Pred).addReg(PredReg).addReg(0); HI16.addImm(Pred).addReg(PredReg).addReg(0); TransferImpOps(MI, LO16, HI16); @@ -700,8 +698,8 @@ HI16 = HI16.addGlobalAddress(GV, MO.getOffset(), TF | ARMII::MO_HI16); } - (*LO16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); - (*HI16).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + LO16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + HI16->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); LO16.addImm(Pred).addReg(PredReg); HI16.addImm(Pred).addReg(PredReg); @@ -864,7 +862,7 @@ TII->get(ARM::BL)) .addExternalSymbol("__aeabi_read_tp", 0); - (*MIB).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); TransferImpOps(MI, MIB, MIB); MI.eraseFromParent(); return true; @@ -879,7 +877,7 @@ AddDefaultPred(BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(NewLdOpc), DstReg) .addOperand(MI.getOperand(1))); - (*MIB1).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + MIB1->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); MachineInstrBuilder MIB2 = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(ARM::tPICADD)) .addReg(DstReg, RegState::Define | getDeadRegState(DstIsDead)) @@ -935,7 +933,7 @@ if (isARM) { AddDefaultPred(MIB3); if (Opcode == ARM::MOV_ga_pcrel_ldr) - (*MIB2).setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); + MIB2->setMemRefs(MI.memoperands_begin(), MI.memoperands_end()); } TransferImpOps(MI, MIB1, MIB3); MI.eraseFromParent(); @@ -1027,9 +1025,8 @@ unsigned D1 = TRI->getSubReg(SrcReg, ARM::dsub_1); MIB.addReg(D0).addReg(D1); - if (SrcIsKill) - // Add an implicit kill for the Q register. - (*MIB).addRegisterKilled(SrcReg, TRI, true); + if (SrcIsKill) // Add an implicit kill for the Q register. + MIB->addRegisterKilled(SrcReg, TRI, true); TransferImpOps(MI, MIB, MIB); MI.eraseFromParent(); Modified: llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp?rev=130474&r1=130473&r2=130474&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMLoadStoreOptimizer.cpp Fri Apr 29 00:24:29 2011 @@ -761,7 +761,7 @@ MIB.addOperand(MI->getOperand(OpNum)); // Transfer memoperands. - (*MIB).setMemRefs(MI->memoperands_begin(), MI->memoperands_end()); + MIB->setMemRefs(MI->memoperands_begin(), MI->memoperands_end()); MBB.erase(MBBI); return true; Modified: llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp?rev=130474&r1=130473&r2=130474&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb2SizeReduction.cpp Fri Apr 29 00:24:29 2011 @@ -465,7 +465,7 @@ MIB.addOperand(MI->getOperand(OpNum)); // Transfer memoperands. - (*MIB).setMemRefs(MI->memoperands_begin(), MI->memoperands_end()); + MIB->setMemRefs(MI->memoperands_begin(), MI->memoperands_end()); // Transfer MI flags. MIB.setMIFlags(MI->getFlags()); From sabre at nondot.org Fri Apr 29 00:40:18 2011 From: sabre at nondot.org (Chris Lattner) Date: Fri, 29 Apr 2011 05:40:18 -0000 Subject: [llvm-commits] [llvm] r130475 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20110429054019.12CBD2A6C135@llvm.org> Author: lattner Date: Fri Apr 29 00:40:18 2011 New Revision: 130475 URL: http://llvm.org/viewvc/llvm-project?rev=130475&view=rev Log: clean up after Sean's r127646 patch. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=130475&r1=130474&r2=130475&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri Apr 29 00:40:18 2011 @@ -135,18 +135,16 @@ // is used instead. Register-to-register movss/movsd is not modeled as an // INSERT_SUBREG because INSERT_SUBREG requires that the insert be implementable // in terms of a copy, and just mentioned, we don't use movss/movsd for copies. -let isAsmParserOnly = 0 in { - def VMOVSSrr : sse12_move_rr, XS, VEX_4V; - def VMOVSDrr : sse12_move_rr, XD, VEX_4V; +def VMOVSSrr : sse12_move_rr, XS, VEX_4V; +def VMOVSDrr : sse12_move_rr, XD, VEX_4V; - let canFoldAsLoad = 1, isReMaterializable = 1 in { - def VMOVSSrm : sse12_move_rm, XS, VEX; +let canFoldAsLoad = 1, isReMaterializable = 1 in { + def VMOVSSrm : sse12_move_rm, XS, VEX; - let AddedComplexity = 20 in - def VMOVSDrm : sse12_move_rm, XD, VEX; - } + let AddedComplexity = 20 in + def VMOVSDrm : sse12_move_rm, XD, VEX; } let Constraints = "$src1 = $dst" in { @@ -218,14 +216,12 @@ "movsd\t{$src, $dst|$dst, $src}", [(store FR64:$src, addr:$dst)]>; -let isAsmParserOnly = 0 in { def VMOVSSmr : SI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src), "movss\t{$src, $dst|$dst, $src}", [(store FR32:$src, addr:$dst)]>, XS, VEX; def VMOVSDmr : SI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src), "movsd\t{$src, $dst|$dst, $src}", [(store FR64:$src, addr:$dst)]>, XD, VEX; -} // Extract and store. def : Pat<(store (f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))), @@ -251,7 +247,6 @@ [(set RC:$dst, (ld_frag addr:$src))], d>; } -let isAsmParserOnly = 0 in { defm VMOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32, "movaps", SSEPackedSingle>, VEX; defm VMOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64, @@ -269,7 +264,6 @@ "movups", SSEPackedSingle>, VEX; defm VMOVUPDY : sse12_mov_packed<0x10, VR256, f256mem, loadv4f64, "movupd", SSEPackedDouble, 0>, OpSize, VEX; -} defm MOVAPS : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv4f32, "movaps", SSEPackedSingle>, TB; defm MOVAPD : sse12_mov_packed<0x28, VR128, f128mem, alignedloadv2f64, @@ -279,7 +273,6 @@ defm MOVUPD : sse12_mov_packed<0x10, VR128, f128mem, loadv2f64, "movupd", SSEPackedDouble, 0>, TB, OpSize; -let isAsmParserOnly = 0 in { def VMOVAPSmr : VPSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movaps\t{$src, $dst|$dst, $src}", [(alignedstore (v4f32 VR128:$src), addr:$dst)]>, VEX; @@ -304,7 +297,6 @@ def VMOVUPDYmr : VPDI<0x11, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src), "movupd\t{$src, $dst|$dst, $src}", [(store (v4f64 VR256:$src), addr:$dst)]>, VEX; -} def : Pat<(int_x86_avx_loadu_ps_256 addr:$src), (VMOVUPSYrm addr:$src)>; def : Pat<(int_x86_avx_storeu_ps_256 addr:$dst, VR256:$src), @@ -328,16 +320,14 @@ [(store (v2f64 VR128:$src), addr:$dst)]>; // Intrinsic forms of MOVUPS/D load and store -let isAsmParserOnly = 0 in { - def VMOVUPSmr_Int : VPSI<0x11, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movups\t{$src, $dst|$dst, $src}", - [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>, VEX; - def VMOVUPDmr_Int : VPDI<0x11, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movupd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>, VEX; -} +def VMOVUPSmr_Int : VPSI<0x11, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movups\t{$src, $dst|$dst, $src}", + [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>, VEX; +def VMOVUPDmr_Int : VPDI<0x11, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movupd\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>, VEX; def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movups\t{$src, $dst|$dst, $src}", @@ -366,7 +356,7 @@ SSEPackedDouble>, TB, OpSize; } -let isAsmParserOnly = 0, AddedComplexity = 20 in { +let AddedComplexity = 20 in { defm VMOVL : sse12_mov_hilo_packed<0x12, VR128, movlp, "movlp", "\t{$src2, $src1, $dst|$dst, $src1, $src2}">, VEX_4V; defm VMOVH : sse12_mov_hilo_packed<0x16, VR128, movlhps, "movhp", @@ -379,7 +369,6 @@ "\t{$src2, $dst|$dst, $src2}">; } -let isAsmParserOnly = 0 in { def VMOVLPSmr : VPSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movlps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)), @@ -388,7 +377,6 @@ "movlpd\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract (v2f64 VR128:$src), (iPTR 0))), addr:$dst)]>, VEX; -} def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movlps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)), @@ -400,7 +388,6 @@ // v2f64 extract element 1 is always custom lowered to unpack high to low // and extract element 0 so the non-store version isn't too horrible. -let isAsmParserOnly = 0 in { def VMOVHPSmr : VPSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract @@ -413,7 +400,6 @@ (v2f64 (unpckh VR128:$src, (undef))), (iPTR 0))), addr:$dst)]>, VEX; -} def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), "movhps\t{$src, $dst|$dst, $src}", [(store (f64 (vector_extract @@ -425,7 +411,7 @@ (v2f64 (unpckh VR128:$src, (undef))), (iPTR 0))), addr:$dst)]>; -let isAsmParserOnly = 0, AddedComplexity = 20 in { +let AddedComplexity = 20 in { def VMOVLHPSrr : VPSI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), "movlhps\t{$src2, $src1, $dst|$dst, $src1, $src2}", @@ -500,7 +486,6 @@ !strconcat(asm,"\t{$src, $src1, $dst|$dst, $src1, $src}"), []>; } -let isAsmParserOnly = 0 in { defm VCVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32, "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX; defm VCVTTSS2SI64 : sse12_cvt_s<0x2C, FR32, GR64, fp_to_sint, f32mem, loadf32, @@ -526,7 +511,6 @@ VEX_4V; defm VCVTSI2SD64 : sse12_vcvt_avx<0x2A, GR64, FR64, i64mem, "cvtsi2sd{q}">, XD, VEX_4V, VEX_W; -} defm CVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32, "cvttss2si\t{$src, $dst|$dst, $src}">, XS; @@ -575,27 +559,25 @@ [(set DstRC:$dst, (Int DstRC:$src1, (ld_frag addr:$src2)))]>; } -let isAsmParserOnly = 0 in { - defm Int_VCVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si, - f32mem, load, "cvtss2si">, XS, VEX; - defm Int_VCVTSS2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, - int_x86_sse_cvtss2si64, f32mem, load, "cvtss2si">, - XS, VEX, VEX_W; - defm Int_VCVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si, - f128mem, load, "cvtsd2si">, XD, VEX; - defm Int_VCVTSD2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, - int_x86_sse2_cvtsd2si64, f128mem, load, "cvtsd2si">, - XD, VEX, VEX_W; - - // FIXME: The asm matcher has a hack to ignore instructions with _Int and Int_ - // Get rid of this hack or rename the intrinsics, there are several - // intructions that only match with the intrinsic form, why create duplicates - // to let them be recognized by the assembler? - defm VCVTSD2SI_alt : sse12_cvt_s_np<0x2D, FR64, GR32, f64mem, - "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX; - defm VCVTSD2SI64 : sse12_cvt_s_np<0x2D, FR64, GR64, f64mem, - "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_W; -} +defm Int_VCVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si, + f32mem, load, "cvtss2si">, XS, VEX; +defm Int_VCVTSS2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, + int_x86_sse_cvtss2si64, f32mem, load, "cvtss2si">, + XS, VEX, VEX_W; +defm Int_VCVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si, + f128mem, load, "cvtsd2si">, XD, VEX; +defm Int_VCVTSD2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, + int_x86_sse2_cvtsd2si64, f128mem, load, "cvtsd2si">, + XD, VEX, VEX_W; + +// FIXME: The asm matcher has a hack to ignore instructions with _Int and Int_ +// Get rid of this hack or rename the intrinsics, there are several +// intructions that only match with the intrinsic form, why create duplicates +// to let them be recognized by the assembler? +defm VCVTSD2SI_alt : sse12_cvt_s_np<0x2D, FR64, GR32, f64mem, + "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX; +defm VCVTSD2SI64 : sse12_cvt_s_np<0x2D, FR64, GR64, f64mem, + "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_W; defm Int_CVTSS2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse_cvtss2si, f32mem, load, "cvtss2si">, XS; defm Int_CVTSS2SI64 : sse12_cvt_sint<0x2D, VR128, GR64, int_x86_sse_cvtss2si64, @@ -606,18 +588,16 @@ f128mem, load, "cvtsd2si{q}">, XD, REX_W; -let isAsmParserOnly = 0 in { - defm Int_VCVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128, - int_x86_sse_cvtsi2ss, i32mem, loadi32, "cvtsi2ss", 0>, XS, VEX_4V; - defm Int_VCVTSI2SS64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128, - int_x86_sse_cvtsi642ss, i64mem, loadi64, "cvtsi2ss", 0>, XS, VEX_4V, - VEX_W; - defm Int_VCVTSI2SD : sse12_cvt_sint_3addr<0x2A, GR32, VR128, - int_x86_sse2_cvtsi2sd, i32mem, loadi32, "cvtsi2sd", 0>, XD, VEX_4V; - defm Int_VCVTSI2SD64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128, - int_x86_sse2_cvtsi642sd, i64mem, loadi64, "cvtsi2sd", 0>, XD, - VEX_4V, VEX_W; -} +defm Int_VCVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128, + int_x86_sse_cvtsi2ss, i32mem, loadi32, "cvtsi2ss", 0>, XS, VEX_4V; +defm Int_VCVTSI2SS64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128, + int_x86_sse_cvtsi642ss, i64mem, loadi64, "cvtsi2ss", 0>, XS, VEX_4V, + VEX_W; +defm Int_VCVTSI2SD : sse12_cvt_sint_3addr<0x2A, GR32, VR128, + int_x86_sse2_cvtsi2sd, i32mem, loadi32, "cvtsi2sd", 0>, XD, VEX_4V; +defm Int_VCVTSI2SD64 : sse12_cvt_sint_3addr<0x2A, GR64, VR128, + int_x86_sse2_cvtsi642sd, i64mem, loadi64, "cvtsi2sd", 0>, XD, + VEX_4V, VEX_W; let Constraints = "$src1 = $dst" in { defm Int_CVTSI2SS : sse12_cvt_sint_3addr<0x2A, GR32, VR128, @@ -637,7 +617,6 @@ /// SSE 1 Only // Aliases for intrinsics -let isAsmParserOnly = 0 in { defm Int_VCVTTSS2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse_cvttss2si, f32mem, load, "cvttss2si">, XS, VEX; defm Int_VCVTTSS2SI64 : sse12_cvt_sint<0x2C, VR128, GR64, @@ -648,7 +627,6 @@ defm Int_VCVTTSD2SI64 : sse12_cvt_sint<0x2C, VR128, GR64, int_x86_sse2_cvttsd2si64, f128mem, load, "cvttsd2si">, XD, VEX, VEX_W; -} defm Int_CVTTSS2SI : sse12_cvt_sint<0x2C, VR128, GR32, int_x86_sse_cvttss2si, f32mem, load, "cvttss2si">, XS; defm Int_CVTTSS2SI64 : sse12_cvt_sint<0x2C, VR128, GR64, @@ -660,7 +638,7 @@ int_x86_sse2_cvttsd2si64, f128mem, load, "cvttsd2si{q}">, XD, REX_W; -let isAsmParserOnly = 0, Pattern = [] in { +let Pattern = [] in { defm VCVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load, "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS, VEX; defm VCVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load, @@ -686,7 +664,6 @@ /// SSE 2 Only // Convert scalar double to scalar single -let isAsmParserOnly = 0 in { def VCVTSD2SSrr : VSDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src1, FR64:$src2), "cvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, @@ -695,7 +672,6 @@ (ins FR64:$src1, f64mem:$src2), "vcvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, XD, Requires<[HasAVX, OptForSize]>, VEX_4V; -} def : Pat<(f32 (fround FR64:$src)), (VCVTSD2SSrr FR64:$src, FR64:$src)>, Requires<[HasAVX]>; @@ -707,7 +683,6 @@ [(set FR32:$dst, (fround (loadf64 addr:$src)))]>, XD, Requires<[HasSSE2, OptForSize]>; -let isAsmParserOnly = 0 in defm Int_VCVTSD2SS: sse12_cvt_sint_3addr<0x5A, VR128, VR128, int_x86_sse2_cvtsd2ss, f64mem, load, "cvtsd2ss", 0>, XS, VEX_4V; @@ -716,7 +691,7 @@ int_x86_sse2_cvtsd2ss, f64mem, load, "cvtsd2ss">, XS; // Convert scalar single to scalar double -let isAsmParserOnly = 0 in { // SSE2 instructions with XS prefix +// SSE2 instructions with XS prefix def VCVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src1, FR32:$src2), "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}", @@ -725,7 +700,6 @@ (ins FR32:$src1, f32mem:$src2), "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, XS, VEX_4V, Requires<[HasAVX, OptForSize]>; -} def : Pat<(f64 (fextend FR32:$src)), (VCVTSS2SDrr FR32:$src, FR32:$src)>, Requires<[HasAVX]>; @@ -738,7 +712,6 @@ [(set FR64:$dst, (extloadf32 addr:$src))]>, XS, Requires<[HasSSE2, OptForSize]>; -let isAsmParserOnly = 0 in { def Int_VCVTSS2SDrr: I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}", @@ -751,7 +724,6 @@ [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1, (load addr:$src2)))]>, XS, VEX_4V, Requires<[HasAVX]>; -} let Constraints = "$src1 = $dst" in { // SSE2 instructions with XS prefix def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), @@ -772,7 +744,7 @@ Requires<[HasSSE2, OptForSpeed]>; // Convert doubleword to packed single/double fp -let isAsmParserOnly = 0 in { // SSE2 instructions without OpSize prefix +// SSE2 instructions without OpSize prefix def Int_VCVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtdq2ps\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>, @@ -782,7 +754,6 @@ [(set VR128:$dst, (int_x86_sse2_cvtdq2ps (bitconvert (memopv2i64 addr:$src))))]>, TB, VEX, Requires<[HasAVX]>; -} def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtdq2ps\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>, @@ -794,7 +765,7 @@ TB, Requires<[HasSSE2]>; // FIXME: why the non-intrinsic version is described as SSE3? -let isAsmParserOnly = 0 in { // SSE2 instructions with XS prefix +// SSE2 instructions with XS prefix def Int_VCVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtdq2pd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>, @@ -804,7 +775,6 @@ [(set VR128:$dst, (int_x86_sse2_cvtdq2pd (bitconvert (memopv2i64 addr:$src))))]>, XS, VEX, Requires<[HasAVX]>; -} def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtdq2pd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>, @@ -817,7 +787,6 @@ // Convert packed single/double fp to doubleword -let isAsmParserOnly = 0 in { def VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTPS2DQrm : VPDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), @@ -826,13 +795,11 @@ "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTPS2DQYrm : VPDI<0x5B, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", []>, VEX; -} def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", []>; def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", []>; -let isAsmParserOnly = 0 in { def Int_VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>, @@ -842,7 +809,6 @@ "cvtps2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtps2dq (memop addr:$src)))]>, VEX; -} def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtps2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>; @@ -851,7 +817,7 @@ [(set VR128:$dst, (int_x86_sse2_cvtps2dq (memop addr:$src)))]>; -let isAsmParserOnly = 0 in { // SSE2 packed instructions with XD prefix +// SSE2 packed instructions with XD prefix def Int_VCVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtpd2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>, @@ -861,7 +827,6 @@ [(set VR128:$dst, (int_x86_sse2_cvtpd2dq (memop addr:$src)))]>, XD, VEX, Requires<[HasAVX]>; -} def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtpd2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>, @@ -874,7 +839,7 @@ // Convert with truncation packed single/double fp to doubleword -let isAsmParserOnly = 0 in { // SSE2 packed instructions with XS prefix +// SSE2 packed instructions with XS prefix def VCVTTPS2DQrr : VSSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTTPS2DQrm : VSSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), @@ -883,7 +848,6 @@ "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTTPS2DQYrm : VSSI<0x5B, MRMSrcMem, (outs VR256:$dst), (ins f256mem:$src), "cvttps2dq\t{$src, $dst|$dst, $src}", []>, VEX; -} def CVTTPS2DQrr : SSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvttps2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -894,7 +858,6 @@ (int_x86_sse2_cvttps2dq (memop addr:$src)))]>; -let isAsmParserOnly = 0 in { def Int_VCVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvttps2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -905,9 +868,7 @@ [(set VR128:$dst, (int_x86_sse2_cvttps2dq (memop addr:$src)))]>, XS, VEX, Requires<[HasAVX]>; -} -let isAsmParserOnly = 0 in { def Int_VCVTTPD2DQrr : VPDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvttpd2dq\t{$src, $dst|$dst, $src}", @@ -918,7 +879,6 @@ "cvttpd2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvttpd2dq (memop addr:$src)))]>, VEX; -} def CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvttpd2dq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>; @@ -927,7 +887,6 @@ [(set VR128:$dst, (int_x86_sse2_cvttpd2dq (memop addr:$src)))]>; -let isAsmParserOnly = 0 in { // The assembler can recognize rr 256-bit instructions by seeing a ymm // register, but the same isn't true when using memory operands instead. // Provide other assembly rr and rm forms to address this explicitly. @@ -947,10 +906,9 @@ "cvttpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTTPD2DQYrm : VPDI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f256mem:$src), "cvttpd2dqy\t{$src, $dst|$dst, $src}", []>, VEX, VEX_L; -} // Convert packed single to packed double -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // SSE2 instructions without OpSize prefix def VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtps2pd\t{$src, $dst|$dst, $src}", []>, VEX; @@ -966,7 +924,6 @@ def CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), "cvtps2pd\t{$src, $dst|$dst, $src}", []>, TB; -let isAsmParserOnly = 0 in { def Int_VCVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtps2pd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>, @@ -976,7 +933,6 @@ [(set VR128:$dst, (int_x86_sse2_cvtps2pd (load addr:$src)))]>, VEX, Requires<[HasAVX]>; -} def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtps2pd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>, @@ -988,7 +944,6 @@ TB, Requires<[HasSSE2]>; // Convert packed double to packed single -let isAsmParserOnly = 0 in { // The assembler can recognize rr 256-bit instructions by seeing a ymm // register, but the same isn't true when using memory operands instead. // Provide other assembly rr and rm forms to address this explicitly. @@ -1008,14 +963,12 @@ "cvtpd2psy\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTPD2PSYrm : VPDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f256mem:$src), "cvtpd2psy\t{$src, $dst|$dst, $src}", []>, VEX, VEX_L; -} def CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtpd2ps\t{$src, $dst|$dst, $src}", []>; def CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), "cvtpd2ps\t{$src, $dst|$dst, $src}", []>; -let isAsmParserOnly = 0 in { def Int_VCVTPD2PSrr : VPDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtpd2ps\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>; @@ -1024,7 +977,6 @@ "cvtpd2ps\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtpd2ps (memop addr:$src)))]>; -} def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtpd2ps\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>; @@ -1093,7 +1045,7 @@ asm_alt, []>; } -let neverHasSideEffects = 1, isAsmParserOnly = 0 in { +let neverHasSideEffects = 1 in { defm VCMPSS : sse12_cmp_scalar, @@ -1126,14 +1078,12 @@ } // Aliases to match intrinsics which expect XMM operand(s). -let isAsmParserOnly = 0 in { - defm Int_VCMPSS : sse12_cmp_scalar_int, - XS, VEX_4V; - defm Int_VCMPSD : sse12_cmp_scalar_int, - XD, VEX_4V; -} +defm Int_VCMPSS : sse12_cmp_scalar_int, + XS, VEX_4V; +defm Int_VCMPSD : sse12_cmp_scalar_int, + XD, VEX_4V; let Constraints = "$src1 = $dst" in { defm Int_CMPSS : sse12_cmp_scalar_int, XS; @@ -1156,28 +1106,26 @@ } let Defs = [EFLAGS] in { - let isAsmParserOnly = 0 in { - defm VUCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32, - "ucomiss", SSEPackedSingle>, VEX; - defm VUCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64, - "ucomisd", SSEPackedDouble>, OpSize, VEX; - let Pattern = [] in { - defm VCOMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load, - "comiss", SSEPackedSingle>, VEX; - defm VCOMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load, - "comisd", SSEPackedDouble>, OpSize, VEX; - } - - defm Int_VUCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem, - load, "ucomiss", SSEPackedSingle>, VEX; - defm Int_VUCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem, - load, "ucomisd", SSEPackedDouble>, OpSize, VEX; - - defm Int_VCOMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem, - load, "comiss", SSEPackedSingle>, VEX; - defm Int_VCOMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem, - load, "comisd", SSEPackedDouble>, OpSize, VEX; + defm VUCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32, + "ucomiss", SSEPackedSingle>, VEX; + defm VUCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64, + "ucomisd", SSEPackedDouble>, OpSize, VEX; + let Pattern = [] in { + defm VCOMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load, + "comiss", SSEPackedSingle>, VEX; + defm VCOMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load, + "comisd", SSEPackedDouble>, OpSize, VEX; } + + defm Int_VUCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem, + load, "ucomiss", SSEPackedSingle>, VEX; + defm Int_VUCOMISD : sse12_ord_cmp<0x2E, VR128, X86ucomi, v2f64, f128mem, + load, "ucomisd", SSEPackedDouble>, OpSize, VEX; + + defm Int_VCOMISS : sse12_ord_cmp<0x2F, VR128, X86comi, v4f32, f128mem, + load, "comiss", SSEPackedSingle>, VEX; + defm Int_VCOMISD : sse12_ord_cmp<0x2F, VR128, X86comi, v2f64, f128mem, + load, "comisd", SSEPackedDouble>, OpSize, VEX; defm UCOMISS : sse12_ord_cmp<0x2E, FR32, X86cmp, f32, f32mem, loadf32, "ucomiss", SSEPackedSingle>, TB; defm UCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64, @@ -1223,24 +1171,22 @@ asm_alt, [], d>; } -let isAsmParserOnly = 0 in { - defm VCMPPS : sse12_cmp_packed, VEX_4V; - defm VCMPPD : sse12_cmp_packed, OpSize, VEX_4V; - defm VCMPPSY : sse12_cmp_packed, VEX_4V; - defm VCMPPDY : sse12_cmp_packed, OpSize, VEX_4V; -} +defm VCMPPS : sse12_cmp_packed, VEX_4V; +defm VCMPPD : sse12_cmp_packed, OpSize, VEX_4V; +defm VCMPPSY : sse12_cmp_packed, VEX_4V; +defm VCMPPDY : sse12_cmp_packed, OpSize, VEX_4V; let Constraints = "$src1 = $dst" in { defm CMPPS : sse12_cmp_packed; } -let isAsmParserOnly = 0 in { - defm VSHUFPS : sse12_shuffle, TB, VEX_4V; - defm VSHUFPSY : sse12_shuffle, TB, VEX_4V; - defm VSHUFPD : sse12_shuffle, TB, OpSize, VEX_4V; - defm VSHUFPDY : sse12_shuffle, TB, OpSize, VEX_4V; -} +defm VSHUFPS : sse12_shuffle, TB, VEX_4V; +defm VSHUFPSY : sse12_shuffle, TB, VEX_4V; +defm VSHUFPD : sse12_shuffle, TB, OpSize, VEX_4V; +defm VSHUFPDY : sse12_shuffle, TB, OpSize, VEX_4V; let Constraints = "$src1 = $dst" in { defm SHUFPS : sse12_shuffle, VEX_4V; - defm VUNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64, - VR128, f128mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedDouble>, OpSize, VEX_4V; - defm VUNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32, - VR128, f128mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedSingle>, VEX_4V; - defm VUNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64, - VR128, f128mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedDouble>, OpSize, VEX_4V; - - defm VUNPCKHPSY: sse12_unpack_interleave<0x15, unpckh, v8f32, memopv8f32, - VR256, f256mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedSingle>, VEX_4V; - defm VUNPCKHPDY: sse12_unpack_interleave<0x15, unpckh, v4f64, memopv4f64, - VR256, f256mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedDouble>, OpSize, VEX_4V; - defm VUNPCKLPSY: sse12_unpack_interleave<0x14, unpckl, v8f32, memopv8f32, - VR256, f256mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedSingle>, VEX_4V; - defm VUNPCKLPDY: sse12_unpack_interleave<0x14, unpckl, v4f64, memopv4f64, - VR256, f256mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - SSEPackedDouble>, OpSize, VEX_4V; - } + defm VUNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32, + VR128, f128mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedSingle>, VEX_4V; + defm VUNPCKHPD: sse12_unpack_interleave<0x15, unpckh, v2f64, memopv2f64, + VR128, f128mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedDouble>, OpSize, VEX_4V; + defm VUNPCKLPS: sse12_unpack_interleave<0x14, unpckl, v4f32, memopv4f32, + VR128, f128mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedSingle>, VEX_4V; + defm VUNPCKLPD: sse12_unpack_interleave<0x14, unpckl, v2f64, memopv2f64, + VR128, f128mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedDouble>, OpSize, VEX_4V; + + defm VUNPCKHPSY: sse12_unpack_interleave<0x15, unpckh, v8f32, memopv8f32, + VR256, f256mem, "unpckhps\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedSingle>, VEX_4V; + defm VUNPCKHPDY: sse12_unpack_interleave<0x15, unpckh, v4f64, memopv4f64, + VR256, f256mem, "unpckhpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedDouble>, OpSize, VEX_4V; + defm VUNPCKLPSY: sse12_unpack_interleave<0x14, unpckl, v8f32, memopv8f32, + VR256, f256mem, "unpcklps\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedSingle>, VEX_4V; + defm VUNPCKLPDY: sse12_unpack_interleave<0x14, unpckl, v4f64, memopv4f64, + VR256, f256mem, "unpcklpd\t{$src2, $src1, $dst|$dst, $src1, $src2}", + SSEPackedDouble>, OpSize, VEX_4V; let Constraints = "$src1 = $dst" in { defm UNPCKHPS: sse12_unpack_interleave<0x15, unpckh, v4f32, memopv4f32, @@ -1390,30 +1332,28 @@ defm MOVMSKPD : sse12_extr_sign_mask, TB, OpSize; -let isAsmParserOnly = 0 in { - defm VMOVMSKPS : sse12_extr_sign_mask, VEX; - defm VMOVMSKPD : sse12_extr_sign_mask, OpSize, - VEX; - defm VMOVMSKPSY : sse12_extr_sign_mask, VEX; - defm VMOVMSKPDY : sse12_extr_sign_mask, OpSize, - VEX; +defm VMOVMSKPS : sse12_extr_sign_mask, VEX; +defm VMOVMSKPD : sse12_extr_sign_mask, OpSize, + VEX; +defm VMOVMSKPSY : sse12_extr_sign_mask, VEX; +defm VMOVMSKPDY : sse12_extr_sign_mask, OpSize, + VEX; - // Assembler Only - def VMOVMSKPSr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), - "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; - def VMOVMSKPDr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), - "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, - VEX; - def VMOVMSKPSYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), - "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; - def VMOVMSKPDYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), - "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, - VEX; -} +// Assembler Only +def VMOVMSKPSr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), + "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; +def VMOVMSKPDr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), + "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, + VEX; +def VMOVMSKPSYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), + "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; +def VMOVMSKPDYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), + "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, + VEX; //===----------------------------------------------------------------------===// // SSE 1 & 2 - Misc aliasing of packed SSE 1 & 2 instructions @@ -1468,13 +1408,11 @@ /// multiclass sse12_fp_alias_pack_logical opc, string OpcodeStr, SDNode OpNode> { - let isAsmParserOnly = 0 in { - defm V#NAME#PS : sse12_fp_packed, VEX_4V; + defm V#NAME#PS : sse12_fp_packed, VEX_4V; - defm V#NAME#PD : sse12_fp_packed, OpSize, VEX_4V; - } + defm V#NAME#PD : sse12_fp_packed, OpSize, VEX_4V; let Constraints = "$src1 = $dst" in { defm PS : sse12_fp_packed opc, string OpcodeStr, SDNode OpNode, int HasPat = 0, list> Pattern = []> { - let isAsmParserOnly = 0, Pattern = [] in { + let Pattern = [] in { defm V#NAME#PS : sse12_fp_packed_logical_rm opc, string OpcodeStr> { defm PSY : sse12_fp_packed_logical_rm, VEX_4V; @@ -1555,7 +1492,6 @@ defm PDY : sse12_fp_packed_logical_rm, OpSize, VEX_4V; } -} // AVX 256-bit packed logical ops forms defm VAND : sse12_fp_packed_logical_y<0x54, "and">; @@ -1653,38 +1589,36 @@ } // Binary Arithmetic instructions -let isAsmParserOnly = 0 in { - defm VADD : basic_sse12_fp_binop_s<0x58, "add", fadd, 0>, - basic_sse12_fp_binop_s_int<0x58, "add", 0>, - basic_sse12_fp_binop_p<0x58, "add", fadd, 0>, - basic_sse12_fp_binop_p_y<0x58, "add", fadd>, VEX_4V; - defm VMUL : basic_sse12_fp_binop_s<0x59, "mul", fmul, 0>, - basic_sse12_fp_binop_s_int<0x59, "mul", 0>, - basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>, - basic_sse12_fp_binop_p_y<0x59, "mul", fmul>, VEX_4V; +defm VADD : basic_sse12_fp_binop_s<0x58, "add", fadd, 0>, + basic_sse12_fp_binop_s_int<0x58, "add", 0>, + basic_sse12_fp_binop_p<0x58, "add", fadd, 0>, + basic_sse12_fp_binop_p_y<0x58, "add", fadd>, VEX_4V; +defm VMUL : basic_sse12_fp_binop_s<0x59, "mul", fmul, 0>, + basic_sse12_fp_binop_s_int<0x59, "mul", 0>, + basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>, + basic_sse12_fp_binop_p_y<0x59, "mul", fmul>, VEX_4V; - let isCommutable = 0 in { - defm VSUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub, 0>, - basic_sse12_fp_binop_s_int<0x5C, "sub", 0>, - basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>, - basic_sse12_fp_binop_p_y<0x5C, "sub", fsub>, VEX_4V; - defm VDIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv, 0>, - basic_sse12_fp_binop_s_int<0x5E, "div", 0>, - basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>, - basic_sse12_fp_binop_p_y<0x5E, "div", fdiv>, VEX_4V; - defm VMAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax, 0>, - basic_sse12_fp_binop_s_int<0x5F, "max", 0>, - basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>, - basic_sse12_fp_binop_p_int<0x5F, "max", 0>, - basic_sse12_fp_binop_p_y<0x5F, "max", X86fmax>, - basic_sse12_fp_binop_p_y_int<0x5F, "max">, VEX_4V; - defm VMIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin, 0>, - basic_sse12_fp_binop_s_int<0x5D, "min", 0>, - basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>, - basic_sse12_fp_binop_p_int<0x5D, "min", 0>, - basic_sse12_fp_binop_p_y_int<0x5D, "min">, - basic_sse12_fp_binop_p_y<0x5D, "min", X86fmin>, VEX_4V; - } +let isCommutable = 0 in { + defm VSUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub, 0>, + basic_sse12_fp_binop_s_int<0x5C, "sub", 0>, + basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>, + basic_sse12_fp_binop_p_y<0x5C, "sub", fsub>, VEX_4V; + defm VDIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv, 0>, + basic_sse12_fp_binop_s_int<0x5E, "div", 0>, + basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>, + basic_sse12_fp_binop_p_y<0x5E, "div", fdiv>, VEX_4V; + defm VMAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax, 0>, + basic_sse12_fp_binop_s_int<0x5F, "max", 0>, + basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>, + basic_sse12_fp_binop_p_int<0x5F, "max", 0>, + basic_sse12_fp_binop_p_y<0x5F, "max", X86fmax>, + basic_sse12_fp_binop_p_y_int<0x5F, "max">, VEX_4V; + defm VMIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin, 0>, + basic_sse12_fp_binop_s_int<0x5D, "min", 0>, + basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>, + basic_sse12_fp_binop_p_int<0x5D, "min", 0>, + basic_sse12_fp_binop_p_y_int<0x5D, "min">, + basic_sse12_fp_binop_p_y<0x5D, "min", X86fmin>, VEX_4V; } let Constraints = "$src1 = $dst" in { @@ -1885,7 +1819,7 @@ [(set VR256:$dst, (V2F64Int (memopv4f64 addr:$src)))]>; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // Square root. defm VSQRT : sse1_fp_unop_s_avx<0x51, "vsqrt", fsqrt, int_x86_sse_sqrt_ss>, sse2_fp_unop_s_avx<0x51, "vsqrt", fsqrt, int_x86_sse2_sqrt_sd>, @@ -1941,67 +1875,65 @@ // SSE 1 & 2 - Non-temporal stores //===----------------------------------------------------------------------===// -let isAsmParserOnly = 0 in { - def VMOVNTPSmr_Int : VPSI<0x2B, MRMDestMem, (outs), - (ins i128mem:$dst, VR128:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>, VEX; - def VMOVNTPDmr_Int : VPDI<0x2B, MRMDestMem, (outs), - (ins i128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>, VEX; +def VMOVNTPSmr_Int : VPSI<0x2B, MRMDestMem, (outs), + (ins i128mem:$dst, VR128:$src), + "movntps\t{$src, $dst|$dst, $src}", + [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>, VEX; +def VMOVNTPDmr_Int : VPDI<0x2B, MRMDestMem, (outs), + (ins i128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>, VEX; - let ExeDomain = SSEPackedInt in - def VMOVNTDQmr_Int : VPDI<0xE7, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>, VEX; +let ExeDomain = SSEPackedInt in + def VMOVNTDQmr_Int : VPDI<0xE7, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>, VEX; - let AddedComplexity = 400 in { // Prefer non-temporal versions - def VMOVNTPSmr : VPSI<0x2B, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f32 VR128:$src), - addr:$dst)]>, VEX; - def VMOVNTPDmr : VPDI<0x2B, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v2f64 VR128:$src), - addr:$dst)]>, VEX; - def VMOVNTDQ_64mr : VPDI<0xE7, MRMDestMem, (outs), - (ins f128mem:$dst, VR128:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v2f64 VR128:$src), - addr:$dst)]>, VEX; - let ExeDomain = SSEPackedInt in - def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs), +let AddedComplexity = 400 in { // Prefer non-temporal versions + def VMOVNTPSmr : VPSI<0x2B, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movntps\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), + addr:$dst)]>, VEX; + def VMOVNTPDmr : VPDI<0x2B, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v2f64 VR128:$src), + addr:$dst)]>, VEX; + def VMOVNTDQ_64mr : VPDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f32 VR128:$src), + [(alignednontemporalstore (v2f64 VR128:$src), addr:$dst)]>, VEX; - - def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs), - (ins f256mem:$dst, VR256:$src), - "movntps\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v8f32 VR256:$src), - addr:$dst)]>, VEX; - def VMOVNTPDYmr : VPDI<0x2B, MRMDestMem, (outs), - (ins f256mem:$dst, VR256:$src), - "movntpd\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f64 VR256:$src), - addr:$dst)]>, VEX; - def VMOVNTDQY_64mr : VPDI<0xE7, MRMDestMem, (outs), - (ins f256mem:$dst, VR256:$src), - "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v4f64 VR256:$src), - addr:$dst)]>, VEX; - let ExeDomain = SSEPackedInt in - def VMOVNTDQYmr : VPDI<0xE7, MRMDestMem, (outs), + let ExeDomain = SSEPackedInt in + def VMOVNTDQmr : VPDI<0xE7, MRMDestMem, (outs), + (ins f128mem:$dst, VR128:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f32 VR128:$src), + addr:$dst)]>, VEX; + + def VMOVNTPSYmr : VPSI<0x2B, MRMDestMem, (outs), + (ins f256mem:$dst, VR256:$src), + "movntps\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v8f32 VR256:$src), + addr:$dst)]>, VEX; + def VMOVNTPDYmr : VPDI<0x2B, MRMDestMem, (outs), + (ins f256mem:$dst, VR256:$src), + "movntpd\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v4f64 VR256:$src), + addr:$dst)]>, VEX; + def VMOVNTDQY_64mr : VPDI<0xE7, MRMDestMem, (outs), (ins f256mem:$dst, VR256:$src), "movntdq\t{$src, $dst|$dst, $src}", - [(alignednontemporalstore (v8f32 VR256:$src), + [(alignednontemporalstore (v4f64 VR256:$src), addr:$dst)]>, VEX; - } + let ExeDomain = SSEPackedInt in + def VMOVNTDQYmr : VPDI<0xE7, MRMDestMem, (outs), + (ins f256mem:$dst, VR256:$src), + "movntdq\t{$src, $dst|$dst, $src}", + [(alignednontemporalstore (v8f32 VR256:$src), + addr:$dst)]>, VEX; } def : Pat<(int_x86_avx_movnt_dq_256 addr:$dst, VR256:$src), @@ -2124,12 +2056,10 @@ // SSE 1 & 2 - Load/Store XCSR register //===----------------------------------------------------------------------===// -let isAsmParserOnly = 0 in { - def VLDMXCSR : VPSI<0xAE, MRM2m, (outs), (ins i32mem:$src), - "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>, VEX; - def VSTMXCSR : VPSI<0xAE, MRM3m, (outs), (ins i32mem:$dst), - "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>, VEX; -} +def VLDMXCSR : VPSI<0xAE, MRM2m, (outs), (ins i32mem:$src), + "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>, VEX; +def VSTMXCSR : VPSI<0xAE, MRM3m, (outs), (ins i32mem:$dst), + "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>, VEX; def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src), "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>; @@ -2142,45 +2072,43 @@ let ExeDomain = SSEPackedInt in { // SSE integer instructions -let isAsmParserOnly = 0 in { - let neverHasSideEffects = 1 in { - def VMOVDQArr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - def VMOVDQAYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - } - def VMOVDQUrr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), - "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX; - def VMOVDQUYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src), - "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX; - - let canFoldAsLoad = 1, mayLoad = 1 in { - def VMOVDQArm : VPDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - def VMOVDQAYrm : VPDI<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - let Predicates = [HasAVX] in { - def VMOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), - "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; - def VMOVDQUYrm : I<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src), - "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; - } - } +let neverHasSideEffects = 1 in { +def VMOVDQArr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +def VMOVDQAYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +} +def VMOVDQUrr : VPDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), + "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX; +def VMOVDQUYrr : VPDI<0x6F, MRMSrcReg, (outs VR256:$dst), (ins VR256:$src), + "movdqu\t{$src, $dst|$dst, $src}", []>, XS, VEX; - let mayStore = 1 in { - def VMOVDQAmr : VPDI<0x7F, MRMDestMem, (outs), - (ins i128mem:$dst, VR128:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - def VMOVDQAYmr : VPDI<0x7F, MRMDestMem, (outs), - (ins i256mem:$dst, VR256:$src), - "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; - let Predicates = [HasAVX] in { - def VMOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), +let canFoldAsLoad = 1, mayLoad = 1 in { +def VMOVDQArm : VPDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +def VMOVDQAYrm : VPDI<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +let Predicates = [HasAVX] in { + def VMOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; - def VMOVDQUYmr : I<0x7F, MRMDestMem, (outs), (ins i256mem:$dst, VR256:$src), + def VMOVDQUYrm : I<0x6F, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src), "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; - } - } +} +} + +let mayStore = 1 in { +def VMOVDQAmr : VPDI<0x7F, MRMDestMem, (outs), + (ins i128mem:$dst, VR128:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +def VMOVDQAYmr : VPDI<0x7F, MRMDestMem, (outs), + (ins i256mem:$dst, VR256:$src), + "movdqa\t{$src, $dst|$dst, $src}", []>, VEX; +let Predicates = [HasAVX] in { +def VMOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), + "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; +def VMOVDQUYmr : I<0x7F, MRMDestMem, (outs), (ins i256mem:$dst, VR256:$src), + "vmovdqu\t{$src, $dst|$dst, $src}",[]>, XS, VEX; +} } let neverHasSideEffects = 1 in @@ -2212,12 +2140,10 @@ } // Intrinsic forms of MOVDQU load and store -let isAsmParserOnly = 0 in { def VMOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "vmovdqu\t{$src, $dst|$dst, $src}", [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>, XS, VEX, Requires<[HasAVX]>; -} def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movdqu\t{$src, $dst|$dst, $src}", @@ -2323,7 +2249,7 @@ // 128-bit Integer Arithmetic -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPADDB : PDI_binop_rm<0xFC, "vpaddb", add, v16i8, 1, 0 /*3addr*/>, VEX_4V; defm VPADDW : PDI_binop_rm<0xFD, "vpaddw", add, v8i16, 1, 0>, VEX_4V; defm VPADDD : PDI_binop_rm<0xFE, "vpaddd", add, v4i32, 1, 0>, VEX_4V; @@ -2413,7 +2339,7 @@ // SSE2 - Packed Integer Logical Instructions //===---------------------------------------------------------------------===// -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "vpsllw", int_x86_sse2_psll_w, int_x86_sse2_pslli_w, 0>, VEX_4V; @@ -2560,7 +2486,7 @@ // SSE2 - Packed Integer Comparison Instructions //===---------------------------------------------------------------------===// -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPCMPEQB : PDI_binop_rm_int<0x74, "vpcmpeqb", int_x86_sse2_pcmpeq_b, 1, 0>, VEX_4V; defm VPCMPEQW : PDI_binop_rm_int<0x75, "vpcmpeqw", int_x86_sse2_pcmpeq_w, 1, @@ -2614,7 +2540,7 @@ // SSE2 - Packed Integer Pack Instructions //===---------------------------------------------------------------------===// -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPACKSSWB : PDI_binop_rm_int<0x63, "vpacksswb", int_x86_sse2_packsswb_128, 0, 0>, VEX_4V; defm VPACKSSDW : PDI_binop_rm_int<0x6B, "vpackssdw", int_x86_sse2_packssdw_128, @@ -2652,7 +2578,7 @@ } } // ExeDomain = SSEPackedInt -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { let AddedComplexity = 5 in defm VPSHUFD : sse2_pshuffle<"vpshufd", v4i32, pshufd, bc_v4i32>, OpSize, VEX; @@ -2700,7 +2626,7 @@ addr:$src2))))]>; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPUNPCKLBW : sse2_unpack<0x60, "vpunpcklbw", v16i8, unpckl, bc_v16i8, 0>, VEX_4V; defm VPUNPCKLWD : sse2_unpack<0x61, "vpunpcklwd", v8i16, unpckl, bc_v8i16, @@ -2810,7 +2736,7 @@ } // Extract -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in def VPEXTRWri : Ii8<0xC5, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2), "vpextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}", @@ -2823,7 +2749,7 @@ imm:$src2))]>; // Insert -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPINSRW : sse2_pinsrw<0>, OpSize, VEX_4V; def VPINSRWrr64i : Ii8<0xC4, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, GR64:$src2, i32i8imm:$src3), @@ -2842,13 +2768,11 @@ let ExeDomain = SSEPackedInt in { -let isAsmParserOnly = 0 in { def VPMOVMSKBrr : VPDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), "pmovmskb\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>, VEX; def VPMOVMSKBr64r : VPDI<0xD7, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), "pmovmskb\t{$src, $dst|$dst, $src}", []>, VEX; -} def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), "pmovmskb\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>; @@ -2861,7 +2785,6 @@ let ExeDomain = SSEPackedInt in { -let isAsmParserOnly = 0 in { let Uses = [EDI] in def VMASKMOVDQU : VPDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask), @@ -2872,7 +2795,6 @@ (ins VR128:$src, VR128:$mask), "maskmovdqu\t{$mask, $src|$src, $mask}", [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>, VEX; -} let Uses = [EDI] in def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask), @@ -2890,7 +2812,6 @@ //===---------------------------------------------------------------------===// // Move Int Doubleword to Packed Double Int -let isAsmParserOnly = 0 in { def VMOVDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -2900,7 +2821,6 @@ [(set VR128:$dst, (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>, VEX; -} def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -2919,7 +2839,6 @@ // Move Int Doubleword to Single Scalar -let isAsmParserOnly = 0 in { def VMOVDI2SSrr : VPDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set FR32:$dst, (bitconvert GR32:$src))]>, VEX; @@ -2928,7 +2847,6 @@ "movd\t{$src, $dst|$dst, $src}", [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>, VEX; -} def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set FR32:$dst, (bitconvert GR32:$src))]>; @@ -2938,7 +2856,6 @@ [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>; // Move Packed Doubleword Int to Packed Double Int -let isAsmParserOnly = 0 in { def VMOVPDI2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src), "movd\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (vector_extract (v4i32 VR128:$src), @@ -2948,7 +2865,6 @@ "movd\t{$src, $dst|$dst, $src}", [(store (i32 (vector_extract (v4i32 VR128:$src), (iPTR 0))), addr:$dst)]>, VEX; -} def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src), "movd\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (vector_extract (v4i32 VR128:$src), @@ -2974,14 +2890,12 @@ [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; // Move Scalar Single to Double Int -let isAsmParserOnly = 0 in { def VMOVSS2DIrr : VPDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (bitconvert FR32:$src))]>, VEX; def VMOVSS2DImr : VPDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src), "movd\t{$src, $dst|$dst, $src}", [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>, VEX; -} def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set GR32:$dst, (bitconvert FR32:$src))]>; @@ -2990,7 +2904,7 @@ [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>; // movd / movq to XMM register zero-extends -let AddedComplexity = 15, isAsmParserOnly = 0 in { +let AddedComplexity = 15 in { def VMOVZDI2PDIrr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (v4i32 (X86vzmovl @@ -3014,7 +2928,6 @@ } let AddedComplexity = 20 in { -let isAsmParserOnly = 0 in def VMOVZDI2PDIrm : VPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), "movd\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -3040,7 +2953,6 @@ //===---------------------------------------------------------------------===// // Move Quadword Int to Packed Quadword Int -let isAsmParserOnly = 0 in def VMOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), "vmovq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -3053,7 +2965,6 @@ Requires<[HasSSE2]>; // SSE2 instruction with XS Prefix // Move Packed Quadword Int to Quadword Int -let isAsmParserOnly = 0 in def VMOVPQI2QImr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src), "movq\t{$src, $dst|$dst, $src}", [(store (i64 (vector_extract (v2i64 VR128:$src), @@ -3067,7 +2978,6 @@ (f64 (EXTRACT_SUBREG (v2f64 VR128:$src), sub_sd))>; // Store / copy lower 64-bits of a XMM register. -let isAsmParserOnly = 0 in def VMOVLQ128mr : VPDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src), "movq\t{$src, $dst|$dst, $src}", [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>, VEX; @@ -3075,7 +2985,7 @@ "movq\t{$src, $dst|$dst, $src}", [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>; -let AddedComplexity = 20, isAsmParserOnly = 0 in +let AddedComplexity = 20 in def VMOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), "vmovq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, @@ -3100,7 +3010,7 @@ // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in // IA32 document. movq xmm1, xmm2 does clear the high bits. -let isAsmParserOnly = 0, AddedComplexity = 15 in +let AddedComplexity = 15 in def VMOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vmovq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>, @@ -3111,7 +3021,7 @@ [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>, XS, Requires<[HasSSE2]>; -let AddedComplexity = 20, isAsmParserOnly = 0 in +let AddedComplexity = 20 in def VMOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "vmovq\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (v2i64 (X86vzmovl @@ -3129,7 +3039,6 @@ } // Instructions to match in the assembler -let isAsmParserOnly = 0 in { def VMOVQs64rr : VPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), "movq\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W; def VMOVQd64rr : VPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), @@ -3137,13 +3046,12 @@ // Recognize "movd" with GR64 destination, but encode as a "movq" def VMOVQd64rr_alt : VPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), "movd\t{$src, $dst|$dst, $src}", []>, VEX, VEX_W; -} // Instructions for the disassembler // xr = XMM register // xm = mem64 -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in def VMOVQxrxr: I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vmovq\t{$src, $dst|$dst, $src}", []>, VEX, XS; def MOVQxrxr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), @@ -3185,7 +3093,7 @@ //===---------------------------------------------------------------------===// // Convert Packed Double FP to Packed DW Integers -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // The assembler can recognize rr 256-bit instructions by seeing a ymm // register, but the same isn't true when using memory operands instead. // Provide other assembly rr and rm forms to address this explicitly. @@ -3213,7 +3121,7 @@ "cvtpd2dq\t{$src, $dst|$dst, $src}", []>; // Convert Packed DW Integers to Packed Double FP -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { def VCVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), @@ -3264,7 +3172,7 @@ !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), []>; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // FIXME: Merge above classes when we have patterns for the ymm version defm VMOVSHDUP : sse3_replicate_sfp<0x16, movshdup, "vmovshdup">, VEX; defm VMOVSLDUP : sse3_replicate_sfp<0x12, movsldup, "vmovsldup">, VEX; @@ -3295,7 +3203,7 @@ []>; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // FIXME: Merge above classes when we have patterns for the ymm version defm VMOVDDUP : sse3_replicate_dfp<"vmovddup">, VEX; defm VMOVDDUPY : sse3_replicate_dfp_y<"vmovddup">, VEX; @@ -3303,7 +3211,7 @@ defm MOVDDUP : sse3_replicate_dfp<"movddup">; // Move Unaligned Integer -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { def VLDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "vlddqu\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>, VEX; @@ -3367,7 +3275,7 @@ [(set RC:$dst, (Int RC:$src1, (memop addr:$src2)))]>; } -let isAsmParserOnly = 0, Predicates = [HasAVX], +let Predicates = [HasAVX], ExeDomain = SSEPackedDouble in { defm VADDSUBPS : sse3_addsub, TB, XD, VEX_4V; @@ -3420,7 +3328,7 @@ [(set RC:$dst, (vt (IntId RC:$src1, (memop addr:$src2))))]>; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VHADDPS : S3D_Int<0x7C, "vhaddps", v4f32, VR128, f128mem, int_x86_sse3_hadd_ps, 0>, VEX_4V; defm VHADDPD : S3_Int <0x7C, "vhaddpd", v2f64, VR128, f128mem, @@ -3472,7 +3380,7 @@ (bitconvert (mem_frag128 addr:$src))))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPABSB : SS3I_unop_rm_int<0x1C, "vpabsb", memopv16i8, int_x86_ssse3_pabs_b_128>, VEX; defm VPABSW : SS3I_unop_rm_int<0x1D, "vpabsw", memopv8i16, @@ -3514,7 +3422,7 @@ (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { let isCommutable = 0 in { defm VPHADDW : SS3I_binop_rm_int<0x01, "vphaddw", memopv8i16, int_x86_ssse3_phadd_w_128, 0>, VEX_4V; @@ -3606,7 +3514,7 @@ []>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPALIGN : ssse3_palign<"vpalignr", 0>, VEX_4V; let Constraints = "$src1 = $dst" in defm PALIGN : ssse3_palign<"palignr">; @@ -3961,7 +3869,7 @@ OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPMOVSXBW : SS41I_binop_rm_int8<0x20, "vpmovsxbw", int_x86_sse41_pmovsxbw>, VEX; defm VPMOVSXWD : SS41I_binop_rm_int8<0x23, "vpmovsxwd", int_x86_sse41_pmovsxwd>, @@ -4027,7 +3935,7 @@ OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPMOVSXBD : SS41I_binop_rm_int4<0x21, "vpmovsxbd", int_x86_sse41_pmovsxbd>, VEX; defm VPMOVSXWQ : SS41I_binop_rm_int4<0x24, "vpmovsxwq", int_x86_sse41_pmovsxwq>, @@ -4068,7 +3976,7 @@ OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPMOVSXBQ : SS41I_binop_rm_int2<0x22, "vpmovsxbq", int_x86_sse41_pmovsxbq>, VEX; defm VPMOVZXBQ : SS41I_binop_rm_int2<0x32, "vpmovzxbq", int_x86_sse41_pmovzxbq>, @@ -4110,7 +4018,7 @@ // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst) } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPEXTRB : SS41I_extract8<0x14, "vpextrb">, VEX; def VPEXTRBrr64 : SS4AIi8<0x14, MRMDestReg, (outs GR64:$dst), (ins VR128:$src1, i32i8imm:$src2), @@ -4132,7 +4040,7 @@ // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst) } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPEXTRW : SS41I_extract16<0x15, "vpextrw">, VEX; defm PEXTRW : SS41I_extract16<0x15, "pextrw">; @@ -4154,7 +4062,7 @@ addr:$dst)]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPEXTRD : SS41I_extract32<0x16, "vpextrd">, VEX; defm PEXTRD : SS41I_extract32<0x16, "pextrd">; @@ -4175,7 +4083,7 @@ addr:$dst)]>, OpSize, REX_W; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPEXTRQ : SS41I_extract64<0x16, "vpextrq">, VEX, VEX_W; defm PEXTRQ : SS41I_extract64<0x16, "pextrq">; @@ -4198,7 +4106,7 @@ addr:$dst)]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VEXTRACTPS : SS41I_extractf32<0x17, "vextractps">, VEX; def VEXTRACTPSrr64 : SS4AIi8<0x17, MRMDestReg, (outs GR64:$dst), (ins VR128:$src1, i32i8imm:$src2), @@ -4238,7 +4146,7 @@ imm:$src3))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPINSRB : SS41I_insert8<0x20, "vpinsrb", 0>, VEX_4V; let Constraints = "$src1 = $dst" in defm PINSRB : SS41I_insert8<0x20, "pinsrb">; @@ -4264,7 +4172,7 @@ imm:$src3)))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPINSRD : SS41I_insert32<0x22, "vpinsrd", 0>, VEX_4V; let Constraints = "$src1 = $dst" in defm PINSRD : SS41I_insert32<0x22, "pinsrd">; @@ -4290,7 +4198,7 @@ imm:$src3)))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPINSRQ : SS41I_insert64<0x22, "vpinsrq", 0>, VEX_4V, VEX_W; let Constraints = "$src1 = $dst" in defm PINSRQ : SS41I_insert64<0x22, "pinsrq">, REX_W; @@ -4323,7 +4231,7 @@ let Constraints = "$src1 = $dst" in defm INSERTPS : SS41I_insertf32<0x21, "insertps">; -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VINSERTPS : SS41I_insertf32<0x21, "vinsertps", 0>, VEX_4V; def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3), @@ -4493,7 +4401,7 @@ } // FP round - roundss, roundps, roundsd, roundpd -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { // Intrinsic form defm VROUND : sse41_fp_unop_rm<0x08, 0x09, "vround", f128mem, VR128, memopv4f32, memopv2f64, @@ -4528,7 +4436,7 @@ // ptest instruction we'll lower to this in X86ISelLowering primarily from // the intel intrinsic that corresponds to this. -let Defs = [EFLAGS], isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Defs = [EFLAGS], Predicates = [HasAVX] in { def VPTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), "vptest\t{$src2, $src1|$src1, $src2}", [(set EFLAGS, (X86ptest VR128:$src1, (v4f32 VR128:$src2)))]>, @@ -4571,7 +4479,7 @@ OpSize, VEX; } -let Defs = [EFLAGS], isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Defs = [EFLAGS], Predicates = [HasAVX] in { defm VTESTPS : avx_bittest<0x0E, "vtestps", VR128, f128mem, memopv4f32, v4f32>; defm VTESTPSY : avx_bittest<0x0E, "vtestps", VR256, f256mem, memopv8f32, v8f32>; defm VTESTPD : avx_bittest<0x0F, "vtestpd", VR128, f128mem, memopv2f64, v2f64>; @@ -4620,7 +4528,7 @@ (bitconvert (memopv8i16 addr:$src))))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "vphminposuw", int_x86_sse41_phminposuw>, VEX; defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw", @@ -4646,7 +4554,7 @@ (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { let isCommutable = 0 in defm VPACKUSDW : SS41I_binop_rm_int<0x2B, "vpackusdw", int_x86_sse41_packusdw, 0>, VEX_4V; @@ -4713,7 +4621,7 @@ OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPMULLD : SS48I_binop_rm<0x40, "vpmulld", mul, v4i32, 0>, VEX_4V; let Constraints = "$src1 = $dst" in defm PMULLD : SS48I_binop_rm<0x40, "pmulld", mul, v4i32>; @@ -4745,7 +4653,7 @@ OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { let isCommutable = 0 in { defm VBLENDPS : SS41I_binop_rmi_int<0x0C, "vblendps", int_x86_sse41_blendps, VR128, memopv16i8, i128mem, 0>, VEX_4V; @@ -4786,7 +4694,7 @@ } /// SS41I_quaternary_int_avx - AVX SSE 4.1 with 4 operators -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { multiclass SS41I_quaternary_int_avx opc, string OpcodeStr, RegisterClass RC, X86MemOperand x86memop, PatFrag mem_frag, Intrinsic IntId> { @@ -4846,7 +4754,7 @@ def : Pat<(X86pblendv VR128:$src1, VR128:$src2, XMM0), (PBLENDVBrr0 VR128:$src1, VR128:$src2)>; -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in def VMOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "vmovntdqa\t{$src, $dst|$dst, $src}", [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>, @@ -4880,7 +4788,7 @@ (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; } -let isAsmParserOnly = 0, Predicates = [HasAVX] in +let Predicates = [HasAVX] in defm VPCMPGTQ : SS42I_binop_rm_int<0x37, "vpcmpgtq", int_x86_sse42_pcmpgtq, 0>, VEX_4V; let Constraints = "$src1 = $dst" in @@ -4912,8 +4820,7 @@ defm VPCMPISTRM128 : pseudo_pcmpistrm<"#VPCMPISTRM128">, Requires<[HasAVX]>; } -let Defs = [XMM0, EFLAGS], isAsmParserOnly = 0, - Predicates = [HasAVX] in { +let Defs = [XMM0, EFLAGS], Predicates = [HasAVX] in { def VPCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2, i8imm:$src3), "vpcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", []>, OpSize, VEX; @@ -4948,7 +4855,7 @@ defm VPCMPESTRM128 : pseudo_pcmpestrm<"#VPCMPESTRM128">, Requires<[HasAVX]>; } -let isAsmParserOnly = 0, Predicates = [HasAVX], +let Predicates = [HasAVX], Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in { def VPCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src3, i8imm:$src5), @@ -4983,7 +4890,7 @@ } } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPCMPISTRI : SS42AI_pcmpistri, VEX; defm VPCMPISTRIA : SS42AI_pcmpistri, @@ -5022,7 +4929,7 @@ } } -let isAsmParserOnly = 0, Predicates = [HasAVX] in { +let Predicates = [HasAVX] in { defm VPCMPESTRI : SS42AI_pcmpestri, VEX; defm VPCMPESTRIA : SS42AI_pcmpestri, @@ -5141,7 +5048,7 @@ } // Perform One Round of an AES Encryption/Decryption Flow -let isAsmParserOnly = 0, Predicates = [HasAVX, HasAES] in { +let Predicates = [HasAVX, HasAES] in { defm VAESENC : AESI_binop_rm_int<0xDC, "vaesenc", int_x86_aesni_aesenc, 0>, VEX_4V; defm VAESENCLAST : AESI_binop_rm_int<0xDD, "vaesenclast", @@ -5181,7 +5088,7 @@ (AESDECLASTrm VR128:$src1, addr:$src2)>; // Perform the AES InvMixColumn Transformation -let isAsmParserOnly = 0, Predicates = [HasAVX, HasAES] in { +let Predicates = [HasAVX, HasAES] in { def VAESIMCrr : AES8I<0xDB, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1), "vaesimc\t{$src1, $dst|$dst, $src1}", @@ -5209,7 +5116,7 @@ OpSize; // AES Round Key Generation Assist -let isAsmParserOnly = 0, Predicates = [HasAVX, HasAES] in { +let Predicates = [HasAVX, HasAES] in { def VAESKEYGENASSIST128rr : AESAI<0xDF, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2), "vaeskeygenassist\t{$src2, $src1, $dst|$dst, $src1, $src2}", @@ -5245,7 +5152,6 @@ // Only the AVX version of CLMUL instructions are described here. // Carry-less Multiplication instructions -let isAsmParserOnly = 0 in { def VPCLMULQDQrr : CLMULIi8<0x44, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3), "vpclmulqdq\t{$src3, $src2, $src1, $dst|$dst, $src1, $src2, $src3}", @@ -5271,13 +5177,10 @@ defm VPCLMULLQHQDQ : avx_vpclmul<"vpclmullqhqdq">; defm VPCLMULLQLQDQ : avx_vpclmul<"vpclmullqlqdq">; -} // isAsmParserOnly - //===----------------------------------------------------------------------===// // AVX Instructions //===----------------------------------------------------------------------===// -let isAsmParserOnly = 0 in { // Load from memory and broadcast to all elements of the destination operand class avx_broadcast opc, string OpcodeStr, RegisterClass RC, @@ -5411,8 +5314,6 @@ def VZEROUPPER : I<0x77, RawFrm, (outs), (ins), "vzeroupper", [(int_x86_avx_vzeroupper)]>, VEX, Requires<[HasAVX]>; -} // isAsmParserOnly - def : Pat<(int_x86_avx_vinsertf128_pd_256 VR256:$src1, VR128:$src2, imm:$src3), (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>; def : Pat<(int_x86_avx_vinsertf128_ps_256 VR256:$src1, VR128:$src2, imm:$src3), From baldrick at free.fr Fri Apr 29 01:31:39 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 06:31:39 -0000 Subject: [llvm-commits] [dragonegg] r130479 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110429063139.4AE1D2A6C135@llvm.org> Author: baldrick Date: Fri Apr 29 01:31:39 2011 New Revision: 130479 URL: http://llvm.org/viewvc/llvm-project?rev=130479&view=rev Log: Remove all uses of the global TheFolder constant folder from global constant handling. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130479&r1=130478&r2=130479&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Fri Apr 29 01:31:39 2011 @@ -34,6 +34,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/LLVMContext.h" #include "llvm/Support/Host.h" +#include "llvm/Support/TargetFolder.h" #include "llvm/Target/TargetData.h" // System headers @@ -55,6 +56,10 @@ static LLVMContext &Context = getGlobalContext(); +// Forward declarations. +static Constant *ConvertInitializerImpl(tree, TargetFolder &); +static Constant *AddressOfImpl(tree, TargetFolder &); + //===----------------------------------------------------------------------===// // ... InterpretAsType ... //===----------------------------------------------------------------------===// @@ -62,6 +67,8 @@ typedef Range SignedRange; /// BitSlice - A contiguous range of bits held in memory. +namespace { + class BitSlice { SignedRange R; Constant *Contents; // Null if and only if the range is empty. @@ -74,11 +81,11 @@ } /// ExtendRange - Extend the slice to a wider range. All added bits are zero. - BitSlice ExtendRange(SignedRange r) const; + BitSlice ExtendRange(SignedRange r, TargetFolder &Folder) const; /// ReduceRange - Reduce the slice to a smaller range discarding any bits that /// do not belong to the new range. - BitSlice ReduceRange(SignedRange r) const; + BitSlice ReduceRange(SignedRange r, TargetFolder &Folder) const; public: /// BitSlice - Default constructor: empty bit range. @@ -137,16 +144,18 @@ /// returned value corresponds to the first bit of the range (aka "First"), /// while on big-endian machines it corresponds to the last bit of the range /// (aka "Last-1"). - Constant *getBits(SignedRange r) const; + Constant *getBits(SignedRange r, TargetFolder &Folder) const; /// Merge - Join the slice with another (which must be disjoint), forming the /// convex hull of the ranges. The bits in the range of one of the slices are /// those of that slice. Any other bits have an undefined value. - void Merge(const BitSlice &other); + void Merge(const BitSlice &other, TargetFolder &Folder); }; +} // Unnamed namespace. + /// ExtendRange - Extend the slice to a wider range. All added bits are zero. -BitSlice BitSlice::ExtendRange(SignedRange r) const { +BitSlice BitSlice::ExtendRange(SignedRange r, TargetFolder &Folder) const { assert(r.contains(R) && "Not an extension!"); // Quick exit if the range did not actually increase. if (R == r) @@ -157,18 +166,18 @@ if (empty()) return BitSlice(r, Constant::getNullValue(ExtTy)); // Extend the contents to the new type. - Constant *C = TheFolder->CreateZExtOrBitCast(Contents, ExtTy); + Constant *C = Folder.CreateZExtOrBitCast(Contents, ExtTy); // Position the old contents correctly inside the new contents. unsigned deltaFirst = R.getFirst() - r.getFirst(); unsigned deltaLast = r.getLast() - R.getLast(); if (BYTES_BIG_ENDIAN && deltaLast) { (void)deltaFirst; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast); - C = TheFolder->CreateShl(C, ShiftAmt); + C = Folder.CreateShl(C, ShiftAmt); } else if (!BYTES_BIG_ENDIAN && deltaFirst) { (void)deltaLast; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaFirst); - C = TheFolder->CreateShl(C, ShiftAmt); + C = Folder.CreateShl(C, ShiftAmt); } return BitSlice(r, C); } @@ -180,7 +189,7 @@ /// returned value corresponds to the first bit of the range (aka "First"), /// while on big-endian machines it corresponds to the last bit of the range /// (aka "Last-1"). -Constant *BitSlice::getBits(SignedRange r) const { +Constant *BitSlice::getBits(SignedRange r, TargetFolder &Folder) const { assert(!r.empty() && "Bit range is empty!"); // Quick exit if the desired range matches that of the slice. if (R == r) @@ -190,9 +199,9 @@ if (empty()) return UndefValue::get(RetTy); // Extend to the convex hull of the two ranges. - BitSlice Slice = ExtendRange(R.Join(r)); + BitSlice Slice = ExtendRange(R.Join(r), Folder); // Chop the slice down to the requested range. - Slice = Slice.ReduceRange(r); + Slice = Slice.ReduceRange(r, Folder); // Now we can just return the bits contained in the slice. return Slice.Contents; } @@ -200,7 +209,7 @@ /// Merge - Join the slice with another (which must be disjoint), forming the /// convex hull of the ranges. The bits in the range of one of the slices are /// those of that slice. Any other bits have an undefined value. -void BitSlice::Merge(const BitSlice &other) { +void BitSlice::Merge(const BitSlice &other, TargetFolder &Folder) { // If the other slice is empty, the result is this slice. if (other.empty()) return; @@ -213,18 +222,17 @@ // Extend each slice to the convex hull of the ranges. SignedRange Hull = R.Join(other.getRange()); - BitSlice ExtThis = ExtendRange(Hull); - BitSlice ExtOther = other.ExtendRange(Hull); + BitSlice ExtThis = ExtendRange(Hull, Folder); + BitSlice ExtOther = other.ExtendRange(Hull, Folder); // Since the slices are disjoint and all added bits are zero they can be // joined via a simple 'or'. - *this = BitSlice(Hull, TheFolder->CreateOr(ExtThis.Contents, - ExtOther.Contents)); + *this = BitSlice(Hull, Folder.CreateOr(ExtThis.Contents, ExtOther.Contents)); } /// ReduceRange - Reduce the slice to a smaller range discarding any bits that /// do not belong to the new range. -BitSlice BitSlice::ReduceRange(SignedRange r) const { +BitSlice BitSlice::ReduceRange(SignedRange r, TargetFolder &Folder) const { assert(R.contains(r) && "Not a reduction!"); // Quick exit if the range did not actually decrease. if (R == r) @@ -240,15 +248,15 @@ if (BYTES_BIG_ENDIAN && deltaLast) { (void)deltaFirst; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaLast); - C = TheFolder->CreateLShr(C, ShiftAmt); + C = Folder.CreateLShr(C, ShiftAmt); } else if (!BYTES_BIG_ENDIAN && deltaFirst) { (void)deltaLast; // Avoid unused variable warning. Constant *ShiftAmt = ConstantInt::get(C->getType(), deltaFirst); - C = TheFolder->CreateLShr(C, ShiftAmt); + C = Folder.CreateLShr(C, ShiftAmt); } // Truncate to the new type. const Type *RedTy = IntegerType::get(Context, r.getWidth()); - C = TheFolder->CreateTruncOrBitCast(C, RedTy); + C = Folder.CreateTruncOrBitCast(C, RedTy); return BitSlice(r, C); } @@ -256,7 +264,7 @@ /// integer. Only the bits in the given range are needed, so there is no need /// to supply bits outside this range though it is harmless to do so. There is /// also no need to supply undefined bits inside the range. -static BitSlice ViewAsBits(Constant *C, SignedRange R) { +static BitSlice ViewAsBits(Constant *C, SignedRange R, TargetFolder &Folder) { if (R.empty()) return BitSlice(); @@ -276,7 +284,7 @@ case Type::PointerTyID: { // Cast to an integer with the same number of bits and return that. const IntegerType *IntTy = getTargetData().getIntPtrType(Context); - return BitSlice(0, StoreSize, TheFolder->CreatePtrToInt(C, IntTy)); + return BitSlice(0, StoreSize, Folder.CreatePtrToInt(C, IntTy)); } case Type::DoubleTyID: case Type::FloatTyID: @@ -288,7 +296,7 @@ // Bitcast to an integer with the same number of bits and return that. unsigned BitWidth = Ty->getPrimitiveSizeInBits(); const IntegerType *IntTy = IntegerType::get(Context, BitWidth); - C = TheFolder->CreateBitCast(C, IntTy); + C = Folder.CreateBitCast(C, IntTy); // Be careful about where the bits are placed in case this is a funky type // like i1. If the width is a multiple of the address unit then there is // nothing to worry about: the bits occupy the range [0, StoreSize). But @@ -314,11 +322,11 @@ SignedRange StrideRange(0, Stride); for (unsigned i = FirstElt; i < LastElt; ++i) { // Extract the element. - Constant *Elt = TheFolder->CreateExtractValue(C, &i, 1); + Constant *Elt = Folder.CreateExtractValue(C, &i, 1); // View it as a bunch of bits. - BitSlice EltBits = ViewAsBits(Elt, StrideRange); + BitSlice EltBits = ViewAsBits(Elt, StrideRange, Folder); // Add to the already known bits. - Bits.Merge(EltBits.Displace(i * Stride)); + Bits.Merge(EltBits.Displace(i * Stride), Folder); } return Bits; } @@ -334,13 +342,14 @@ BitSlice Bits; for (unsigned i = FirstIdx; i < LastIdx; ++i) { // Extract the field. - Constant *Field = TheFolder->CreateExtractValue(C, &i, 1); + Constant *Field = Folder.CreateExtractValue(C, &i, 1); // View it as a bunch of bits. const Type *FieldTy = Field->getType(); unsigned FieldStoreSize = getTargetData().getTypeStoreSizeInBits(FieldTy); - BitSlice FieldBits = ViewAsBits(Field, SignedRange(0, FieldStoreSize)); + BitSlice FieldBits = ViewAsBits(Field, SignedRange(0, FieldStoreSize), + Folder); // Add to the already known bits. - Bits.Merge(FieldBits.Displace(SL->getElementOffset(i)*8)); + Bits.Merge(FieldBits.Displace(SL->getElementOffset(i)*8), Folder); } return Bits; } @@ -362,11 +371,11 @@ for (unsigned i = FirstElt; i < LastElt; ++i) { // Extract the element. ConstantInt *Idx = ConstantInt::get(Type::getInt32Ty(Context), i); - Constant *Elt = TheFolder->CreateExtractElement(C, Idx); + Constant *Elt = Folder.CreateExtractElement(C, Idx); // View it as a bunch of bits. - BitSlice EltBits = ViewAsBits(Elt, StrideRange); + BitSlice EltBits = ViewAsBits(Elt, StrideRange, Folder); // Add to the already known bits. - Bits.Merge(EltBits.Displace(i * Stride)); + Bits.Merge(EltBits.Displace(i * Stride), Folder); } return Bits; } @@ -378,7 +387,8 @@ /// same constant as you would get by storing the bits of 'C' to memory (with /// the first bit stored being 'StartingBit') and then loading out a (constant) /// value of type 'Ty' from the stored to memory location. -Constant *InterpretAsType(Constant *C, const Type* Ty, int StartingBit = 0) { +static Constant *InterpretAsType(Constant *C, const Type* Ty, int StartingBit, + TargetFolder &Folder) { if (C->getType() == Ty) return C; @@ -392,23 +402,23 @@ // out are needed, so rather than converting the entire constant this only // converts enough to get all of the required bits. BitSlice Bits = ViewAsBits(C, SignedRange(StartingBit, - StartingBit + StoreSize)); + StartingBit + StoreSize), Folder); // Extract the bits used by the integer. If the integer width is a multiple // of the address unit then the endianness of the target doesn't matter. If // not then the padding bits come at the start on big-endian machines and at // the end on little-endian machines. Bits = Bits.Displace(-StartingBit); return BYTES_BIG_ENDIAN ? - Bits.getBits(SignedRange(StoreSize - BitWidth, StoreSize)) : - Bits.getBits(SignedRange(0, BitWidth)); + Bits.getBits(SignedRange(StoreSize - BitWidth, StoreSize), Folder) : + Bits.getBits(SignedRange(0, BitWidth), Folder); } case Type::PointerTyID: { // Interpret as an integer with the same number of bits then cast back to // the original type. const IntegerType *IntTy = getTargetData().getIntPtrType(Context); - C = InterpretAsType(C, IntTy, StartingBit); - return TheFolder->CreateIntToPtr(C, Ty); + C = InterpretAsType(C, IntTy, StartingBit, Folder); + return Folder.CreateIntToPtr(C, Ty); } case Type::DoubleTyID: case Type::FloatTyID: @@ -420,7 +430,8 @@ // the original type. unsigned BitWidth = Ty->getPrimitiveSizeInBits(); const IntegerType *IntTy = IntegerType::get(Context, BitWidth); - return TheFolder->CreateBitCast(InterpretAsType(C, IntTy, StartingBit), Ty); + return Folder.CreateBitCast(InterpretAsType(C, IntTy, StartingBit, Folder), + Ty); } case Type::ArrayTyID: { @@ -431,7 +442,7 @@ const unsigned NumElts = ATy->getNumElements(); std::vector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) - Vals[i] = InterpretAsType(C, EltTy, StartingBit + i*Stride); + Vals[i] = InterpretAsType(C, EltTy, StartingBit + i*Stride, Folder); return ConstantArray::get(ATy, Vals); // TODO: Use ArrayRef constructor. } @@ -443,7 +454,8 @@ std::vector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) Vals[i] = InterpretAsType(C, STy->getElementType(i), - StartingBit + SL->getElementOffsetInBits(i)); + StartingBit + SL->getElementOffsetInBits(i), + Folder); return ConstantStruct::get(STy, Vals); // TODO: Use ArrayRef constructor. } @@ -455,7 +467,7 @@ const unsigned NumElts = VTy->getNumElements(); SmallVector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) - Vals[i] = InterpretAsType(C, EltTy, StartingBit + i*Stride); + Vals[i] = InterpretAsType(C, EltTy, StartingBit + i*Stride, Folder); return ConstantVector::get(Vals); } } @@ -466,12 +478,11 @@ // ... ExtractRegisterFromConstant ... //===----------------------------------------------------------------------===// -/// ExtractRegisterFromConstant - Extract a value of the given scalar GCC type -/// from a constant. The returned value is of in-register type, as returned by -/// getRegType, and is what you would get by storing the constant to memory and -/// using LoadRegisterFromMemory to load a register value back out starting from -/// byte StartingByte. -Constant *ExtractRegisterFromConstant(Constant *C, tree type, int StartingByte) { +/// ExtractRegisterFromConstantImpl - Implementation of +/// ExtractRegisterFromConstant. +static Constant *ExtractRegisterFromConstantImpl(Constant *C, tree type, + int StartingByte, + TargetFolder &Folder) { // NOTE: Needs to be kept in sync with getRegType and RepresentAsMemory. int StartingBit = StartingByte * BITS_PER_UNIT; switch (TREE_CODE(type)) { @@ -489,16 +500,16 @@ // big endian machines. uint64_t Size = getInt64(TYPE_SIZE(type), true); const Type *MemTy = IntegerType::get(Context, Size); - C = InterpretAsType(C, MemTy, StartingBit); - return TheFolder->CreateTruncOrBitCast(C, getRegType(type)); + C = InterpretAsType(C, MemTy, StartingBit, Folder); + return Folder.CreateTruncOrBitCast(C, getRegType(type)); } case COMPLEX_TYPE: { tree elt_type = TREE_TYPE(type); unsigned Stride = GET_MODE_BITSIZE(TYPE_MODE(elt_type)); Constant *Vals[2] = { - ExtractRegisterFromConstant(C, elt_type, StartingBit), - ExtractRegisterFromConstant(C, elt_type, StartingBit + Stride) + ExtractRegisterFromConstantImpl(C, elt_type, StartingBit, Folder), + ExtractRegisterFromConstantImpl(C, elt_type, StartingBit + Stride, Folder) }; return ConstantStruct::get(Context, Vals, 2, false); } @@ -506,12 +517,12 @@ case OFFSET_TYPE: case POINTER_TYPE: case REFERENCE_TYPE: - return InterpretAsType(C, getRegType(type), StartingBit); + return InterpretAsType(C, getRegType(type), StartingBit, Folder); case REAL_TYPE: // NOTE: This might be wrong for floats with precision less than their alloc // size on big-endian machines. - return InterpretAsType(C, getRegType(type), StartingBit); + return InterpretAsType(C, getRegType(type), StartingBit, Folder); case VECTOR_TYPE: { tree elt_type = TREE_TYPE(type); @@ -519,12 +530,13 @@ unsigned Stride = GET_MODE_BITSIZE(TYPE_MODE(elt_type)); SmallVector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) { - Vals[i] = ExtractRegisterFromConstant(C, elt_type, StartingBit+i*Stride); + Vals[i] = ExtractRegisterFromConstantImpl(C, elt_type, + StartingBit+i*Stride, Folder); // LLVM does not support vectors of pointers, so turn any pointers into // integers. if (isa(Vals[i]->getType())) { const IntegerType *IntTy = getTargetData().getIntPtrType(Context); - Vals[i] = TheFolder->CreatePtrToInt(Vals[i], IntTy); + Vals[i] = Folder.CreatePtrToInt(Vals[i], IntTy); } } return ConstantVector::get(Vals); @@ -533,6 +545,16 @@ } } +/// ExtractRegisterFromConstant - Extract a value of the given scalar GCC type +/// from a constant. The returned value is of in-register type, as returned by +/// getRegType, and is what you would get by storing the constant to memory and +/// using LoadRegisterFromMemory to load a register value back out starting from +/// byte StartingByte. +Constant *ExtractRegisterFromConstant(Constant *C, tree type, int StartingByte) { + TargetFolder Folder(&getTargetData()); + return ExtractRegisterFromConstantImpl(C, type, StartingByte, Folder); +} + //===----------------------------------------------------------------------===// // ... ConvertInitializer ... @@ -540,16 +562,17 @@ /// getAsRegister - Turn the given GCC scalar constant into an LLVM constant of /// register type. -static Constant *getAsRegister(tree exp) { - Constant *C = ConvertInitializer(exp); - return ExtractRegisterFromConstant(C, TREE_TYPE(exp)); +static Constant *getAsRegister(tree exp, TargetFolder &Folder) { + Constant *C = ConvertInitializerImpl(exp, Folder); + return ExtractRegisterFromConstantImpl(C, TREE_TYPE(exp), 0, Folder); } /// RepresentAsMemory - Turn a constant of in-register type (corresponding /// to the given GCC type) into an in-memory constant. The result has the /// property that applying ExtractRegisterFromConstant to it gives you the /// original in-register constant back again. -static Constant *RepresentAsMemory(Constant *C, tree type) { +static Constant *RepresentAsMemory(Constant *C, tree type, + TargetFolder &Folder) { // NOTE: Needs to be kept in sync with ExtractRegisterFromConstant. assert(C->getType() == getRegType(type) && "Constant has wrong type!"); Constant *Result; @@ -570,18 +593,18 @@ const Type *MemTy = IntegerType::get(Context, Size); // We can extend in any way, but get nicer IR by respecting signedness. bool isSigned = !TYPE_UNSIGNED(type); - Result = isSigned ? TheFolder->CreateSExtOrBitCast(C, MemTy) : - TheFolder->CreateZExtOrBitCast(C, MemTy); + Result = isSigned ? Folder.CreateSExtOrBitCast(C, MemTy) : + Folder.CreateZExtOrBitCast(C, MemTy); break; } case COMPLEX_TYPE: { tree elt_type = TREE_TYPE(type); unsigned Idx[2] = {0, 1}; - Constant *Real = TheFolder->CreateExtractValue(C, Idx, 1); - Constant *Imag = TheFolder->CreateExtractValue(C, Idx + 1, 1); - Real = RepresentAsMemory(Real, elt_type); - Imag = RepresentAsMemory(Imag, elt_type); + Constant *Real = Folder.CreateExtractValue(C, Idx, 1); + Constant *Imag = Folder.CreateExtractValue(C, Idx + 1, 1); + Real = RepresentAsMemory(Real, elt_type, Folder); + Imag = RepresentAsMemory(Imag, elt_type, Folder); Constant *Vals[2] = { Real, Imag }; Result = ConstantStruct::get(Context, Vals, 2, false); break; @@ -607,8 +630,8 @@ std::vector Vals(NumElts); for (unsigned i = 0; i != NumElts; ++i) { ConstantInt *Idx = ConstantInt::get(Type::getInt32Ty(Context), i); - Vals[i] = TheFolder->CreateExtractElement(C, Idx); - Vals[i] = RepresentAsMemory(Vals[i], elt_type); + Vals[i] = Folder.CreateExtractElement(C, Idx); + Vals[i] = RepresentAsMemory(Vals[i], elt_type, Folder); } // The elements may have funky types, so forming a vector may not always be // possible. @@ -620,9 +643,9 @@ // Ensure that the result satisfies the guarantees given by ConvertInitializer // by turning it into a type with the right size and an appropriate alignment. - Result = InterpretAsType(Result, ConvertType(type)); + Result = InterpretAsType(Result, ConvertType(type), 0, Folder); - assert(C == ExtractRegisterFromConstant(Result, type) && + assert(C == ExtractRegisterFromConstantImpl(Result, type, 0, Folder) && "Register inserted wrong!"); return Result; @@ -633,9 +656,10 @@ /// and the initializer are scalar. This is convenient for making explicit the /// implicit scalar casts that GCC allows in "assignments" such as initializing /// a record field. -static Constant *ConvertInitializerWithCast(tree exp, tree type) { +static Constant *ConvertInitializerWithCast(tree exp, tree type, + TargetFolder &Folder) { // Convert the initializer. - Constant *C = ConvertInitializer(exp); + Constant *C = ConvertInitializerImpl(exp, Folder); // If no cast is needed, or it would not be a scalar cast, then just return // the initializer as is. @@ -654,21 +678,21 @@ // that would not perform a value extension (adding extra zeros or sign bits // when casting to a larger integer type for example): any extra bits would // wrongly get an undefined value instead. - C = ExtractRegisterFromConstant(C, TREE_TYPE(exp)); + C = ExtractRegisterFromConstantImpl(C, TREE_TYPE(exp), 0, Folder); // Cast to the desired type. bool SrcIsSigned = !TYPE_UNSIGNED(TREE_TYPE(exp)); bool DestIsSigned = !TYPE_UNSIGNED(type); Instruction::CastOps opcode = CastInst::getCastOpcode(C, SrcIsSigned, DestTy, DestIsSigned); - C = TheFolder->CreateCast(opcode, C, DestTy); + C = Folder.CreateCast(opcode, C, DestTy); - return RepresentAsMemory(C, type); + return RepresentAsMemory(C, type, Folder); } /// ConvertCST - Return the given simple constant as an array of bytes. For the /// moment only INTEGER_CST, REAL_CST, COMPLEX_CST and VECTOR_CST are supported. -static Constant *ConvertCST(tree exp) { +static Constant *ConvertCST(tree exp, TargetFolder &) { const tree type = TREE_TYPE(exp); unsigned SizeInChars = (TREE_INT_CST_LOW(TYPE_SIZE(type)) + CHAR_BIT - 1) / CHAR_BIT; @@ -681,7 +705,7 @@ /*AddNull*/false); } -static Constant *ConvertSTRING_CST(tree exp) { +static Constant *ConvertSTRING_CST(tree exp, TargetFolder &) { const ArrayType *StrTy = cast(ConvertType(TREE_TYPE(exp))); const Type *ElTy = StrTy->getElementType(); @@ -752,12 +776,12 @@ return ConstantArray::get(StrTy, Elts); } -static Constant *ConvertADDR_EXPR(tree exp) { - return AddressOf(TREE_OPERAND(exp, 0)); +static Constant *ConvertADDR_EXPR(tree exp, TargetFolder &Folder) { + return AddressOfImpl(TREE_OPERAND(exp, 0), Folder); } /// ConvertArrayCONSTRUCTOR - Convert a CONSTRUCTOR with array or vector type. -static Constant *ConvertArrayCONSTRUCTOR(tree exp) { +static Constant *ConvertArrayCONSTRUCTOR(tree exp, TargetFolder &Folder) { const TargetData &TD = getTargetData(); tree init_type = TREE_TYPE(exp); @@ -794,7 +818,7 @@ tree elt_index, elt_value; FOR_EACH_CONSTRUCTOR_ELT(CONSTRUCTOR_ELTS(exp), ix, elt_index, elt_value) { // Find and decode the constructor's value. - Constant *Val = ConvertInitializerWithCast(elt_value, elt_type); + Constant *Val = ConvertInitializerWithCast(elt_value, elt_type, Folder); uint64_t ValSize = TD.getTypeAllocSizeInBits(Val->getType()); assert(ValSize <= EltSize && "Element initial value too big!"); @@ -903,13 +927,16 @@ /// FieldContents - A constant restricted to a range of bits. Any part of the /// constant outside of the range is discarded. The range may be bigger than /// the constant in which case any extra bits have an undefined value. +namespace { + class FieldContents { SignedRange R; // The range of bits occupied by the constant. Constant *C; // The constant. May be null if the range is empty. int Starts; // The first bit of the constant is positioned at this offset. + TargetFolder &Folder; - FieldContents(SignedRange r, Constant *c, int starts) - : R(r), C(c), Starts(starts) { + FieldContents(SignedRange r, Constant *c, int starts, TargetFolder &folder) + : R(r), C(c), Starts(starts), Folder(folder) { assert((R.empty() || C) && "Need constant when range not empty!"); } @@ -919,7 +946,7 @@ if (R.empty()) return 0; const Type *IntTy = IntegerType::get(Context, R.getWidth()); - return InterpretAsType(C, IntTy, R.getFirst() - Starts); + return InterpretAsType(C, IntTy, R.getFirst() - Starts, Folder); } /// isSafeToReturnContentsDirectly - Return whether the current value for the @@ -942,12 +969,16 @@ } public: - /// FieldContents - Default constructor: empty bit range. - FieldContents() : R(), C(0), Starts(0) {} - /// get - Fill the range [first, last) with the given constant. - static FieldContents get(int first, int last, Constant *c) { - return FieldContents(SignedRange(first, last), c, first); + static FieldContents get(int first, int last, Constant *c, + TargetFolder &folder) { + return FieldContents(SignedRange(first, last), c, first, folder); + } + + // Copy assignment operator. + FieldContents &operator=(const FieldContents &other) { + R = other.R; C = other.C; Starts = other.Starts; Folder = other.Folder; + return *this; } /// getRange - Return the range occupied by this field. @@ -993,12 +1024,14 @@ // The integer type used to hold the bits was too big (for example an i24 // typically occupies 32 bits so is too big for a range of 24 bits). Turn // it into an array of bytes instead. - C = InterpretAsType(C, GetUnitType(Context, Units)); + C = InterpretAsType(C, GetUnitType(Context, Units), 0, Folder); assert(isSafeToReturnContentsDirectly(TD) && "Unit over aligned?"); return C; } }; +} // Unnamed namespace. + /// JoinWith - Form the union of this field with another field (which must be /// disjoint from this one). After this the range will be the convex hull of /// the ranges of the two fields. @@ -1007,13 +1040,13 @@ // together. This can result in a nasty integer constant expression, but as // we only get here for bitfields that's mostly harmless. BitSlice Bits(R, getAsBits()); - Bits.Merge (BitSlice(S.R, S.getAsBits())); + Bits.Merge (BitSlice(S.R, S.getAsBits()), Folder); R = Bits.getRange(); - C = Bits.getBits(R); + C = Bits.getBits(R, Folder); Starts = R.empty() ? 0 : R.getFirst(); } -static Constant *ConvertRecordCONSTRUCTOR(tree exp) { +static Constant *ConvertRecordCONSTRUCTOR(tree exp, TargetFolder &Folder) { // FIXME: This new logic, especially the handling of bitfields, is untested // and probably wrong on big-endian machines. IntervalList Layout; @@ -1062,7 +1095,7 @@ // it is guaranteed to cover all parts of the GCC type that can be default // initialized. This makes for nicer IR than just using a bunch of bytes. Constant *Zero = Constant::getNullValue(FieldTy); - Layout.AddInterval(FieldContents::get(FirstBit, LastBit, Zero)); + Layout.AddInterval(FieldContents::get(FirstBit, LastBit, Zero, Folder)); } } @@ -1086,7 +1119,8 @@ assert(TREE_CODE(field) == FIELD_DECL && "Initial value not for a field!"); assert(OffsetIsLLVMCompatible(field) && "Field position not known!"); // Turn the initial value for this field into an LLVM constant. - Constant *Init = ConvertInitializerWithCast(value, TREE_TYPE(field)); + Constant *Init = ConvertInitializerWithCast(value, TREE_TYPE(field), + Folder); // Work out the range of bits occupied by the field. uint64_t FirstBit = getFieldOffsetInBits(field); assert(FirstBit <= TypeSize && "Field off end of type!"); @@ -1098,7 +1132,7 @@ uint64_t LastBit = FirstBit + BitWidth; // Set the bits occupied by the field to the initial value. - Layout.AddInterval(FieldContents::get(FirstBit, LastBit, Init)); + Layout.AddInterval(FieldContents::get(FirstBit, LastBit, Init, Folder)); } // Force all fields to begin and end on a byte boundary. This automagically @@ -1173,7 +1207,7 @@ return ConstantStruct::get(Context, Elts, Pack); } -static Constant *ConvertCONSTRUCTOR(tree exp) { +static Constant *ConvertCONSTRUCTOR(tree exp, TargetFolder &Folder) { // If the constructor is empty then default initialize all of the components. // It is safe to use the LLVM type here as it covers every part of the GCC // type that can possibly be default initialized. @@ -1184,56 +1218,48 @@ default: DieAbjectly("Unknown constructor!", exp); case VECTOR_TYPE: - case ARRAY_TYPE: return ConvertArrayCONSTRUCTOR(exp); + case ARRAY_TYPE: return ConvertArrayCONSTRUCTOR(exp, Folder); case QUAL_UNION_TYPE: case RECORD_TYPE: - case UNION_TYPE: return ConvertRecordCONSTRUCTOR(exp); + case UNION_TYPE: return ConvertRecordCONSTRUCTOR(exp, Folder); } } -static Constant *ConvertMINUS_EXPR(tree exp) { - Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0)); - Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1)); - return RepresentAsMemory(TheFolder->CreateSub(LHS, RHS), TREE_TYPE(exp)); +static Constant *ConvertMINUS_EXPR(tree exp, TargetFolder &Folder) { + Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0), Folder); + Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1), Folder); + return RepresentAsMemory(Folder.CreateSub(LHS, RHS), TREE_TYPE(exp), Folder); } -static Constant *ConvertPLUS_EXPR(tree exp) { - Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0)); - Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1)); - return RepresentAsMemory(TheFolder->CreateAdd(LHS, RHS), TREE_TYPE(exp)); +static Constant *ConvertPLUS_EXPR(tree exp, TargetFolder &Folder) { + Constant *LHS = getAsRegister(TREE_OPERAND(exp, 0), Folder); + Constant *RHS = getAsRegister(TREE_OPERAND(exp, 1), Folder); + return RepresentAsMemory(Folder.CreateAdd(LHS, RHS), TREE_TYPE(exp), Folder); } -static Constant *ConvertPOINTER_PLUS_EXPR(tree exp) { - Constant *Ptr = getAsRegister(TREE_OPERAND(exp, 0)); // The pointer. - Constant *Idx = getAsRegister(TREE_OPERAND(exp, 1)); // Offset in units. +static Constant *ConvertPOINTER_PLUS_EXPR(tree exp, TargetFolder &Folder) { + Constant *Ptr = getAsRegister(TREE_OPERAND(exp, 0), Folder); // Pointer + Constant *Idx = getAsRegister(TREE_OPERAND(exp, 1), Folder); // Offset (units) // Convert the pointer into an i8* and add the offset to it. - Ptr = TheFolder->CreateBitCast(Ptr, GetUnitPointerType(Context)); + Ptr = Folder.CreateBitCast(Ptr, GetUnitPointerType(Context)); Constant *Result = POINTER_TYPE_OVERFLOW_UNDEFINED ? - TheFolder->CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : - TheFolder->CreateGetElementPtr(Ptr, &Idx, 1); + Folder.CreateInBoundsGetElementPtr(Ptr, &Idx, 1) : + Folder.CreateGetElementPtr(Ptr, &Idx, 1); // The result may be of a different pointer type. - Result = TheFolder->CreateBitCast(Result, getRegType(TREE_TYPE(exp))); + Result = Folder.CreateBitCast(Result, getRegType(TREE_TYPE(exp))); - return RepresentAsMemory(Result, TREE_TYPE(exp)); + return RepresentAsMemory(Result, TREE_TYPE(exp), Folder); } -static Constant *ConvertVIEW_CONVERT_EXPR(tree exp) { +static Constant *ConvertVIEW_CONVERT_EXPR(tree exp, TargetFolder &Folder) { // Does not change the bits, only the type they are considered to be. - return ConvertInitializer(TREE_OPERAND(exp, 0)); + return ConvertInitializerImpl(TREE_OPERAND(exp, 0), Folder); } -/// ConvertInitializer - Convert the initial value for a global variable to an -/// equivalent LLVM constant. Also handles constant constructors. The type of -/// the returned value may be pretty much anything. All that is guaranteed is -/// that its alloc size is equal to the size of the initial value and that its -/// alignment is less than or equal to the initial value's GCC type alignment. -/// Note that the GCC type may have variable size or no size, in which case the -/// size is determined by the initial value. When this happens the size of the -/// initial value may exceed the alloc size of the LLVM memory type generated -/// for the GCC type (see ConvertType); it is never smaller than the alloc size. -Constant *ConvertInitializer(tree exp) { +/// ConvertInitializerImpl - Implementation of ConvertInitializer. +static Constant *ConvertInitializerImpl(tree exp, TargetFolder &Folder) { // If we already converted the initializer then return the cached copy. if (Constant *C = (Constant *)llvm_get_cached(exp)) return C; @@ -1246,39 +1272,40 @@ case INTEGER_CST: case REAL_CST: case VECTOR_CST: - Init = ConvertCST(exp); + Init = ConvertCST(exp, Folder); break; case STRING_CST: - Init = ConvertSTRING_CST(exp); + Init = ConvertSTRING_CST(exp, Folder); break; case ADDR_EXPR: - Init = ConvertADDR_EXPR(exp); + Init = ConvertADDR_EXPR(exp, Folder); break; case CONSTRUCTOR: - Init = ConvertCONSTRUCTOR(exp); + Init = ConvertCONSTRUCTOR(exp, Folder); break; case CONVERT_EXPR: case NOP_EXPR: - Init = ConvertInitializerWithCast(TREE_OPERAND(exp, 0), TREE_TYPE(exp)); + Init = ConvertInitializerWithCast(TREE_OPERAND(exp, 0), TREE_TYPE(exp), + Folder); break; case MINUS_EXPR: - Init = ConvertMINUS_EXPR(exp); + Init = ConvertMINUS_EXPR(exp, Folder); break; case PLUS_EXPR: - Init = ConvertPLUS_EXPR(exp); + Init = ConvertPLUS_EXPR(exp, Folder); break; case POINTER_PLUS_EXPR: - Init = ConvertPOINTER_PLUS_EXPR(exp); + Init = ConvertPOINTER_PLUS_EXPR(exp, Folder); break; case VIEW_CONVERT_EXPR: - Init = ConvertVIEW_CONVERT_EXPR(exp); + Init = ConvertVIEW_CONVERT_EXPR(exp, Folder); break; } // Make the IR easier to read by converting the bunch of bytes returned by // ConvertCST into a less surprising type when it is safe to do so. if (!AGGREGATE_TYPE_P(TREE_TYPE(exp))) - Init = InterpretAsType(Init, ConvertType(TREE_TYPE(exp))); + Init = InterpretAsType(Init, ConvertType(TREE_TYPE(exp)), 0, Folder); #ifndef NDEBUG // Check that the guarantees we make about the returned value actually hold. @@ -1306,14 +1333,28 @@ return Init; } +/// ConvertInitializer - Convert the initial value for a global variable to an +/// equivalent LLVM constant. Also handles constant constructors. The type of +/// the returned value may be pretty much anything. All that is guaranteed is +/// that its alloc size is equal to the size of the initial value and that its +/// alignment is less than or equal to the initial value's GCC type alignment. +/// Note that the GCC type may have variable size or no size, in which case the +/// size is determined by the initial value. When this happens the size of the +/// initial value may exceed the alloc size of the LLVM memory type generated +/// for the GCC type (see ConvertType); it is never smaller than the alloc size. +Constant *ConvertInitializer(tree exp) { + TargetFolder Folder(&getTargetData()); + return ConvertInitializerImpl(exp, Folder); +} + //===----------------------------------------------------------------------===// // ... AddressOf ... //===----------------------------------------------------------------------===// /// AddressOfCST - Return the address of a simple constant, eg a of number. -static Constant *AddressOfCST(tree exp) { - Constant *Init = ConvertInitializer(exp); +static Constant *AddressOfCST(tree exp, TargetFolder &Folder) { + Constant *Init = ConvertInitializerImpl(exp, Folder); // Cache the constants to avoid making obvious duplicates that have to be // folded by the optimizer. @@ -1335,7 +1376,7 @@ } /// AddressOfARRAY_REF - Return the address of an array element or slice. -static Constant *AddressOfARRAY_REF(tree exp) { +static Constant *AddressOfARRAY_REF(tree exp, TargetFolder &Folder) { tree array = TREE_OPERAND(exp, 0); tree index = TREE_OPERAND(exp, 1); tree index_type = TREE_TYPE(index); @@ -1346,46 +1387,45 @@ "Global with variable size?"); // Get the index into the array as an LLVM integer constant. - Constant *IndexVal = getAsRegister(index); + Constant *IndexVal = getAsRegister(index, Folder); // Subtract off the lower bound, if any. tree lower_bound = array_ref_low_bound(exp); if (!integer_zerop(lower_bound)) { // Get the lower bound as an LLVM integer constant. - Constant *LowerBoundVal = getAsRegister(lower_bound); - IndexVal = TheFolder->CreateSub(IndexVal, LowerBoundVal, hasNUW(index_type), - hasNSW(index_type)); + Constant *LowerBoundVal = getAsRegister(lower_bound, Folder); + IndexVal = Folder.CreateSub(IndexVal, LowerBoundVal, hasNUW(index_type), + hasNSW(index_type)); } // Avoid any assumptions about how the array type is represented in LLVM by // doing the GEP on a pointer to the first array element. - Constant *ArrayAddr = AddressOf(array); + Constant *ArrayAddr = AddressOfImpl(array, Folder); const Type *EltTy = ConvertType(TREE_TYPE(TREE_TYPE(array))); - ArrayAddr = TheFolder->CreateBitCast(ArrayAddr, EltTy->getPointerTo()); + ArrayAddr = Folder.CreateBitCast(ArrayAddr, EltTy->getPointerTo()); return POINTER_TYPE_OVERFLOW_UNDEFINED ? - TheFolder->CreateInBoundsGetElementPtr(ArrayAddr, &IndexVal, 1) : - TheFolder->CreateGetElementPtr(ArrayAddr, &IndexVal, 1); + Folder.CreateInBoundsGetElementPtr(ArrayAddr, &IndexVal, 1) : + Folder.CreateGetElementPtr(ArrayAddr, &IndexVal, 1); } /// AddressOfCOMPONENT_REF - Return the address of a field in a record. -static Constant *AddressOfCOMPONENT_REF(tree exp) { +static Constant *AddressOfCOMPONENT_REF(tree exp, TargetFolder &Folder) { tree field_decl = TREE_OPERAND(exp, 1); // Compute the field offset in units from the start of the record. Constant *Offset; if (TREE_OPERAND(exp, 2)) { - Offset = getAsRegister(TREE_OPERAND(exp, 2)); + Offset = getAsRegister(TREE_OPERAND(exp, 2), Folder); // At this point the offset is measured in units divided by (exactly) // (DECL_OFFSET_ALIGN / BITS_PER_UNIT). Convert to units. unsigned factor = DECL_OFFSET_ALIGN(field_decl) / BITS_PER_UNIT; if (factor != 1) - Offset = TheFolder->CreateMul(Offset, - ConstantInt::get(Offset->getType(), - factor)); + Offset = Folder.CreateMul(Offset, ConstantInt::get(Offset->getType(), + factor)); } else { assert(DECL_FIELD_OFFSET(field_decl) && "Field offset not available!"); - Offset = getAsRegister(DECL_FIELD_OFFSET(field_decl)); + Offset = getAsRegister(DECL_FIELD_OFFSET(field_decl), Folder); } // Here BitStart gives the offset of the field in bits from Offset. @@ -1393,35 +1433,34 @@ // Incorporate as much of it as possible into the pointer computation. uint64_t Units = BitStart / BITS_PER_UNIT; if (Units > 0) { - Offset = TheFolder->CreateAdd(Offset, - ConstantInt::get(Offset->getType(), - Units)); + Offset = Folder.CreateAdd(Offset, ConstantInt::get(Offset->getType(), + Units)); BitStart -= Units * BITS_PER_UNIT; } assert(BitStart == 0 && "It's a bitfield reference or we didn't get to the field!"); const Type *UnitPtrTy = GetUnitPointerType(Context); - Constant *StructAddr = AddressOf(TREE_OPERAND(exp, 0)); - Constant *FieldPtr = TheFolder->CreateBitCast(StructAddr, UnitPtrTy); - FieldPtr = TheFolder->CreateInBoundsGetElementPtr(FieldPtr, &Offset, 1); + Constant *StructAddr = AddressOfImpl(TREE_OPERAND(exp, 0), Folder); + Constant *FieldPtr = Folder.CreateBitCast(StructAddr, UnitPtrTy); + FieldPtr = Folder.CreateInBoundsGetElementPtr(FieldPtr, &Offset, 1); return FieldPtr; } /// AddressOfDecl - Return the address of a global. -static Constant *AddressOfDecl(tree exp) { +static Constant *AddressOfDecl(tree exp, TargetFolder &) { return cast(DEFINITION_LLVM(exp)); } /// AddressOfINDIRECT_REF - Return the address of a dereference. -static Constant *AddressOfINDIRECT_REF(tree exp) { +static Constant *AddressOfINDIRECT_REF(tree exp, TargetFolder &Folder) { // The address is just the dereferenced operand. Get it as an LLVM constant. - return getAsRegister(TREE_OPERAND(exp, 0)); + return getAsRegister(TREE_OPERAND(exp, 0), Folder); } /// AddressOfLABEL_DECL - Return the address of a label. -static Constant *AddressOfLABEL_DECL(tree exp) { +static Constant *AddressOfLABEL_DECL(tree exp, TargetFolder &) { extern TreeToLLVM *TheTreeToLLVM; assert(TheTreeToLLVM && @@ -1438,12 +1477,8 @@ return TheTreeToLLVM->AddressOfLABEL_DECL(exp); } -/// AddressOf - Given an expression with a constant address such as a constant, -/// a global variable or a label, returns the address. The type of the returned -/// is always a pointer type and, as long as 'exp' does not have void type, the -/// type of the pointee is the memory type that corresponds to the type of exp -/// (see ConvertType). -Constant *AddressOf(tree exp) { +/// AddressOfImpl - Implementation of AddressOf. +static Constant *AddressOfImpl(tree exp, TargetFolder &Folder) { Constant *Addr; switch (TREE_CODE(exp)) { @@ -1455,29 +1490,29 @@ case REAL_CST: case STRING_CST: case VECTOR_CST: - Addr = AddressOfCST(exp); + Addr = AddressOfCST(exp, Folder); break; case ARRAY_RANGE_REF: case ARRAY_REF: - Addr = AddressOfARRAY_REF(exp); + Addr = AddressOfARRAY_REF(exp, Folder); break; case COMPONENT_REF: - Addr = AddressOfCOMPONENT_REF(exp); + Addr = AddressOfCOMPONENT_REF(exp, Folder); break; case COMPOUND_LITERAL_EXPR: // FIXME: not gimple - defined by C front-end - Addr = AddressOf(DECL_EXPR_DECL(TREE_OPERAND(exp, 0))); + Addr = AddressOfImpl(DECL_EXPR_DECL(TREE_OPERAND(exp, 0)), Folder); break; case CONST_DECL: case FUNCTION_DECL: case VAR_DECL: - Addr = AddressOfDecl(exp); + Addr = AddressOfDecl(exp, Folder); break; case INDIRECT_REF: case MISALIGNED_INDIRECT_REF: - Addr = AddressOfINDIRECT_REF(exp); + Addr = AddressOfINDIRECT_REF(exp, Folder); break; case LABEL_DECL: - Addr = AddressOfLABEL_DECL(exp); + Addr = AddressOfLABEL_DECL(exp, Folder); break; } @@ -1489,5 +1524,15 @@ else Ty = ConvertType(TREE_TYPE(exp))->getPointerTo(); - return TheFolder->CreateBitCast(Addr, Ty); + return Folder.CreateBitCast(Addr, Ty); +} + +/// AddressOf - Given an expression with a constant address such as a constant, +/// a global variable or a label, returns the address. The type of the returned +/// is always a pointer type and, as long as 'exp' does not have void type, the +/// type of the pointee is the memory type that corresponds to the type of exp +/// (see ConvertType). +Constant *AddressOf(tree exp) { + TargetFolder Folder(&getTargetData()); + return AddressOfImpl(exp, Folder); } From benny.kra at googlemail.com Fri Apr 29 03:15:41 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 29 Apr 2011 08:15:41 -0000 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll Message-ID: <20110429081541.B7F422A6C138@llvm.org> Author: d0k Date: Fri Apr 29 03:15:41 2011 New Revision: 130485 URL: http://llvm.org/viewvc/llvm-project?rev=130485&view=rev Log: InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A) Fixes PR9809. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp llvm/trunk/test/Transforms/InstCombine/shift.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=130485&r1=130484&r2=130485&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Fri Apr 29 03:15:41 2011 @@ -644,7 +644,14 @@ return &I; } } - + + // (C1 << A) << C2) -> (C1 << C2) << A) + Constant *C1, *C2; + Value *A; + if (match(I.getOperand(0), m_OneUse(m_Shl(m_Constant(C1), m_Value(A)))) && + match(I.getOperand(1), m_Constant(C2))) + return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A); + return 0; } Modified: llvm/trunk/test/Transforms/InstCombine/shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/shift.ll?rev=130485&r1=130484&r2=130485&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/shift.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/shift.ll Fri Apr 29 03:15:41 2011 @@ -485,3 +485,24 @@ ; CHECK: ret i8 %tmp551 ret i8 %tmp55 } + +; PR9809 +define i32 @test40(i32 %a, i32 %b) nounwind { + %shl1 = shl i32 1, %b + %shl2 = shl i32 %shl1, 2 + %div = udiv i32 %a, %shl2 + ret i32 %div +; CHECK: @test40 +; CHECK-NEXT: add i32 %b, 2 +; CHECK-NEXT: lshr i32 %a +; CHECK-NEXT: ret i32 +} + +define i32 @test41(i32 %a, i32 %b) nounwind { + %1 = shl i32 1, %b + %2 = shl i32 %1, 3 + ret i32 %2 +; CHECK: @test41 +; CHECK-NEXT: shl i32 8, %b +; CHECK-NEXT: ret i32 +} From baldrick at free.fr Fri Apr 29 03:36:26 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 10:36:26 +0200 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <20110429081541.B7F422A6C138@llvm.org> References: <20110429081541.B7F422A6C138@llvm.org> Message-ID: <4DBA788A.9000001@free.fr> Hi Benjamin, > + // (C1<< A)<< C2) -> (C1<< C2)<< A) nice transform! You have more closing parentheses than opening parentheses on the above line though :) Ciao, Duncan. From benny.kra at googlemail.com Fri Apr 29 03:41:23 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 29 Apr 2011 08:41:23 -0000 Subject: [llvm-commits] [llvm] r130489 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Message-ID: <20110429084123.9F95E2A6C135@llvm.org> Author: d0k Date: Fri Apr 29 03:41:23 2011 New Revision: 130489 URL: http://llvm.org/viewvc/llvm-project?rev=130489&view=rev Log: Balance parentheses. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=130489&r1=130488&r2=130489&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Fri Apr 29 03:41:23 2011 @@ -645,7 +645,7 @@ } } - // (C1 << A) << C2) -> (C1 << C2) << A) + // (C1 << A) << C2 -> (C1 << C2) << A Constant *C1, *C2; Value *A; if (match(I.getOperand(0), m_OneUse(m_Shl(m_Constant(C1), m_Value(A)))) && From pichet2000 at gmail.com Fri Apr 29 03:56:07 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Fri, 29 Apr 2011 08:56:07 -0000 Subject: [llvm-commits] [llvm] r130490 - in /llvm/trunk/runtime/libprofile: CommonProfiling.c PathProfiling.c Message-ID: <20110429085607.BCFA12A6C135@llvm.org> Author: fpichet Date: Fri Apr 29 03:56:07 2011 New Revision: 130490 URL: http://llvm.org/viewvc/llvm-project?rev=130490&view=rev Log: Unbreak the MSVC build: - unistd.h doesn't exist with MSVC - inline must be __inline in Microsoft C - atexit cannot take a function declared as void f(), must be void f(void). Modified: llvm/trunk/runtime/libprofile/CommonProfiling.c llvm/trunk/runtime/libprofile/PathProfiling.c Modified: llvm/trunk/runtime/libprofile/CommonProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/CommonProfiling.c?rev=130490&r1=130489&r2=130490&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/CommonProfiling.c (original) +++ llvm/trunk/runtime/libprofile/CommonProfiling.c Fri Apr 29 03:56:07 2011 @@ -19,7 +19,11 @@ #include #include #include +#if !defined(_MSC_VER) && !defined(__MINGW32__) #include +#else +#include +#endif #include static char *SavedArgs = 0; Modified: llvm/trunk/runtime/libprofile/PathProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/PathProfiling.c?rev=130490&r1=130489&r2=130490&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/PathProfiling.c (original) +++ llvm/trunk/runtime/libprofile/PathProfiling.c Fri Apr 29 03:56:07 2011 @@ -16,13 +16,21 @@ #include "Profiling.h" #include "llvm/Analysis/ProfileInfoTypes.h" #include -#include +#if !defined(_MSC_VER) && !defined(__MINGW32__) +#include +#else +#include +#endif #include #include -#include #include #include +// Must use __inline in Microsoft C +#if defined(_MSC_VER) +#define inline __inline +#endif + /* note that this is used for functions with large path counts, but it is unlikely those paths will ALL be executed */ #define ARBITRARY_HASH_BIN_COUNT 100 @@ -215,7 +223,7 @@ * +-----------------+-----------------+ * */ -static void pathProfAtExitHandler() { +static void pathProfAtExitHandler(void) { int outFile = getOutFile(); uint32_t i; uint32_t header[2] = { PathInfo, 0 }; From geek4civic at gmail.com Fri Apr 29 04:59:12 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Fri, 29 Apr 2011 09:59:12 -0000 Subject: [llvm-commits] [llvm] r130493 - /llvm/trunk/docs/doxygen.css Message-ID: <20110429095912.75A722A6C135@llvm.org> Author: chapuni Date: Fri Apr 29 04:59:12 2011 New Revision: 130493 URL: http://llvm.org/viewvc/llvm-project?rev=130493&view=rev Log: docs/doxygen.css: Tweak padding on memdoc. Modified: llvm/trunk/docs/doxygen.css Modified: llvm/trunk/docs/doxygen.css URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/doxygen.css?rev=130493&r1=130492&r2=130493&view=diff ============================================================================== --- llvm/trunk/docs/doxygen.css (original) +++ llvm/trunk/docs/doxygen.css Fri Apr 29 04:59:12 2011 @@ -401,3 +401,8 @@ -moz-border-radius-topleft: 0.5em; -moz-border-radius-topright: 0.5em; } + +div.memdoc { + padding-left: 1em; + padding-right: 1em; +} From baldrick at free.fr Fri Apr 29 05:34:45 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 10:34:45 -0000 Subject: [llvm-commits] [dragonegg] r130494 - in /dragonegg/trunk/src: Constants.cpp Types.cpp Message-ID: <20110429103445.87BB52A6C135@llvm.org> Author: baldrick Date: Fri Apr 29 05:34:45 2011 New Revision: 130494 URL: http://llvm.org/viewvc/llvm-project?rev=130494&view=rev Log: By the time a record or union type gets to the plugin it will only contain FIELD_DECLs, thanks to the free_lang_data pass. Modified: dragonegg/trunk/src/Constants.cpp dragonegg/trunk/src/Types.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130494&r1=130493&r2=130494&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Fri Apr 29 05:34:45 2011 @@ -1060,9 +1060,7 @@ if (flag_default_initialize_globals) { for (tree field = TYPE_FIELDS(TREE_TYPE(exp)); field; field = TREE_CHAIN(field)) { - // Skip contained methods, types etc. - if (TREE_CODE(field) != FIELD_DECL) - continue; + assert(TREE_CODE(field) == FIELD_DECL && "Lang data not freed?"); // If the field has variable or unknown position then it cannot be default // initialized - skip it. if (!OffsetIsLLVMCompatible(field)) Modified: dragonegg/trunk/src/Types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=130494&r1=130493&r2=130494&view=diff ============================================================================== --- dragonegg/trunk/src/Types.cpp (original) +++ dragonegg/trunk/src/Types.cpp Fri Apr 29 05:34:45 2011 @@ -582,17 +582,14 @@ if (TYPE_TRANSPARENT_AGGR(type)) { tree Field = TYPE_FIELDS(type); assert(Field && "Transparent union must have some elements!"); - while (TREE_CODE(Field) != FIELD_DECL) { - Field = TREE_CHAIN(Field); - assert(Field && "Transparent union must have some elements!"); - } + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); return GCCTypeOverlapsWithPadding(TREE_TYPE(Field), PadStartBits, PadSizeBits); } // See if any elements overlap. for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (TREE_CODE(Field) != FIELD_DECL) continue; + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); assert(getFieldOffsetInBits(Field) == 0 && "Union with non-zero offset?"); // Skip fields that are known not to be present. if (TREE_CODE(type) == QUAL_UNION_TYPE && @@ -614,7 +611,7 @@ case RECORD_TYPE: for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (TREE_CODE(Field) != FIELD_DECL) continue; + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); if (!OffsetIsLLVMCompatible(Field)) // Variable or humongous offset. @@ -1795,8 +1792,8 @@ unsigned ExtraSizeInBits = 0; tree LastBitField = 0; for (tree f = TREE_CHAIN(Field); f; f = TREE_CHAIN(f)) { - if (TREE_CODE(f) != FIELD_DECL || - TREE_CODE(DECL_FIELD_OFFSET(f)) != INTEGER_CST) + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); + if (TREE_CODE(DECL_FIELD_OFFSET(f)) != INTEGER_CST) break; if (isBitfield(f)) LastBitField = f; @@ -1890,7 +1887,7 @@ /// offsets that are zero, e.g., no Fortran equivalences. static bool UnionHasOnlyZeroOffsets(tree type) { for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (TREE_CODE(Field) != FIELD_DECL) continue; + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); if (!OffsetIsLLVMCompatible(Field)) return false; if (getFieldOffsetInBits(Field) != 0) @@ -1913,7 +1910,7 @@ unsigned MinAlign = ~0U; uint64_t BestSize = FindBiggest ? 0 : ~(uint64_t)0; for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { - if (TREE_CODE(Field) != FIELD_DECL) continue; + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); assert(DECL_FIELD_OFFSET(Field) && integer_zerop(DECL_FIELD_OFFSET(Field)) && "Union with non-zero offset?"); @@ -2015,9 +2012,11 @@ // Record those fields which will be converted to LLVM fields. SmallVector, 32> Fields; - for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) - if (TREE_CODE(Field) == FIELD_DECL && OffsetIsLLVMCompatible(Field)) + for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) { + assert(TREE_CODE(Field) == FIELD_DECL && "Lang data not freed?"); + if (OffsetIsLLVMCompatible(Field)) Fields.push_back(std::make_pair(Field, getFieldOffsetInBits(Field))); + } // The fields are almost always sorted, but occasionally not. Sort them by // field offset. From baldrick at free.fr Fri Apr 29 05:48:25 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 10:48:25 -0000 Subject: [llvm-commits] [dragonegg] r130495 - /dragonegg/trunk/src/Convert.cpp Message-ID: <20110429104825.951752A6C135@llvm.org> Author: baldrick Date: Fri Apr 29 05:48:25 2011 New Revision: 130495 URL: http://llvm.org/viewvc/llvm-project?rev=130495&view=rev Log: Don't mention constants here, since we get here whenever we hit an unsupported gimple statement. Modified: dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=130495&r1=130494&r2=130495&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri Apr 29 05:48:25 2011 @@ -5902,7 +5902,7 @@ Constant *TreeToLLVM::EmitRegisterConstant(tree reg) { #ifndef NDEBUG if (!is_gimple_constant(reg)) - DieAbjectly("Not a gimple constant!", reg); + DieAbjectly("Unsupported gimple!", reg); #endif assert(is_gimple_reg_type(TREE_TYPE(reg)) && "Not of register type!"); From baldrick at free.fr Fri Apr 29 06:59:53 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 11:59:53 -0000 Subject: [llvm-commits] [dragonegg] r130496 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20110429115953.CDF4D2A6C135@llvm.org> Author: baldrick Date: Fri Apr 29 06:59:53 2011 New Revision: 130496 URL: http://llvm.org/viewvc/llvm-project?rev=130496&view=rev Log: Add support for COND_EXPRs. These are removed by the gimplifier but may be reintroduced by the if-conversion pass when GCC optimization is enabled. Note that unlike in llvm-gcc the operands are not branches but expressions. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=130496&r1=130495&r2=130496&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Fri Apr 29 06:59:53 2011 @@ -721,6 +721,7 @@ Value *EmitLoadOfLValue(tree_node *exp); Value *EmitOBJ_TYPE_REF(tree_node *exp); Value *EmitADDR_EXPR(tree_node *exp); + Value *EmitCOND_EXPR(tree_node *exp); Value *EmitCallOf(Value *Callee, gimple_statement_d *stmt, const MemRef *DestLoc, const AttrListPtr &PAL); CallInst *EmitSimpleCall(StringRef CalleeName, tree_node *ret_type, Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=130496&r1=130495&r2=130496&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri Apr 29 06:59:53 2011 @@ -2386,6 +2386,21 @@ return Builder.CreateBitCast(LV.Ptr, ConvertType(TREE_TYPE(exp))); } +Value *TreeToLLVM::EmitCOND_EXPR(tree exp) { + // Emit the comparison. + tree cond = COND_EXPR_COND(exp); + assert(COMPARISON_CLASS_P(cond) && "Expected a comparison!"); + Value *CondVal = EmitCompare(TREE_OPERAND(cond, 0), TREE_OPERAND(cond, 1), + TREE_CODE(cond)); + + // Emit the true and false values. + Value *TrueVal = EmitRegister(COND_EXPR_THEN(exp)); + Value *FalseVal = EmitRegister(COND_EXPR_ELSE(exp)); + + // Select the value to use based on the condition. + return Builder.CreateSelect(CondVal, TrueVal, FalseVal); +} + Value *TreeToLLVM::EmitOBJ_TYPE_REF(tree exp) { return Builder.CreateBitCast(EmitRegister(OBJ_TYPE_REF_EXPR(exp)), ConvertType(TREE_TYPE(exp))); @@ -7897,6 +7912,7 @@ // Expressions (tcc_expression). case ADDR_EXPR: return EmitADDR_EXPR(rhs); + case COND_EXPR: return EmitCOND_EXPR(rhs); case OBJ_TYPE_REF: return EmitOBJ_TYPE_REF(rhs); // Exceptional (tcc_exceptional). From baldrick at free.fr Fri Apr 29 08:55:12 2011 From: baldrick at free.fr (Duncan Sands) Date: Fri, 29 Apr 2011 13:55:12 -0000 Subject: [llvm-commits] [dragonegg] r130497 - /dragonegg/trunk/src/Convert.cpp Message-ID: <20110429135512.212522A6C135@llvm.org> Author: baldrick Date: Fri Apr 29 08:55:11 2011 New Revision: 130497 URL: http://llvm.org/viewvc/llvm-project?rev=130497&view=rev Log: Fully support cond_expr: as well as a comparison the condition might be an ssa name, see is_gimple_condexpr. Modified: dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=130497&r1=130496&r2=130497&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Fri Apr 29 08:55:11 2011 @@ -2387,11 +2387,17 @@ } Value *TreeToLLVM::EmitCOND_EXPR(tree exp) { - // Emit the comparison. + // Emit the condition. It may not be in SSA form, but if not then it is a + // comparison. tree cond = COND_EXPR_COND(exp); - assert(COMPARISON_CLASS_P(cond) && "Expected a comparison!"); - Value *CondVal = EmitCompare(TREE_OPERAND(cond, 0), TREE_OPERAND(cond, 1), - TREE_CODE(cond)); + Value *CondVal = COMPARISON_CLASS_P(cond) ? + EmitCompare(TREE_OPERAND(cond, 0), TREE_OPERAND(cond, 1), TREE_CODE(cond)) : + EmitRegister(cond); + + // Ensure the condition has i1 type. + if (!CondVal->getType()->isIntegerTy(1)) + CondVal = Builder.CreateICmpNE(CondVal, + Constant::getNullValue(CondVal->getType())); // Emit the true and false values. Value *TrueVal = EmitRegister(COND_EXPR_THEN(exp)); From atrick at apple.com Fri Apr 29 09:02:41 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 29 Apr 2011 14:02:41 -0000 Subject: [llvm-commits] [llvm] r130498 - in /llvm/trunk/test/CodeGen/Thumb2: thumb2-ror.ll thumb2-ror2.ll Message-ID: <20110429140241.454A92A6C135@llvm.org> Author: atrick Date: Fri Apr 29 09:02:41 2011 New Revision: 130498 URL: http://llvm.org/viewvc/llvm-project?rev=130498&view=rev Log: Combine thumb2-ror tests. Removed: llvm/trunk/test/CodeGen/Thumb2/thumb2-ror2.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll?rev=130498&r1=130497&r2=130498&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll Fri Apr 29 09:02:41 2011 @@ -1,11 +1,22 @@ ; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s +; CHECK: f1: +; CHECK: ror.w r0, r0, #22 define i32 @f1(i32 %a) { %l8 = shl i32 %a, 10 %r8 = lshr i32 %a, 22 %tmp = or i32 %l8, %r8 ret i32 %tmp } -; CHECK: f1: -; CHECK: ror.w r0, r0, #22 + +; CHECK: f2: +; CHECK: ror +define i32 @f2(i32 %v, i32 %nbits) { +entry: + %shr = lshr i32 %v, %nbits + %sub = sub i32 32, %nbits + %shl = shl i32 %v, %sub + %or = or i32 %shl, %shr + ret i32 %or +} \ No newline at end of file Removed: llvm/trunk/test/CodeGen/Thumb2/thumb2-ror2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ror2.ll?rev=130497&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ror2.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ror2.ll (removed) @@ -1,11 +0,0 @@ -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s - -define i32 @f1(i32 %a, i32 %b) { -; CHECK: f1: -; CHECK: rors r0, r1 - %db = sub i32 32, %b - %l8 = shl i32 %a, %b - %r8 = lshr i32 %a, %db - %tmp = or i32 %l8, %r8 - ret i32 %tmp -} From benny.kra at googlemail.com Fri Apr 29 09:09:57 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 29 Apr 2011 14:09:57 -0000 Subject: [llvm-commits] [llvm] r130499 - /llvm/trunk/lib/Target/X86/README.txt Message-ID: <20110429140957.A97F12A6C135@llvm.org> Author: d0k Date: Fri Apr 29 09:09:57 2011 New Revision: 130499 URL: http://llvm.org/viewvc/llvm-project?rev=130499&view=rev Log: This is done. Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=130499&r1=130498&r2=130499&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Fri Apr 29 09:09:57 2011 @@ -1728,26 +1728,6 @@ //===---------------------------------------------------------------------===// Take the following C code: -int x(int y) { return (y & 63) << 14; } - -Code produced by gcc: - andl $63, %edi - sall $14, %edi - movl %edi, %eax - ret - -Code produced by clang: - shll $14, %edi - movl %edi, %eax - andl $1032192, %eax - ret - -The code produced by gcc is 3 bytes shorter. This sort of construct often -shows up with bitfields. - -//===---------------------------------------------------------------------===// - -Take the following C code: int f(int a, int b) { return (unsigned char)a == (unsigned char)b; } We generate the following IR with clang: From rafael.espindola at gmail.com Fri Apr 29 09:14:06 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 14:14:06 -0000 Subject: [llvm-commits] [llvm] r130501 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Message-ID: <20110429141406.A70C32A6C135@llvm.org> Author: rafael Date: Fri Apr 29 09:14:06 2011 New Revision: 130501 URL: http://llvm.org/viewvc/llvm-project?rev=130501&view=rev Log: Factor some code to needsCFIMoves. Avoid printing moves when we don't have to. Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=130501&r1=130500&r2=130501&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original) +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Apr 29 09:14:06 2011 @@ -185,6 +185,8 @@ void emitPrologLabel(const MachineInstr &MI); + bool needsCFIMoves(); + /// EmitConstantPool - Print to the current output stream assembly /// representations of the constants in the constant pool MCP. This is /// used to print out constants which have been "spilled to memory" by Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130501&r1=130500&r2=130501&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Apr 29 09:14:06 2011 @@ -38,6 +38,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetLoweringObjectFile.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Assembly/Writer.h" #include "llvm/ADT/SmallString.h" @@ -591,6 +592,19 @@ return true; } +bool AsmPrinter::needsCFIMoves() { + if (UnwindTablesMandatory) + return true; + + if (MMI->hasDebugInfo() && !MAI->doesDwarfRequireFrameSection()) + return true; + + if (MF->getFunction()->doesNotThrow()) + return false; + + return true; +} + void AsmPrinter::emitPrologLabel(const MachineInstr &MI) { MCSymbol *Label = MI.getOperand(0).getMCSymbol(); @@ -601,8 +615,10 @@ if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI) return; - const MachineFunction &MF = *MI.getParent()->getParent(); - MachineModuleInfo &MMI = MF.getMMI(); + if (!needsCFIMoves()) + return; + + MachineModuleInfo &MMI = MF->getMMI(); std::vector &Moves = MMI.getFrameMoves(); bool FoundOne = false; (void)FoundOne; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=130501&r1=130500&r2=130501&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Fri Apr 29 09:14:06 2011 @@ -78,8 +78,7 @@ shouldEmitTable = !MMI->getLandingPads().empty(); // See if we need frame move info. - shouldEmitMoves = MMI->hasDebugInfo() || - !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory; + shouldEmitMoves = Asm->needsCFIMoves(); if (shouldEmitMoves || shouldEmitTable) // Assumes in correct section after the entry point. From atrick at apple.com Fri Apr 29 09:18:15 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 29 Apr 2011 14:18:15 -0000 Subject: [llvm-commits] [llvm] r130502 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/Thumb2/thumb2-ror.ll Message-ID: <20110429141815.90FCE2A6C135@llvm.org> Author: atrick Date: Fri Apr 29 09:18:15 2011 New Revision: 130502 URL: http://llvm.org/viewvc/llvm-project?rev=130502&view=rev Log: Teach Thumb2 isel to fold and->rotr ==> ROR. Generalization of Nate Begeman's patch! Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130502&r1=130501&r2=130502&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Apr 29 09:18:15 2011 @@ -84,6 +84,11 @@ return (uint32_t)(~N->getZExtValue()) < 255; }], imm_comp_XFORM>; +def lo5AllOne : PatLeaf<(i32 imm), [{ + // Returns true if all low 5-bits are 1. + return (((uint32_t)N->getZExtValue()) & 0x1FUL) == 0x1FUL; +}]>; + // Define Thumb2 specific addressing modes. // t2addrmode_imm12 := reg + imm12 @@ -2023,6 +2028,10 @@ defm t2ASR : T2I_sh_ir<0b10, "asr", BinOpFrag<(sra node:$LHS, node:$RHS)>>; defm t2ROR : T2I_sh_ir<0b11, "ror", BinOpFrag<(rotr node:$LHS, node:$RHS)>>; +// (rotr x, (and y, 0x...1f)) ==> (ROR x, y) +def : Pat<(rotr rGPR:$lhs, (and rGPR:$rhs, lo5AllOne)), + (t2RORrr rGPR:$lhs, rGPR:$rhs)>; + let Uses = [CPSR] in { def t2RRX : T2sTwoReg<(outs rGPR:$Rd), (ins rGPR:$Rm), IIC_iMOVsi, "rrx", "\t$Rd, $Rm", Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll?rev=130502&r1=130501&r2=130502&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ror.ll Fri Apr 29 09:18:15 2011 @@ -11,11 +11,13 @@ } ; CHECK: f2: +; CHECK-NOT: and ; CHECK: ror define i32 @f2(i32 %v, i32 %nbits) { entry: - %shr = lshr i32 %v, %nbits - %sub = sub i32 32, %nbits + %and = and i32 %nbits, 31 + %shr = lshr i32 %v, %and + %sub = sub i32 32, %and %shl = shl i32 %v, %sub %or = or i32 %shl, %shr ret i32 %or From rafael.espindola at gmail.com Fri Apr 29 09:48:51 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 14:48:51 -0000 Subject: [llvm-commits] [llvm] r130503 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfCFIException.cpp lib/CodeGen/AsmPrinter/DwarfException.h test/CodeGen/X86/2007-05-05-Personality.ll Message-ID: <20110429144851.B66F12A6C135@llvm.org> Author: rafael Date: Fri Apr 29 09:48:51 2011 New Revision: 130503 URL: http://llvm.org/viewvc/llvm-project?rev=130503&view=rev Log: Change DwarfCFIException's member variables to track what it actually emmits: .cfi_personality, .cfi_lsda and the moves. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h llvm/trunk/test/CodeGen/X86/2007-05-05-Personality.ll Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=130503&r1=130502&r2=130503&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Fri Apr 29 09:48:51 2011 @@ -41,7 +41,7 @@ DwarfCFIException::DwarfCFIException(AsmPrinter *A) : DwarfException(A), - shouldEmitTable(false), shouldEmitMoves(false), shouldEmitTableModule(false) + shouldEmitPersonality(false), shouldEmitLSDA(false), shouldEmitMoves(false) {} DwarfCFIException::~DwarfCFIException() {} @@ -52,9 +52,6 @@ if (!Asm->MAI->isExceptionHandlingDwarf()) return; - if (!shouldEmitTableModule) - return; - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned PerEncoding = TLOF.getPersonalityEncoding(); @@ -64,7 +61,9 @@ // Emit references to all used personality functions const std::vector &Personalities = MMI->getPersonalities(); for (size_t i = 0, e = Personalities.size(); i != e; ++i) { - const MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]); + if (!Personalities[i]) + continue; + MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]); TLOF.emitPersonalityValue(Asm->OutStreamer, Asm->TM, Sym); } } @@ -72,50 +71,54 @@ /// BeginFunction - Gather pre-function exception information. Assumes it's /// being emitted immediately after the function entry point. void DwarfCFIException::BeginFunction(const MachineFunction *MF) { - shouldEmitTable = shouldEmitMoves = false; + shouldEmitMoves = shouldEmitPersonality = shouldEmitLSDA = false; // If any landing pads survive, we need an EH table. - shouldEmitTable = !MMI->getLandingPads().empty(); + bool hasLandingPads = !MMI->getLandingPads().empty(); // See if we need frame move info. shouldEmitMoves = Asm->needsCFIMoves(); - if (shouldEmitMoves || shouldEmitTable) - // Assumes in correct section after the entry point. - Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin", - Asm->getFunctionNumber())); + const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + unsigned PerEncoding = TLOF.getPersonalityEncoding(); + const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()]; - shouldEmitTableModule |= shouldEmitTable; + shouldEmitPersonality = hasLandingPads && + PerEncoding != dwarf::DW_EH_PE_omit && Per; - if (shouldEmitMoves || shouldEmitTable) - Asm->OutStreamer.EmitCFIStartProc(); + unsigned LSDAEncoding = TLOF.getLSDAEncoding(); + shouldEmitLSDA = shouldEmitPersonality && + LSDAEncoding != dwarf::DW_EH_PE_omit; - if (!shouldEmitTable) + if (!shouldEmitPersonality && !shouldEmitMoves) return; - const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); - - // Provide LSDA information. - unsigned LSDAEncoding = TLOF.getLSDAEncoding(); - if (LSDAEncoding != dwarf::DW_EH_PE_omit) - Asm->OutStreamer.EmitCFILsda(Asm->GetTempSymbol("exception", - Asm->getFunctionNumber()), - LSDAEncoding); + Asm->OutStreamer.EmitCFIStartProc(); // Indicate personality routine, if any. - unsigned PerEncoding = TLOF.getPersonalityEncoding(); - const Function *Per = MMI->getPersonalities()[MMI->getPersonalityIndex()]; - if (PerEncoding == dwarf::DW_EH_PE_omit || !Per) + if (!shouldEmitPersonality) return; const MCSymbol *Sym = TLOF.getCFIPersonalitySymbol(Per, Asm->Mang, MMI); Asm->OutStreamer.EmitCFIPersonality(Sym, PerEncoding); + + Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin", + Asm->getFunctionNumber())); + + // Provide LSDA information. + if (!shouldEmitLSDA) + return; + + Asm->OutStreamer.EmitCFILsda(Asm->GetTempSymbol("exception", + Asm->getFunctionNumber()), + LSDAEncoding); } /// EndFunction - Gather and emit post-function exception information. /// void DwarfCFIException::EndFunction() { - if (!shouldEmitMoves && !shouldEmitTable) return; + if (!shouldEmitPersonality && !shouldEmitMoves) + return; Asm->OutStreamer.EmitCFIEndProc(); @@ -125,6 +128,6 @@ // Map all labels and get rid of any dead landing pads. MMI->TidyLandingPads(); - if (shouldEmitTable) + if (shouldEmitPersonality) EmitExceptionTable(); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h?rev=130503&r1=130502&r2=130503&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.h Fri Apr 29 09:48:51 2011 @@ -140,17 +140,18 @@ }; class DwarfCFIException : public DwarfException { - /// shouldEmitTable - Per-function flag to indicate if EH tables should - /// be emitted. - bool shouldEmitTable; + /// shouldEmitPersonality - Per-function flag to indicate if .cfi_personality + /// should be emitted. + bool shouldEmitPersonality; + + /// shouldEmitLSDA - Per-function flag to indicate if .cfi_lsda + /// should be emitted. + bool shouldEmitLSDA; /// shouldEmitMoves - Per-function flag to indicate if frame moves info /// should be emitted. bool shouldEmitMoves; - /// shouldEmitTableModule - Per-module flag to indicate if EH tables - /// should be emitted. - bool shouldEmitTableModule; public: //===--------------------------------------------------------------------===// // Main entry points. Modified: llvm/trunk/test/CodeGen/X86/2007-05-05-Personality.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-05-05-Personality.ll?rev=130503&r1=130502&r2=130503&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-05-05-Personality.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-05-05-Personality.ll Fri Apr 29 09:48:51 2011 @@ -1,7 +1,7 @@ ; RUN: llc < %s -mtriple=i686-pc-linux-gnu -o - | FileCheck %s -; CHECK: .cfi_lsda 0, .Lexception0 ; CHECK: .cfi_personality 0, __gnat_eh_personality +; CHECK: .cfi_lsda 0, .Lexception0 @error = external global i8 ; [#uses=2] From rafael.espindola at gmail.com Fri Apr 29 10:09:53 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 15:09:53 -0000 Subject: [llvm-commits] [llvm] r130504 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Message-ID: <20110429150953.501A92A6C135@llvm.org> Author: rafael Date: Fri Apr 29 10:09:53 2011 New Revision: 130504 URL: http://llvm.org/viewvc/llvm-project?rev=130504&view=rev Log: The last hack for producing bit identical output with cfi on OS X. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=130504&r1=130503&r2=130504&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Fri Apr 29 10:09:53 2011 @@ -53,6 +53,14 @@ return; const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); + + if (!TLOF.isFunctionEHFrameSymbolPrivate()) { + // This is a temporary hack to keep sections in the same order they + // were before. This lets us produce bit identical outputs while + // transitioning to CFI. + Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); + } + unsigned PerEncoding = TLOF.getPersonalityEncoding(); if ((PerEncoding & 0x70) != dwarf::DW_EH_PE_pcrel) From daniel at zuster.org Fri Apr 29 10:26:12 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 15:26:12 -0000 Subject: [llvm-commits] [zorg] r130507 - /zorg/trunk/lnt/lnt/server/ui/views.py Message-ID: <20110429152612.1BFB12A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 10:26:11 2011 New Revision: 130507 URL: http://llvm.org/viewvc/llvm-project?rev=130507&view=rev Log: LNT/Flask: Fix a few bugs in the submit process. Modified: zorg/trunk/lnt/lnt/server/ui/views.py Modified: zorg/trunk/lnt/lnt/server/ui/views.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=130507&r1=130506&r2=130507&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/server/ui/views.py (original) +++ zorg/trunk/lnt/lnt/server/ui/views.py Fri Apr 29 10:26:11 2011 @@ -90,14 +90,17 @@ input_data = request.form.get('input_data') commit = int(request.form.get('commit', 0)) - if not input_file.content_length and not input_data: + if input_file and not input_file.content_length: + input_file = None + + if not input_file and not input_data: return render_template( "submit_run.html", error="must provide input file or data") - if input_file.content_length and input_data: + if input_file and input_data: return render_template( "submit_run.html", error="cannot provide input file *and* data") - if input_file.content_length: + if input_file: data_value = input_file.read() else: data_value = input_data @@ -120,7 +123,7 @@ result = ImportData.import_and_report( current_app.old_config, g.db_name, db, path, '', commit) - return flask.jsonify(data = result) + return flask.jsonify(**result) return render_template("submit_run.html") From dgregor at apple.com Fri Apr 29 11:12:17 2011 From: dgregor at apple.com (Douglas Gregor) Date: Fri, 29 Apr 2011 16:12:17 -0000 Subject: [llvm-commits] [llvm] r130510 - /llvm/trunk/lib/Support/Unix/Signals.inc Message-ID: <20110429161217.C96192A6C135@llvm.org> Author: dgregor Date: Fri Apr 29 11:12:17 2011 New Revision: 130510 URL: http://llvm.org/viewvc/llvm-project?rev=130510&view=rev Log: Include before we use pthread_self/pthread_kill Modified: llvm/trunk/lib/Support/Unix/Signals.inc Modified: llvm/trunk/lib/Support/Unix/Signals.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Signals.inc?rev=130510&r1=130509&r2=130510&view=diff ============================================================================== --- llvm/trunk/lib/Support/Unix/Signals.inc (original) +++ llvm/trunk/lib/Support/Unix/Signals.inc Fri Apr 29 11:12:17 2011 @@ -274,6 +274,9 @@ #ifdef __APPLE__ +#include +#include + int raise(int sig) { return pthread_kill(pthread_self(), sig); } @@ -291,9 +294,6 @@ abort(); } -#include -#include - void abort() { raise(SIGABRT); usleep(1000); From fjahanian at apple.com Fri Apr 29 11:35:23 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Fri, 29 Apr 2011 16:35:23 -0000 Subject: [llvm-commits] [test-suite] r130512 - /test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Message-ID: <20110429163523.557E22A6C135@llvm.org> Author: fjahanian Date: Fri Apr 29 11:35:23 2011 New Revision: 130512 URL: http://llvm.org/viewvc/llvm-project?rev=130512&view=rev Log: Add missing ms_struct attribute to test. Modified: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Modified: test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c?rev=130512&r1=130511&r2=130512&view=diff ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c (original) +++ test-suite/trunk/SingleSource/UnitTests/ms_struct-bitfield-init.c Fri Apr 29 11:35:23 2011 @@ -38,7 +38,7 @@ int i3; int : 0; int i4; -} t3 = {1,2,3,4}; +} ATTR t3 = {1,2,3,4}; int main() { if (sizeof(t1) != 2) From dgregor at apple.com Fri Apr 29 11:57:12 2011 From: dgregor at apple.com (Douglas Gregor) Date: Fri, 29 Apr 2011 16:57:12 -0000 Subject: [llvm-commits] [llvm] r130513 - /llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp Message-ID: <20110429165712.3B9542A6C135@llvm.org> Author: dgregor Date: Fri Apr 29 11:57:12 2011 New Revision: 130513 URL: http://llvm.org/viewvc/llvm-project?rev=130513&view=rev Log: Fix a C++0x portability issue with std::make_pair. Explicitly providing template arguments no longer works when the call arguments are lvalues. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp?rev=130513&r1=130512&r2=130513&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp Fri Apr 29 11:57:12 2011 @@ -142,7 +142,7 @@ // Add a mapping from F to the entry and buffer, so we can delete this // info later. - FnMap[F] = std::make_pair(Buffer, JITCodeEntry); + FnMap[F] = std::make_pair(Buffer, JITCodeEntry); // Acquire the lock and do the registration. { From daniel at zuster.org Fri Apr 29 12:53:12 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 17:53:12 -0000 Subject: [llvm-commits] [llvm] r130515 - /llvm/trunk/lib/MC/MCParser/AsmParser.cpp Message-ID: <20110429175312.286152A6C139@llvm.org> Author: ddunbar Date: Fri Apr 29 12:53:11 2011 New Revision: 130515 URL: http://llvm.org/viewvc/llvm-project?rev=130515&view=rev Log: MC/AsmParser: Generalize a check. Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=130515&r1=130514&r2=130515&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Fri Apr 29 12:53:11 2011 @@ -1348,7 +1348,7 @@ // FIXME: Diagnose assignment to protected identifier (e.g., register name). if (Sym->isUndefined() && !Sym->isUsed() && !Sym->isVariable()) ; // Allow redefinitions of undefined symbols only used in directives. - else if (!Sym->isUndefined() && (!Sym->isAbsolute() || !allow_redef)) + else if (!Sym->isUndefined() && (!Sym->isVariable() || !allow_redef)) return Error(EqualLoc, "redefinition of '" + Name + "'"); else if (!Sym->isVariable()) return Error(EqualLoc, "invalid assignment to '" + Name + "'"); From daniel at zuster.org Fri Apr 29 13:00:03 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:00:03 -0000 Subject: [llvm-commits] [llvm] r130517 - in /llvm/trunk: include/llvm/MC/MCExpr.h include/llvm/MC/MCSymbol.h lib/MC/MCExpr.cpp lib/Target/ARM/ARMMCExpr.h Message-ID: <20110429180003.942FA2A6C139@llvm.org> Author: ddunbar Date: Fri Apr 29 13:00:03 2011 New Revision: 130517 URL: http://llvm.org/viewvc/llvm-project?rev=130517&view=rev Log: MCExpr: Add FindAssociatedSection, which attempts to mirror the 'as' semantics that associate sections with expressions. Modified: llvm/trunk/include/llvm/MC/MCExpr.h llvm/trunk/include/llvm/MC/MCSymbol.h llvm/trunk/lib/MC/MCExpr.cpp llvm/trunk/lib/Target/ARM/ARMMCExpr.h Modified: llvm/trunk/include/llvm/MC/MCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=130517&r1=130516&r2=130517&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCExpr.h (original) +++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Apr 29 13:00:03 2011 @@ -19,6 +19,7 @@ class MCAsmLayout; class MCAssembler; class MCContext; +class MCSection; class MCSectionData; class MCSymbol; class MCValue; @@ -92,6 +93,12 @@ /// @result - True on success. bool EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout &Layout) const; + /// FindAssociatedSection - Find the "associated section" for this expression, + /// which is currently defined as the absolute section for constants, or + /// otherwise the section associated with the first defined symbol in the + /// expression. + const MCSection *FindAssociatedSection() const; + /// @} static bool classof(const MCExpr *) { return true; } @@ -420,6 +427,7 @@ virtual bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const = 0; virtual void AddValueSymbols(MCAssembler *) const = 0; + virtual const MCSection *FindAssociatedSection() const = 0; static bool classof(const MCExpr *E) { return E->getKind() == MCExpr::Target; Modified: llvm/trunk/include/llvm/MC/MCSymbol.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=130517&r1=130516&r2=130517&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCSymbol.h (original) +++ llvm/trunk/include/llvm/MC/MCSymbol.h Fri Apr 29 13:00:03 2011 @@ -56,6 +56,7 @@ mutable unsigned IsUsed : 1; private: // MCContext creates and uniques these. + friend class MCExpr; friend class MCContext; MCSymbol(StringRef name, bool isTemporary) : Name(name), Section(0), Value(0), Modified: llvm/trunk/lib/MC/MCExpr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=130517&r1=130516&r2=130517&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCExpr.cpp (original) +++ llvm/trunk/lib/MC/MCExpr.cpp Fri Apr 29 13:00:03 2011 @@ -559,3 +559,45 @@ assert(0 && "Invalid assembly expression kind!"); return false; } + +const MCSection *MCExpr::FindAssociatedSection() const { + switch (getKind()) { + case Target: + // We never look through target specific expressions. + return cast(this)->FindAssociatedSection(); + + case Constant: + return MCSymbol::AbsolutePseudoSection; + + case SymbolRef: { + const MCSymbolRefExpr *SRE = cast(this); + const MCSymbol &Sym = SRE->getSymbol(); + + if (Sym.isDefined()) + return &Sym.getSection(); + + return 0; + } + + case Unary: + return cast(this)->getSubExpr()->FindAssociatedSection(); + + case Binary: { + const MCBinaryExpr *BE = cast(this); + const MCSection *LHS_S = BE->getLHS()->FindAssociatedSection(); + const MCSection *RHS_S = BE->getRHS()->FindAssociatedSection(); + + // If either section is absolute, return the other. + if (LHS_S == MCSymbol::AbsolutePseudoSection) + return RHS_S; + if (RHS_S == MCSymbol::AbsolutePseudoSection) + return LHS_S; + + // Otherwise, return the first non-null section. + return LHS_S ? LHS_S : RHS_S; + } + } + + assert(0 && "Invalid assembly expression kind!"); + return 0; +} Modified: llvm/trunk/lib/Target/ARM/ARMMCExpr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCExpr.h?rev=130517&r1=130516&r2=130517&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCExpr.h (original) +++ llvm/trunk/lib/Target/ARM/ARMMCExpr.h Fri Apr 29 13:00:03 2011 @@ -60,6 +60,9 @@ bool EvaluateAsRelocatableImpl(MCValue &Res, const MCAsmLayout *Layout) const; void AddValueSymbols(MCAssembler *) const; + const MCSection *FindAssociatedSection() const { + return getSubExpr()->FindAssociatedSection(); + } static bool classof(const MCExpr *E) { return E->getKind() == MCExpr::Target; From dpatel at apple.com Fri Apr 29 13:00:54 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 18:00:54 -0000 Subject: [llvm-commits] [llvm] r130518 - in /llvm/trunk/lib: CodeGen/AsmPrinter/AsmPrinter.cpp MC/MCAsmStreamer.cpp Message-ID: <20110429180054.F0F8A2A6C139@llvm.org> Author: dpatel Date: Fri Apr 29 13:00:54 2011 New Revision: 130518 URL: http://llvm.org/viewvc/llvm-project?rev=130518&view=rev Log: Hoist MCLineEntry construction AsmPrinter so that anyone who derives from AsmPrinter can have line number entries. PR 9810 Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=130518&r1=130517&r2=130518&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Fri Apr 29 13:00:54 2011 @@ -691,6 +691,9 @@ if (isVerbose()) EmitKill(II, *this); break; default: + if (!TM.hasMCUseLoc()) + MCLineEntry::Make(&OutStreamer, getCurrentSection()); + EmitInstruction(II); break; } Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130518&r1=130517&r2=130518&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Apr 29 13:00:54 2011 @@ -957,9 +957,6 @@ void MCAsmStreamer::EmitInstruction(const MCInst &Inst) { assert(getCurrentSection() && "Cannot emit contents before setting section!"); - if (!UseLoc) - MCLineEntry::Make(this, getCurrentSection()); - // Show the encoding in a comment if we have a code emitter. if (Emitter) AddEncodingComment(Inst); From daniel at zuster.org Fri Apr 29 13:07:44 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:07:44 -0000 Subject: [llvm-commits] [llvm] r130519 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20110429180744.179E42A6C139@llvm.org> Author: ddunbar Date: Fri Apr 29 13:07:43 2011 New Revision: 130519 URL: http://llvm.org/viewvc/llvm-project?rev=130519&view=rev Log: MC/Mach-O: Find section ordinal's by looking at the symbol, instead of assuming they are present in a fragment. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=130519&r1=130518&r2=130519&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri Apr 29 13:07:43 2011 @@ -1050,8 +1050,10 @@ FixedValue -= Layout.getSymbolOffset(SD); } else { // The index is the section ordinal (1-based). - Index = SD->getFragment()->getParent()->getOrdinal() + 1; - FixedValue += getSectionAddress(SD->getFragment()->getParent()); + const MCSectionData &SymSD = Asm.getSectionData( + SD->getSymbol().getSection()); + Index = SymSD.getOrdinal() + 1; + FixedValue += getSectionAddress(&SymSD); } if (IsPCRel) FixedValue -= getSectionAddress(Fragment->getParent()); @@ -1149,8 +1151,10 @@ FixedValue -= Layout.getSymbolOffset(SD); } else { // The index is the section ordinal (1-based). - Index = SD->getFragment()->getParent()->getOrdinal() + 1; - FixedValue += getSectionAddress(SD->getFragment()->getParent()); + const MCSectionData &SymSD = Asm.getSectionData( + SD->getSymbol().getSection()); + Index = SymSD.getOrdinal() + 1; + FixedValue += getSectionAddress(&SymSD); } if (IsPCRel) FixedValue -= getSectionAddress(Fragment->getParent()); From daniel at zuster.org Fri Apr 29 13:10:47 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:10:47 -0000 Subject: [llvm-commits] [llvm] r130520 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20110429181047.604722A6C139@llvm.org> Author: ddunbar Date: Fri Apr 29 13:10:47 2011 New Revision: 130520 URL: http://llvm.org/viewvc/llvm-project?rev=130520&view=rev Log: MC/Mach-O: Allow emission of relocations for variables in some more cases. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=130520&r1=130519&r2=130520&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri Apr 29 13:10:47 2011 @@ -550,7 +550,7 @@ // Add the local offset, if needed. if (Base != &SD) Value += Layout.getSymbolOffset(&SD) - Layout.getSymbolOffset(Base); - } else if (Symbol->isInSection()) { + } else if (Symbol->isInSection() && !Symbol->isVariable()) { // The index is the section ordinal (1-based). Index = SD.getFragment()->getParent()->getOrdinal() + 1; IsExtern = 0; @@ -1028,17 +1028,17 @@ // FIXME! report_fatal_error("FIXME: relocations to absolute targets " "not yet implemented"); - } else if (SD->getSymbol().isVariable()) { - int64_t Res; - if (SD->getSymbol().getVariableValue()->EvaluateAsAbsolute( - Res, Layout, SectionAddress)) { - FixedValue = Res; - return; + } else { + // Resolve constant variables. + if (SD->getSymbol().isVariable()) { + int64_t Res; + if (SD->getSymbol().getVariableValue()->EvaluateAsAbsolute( + Res, Layout, SectionAddress)) { + FixedValue = Res; + return; + } } - report_fatal_error("unsupported relocation of variable '" + - SD->getSymbol().getName() + "'"); - } else { // Check whether we need an external or internal relocation. if (doesSymbolRequireExternRelocation(SD)) { IsExtern = 1; @@ -1129,17 +1129,17 @@ // FIXME: Currently, these are never generated (see code below). I cannot // find a case where they are actually emitted. Type = macho::RIT_Vanilla; - } else if (SD->getSymbol().isVariable()) { - int64_t Res; - if (SD->getSymbol().getVariableValue()->EvaluateAsAbsolute( - Res, Layout, SectionAddress)) { - FixedValue = Res; - return; + } else { + // Resolve constant variables. + if (SD->getSymbol().isVariable()) { + int64_t Res; + if (SD->getSymbol().getVariableValue()->EvaluateAsAbsolute( + Res, Layout, SectionAddress)) { + FixedValue = Res; + return; + } } - report_fatal_error("unsupported relocation of variable '" + - SD->getSymbol().getName() + "'"); - } else { // Check whether we need an external or internal relocation. if (doesSymbolRequireExternRelocation(SD)) { IsExtern = 1; From daniel at zuster.org Fri Apr 29 13:13:42 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:13:42 -0000 Subject: [llvm-commits] [llvm] r130522 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20110429181342.BBE0E2A6C139@llvm.org> Author: ddunbar Date: Fri Apr 29 13:13:42 2011 New Revision: 130522 URL: http://llvm.org/viewvc/llvm-project?rev=130522&view=rev Log: MC/Mach-O: Update getSymbolAddress() to support evaluation of variables. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=130522&r1=130521&r2=130522&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri Apr 29 13:13:42 2011 @@ -121,6 +121,33 @@ } uint64_t getSymbolAddress(const MCSymbolData* SD, const MCAsmLayout &Layout) const { + const MCSymbol &S = SD->getSymbol(); + + // If this is a variable, then recursively evaluate now. + if (S.isVariable()) { + MCValue Target; + if (!S.getVariableValue()->EvaluateAsRelocatable(Target, Layout)) + report_fatal_error("unable to evaluate offset for variable '" + + S.getName() + "'"); + + // Verify that any used symbols are defined. + if (Target.getSymA() && Target.getSymA()->getSymbol().isUndefined()) + report_fatal_error("unable to evaluate offset to undefined symbol '" + + Target.getSymA()->getSymbol().getName() + "'"); + if (Target.getSymB() && Target.getSymB()->getSymbol().isUndefined()) + report_fatal_error("unable to evaluate offset to undefined symbol '" + + Target.getSymB()->getSymbol().getName() + "'"); + + uint64_t Address = Target.getConstant(); + if (Target.getSymA()) + Address += getSymbolAddress(&Layout.getAssembler().getSymbolData( + Target.getSymA()->getSymbol()), Layout); + if (Target.getSymB()) + Address += getSymbolAddress(&Layout.getAssembler().getSymbolData( + Target.getSymB()->getSymbol()), Layout); + return Address; + } + return getSectionAddress(SD->getFragment()->getParent()) + Layout.getSymbolOffset(SD); } From daniel at zuster.org Fri Apr 29 13:20:17 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:20:17 -0000 Subject: [llvm-commits] [llvm] r130523 - in /llvm/trunk: lib/MC/MCSymbol.cpp test/MC/MachO/variable-exprs.s Message-ID: <20110429182017.AF5602A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 13:20:17 2011 New Revision: 130523 URL: http://llvm.org/viewvc/llvm-project?rev=130523&view=rev Log: MC: Change variable symbols to be recognized as defined, by assigning their sections based on FindAssociatedSection(). Added: llvm/trunk/test/MC/MachO/variable-exprs.s Modified: llvm/trunk/lib/MC/MCSymbol.cpp Modified: llvm/trunk/lib/MC/MCSymbol.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=130523&r1=130522&r2=130523&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCSymbol.cpp (original) +++ llvm/trunk/lib/MC/MCSymbol.cpp Fri Apr 29 13:20:17 2011 @@ -58,9 +58,13 @@ "Invalid redefinition!"); this->Value = Value; - // Mark the variable as absolute as appropriate. - if (isa(Value)) - setAbsolute(); + // Variables should always be marked as in the same "section" as the value. + const MCSection *Section = Value->FindAssociatedSection(); + if (Section) { + setSection(*Section); + } else { + setUndefined(); + } } void MCSymbol::print(raw_ostream &OS) const { Added: llvm/trunk/test/MC/MachO/variable-exprs.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/variable-exprs.s?rev=130523&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/variable-exprs.s (added) +++ llvm/trunk/test/MC/MachO/variable-exprs.s Fri Apr 29 13:20:17 2011 @@ -0,0 +1,446 @@ +// RUN: llvm-mc -triple i386-apple-darwin10 %s -filetype=obj -o %t.o +// RUN: macho-dump --dump-section-data < %t.o > %t.dump +// RUN: FileCheck --check-prefix=CHECK-I386 < %t.dump %s + +// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o %t.o +// RUN: macho-dump --dump-section-data < %t.o > %t.dump +// RUN: FileCheck --check-prefix=CHECK-X86_64 < %t.dump %s + +.data + + .long 0 +a: + .long 0 +b = a + +c: .long b + +d2 = d +.globl d2 +d3 = d + 4 +.globl d3 + +e = a + 4 + +g: +f = g + .long 0 + + .long b + .long e + .long a + 4 + .long d + .long d2 + .long d3 + .long f + .long g + +/// + .text +t0: +Lt0_a: + ret + + .data +Lt0_b: +Lt0_x = Lt0_a - Lt0_b + .quad Lt0_x + +// CHECK-I386: ('cputype', 7) +// CHECK-I386: ('cpusubtype', 3) +// CHECK-I386: ('filetype', 1) +// CHECK-I386: ('num_load_commands', 3) +// CHECK-I386: ('load_commands_size', 296) +// CHECK-I386: ('flag', 0) +// CHECK-I386: ('load_commands', [ +// CHECK-I386: # Load Command 0 +// CHECK-I386: (('command', 1) +// CHECK-I386: ('size', 192) +// CHECK-I386: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-I386: ('vm_addr', 0) +// CHECK-I386: ('vm_size', 57) +// CHECK-I386: ('file_offset', 324) +// CHECK-I386: ('file_size', 57) +// CHECK-I386: ('maxprot', 7) +// CHECK-I386: ('initprot', 7) +// CHECK-I386: ('num_sections', 2) +// CHECK-I386: ('flags', 0) +// CHECK-I386: ('sections', [ +// CHECK-I386: # Section 0 +// CHECK-I386: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-I386: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-I386: ('address', 0) +// CHECK-I386: ('size', 1) +// CHECK-I386: ('offset', 324) +// CHECK-I386: ('alignment', 0) +// CHECK-I386: ('reloc_offset', 0) +// CHECK-I386: ('num_reloc', 0) +// CHECK-I386: ('flags', 0x80000400) +// CHECK-I386: ('reserved1', 0) +// CHECK-I386: ('reserved2', 0) +// CHECK-I386: ), +// CHECK-I386: ('_relocations', [ +// CHECK-I386: ]) +// CHECK-I386: ('_section_data', 'c3') +// CHECK-I386: # Section 1 +// CHECK-I386: (('section_name', '__data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-I386: ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-I386: ('address', 1) +// CHECK-I386: ('size', 56) +// CHECK-I386: ('offset', 325) +// CHECK-I386: ('alignment', 0) +// CHECK-I386: ('reloc_offset', 384) +// CHECK-I386: ('num_reloc', 9) +// CHECK-I386: ('flags', 0x0) +// CHECK-I386: ('reserved1', 0) +// CHECK-I386: ('reserved2', 0) +// CHECK-I386: ), +// CHECK-I386: ('_relocations', [ +// CHECK-I386: # Relocation 0 +// CHECK-I386: (('word-0', 0x2c), +// CHECK-I386: ('word-1', 0x4000002)), +// CHECK-I386: # Relocation 1 +// CHECK-I386: (('word-0', 0x28), +// CHECK-I386: ('word-1', 0x4000002)), +// CHECK-I386: # Relocation 2 +// CHECK-I386: (('word-0', 0x24), +// CHECK-I386: ('word-1', 0xc000009)), +// CHECK-I386: # Relocation 3 +// CHECK-I386: (('word-0', 0x20), +// CHECK-I386: ('word-1', 0xc000008)), +// CHECK-I386: # Relocation 4 +// CHECK-I386: (('word-0', 0x1c), +// CHECK-I386: ('word-1', 0xc000007)), +// CHECK-I386: # Relocation 5 +// CHECK-I386: (('word-0', 0xa0000018), +// CHECK-I386: ('word-1', 0x5)), +// CHECK-I386: # Relocation 6 +// CHECK-I386: (('word-0', 0x14), +// CHECK-I386: ('word-1', 0x4000002)), +// CHECK-I386: # Relocation 7 +// CHECK-I386: (('word-0', 0x10), +// CHECK-I386: ('word-1', 0x4000002)), +// CHECK-I386: # Relocation 8 +// CHECK-I386: (('word-0', 0x8), +// CHECK-I386: ('word-1', 0x4000002)), +// CHECK-I386: ]) +// CHECK-I386: ('_section_data', '00000000 00000000 05000000 00000000 05000000 09000000 09000000 00000000 00000000 00000000 0d000000 0d000000 cfffffff ffffffff') +// CHECK-I386: ]) +// CHECK-I386: ), +// CHECK-I386: # Load Command 1 +// CHECK-I386: (('command', 2) +// CHECK-I386: ('size', 24) +// CHECK-I386: ('symoff', 456) +// CHECK-I386: ('nsyms', 10) +// CHECK-I386: ('stroff', 576) +// CHECK-I386: ('strsize', 24) +// CHECK-I386: ('_string_data', '\x00d2\x00d\x00d3\x00a\x00b\x00c\x00e\x00g\x00f\x00t0\x00') +// CHECK-I386: ('_symbols', [ +// CHECK-I386: # Symbol 0 +// CHECK-I386: (('n_strx', 9) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 5) +// CHECK-I386: ('_string', 'a') +// CHECK-I386: ), +// CHECK-I386: # Symbol 1 +// CHECK-I386: (('n_strx', 11) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 5) +// CHECK-I386: ('_string', 'b') +// CHECK-I386: ), +// CHECK-I386: # Symbol 2 +// CHECK-I386: (('n_strx', 13) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 9) +// CHECK-I386: ('_string', 'c') +// CHECK-I386: ), +// CHECK-I386: # Symbol 3 +// CHECK-I386: (('n_strx', 15) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 9) +// CHECK-I386: ('_string', 'e') +// CHECK-I386: ), +// CHECK-I386: # Symbol 4 +// CHECK-I386: (('n_strx', 17) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 13) +// CHECK-I386: ('_string', 'g') +// CHECK-I386: ), +// CHECK-I386: # Symbol 5 +// CHECK-I386: (('n_strx', 19) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 2) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 13) +// CHECK-I386: ('_string', 'f') +// CHECK-I386: ), +// CHECK-I386: # Symbol 6 +// CHECK-I386: (('n_strx', 21) +// CHECK-I386: ('n_type', 0xe) +// CHECK-I386: ('n_sect', 1) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 0) +// CHECK-I386: ('_string', 't0') +// CHECK-I386: ), +// CHECK-I386: # Symbol 7 +// CHECK-I386: (('n_strx', 4) +// CHECK-I386: ('n_type', 0x1) +// CHECK-I386: ('n_sect', 0) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 0) +// CHECK-I386: ('_string', 'd') +// CHECK-I386: ), +// CHECK-I386: # Symbol 8 +// CHECK-I386: (('n_strx', 1) +// CHECK-I386: ('n_type', 0x1) +// CHECK-I386: ('n_sect', 0) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 0) +// CHECK-I386: ('_string', 'd2') +// CHECK-I386: ), +// CHECK-I386: # Symbol 9 +// CHECK-I386: (('n_strx', 6) +// CHECK-I386: ('n_type', 0x1) +// CHECK-I386: ('n_sect', 0) +// CHECK-I386: ('n_desc', 0) +// CHECK-I386: ('n_value', 0) +// CHECK-I386: ('_string', 'd3') +// CHECK-I386: ), +// CHECK-I386: ]) +// CHECK-I386: ), +// CHECK-I386: # Load Command 2 +// CHECK-I386: (('command', 11) +// CHECK-I386: ('size', 80) +// CHECK-I386: ('ilocalsym', 0) +// CHECK-I386: ('nlocalsym', 7) +// CHECK-I386: ('iextdefsym', 7) +// CHECK-I386: ('nextdefsym', 0) +// CHECK-I386: ('iundefsym', 7) +// CHECK-I386: ('nundefsym', 3) +// CHECK-I386: ('tocoff', 0) +// CHECK-I386: ('ntoc', 0) +// CHECK-I386: ('modtaboff', 0) +// CHECK-I386: ('nmodtab', 0) +// CHECK-I386: ('extrefsymoff', 0) +// CHECK-I386: ('nextrefsyms', 0) +// CHECK-I386: ('indirectsymoff', 0) +// CHECK-I386: ('nindirectsyms', 0) +// CHECK-I386: ('extreloff', 0) +// CHECK-I386: ('nextrel', 0) +// CHECK-I386: ('locreloff', 0) +// CHECK-I386: ('nlocrel', 0) +// CHECK-I386: ('_indirect_symbols', [ +// CHECK-I386: ]) +// CHECK-I386: ), +// CHECK-I386: ]) + +// CHECK-X86_64: ('cputype', 16777223) +// CHECK-X86_64: ('cpusubtype', 3) +// CHECK-X86_64: ('filetype', 1) +// CHECK-X86_64: ('num_load_commands', 3) +// CHECK-X86_64: ('load_commands_size', 336) +// CHECK-X86_64: ('flag', 0) +// CHECK-X86_64: ('reserved', 0) +// CHECK-X86_64: ('load_commands', [ +// CHECK-X86_64: # Load Command 0 +// CHECK-X86_64: (('command', 25) +// CHECK-X86_64: ('size', 232) +// CHECK-X86_64: ('segment_name', '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-X86_64: ('vm_addr', 0) +// CHECK-X86_64: ('vm_size', 57) +// CHECK-X86_64: ('file_offset', 368) +// CHECK-X86_64: ('file_size', 57) +// CHECK-X86_64: ('maxprot', 7) +// CHECK-X86_64: ('initprot', 7) +// CHECK-X86_64: ('num_sections', 2) +// CHECK-X86_64: ('flags', 0) +// CHECK-X86_64: ('sections', [ +// CHECK-X86_64: # Section 0 +// CHECK-X86_64: (('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-X86_64: ('segment_name', '__TEXT\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-X86_64: ('address', 0) +// CHECK-X86_64: ('size', 1) +// CHECK-X86_64: ('offset', 368) +// CHECK-X86_64: ('alignment', 0) +// CHECK-X86_64: ('reloc_offset', 0) +// CHECK-X86_64: ('num_reloc', 0) +// CHECK-X86_64: ('flags', 0x80000400) +// CHECK-X86_64: ('reserved1', 0) +// CHECK-X86_64: ('reserved2', 0) +// CHECK-X86_64: ('reserved3', 0) +// CHECK-X86_64: ), +// CHECK-X86_64: ('_relocations', [ +// CHECK-X86_64: ]) +// CHECK-X86_64: ('_section_data', 'c3') +// CHECK-X86_64: # Section 1 +// CHECK-X86_64: (('section_name', '__data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-X86_64: ('segment_name', '__DATA\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') +// CHECK-X86_64: ('address', 1) +// CHECK-X86_64: ('size', 56) +// CHECK-X86_64: ('offset', 369) +// CHECK-X86_64: ('alignment', 0) +// CHECK-X86_64: ('reloc_offset', 428) +// CHECK-X86_64: ('num_reloc', 9) +// CHECK-X86_64: ('flags', 0x0) +// CHECK-X86_64: ('reserved1', 0) +// CHECK-X86_64: ('reserved2', 0) +// CHECK-X86_64: ('reserved3', 0) +// CHECK-X86_64: ), +// CHECK-X86_64: ('_relocations', [ +// CHECK-X86_64: # Relocation 0 +// CHECK-X86_64: (('word-0', 0x2c), +// CHECK-X86_64: ('word-1', 0xc000004)), +// CHECK-X86_64: # Relocation 1 +// CHECK-X86_64: (('word-0', 0x28), +// CHECK-X86_64: ('word-1', 0xc000005)), +// CHECK-X86_64: # Relocation 2 +// CHECK-X86_64: (('word-0', 0x24), +// CHECK-X86_64: ('word-1', 0xc000009)), +// CHECK-X86_64: # Relocation 3 +// CHECK-X86_64: (('word-0', 0x20), +// CHECK-X86_64: ('word-1', 0xc000008)), +// CHECK-X86_64: # Relocation 4 +// CHECK-X86_64: (('word-0', 0x1c), +// CHECK-X86_64: ('word-1', 0xc000007)), +// CHECK-X86_64: # Relocation 5 +// CHECK-X86_64: (('word-0', 0x18), +// CHECK-X86_64: ('word-1', 0xc000000)), +// CHECK-X86_64: # Relocation 6 +// CHECK-X86_64: (('word-0', 0x14), +// CHECK-X86_64: ('word-1', 0xc000003)), +// CHECK-X86_64: # Relocation 7 +// CHECK-X86_64: (('word-0', 0x10), +// CHECK-X86_64: ('word-1', 0xc000001)), +// CHECK-X86_64: # Relocation 8 +// CHECK-X86_64: (('word-0', 0x8), +// CHECK-X86_64: ('word-1', 0xc000001)), +// CHECK-X86_64: ]) +// CHECK-X86_64: ('_section_data', '00000000 00000000 00000000 00000000 00000000 00000000 04000000 00000000 00000000 00000000 00000000 00000000 cfffffff ffffffff') +// CHECK-X86_64: ]) +// CHECK-X86_64: ), +// CHECK-X86_64: # Load Command 1 +// CHECK-X86_64: (('command', 2) +// CHECK-X86_64: ('size', 24) +// CHECK-X86_64: ('symoff', 500) +// CHECK-X86_64: ('nsyms', 10) +// CHECK-X86_64: ('stroff', 660) +// CHECK-X86_64: ('strsize', 24) +// CHECK-X86_64: ('_string_data', '\x00d2\x00d\x00d3\x00a\x00b\x00c\x00e\x00g\x00f\x00t0\x00') +// CHECK-X86_64: ('_symbols', [ +// CHECK-X86_64: # Symbol 0 +// CHECK-X86_64: (('n_strx', 9) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 5) +// CHECK-X86_64: ('_string', 'a') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 1 +// CHECK-X86_64: (('n_strx', 11) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 5) +// CHECK-X86_64: ('_string', 'b') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 2 +// CHECK-X86_64: (('n_strx', 13) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 9) +// CHECK-X86_64: ('_string', 'c') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 3 +// CHECK-X86_64: (('n_strx', 15) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 9) +// CHECK-X86_64: ('_string', 'e') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 4 +// CHECK-X86_64: (('n_strx', 17) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 13) +// CHECK-X86_64: ('_string', 'g') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 5 +// CHECK-X86_64: (('n_strx', 19) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 2) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 13) +// CHECK-X86_64: ('_string', 'f') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 6 +// CHECK-X86_64: (('n_strx', 21) +// CHECK-X86_64: ('n_type', 0xe) +// CHECK-X86_64: ('n_sect', 1) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 0) +// CHECK-X86_64: ('_string', 't0') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 7 +// CHECK-X86_64: (('n_strx', 4) +// CHECK-X86_64: ('n_type', 0x1) +// CHECK-X86_64: ('n_sect', 0) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 0) +// CHECK-X86_64: ('_string', 'd') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 8 +// CHECK-X86_64: (('n_strx', 1) +// CHECK-X86_64: ('n_type', 0x1) +// CHECK-X86_64: ('n_sect', 0) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 0) +// CHECK-X86_64: ('_string', 'd2') +// CHECK-X86_64: ), +// CHECK-X86_64: # Symbol 9 +// CHECK-X86_64: (('n_strx', 6) +// CHECK-X86_64: ('n_type', 0x1) +// CHECK-X86_64: ('n_sect', 0) +// CHECK-X86_64: ('n_desc', 0) +// CHECK-X86_64: ('n_value', 0) +// CHECK-X86_64: ('_string', 'd3') +// CHECK-X86_64: ), +// CHECK-X86_64: ]) +// CHECK-X86_64: ), +// CHECK-X86_64: # Load Command 2 +// CHECK-X86_64: (('command', 11) +// CHECK-X86_64: ('size', 80) +// CHECK-X86_64: ('ilocalsym', 0) +// CHECK-X86_64: ('nlocalsym', 7) +// CHECK-X86_64: ('iextdefsym', 7) +// CHECK-X86_64: ('nextdefsym', 0) +// CHECK-X86_64: ('iundefsym', 7) +// CHECK-X86_64: ('nundefsym', 3) +// CHECK-X86_64: ('tocoff', 0) +// CHECK-X86_64: ('ntoc', 0) +// CHECK-X86_64: ('modtaboff', 0) +// CHECK-X86_64: ('nmodtab', 0) +// CHECK-X86_64: ('extrefsymoff', 0) +// CHECK-X86_64: ('nextrefsyms', 0) +// CHECK-X86_64: ('indirectsymoff', 0) +// CHECK-X86_64: ('nindirectsyms', 0) +// CHECK-X86_64: ('extreloff', 0) +// CHECK-X86_64: ('nextrel', 0) +// CHECK-X86_64: ('locreloff', 0) +// CHECK-X86_64: ('nlocrel', 0) +// CHECK-X86_64: ('_indirect_symbols', [ +// CHECK-X86_64: ]) +// CHECK-X86_64: ), +// CHECK-X86_64: ]) From daniel at zuster.org Fri Apr 29 13:20:21 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:20:21 -0000 Subject: [llvm-commits] [llvm] r130524 - in /llvm/trunk: lib/MC/MCAssembler.cpp test/MC/MachO/variable-errors.s Message-ID: <20110429182021.1FF702A6C138@llvm.org> Author: ddunbar Date: Fri Apr 29 13:20:20 2011 New Revision: 130524 URL: http://llvm.org/viewvc/llvm-project?rev=130524&view=rev Log: MCAsmLayout: Add support for computing the symbol offset of variables. Not currently used, because variables don't get reported as being "defined". Added: llvm/trunk/test/MC/MachO/variable-errors.s Modified: llvm/trunk/lib/MC/MCAssembler.cpp Modified: llvm/trunk/lib/MC/MCAssembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=130524&r1=130523&r2=130524&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAssembler.cpp (original) +++ llvm/trunk/lib/MC/MCAssembler.cpp Fri Apr 29 13:20:20 2011 @@ -102,6 +102,33 @@ } uint64_t MCAsmLayout::getSymbolOffset(const MCSymbolData *SD) const { + const MCSymbol &S = SD->getSymbol(); + + // If this is a variable, then recursively evaluate now. + if (S.isVariable()) { + MCValue Target; + if (!S.getVariableValue()->EvaluateAsRelocatable(Target, *this)) + report_fatal_error("unable to evaluate offset for variable '" + + S.getName() + "'"); + + // Verify that any used symbols are defined. + if (Target.getSymA() && Target.getSymA()->getSymbol().isUndefined()) + report_fatal_error("unable to evaluate offset to undefined symbol '" + + Target.getSymA()->getSymbol().getName() + "'"); + if (Target.getSymB() && Target.getSymB()->getSymbol().isUndefined()) + report_fatal_error("unable to evaluate offset to undefined symbol '" + + Target.getSymB()->getSymbol().getName() + "'"); + + uint64_t Offset = Target.getConstant(); + if (Target.getSymA()) + Offset += getSymbolOffset(&Assembler.getSymbolData( + Target.getSymA()->getSymbol())); + if (Target.getSymB()) + Offset -= getSymbolOffset(&Assembler.getSymbolData( + Target.getSymB()->getSymbol())); + return Offset; + } + assert(SD->getFragment() && "Invalid getOffset() on undefined symbol!"); return getFragmentOffset(SD->getFragment()) + SD->getOffset(); } Added: llvm/trunk/test/MC/MachO/variable-errors.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/variable-errors.s?rev=130524&view=auto ============================================================================== --- llvm/trunk/test/MC/MachO/variable-errors.s (added) +++ llvm/trunk/test/MC/MachO/variable-errors.s Fri Apr 29 13:20:20 2011 @@ -0,0 +1,8 @@ +// RUN: not llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o %t.o 2> %t.err +// RUN: FileCheck < %t.err %s + + .data +t0_a: +t0_x = t0_a - t0_b +// CHECK: unable to evaluate offset to undefined symbol 't0_b' + .long t0_x From peter at pcc.me.uk Fri Apr 29 13:47:26 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 29 Apr 2011 18:47:26 -0000 Subject: [llvm-commits] [llvm] r130526 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/PhiEliminate2.ll Message-ID: <20110429184726.2C0292A6C135@llvm.org> Author: pcc Date: Fri Apr 29 13:47:25 2011 New Revision: 130526 URL: http://llvm.org/viewvc/llvm-project?rev=130526&view=rev Log: SimplifyCFG: Add Trunc, ZExt and SExt to the list of cheap instructions for phi node folding Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate2.ll Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=130526&r1=130525&r2=130526&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Apr 29 13:47:25 2011 @@ -261,6 +261,9 @@ case Instruction::LShr: case Instruction::AShr: case Instruction::ICmp: + case Instruction::Trunc: + case Instruction::ZExt: + case Instruction::SExt: break; // These are all cheap and non-trapping instructions. } Modified: llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate2.ll?rev=130526&r1=130525&r2=130526&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate2.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate2.ll Fri Apr 29 13:47:25 2011 @@ -1,14 +1,17 @@ ; RUN: opt < %s -simplifycfg -S | not grep br -define i32 @test(i1 %C, i32 %V1, i32 %V2) { +define i32 @test(i1 %C, i32 %V1, i32 %V2, i16 %V3) { entry: - br i1 %C, label %then, label %Cont + br i1 %C, label %then, label %else then: ; preds = %entry - %V3 = or i32 %V2, %V1 ; [#uses=1] + %V4 = or i32 %V2, %V1 ; [#uses=1] br label %Cont -Cont: ; preds = %then, %entry - %V4 = phi i32 [ %V1, %entry ], [ %V3, %then ] ; [#uses=0] - call i32 @test( i1 false, i32 0, i32 0 ) ; :0 [#uses=0] +else: ; preds = %entry + %V5 = sext i16 %V3 to i32 ; [#uses=1] + br label %Cont +Cont: ; preds = %then, %else + %V6 = phi i32 [ %V5, %else ], [ %V4, %then ] ; [#uses=0] + call i32 @test( i1 false, i32 0, i32 0, i16 0 ) ; :0 [#uses=0] ret i32 %V1 } From peter at pcc.me.uk Fri Apr 29 13:47:32 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 29 Apr 2011 18:47:32 -0000 Subject: [llvm-commits] [llvm] r130527 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/PhiBlockMerge.ll Message-ID: <20110429184732.1670C2A6C138@llvm.org> Author: pcc Date: Fri Apr 29 13:47:31 2011 New Revision: 130527 URL: http://llvm.org/viewvc/llvm-project?rev=130527&view=rev Log: SimplifyCFG: Add CostRemaining parameter to DominatesMergePoint Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/test/Transforms/SimplifyCFG/PhiBlockMerge.ll Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=130527&r1=130526&r2=130527&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Apr 29 13:47:31 2011 @@ -201,11 +201,20 @@ /// which works well enough for us. /// /// If AggressiveInsts is non-null, and if V does not dominate BB, we check to -/// see if V (which must be an instruction) is cheap to compute and is -/// non-trapping. If both are true, the instruction is inserted into the set -/// and true is returned. +/// see if V (which must be an instruction) and its recursive operands +/// that do not dominate BB have a combined cost lower than CostRemaining and +/// are non-trapping. If both are true, the instruction is inserted into the +/// set and true is returned. +/// +/// The cost for most non-trapping instructions is defined as 1 except for +/// Select whose cost is 2. +/// +/// After this function returns, CostRemaining is decreased by the cost of +/// V plus its non-dominating operands. If that cost is greater than +/// CostRemaining, false is returned and CostRemaining is undefined. static bool DominatesMergePoint(Value *V, BasicBlock *BB, - SmallPtrSet *AggressiveInsts) { + SmallPtrSet *AggressiveInsts, + unsigned &CostRemaining) { Instruction *I = dyn_cast(V); if (!I) { // Non-instructions all dominate instructions, but not all constantexprs @@ -232,12 +241,17 @@ // instructions in the 'if region'. if (AggressiveInsts == 0) return false; + // If we have seen this instruction before, don't count it again. + if (AggressiveInsts->count(I)) return true; + // Okay, it looks like the instruction IS in the "condition". Check to // see if it's a cheap instruction to unconditionally compute, and if it // only uses stuff defined outside of the condition. If so, hoist it out. if (!I->isSafeToSpeculativelyExecute()) return false; + unsigned Cost = 0; + switch (I->getOpcode()) { default: return false; // Cannot hoist this out safely. case Instruction::Load: @@ -246,11 +260,13 @@ // predecessor. if (PBB->getFirstNonPHIOrDbg() != I) return false; + Cost = 1; break; case Instruction::GetElementPtr: // GEPs are cheap if all indices are constant. if (!cast(I)->hasAllConstantIndices()) return false; + Cost = 1; break; case Instruction::Add: case Instruction::Sub: @@ -264,13 +280,23 @@ case Instruction::Trunc: case Instruction::ZExt: case Instruction::SExt: + Cost = 1; break; // These are all cheap and non-trapping instructions. + + case Instruction::Select: + Cost = 2; + break; } - // Okay, we can only really hoist these out if their operands are not - // defined in the conditional region. + if (Cost > CostRemaining) + return false; + + CostRemaining -= Cost; + + // Okay, we can only really hoist these out if their operands do + // not take us over the cost threshold. for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) - if (!DominatesMergePoint(*i, BB, 0)) + if (!DominatesMergePoint(*i, BB, AggressiveInsts, CostRemaining)) return false; // Okay, it's safe to do this! Remember this instruction. AggressiveInsts->insert(I); @@ -1220,6 +1246,7 @@ // instructions. While we are at it, keep track of the instructions // that need to be moved to the dominating block. SmallPtrSet AggressiveInsts; + unsigned MaxCostVal0 = 1, MaxCostVal1 = 1; for (BasicBlock::iterator II = BB->begin(); isa(II);) { PHINode *PN = cast(II++); @@ -1229,8 +1256,10 @@ continue; } - if (!DominatesMergePoint(PN->getIncomingValue(0), BB, &AggressiveInsts) || - !DominatesMergePoint(PN->getIncomingValue(1), BB, &AggressiveInsts)) + if (!DominatesMergePoint(PN->getIncomingValue(0), BB, &AggressiveInsts, + MaxCostVal0) || + !DominatesMergePoint(PN->getIncomingValue(1), BB, &AggressiveInsts, + MaxCostVal1)) return false; } Modified: llvm/trunk/test/Transforms/SimplifyCFG/PhiBlockMerge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/PhiBlockMerge.ll?rev=130527&r1=130526&r2=130527&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/PhiBlockMerge.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/PhiBlockMerge.ll Fri Apr 29 13:47:31 2011 @@ -6,6 +6,7 @@ define i32 @test(i1 %a, i1 %b) { ; CHECK: br i1 %a br i1 %a, label %M, label %O +; CHECK: O: O: ; preds = %0 ; CHECK: select i1 %b, i32 0, i32 1 ; CHECK-NOT: phi From peter at pcc.me.uk Fri Apr 29 13:47:38 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Fri, 29 Apr 2011 18:47:38 -0000 Subject: [llvm-commits] [llvm] r130528 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/PhiEliminate3.ll Message-ID: <20110429184738.7D4302A6C135@llvm.org> Author: pcc Date: Fri Apr 29 13:47:38 2011 New Revision: 130528 URL: http://llvm.org/viewvc/llvm-project?rev=130528&view=rev Log: SimplifyCFG: Expose phi node folding cost threshold as command line parameter Added: llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=130528&r1=130527&r2=130528&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Apr 29 13:47:38 2011 @@ -37,6 +37,10 @@ #include using namespace llvm; +static cl::opt +PHINodeFoldingThreshold("phi-node-folding-threshold", cl::Hidden, cl::init(1), + cl::desc("Control the amount of phi node folding to perform (default = 1)")); + static cl::opt DupRet("simplifycfg-dup-ret", cl::Hidden, cl::init(false), cl::desc("Duplicate return instructions into unconditional branches")); @@ -1246,7 +1250,8 @@ // instructions. While we are at it, keep track of the instructions // that need to be moved to the dominating block. SmallPtrSet AggressiveInsts; - unsigned MaxCostVal0 = 1, MaxCostVal1 = 1; + unsigned MaxCostVal0 = PHINodeFoldingThreshold, + MaxCostVal1 = PHINodeFoldingThreshold; for (BasicBlock::iterator II = BB->begin(); isa(II);) { PHINode *PN = cast(II++); Added: llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll?rev=130528&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll Fri Apr 29 13:47:38 2011 @@ -0,0 +1,34 @@ +; Test merging of blocks containing complex expressions, +; with various folding thresholds +; +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | grep N: +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | not grep N: +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | grep M: +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | not grep M: +; + +define i32 @test(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) { +entry: + br i1 %a, label %M, label %O +O: + br i1 %b, label %P, label %Q +P: + %iaj = add i32 %i, %j + %iajak = add i32 %iaj, %k + br label %N +Q: + %ixj = xor i32 %i, %j + %ixjxk = xor i32 %ixj, %k + br label %N +N: + ; This phi should be foldable if threshold >= 2 + %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ] + %Wp2 = add i32 %Wp, %Wp + br label %M +M: + ; This phi should be foldable if threshold >= 7 + %W = phi i32 [ %Wp2, %N ], [ 2, %entry ] + %R = add i32 %W, 1 + ret i32 %R +} + From daniel at zuster.org Fri Apr 29 13:58:55 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:58:55 -0000 Subject: [llvm-commits] [llvm] r130529 - /llvm/trunk/runtime/libprofile/PathProfiling.c Message-ID: <20110429185855.4E2442A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 13:58:55 2011 New Revision: 130529 URL: http://llvm.org/viewvc/llvm-project?rev=130529&view=rev Log: Cleanup some DOS newlines. Modified: llvm/trunk/runtime/libprofile/PathProfiling.c Modified: llvm/trunk/runtime/libprofile/PathProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/PathProfiling.c?rev=130529&r1=130528&r2=130529&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/PathProfiling.c (original) +++ llvm/trunk/runtime/libprofile/PathProfiling.c Fri Apr 29 13:58:55 2011 @@ -16,20 +16,20 @@ #include "Profiling.h" #include "llvm/Analysis/ProfileInfoTypes.h" #include -#if !defined(_MSC_VER) && !defined(__MINGW32__) -#include -#else -#include -#endif +#if !defined(_MSC_VER) && !defined(__MINGW32__) +#include +#else +#include +#endif #include #include #include #include // Must use __inline in Microsoft C -#if defined(_MSC_VER) -#define inline __inline -#endif +#if defined(_MSC_VER) +#define inline __inline +#endif /* note that this is used for functions with large path counts, but it is unlikely those paths will ALL be executed */ From daniel at zuster.org Fri Apr 29 13:58:58 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 29 Apr 2011 18:58:58 -0000 Subject: [llvm-commits] [llvm] r130530 - /llvm/trunk/runtime/libprofile/PathProfiling.c Message-ID: <20110429185858.295AE2A6C138@llvm.org> Author: ddunbar Date: Fri Apr 29 13:58:57 2011 New Revision: 130530 URL: http://llvm.org/viewvc/llvm-project?rev=130530&view=rev Log: win32: Include DataTypes.h instead of stdint.h to try and fix a Win32 build issue. Modified: llvm/trunk/runtime/libprofile/PathProfiling.c Modified: llvm/trunk/runtime/libprofile/PathProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/PathProfiling.c?rev=130530&r1=130529&r2=130530&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/PathProfiling.c (original) +++ llvm/trunk/runtime/libprofile/PathProfiling.c Fri Apr 29 13:58:57 2011 @@ -15,6 +15,7 @@ #include "Profiling.h" #include "llvm/Analysis/ProfileInfoTypes.h" +#include "llvm/Support/DataTypes.h" #include #if !defined(_MSC_VER) && !defined(__MINGW32__) #include @@ -23,7 +24,6 @@ #endif #include #include -#include #include // Must use __inline in Microsoft C From echristo at apple.com Fri Apr 29 15:02:39 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 20:02:39 -0000 Subject: [llvm-commits] [llvm] r130534 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel.ll Message-ID: <20110429200239.9458B2A6C135@llvm.org> Author: echristo Date: Fri Apr 29 15:02:39 2011 New Revision: 130534 URL: http://llvm.org/viewvc/llvm-project?rev=130534&view=rev Log: Add trunc->branch support, this won't help with clang's i8->i1 truncations for bools, but is a start. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp llvm/trunk/test/CodeGen/ARM/fast-isel.ll Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130534&r1=130533&r2=130534&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Fri Apr 29 15:02:39 2011 @@ -1116,6 +1116,30 @@ FuncInfo.MBB->addSuccessor(TBB); return true; } + } else if (TruncInst *TI = dyn_cast(BI->getCondition())) { + MVT SourceVT; + if (TI->hasOneUse() && TI->getParent() == I->getParent() && + (isTypeLegal(TI->getOperand(0)->getType(), SourceVT))) { + unsigned TstOpc = isThumb ? ARM::t2TSTri : ARM::TSTri; + unsigned OpReg = getRegForValue(TI->getOperand(0)); + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + TII.get(TstOpc)) + .addReg(OpReg).addImm(1)); + + unsigned CCMode = ARMCC::NE; + if (FuncInfo.MBB->isLayoutSuccessor(TBB)) { + std::swap(TBB, FBB); + CCMode = ARMCC::EQ; + } + + unsigned BrOpc = isThumb ? ARM::t2Bcc : ARM::Bcc; + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(BrOpc)) + .addMBB(TBB).addImm(CCMode).addReg(ARM::CPSR); + + FastEmitBranch(FBB, DL); + FuncInfo.MBB->addSuccessor(TBB); + return true; + } } unsigned CmpReg = getRegForValue(BI->getCondition()); @@ -1132,7 +1156,6 @@ AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, TII.get(TstOpc)) .addReg(CmpReg).addImm(1)); - unsigned CCMode = ARMCC::NE; if (FuncInfo.MBB->isLayoutSuccessor(TBB)) { std::swap(TBB, FBB); Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=130534&r1=130533&r2=130534&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Apr 29 15:02:39 2011 @@ -13,4 +13,19 @@ %tmp1 = load i32* %b.addr %add = add nsw i32 %tmp, %tmp1 ret i32 %add -} \ No newline at end of file +} + +define void @test1(i32 %tmp) nounwind { +entry: +%tobool = trunc i32 %tmp to i1 +br i1 %tobool, label %if.then, label %if.end + +if.then: ; preds = %entry +call void @test1(i32 0) +br label %if.end + +if.end: ; preds = %if.then, %entry +ret void +; CHECK: test1: +; CHECK: tst r0, #1 +} From dpatel at apple.com Fri Apr 29 15:38:55 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 20:38:55 -0000 Subject: [llvm-commits] [llvm] r130536 - /llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Message-ID: <20110429203855.8ED9D2A6C135@llvm.org> Author: dpatel Date: Fri Apr 29 15:38:55 2011 New Revision: 130536 URL: http://llvm.org/viewvc/llvm-project?rev=130536&view=rev Log: Preserve line number information. Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=130536&r1=130535&r2=130536&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Fri Apr 29 15:38:55 2011 @@ -326,7 +326,8 @@ // We can fold the conditional branch in the preheader, this makes things // simpler. The first step is to remove the extra edge to the Exit block. Exit->removePredecessor(OrigPreheader, true /*preserve LCSSA*/); - BranchInst::Create(NewHeader, PHBI); + BranchInst *NewBI = BranchInst::Create(NewHeader, PHBI); + NewBI->setDebugLoc(PHBI->getDebugLoc()); PHBI->eraseFromParent(); // With our CFG finalized, update DomTree if it is available. From eli.friedman at gmail.com Fri Apr 29 16:22:56 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 21:22:56 -0000 Subject: [llvm-commits] [llvm] r130539 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-redefinition.ll Message-ID: <20110429212256.DAAA02A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 16:22:56 2011 New Revision: 130539 URL: http://llvm.org/viewvc/llvm-project?rev=130539&view=rev Log: Re-committing r130454, which does not in fact break anything. Fix a rather obscure crash caused by ARM fast-isel generating code which redefines a register. rdar://problem/9338332 . Added: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130539&r1=130538&r2=130539&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Fri Apr 29 16:22:56 2011 @@ -822,26 +822,9 @@ // Since the offset is too large for the load/store instruction // get the reg+offset into a register. if (needsLowering) { - ARMCC::CondCodes Pred = ARMCC::AL; - unsigned PredReg = 0; - - TargetRegisterClass *RC = isThumb ? ARM::tGPRRegisterClass : - ARM::GPRRegisterClass; - unsigned BaseReg = createResultReg(RC); - - if (!isThumb) - emitARMRegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, - BaseReg, Addr.Base.Reg, Addr.Offset, - Pred, PredReg, - static_cast(TII)); - else { - assert(AFI->isThumb2Function()); - emitT2RegPlusImmediate(*FuncInfo.MBB, FuncInfo.InsertPt, DL, - BaseReg, Addr.Base.Reg, Addr.Offset, Pred, PredReg, - static_cast(TII)); - } + Addr.Base.Reg = FastEmit_ri_(MVT::i32, ISD::ADD, Addr.Base.Reg, + /*Op0IsKill*/false, Addr.Offset, MVT::i32); Addr.Offset = 0; - Addr.Base.Reg = BaseReg; } } Added: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll?rev=130539&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (added) +++ llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Fri Apr 29 16:22:56 2011 @@ -0,0 +1,11 @@ +; RUN: llc -O0 -regalloc=linearscan | grep "ldr r0" +; This isn't exactly a useful set of command-line options, but check that it +; doesn't crash. (It was crashing because a register was getting redefined.) + +target triple = "thumbv7-apple-macosx10.6.7" + +define i32 @f(i32* %x) nounwind ssp { + %y = getelementptr inbounds i32* %x, i32 5000 + %tmp103 = load i32* %y, align 4 + ret i32 %tmp103 +} From echristo at apple.com Fri Apr 29 16:29:31 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 14:29:31 -0700 Subject: [llvm-commits] [llvm] r130539 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp test/CodeGen/ARM/fast-isel-redefinition.ll In-Reply-To: <20110429212256.DAAA02A6C135@llvm.org> References: <20110429212256.DAAA02A6C135@llvm.org> Message-ID: <61973697-52BD-45CA-AB14-1C98B530D38F@apple.com> On Apr 29, 2011, at 2:22 PM, Eli Friedman wrote: > Author: efriedma > Date: Fri Apr 29 16:22:56 2011 > New Revision: 130539 > > URL: http://llvm.org/viewvc/llvm-project?rev=130539&view=rev > Log: > Re-committing r130454, which does not in fact break anything. Thanks Eli! Sorry about the false failure :) -eric From dpatel at apple.com Fri Apr 29 16:35:56 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 14:35:56 -0700 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <20110429081541.B7F422A6C138@llvm.org> References: <20110429081541.B7F422A6C138@llvm.org> Message-ID: Benjamin, On Apr 29, 2011, at 1:15 AM, Benjamin Kramer wrote: > Author: d0k > Date: Fri Apr 29 03:15:41 2011 > New Revision: 130485 > > URL: http://llvm.org/viewvc/llvm-project?rev=130485&view=rev > Log: > InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A) Please set DebugLoc on new Shl, based on A's DebugLoc. I'm not picking on you. I just started paying attention to this instcombiner issue. I know, there are many of places in instcombiner where we create new instructions without debug location. If you or anyone else has better approach we can use to preserve DebugLoc in instcombiner, I'd like to know! Thanks, - Devang > > Fixes PR9809. > > Modified: > llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp > llvm/trunk/test/Transforms/InstCombine/shift.ll > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=130485&r1=130484&r2=130485&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Fri Apr 29 03:15:41 2011 > @@ -644,7 +644,14 @@ > return &I; > } > } > - > + > + // (C1 << A) << C2) -> (C1 << C2) << A) > + Constant *C1, *C2; > + Value *A; > + if (match(I.getOperand(0), m_OneUse(m_Shl(m_Constant(C1), m_Value(A)))) && > + match(I.getOperand(1), m_Constant(C2))) > + return BinaryOperator::CreateShl(ConstantExpr::getShl(C1, C2), A); > + > return 0; > } > > > Modified: llvm/trunk/test/Transforms/InstCombine/shift.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/shift.ll?rev=130485&r1=130484&r2=130485&view=diff > ============================================================================== > --- llvm/trunk/test/Transforms/InstCombine/shift.ll (original) > +++ llvm/trunk/test/Transforms/InstCombine/shift.ll Fri Apr 29 03:15:41 2011 > @@ -485,3 +485,24 @@ > ; CHECK: ret i8 %tmp551 > ret i8 %tmp55 > } > + > +; PR9809 > +define i32 @test40(i32 %a, i32 %b) nounwind { > + %shl1 = shl i32 1, %b > + %shl2 = shl i32 %shl1, 2 > + %div = udiv i32 %a, %shl2 > + ret i32 %div > +; CHECK: @test40 > +; CHECK-NEXT: add i32 %b, 2 > +; CHECK-NEXT: lshr i32 %a > +; CHECK-NEXT: ret i32 > +} > + > +define i32 @test41(i32 %a, i32 %b) nounwind { > + %1 = shl i32 1, %b > + %2 = shl i32 %1, 3 > + ret i32 %2 > +; CHECK: @test41 > +; CHECK-NEXT: shl i32 8, %b > +; CHECK-NEXT: ret i32 > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From eli.friedman at gmail.com Fri Apr 29 16:33:03 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 21:33:03 -0000 Subject: [llvm-commits] [llvm] r130540 - /llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Message-ID: <20110429213303.451A72A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 16:33:03 2011 New Revision: 130540 URL: http://llvm.org/viewvc/llvm-project?rev=130540&view=rev Log: Fix run-line, again. :( Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Modified: llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll?rev=130540&r1=130539&r2=130540&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel-redefinition.ll Fri Apr 29 16:33:03 2011 @@ -1,4 +1,4 @@ -; RUN: llc -O0 -regalloc=linearscan | grep "ldr r0" +; RUN: llc -O0 -regalloc=linearscan < %s ; This isn't exactly a useful set of command-line options, but check that it ; doesn't crash. (It was crashing because a register was getting redefined.) From dpatel at apple.com Fri Apr 29 16:36:04 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 21:36:04 -0000 Subject: [llvm-commits] [llvm] r130542 - /llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Message-ID: <20110429213604.4E86F2A6C135@llvm.org> Author: dpatel Date: Fri Apr 29 16:36:04 2011 New Revision: 130542 URL: http://llvm.org/viewvc/llvm-project?rev=130542&view=rev Log: Print new instructions without DebugLoc. Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Modified: llvm/trunk/lib/VMCore/DebugInfoProbe.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/DebugInfoProbe.cpp?rev=130542&r1=130541&r2=130542&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/DebugInfoProbe.cpp (original) +++ llvm/trunk/lib/VMCore/DebugInfoProbe.cpp Fri Apr 29 16:36:04 2011 @@ -53,6 +53,7 @@ Function *TheFn; std::set LineNos; std::set DbgVariables; + std::set MissingDebugLoc; }; } @@ -89,6 +90,8 @@ for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { + if (BI->getDebugLoc().isUnknown()) + MissingDebugLoc.insert(BI); if (!isa(BI)) continue; Value *Addr = NULL; MDNode *Node = NULL; @@ -148,6 +151,12 @@ for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); BI != BE; ++BI) { + if (BI->getDebugLoc().isUnknown() && + MissingDebugLoc.count(BI) == 0) { + DEBUG(dbgs() << "DebugInfoProbe(" << PassName << "): --- "); + DEBUG(BI->print(dbgs())); + DEBUG(dbgs() << "\n"); + } if (!isa(BI)) continue; Value *Addr = NULL; MDNode *Node = NULL; From rafael.espindola at gmail.com Fri Apr 29 16:41:06 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 21:41:06 -0000 Subject: [llvm-commits] [llvm] r130543 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp Message-ID: <20110429214106.B5F392A6C135@llvm.org> Author: rafael Date: Fri Apr 29 16:41:06 2011 New Revision: 130543 URL: http://llvm.org/viewvc/llvm-project?rev=130543&view=rev Log: Implement MCAsmStreamer::EmitCFIDefCfa. Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130543&r1=130542&r2=130543&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Apr 29 16:41:06 2011 @@ -741,7 +741,10 @@ } void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) { - abort(); + MCStreamer::EmitCFIDefCfa(Register, Offset); + + OS << ".cfi_def_cfa " << Register << ", " << Offset; + EmitEOL(); } void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) { From benny.kra at googlemail.com Fri Apr 29 16:50:52 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 29 Apr 2011 23:50:52 +0200 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: References: <20110429081541.B7F422A6C138@llvm.org> Message-ID: On 29.04.2011, at 23:35, Devang Patel wrote: > Benjamin, > > On Apr 29, 2011, at 1:15 AM, Benjamin Kramer wrote: > >> Author: d0k >> Date: Fri Apr 29 03:15:41 2011 >> New Revision: 130485 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130485&view=rev >> Log: >> InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A) > > Please set DebugLoc on new Shl, based on A's DebugLoc. > > I'm not picking on you. I just started paying attention to this instcombiner issue. I know, there are many of places in instcombiner where we create new instructions without debug location. If you or anyone else has better approach we can use to preserve DebugLoc in instcombiner, I'd like to know! Are you sure this specific transformation destroys the DebugLoc? When InstCombine simply replaces one instruction with another it preserves debug information (InstructionCombining.cpp:1592). From rafael.espindola at gmail.com Fri Apr 29 16:50:57 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Fri, 29 Apr 2011 21:50:57 -0000 Subject: [llvm-commits] [llvm] r130544 - /llvm/trunk/lib/MC/MCDwarf.cpp Message-ID: <20110429215057.9FB472A6C135@llvm.org> Author: rafael Date: Fri Apr 29 16:50:57 2011 New Revision: 130544 URL: http://llvm.org/viewvc/llvm-project?rev=130544&view=rev Log: Avoid some uses of .uleb128. This is a small speedup and more importantly lets this code be used when producing assembly code for old assemblers without uleb support. Modified: llvm/trunk/lib/MC/MCDwarf.cpp Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130544&r1=130543&r2=130544&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Fri Apr 29 16:50:57 2011 @@ -679,15 +679,23 @@ streamer.EmitULEB128IntValue(asmInfo.getDwarfRARegNum(true)); // Augmentation Data Length (optional) - MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol(); - MCSymbol *augmentationEnd = streamer.getContext().CreateTempSymbol(); - const MCExpr *augmentationLength = MakeStartMinusEndExpr(streamer, - *augmentationStart, - *augmentationEnd, 0); - streamer.EmitULEB128Value(augmentationLength); + + unsigned augmentationLength = 0; + if (personality) { + // Personality Encoding + augmentationLength += 1; + // Personality + augmentationLength += getSizeForEncoding(streamer, personalityEncoding); + } + if (lsda) { + augmentationLength += 1; + } + // Encoding of the FDE pointers + augmentationLength += 1; + + streamer.EmitULEB128IntValue(augmentationLength); // Augmentation Data (optional) - streamer.EmitLabel(augmentationStart); if (personality) { // Personality Encoding streamer.EmitIntValue(personalityEncoding, 1); @@ -700,7 +708,6 @@ } // Encoding of the FDE pointers streamer.EmitIntValue(asmInfo.getFDEEncoding(), 1); - streamer.EmitLabel(augmentationEnd); // Initial Instructions @@ -763,15 +770,14 @@ streamer.EmitAbsValue(Range, size); // Augmentation Data Length - MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol(); - MCSymbol *augmentationEnd = streamer.getContext().CreateTempSymbol(); - const MCExpr *augmentationLength = MakeStartMinusEndExpr(streamer, - *augmentationStart, - *augmentationEnd, 0); - streamer.EmitULEB128Value(augmentationLength); + unsigned augmentationLength = 0; + + if (frame.Lsda || forceLsda) + augmentationLength += getSizeForEncoding(streamer, frame.LsdaEncoding); + + streamer.EmitULEB128IntValue(augmentationLength); // Augmentation Data - streamer.EmitLabel(augmentationStart); // When running in "CodeGen compatibility mode" a FDE with no LSDA can be // assigned to a CIE that requires one. In that case we output a 0 (as does @@ -779,9 +785,8 @@ if (frame.Lsda) EmitSymbol(streamer, *frame.Lsda, frame.LsdaEncoding); else if (forceLsda) - streamer.EmitIntValue(0, size); + streamer.EmitIntValue(0, getSizeForEncoding(streamer, frame.LsdaEncoding)); - streamer.EmitLabel(augmentationEnd); // Call Frame Instructions EmitCFIInstructions(streamer, frame.Instructions, frame.Begin); From dpatel at apple.com Fri Apr 29 17:00:32 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 15:00:32 -0700 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: References: <20110429081541.B7F422A6C138@llvm.org> Message-ID: <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> On Apr 29, 2011, at 2:50 PM, Benjamin Kramer wrote: > > On 29.04.2011, at 23:35, Devang Patel wrote: > >> Benjamin, >> >> On Apr 29, 2011, at 1:15 AM, Benjamin Kramer wrote: >> >>> Author: d0k >>> Date: Fri Apr 29 03:15:41 2011 >>> New Revision: 130485 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=130485&view=rev >>> Log: >>> InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A) >> >> Please set DebugLoc on new Shl, based on A's DebugLoc. >> >> I'm not picking on you. I just started paying attention to this instcombiner issue. I know, there are many of places in instcombiner where we create new instructions without debug location. If you or anyone else has better approach we can use to preserve DebugLoc in instcombiner, I'd like to know! > > Are you sure this specific transformation destroys the DebugLoc? When InstCombine simply replaces one > instruction with another it preserves debug information (InstructionCombining.cpp:1592). I added line 1592 however I am not sure that this particular transformation is covered by 1592 in all cases. I have seen "shl" without DebugLoc generated by instcombine before your patch landed in svn. If you're interested I can send you more info. - Devang From echristo at apple.com Fri Apr 29 16:56:31 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 21:56:31 -0000 Subject: [llvm-commits] [llvm] r130546 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110429215631.A1FBE2A6C135@llvm.org> Author: echristo Date: Fri Apr 29 16:56:31 2011 New Revision: 130546 URL: http://llvm.org/viewvc/llvm-project?rev=130546&view=rev Log: Some cleanup and optimize fallthrough more. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130546&r1=130545&r2=130546&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Fri Apr 29 16:56:31 2011 @@ -1045,18 +1045,16 @@ // behavior. // TODO: Factor this out. if (const CmpInst *CI = dyn_cast(BI->getCondition())) { - if (CI->hasOneUse() && (CI->getParent() == I->getParent())) { - MVT VT; - const Type *Ty = CI->getOperand(0)->getType(); - if (!isTypeLegal(Ty, VT)) - return false; - + MVT SourceVT; + const Type *Ty = CI->getOperand(0)->getType(); + if (CI->hasOneUse() && (CI->getParent() == I->getParent()) + && isTypeLegal(Ty, SourceVT)) { bool isFloat = (Ty->isDoubleTy() || Ty->isFloatTy()); if (isFloat && !Subtarget->hasVFP2()) return false; unsigned CmpOpc; - switch (VT.SimpleTy) { + switch (SourceVT.SimpleTy) { default: return false; // TODO: Verify compares. case MVT::f32: @@ -1071,7 +1069,14 @@ } // Get the compare predicate. - ARMCC::CondCodes ARMPred = getComparePred(CI->getPredicate()); + // Try to take advantage of fallthrough opportunities. + CmpInst::Predicate Predicate = CI->getPredicate(); + if (FuncInfo.MBB->isLayoutSuccessor(TBB)) { + std::swap(TBB, FBB); + Predicate = CmpInst::getInversePredicate(Predicate); + } + + ARMCC::CondCodes ARMPred = getComparePred(Predicate); // We may not handle every CC for now. if (ARMPred == ARMCC::AL) return false; From eli.friedman at gmail.com Fri Apr 29 16:58:31 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 21:58:31 -0000 Subject: [llvm-commits] [llvm] r130547 - /llvm/trunk/utils/TableGen/FastISelEmitter.cpp Message-ID: <20110429215831.E45252A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 16:58:31 2011 New Revision: 130547 URL: http://llvm.org/viewvc/llvm-project?rev=130547&view=rev Log: Filter out pattterns from the FastISel emitter which it doesn't actually know how to handle. No significant functionality change at the moment, but it's necessary for some changes I'm planning. Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=130547&r1=130546&r2=130547&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Fri Apr 29 16:58:31 2011 @@ -393,6 +393,33 @@ : InstNS(instns) { } +static std::string PhyRegForNode(TreePatternNode *Op, + const CodeGenTarget &Target) { + std::string PhysReg; + + if (!Op->isLeaf()) + return PhysReg; + + DefInit *OpDI = dynamic_cast(Op->getLeafValue()); + Record *OpLeafRec = OpDI->getDef(); + if (!OpLeafRec->isSubClassOf("Register")) + return PhysReg; + + PhysReg += static_cast(OpLeafRec->getValue( \ + "Namespace")->getValue())->getValue(); + PhysReg += "::"; + + std::vector Regs = Target.getRegisters(); + for (unsigned i = 0; i < Regs.size(); ++i) { + if (Regs[i].TheDef == OpLeafRec) { + PhysReg += Regs[i].getName(); + break; + } + } + + return PhysReg; +} + void FastISelMap::collectPatterns(CodeGenDAGPatterns &CGP) { const CodeGenTarget &Target = CGP.getTargetInfo(); @@ -470,11 +497,6 @@ assert(InstPatNode->getChild(0)->getNumTypes() == 1); VT = InstPatNode->getChild(0)->getType(0); } - - // For now, filter out instructions which just set a register to - // an Operand or an immediate, like MOV32ri. - if (InstPatOp->isSubClassOf("Operand")) - continue; // For now, filter out any instructions with predicates. if (!InstPatNode->getPredicateFns().empty()) @@ -486,39 +508,35 @@ continue; std::vector* PhysRegInputs = new std::vector(); - if (!InstPatNode->isLeaf() && - (InstPatNode->getOperator()->getName() == "imm" || - InstPatNode->getOperator()->getName() == "fpimmm")) + if (InstPatNode->getOperator()->getName() == "imm" || + InstPatNode->getOperator()->getName() == "fpimmm") PhysRegInputs->push_back(""); - else if (!InstPatNode->isLeaf()) { + else { + // Compute the PhysRegs used by the given pattern, and check that + // the mapping from the src to dst patterns is simple. + bool FoundNonSimplePattern = false; + unsigned DstIndex = 0; for (unsigned i = 0, e = InstPatNode->getNumChildren(); i != e; ++i) { - TreePatternNode *Op = InstPatNode->getChild(i); - if (!Op->isLeaf()) { - PhysRegInputs->push_back(""); - continue; - } - - DefInit *OpDI = dynamic_cast(Op->getLeafValue()); - Record *OpLeafRec = OpDI->getDef(); - std::string PhysReg; - if (OpLeafRec->isSubClassOf("Register")) { - PhysReg += static_cast(OpLeafRec->getValue( \ - "Namespace")->getValue())->getValue(); - PhysReg += "::"; - - std::vector Regs = Target.getRegisters(); - for (unsigned i = 0; i < Regs.size(); ++i) { - if (Regs[i].TheDef == OpLeafRec) { - PhysReg += Regs[i].getName(); - break; - } + std::string PhysReg = PhyRegForNode(InstPatNode->getChild(i), Target); + if (PhysReg.empty()) { + if (DstIndex >= Dst->getNumChildren() || + Dst->getChild(DstIndex)->getName() != + InstPatNode->getChild(i)->getName()) { + FoundNonSimplePattern = true; + break; } + ++DstIndex; } PhysRegInputs->push_back(PhysReg); } - } else - PhysRegInputs->push_back(""); + + if (Op->getName() != "EXTRACT_SUBREG" && DstIndex < Dst->getNumChildren()) + FoundNonSimplePattern = true; + + if (FoundNonSimplePattern) + continue; + } // Get the predicate that guards this pattern. std::string PredicateCheck = Pattern.getPredicateCheck(); From fjahanian at apple.com Fri Apr 29 17:04:21 2011 From: fjahanian at apple.com (Fariborz Jahanian) Date: Fri, 29 Apr 2011 22:04:21 -0000 Subject: [llvm-commits] [test-suite] r130548 - in /test-suite/trunk/SingleSource/UnitTests/ObjC: block-byref-aggr.m block-byref-aggr.reference_output Message-ID: <20110429220421.7173F2A6C135@llvm.org> Author: fjahanian Date: Fri Apr 29 17:04:21 2011 New Revision: 130548 URL: http://llvm.org/viewvc/llvm-project?rev=130548&view=rev Log: Executable test for clang's // rdar://9309454 Added: test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output Added: test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m?rev=130548&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m (added) +++ test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.m Fri Apr 29 17:04:21 2011 @@ -0,0 +1,36 @@ +#import +#import + +typedef struct { uintptr_t v; } RetType; +#define logRetType(msg, val) printf(msg, val.v); + +RetType func(dispatch_block_t block); + +RetType func(dispatch_block_t block) { + block = Block_copy(block); + block(); + + RetType ret = {4}; + return ret; +} + +int main (int argc, const char * argv[]) { + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + + __block RetType a = {0}; + dispatch_block_t b = ^{ + logRetType("a was originally: %ld\n", a); + }; + + a = func(b); + logRetType("a is now: %ld\n", a); + + // b was Block_copied already, so the result is different. + + a = func(b); + logRetType("a has become: %ld\n", a); + + [pool drain]; + return 0; +} + Added: test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output?rev=130548&view=auto ============================================================================== --- test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output (added) +++ test-suite/trunk/SingleSource/UnitTests/ObjC/block-byref-aggr.reference_output Fri Apr 29 17:04:21 2011 @@ -0,0 +1,5 @@ +a was originally: 0 +a is now: 4 +a was originally: 4 +a has become: 4 +exit 0 From echristo at apple.com Fri Apr 29 17:07:50 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 22:07:50 -0000 Subject: [llvm-commits] [llvm] r130549 - /llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Message-ID: <20110429220750.DD03E2A6C135@llvm.org> Author: echristo Date: Fri Apr 29 17:07:50 2011 New Revision: 130549 URL: http://llvm.org/viewvc/llvm-project?rev=130549&view=rev Log: Add FastEmitInst_ii for the arm fast isel generator. It doesn't use it, but if it ever did it needs the def machinery. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130549&r1=130548&r2=130549&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Fri Apr 29 17:07:50 2011 @@ -137,6 +137,9 @@ virtual unsigned FastEmitInst_i(unsigned MachineInstOpcode, const TargetRegisterClass *RC, uint64_t Imm); + virtual unsigned FastEmitInst_ii(unsigned MachineInstOpcode, + const TargetRegisterClass *RC, + uint64_t Imm1, uint64_t Imm2); virtual unsigned FastEmitInst_extractsubreg(MVT RetVT, unsigned Op0, bool Op0IsKill, @@ -434,6 +437,26 @@ return ResultReg; } +unsigned ARMFastISel::FastEmitInst_ii(unsigned MachineInstOpcode, + const TargetRegisterClass *RC, + uint64_t Imm1, uint64_t Imm2) { + unsigned ResultReg = createResultReg(RC); + const TargetInstrDesc &II = TII.get(MachineInstOpcode); + + if (II.getNumDefs() >= 1) + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II, ResultReg) + .addImm(Imm1).addImm(Imm2)); + else { + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, II) + .addImm(Imm1).addImm(Imm2)); + AddOptionalDefs(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DL, + TII.get(TargetOpcode::COPY), + ResultReg) + .addReg(II.ImplicitDefs[0])); + } + return ResultReg; +} + unsigned ARMFastISel::FastEmitInst_extractsubreg(MVT RetVT, unsigned Op0, bool Op0IsKill, uint32_t Idx) { From dpatel at apple.com Fri Apr 29 17:28:59 2011 From: dpatel at apple.com (Devang Patel) Date: Fri, 29 Apr 2011 22:28:59 -0000 Subject: [llvm-commits] [llvm] r130551 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Utils/BasicBlockUtils.cpp lib/Transforms/Utils/SSAUpdater.cpp Message-ID: <20110429222859.4F3242A6C135@llvm.org> Author: dpatel Date: Fri Apr 29 17:28:59 2011 New Revision: 130551 URL: http://llvm.org/viewvc/llvm-project?rev=130551&view=rev Log: Assing line number info to new PHIs created by SSA updater. Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=130551&r1=130550&r2=130551&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Fri Apr 29 17:28:59 2011 @@ -19,6 +19,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" +#include "llvm/Support/DebugLoc.h" namespace llvm { @@ -181,6 +182,10 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred); +/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a +/// given basic block. +DebugLoc GetFirstDebugLocInBasicBlock(const BasicBlock *BB); + } // End llvm namespace #endif Modified: llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp?rev=130551&r1=130550&r2=130551&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BasicBlockUtils.cpp Fri Apr 29 17:28:59 2011 @@ -538,3 +538,15 @@ UncondBranch->eraseFromParent(); return cast(NewRet); } + +/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a +/// given basic block. +DebugLoc llvm::GetFirstDebugLocInBasicBlock(const BasicBlock *BB) { + for (BasicBlock::const_iterator BI = BB->begin(), BE = BB->end(); + BI != BE; ++BI) { + DebugLoc DL = BI->getDebugLoc(); + if (!DL.isUnknown()) + return DL; + } + return DebugLoc(); +} Modified: llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp?rev=130551&r1=130550&r2=130551&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SSAUpdater.cpp Fri Apr 29 17:28:59 2011 @@ -21,8 +21,10 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" #include "llvm/Transforms/Utils/SSAUpdaterImpl.h" + using namespace llvm; typedef DenseMap AvailableValsTy; @@ -185,6 +187,9 @@ return V; } + // Set DebugLoc. + InsertedPHI->setDebugLoc(GetFirstDebugLocInBasicBlock(BB)); + // If the client wants to know about all new instructions, tell it. if (InsertedPHIs) InsertedPHIs->push_back(InsertedPHI); From eli.friedman at gmail.com Fri Apr 29 17:48:03 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 22:48:03 -0000 Subject: [llvm-commits] [llvm] r130552 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/fast-isel.ll Message-ID: <20110429224804.04F5A2A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 17:48:03 2011 New Revision: 130552 URL: http://llvm.org/viewvc/llvm-project?rev=130552&view=rev Log: Switch to ImmLeaf (which can be used by FastISel) for a few more common ARM/Thumb2 patterns. Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/CodeGen/ARM/fast-isel.ll Modified: llvm/trunk/lib/Target/ARM/ARMFastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMFastISel.cpp?rev=130552&r1=130551&r2=130552&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMFastISel.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMFastISel.cpp Fri Apr 29 17:48:03 2011 @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "ARM.h" +#include "ARMAddressingModes.h" #include "ARMBaseInstrInfo.h" #include "ARMCallingConv.h" #include "ARMRegisterInfo.h" Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=130552&r1=130551&r2=130552&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Fri Apr 29 17:48:03 2011 @@ -412,7 +412,9 @@ // so_imm - Match a 32-bit shifter_operand immediate operand, which is an // 8-bit immediate rotated by an arbitrary number of bits. -def so_imm : Operand, PatLeaf<(imm), [{ return Pred_so_imm(N); }]> { +def so_imm : Operand, ImmLeaf { let EncoderMethod = "getSOImmOpValue"; let PrintMethod = "printSOImmOperand"; } Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=130552&r1=130551&r2=130552&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Apr 29 17:48:03 2011 @@ -44,7 +44,9 @@ // t2_so_imm - Match a 32-bit immediate operand, which is an // 8-bit immediate rotated by an arbitrary number of bits, or an 8-bit // immediate splatted into multiple bytes of the word. -def t2_so_imm : Operand, PatLeaf<(imm), [{ return Pred_t2_so_imm(N); }]> { +def t2_so_imm : Operand, ImmLeaf { let EncoderMethod = "getT2SOImmOpValue"; } Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=130552&r1=130551&r2=130552&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Apr 29 17:48:03 2011 @@ -1,8 +1,7 @@ -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=armv7-apple-darwin -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=thumbv7-apple-darwin +; RUN: llc < %s -O0 -fast-isel-abort -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM +; RUN: llc < %s -O0 -fast-isel-abort -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB ; Very basic fast-isel functionality. - define i32 @add(i32 %a, i32 %b) nounwind { entry: %a.addr = alloca i32, align 4 @@ -15,6 +14,7 @@ ret i32 %add } +; Check truncate to bool define void @test1(i32 %tmp) nounwind { entry: %tobool = trunc i32 %tmp to i1 @@ -26,6 +26,30 @@ if.end: ; preds = %if.then, %entry ret void -; CHECK: test1: -; CHECK: tst r0, #1 +; ARM: test1: +; ARM: tst r0, #1 +; THUMB: test1: +; THUMB: tst.w r0, #1 +} + +; Check some simple operations with immediates +define void @test2(i32 %tmp, i32* %ptr) nounwind { +; THUMB: test2: +; ARM: test2: + +b1: + %b = add i32 %tmp, 4096 + store i32 %b, i32* %ptr + br label %b2 + +; THUMB: add.w {{.*}} #4096 +; ARM: add {{.*}} #1, #20 + +b2: + %c = or i32 %tmp, 4 + store i32 %c, i32* %ptr + ret void + +; THUMB: orr {{.*}} #4 +; ARM: orr {{.*}} #4 } From aggarwa4 at illinois.edu Fri Apr 29 17:49:07 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Fri, 29 Apr 2011 22:49:07 -0000 Subject: [llvm-commits] [poolalloc] r130553 - /poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Message-ID: <20110429224907.2EBDF2A6C135@llvm.org> Author: aggarwa4 Date: Fri Apr 29 17:49:07 2011 New Revision: 130553 URL: http://llvm.org/viewvc/llvm-project?rev=130553&view=rev Log: Teach the simple poolallocate algorithm about poolmemalign. Needed for Baggy Bounds, which uses PASimple. Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=130553&r1=130552&r2=130553&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Fri Apr 29 17:49:07 2011 @@ -305,6 +305,58 @@ // Update def-use info CI->replaceAllUsesWith(Casted); + } else if (CF && (CF->isDeclaration()) && (CF->getName() == "memalign")) { + DSNode * Node = CombinedDSGraph->getNodeForValue(CI).getNode(); + FInfo.PoolDescriptors.insert(std::make_pair(Node,TheGlobalPool)); + + // Mark the call to memalign as an instruction to delete + toDelete.push_back(CI); + + // Insertion point - Instruction before which all our instructions go + Instruction *InsertPt = CI; + Value *Size = CS.getArgument(0); + Value *Align = CS.getArgument(1); + + // Ensure the size and pointer arguments are of the correct type + if (Size->getType() != Int32Type) + Size = CastInst::CreateIntegerCast (Size, + Int32Type, + false, + Size->getName(), + InsertPt); + if (Align->getType() != Int32Type) + Align = CastInst::CreateIntegerCast (Align, + Int32Type, + false, + Align->getName(), + InsertPt); + // + // Remember the name of the old instruction and then clear it. This + // allows us to give the name to the new call to poolmemalign(). + // + std::string Name = CI->getName(); CI->setName(""); + + // + // Insert the call to poolalloc() + // + Value* Opts[3] = {TheGlobalPool, Align, Size}; + Instruction *V = CallInst::Create (PoolMemAlign, + Opts, + Opts + 3, + Name, + InsertPt); + + // + // Update the DSGraph. + // + CombinedDSGraph->getScalarMap().replaceScalar (CI, V); + + Instruction *Casted = V; + if (V->getType() != CI->getType()) + Casted = CastInst::CreatePointerCast (V, CI->getType(), V->getName(), InsertPt); + + // Update def-use info + CI->replaceAllUsesWith(Casted); } else if (CF && (CF->isDeclaration()) && (CF->getName() == "realloc")) { // Associate the global pool decriptor with the DSNode DSNode * Node = CombinedDSGraph->getNodeForValue(CI).getNode(); From echristo at apple.com Fri Apr 29 17:59:44 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 15:59:44 -0700 Subject: [llvm-commits] [llvm] r130552 - in /llvm/trunk: lib/Target/ARM/ARMFastISel.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/fast-isel.ll In-Reply-To: <20110429224804.04F5A2A6C135@llvm.org> References: <20110429224804.04F5A2A6C135@llvm.org> Message-ID: <12EAE030-7325-48F3-90A8-E2D3566999D9@apple.com> On Apr 29, 2011, at 3:48 PM, Eli Friedman wrote: > Author: efriedma > Date: Fri Apr 29 17:48:03 2011 > New Revision: 130552 > > URL: http://llvm.org/viewvc/llvm-project?rev=130552&view=rev > Log: > Switch to ImmLeaf (which can be used by FastISel) for a few more common ARM/Thumb2 patterns. I think Pred_so_imm is now unused :) -eric From eli.friedman at gmail.com Fri Apr 29 17:56:48 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 22:56:48 -0000 Subject: [llvm-commits] [llvm] r130557 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <20110429225648.E9B2D2A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 17:56:48 2011 New Revision: 130557 URL: http://llvm.org/viewvc/llvm-project?rev=130557&view=rev Log: Zap a couple now-unused functions. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=130557&r1=130556&r2=130557&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Fri Apr 29 17:56:48 2011 @@ -179,16 +179,6 @@ return ARM_AM::getT2SOImmVal(~Imm) != -1; } - inline bool Pred_so_imm(SDNode *inN) const { - ConstantSDNode *N = cast(inN); - return is_so_imm(N->getZExtValue()); - } - - inline bool Pred_t2_so_imm(SDNode *inN) const { - ConstantSDNode *N = cast(inN); - return is_t2_so_imm(N->getZExtValue()); - } - // Include the pieces autogenerated from the target description. #include "ARMGenDAGISel.inc" From echristo at apple.com Fri Apr 29 18:12:02 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 23:12:02 -0000 Subject: [llvm-commits] [llvm] r130558 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20110429231202.321342A6C135@llvm.org> Author: echristo Date: Fri Apr 29 18:12:01 2011 New Revision: 130558 URL: http://llvm.org/viewvc/llvm-project?rev=130558&view=rev Log: 80-col. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=130558&r1=130557&r2=130558&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Apr 29 18:12:01 2011 @@ -2377,9 +2377,9 @@ // to their spots on the stack so that they may be loaded by deferencing // the result of va_next. AFI->setVarArgsRegSaveSize(VARegSaveSize); - AFI->setVarArgsFrameIndex( - MFI->CreateFixedObject(VARegSaveSize, - ArgOffset + VARegSaveSize - VARegSize, + AFI->setVarArgsFrameIndex(MFI->CreateFixedObject(VARegSaveSize, + ArgOffset + VARegSaveSize + - VARegSize, false)); SDValue FIN = DAG.getFrameIndex(AFI->getVarArgsFrameIndex(), getPointerTy()); @@ -2396,7 +2396,7 @@ SDValue Val = DAG.getCopyFromReg(Chain, dl, VReg, MVT::i32); SDValue Store = DAG.getStore(Val.getValue(1), dl, Val, FIN, - MachinePointerInfo::getFixedStack(AFI->getVarArgsFrameIndex()), + MachinePointerInfo::getFixedStack(AFI->getVarArgsFrameIndex()), false, false, 0); MemOps.push_back(Store); FIN = DAG.getNode(ISD::ADD, dl, getPointerTy(), FIN, @@ -2525,10 +2525,11 @@ if (index != lastInsIndex) { ISD::ArgFlagsTy Flags = Ins[index].Flags; - // FIXME: For now, all byval parameter objects are marked mutable. This can be - // changed with more analysis. - // In case of tail call optimization mark all arguments mutable. Since they - // could be overwritten by lowering of arguments in case of a tail call. + // FIXME: For now, all byval parameter objects are marked mutable. + // This can be changed with more analysis. + // In case of tail call optimization mark all arguments mutable. + // Since they could be overwritten by lowering of arguments in case of + // a tail call. if (Flags.isByVal()) { unsigned VARegSize, VARegSaveSize; computeRegArea(CCInfo, MF, VARegSize, VARegSaveSize); From eli.friedman at gmail.com Fri Apr 29 18:34:52 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 29 Apr 2011 23:34:52 -0000 Subject: [llvm-commits] [llvm] r130560 - in /llvm/trunk: lib/CodeGen/SelectionDAG/FastISel.cpp test/CodeGen/ARM/fast-isel.ll Message-ID: <20110429233452.D44232A6C135@llvm.org> Author: efriedma Date: Fri Apr 29 18:34:52 2011 New Revision: 130560 URL: http://llvm.org/viewvc/llvm-project?rev=130560&view=rev Log: Make FastEmit_ri_ try a bit harder to succeed for supported operations; FastEmit_i can fail for non-Thumb2 ARM. Makes ARMSimplifyAddress work correctly, and reduces the number of fast-isel bailouts on non-Thumb ARM. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp llvm/trunk/test/CodeGen/ARM/fast-isel.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=130560&r1=130559&r2=130560&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Fri Apr 29 18:34:52 2011 @@ -1032,8 +1032,13 @@ if (ResultReg != 0) return ResultReg; unsigned MaterialReg = FastEmit_i(ImmType, ImmType, ISD::Constant, Imm); - if (MaterialReg == 0) - return 0; + if (MaterialReg == 0) { + // This is a bit ugly/slow, but failing here means falling out of + // fast-isel, which would be very slow. + const IntegerType *ITy = IntegerType::get(FuncInfo.Fn->getContext(), + VT.getSizeInBits()); + MaterialReg = getRegForValue(ConstantInt::get(ITy, Imm)); + } return FastEmit_rr(VT, VT, Opcode, Op0, Op0IsKill, MaterialReg, /*Kill=*/true); Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=130560&r1=130559&r2=130560&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Apr 29 18:34:52 2011 @@ -38,14 +38,22 @@ ; ARM: test2: b1: - %b = add i32 %tmp, 4096 - store i32 %b, i32* %ptr + %a = add i32 %tmp, 4096 + store i32 %a, i32* %ptr br label %b2 ; THUMB: add.w {{.*}} #4096 ; ARM: add {{.*}} #1, #20 b2: + %b = add i32 %tmp, 4095 + store i32 %b, i32* %ptr + br label %b3 +; THUMB: addw {{.*}} #4095 +; ARM: movw {{.*}} #4095 +; ARM: add + +b3: %c = or i32 %tmp, 4 store i32 %c, i32* %ptr ret void From isanbard at gmail.com Fri Apr 29 18:45:22 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 29 Apr 2011 23:45:22 -0000 Subject: [llvm-commits] [llvm] r130562 - /llvm/trunk/lib/CodeGen/MachineInstr.cpp Message-ID: <20110429234522.6E0142A6C135@llvm.org> Author: void Date: Fri Apr 29 18:45:22 2011 New Revision: 130562 URL: http://llvm.org/viewvc/llvm-project?rev=130562&view=rev Log: Print out the 'nontemporal' info on a store. Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=130562&r1=130561&r2=130562&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original) +++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Fri Apr 29 18:45:22 2011 @@ -441,6 +441,10 @@ OS << ")"; } + // Print nontemporal info. + if (MMO.isNonTemporal()) + OS << "(nontemporal)"; + return OS; } From aggarwa4 at illinois.edu Fri Apr 29 18:47:41 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Fri, 29 Apr 2011 23:47:41 -0000 Subject: [llvm-commits] [poolalloc] r130563 - in /poolalloc/trunk/lib/PoolAllocate: PASimple.cpp TransformFunctionBody.cpp Message-ID: <20110429234742.0505E2A6C135@llvm.org> Author: aggarwa4 Date: Fri Apr 29 18:47:41 2011 New Revision: 130563 URL: http://llvm.org/viewvc/llvm-project?rev=130563&view=rev Log: Also detect cfree. Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=130563&r1=130562&r2=130563&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Fri Apr 29 18:47:41 2011 @@ -489,7 +489,7 @@ // Update def-use info CI->replaceAllUsesWith(Casted); - } else if (CF && (CF->isDeclaration()) && (CF->getName() == "free")) { + } else if (CF && (CF->isDeclaration()) && ((CF->getName() == "free") || (CF->getName() == "cfree"))) { Type * VoidPtrTy = PointerType::getUnqual(Int8Type); Value * FreedNode = castTo (CI->getOperand(1), VoidPtrTy, "cast", ii); toDelete.push_back(ii); Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=130563&r1=130562&r2=130563&view=diff ============================================================================== --- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original) +++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Fri Apr 29 18:47:41 2011 @@ -837,7 +837,8 @@ // If this function is one of the memory manipulating functions built into // libc, emulate it with pool calls as appropriate. if (CF && CF->isDeclaration()) { - if (CF->getName() == "free") { + if (CF->getName() == "free" || + CF->getName() == "cfree") { visitFreeCall(CS); return; } else if (CF->getName() == "malloc") { From bruno.cardoso at gmail.com Fri Apr 29 19:26:30 2011 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Fri, 29 Apr 2011 21:26:30 -0300 Subject: [llvm-commits] [PATCH] arm coprocessor builtins and intrinsics! Message-ID: Hi all, I know in some cases we prefer avoiding the usage of intrinsics as much as possible and I'm not aware what it's the policy regarding the addition of new ARM builtins and intrinsics. However, this patch implements builtins and intrinsics for some coprocessor instructions, they have a clean interface and directly match the real instructions. Is it OK to commit? -- Bruno Cardoso Lopes http://www.brunocardoso.cc -------------- next part -------------- A non-text attachment was scrubbed... Name: clang-arm-intrinsics.patch Type: application/octet-stream Size: 840 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110429/e9e7b768/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-arm-intrinsics.patch Type: application/octet-stream Size: 13003 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110429/e9e7b768/attachment-0001.obj From daniel at zuster.org Fri Apr 29 20:20:57 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 01:20:57 -0000 Subject: [llvm-commits] [compiler-rt] r130566 - /compiler-rt/trunk/make/platform/clang_darwin.mk Message-ID: <20110430012057.156892A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 20:20:56 2011 New Revision: 130566 URL: http://llvm.org/viewvc/llvm-project?rev=130566&view=rev Log: clang/Darwin: Update ios static lib to build for all archs, in case the simulator wants to use it. Modified: compiler-rt/trunk/make/platform/clang_darwin.mk Modified: compiler-rt/trunk/make/platform/clang_darwin.mk URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/platform/clang_darwin.mk?rev=130566&r1=130565&r2=130566&view=diff ============================================================================== --- compiler-rt/trunk/make/platform/clang_darwin.mk (original) +++ compiler-rt/trunk/make/platform/clang_darwin.mk Fri Apr 29 20:20:56 2011 @@ -25,7 +25,7 @@ # in the same linkage unit, and for a couple of other functions that didn't # make it into libSystem. Configs += ios -UniversalArchs.ios := armv6 armv7 +UniversalArchs.ios := i386 x86_64 armv6 armv7 # Configuration for use with kernel/kexts. Configs += cc_kext @@ -55,7 +55,10 @@ CFLAGS.eprintf := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) CFLAGS.10.4 := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) -CFLAGS.ios := $(CFLAGS) $(ARM_DEPLOYMENT_ARGS) +CFLAGS.ios.i386 := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) +CFLAGS.ios.x86_64 := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) +CFLAGS.ios.armv6 := $(CFLAGS) $(ARM_DEPLOYMENT_ARGS) +CFLAGS.ios.armv7 := $(CFLAGS) $(ARM_DEPLOYMENT_ARGS) CFLAGS.cc_kext.i386 := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) CFLAGS.cc_kext.x86_64 := $(CFLAGS) $(X86_DEPLOYMENT_ARGS) CFLAGS.cc_kext.armv6 := $(CFLAGS) $(ARM_DEPLOYMENT_ARGS) -mthumb @@ -64,12 +67,11 @@ FUNCTIONS.eprintf := eprintf FUNCTIONS.10.4 := eprintf floatundidf floatundisf floatundixf -IOS_COMMON_FUNCTIONS := divmodsi4 udivmodsi4 -FUNCTIONS.ios.armv6 := $(IOS_COMMON_FUNCTIONS) \ +FUNCTIONS.ios := divmodsi4 udivmodsi4 +FUNCTIONS.ios.armv6 := $(FUNCTIONS.ios) \ sync_synchronize \ switch16 switch32 switch8 switchu8 \ save_vfp_d8_d15_regs restore_vfp_d8_d15_regs -FUNCTIONS.ios.armv7 := $(IOS_COMMON_FUNCTIONS) CCKEXT_COMMON_FUNCTIONS := \ absvdi2 \ From stoklund at 2pi.dk Fri Apr 29 20:37:52 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 01:37:52 -0000 Subject: [llvm-commits] [llvm] r130567 - in /llvm/trunk/test/CodeGen: ARM/arm-and-tst-peephole.ll ARM/indirectbr.ll ARM/ldrd.ll ARM/lsr-code-insertion.ll ARM/unaligned_load_store.ll Thumb2/machine-licm.ll X86/2010-09-17-SideEffectsInChain.ll Message-ID: <20110430013752.913A32A6C135@llvm.org> Author: stoklund Date: Fri Apr 29 20:37:52 2011 New Revision: 130567 URL: http://llvm.org/viewvc/llvm-project?rev=130567&view=rev Log: Weekly fix of register allocation dependent unit tests. Modified: llvm/trunk/test/CodeGen/ARM/arm-and-tst-peephole.ll llvm/trunk/test/CodeGen/ARM/indirectbr.ll llvm/trunk/test/CodeGen/ARM/ldrd.ll llvm/trunk/test/CodeGen/ARM/lsr-code-insertion.ll llvm/trunk/test/CodeGen/ARM/unaligned_load_store.ll llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll llvm/trunk/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll Modified: llvm/trunk/test/CodeGen/ARM/arm-and-tst-peephole.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arm-and-tst-peephole.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/arm-and-tst-peephole.ll (original) +++ llvm/trunk/test/CodeGen/ARM/arm-and-tst-peephole.ll Fri Apr 29 20:37:52 2011 @@ -23,7 +23,7 @@ %tmp2 = load i8** %scevgep5 %0 = ptrtoint i8* %tmp2 to i32 -; ARM: ands r12, r12, #3 +; ARM: ands {{r[0-9]+}}, {{r[0-9]+}}, #3 ; ARM-NEXT: beq ; THUMB: movs r[[R0:[0-9]+]], #3 @@ -31,7 +31,7 @@ ; THUMB-NEXT: cmp r[[R0]], #0 ; THUMB-NEXT: beq -; T2: ands r12, r12, #3 +; T2: ands {{r[0-9]+}}, {{r[0-9]+}}, #3 ; T2-NEXT: beq %and = and i32 %0, 3 Modified: llvm/trunk/test/CodeGen/ARM/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/indirectbr.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/indirectbr.ll (original) +++ llvm/trunk/test/CodeGen/ARM/indirectbr.ll Fri Apr 29 20:37:52 2011 @@ -42,20 +42,23 @@ br label %L2 L2: ; preds = %L3, %bb2 +; THUMB: muls %res.2 = phi i32 [ %res.1, %L3 ], [ 1, %bb2 ] ; [#uses=1] %phitmp = mul i32 %res.2, 6 ; [#uses=1] br label %L1 L1: ; preds = %L2, %bb2 %res.3 = phi i32 [ %phitmp, %L2 ], [ 2, %bb2 ] ; [#uses=1] -; ARM: ldr r1, LCPI -; ARM: add r1, pc, r1 -; ARM: str r1 -; THUMB: ldr.n r2, LCPI -; THUMB: add r2, pc -; THUMB: str r2 -; THUMB2: ldr.n r2, LCPI -; THUMB2-NEXT: str r2 +; ARM: ldr [[R1:r[0-9]+]], LCPI +; ARM: add [[R1b:r[0-9]+]], pc, [[R1]] +; ARM: str [[R1b]] +; THUMB: ldr.n +; THUMB: add +; THUMB: ldr.n [[R2:r[0-9]+]], LCPI +; THUMB: add [[R2]], pc +; THUMB: str [[R2]] +; THUMB2: ldr.n [[R2:r[0-9]+]], LCPI +; THUMB2-NEXT: str{{(.w)?}} [[R2]] store i8* blockaddress(@foo, %L5), i8** @nextaddr, align 4 ret i32 %res.3 } Modified: llvm/trunk/test/CodeGen/ARM/ldrd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/ldrd.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/ldrd.ll (original) +++ llvm/trunk/test/CodeGen/ARM/ldrd.ll Fri Apr 29 20:37:52 2011 @@ -1,6 +1,6 @@ ; RUN: llc < %s -mtriple=armv6-apple-darwin -regalloc=linearscan | FileCheck %s -check-prefix=V6 -; RUN: llc < %s -mtriple=armv5-apple-darwin | FileCheck %s -check-prefix=V5 -; RUN: llc < %s -mtriple=armv6-eabi | FileCheck %s -check-prefix=EABI +; RUN: llc < %s -mtriple=armv5-apple-darwin -regalloc=linearscan | FileCheck %s -check-prefix=V5 +; RUN: llc < %s -mtriple=armv6-eabi -regalloc=linearscan | FileCheck %s -check-prefix=EABI ; rdar://r6949835 ; Magic ARM pair hints works best with linearscan. Modified: llvm/trunk/test/CodeGen/ARM/lsr-code-insertion.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/lsr-code-insertion.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/lsr-code-insertion.ll (original) +++ llvm/trunk/test/CodeGen/ARM/lsr-code-insertion.ll Fri Apr 29 20:37:52 2011 @@ -1,5 +1,4 @@ -; RUN: llc < %s -stats |& grep {39.*Number of machine instrs printed} -; RUN: llc < %s -stats |& not grep {.*Number of re-materialization} +; RUN: llc < %s | FileCheck %s ; This test really wants to check that the resultant "cond_true" block only ; has a single store in it, and that cond_true55 only has code to materialize ; the constant and do a store. We do *not* want something like this: @@ -8,6 +7,11 @@ ; add r8, r0, r6 ; str r10, [r8, #+4] ; +; CHECK: ldr [[R6:r[0-9*]+]], LCP +; CHECK: cmp {{.*}}, [[R6]] +; CHECK: ldrle +; CHECK-NEXT: strle + target triple = "arm-apple-darwin8" define void @foo(i32* %mc, i32* %mpp, i32* %ip, i32* %dpp, i32* %tpmm, i32 %M, i32* %tpim, i32* %tpdm, i32* %bp, i32* %ms, i32 %xmb) { Modified: llvm/trunk/test/CodeGen/ARM/unaligned_load_store.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/unaligned_load_store.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/unaligned_load_store.ll (original) +++ llvm/trunk/test/CodeGen/ARM/unaligned_load_store.ll Fri Apr 29 20:37:52 2011 @@ -8,14 +8,14 @@ define void @t(i8* nocapture %a, i8* nocapture %b) nounwind { entry: ; GENERIC: t: -; GENERIC: ldrb r2 -; GENERIC: ldrb r3 -; GENERIC: ldrb r12 -; GENERIC: ldrb r1 -; GENERIC: strb r1 -; GENERIC: strb r12 -; GENERIC: strb r3 -; GENERIC: strb r2 +; GENERIC: ldrb [[R2:r[0-9]+]] +; GENERIC: ldrb [[R3:r[0-9]+]] +; GENERIC: ldrb [[R12:r[0-9]+]] +; GENERIC: ldrb [[R1:r[0-9]+]] +; GENERIC: strb [[R1]] +; GENERIC: strb [[R12]] +; GENERIC: strb [[R3]] +; GENERIC: strb [[R2]] ; DARWIN_V6: t: ; DARWIN_V6: ldr r1 Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Apr 29 20:37:52 2011 @@ -14,19 +14,19 @@ bb.nph: ; preds = %entry ; CHECK: BB#1 -; CHECK: movw r2, :lower16:L_GV$non_lazy_ptr -; CHECK: movt r2, :upper16:L_GV$non_lazy_ptr -; CHECK: ldr r2, [r2] -; CHECK: ldr r3, [r2] +; CHECK: movw r[[R2:[0-9]+]], :lower16:L_GV$non_lazy_ptr +; CHECK: movt r[[R2]], :upper16:L_GV$non_lazy_ptr +; CHECK: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] +; CHECK: ldr{{.*}}, [r[[R2b]] ; CHECK: LBB0_2 ; CHECK-NOT: LCPI0_0: ; PIC: BB#1 -; PIC: movw r2, :lower16:(L_GV$non_lazy_ptr-(LPC0_0+4)) -; PIC: movt r2, :upper16:(L_GV$non_lazy_ptr-(LPC0_0+4)) -; PIC: add r2, pc -; PIC: ldr r2, [r2] -; PIC: ldr r3, [r2] +; PIC: movw r[[R2:[0-9]+]], :lower16:(L_GV$non_lazy_ptr-(LPC0_0+4)) +; PIC: movt r[[R2]], :upper16:(L_GV$non_lazy_ptr-(LPC0_0+4)) +; PIC: add r[[R2]], pc +; PIC: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] +; PIC: ldr{{.*}}, [r[[R2b]] ; PIC: LBB0_2 ; PIC-NOT: LCPI0_0: ; PIC: .section @@ -89,7 +89,7 @@ ; CHECK: bb.nph ; CHECK: movw {{(r[0-9])|(lr)}}, #32768 ; CHECK: movs {{(r[0-9]+)|(lr)}}, #0 -; CHECK: movw [[REGISTER:(r[0-9])|(lr)]], #16386 +; CHECK: movw [[REGISTER:(r[0-9]+)|(lr)]], #16386 ; CHECK: movw {{(r[0-9]+)|(lr)}}, #65534 ; CHECK: movt {{(r[0-9]+)|(lr)}}, #65535 br label %bb Modified: llvm/trunk/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll?rev=130567&r1=130566&r2=130567&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll Fri Apr 29 20:37:52 2011 @@ -18,7 +18,7 @@ ret i32 0 } -; CHECK: movq ___stack_chk_guard at GOTPCREL(%rip), %rax +; CHECK: movq ___stack_chk_guard at GOTPCREL(%rip) ; CHECK: movb 38(%rsp), [[R0:%.+]] ; CHECK: movb 8(%rsp), [[R1:%.+]] ; CHECK: movb [[R1]], 8(%rsp) From stoklund at 2pi.dk Fri Apr 29 20:37:54 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 01:37:54 -0000 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp Message-ID: <20110430013754.E6BA62A6C138@llvm.org> Author: stoklund Date: Fri Apr 29 20:37:54 2011 New Revision: 130568 URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev Log: Use a greedy algorithm for allocating registers. Modified: llvm/trunk/lib/CodeGen/Passes.cpp Modified: llvm/trunk/lib/CodeGen/Passes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130568&r1=130567&r2=130568&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Passes.cpp (original) +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 20:37:54 2011 @@ -57,8 +57,8 @@ // This forces linking of the greedy register allocator, so -regalloc=greedy // works in clang. - if (Ctor == createGreedyRegisterAllocator) - return createGreedyRegisterAllocator(); + if (Ctor == createLinearScanRegisterAllocator) + return createLinearScanRegisterAllocator(); if (Ctor != createDefaultRegisterAllocator) return Ctor(); @@ -68,6 +68,6 @@ case CodeGenOpt::None: return createFastRegisterAllocator(); default: - return createLinearScanRegisterAllocator(); + return createGreedyRegisterAllocator(); } } From daniel at zuster.org Fri Apr 29 21:04:17 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 02:04:17 -0000 Subject: [llvm-commits] [zorg] r130571 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110430020417.B29CD2A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 21:04:17 2011 New Revision: 130571 URL: http://llvm.org/viewvc/llvm-project?rev=130571&view=rev Log: LNT/nt: Change --without-llvm to be the default if no explicit LLVM paths are given. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130571&r1=130570&r2=130571&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Apr 29 21:04:17 2011 @@ -778,6 +778,10 @@ nick, = args + # The --without--llvm option is the default if no LLVM paths are given. + if opts.llvm_src_root is None and opts.llvm_obj_root is None: + opts.without_llvm = True + # Validate options. if opts.sandbox_path is None: From daniel at zuster.org Fri Apr 29 21:04:44 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 02:04:44 -0000 Subject: [llvm-commits] [zorg] r130572 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110430020444.643992A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 21:04:44 2011 New Revision: 130572 URL: http://llvm.org/viewvc/llvm-project?rev=130572&view=rev Log: LNT/nt: Add --test-style argument and swith to TEST=simple being the default. - The --simple argument is deprecated. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130572&r1=130571&r2=130572&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Apr 29 21:04:44 2011 @@ -46,8 +46,8 @@ 'TARGET_FLAGS' : ' '.join(target_flags), } - # Compute TARGET_LLCFLAGS, for non-TEST=simple runs. - if not opts.test_simple: + # Compute TARGET_LLCFLAGS, for TEST=nightly runs. + if opts.test_style == "nightly": # Compute TARGET_LLCFLAGS. target_llcflags = [] if opts.mcpu is not None: @@ -128,14 +128,11 @@ make_variables['ENABLE_PARALLEL_REPORT'] = '1' # Select the test style to use. - if opts.test_simple: - test_style = 'simple' + if opts.test_style == "simple": # We always use reference outputs with TEST=simple. make_variables['ENABLE_HASHED_PROGRAM_OUTPUT'] = '1' make_variables['USE_REFERENCE_OUTPUT'] = '1' - else: - test_style = 'nightly' - make_variables['TEST'] = test_style + make_variables['TEST'] = opts.test_style # Support disabling test suite externals separately from providing path. if not opts.test_externals: @@ -319,7 +316,7 @@ report_path = os.path.join(basedir) if opts.only_test is not None: report_path = os.path.join(report_path, opts.only_test) - report_path = os.path.join(report_path, 'report.%s.csv' % test_style) + report_path = os.path.join(report_path, 'report.%s.csv' % opts.test_style) if os.path.exists(report_path): os.remove(report_path) @@ -328,7 +325,7 @@ test_log = open(test_log_path, 'w') args = ['make', '-k', '-j', str(opts.threads), - 'report', 'report.%s.csv' % test_style] + 'report', 'report.%s.csv' % opts.test_style] args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) if opts.only_test is not None: args.extend(['-C',opts.only_test]) @@ -351,7 +348,7 @@ # Compute the test samples to report. sample_keys = [] - if opts.test_simple: + if opts.test_style == "simple": test_namespace = 'nts' sample_keys.append(('compile', 'CC_Time', None, 'CC')) sample_keys.append(('exec', 'Exec_Time', None, 'Exec')) @@ -696,6 +693,9 @@ group.add_option("", "--simple", dest="test_simple", help="Use TEST=simple instead of TEST=nightly", action="store_true", default=False) + group.add_option("", "--test-style", dest="test_style", + help="Set the test style to run [%default]", + choices=('nightly', 'simple'), default='simple') group.add_option("", "--disable-cxx", dest="test_cxx", help="Disable C++ tests", @@ -787,7 +787,12 @@ if opts.sandbox_path is None: parser.error('--sandbox is required') + # Deprecate --simple. if opts.test_simple: + warning("--simple is deprecated, it is the default.") + del opts.test_simple + + if opts.test_style == "simple": # TEST=simple doesn't use a reference compiler. if opts.cc_reference is not None: parser.error('--cc-reference is unused with --simple') From daniel at zuster.org Fri Apr 29 22:04:20 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 03:04:20 -0000 Subject: [llvm-commits] [test-suite] r130578 - /test-suite/trunk/Makefile.programs Message-ID: <20110430030420.DBC872A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 22:04:20 2011 New Revision: 130578 URL: http://llvm.org/viewvc/llvm-project?rev=130578&view=rev Log: build: Add support for an EXECUTION_ENVIRONMENT_OVERRIDES variable, which can used to override various environment variables for test execution. Useful for tweaking things like dyld library paths, for example. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=130578&r1=130577&r2=130578&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Fri Apr 29 22:04:20 2011 @@ -145,6 +145,10 @@ RUNSAFELYLOCAL := $(RUNSAFELYLOCAL) $(RUNTIMELIMIT) $(EXIT_OK) endif +ifdef EXECUTION_ENVIRONMENT_OVERRIDES +RUNSAFELY := $(RUNSAFELY) -u 'env $(EXECUTION_ENVIRONMENT_OVERRIDES)' $(RUNSAFELY) +endif + RUNTOOLSAFELY := $(PROGDIR)/RunToolSafely.sh $(RUNTIMELIMIT) ifndef STDIN_FILENAME From daniel at zuster.org Fri Apr 29 22:07:02 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 03:07:02 -0000 Subject: [llvm-commits] [zorg] r130579 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110430030702.1886A2A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 22:07:01 2011 New Revision: 130579 URL: http://llvm.org/viewvc/llvm-project?rev=130579&view=rev Log: LNT/nt: Update help text to drop --without-llvm and --simple. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130579&r1=130578&r2=130579&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Apr 29 22:07:01 2011 @@ -575,14 +575,13 @@ --sandbox FOO \\ --cc ~/llvm.obj.64/Release/bin/clang \\ --cxx ~/llvm.obj.64/Release/bin/clang++ \\ - --without-llvm --simple \\ --test-suite ~/llvm-test-suite \\ FOO where --sandbox is the directory to build and store results in, --cc and --cxx -are the full paths to the compilers to test, and the remaining options are paths -to the LLVM source tree, LLVM object tree, and test-suite source tree. The final -argument is the base nickname to use to describe this run in reports. +are the full paths to the compilers to test, and --test-suite is the path to the +test-suite source. The final argument is the base nickname to use to describe +this run in reports. To do a quick test, you can add something like: From daniel at zuster.org Fri Apr 29 22:07:04 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 03:07:04 -0000 Subject: [llvm-commits] [zorg] r130580 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110430030704.9D83F2A6C138@llvm.org> Author: ddunbar Date: Fri Apr 29 22:07:04 2011 New Revision: 130580 URL: http://llvm.org/viewvc/llvm-project?rev=130580&view=rev Log: LNT/nt: Add an option to make it easier to run tests under the Darwin iOS simulator. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130580&r1=130579&r2=130580&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Apr 29 22:07:04 2011 @@ -59,7 +59,22 @@ if opts.disable_fp_elim: target_llcflags.append('-disable-fp-elim') make_variables['TARGET_LLCFLAGS'] = ' '.join(target_llcflags) - + + # Set up environment overrides if requested, to effectively run under the + # specified the Darwin iOS simulator. + # + # See /D/P/../Developer/Tools/RunPlatformUnitTests. + if opts.ios_simulator_sdk is not None: + make_variables['EXECUTION_ENVIRONMENT_OVERRIDES'] = ' '.join( + ['DYLD_FRAMEWORK_PATH="%s"' % opts.ios_simulator_sdk, + 'DYLD_LIBRARY_PATH=""', + 'DYLD_ROOT_PATH="%s"' % opts.ios_simulator_sdk, + 'DYLD_NEW_LOCAL_SHARED_REGIONS=YES', + 'DYLD_NO_FIX_PREBINDING=YES', + 'IPHONE_SIMULATOR_ROOT="%s"' % opts.ios_simulator_sdk, + 'CFFIXED_USER_HOME="%s"' % os.path.expanduser( + "~/Library/Application Support/iPhone Simulator/User")]) + # Pick apart the build mode. build_mode = opts.build_mode if build_mode.startswith("Debug"): @@ -753,6 +768,11 @@ help="Set remote execution client [%default]", type=str, default="ssh", metavar="RSH",) + group.add_option("", "--use-ios-simulator", dest="ios_simulator_sdk", + help=("Execute using an iOS simulator SDK (using " + "environment overrides)"), + type=str, default=None, metavar="SDKPATH") + group.add_option("", "--multisample", dest="multisample", help="Accumulate test data from multiple runs", type=int, default=None, metavar="N") @@ -874,6 +894,16 @@ parser.error('invalid --liblto-path argument %r' % ( opts.liblto_path,)) + # Set up iOS simulator options. + if opts.ios_simulator_sdk: + # Warn if the user asked to run under an iOS simulator SDK, but + # didn't set an isysroot for compilation. + if opts.isysroot is None: + warning('expected --isysroot when executing with ' + '--ios-simulator-sdk') + + opts.isysroot = opts.ios_simulator_sdk + # FIXME: We need to validate that there is no configured output in the # test-suite directory, that borks things. From nicholas at mxc.ca Fri Apr 29 22:15:00 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 29 Apr 2011 20:15:00 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <20110430013754.E6BA62A6C138@llvm.org> References: <20110430013754.E6BA62A6C138@llvm.org> Message-ID: <4DBB7EB4.3050801@mxc.ca> On 04/29/2011 06:37 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Fri Apr 29 20:37:54 2011 > New Revision: 130568 > > URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev > Log: > Use a greedy algorithm for allocating registers. > > Modified: > llvm/trunk/lib/CodeGen/Passes.cpp > > Modified: llvm/trunk/lib/CodeGen/Passes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130568&r1=130567&r2=130568&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/Passes.cpp (original) > +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 20:37:54 2011 > @@ -57,8 +57,8 @@ > > // This forces linking of the greedy register allocator, so -regalloc=greedy > // works in clang. Update this comment? > - if (Ctor == createGreedyRegisterAllocator) > - return createGreedyRegisterAllocator(); > + if (Ctor == createLinearScanRegisterAllocator) > + return createLinearScanRegisterAllocator(); > > if (Ctor != createDefaultRegisterAllocator) > return Ctor(); > @@ -68,6 +68,6 @@ > case CodeGenOpt::None: > return createFastRegisterAllocator(); > default: > - return createLinearScanRegisterAllocator(); > + return createGreedyRegisterAllocator(); > } > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From stoklund at 2pi.dk Fri Apr 29 22:13:08 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 03:13:08 -0000 Subject: [llvm-commits] [llvm] r130582 - /llvm/trunk/lib/CodeGen/Passes.cpp Message-ID: <20110430031308.745382A6C135@llvm.org> Author: stoklund Date: Fri Apr 29 22:13:08 2011 New Revision: 130582 URL: http://llvm.org/viewvc/llvm-project?rev=130582&view=rev Log: Update comment. Modified: llvm/trunk/lib/CodeGen/Passes.cpp Modified: llvm/trunk/lib/CodeGen/Passes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130582&r1=130581&r2=130582&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Passes.cpp (original) +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 22:13:08 2011 @@ -55,8 +55,8 @@ RegisterRegAlloc::setDefault(RegAlloc); } - // This forces linking of the greedy register allocator, so -regalloc=greedy - // works in clang. + // This forces linking of the linear scan register allocator, + // so -regalloc=linearscan still works in clang. if (Ctor == createLinearScanRegisterAllocator) return createLinearScanRegisterAllocator(); From daniel at zuster.org Fri Apr 29 22:13:37 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Sat, 30 Apr 2011 03:13:37 -0000 Subject: [llvm-commits] [zorg] r130584 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20110430031337.D8FFF2A6C135@llvm.org> Author: ddunbar Date: Fri Apr 29 22:13:37 2011 New Revision: 130584 URL: http://llvm.org/viewvc/llvm-project?rev=130584&view=rev Log: LNT/nt: Don't force the isysroot when using --use-ios-simulator-sdk, we want to be able to build and test against different SDKs. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=130584&r1=130583&r2=130584&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Apr 29 22:13:37 2011 @@ -902,8 +902,6 @@ warning('expected --isysroot when executing with ' '--ios-simulator-sdk') - opts.isysroot = opts.ios_simulator_sdk - # FIXME: We need to validate that there is no configured output in the # test-suite directory, that borks things. From stoklund at 2pi.dk Fri Apr 29 22:18:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 29 Apr 2011 20:18:36 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <4DBB7EB4.3050801@mxc.ca> References: <20110430013754.E6BA62A6C138@llvm.org> <4DBB7EB4.3050801@mxc.ca> Message-ID: On Apr 29, 2011, at 8:15 PM, Nick Lewycky wrote: > On 04/29/2011 06:37 PM, Jakob Stoklund Olesen wrote: >> Author: stoklund >> Date: Fri Apr 29 20:37:54 2011 >> New Revision: 130568 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev >> Log: >> Use a greedy algorithm for allocating registers. >> >> Modified: >> llvm/trunk/lib/CodeGen/Passes.cpp >> >> Modified: llvm/trunk/lib/CodeGen/Passes.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130568&r1=130567&r2=130568&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/Passes.cpp (original) >> +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 20:37:54 2011 >> @@ -57,8 +57,8 @@ >> >> // This forces linking of the greedy register allocator, so -regalloc=greedy >> // works in clang. > > Update this comment? Fixed in r130582, thanks! /jakob From rafael.espindola at gmail.com Fri Apr 29 22:21:04 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 03:21:04 -0000 Subject: [llvm-commits] [llvm] r130585 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/MC/MCAsmStreamer.cpp lib/MC/MCObjectStreamer.cpp lib/MC/MCStreamer.cpp Message-ID: <20110430032104.7E2892A6C135@llvm.org> Author: rafael Date: Fri Apr 29 22:21:04 2011 New Revision: 130585 URL: http://llvm.org/viewvc/llvm-project?rev=130585&view=rev Log: Implement MCAsmStreamer::EmitDwarfAdvanceFrameAddr. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=130585&r1=130584&r2=130585&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Fri Apr 29 22:21:04 2011 @@ -67,6 +67,12 @@ protected: MCStreamer(MCContext &Ctx); + const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, + const MCSymbol *B); + + const MCExpr *ForceExpAbs(MCStreamer *Streamer, MCContext &Context, + const MCExpr* Expr); + public: virtual ~MCStreamer(); Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130585&r1=130584&r2=130585&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Apr 29 22:21:04 2011 @@ -127,6 +127,8 @@ virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label); + virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, + const MCSymbol *Label); virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); @@ -324,6 +326,15 @@ getContext().getTargetAsmInfo().getPointerSize()); } +void MCAsmStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, + const MCSymbol *Label) { + EmitIntValue(dwarf::DW_CFA_advance_loc4, 1); + const MCExpr *AddrDelta = BuildSymbolDiff(getContext(), Label, LastLabel); + AddrDelta = ForceExpAbs(this, getContext(), AddrDelta); + EmitValue(AddrDelta, 4); +} + + void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) { switch (Attribute) { Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=130585&r1=130584&r2=130585&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Fri Apr 29 22:21:04 2011 @@ -121,16 +121,6 @@ SD.setOffset(F->getContents().size()); } -static const MCExpr *ForceExpAbs(MCObjectStreamer *Streamer, - MCContext &Context, const MCExpr* Expr) { - if (Context.getAsmInfo().hasAggressiveSymbolFolding()) - return Expr; - - MCSymbol *ABS = Context.CreateTempSymbol(); - Streamer->EmitAssignment(ABS, Expr); - return MCSymbolRefExpr::Create(ABS, Context); -} - void MCObjectStreamer::EmitULEB128Value(const MCExpr *Value) { int64_t IntValue; if (Value->EvaluateAsAbsolute(IntValue, getAssembler())) { @@ -205,18 +195,6 @@ IF->getCode().append(Code.begin(), Code.end()); } -static const MCExpr *BuildSymbolDiff(MCContext &Context, - const MCSymbol *A, const MCSymbol *B) { - MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; - const MCExpr *ARef = - MCSymbolRefExpr::Create(A, Variant, Context); - const MCExpr *BRef = - MCSymbolRefExpr::Create(B, Variant, Context); - const MCExpr *AddrDelta = - MCBinaryExpr::Create(MCBinaryExpr::Sub, ARef, BRef, Context); - return AddrDelta; -} - void MCObjectStreamer::EmitDwarfAdvanceLineAddr(int64_t LineDelta, const MCSymbol *LastLabel, const MCSymbol *Label) { Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=130585&r1=130584&r2=130585&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Fri Apr 29 22:21:04 2011 @@ -28,6 +28,29 @@ MCStreamer::~MCStreamer() { } +const MCExpr *MCStreamer::BuildSymbolDiff(MCContext &Context, + const MCSymbol *A, + const MCSymbol *B) { + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + const MCExpr *ARef = + MCSymbolRefExpr::Create(A, Variant, Context); + const MCExpr *BRef = + MCSymbolRefExpr::Create(B, Variant, Context); + const MCExpr *AddrDelta = + MCBinaryExpr::Create(MCBinaryExpr::Sub, ARef, BRef, Context); + return AddrDelta; +} + +const MCExpr *MCStreamer::ForceExpAbs(MCStreamer *Streamer, + MCContext &Context, const MCExpr* Expr) { + if (Context.getAsmInfo().hasAggressiveSymbolFolding()) + return Expr; + + MCSymbol *ABS = Context.CreateTempSymbol(); + Streamer->EmitAssignment(ABS, Expr); + return MCSymbolRefExpr::Create(ABS, Context); +} + raw_ostream &MCStreamer::GetCommentOS() { // By default, discard comments. return nulls(); From rafael.espindola at gmail.com Fri Apr 29 22:44:38 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 03:44:38 -0000 Subject: [llvm-commits] [llvm] r130587 - in /llvm/trunk: include/llvm/MC/MCStreamer.h include/llvm/Target/TargetMachine.h include/llvm/Target/TargetRegistry.h lib/CodeGen/LLVMTargetMachine.cpp lib/MC/MCAsmStreamer.cpp lib/Target/PTX/PTXMCAsmStreamer.cpp lib/Target/PTX/PTXTargetMachine.cpp lib/Target/TargetMachine.cpp tools/llc/llc.cpp tools/llvm-mc/llvm-mc.cpp Message-ID: <20110430034438.1BC852A6C135@llvm.org> Author: rafael Date: Fri Apr 29 22:44:37 2011 New Revision: 130587 URL: http://llvm.org/viewvc/llvm-project?rev=130587&view=rev Log: Add all the plumbing needed for MC to expand cfi to the old tables in the final assembly. It is the same technique used when targeting assemblers that don't support .loc. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/include/llvm/Target/TargetMachine.h llvm/trunk/include/llvm/Target/TargetRegistry.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp llvm/trunk/lib/Target/TargetMachine.cpp llvm/trunk/tools/llc/llc.cpp llvm/trunk/tools/llvm-mc/llvm-mc.cpp Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Fri Apr 29 22:44:37 2011 @@ -510,6 +510,7 @@ MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, + bool useCFI, MCInstPrinter *InstPrint = 0, MCCodeEmitter *CE = 0, TargetAsmBackend *TAB = 0, Modified: llvm/trunk/include/llvm/Target/TargetMachine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetMachine.h (original) +++ llvm/trunk/include/llvm/Target/TargetMachine.h Fri Apr 29 22:44:37 2011 @@ -108,6 +108,7 @@ unsigned MCNoExecStack : 1; unsigned MCSaveTempLabels : 1; unsigned MCUseLoc : 1; + unsigned MCUseCFI : 1; public: virtual ~TargetMachine(); @@ -193,6 +194,12 @@ /// setMCUseLoc - Set whether all we should use dwarf's .loc directive. void setMCUseLoc(bool Value) { MCUseLoc = Value; } + /// hasMCUseCFI - Check whether we should use dwarf's .cfi_* directives. + bool hasMCUseCFI() const { return MCUseCFI; } + + /// setMCUseCFI - Set whether all we should use dwarf's .cfi_* directives. + void setMCUseCFI(bool Value) { MCUseCFI = Value; } + /// getRelocationModel - Returns the code generation relocation model. The /// choices are static, PIC, and dynamic-no-pic, and target default. static Reloc::Model getRelocationModel(); Modified: llvm/trunk/include/llvm/Target/TargetRegistry.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegistry.h?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegistry.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegistry.h Fri Apr 29 22:44:37 2011 @@ -43,7 +43,7 @@ MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, bool isVerboseAsm, - bool useLoc, + bool useLoc, bool useCFI, MCInstPrinter *InstPrint, MCCodeEmitter *CE, TargetAsmBackend *TAB, @@ -96,6 +96,7 @@ formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, + bool useCFI, MCInstPrinter *InstPrint, MCCodeEmitter *CE, TargetAsmBackend *TAB, @@ -329,12 +330,13 @@ formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, + bool useCFI, MCInstPrinter *InstPrint, MCCodeEmitter *CE, TargetAsmBackend *TAB, bool ShowInst) const { // AsmStreamerCtorFn is default to llvm::createAsmStreamer - return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, + return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI, InstPrint, CE, TAB, ShowInst); } Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Apr 29 22:44:37 2011 @@ -149,6 +149,7 @@ MCStreamer *S = getTarget().createAsmStreamer(*Context, Out, getVerboseAsm(), hasMCUseLoc(), + hasMCUseCFI(), InstPrinter, MCE, TAB, ShowMCInst); Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Fri Apr 29 22:44:37 2011 @@ -45,20 +45,20 @@ unsigned IsVerboseAsm : 1; unsigned ShowInst : 1; unsigned UseLoc : 1; + unsigned UseCFI : 1; bool needsSet(const MCExpr *Value); public: MCAsmStreamer(MCContext &Context, formatted_raw_ostream &os, - bool isVerboseAsm, - bool useLoc, + bool isVerboseAsm, bool useLoc, bool useCFI, MCInstPrinter *printer, MCCodeEmitter *emitter, TargetAsmBackend *asmbackend, bool showInst) : MCStreamer(Context), OS(os), MAI(Context.getAsmInfo()), InstPrinter(printer), Emitter(emitter), AsmBackend(asmbackend), CommentStream(CommentToEmit), IsVerboseAsm(isVerboseAsm), - ShowInst(showInst), UseLoc(useLoc) { + ShowInst(showInst), UseLoc(useLoc), UseCFI(useCFI) { if (InstPrinter && IsVerboseAsm) InstPrinter->setCommentStream(CommentStream); } @@ -740,6 +740,9 @@ void MCAsmStreamer::EmitCFIStartProc() { MCStreamer::EmitCFIStartProc(); + if (!UseCFI) + return; + OS << "\t.cfi_startproc"; EmitEOL(); } @@ -747,6 +750,9 @@ void MCAsmStreamer::EmitCFIEndProc() { MCStreamer::EmitCFIEndProc(); + if (!UseCFI) + return; + OS << "\t.cfi_endproc"; EmitEOL(); } @@ -754,6 +760,9 @@ void MCAsmStreamer::EmitCFIDefCfa(int64_t Register, int64_t Offset) { MCStreamer::EmitCFIDefCfa(Register, Offset); + if (!UseCFI) + return; + OS << ".cfi_def_cfa " << Register << ", " << Offset; EmitEOL(); } @@ -761,6 +770,9 @@ void MCAsmStreamer::EmitCFIDefCfaOffset(int64_t Offset) { MCStreamer::EmitCFIDefCfaOffset(Offset); + if (!UseCFI) + return; + OS << "\t.cfi_def_cfa_offset " << Offset; EmitEOL(); } @@ -768,6 +780,9 @@ void MCAsmStreamer::EmitCFIDefCfaRegister(int64_t Register) { MCStreamer::EmitCFIDefCfaRegister(Register); + if (!UseCFI) + return; + OS << "\t.cfi_def_cfa_register " << Register; EmitEOL(); } @@ -775,6 +790,9 @@ void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) { this->MCStreamer::EmitCFIOffset(Register, Offset); + if (!UseCFI) + return; + OS << "\t.cfi_offset " << Register << ", " << Offset; EmitEOL(); } @@ -783,6 +801,9 @@ unsigned Encoding) { MCStreamer::EmitCFIPersonality(Sym, Encoding); + if (!UseCFI) + return; + OS << "\t.cfi_personality " << Encoding << ", " << *Sym; EmitEOL(); } @@ -790,6 +811,9 @@ void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) { MCStreamer::EmitCFILsda(Sym, Encoding); + if (!UseCFI) + return; + OS << "\t.cfi_lsda " << Encoding << ", " << *Sym; EmitEOL(); } @@ -797,6 +821,9 @@ void MCAsmStreamer::EmitCFIRememberState() { MCStreamer::EmitCFIRememberState(); + if (!UseCFI) + return; + OS << "\t.cfi_remember_state"; EmitEOL(); } @@ -804,6 +831,9 @@ void MCAsmStreamer::EmitCFIRestoreState() { MCStreamer::EmitCFIRestoreState(); + if (!UseCFI) + return; + OS << "\t.cfi_restore_state"; EmitEOL(); } @@ -811,6 +841,9 @@ void MCAsmStreamer::EmitCFISameValue(int64_t Register) { MCStreamer::EmitCFISameValue(Register); + if (!UseCFI) + return; + OS << "\t.cfi_same_value " << Register; EmitEOL(); } @@ -818,6 +851,9 @@ void MCAsmStreamer::EmitCFIRelOffset(int64_t Register, int64_t Offset) { MCStreamer::EmitCFIRelOffset(Register, Offset); + if (!UseCFI) + return; + OS << "\t.cfi_rel_offset " << Register << ", " << Offset; EmitEOL(); } @@ -825,6 +861,9 @@ void MCAsmStreamer::EmitCFIAdjustCfaOffset(int64_t Adjustment) { MCStreamer::EmitCFIAdjustCfaOffset(Adjustment); + if (!UseCFI) + return; + OS << "\t.cfi_adjust_cfa_offset " << Adjustment; EmitEOL(); } @@ -1008,8 +1047,9 @@ MCStreamer *llvm::createAsmStreamer(MCContext &Context, formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, + bool useCFI, MCInstPrinter *IP, MCCodeEmitter *CE, TargetAsmBackend *TAB, bool ShowInst) { - return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, + return new MCAsmStreamer(Context, OS, isVerboseAsm, useLoc, useCFI, IP, CE, TAB, ShowInst); } Modified: llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Fri Apr 29 22:44:37 2011 @@ -531,7 +531,7 @@ namespace llvm { MCStreamer *createPTXAsmStreamer(MCContext &Context, formatted_raw_ostream &OS, - bool isVerboseAsm, bool useLoc, + bool isVerboseAsm, bool useLoc, bool useCFI, MCInstPrinter *IP, MCCodeEmitter *CE, TargetAsmBackend *TAB, bool ShowInst) { Modified: llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXTargetMachine.cpp Fri Apr 29 22:44:37 2011 @@ -23,6 +23,7 @@ namespace llvm { MCStreamer *createPTXAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, + bool useCFI, MCInstPrinter *InstPrint, MCCodeEmitter *CE, TargetAsmBackend *TAB, Modified: llvm/trunk/lib/Target/TargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetMachine.cpp (original) +++ llvm/trunk/lib/Target/TargetMachine.cpp Fri Apr 29 22:44:37 2011 @@ -227,7 +227,8 @@ MCRelaxAll(false), MCNoExecStack(false), MCSaveTempLabels(false), - MCUseLoc(true) { + MCUseLoc(true), + MCUseCFI(true) { // Typically it will be subtargets that will adjust FloatABIType from Default // to Soft or Hard. if (UseSoftFloat) Modified: llvm/trunk/tools/llc/llc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/tools/llc/llc.cpp (original) +++ llvm/trunk/tools/llc/llc.cpp Fri Apr 29 22:44:37 2011 @@ -99,6 +99,9 @@ cl::opt DisableDotLoc("disable-dot-loc", cl::Hidden, cl::desc("Do not use .loc entries")); +cl::opt DisableCFI("disable-cfi", cl::Hidden, + cl::desc("Do not use .cfi_* directives")); + static cl::opt DisableRedZone("disable-red-zone", cl::desc("Do not emit code that uses the red zone."), @@ -279,6 +282,9 @@ if (DisableDotLoc) Target.setMCUseLoc(false); + if (DisableCFI) + Target.setMCUseCFI(false); + // Disable .loc support for older OS X versions. if (TheTriple.isMacOSX() && TheTriple.isMacOSXVersionLT(10, 6)) Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=130587&r1=130586&r2=130587&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Fri Apr 29 22:44:37 2011 @@ -356,7 +356,8 @@ TAB = TheTarget->createAsmBackend(TripleName); } Str.reset(TheTarget->createAsmStreamer(Ctx, FOS, /*asmverbose*/true, - /*useLoc*/ true, IP, CE, TAB, + /*useLoc*/ true, + /*useCFI*/ true, IP, CE, TAB, ShowInst)); } else if (FileType == OFT_Null) { Str.reset(createNullStreamer(Ctx)); From geek4civic at gmail.com Fri Apr 29 22:53:56 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Sat, 30 Apr 2011 03:53:56 -0000 Subject: [llvm-commits] [llvm] r130589 - /llvm/trunk/runtime/libprofile/PathProfiling.c Message-ID: <20110430035356.2E1252A6C135@llvm.org> Author: chapuni Date: Fri Apr 29 22:53:56 2011 New Revision: 130589 URL: http://llvm.org/viewvc/llvm-project?rev=130589&view=rev Log: runtime/libprofile/PathProfiling.c: Don't use // comment in C source. Modified: llvm/trunk/runtime/libprofile/PathProfiling.c Modified: llvm/trunk/runtime/libprofile/PathProfiling.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtime/libprofile/PathProfiling.c?rev=130589&r1=130588&r2=130589&view=diff ============================================================================== --- llvm/trunk/runtime/libprofile/PathProfiling.c (original) +++ llvm/trunk/runtime/libprofile/PathProfiling.c Fri Apr 29 22:53:56 2011 @@ -26,7 +26,7 @@ #include #include -// Must use __inline in Microsoft C +/* Must use __inline in Microsoft C */ #if defined(_MSC_VER) #define inline __inline #endif From rafael.espindola at gmail.com Fri Apr 29 23:06:34 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 04:06:34 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Message-ID: <20110430040634.BE8612A6C135@llvm.org> Author: rafael Date: Fri Apr 29 23:06:34 2011 New Revision: 130590 URL: http://llvm.org/viewvc/llvm-project?rev=130590&view=rev Log: Don't use the CFI directives in llvm-gcc. Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=130590&r1=130589&r2=130590&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Fri Apr 29 23:06:34 2011 @@ -551,6 +551,7 @@ TheTarget = TME->createTargetMachine(TargetTriple, FeatureStr); TheTarget->setMCUseLoc(false); + TheTarget->setMCUseCFI(false); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); TheFolder = new TargetFolder(TheTarget->getTargetData()); From evan.cheng at apple.com Fri Apr 29 23:47:26 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Fri, 29 Apr 2011 21:47:26 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <20110430013754.E6BA62A6C138@llvm.org> References: <20110430013754.E6BA62A6C138@llvm.org> Message-ID: <850C4F2D-922F-4404-8321-D500A4686282@apple.com> Yayyyy!!! Congratulations! Evan On Apr 29, 2011, at 6:37 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Fri Apr 29 20:37:54 2011 > New Revision: 130568 > > URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev > Log: > Use a greedy algorithm for allocating registers. > > Modified: > llvm/trunk/lib/CodeGen/Passes.cpp > > Modified: llvm/trunk/lib/CodeGen/Passes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130568&r1=130567&r2=130568&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/Passes.cpp (original) > +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 20:37:54 2011 > @@ -57,8 +57,8 @@ > > // This forces linking of the greedy register allocator, so -regalloc=greedy > // works in clang. > - if (Ctor == createGreedyRegisterAllocator) > - return createGreedyRegisterAllocator(); > + if (Ctor == createLinearScanRegisterAllocator) > + return createLinearScanRegisterAllocator(); > > if (Ctor != createDefaultRegisterAllocator) > return Ctor(); > @@ -68,6 +68,6 @@ > case CodeGenOpt::None: > return createFastRegisterAllocator(); > default: > - return createLinearScanRegisterAllocator(); > + return createGreedyRegisterAllocator(); > } > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Sat Apr 30 00:07:46 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 05:07:46 -0000 Subject: [llvm-commits] [llvm] r130596 - /llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Message-ID: <20110430050746.818C72A6C135@llvm.org> Author: stoklund Date: Sat Apr 30 00:07:46 2011 New Revision: 130596 URL: http://llvm.org/viewvc/llvm-project?rev=130596&view=rev Log: Use hysteresis for local live range splitting as well. Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Modified: llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp?rev=130596&r1=130595&r2=130596&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocGreedy.cpp Sat Apr 30 00:07:46 2011 @@ -1225,13 +1225,13 @@ PrevSlot[SplitBefore].distance(Uses[SplitAfter])); // Would this split be possible to allocate? // Never allocate all gaps, we wouldn't be making progress. - float Diff = EstWeight - MaxGap; - DEBUG(dbgs() << " w=" << EstWeight << " d=" << Diff); - if (Diff > 0) { + DEBUG(dbgs() << " w=" << EstWeight); + if (EstWeight * Hysteresis >= MaxGap) { Shrink = false; + float Diff = EstWeight - MaxGap; if (Diff > BestDiff) { DEBUG(dbgs() << " (best)"); - BestDiff = Diff; + BestDiff = Hysteresis * Diff; BestBefore = SplitBefore; BestAfter = SplitAfter; } From echristo at apple.com Sat Apr 30 01:17:29 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 29 Apr 2011 23:17:29 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <20110430013754.E6BA62A6C138@llvm.org> References: <20110430013754.E6BA62A6C138@llvm.org> Message-ID: On Apr 29, 2011, at 6:37 PM, Jakob Stoklund Olesen wrote: > Author: stoklund > Date: Fri Apr 29 20:37:54 2011 > New Revision: 130568 > > URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev > Log: > Use a greedy algorithm for allocating registers. Congratulations Jakob! -eric From anton at korobeynikov.info Sat Apr 30 01:28:18 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 30 Apr 2011 10:28:18 +0400 Subject: [llvm-commits] [llvm] r130544 - /llvm/trunk/lib/MC/MCDwarf.cpp In-Reply-To: <20110429215057.9FB472A6C135@llvm.org> References: <20110429215057.9FB472A6C135@llvm.org> Message-ID: Hi Rafael, > more importantly lets this code be used when producing assembly code for old assemblers without > uleb support. I don't think it's a good idea in general. In such a way we can not emit .cfi stuff at all, because "old assemblers don't support it". The change definitely makes the code less readable, because it emits some magic constants instead of direct label difference. Maybe the stuff can be conditionalized? E.g. via "HasUleb" option or something like this? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Sat Apr 30 01:29:50 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 30 Apr 2011 10:29:50 +0400 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <20110430040634.BE8612A6C135@llvm.org> References: <20110430040634.BE8612A6C135@llvm.org> Message-ID: > URL: http://llvm.org/viewvc/llvm-project?rev=130590&view=rev > Log: > Don't use the CFI directives in llvm-gcc. Can't we check the presence of the "good" assembler during the configure? In the same way the mainline gcc does? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From stoklund at 2pi.dk Sat Apr 30 01:42:21 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 06:42:21 -0000 Subject: [llvm-commits] [llvm] r130597 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/InlineSpiller.cpp Message-ID: <20110430064221.CBAE32A6C135@llvm.org> Author: stoklund Date: Sat Apr 30 01:42:21 2011 New Revision: 130597 URL: http://llvm.org/viewvc/llvm-project?rev=130597&view=rev Log: Avoid using stale entries form the sibling value map. This could happen when trying to use a value that had been eliminated after dead code elimination and folding loads. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/InlineSpiller.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=130597&r1=130596&r2=130597&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Sat Apr 30 01:42:21 2011 @@ -286,6 +286,11 @@ return valnos[ValNo]; } + /// containsValue - Returns true if VNI belongs to this interval. + bool containsValue(const VNInfo *VNI) const { + return VNI && VNI->id < getNumValNums() && VNI == getValNumInfo(VNI->id); + } + /// getNextValue - Create a new value number and return it. MIIdx specifies /// the instruction that defines the value number. VNInfo *getNextValue(SlotIndex def, MachineInstr *CopyMI, Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=130597&r1=130596&r2=130597&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Sat Apr 30 01:42:21 2011 @@ -434,7 +434,7 @@ SlotIndex Idx = LIS.getInstructionIndex(CopyMI); VNInfo *VNI = SpillLI.getVNInfoAt(Idx.getDefIndex()); assert(VNI && VNI->def == Idx.getDefIndex() && "Not defined by copy"); - SibValueMap::const_iterator I = SibValues.find(VNI); + SibValueMap::iterator I = SibValues.find(VNI); if (I == SibValues.end()) return false; @@ -444,6 +444,20 @@ if (!SVI.AllDefsAreReloads && SVI.SpillVNI == VNI) return false; + // SpillReg may have been deleted by remat and DCE. + if (!LIS.hasInterval(SVI.SpillReg)) { + DEBUG(dbgs() << "Stale interval: " << PrintReg(SVI.SpillReg) << '\n'); + SibValues.erase(I); + return false; + } + + LiveInterval &SibLI = LIS.getInterval(SVI.SpillReg); + if (!SibLI.containsValue(SVI.SpillVNI)) { + DEBUG(dbgs() << "Stale value: " << PrintReg(SVI.SpillReg) << '\n'); + SibValues.erase(I); + return false; + } + // Conservatively extend the stack slot range to the range of the original // value. We may be able to do better with stack slot coloring by being more // careful here. @@ -460,14 +474,16 @@ // We are going to spill SVI.SpillVNI immediately after its def, so clear out // any later spills of the same value. - eliminateRedundantSpills(LIS.getInterval(SVI.SpillReg), SVI.SpillVNI); + eliminateRedundantSpills(SibLI, SVI.SpillVNI); MachineBasicBlock *MBB = LIS.getMBBFromIndex(SVI.SpillVNI->def); MachineBasicBlock::iterator MII; if (SVI.SpillVNI->isPHIDef()) MII = MBB->SkipPHIsAndLabels(MBB->begin()); else { - MII = LIS.getInstructionFromIndex(SVI.SpillVNI->def); + MachineInstr *DefMI = LIS.getInstructionFromIndex(SVI.SpillVNI->def); + assert(DefMI && "Defining instruction disappeared"); + MII = DefMI; ++MII; } // Insert spill without kill flag immediately after def. @@ -492,8 +508,8 @@ LiveInterval *LI; tie(LI, VNI) = WorkList.pop_back_val(); unsigned Reg = LI->reg; - DEBUG(dbgs() << "Checking redundant spills for " << PrintReg(Reg) << ':' - << VNI->id << '@' << VNI->def << '\n'); + DEBUG(dbgs() << "Checking redundant spills for " + << VNI->id << '@' << VNI->def << " in " << *LI << '\n'); // Regs to spill are taken care of. if (isRegToSpill(Reg)) From stoklund at 2pi.dk Sat Apr 30 03:00:50 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 08:00:50 -0000 Subject: [llvm-commits] [llvm] r130599 - /llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll Message-ID: <20110430080050.D432A2A6C139@llvm.org> Author: stoklund Date: Sat Apr 30 03:00:50 2011 New Revision: 130599 URL: http://llvm.org/viewvc/llvm-project?rev=130599&view=rev Log: Allow folded spills in test. Modified: llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll Modified: llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll?rev=130599&r1=130598&r2=130599&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-04-25-MMX-PADDQ.ll Sat Apr 30 03:00:50 2011 @@ -8,8 +8,8 @@ bb26: ; preds = %bb26, %entry -; CHECK: addl %e -; CHECK: adcl %e +; CHECK: addl +; CHECK: adcl %i.037.0 = phi i32 [ 0, %entry ], [ %tmp25, %bb26 ] ; [#uses=3] %sum.035.0 = phi <1 x i64> [ zeroinitializer, %entry ], [ %tmp22, %bb26 ] ; <<1 x i64>> [#uses=1] From benny.kra at googlemail.com Sat Apr 30 05:22:56 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 30 Apr 2011 12:22:56 +0200 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> References: <20110429081541.B7F422A6C138@llvm.org> <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> Message-ID: <5F0816C4-4FC4-4F02-8B7E-51858107AC6D@googlemail.com> On 30.04.2011, at 00:00, Devang Patel wrote: > > On Apr 29, 2011, at 2:50 PM, Benjamin Kramer wrote: >> >> Are you sure this specific transformation destroys the DebugLoc? When InstCombine simply replaces one >> instruction with another it preserves debug information (InstructionCombining.cpp:1592). > > I added line 1592 however I am not sure that this particular transformation is covered by 1592 in all cases. I have seen "shl" without DebugLoc generated by instcombine before your patch landed in svn. If you're interested I can send you more info. There is a way this transform can lose a DebugLoc x = C1 << A # with DebugLoc y = x << C2 # without DebugLoc InstCombine will then replace 'y' with a new instruction (but there's no DebugLoc to attach to it) and 'x' is DCE'd. I think the only feasible way to improve here is to find out why 'y' has no debug info attached to it. If you have a test case where InstCombine introduces SHLs without DebugLocs, I'd be interested in seeing it. From baldrick at free.fr Sat Apr 30 07:00:25 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 14:00:25 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: References: <20110430040634.BE8612A6C135@llvm.org> Message-ID: <4DBBF9D9.4090800@free.fr> Hi Anton, >> URL: http://llvm.org/viewvc/llvm-project?rev=130590&view=rev >> Log: >> Don't use the CFI directives in llvm-gcc. > Can't we check the presence of the "good" assembler during the > configure? In the same way the mainline gcc does? do you know how in mainline gcc this information is made available? Then I could condition CFI directives on it in dragonegg. Ciao, Duncan. From baldrick at free.fr Sat Apr 30 07:07:58 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 14:07:58 +0200 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <20110430013754.E6BA62A6C138@llvm.org> References: <20110430013754.E6BA62A6C138@llvm.org> Message-ID: <4DBBFB9E.3020203@free.fr> Hi Jakob, this probably broke the i386 dragonegg buildbot: http://google1.osuosl.org:8011/builders/dragonegg-i386-linux/builds/1251 The failure is: cc1plus: lib/CodeGen/RegAllocGreedy.cpp:809: void::RAGreedy::splitAroundRegion(llvm::LiveInterval&, ::RAGreedy::GlobalSplitCandidate&, llvm::SmallVectorImpl&): Assertion `SegStart >= Intf.last() && "Couldn't avoid interference"' failed. Stack dump: 0. Running pass 'Greedy Register Allocator' on function '@_ZN4llvm16InstrInfoEmitter14GetOperandInfoERKNS_18CodeGenInstructionE' g++: Internal error: Aborted (program cc1plus) I can try to get you a testcase if you like. Ciao, Duncan. > Author: stoklund > Date: Fri Apr 29 20:37:54 2011 > New Revision: 130568 > > URL: http://llvm.org/viewvc/llvm-project?rev=130568&view=rev > Log: > Use a greedy algorithm for allocating registers. > > Modified: > llvm/trunk/lib/CodeGen/Passes.cpp > > Modified: llvm/trunk/lib/CodeGen/Passes.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Passes.cpp?rev=130568&r1=130567&r2=130568&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/Passes.cpp (original) > +++ llvm/trunk/lib/CodeGen/Passes.cpp Fri Apr 29 20:37:54 2011 > @@ -57,8 +57,8 @@ > > // This forces linking of the greedy register allocator, so -regalloc=greedy > // works in clang. > - if (Ctor == createGreedyRegisterAllocator) > - return createGreedyRegisterAllocator(); > + if (Ctor == createLinearScanRegisterAllocator) > + return createLinearScanRegisterAllocator(); > > if (Ctor != createDefaultRegisterAllocator) > return Ctor(); > @@ -68,6 +68,6 @@ > case CodeGenOpt::None: > return createFastRegisterAllocator(); > default: > - return createLinearScanRegisterAllocator(); > + return createGreedyRegisterAllocator(); > } > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From baldrick at free.fr Sat Apr 30 07:23:54 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 14:23:54 +0200 Subject: [llvm-commits] [llvm] r130551 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Utils/BasicBlockUtils.cpp lib/Transforms/Utils/SSAUpdater.cpp In-Reply-To: <20110429222859.4F3242A6C135@llvm.org> References: <20110429222859.4F3242A6C135@llvm.org> Message-ID: <4DBBFF5A.5000505@free.fr> Hi Devang, > +/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a > +/// given basic block. > +DebugLoc llvm::GetFirstDebugLocInBasicBlock(const BasicBlock *BB) { > + for (BasicBlock::const_iterator BI = BB->begin(), BE = BB->end(); > + BI != BE; ++BI) { > + DebugLoc DL = BI->getDebugLoc(); > + if (!DL.isUnknown()) > + return DL; > + } > + return DebugLoc(); > +} this potentially scans through the entire basic block which might be expensive if it is big. Also, it's not clear to me that this makes any sense. Suppose the first instructions in the basic block have no line number info. Why should the phi node get the same line number as some random instruction deep down in the basic block? How about just giving the phi node the same line info as the first instruction in the basic block? If it doesn't have any then too bad. Ciao, Duncan. From baldrick at free.fr Sat Apr 30 08:15:48 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 13:15:48 -0000 Subject: [llvm-commits] [dragonegg] r130607 - /dragonegg/trunk/src/Constants.cpp Message-ID: <20110430131548.CA5032A6C138@llvm.org> Author: baldrick Date: Sat Apr 30 08:15:48 2011 New Revision: 130607 URL: http://llvm.org/viewvc/llvm-project?rev=130607&view=rev Log: Add a comment on improving efficiency. Modified: dragonegg/trunk/src/Constants.cpp Modified: dragonegg/trunk/src/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=130607&r1=130606&r2=130607&view=diff ============================================================================== --- dragonegg/trunk/src/Constants.cpp (original) +++ dragonegg/trunk/src/Constants.cpp Sat Apr 30 08:15:48 2011 @@ -64,6 +64,18 @@ // ... InterpretAsType ... //===----------------------------------------------------------------------===// +// TODO: Implement InterpretAsType more efficiently. Turning everything into +// bits is simple but can involve a lot of work when dealing with large arrays. +// For example: +// struct task_struct { +// char comm[16]; +// }; +// union task_union { +// struct task_struct task; +// unsigned long stack[2048*sizeof(long)/sizeof(long)]; +// }; +// union task_union init_task_union = { { comm: "swapper" } }; + typedef Range SignedRange; /// BitSlice - A contiguous range of bits held in memory. From rafael.espindola at gmail.com Sat Apr 30 09:59:20 2011 From: rafael.espindola at gmail.com (=?UTF-8?B?UmFmYWVsIMOBdmlsYSBkZSBFc3DDrW5kb2xh?=) Date: Sat, 30 Apr 2011 10:59:20 -0400 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: References: <20110430040634.BE8612A6C135@llvm.org> Message-ID: <4DBC23C8.2020202@gmail.com> > Can't we check the presence of the "good" assembler during the > configure? In the same way the mainline gcc does? I could, but given that we don't do that for the .loc directives that have been supported by gas for longer and that there will not be a newer release of llvm-gcc, it is hard to justify spending more time one it. Cheers, Rafael From rafael.espindola at gmail.com Sat Apr 30 10:02:25 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Sat, 30 Apr 2011 11:02:25 -0400 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <4DBBF9D9.4090800@free.fr> References: <20110430040634.BE8612A6C135@llvm.org> <4DBBF9D9.4090800@free.fr> Message-ID: <4DBC2481.8060106@gmail.com> On 11-04-30 8:00 AM, Duncan Sands wrote: > Hi Anton, > >>> URL: http://llvm.org/viewvc/llvm-project?rev=130590&view=rev >>> Log: >>> Don't use the CFI directives in llvm-gcc. >> Can't we check the presence of the "good" assembler during the >> configure? In the same way the mainline gcc does? > > do you know how in mainline gcc this information is made available? > Then I could condition CFI directives on it in dragonegg. Looks like HAVE_GAS_CFI_DIRECTIVE is what you want. > Ciao, Duncan. Cheers, Rafael From rafael.espindola at gmail.com Sat Apr 30 10:10:46 2011 From: rafael.espindola at gmail.com (=?UTF-8?B?UmFmYWVsIMOBdmlsYSBkZSBFc3DDrW5kb2xh?=) Date: Sat, 30 Apr 2011 11:10:46 -0400 Subject: [llvm-commits] [llvm] r130544 - /llvm/trunk/lib/MC/MCDwarf.cpp In-Reply-To: References: <20110429215057.9FB472A6C135@llvm.org> Message-ID: <4DBC2676.7080505@gmail.com> On 11-04-30 2:28 AM, Anton Korobeynikov wrote: > Hi Rafael, > >> more importantly lets this code be used when producing assembly code for old assemblers without >> uleb support. > I don't think it's a good idea in general. In such a way we can not > emit .cfi stuff at all, because "old assemblers don't support it". > The change definitely makes the code less readable, because it emits > some magic constants instead of direct label difference. > > Maybe the stuff can be conditionalized? E.g. via "HasUleb" option or > something like this? > It is a maintenance problem in this particular code, but I think it is the best global solution. Consider the alternatives: * have llvm-gcc use llvm-mc. We would need a ppc parser and it is not clear that dragonegg could do the same trick (it would have to patch gcc's spec at runtime) * Have a table emission code in Codegen. This would be a lot of duplicated code. * Have this conditionalized. The code would still be there, just not executed as often and it would be more likely to catch bugs. As it is now, it is well tested. When I added the cfi.s test, I added it with all the personality and lsda combinations that gas supported. Cheers, Rafael From rafael.espindola at gmail.com Sat Apr 30 11:22:46 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 16:22:46 -0000 Subject: [llvm-commits] [llvm] r130609 - /llvm/trunk/lib/MC/MCMachOStreamer.cpp Message-ID: <20110430162246.A037F2A6C138@llvm.org> Author: rafael Date: Sat Apr 30 11:22:46 2011 New Revision: 130609 URL: http://llvm.org/viewvc/llvm-project?rev=130609&view=rev Log: Handle PrivateExtern eh symbols. Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=130609&r1=130608&r2=130609&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sat Apr 30 11:22:46 2011 @@ -111,6 +111,8 @@ EmitSymbolAttribute(EHSymbol, MCSA_Global); if (SD.getFlags() & SF_WeakDefinition) EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition); + if (SD.isPrivateExtern()) + EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern); } void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) { From baldrick at free.fr Sat Apr 30 11:28:25 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 18:28:25 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <4DBC2481.8060106@gmail.com> References: <20110430040634.BE8612A6C135@llvm.org> <4DBBF9D9.4090800@free.fr> <4DBC2481.8060106@gmail.com> Message-ID: <4DBC38A9.8080500@free.fr> Hi Rafael, >>>> Don't use the CFI directives in llvm-gcc. >>> Can't we check the presence of the "good" assembler during the >>> configure? In the same way the mainline gcc does? >> >> do you know how in mainline gcc this information is made available? >> Then I could condition CFI directives on it in dragonegg. > > Looks like HAVE_GAS_CFI_DIRECTIVE is what you want. that's used to give the default value for flag_dwarf2_cfi_asm, and from then on flag_dwarf2_cfi_asm seems to be what is actually used, so I guess that's the right thing for dragonegg to look at. Ciao, Duncan. From baldrick at free.fr Sat Apr 30 11:27:20 2011 From: baldrick at free.fr (Duncan Sands) Date: Sat, 30 Apr 2011 16:27:20 -0000 Subject: [llvm-commits] [dragonegg] r130610 - /dragonegg/trunk/src/Backend.cpp Message-ID: <20110430162721.0274B2A6C138@llvm.org> Author: baldrick Date: Sat Apr 30 11:27:20 2011 New Revision: 130610 URL: http://llvm.org/viewvc/llvm-project?rev=130610&view=rev Log: Port llvm-gcc commit 130590 to dragonegg. Modified: dragonegg/trunk/src/Backend.cpp Modified: dragonegg/trunk/src/Backend.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=130610&r1=130609&r2=130610&view=diff ============================================================================== --- dragonegg/trunk/src/Backend.cpp (original) +++ dragonegg/trunk/src/Backend.cpp Sat Apr 30 11:27:20 2011 @@ -458,6 +458,7 @@ FeatureStr = Features.getString(); #endif TheTarget = TME->createTargetMachine(TargetTriple, FeatureStr); + TheTarget->setMCUseCFI(flag_dwarf2_cfi_asm); assert(TheTarget->getTargetData()->isBigEndian() == BYTES_BIG_ENDIAN); } From rafael.espindola at gmail.com Sat Apr 30 11:34:57 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 16:34:57 -0000 Subject: [llvm-commits] [llvm] r130611 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp Message-ID: <20110430163457.CB27A2A6C138@llvm.org> Author: rafael Date: Sat Apr 30 11:34:57 2011 New Revision: 130611 URL: http://llvm.org/viewvc/llvm-project?rev=130611&view=rev Log: Implement MCAsmStreamer::EmitEHSymAttributes. Doing this in the asm streamer is a bit ugly, but doing it on the base MCStreamer would be redundant with the object streamer which does it using SD. Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130611&r1=130610&r2=130611&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Apr 30 11:34:57 2011 @@ -47,6 +47,11 @@ unsigned UseLoc : 1; unsigned UseCFI : 1; + enum EHSymbolFlags { EHGlobal = 1, + EHWeakDefinition = 1 << 1, + EHPrivateExtern = 1 << 2 }; + DenseMap FlagMap; + bool needsSet(const MCExpr *Value); public: @@ -118,7 +123,8 @@ } virtual void EmitLabel(MCSymbol *Symbol); - + virtual void EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol); virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); virtual void EmitThumbFunc(MCSymbol *Func); @@ -278,6 +284,21 @@ Section->PrintSwitchToSection(MAI, OS); } +void MCAsmStreamer::EmitEHSymAttributes(const MCSymbol *Symbol, + MCSymbol *EHSymbol) { + if (UseCFI) + return; + + unsigned Flags = FlagMap.lookup(Symbol); + + if (Flags & EHGlobal) + EmitSymbolAttribute(EHSymbol, MCSA_Global); + if (Flags & EHWeakDefinition) + EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition); + if (Flags & EHPrivateExtern) + EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern); +} + void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) { assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); MCStreamer::EmitLabel(Symbol); @@ -363,6 +384,7 @@ return; case MCSA_Global: // .globl/.global OS << MAI.getGlobalDirective(); + FlagMap[Symbol] |= EHGlobal; break; case MCSA_Hidden: OS << "\t.hidden\t"; break; case MCSA_IndirectSymbol: OS << "\t.indirect_symbol\t"; break; @@ -371,11 +393,17 @@ case MCSA_Local: OS << "\t.local\t"; break; case MCSA_NoDeadStrip: OS << "\t.no_dead_strip\t"; break; case MCSA_SymbolResolver: OS << "\t.symbol_resolver\t"; break; - case MCSA_PrivateExtern: OS << "\t.private_extern\t"; break; + case MCSA_PrivateExtern: + OS << "\t.private_extern\t"; + FlagMap[Symbol] |= EHPrivateExtern; + break; case MCSA_Protected: OS << "\t.protected\t"; break; case MCSA_Reference: OS << "\t.reference\t"; break; case MCSA_Weak: OS << "\t.weak\t"; break; - case MCSA_WeakDefinition: OS << "\t.weak_definition\t"; break; + case MCSA_WeakDefinition: + OS << "\t.weak_definition\t"; + FlagMap[Symbol] |= EHWeakDefinition; + break; // .weak_reference case MCSA_WeakReference: OS << MAI.getWeakRefDirective(); break; case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break; From stoklund at 2pi.dk Sat Apr 30 12:24:32 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 10:24:32 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <4DBBFB9E.3020203@free.fr> References: <20110430013754.E6BA62A6C138@llvm.org> <4DBBFB9E.3020203@free.fr> Message-ID: On Apr 30, 2011, at 5:07 AM, Duncan Sands wrote: > Hi Jakob, this probably broke the i386 dragonegg buildbot: > http://google1.osuosl.org:8011/builders/dragonegg-i386-linux/builds/1251 > > The failure is: > cc1plus: lib/CodeGen/RegAllocGreedy.cpp:809: > void::RAGreedy::splitAroundRegion(llvm::LiveInterval&, > ::RAGreedy::GlobalSplitCandidate&, > llvm::SmallVectorImpl&): Assertion `SegStart >= Intf.last() > && "Couldn't avoid interference"' failed. > Stack dump: > 0. Running pass 'Greedy Register Allocator' on function > '@_ZN4llvm16InstrInfoEmitter14GetOperandInfoERKNS_18CodeGenInstructionE' > g++: Internal error: Aborted (program cc1plus) > > I can try to get you a testcase if you like. Please do, that would be very helpful. Thanks, /jakob From benny.kra at googlemail.com Sat Apr 30 13:15:53 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 30 Apr 2011 18:15:53 -0000 Subject: [llvm-commits] [llvm] r130613 - /llvm/trunk/test/Transforms/InstCombine/div.ll Message-ID: <20110430181553.4555F2A6C138@llvm.org> Author: d0k Date: Sat Apr 30 13:15:53 2011 New Revision: 130613 URL: http://llvm.org/viewvc/llvm-project?rev=130613&view=rev Log: FileCheckize. Modified: llvm/trunk/test/Transforms/InstCombine/div.ll Modified: llvm/trunk/test/Transforms/InstCombine/div.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/div.ll?rev=130613&r1=130612&r2=130613&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/div.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/div.ll Sat Apr 30 13:15:53 2011 @@ -1,34 +1,44 @@ ; This test makes sure that div instructions are properly eliminated. -; RUN: opt < %s -instcombine -S | not grep div +; RUN: opt < %s -instcombine -S | FileCheck %s define i32 @test1(i32 %A) { %B = sdiv i32 %A, 1 ; [#uses=1] ret i32 %B +; CHECK: @test1 +; CHECK-NEXT: ret i32 %A } define i32 @test2(i32 %A) { ; => Shift %B = udiv i32 %A, 8 ; [#uses=1] ret i32 %B +; CHECK: @test2 +; CHECK-NEXT: lshr i32 %A, 3 } define i32 @test3(i32 %A) { ; => 0, don't need to keep traps %B = sdiv i32 0, %A ; [#uses=1] ret i32 %B +; CHECK: @test3 +; CHECK-NEXT: ret i32 0 } define i32 @test4(i32 %A) { ; 0-A %B = sdiv i32 %A, -1 ; [#uses=1] ret i32 %B +; CHECK: @test4 +; CHECK-NEXT: sub i32 0, %A } define i32 @test5(i32 %A) { %B = udiv i32 %A, -16 ; [#uses=1] %C = udiv i32 %B, -4 ; [#uses=1] ret i32 %C +; CHECK: @test5 +; CHECK-NEXT: ret i32 0 } define i1 @test6(i32 %A) { @@ -36,6 +46,8 @@ ; A < 123 %C = icmp eq i32 %B, 0 ; [#uses=1] ret i1 %C +; CHECK: @test6 +; CHECK-NEXT: icmp ult i32 %A, 123 } define i1 @test7(i32 %A) { @@ -43,6 +55,9 @@ ; A >= 20 && A < 30 %C = icmp eq i32 %B, 2 ; [#uses=1] ret i1 %C +; CHECK: @test7 +; CHECK-NEXT: add i32 %A, -20 +; CHECK-NEXT: icmp ult i32 } define i1 @test8(i8 %A) { @@ -50,6 +65,8 @@ ; A >= 246 %C = icmp eq i8 %B, 2 ; [#uses=1] ret i1 %C +; CHECK: @test8 +; CHECK-NEXT: icmp ugt i8 %A, -11 } define i1 @test9(i8 %A) { @@ -57,28 +74,40 @@ ; A < 246 %C = icmp ne i8 %B, 2 ; [#uses=1] ret i1 %C +; CHECK: @test9 +; CHECK-NEXT: icmp ult i8 %A, -10 } define i32 @test10(i32 %X, i1 %C) { %V = select i1 %C, i32 64, i32 8 ; [#uses=1] %R = udiv i32 %X, %V ; [#uses=1] ret i32 %R +; CHECK: @test10 +; CHECK-NEXT: select i1 %C, i32 6, i32 3 +; CHECK-NEXT: lshr i32 %X } define i32 @test11(i32 %X, i1 %C) { %A = select i1 %C, i32 1024, i32 32 ; [#uses=1] %B = udiv i32 %X, %A ; [#uses=1] ret i32 %B +; CHECK: @test11 +; CHECK-NEXT: select i1 %C, i32 10, i32 5 +; CHECK-NEXT: lshr i32 %X } ; PR2328 define i32 @test12(i32 %x) nounwind { %tmp3 = udiv i32 %x, %x ; 1 ret i32 %tmp3 +; CHECK: @test12 +; CHECK-NEXT: ret i32 1 } define i32 @test13(i32 %x) nounwind { %tmp3 = sdiv i32 %x, %x ; 1 ret i32 %tmp3 +; CHECK: @test13 +; CHECK-NEXT: ret i32 1 } From benny.kra at googlemail.com Sat Apr 30 13:16:00 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 30 Apr 2011 18:16:00 -0000 Subject: [llvm-commits] [llvm] r130614 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/div.ll Message-ID: <20110430181600.7A4312A6C139@llvm.org> Author: d0k Date: Sat Apr 30 13:16:00 2011 New Revision: 130614 URL: http://llvm.org/viewvc/llvm-project?rev=130614&view=rev Log: Use SimplifyDemandedBits on div instructions. This folds away silly stuff like (a&255)/1000 -> 0. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/trunk/test/Transforms/InstCombine/div.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=130614&r1=130613&r2=130614&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sat Apr 30 13:16:00 2011 @@ -320,6 +320,10 @@ } } + // See if we can fold away this div instruction. + if (SimplifyDemandedInstructionBits(I)) + return &I; + // (X - (X rem Y)) / Y -> X / Y; usually originates as ((X / Y) * Y) / Y Value *X = 0, *Z = 0; if (match(Op0, m_Sub(m_Value(X), m_Value(Z)))) { // (X - Z) / Y; Y = Op1 Modified: llvm/trunk/test/Transforms/InstCombine/div.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/div.ll?rev=130614&r1=130613&r2=130614&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/div.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/div.ll Sat Apr 30 13:16:00 2011 @@ -111,3 +111,10 @@ ; CHECK-NEXT: ret i32 1 } +define i32 @test14(i8 %x) nounwind { + %zext = zext i8 %x to i32 + %div = udiv i32 %zext, 257 ; 0 + ret i32 %div +; CHECK: @test14 +; CHECK-NEXT: ret i32 0 +} From benny.kra at googlemail.com Sat Apr 30 13:16:07 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sat, 30 Apr 2011 18:16:07 -0000 Subject: [llvm-commits] [llvm] r130615 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp test/Transforms/InstCombine/udivrem-change-width.ll Message-ID: <20110430181607.BF2082A6C138@llvm.org> Author: d0k Date: Sat Apr 30 13:16:07 2011 New Revision: 130615 URL: http://llvm.org/viewvc/llvm-project?rev=130615&view=rev Log: InstCombine: Turn (zext A) udiv (zext B) into (zext (A udiv B)). Same for urem or constant B. This obviously helps a lot if the division would be turned into a libcall (think i64 udiv on i386), but div is also one of the few remaining instructions on modern CPUs that become more expensive when the bitwidth gets bigger. This also helps register pressure on i386 when dividing chars, divb needs two 8-bit parts of a 16 bit register as input where divl uses two registers. int foo(unsigned char a) { return a/10; } int bar(unsigned char a, unsigned char b) { return a/b; } compiles into (x86_64) _foo: imull $205, %edi, %eax shrl $11, %eax ret _bar: movzbl %dil, %eax divb %sil, %al movzbl %al, %eax ret Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp?rev=130615&r1=130614&r2=130615&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp Sat Apr 30 13:16:07 2011 @@ -336,6 +336,19 @@ return 0; } +/// dyn_castZExtVal - Checks if V is a zext or constant that can +/// be truncated to Ty without losing bits. +static Value *dyn_castZExtVal(Value *V, const Type *Ty) { + if (ZExtInst *Z = dyn_cast(V)) { + if (Z->getSrcTy() == Ty) + return Z->getOperand(0); + } else if (ConstantInt *C = dyn_cast(V)) { + if (C->getValue().getActiveBits() <= cast(Ty)->getBitWidth()) + return ConstantExpr::getTrunc(C, Ty); + } + return 0; +} + Instruction *InstCombiner::visitUDiv(BinaryOperator &I) { Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1); @@ -394,6 +407,14 @@ return SelectInst::Create(Cond, TSI, FSI); } } + + // (zext A) udiv (zext B) --> zext (A udiv B) + if (ZExtInst *ZOp0 = dyn_cast(Op0)) + if (Value *ZOp1 = dyn_castZExtVal(Op1, ZOp0->getSrcTy())) + return new ZExtInst(Builder->CreateUDiv(ZOp0->getOperand(0), ZOp1, "div", + I.isExact()), + I.getType()); + return 0; } @@ -568,7 +589,13 @@ return SelectInst::Create(Cond, TrueAnd, FalseAnd); } } - + + // (zext A) urem (zext B) --> zext (A urem B) + if (ZExtInst *ZOp0 = dyn_cast(Op0)) + if (Value *ZOp1 = dyn_castZExtVal(Op1, ZOp0->getSrcTy())) + return new ZExtInst(Builder->CreateURem(ZOp0->getOperand(0), ZOp1), + I.getType()); + return 0; } Modified: llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll?rev=130615&r1=130614&r2=130615&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/udivrem-change-width.ll Sat Apr 30 13:16:07 2011 @@ -1,14 +1,16 @@ -; RUN: opt < %s -instcombine -S | not grep zext -; PR4548 +; RUN: opt < %s -instcombine -S | FileCheck %s target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" +; PR4548 define i8 @udiv_i8(i8 %a, i8 %b) nounwind { %conv = zext i8 %a to i32 %conv2 = zext i8 %b to i32 %div = udiv i32 %conv, %conv2 %conv3 = trunc i32 %div to i8 ret i8 %conv3 +; CHECK: @udiv_i8 +; CHECK: udiv i8 %a, %b } define i8 @urem_i8(i8 %a, i8 %b) nounwind { @@ -17,5 +19,44 @@ %div = urem i32 %conv, %conv2 %conv3 = trunc i32 %div to i8 ret i8 %conv3 +; CHECK: @urem_i8 +; CHECK: urem i8 %a, %b } +define i32 @udiv_i32(i8 %a, i8 %b) nounwind { + %conv = zext i8 %a to i32 + %conv2 = zext i8 %b to i32 + %div = udiv i32 %conv, %conv2 + ret i32 %div +; CHECK: @udiv_i32 +; CHECK: udiv i8 %a, %b +; CHECK: zext +} + +define i32 @urem_i32(i8 %a, i8 %b) nounwind { + %conv = zext i8 %a to i32 + %conv2 = zext i8 %b to i32 + %div = urem i32 %conv, %conv2 + ret i32 %div +; CHECK: @urem_i32 +; CHECK: urem i8 %a, %b +; CHECK: zext +} + +define i32 @udiv_i32_c(i8 %a) nounwind { + %conv = zext i8 %a to i32 + %div = udiv i32 %conv, 10 + ret i32 %div +; CHECK: @udiv_i32_c +; CHECK: udiv i8 %a, 10 +; CHECK: zext +} + +define i32 @urem_i32_c(i8 %a) nounwind { + %conv = zext i8 %a to i32 + %div = urem i32 %conv, 10 + ret i32 %div +; CHECK: @urem_i32_c +; CHECK: urem i8 %a, 10 +; CHECK: zext +} From stoklund at 2pi.dk Sat Apr 30 14:12:33 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 19:12:33 -0000 Subject: [llvm-commits] [llvm] r130619 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20110430191233.C35272A6C139@llvm.org> Author: stoklund Date: Sat Apr 30 14:12:33 2011 New Revision: 130619 URL: http://llvm.org/viewvc/llvm-project?rev=130619&view=rev Log: When a physreg is live-in and live through a basic block, make sure its live range covers the entire block. The live range can't be terminated at a random instruction. Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=130619&r1=130618&r2=130619&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Sat Apr 30 14:12:33 2011 @@ -638,7 +638,7 @@ end = MIIdx.getStoreIndex(); } else { DEBUG(dbgs() << " live through"); - end = baseIndex; + end = getMBBEndIdx(MBB); } } From stoklund at 2pi.dk Sat Apr 30 14:18:12 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 12:18:12 -0700 Subject: [llvm-commits] [llvm] r130568 - /llvm/trunk/lib/CodeGen/Passes.cpp In-Reply-To: <4DBBFB9E.3020203@free.fr> References: <20110430013754.E6BA62A6C138@llvm.org> <4DBBFB9E.3020203@free.fr> Message-ID: <1CA6BB58-5838-4741-AEC1-BC5EEEF471DC@2pi.dk> On Apr 30, 2011, at 5:07 AM, Duncan Sands wrote: > Hi Jakob, this probably broke the i386 dragonegg buildbot: > http://google1.osuosl.org:8011/builders/dragonegg-i386-linux/builds/1251 > > The failure is: > cc1plus: lib/CodeGen/RegAllocGreedy.cpp:809: > void::RAGreedy::splitAroundRegion(llvm::LiveInterval&, > ::RAGreedy::GlobalSplitCandidate&, > llvm::SmallVectorImpl&): Assertion `SegStart >= Intf.last() > && "Couldn't avoid interference"' failed. > Stack dump: > 0. Running pass 'Greedy Register Allocator' on function > '@_ZN4llvm16InstrInfoEmitter14GetOperandInfoERKNS_18CodeGenInstructionE' > g++: Internal error: Aborted (program cc1plus) > > I can try to get you a testcase if you like. Thanks, Duncan. This should be fixed in r130619. /jakob From rafael.espindola at gmail.com Sat Apr 30 14:46:45 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Sat, 30 Apr 2011 15:46:45 -0400 Subject: [llvm-commits] [llvm-gcc-4.2] r130590 - /llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp In-Reply-To: <4DBC38A9.8080500@free.fr> References: <20110430040634.BE8612A6C135@llvm.org> <4DBBF9D9.4090800@free.fr> <4DBC2481.8060106@gmail.com> <4DBC38A9.8080500@free.fr> Message-ID: <4DBC6725.2050908@gmail.com> > that's used to give the default value for flag_dwarf2_cfi_asm, and from then > on flag_dwarf2_cfi_asm seems to be what is actually used, so I guess that's > the right thing for dragonegg to look at. Make sense. Thanks for updating dragonegg! > Ciao, Duncan. Cheers, Rafael From rafael.espindola at gmail.com Sat Apr 30 17:29:54 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 22:29:54 -0000 Subject: [llvm-commits] [llvm] r130623 - in /llvm/trunk: lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/Target/X86/X86MCAsmInfo.cpp test/CodeGen/PowerPC/mulhs.ll test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll test/CodeGen/X86/2008-04-02-unnamedEH.ll test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll test/CodeGen/X86/hidden-vis-pic.ll test/CodeGen/X86/personality.ll Message-ID: <20110430222954.AE7B02A6C138@llvm.org> Author: rafael Date: Sat Apr 30 17:29:54 2011 New Revision: 130623 URL: http://llvm.org/viewvc/llvm-project?rev=130623&view=rev Log: Enable CFI on OS X. Currently the output should be almost identical to the one produced by CodeGen to make the transition easier. The only two differences I know of are: * Some files get an extra advance loc of size 0. This will be fixed when relaxations are enabled. * The optimization of declaring an EH symbol as an external variable is not implemented. This is a subset of adding the nounwind attribute, so we if really this at -O0 we should probably do it at the IL level. Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/test/CodeGen/PowerPC/mulhs.ll llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll llvm/trunk/test/CodeGen/X86/personality.ll Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Apr 30 17:29:54 2011 @@ -1070,6 +1070,9 @@ // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles() && !UseLoc) MCDwarfFileTable::Emit(this); + + if (getNumFrameInfos() && !UseCFI) + MCDwarfFrameEmitter::Emit(*this); } MCStreamer *llvm::createAsmStreamer(MCContext &Context, Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sat Apr 30 17:29:54 2011 @@ -377,6 +377,9 @@ } void MCMachOStreamer::Finish() { + if (getNumFrameInfos()) + MCDwarfFrameEmitter::Emit(*this); + // We have to set the fragment atom associations so we can relax properly for // Mach-O. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Sat Apr 30 17:29:54 2011 @@ -71,7 +71,7 @@ DwarfUsesInlineInfoSection = true; // Exceptions handling - ExceptionsType = ExceptionHandling::DwarfTable; + ExceptionsType = ExceptionHandling::DwarfCFI; } const MCExpr * Modified: llvm/trunk/test/CodeGen/PowerPC/mulhs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/mulhs.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/mulhs.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/mulhs.ll Sat Apr 30 17:29:54 2011 @@ -5,7 +5,7 @@ ; RUN: not grep add %t ; RUN: grep mulhw %t | count 1 -define i32 @mulhs(i32 %a, i32 %b) { +define i32 @mulhs(i32 %a, i32 %b) nounwind { entry: %tmp.1 = sext i32 %a to i64 ; [#uses=1] %tmp.3 = sext i32 %b to i64 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll Sat Apr 30 17:29:54 2011 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | count 2 +; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | FileCheck %s + +; CHECK: "_-[NSString(local) isNullOrNil].eh": %struct.NSString = type { } %struct._objc__method_prototype_list = type opaque Modified: llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Sat Apr 30 17:29:54 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s | FileCheck %s +; RUN: llc < %s -disable-cfi | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" Modified: llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll Sat Apr 30 17:29:54 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh -; RUN: llc < %s -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -disable-cfi -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh define void @_Z1fv() { entry: Modified: llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll Sat Apr 30 17:29:54 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s +; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s Modified: llvm/trunk/test/CodeGen/X86/personality.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/personality.ll?rev=130623&r1=130622&r2=130623&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/personality.ll (original) +++ llvm/trunk/test/CodeGen/X86/personality.ll Sat Apr 30 17:29:54 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 -; RUN: llc < %s -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -disable-cfi -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 ; PR1632 define void @_Z1fv() { @@ -38,13 +38,15 @@ declare void @__cxa_end_catch() -; X64: Leh_frame_common_begin0: -; X64: .long ___gxx_personality_v0 at GOTPCREL+4 - -; X32: Leh_frame_common_begin0: -; X32: .long L___gxx_personality_v0$non_lazy_ptr- -; .... - -; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers -; X32: L___gxx_personality_v0$non_lazy_ptr: -; X32: .indirect_symbol ___gxx_personality_v0 +; X64: zPLR +; X64: .byte 155 +; X64-NEXT: .long ___gxx_personality_v0 at GOTPCREL+4 + +; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers +; X32-NEXT: L___gxx_personality_v0$non_lazy_ptr: +; X32-NEXT: .indirect_symbol ___gxx_personality_v0 + +; X32: zPLR +; X32: .byte 155 +; X32-NEXT: : +; X32-NEXT: .long L___gxx_personality_v0$non_lazy_ptr- From stoklund at 2pi.dk Sat Apr 30 18:00:06 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Sat, 30 Apr 2011 23:00:06 -0000 Subject: [llvm-commits] [llvm] r130625 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <20110430230006.183DD2A6C138@llvm.org> Author: stoklund Date: Sat Apr 30 18:00:05 2011 New Revision: 130625 URL: http://llvm.org/viewvc/llvm-project?rev=130625&view=rev Log: X86AsmPrinter doesn't know how to handle the X86II::MO_GOT_ABSOLUTE_ADDRESS flag after folding ADD32ri to ADD32mi, so don't do that. This only happens when the greedy register allocator gets itself in trouble and spills %vreg9 here: 16L %vreg9 = MOVPC32r 0, %ESP; GR32:%vreg9 48L %vreg9 = ADD32ri %vreg9, [TF=1], %EFLAGS; GR32:%vreg9 That should never happen, the live range should be split instead. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=130625&r1=130624&r2=130625&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sat Apr 30 18:00:05 2011 @@ -2240,6 +2240,12 @@ bool isTwoAddr = NumOps > 1 && MI->getDesc().getOperandConstraint(1, TOI::TIED_TO) != -1; + // FIXME: AsmPrinter doesn't know how to handle + // X86II::MO_GOT_ABSOLUTE_ADDRESS after folding. + if (MI->getOpcode() == X86::ADD32ri && + MI->getOperand(2).getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) + return NULL; + MachineInstr *NewMI = NULL; // Folding a memory location into the two-address part of a two-address // instruction is different than folding it other places. It requires @@ -2534,6 +2540,12 @@ case X86::TEST32rr: case X86::TEST64rr: return true; + case X86::ADD32ri: + // FIXME: AsmPrinter doesn't know how to handle + // X86II::MO_GOT_ABSOLUTE_ADDRESS after folding. + if (MI->getOperand(2).getTargetFlags() == X86II::MO_GOT_ABSOLUTE_ADDRESS) + return false; + break; } } From rafael.espindola at gmail.com Sat Apr 30 18:03:44 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sat, 30 Apr 2011 23:03:44 -0000 Subject: [llvm-commits] [llvm] r130626 - in /llvm/trunk: lib/MC/MCAsmStreamer.cpp lib/MC/MCMachOStreamer.cpp lib/Target/X86/X86MCAsmInfo.cpp test/CodeGen/PowerPC/mulhs.ll test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll test/CodeGen/X86/2008-04-02-unnamedEH.ll test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll test/CodeGen/X86/hidden-vis-pic.ll test/CodeGen/X86/personality.ll Message-ID: <20110430230345.17A552A6C138@llvm.org> Author: rafael Date: Sat Apr 30 18:03:44 2011 New Revision: 130626 URL: http://llvm.org/viewvc/llvm-project?rev=130626&view=rev Log: Revert the previous patch while I figure out how to make llvm-gcc less agressive about disabling cfi on linux :-( Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/test/CodeGen/PowerPC/mulhs.ll llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll llvm/trunk/test/CodeGen/X86/personality.ll Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Apr 30 18:03:44 2011 @@ -1070,9 +1070,6 @@ // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles() && !UseLoc) MCDwarfFileTable::Emit(this); - - if (getNumFrameInfos() && !UseCFI) - MCDwarfFrameEmitter::Emit(*this); } MCStreamer *llvm::createAsmStreamer(MCContext &Context, Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sat Apr 30 18:03:44 2011 @@ -377,9 +377,6 @@ } void MCMachOStreamer::Finish() { - if (getNumFrameInfos()) - MCDwarfFrameEmitter::Emit(*this); - // We have to set the fragment atom associations so we can relax properly for // Mach-O. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Sat Apr 30 18:03:44 2011 @@ -71,7 +71,7 @@ DwarfUsesInlineInfoSection = true; // Exceptions handling - ExceptionsType = ExceptionHandling::DwarfCFI; + ExceptionsType = ExceptionHandling::DwarfTable; } const MCExpr * Modified: llvm/trunk/test/CodeGen/PowerPC/mulhs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/mulhs.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/mulhs.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/mulhs.ll Sat Apr 30 18:03:44 2011 @@ -5,7 +5,7 @@ ; RUN: not grep add %t ; RUN: grep mulhw %t | count 1 -define i32 @mulhs(i32 %a, i32 %b) nounwind { +define i32 @mulhs(i32 %a, i32 %b) { entry: %tmp.1 = sext i32 %a to i64 ; [#uses=1] %tmp.3 = sext i32 %b to i64 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll Sat Apr 30 18:03:44 2011 @@ -1,6 +1,4 @@ -; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | FileCheck %s - -; CHECK: "_-[NSString(local) isNullOrNil].eh": +; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | count 2 %struct.NSString = type { } %struct._objc__method_prototype_list = type opaque Modified: llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Sat Apr 30 18:03:44 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -disable-cfi | FileCheck %s +; RUN: llc < %s | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" Modified: llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll Sat Apr 30 18:03:44 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -disable-cfi -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh -; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh define void @_Z1fv() { entry: Modified: llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll Sat Apr 30 18:03:44 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s +; RUN: llc < %s -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s Modified: llvm/trunk/test/CodeGen/X86/personality.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/personality.ll?rev=130626&r1=130625&r2=130626&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/personality.ll (original) +++ llvm/trunk/test/CodeGen/X86/personality.ll Sat Apr 30 18:03:44 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -disable-cfi -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 -; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 ; PR1632 define void @_Z1fv() { @@ -38,15 +38,13 @@ declare void @__cxa_end_catch() -; X64: zPLR -; X64: .byte 155 -; X64-NEXT: .long ___gxx_personality_v0 at GOTPCREL+4 - -; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers -; X32-NEXT: L___gxx_personality_v0$non_lazy_ptr: -; X32-NEXT: .indirect_symbol ___gxx_personality_v0 - -; X32: zPLR -; X32: .byte 155 -; X32-NEXT: : -; X32-NEXT: .long L___gxx_personality_v0$non_lazy_ptr- +; X64: Leh_frame_common_begin0: +; X64: .long ___gxx_personality_v0 at GOTPCREL+4 + +; X32: Leh_frame_common_begin0: +; X32: .long L___gxx_personality_v0$non_lazy_ptr- +; .... + +; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers +; X32: L___gxx_personality_v0$non_lazy_ptr: +; X32: .indirect_symbol ___gxx_personality_v0 From mttjwl at gmail.com Sat Apr 30 20:18:03 2011 From: mttjwl at gmail.com (Matthew Wala) Date: Sun, 01 May 2011 01:18:03 -0000 Subject: [llvm-commits] [poolalloc] r130630 - in /poolalloc/trunk: include/dsa/CStdLib.h lib/DSA/StdLibPass.cpp Message-ID: <20110501011803.9D0B72A6C138@llvm.org> Author: wala1 Date: Sat Apr 30 20:18:03 2011 New Revision: 130630 URL: http://llvm.org/viewvc/llvm-project?rev=130630&view=rev Log: Make DSA recognize more CStdLib runtime functions: pool_bcmp(), pool_bcopy(), pool_index(), pool_rindex(). Modified: poolalloc/trunk/include/dsa/CStdLib.h poolalloc/trunk/lib/DSA/StdLibPass.cpp Modified: poolalloc/trunk/include/dsa/CStdLib.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/CStdLib.h?rev=130630&r1=130629&r2=130630&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/CStdLib.h (original) +++ poolalloc/trunk/include/dsa/CStdLib.h Sat Apr 30 20:18:03 2011 @@ -40,6 +40,10 @@ { "pool_strcspn", 2 }, { "pool_memccpy", 2 }, { "pool_memchr", 1 }, + { "pool_bcmp", 1 }, + { "pool_bcopy", 2 }, + { "pool_index", 1 }, + { "pool_rindex", 1 }, { 0, 0 } }; Modified: poolalloc/trunk/lib/DSA/StdLibPass.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/StdLibPass.cpp?rev=130630&r1=130629&r2=130630&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original) +++ poolalloc/trunk/lib/DSA/StdLibPass.cpp Sat Apr 30 20:18:03 2011 @@ -85,6 +85,7 @@ #define YRET_NNYARGS {1,0,0,1,1,1,1,1,1,1} #define NRET_NNYARGS {0,0,0,1,1,1,1,1,1,1} #define YRET_NNYNARGS {1,0,0,1,0,0,0,0,0,0} +#define NRET_NNNYARGS {0,0,0,0,1,1,1,1,1,1} const struct { const char* name; @@ -265,28 +266,31 @@ {"sc.pool_unregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, {"sc.pool_argvregister", {NRET_NARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - // CStdLib Runtime Checks - {"pool_strncpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_strcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_stpcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_strchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, - {"pool_strrchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, - {"pool_strcat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_strncat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_strstr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, - {"pool_strpbrk", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, - {"pool_strspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, - {"pool_strcspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, - {"pool_memccpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, - {"pool_memchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, - {"pool_strcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_strncmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_strlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_strnlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_memcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_strcasecmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - {"pool_strncasecmp",{NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, - + // CStdLib Runtime Wrapper Functions + {"pool_strncpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_stpcpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strrchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strcat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strncat", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_strstr", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, + {"pool_strpbrk", {NRET_NNYARGS, YRET_NARGS, NRET_NARGS, YRET_NNYNARGS, true}}, + {"pool_strspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, + {"pool_strcspn", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, + {"pool_memccpy", {NRET_NNYARGS, YRET_NNYARGS, NRET_NARGS, YRET_NNYARGS, true}}, + {"pool_memchr", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_strcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strncmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strnlen", {NRET_NYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_memcmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strcasecmp", {NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_strncasecmp",{NRET_NNYARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, false}}, + {"pool_bcopy", {NRET_NYARGS, NRET_NNNYARGS, NRET_NARGS, NRET_NNYARGS, true}}, + {"pool_bcmp", {NRET_YARGS, NRET_NARGS, NRET_NARGS, NRET_NARGS, true}}, + {"pool_index", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, + {"pool_rindex", {NRET_NYARGS, YRET_NARGS, NRET_NARGS, YRET_NYARGS, true}}, #if 0 {"wait", {false, false, false, false, true, false, false, false, false}}, From ofv at wanadoo.es Sat Apr 30 21:12:20 2011 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sun, 01 May 2011 02:12:20 -0000 Subject: [llvm-commits] [llvm] r130631 - /llvm/trunk/docs/CMake.html Message-ID: <20110501021220.497582A6C138@llvm.org> Author: ofv Date: Sat Apr 30 21:12:20 2011 New Revision: 130631 URL: http://llvm.org/viewvc/llvm-project?rev=130631&view=rev Log: Update instructions: LLVM.cmake is now LLVMConfig.cmake Modified: llvm/trunk/docs/CMake.html Modified: llvm/trunk/docs/CMake.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.html?rev=130631&r1=130630&r2=130631&view=diff ============================================================================== --- llvm/trunk/docs/CMake.html (original) +++ llvm/trunk/docs/CMake.html Sat Apr 30 21:12:20 2011 @@ -421,7 +421,7 @@ endif() # We incorporate the CMake features provided by LLVM: set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LLVM_ROOT}/share/llvm/cmake") - include(LLVM) + include(LLVMConfig) # Now set the header and library paths: include_directories( ${LLVM_ROOT}/include ) link_directories( ${LLVM_ROOT}/lib ) From rafael.espindola at gmail.com Sat Apr 30 22:50:50 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 01 May 2011 03:50:50 -0000 Subject: [llvm-commits] [llvm] r130634 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCAsmInfoDarwin.h include/llvm/MC/MCObjectStreamer.h include/llvm/MC/MCStreamer.h lib/MC/ELFObjectWriter.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCAsmStreamer.cpp lib/MC/MCDwarf.cpp lib/MC/MCLoggingStreamer.cpp lib/MC/MCNullStreamer.cpp lib/MC/MCObjectStreamer.cpp lib/MC/MCStreamer.cpp lib/Target/PTX/PTXMCAsmStreamer.cpp tools/lto/LTOModule.cpp Message-ID: <20110501035050.2FDE82A6C138@llvm.org> Author: rafael Date: Sat Apr 30 22:50:49 2011 New Revision: 130634 URL: http://llvm.org/viewvc/llvm-project?rev=130634&view=rev Log: Simplify the handling of pcrel relocations on ELF. Now we do the right thing for all symbol differences and can drop the old EmitPCRelSymbolValue method. This also make getExprForFDESymbol on ELF equal to the one on MachO, and it can be made non-virtual. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h llvm/trunk/include/llvm/MC/MCObjectStreamer.h llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/MC/ELFObjectWriter.cpp llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCLoggingStreamer.cpp llvm/trunk/lib/MC/MCNullStreamer.cpp llvm/trunk/lib/MC/MCObjectStreamer.cpp llvm/trunk/lib/MC/MCStreamer.cpp llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Sat Apr 30 22:50:49 2011 @@ -326,10 +326,13 @@ virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const; - virtual const MCExpr * - getExprForFDESymbol(const MCSymbol *Sym, MCStreamer &Streamer) const; + const MCExpr * + getExprForFDESymbol(const MCSymbol *Sym, + unsigned Encoding, + MCStreamer &Streamer) const; bool usesSunStyleELFSectionSwitchSyntax() const { return SunStyleELFSectionSwitchSyntax; Modified: llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfoDarwin.h Sat Apr 30 22:50:49 2011 @@ -25,8 +25,6 @@ struct MCAsmInfoDarwin : public MCAsmInfo { explicit MCAsmInfoDarwin(); - virtual const MCExpr * - getExprForFDESymbol(const MCSymbol *Sym, MCStreamer &Streamer) const; }; } Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Sat Apr 30 22:50:49 2011 @@ -63,7 +63,7 @@ virtual void EmitLabel(MCSymbol *Symbol); virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace); + unsigned AddrSpace); virtual void EmitULEB128Value(const MCExpr *Value); virtual void EmitSLEB128Value(const MCExpr *Value); virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Sat Apr 30 22:50:49 2011 @@ -50,9 +50,6 @@ MCStreamer(const MCStreamer&); // DO NOT IMPLEMENT MCStreamer &operator=(const MCStreamer&); // DO NOT IMPLEMENT - void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, - bool isPCRel, unsigned AddrSpace); - std::vector FrameInfos; MCDwarfFrameInfo *getCurrentFrameInfo(); void EnsureValidFrame(); @@ -311,13 +308,10 @@ /// @param Size - The size of the integer (in bytes) to emit. This must /// match a native machine width. virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) = 0; + unsigned AddrSpace) = 0; void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0); - void EmitPCRelValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace = 0); - /// EmitIntValue - Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. virtual void EmitIntValue(uint64_t Value, unsigned Size, @@ -347,9 +341,6 @@ void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, unsigned AddrSpace = 0); - void EmitPCRelSymbolValue(const MCSymbol *Sym, unsigned Size, - unsigned AddrSpace = 0); - /// EmitGPRel32Value - Emit the expression @p Value into the output as a /// gprel32 (32-bit GP relative) value. /// Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sat Apr 30 22:50:49 2011 @@ -1476,13 +1476,17 @@ if (IsPCRel) { switch ((unsigned)Fixup.getKind()) { default: llvm_unreachable("invalid fixup kind!"); + + case FK_Data_8: Type = ELF::R_X86_64_PC64; break; + case FK_Data_4: Type = ELF::R_X86_64_PC32; break; + case FK_Data_2: Type = ELF::R_X86_64_PC16; break; + case FK_PCRel_8: assert(Modifier == MCSymbolRefExpr::VK_None); Type = ELF::R_X86_64_PC64; break; case X86::reloc_signed_4byte: case X86::reloc_riprel_4byte_movq_load: - case FK_Data_4: // FIXME? case X86::reloc_riprel_4byte: case FK_PCRel_4: switch (Modifier) { Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Sat Apr 30 22:50:49 2011 @@ -13,9 +13,11 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCAsmInfo.h" +#include "llvm/MC/MCContext.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCStreamer.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/Dwarf.h" #include #include using namespace llvm; @@ -111,12 +113,22 @@ const MCExpr * MCAsmInfo::getExprForPersonalitySymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const { - return getExprForFDESymbol(Sym, Streamer); + return getExprForFDESymbol(Sym, Encoding, Streamer); } const MCExpr * MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const { - return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); + if (!(Encoding & dwarf::DW_EH_PE_pcrel)) + return MCSymbolRefExpr::Create(Sym, Streamer.getContext()); + + MCContext &Context = Streamer.getContext(); + const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); + MCSymbol *PCSym = Context.CreateTempSymbol(); + Streamer.EmitLabel(PCSym); + const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); + return MCBinaryExpr::CreateSub(Res, PC, Context); } Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Sat Apr 30 22:50:49 2011 @@ -59,14 +59,3 @@ DwarfUsesAbsoluteLabelForStmtList = false; DwarfUsesLabelOffsetForRanges = false; } - -const MCExpr * -MCAsmInfoDarwin::getExprForFDESymbol(const MCSymbol *Sym, - MCStreamer &Streamer) const { - MCContext &Context = Streamer.getContext(); - const MCExpr *Res = MCSymbolRefExpr::Create(Sym, Context); - MCSymbol *PCSym = Context.CreateTempSymbol(); - Streamer.EmitLabel(PCSym); - const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, Context); - return MCBinaryExpr::CreateSub(Res, PC, Context); -} Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -162,7 +162,7 @@ virtual void EmitBytes(StringRef Data, unsigned AddrSpace); virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace); + unsigned AddrSpace); virtual void EmitIntValue(uint64_t Value, unsigned Size, unsigned AddrSpace = 0); @@ -566,9 +566,8 @@ } void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) { + unsigned AddrSpace) { assert(getCurrentSection() && "Cannot emit contents before setting section!"); - assert(!isPCRel && "Cannot emit pc relative relocations!"); const char *Directive = 0; switch (Size) { default: break; Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Sat Apr 30 22:50:49 2011 @@ -468,26 +468,21 @@ MCContext &context = streamer.getContext(); const MCAsmInfo &asmInfo = context.getAsmInfo(); const MCExpr *v = asmInfo.getExprForFDESymbol(&symbol, + symbolEncoding, streamer); unsigned size = getSizeForEncoding(streamer, symbolEncoding); - unsigned application = symbolEncoding & 0x70; - if (isa(v) && application == dwarf::DW_EH_PE_pcrel) - streamer.EmitPCRelValue(v, size); - else - streamer.EmitAbsValue(v, size); + streamer.EmitAbsValue(v, size); } static void EmitPersonality(MCStreamer &streamer, const MCSymbol &symbol, unsigned symbolEncoding) { MCContext &context = streamer.getContext(); const MCAsmInfo &asmInfo = context.getAsmInfo(); - const MCExpr *v = asmInfo.getExprForPersonalitySymbol(&symbol, streamer); + const MCExpr *v = asmInfo.getExprForPersonalitySymbol(&symbol, + symbolEncoding, + streamer); unsigned size = getSizeForEncoding(streamer, symbolEncoding); - unsigned application = symbolEncoding & 0x70; - if (isa(v) && application == dwarf::DW_EH_PE_pcrel) - streamer.EmitPCRelValue(v, size); - else - streamer.EmitValue(v, size); + streamer.EmitValue(v, size); } static const MachineLocation TranslateMachineLocation( Modified: llvm/trunk/lib/MC/MCLoggingStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCLoggingStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCLoggingStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCLoggingStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -154,9 +154,9 @@ } virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace){ + unsigned AddrSpace){ LogCall("EmitValue"); - return Child->EmitValueImpl(Value, Size, isPCRel, AddrSpace); + return Child->EmitValueImpl(Value, Size, AddrSpace); } virtual void EmitULEB128Value(const MCExpr *Value) { Modified: llvm/trunk/lib/MC/MCNullStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCNullStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCNullStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCNullStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -67,7 +67,7 @@ virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {} virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) {} + unsigned AddrSpace) {} virtual void EmitULEB128Value(const MCExpr *Value) {} virtual void EmitSLEB128Value(const MCExpr *Value) {} virtual void EmitGPRel32Value(const MCExpr *Value) {} Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -90,7 +90,7 @@ } void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) { + unsigned AddrSpace) { assert(AddrSpace == 0 && "Address space must be 0!"); MCDataFragment *DF = getOrCreateDataFragment(); @@ -102,7 +102,7 @@ } DF->addFixup(MCFixup::Create(DF->getContents().size(), Value, - MCFixup::getKindForSize(Size, isPCRel))); + MCFixup::getKindForSize(Size, false))); DF->getContents().resize(DF->getContents().size() + Size, 0); } Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -114,30 +114,15 @@ void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace) { - EmitValueImpl(Value, Size, false, AddrSpace); -} - -void MCStreamer::EmitPCRelValue(const MCExpr *Value, unsigned Size, - unsigned AddrSpace) { - EmitValueImpl(Value, Size, true, AddrSpace); + EmitValueImpl(Value, Size, AddrSpace); } void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, - bool isPCRel, unsigned AddrSpace) { - EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size, isPCRel, + unsigned AddrSpace) { + EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace); } -void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, - unsigned AddrSpace) { - EmitSymbolValue(Sym, Size, false, AddrSpace); -} - -void MCStreamer::EmitPCRelSymbolValue(const MCSymbol *Sym, unsigned Size, - unsigned AddrSpace) { - EmitSymbolValue(Sym, Size, true, AddrSpace); -} - void MCStreamer::EmitGPRel32Value(const MCExpr *Value) { report_fatal_error("unsupported directive in streamer"); } Modified: llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXMCAsmStreamer.cpp Sat Apr 30 22:50:49 2011 @@ -143,7 +143,7 @@ virtual void EmitBytes(StringRef Data, unsigned AddrSpace); virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace); + unsigned AddrSpace); virtual void EmitULEB128Value(const MCExpr *Value); virtual void EmitSLEB128Value(const MCExpr *Value); virtual void EmitGPRel32Value(const MCExpr *Value); @@ -352,9 +352,8 @@ } void PTXMCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) { + unsigned AddrSpace) { assert(getCurrentSection() && "Cannot emit contents before setting section!"); - assert(!isPCRel && "Cannot emit pc relative relocations!"); const char *Directive = 0; switch (Size) { default: break; Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=130634&r1=130633&r2=130634&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Sat Apr 30 22:50:49 2011 @@ -582,7 +582,7 @@ uint64_t Size, unsigned ByteAlignment) {} virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {} virtual void EmitValueImpl(const MCExpr *Value, unsigned Size, - bool isPCRel, unsigned AddrSpace) {} + unsigned AddrSpace) {} virtual void EmitULEB128Value(const MCExpr *Value) {} virtual void EmitSLEB128Value(const MCExpr *Value) {} virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value, From rafael.espindola at gmail.com Sat Apr 30 23:19:24 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 01 May 2011 04:19:24 -0000 Subject: [llvm-commits] [llvm] r130635 - in /llvm/trunk/lib/Target/X86: X86MCAsmInfo.cpp X86MCAsmInfo.h Message-ID: <20110501041925.0AA082A6C138@llvm.org> Author: rafael Date: Sat Apr 30 23:19:24 2011 New Revision: 130635 URL: http://llvm.org/viewvc/llvm-project?rev=130635&view=rev Log: I forgot these files in the previous commit. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.h Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130635&r1=130634&r2=130635&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Sat Apr 30 23:19:24 2011 @@ -76,6 +76,7 @@ const MCExpr * X86_64MCAsmInfoDarwin::getExprForPersonalitySymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const { MCContext &Context = Streamer.getContext(); const MCExpr *Res = Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.h?rev=130635&r1=130634&r2=130635&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.h Sat Apr 30 23:19:24 2011 @@ -29,6 +29,7 @@ explicit X86_64MCAsmInfoDarwin(const Triple &Triple); virtual const MCExpr * getExprForPersonalitySymbol(const MCSymbol *Sym, + unsigned Encoding, MCStreamer &Streamer) const; }; From rafael.espindola at gmail.com Sat Apr 30 23:49:54 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 01 May 2011 04:49:54 -0000 Subject: [llvm-commits] [llvm] r130637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h include/llvm/MC/MCDwarf.h include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfTableException.cpp lib/CodeGen/TargetLoweringObjectFileImpl.cpp lib/MC/MCAsmStreamer.cpp lib/MC/MCDwarf.cpp lib/MC/MCELFStreamer.cpp lib/Target/TargetLoweringObjectFile.cpp lib/Target/X86/X86TargetObjectFile.cpp lib/Target/X86/X86TargetObjectFile.h test/CodeGen/X86/no-cfi.ll Message-ID: <20110501044954.6C7612A6C138@llvm.org> Author: rafael Date: Sat Apr 30 23:49:54 2011 New Revision: 130637 URL: http://llvm.org/viewvc/llvm-project?rev=130637&view=rev Log: GCC uses a different encoding of pointers in the FDE when using -fno-dwarf2-cfi-asm. Implement the same behavior. Added: llvm/trunk/test/CodeGen/X86/no-cfi.ll Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/include/llvm/Target/TargetAsmInfo.h llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp llvm/trunk/lib/MC/MCAsmStreamer.cpp llvm/trunk/lib/MC/MCDwarf.cpp llvm/trunk/lib/MC/MCELFStreamer.cpp llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Modified: llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h (original) +++ llvm/trunk/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h Sat Apr 30 23:49:54 2011 @@ -188,7 +188,7 @@ virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; + virtual unsigned getFDEEncoding(bool CFI) const; virtual unsigned getTTypeEncoding() const; }; Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Sat Apr 30 23:49:54 2011 @@ -281,8 +281,8 @@ // // This emits the frame info section. // - static void Emit(MCStreamer &streamer); - static void EmitDarwin(MCStreamer &streamer); + static void Emit(MCStreamer &streamer, bool usingCFI); + static void EmitDarwin(MCStreamer &streamer, bool usingCFI); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); static void EncodeAdvanceLoc(uint64_t AddrDelta, raw_ostream &OS, const TargetAsmInfo &AsmInfo); Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Sat Apr 30 23:49:54 2011 @@ -58,8 +58,8 @@ return TLOF->getEHFrameSection(); } - unsigned getFDEEncoding() const { - return TLOF->getFDEEncoding(); + unsigned getFDEEncoding(bool CFI) const { + return TLOF->getFDEEncoding(CFI); } bool isFunctionEHFrameSymbolPrivate() const { Modified: llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h (original) +++ llvm/trunk/include/llvm/Target/TargetLoweringObjectFile.h Sat Apr 30 23:49:54 2011 @@ -233,7 +233,7 @@ virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; + virtual unsigned getFDEEncoding(bool CFI) const; virtual unsigned getTTypeEncoding() const; protected: Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfTableException.cpp Sat Apr 30 23:49:54 2011 @@ -92,7 +92,7 @@ // personality function reference: unsigned LSDAEncoding = TLOF.getLSDAEncoding(); - unsigned FDEEncoding = TLOF.getFDEEncoding(); + unsigned FDEEncoding = TLOF.getFDEEncoding(false); unsigned PerEncoding = TLOF.getPersonalityEncoding(); char Augmentation[6] = { 0 }; @@ -168,7 +168,7 @@ const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); unsigned LSDAEncoding = TLOF.getLSDAEncoding(); - unsigned FDEEncoding = TLOF.getFDEEncoding(); + unsigned FDEEncoding = TLOF.getFDEEncoding(false); Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection()); Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original) +++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Sat Apr 30 23:49:54 2011 @@ -879,7 +879,7 @@ return DW_EH_PE_pcrel; } -unsigned TargetLoweringObjectFileMachO::getFDEEncoding() const { +unsigned TargetLoweringObjectFileMachO::getFDEEncoding(bool CFI) const { return DW_EH_PE_pcrel; } Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Sat Apr 30 23:49:54 2011 @@ -1069,6 +1069,9 @@ // Dump out the dwarf file & directory tables and line tables. if (getContext().hasDwarfFiles() && !UseLoc) MCDwarfFileTable::Emit(this); + + if (getNumFrameInfos() && !UseCFI) + MCDwarfFrameEmitter::Emit(*this, false); } MCStreamer *llvm::createAsmStreamer(MCContext &Context, Modified: llvm/trunk/lib/MC/MCDwarf.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDwarf.cpp (original) +++ llvm/trunk/lib/MC/MCDwarf.cpp Sat Apr 30 23:49:54 2011 @@ -500,9 +500,11 @@ class FrameEmitterImpl { int CFAOffset; int CIENum; + bool UsingCFI; public: - FrameEmitterImpl() : CFAOffset(0), CIENum(0) { + FrameEmitterImpl(bool usingCFI) : CFAOffset(0), CIENum(0), + UsingCFI(usingCFI) { } const MCSymbol &EmitCIE(MCStreamer &streamer, @@ -702,7 +704,7 @@ streamer.EmitIntValue(lsdaEncoding, 1); } // Encoding of the FDE pointers - streamer.EmitIntValue(asmInfo.getFDEEncoding(), 1); + streamer.EmitIntValue(asmInfo.getFDEEncoding(UsingCFI), 1); // Initial Instructions @@ -753,7 +755,7 @@ const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, 0); streamer.EmitAbsValue(offset, 4); - unsigned fdeEncoding = asmInfo.getFDEEncoding(); + unsigned fdeEncoding = asmInfo.getFDEEncoding(UsingCFI); unsigned size = getSizeForEncoding(streamer, fdeEncoding); // PC Begin @@ -837,8 +839,9 @@ // compatible with the one in CodeGen. It is useful during the transition // to make it easy to compare the outputs, but should probably be removed // afterwards. -void MCDwarfFrameEmitter::EmitDarwin(MCStreamer &streamer) { - FrameEmitterImpl Emitter; +void MCDwarfFrameEmitter::EmitDarwin(MCStreamer &streamer, + bool usingCFI) { + FrameEmitterImpl Emitter(usingCFI); DenseMap Personalities; const MCSymbol *aCIE = NULL; const MCDwarfFrameInfo *aFrame = NULL; @@ -892,17 +895,18 @@ streamer.EmitLabel(fdeEnd); } -void MCDwarfFrameEmitter::Emit(MCStreamer &streamer) { +void MCDwarfFrameEmitter::Emit(MCStreamer &streamer, + bool usingCFI) { const MCContext &context = streamer.getContext(); const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); if (!asmInfo.isFunctionEHFrameSymbolPrivate()) { - EmitDarwin(streamer); + EmitDarwin(streamer, usingCFI); return; } MCSymbol *fdeEnd = NULL; DenseMap CIEStarts; - FrameEmitterImpl Emitter; + FrameEmitterImpl Emitter(usingCFI); for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCELFStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCELFStreamer.cpp Sat Apr 30 23:49:54 2011 @@ -346,7 +346,7 @@ void MCELFStreamer::Finish() { if (getNumFrameInfos()) - MCDwarfFrameEmitter::Emit(*this); + MCDwarfFrameEmitter::Emit(*this, true); for (std::vector::const_iterator i = LocalCommons.begin(), e = LocalCommons.end(); Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original) +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Sat Apr 30 23:49:54 2011 @@ -350,7 +350,7 @@ return dwarf::DW_EH_PE_absptr; } -unsigned TargetLoweringObjectFile::getFDEEncoding() const { +unsigned TargetLoweringObjectFile::getFDEEncoding(bool CFI) const { return dwarf::DW_EH_PE_absptr; } Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Sat Apr 30 23:49:54 2011 @@ -58,7 +58,7 @@ return DW_EH_PE_absptr; } -unsigned X8632_ELFTargetObjectFile::getFDEEncoding() const { +unsigned X8632_ELFTargetObjectFile::getFDEEncoding(bool FDE) const { if (TM.getRelocationModel() == Reloc::PIC_) return DW_EH_PE_pcrel | DW_EH_PE_sdata4; else @@ -97,8 +97,15 @@ return DW_EH_PE_absptr; } -unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const { - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; +unsigned X8664_ELFTargetObjectFile::getFDEEncoding(bool CFI) const { + if (CFI) + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + + CodeModel::Model Model = TM.getCodeModel(); + if (TM.getRelocationModel() == Reloc::PIC_) + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; + + return DW_EH_PE_udata4; } unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const { Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.h?rev=130637&r1=130636&r2=130637&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.h (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.h Sat Apr 30 23:49:54 2011 @@ -40,7 +40,7 @@ :TM(tm) { } virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; + virtual unsigned getFDEEncoding(bool CFI) const; virtual unsigned getTTypeEncoding() const; }; @@ -51,7 +51,7 @@ :TM(tm) { } virtual unsigned getPersonalityEncoding() const; virtual unsigned getLSDAEncoding() const; - virtual unsigned getFDEEncoding() const; + virtual unsigned getFDEEncoding(bool CFI) const; virtual unsigned getTTypeEncoding() const; }; Added: llvm/trunk/test/CodeGen/X86/no-cfi.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/no-cfi.ll?rev=130637&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/no-cfi.ll (added) +++ llvm/trunk/test/CodeGen/X86/no-cfi.ll Sat Apr 30 23:49:54 2011 @@ -0,0 +1,38 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -disable-cfi | FileCheck --check-prefix=STATIC %s +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -disable-cfi -relocation-model=pic | FileCheck --check-prefix=PIC %s + +; STATIC: .ascii "zPLR" +; STATIC: .byte 3 +; STATIC-NEXT: .long __gxx_personality_v0 +; STATIC-NEXT: .byte 3 +; STATIC-NEXT: .byte 3 + +; PIC: .ascii "zPLR" +; PIC: .byte 155 +; PIC-NEXT: .L +; PIC-NEXT: .long DW.ref.__gxx_personality_v0-.L +; PIC-NEXT: .byte 27 +; PIC-NEXT: .byte 27 + + +define void @bar() { +entry: + %call = invoke i32 @foo() + to label %invoke.cont unwind label %lpad + +invoke.cont: + ret void + +lpad: + %exn = call i8* @llvm.eh.exception() nounwind + %eh.selector = call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %exn, i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*), i8* null) nounwind + ret void +} + +declare i32 @foo() + +declare i8* @llvm.eh.exception() nounwind readonly + +declare i32 @__gxx_personality_v0(...) + +declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind From chandlerc at gmail.com Sun May 1 01:14:10 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Sun, 01 May 2011 06:14:10 -0000 Subject: [llvm-commits] [llvm] r130640 - /llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Message-ID: <20110501061410.5C95D2A6C138@llvm.org> Author: chandlerc Date: Sun May 1 01:14:10 2011 New Revision: 130640 URL: http://llvm.org/viewvc/llvm-project?rev=130640&view=rev Log: Remove an unused variable from this function introduced in r130637, likely a result of copy/paste. Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=130640&r1=130639&r2=130640&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Sun May 1 01:14:10 2011 @@ -101,7 +101,6 @@ if (CFI) return DW_EH_PE_pcrel | DW_EH_PE_sdata4; - CodeModel::Model Model = TM.getCodeModel(); if (TM.getRelocationModel() == Reloc::PIC_) return DW_EH_PE_pcrel | DW_EH_PE_sdata4; From chandlerc at google.com Sun May 1 01:20:21 2011 From: chandlerc at google.com (Chandler Carruth) Date: Sat, 30 Apr 2011 23:20:21 -0700 Subject: [llvm-commits] [llvm] r130637 - in /llvm/trunk: include/llvm/CodeGen/TargetLoweringObjectFileImpl.h include/llvm/MC/MCDwarf.h include/llvm/Target/TargetAsmInfo.h include/llvm/Target/TargetLoweringObjectFile.h lib/CodeGen/AsmPrinter/DwarfTableExce Message-ID: On Sat, Apr 30, 2011 at 9:49 PM, Rafael Espindola < rafael.espindola at gmail.com> wrote: > Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=130637&r1=130636&r2=130637&view=diff > > ============================================================================== > --- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original) > +++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Sat Apr 30 23:49:54 > 2011 > @@ -58,7 +58,7 @@ > return DW_EH_PE_absptr; > } > > -unsigned X8632_ELFTargetObjectFile::getFDEEncoding() const { > +unsigned X8632_ELFTargetObjectFile::getFDEEncoding(bool FDE) const { > if (TM.getRelocationModel() == Reloc::PIC_) > return DW_EH_PE_pcrel | DW_EH_PE_sdata4; > else > @@ -97,8 +97,15 @@ > return DW_EH_PE_absptr; > } > > -unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const { > - return DW_EH_PE_pcrel | DW_EH_PE_sdata4; > +unsigned X8664_ELFTargetObjectFile::getFDEEncoding(bool CFI) const { > + if (CFI) > + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; > + > + CodeModel::Model Model = TM.getCodeModel(); > FYI, I removed this variable in r130640 as it was unused and causing warnings. Mentioning it on the off chance it was intended to be used... > + if (TM.getRelocationModel() == Reloc::PIC_) > + return DW_EH_PE_pcrel | DW_EH_PE_sdata4; > + > + return DW_EH_PE_udata4; > } > > unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const { > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110430/ac154c2e/attachment.html From geek4civic at gmail.com Sun May 1 08:29:50 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Sun, 01 May 2011 13:29:50 -0000 Subject: [llvm-commits] [llvm] r130657 - in /llvm/trunk: autoconf/configure.ac cmake/config-ix.cmake configure include/llvm/Config/config.h.cmake include/llvm/Config/config.h.in lib/Support/Windows/DynamicLibrary.inc Message-ID: <20110501132950.3C1732A6C138@llvm.org> Author: chapuni Date: Sun May 1 08:29:49 2011 New Revision: 130657 URL: http://llvm.org/viewvc/llvm-project?rev=130657&view=rev Log: Windows/DynamicLibrary.inc: Clean up ELM_Callback. We may check the decl instead of the versions of individual libraries. autoconf: Add checking ELM_Callback decl for mingw32 and mingw-w64. cmake/config-ix.cmake: Add checking ELM_Callback decl for win32. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/cmake/config-ix.cmake llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.cmake llvm/trunk/include/llvm/Config/config.h.in llvm/trunk/lib/Support/Windows/DynamicLibrary.inc Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Sun May 1 08:29:49 2011 @@ -1429,6 +1429,24 @@ AC_CHECK_LIB(gcc,__cmpdi2,AC_DEFINE([HAVE___CMPDI2],[1],[Have host's __cmpdi2])) fi +dnl Check Win32 API EnumerateLoadedModules. +if test "$llvm_cv_os_type" = "MingW" ; then + AC_MSG_CHECKING([whether EnumerateLoadedModules() accepts new decl]) + AC_COMPILE_IFELSE([[#include +#include +extern void foo(PENUMLOADED_MODULES_CALLBACK); +extern void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID));]], +[ + AC_MSG_RESULT([yes]) + llvm_cv_win32_elmcb_pcstr="PCSTR" +], +[ + AC_MSG_RESULT([no]) + llvm_cv_win32_elmcb_pcstr="PSTR" +]) + AC_DEFINE_UNQUOTED([WIN32_ELMCB_PCSTR],$llvm_cv_win32_elmcb_pcstr,[Type of 1st arg on ELM Callback]) +fi + dnl Check for variations in the Standard C++ library and STL. These macros are dnl provided by LLVM in the autoconf/m4 directory. AC_FUNC_ISNAN Modified: llvm/trunk/cmake/config-ix.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/cmake/config-ix.cmake (original) +++ llvm/trunk/cmake/config-ix.cmake Sun May 1 08:29:49 2011 @@ -366,6 +366,21 @@ set(LTDL_DLOPEN_DEPLIBS 0) # TODO endif( MSVC ) +if( PURE_WINDOWS ) + CHECK_CXX_SOURCE_COMPILES(" + #include + #include + extern \"C\" void foo(PENUMLOADED_MODULES_CALLBACK); + extern \"C\" void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID)); + int main(){return 0;}" + HAVE_ELMCB_PCSTR) + if( HAVE_ELMCB_PCSTR ) + set(WIN32_ELMCB_PCSTR "PCSTR") + else() + set(WIN32_ELMCB_PCSTR "PSTR") + endif() +endif( PURE_WINDOWS ) + # FIXME: Signal handler return type, currently hardcoded to 'void' set(RETSIGTYPE void) Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Sun May 1 08:29:49 2011 @@ -20660,6 +20660,73 @@ fi +if test "$llvm_cv_os_type" = "MingW" ; then + { echo "$as_me:$LINENO: checking whether EnumerateLoadedModules() accepts new decl" >&5 +echo $ECHO_N "checking whether EnumerateLoadedModules() accepts new decl... $ECHO_C" >&6; } + cat >conftest.$ac_ext <<_ACEOF +#include +#include +extern void foo(PENUMLOADED_MODULES_CALLBACK); +extern void foo(BOOL(CALLBACK*)(PCSTR,ULONG_PTR,ULONG,PVOID)); +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + llvm_cv_win32_elmcb_pcstr="PCSTR" + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + llvm_cv_win32_elmcb_pcstr="PSTR" + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +cat >>confdefs.h <<_ACEOF +#define WIN32_ELMCB_PCSTR $llvm_cv_win32_elmcb_pcstr +_ACEOF + +fi + { echo "$as_me:$LINENO: checking for isnan in " >&5 echo $ECHO_N "checking for isnan in ... $ECHO_C" >&6; } Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Sun May 1 08:29:49 2011 @@ -196,6 +196,9 @@ /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 +/* Type of 1st arg on ELM Callback */ +#cmakedefine WIN32_ELMCB_PCSTR ${WIN32_ELMCB_PCSTR} + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_LIMITS_H ${HAVE_LIMITS_H} Modified: llvm/trunk/include/llvm/Config/config.h.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.in (original) +++ llvm/trunk/include/llvm/Config/config.h.in Sun May 1 08:29:49 2011 @@ -675,6 +675,9 @@ /* Define if use udis86 library */ #undef USE_UDIS86 +/* Type of 1st arg on ELM Callback */ +#undef WIN32_ELMCB_PCSTR + /* Define to empty if `const' does not conform to ANSI C. */ #undef const Modified: llvm/trunk/lib/Support/Windows/DynamicLibrary.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/DynamicLibrary.inc?rev=130657&r1=130656&r2=130657&view=diff ============================================================================== --- llvm/trunk/lib/Support/Windows/DynamicLibrary.inc (original) +++ llvm/trunk/lib/Support/Windows/DynamicLibrary.inc Sun May 1 08:29:49 2011 @@ -41,41 +41,12 @@ static std::vector OpenedHandles; -#ifdef _WIN64 - typedef DWORD64 ModuleBaseType; -#else - typedef ULONG ModuleBaseType; -#endif - extern "C" { -// Use old callback if: -// - Not using Visual Studio -// - Visual Studio 2005 or earlier but only if we are not using the Windows SDK -// or Windows SDK version is older than 6.0 -// Use new callback if: -// - Newer Visual Studio (comes with newer SDK). -// - Visual Studio 2005 with Windows SDK 6.0+ -#if defined(_MSC_VER) - #if _MSC_VER < 1500 && (!defined(VER_PRODUCTBUILD) || VER_PRODUCTBUILD < 6000) - #define OLD_ELM_CALLBACK_DECL 1 - #endif -#elif defined(__MINGW64__) - // Use new callback. -#elif defined(__MINGW32__) - #define OLD_ELM_CALLBACK_DECL 1 -#endif -#ifdef OLD_ELM_CALLBACK_DECL - static BOOL CALLBACK ELM_Callback(PSTR ModuleName, - ModuleBaseType ModuleBase, + static BOOL CALLBACK ELM_Callback(WIN32_ELMCB_PCSTR ModuleName, + ULONG_PTR ModuleBase, ULONG ModuleSize, PVOID UserContext) -#else - static BOOL CALLBACK ELM_Callback(PCSTR ModuleName, - ModuleBaseType ModuleBase, - ULONG ModuleSize, - PVOID UserContext) -#endif { // Ignore VC++ runtimes prior to 7.1. Somehow some of them get loaded // into the process. From rafael.espindola at gmail.com Sun May 1 10:44:13 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Sun, 01 May 2011 15:44:13 -0000 Subject: [llvm-commits] [llvm] r130658 - in /llvm/trunk: lib/MC/MCMachOStreamer.cpp lib/Target/X86/X86MCAsmInfo.cpp test/CodeGen/PowerPC/mulhs.ll test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll test/CodeGen/X86/2008-04-02-unnamedEH.ll test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll test/CodeGen/X86/hidden-vis-pic.ll test/CodeGen/X86/personality.ll Message-ID: <20110501154413.E58B92A6C138@llvm.org> Author: rafael Date: Sun May 1 10:44:13 2011 New Revision: 130658 URL: http://llvm.org/viewvc/llvm-project?rev=130658&view=rev Log: Add r130623 back now that ELF has been fixed to work with -fno-dwarf2-cfi-asm. Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp llvm/trunk/test/CodeGen/PowerPC/mulhs.ll llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll llvm/trunk/test/CodeGen/X86/personality.ll Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Sun May 1 10:44:13 2011 @@ -377,6 +377,9 @@ } void MCMachOStreamer::Finish() { + if (getNumFrameInfos()) + MCDwarfFrameEmitter::Emit(*this, true); + // We have to set the fragment atom associations so we can relax properly for // Mach-O. Modified: llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCAsmInfo.cpp Sun May 1 10:44:13 2011 @@ -71,7 +71,7 @@ DwarfUsesInlineInfoSection = true; // Exceptions handling - ExceptionsType = ExceptionHandling::DwarfTable; + ExceptionsType = ExceptionHandling::DwarfCFI; } const MCExpr * Modified: llvm/trunk/test/CodeGen/PowerPC/mulhs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/mulhs.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/mulhs.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/mulhs.ll Sun May 1 10:44:13 2011 @@ -5,7 +5,7 @@ ; RUN: not grep add %t ; RUN: grep mulhw %t | count 1 -define i32 @mulhs(i32 %a, i32 %b) { +define i32 @mulhs(i32 %a, i32 %b) nounwind { entry: %tmp.1 = sext i32 %a to i64 ; [#uses=1] %tmp.3 = sext i32 %b to i64 ; [#uses=1] Modified: llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-09-17-ObjcFrameEH.ll Sun May 1 10:44:13 2011 @@ -1,4 +1,6 @@ -; RUN: llc < %s -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | count 2 +; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i686-apple-darwin | grep {isNullOrNil].eh"} | FileCheck %s + +; CHECK: "_-[NSString(local) isNullOrNil].eh": %struct.NSString = type { } %struct._objc__method_prototype_list = type opaque Modified: llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-04-02-unnamedEH.ll Sun May 1 10:44:13 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s | FileCheck %s +; RUN: llc < %s -disable-cfi | FileCheck %s target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" target triple = "i386-apple-darwin8" Modified: llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll (original) +++ llvm/trunk/test/CodeGen/X86/2008-12-12-PrivateEHSymbol.ll Sun May 1 10:44:13 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh -; RUN: llc < %s -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -disable-cfi -march=x86-64 -mtriple=x86_64-apple-darwin9 | grep ^__Z1fv.eh +; RUN: llc < %s -disable-cfi -march=x86 -mtriple=i386-apple-darwin9 | grep ^__Z1fv.eh define void @_Z1fv() { entry: Modified: llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll (original) +++ llvm/trunk/test/CodeGen/X86/hidden-vis-pic.ll Sun May 1 10:44:13 2011 @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s +; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -relocation-model=pic -disable-fp-elim -unwind-tables | FileCheck %s Modified: llvm/trunk/test/CodeGen/X86/personality.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/personality.ll?rev=130658&r1=130657&r2=130658&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/personality.ll (original) +++ llvm/trunk/test/CodeGen/X86/personality.ll Sun May 1 10:44:13 2011 @@ -1,5 +1,5 @@ -; RUN: llc < %s -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 -; RUN: llc < %s -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 +; RUN: llc < %s -disable-cfi -mtriple=x86_64-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X64 +; RUN: llc < %s -disable-cfi -mtriple=i386-apple-darwin9 -disable-cgp-branch-opts | FileCheck %s -check-prefix=X32 ; PR1632 define void @_Z1fv() { @@ -38,13 +38,15 @@ declare void @__cxa_end_catch() -; X64: Leh_frame_common_begin0: -; X64: .long ___gxx_personality_v0 at GOTPCREL+4 - -; X32: Leh_frame_common_begin0: -; X32: .long L___gxx_personality_v0$non_lazy_ptr- -; .... - -; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers -; X32: L___gxx_personality_v0$non_lazy_ptr: -; X32: .indirect_symbol ___gxx_personality_v0 +; X64: zPLR +; X64: .byte 155 +; X64-NEXT: .long ___gxx_personality_v0 at GOTPCREL+4 + +; X32: .section __IMPORT,__pointers,non_lazy_symbol_pointers +; X32-NEXT: L___gxx_personality_v0$non_lazy_ptr: +; X32-NEXT: .indirect_symbol ___gxx_personality_v0 + +; X32: zPLR +; X32: .byte 155 +; X32-NEXT: : +; X32-NEXT: .long L___gxx_personality_v0$non_lazy_ptr- From sabre at nondot.org Sun May 1 13:27:11 2011 From: sabre at nondot.org (Chris Lattner) Date: Sun, 01 May 2011 18:27:11 -0000 Subject: [llvm-commits] [llvm] r130661 - in /llvm/trunk: include/llvm/Target/TargetLibraryInfo.h lib/Transforms/Scalar/MemCpyOptimizer.cpp Message-ID: <20110501182711.8C9CB2A6C138@llvm.org> Author: lattner Date: Sun May 1 13:27:11 2011 New Revision: 130661 URL: http://llvm.org/viewvc/llvm-project?rev=130661&view=rev Log: enhance memcpyopt to obey -fno-builtin and friends. This addresses a problem reported on cfe-dev. Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Modified: llvm/trunk/include/llvm/Target/TargetLibraryInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLibraryInfo.h?rev=130661&r1=130660&r2=130661&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLibraryInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetLibraryInfo.h Sun May 1 13:27:11 2011 @@ -23,6 +23,9 @@ // void *memcpy(void *s1, const void *s2, size_t n); memcpy, + // void *memmove(void *s1, const void *s2, size_t n); + memmove, + /// void memset_pattern16(void *b, const void *pattern16, size_t len); memset_pattern16, Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=130661&r1=130660&r2=130661&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Sun May 1 13:27:11 2011 @@ -28,6 +28,7 @@ #include "llvm/Support/IRBuilder.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetLibraryInfo.h" #include using namespace llvm; @@ -299,12 +300,15 @@ namespace { class MemCpyOpt : public FunctionPass { MemoryDependenceAnalysis *MD; + TargetLibraryInfo *TLI; const TargetData *TD; public: static char ID; // Pass identification, replacement for typeid MemCpyOpt() : FunctionPass(ID) { initializeMemCpyOptPass(*PassRegistry::getPassRegistry()); MD = 0; + TLI = 0; + TD = 0; } bool runOnFunction(Function &F); @@ -316,6 +320,7 @@ AU.addRequired(); AU.addRequired(); AU.addRequired(); + AU.addRequired(); AU.addPreserved(); AU.addPreserved(); } @@ -346,6 +351,7 @@ false, false) INITIALIZE_PASS_DEPENDENCY(DominatorTree) INITIALIZE_PASS_DEPENDENCY(MemoryDependenceAnalysis) +INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo) INITIALIZE_AG_DEPENDENCY(AliasAnalysis) INITIALIZE_PASS_END(MemCpyOpt, "memcpyopt", "MemCpy Optimization", false, false) @@ -804,6 +810,9 @@ bool MemCpyOpt::processMemMove(MemMoveInst *M) { AliasAnalysis &AA = getAnalysis(); + if (!TLI->has(LibFunc::memmove)) + return false; + // See if the pointers alias. if (!AA.isNoAlias(AA.getLocationForDest(M), AA.getLocationForSource(M))) return false; @@ -935,6 +944,14 @@ bool MadeChange = false; MD = &getAnalysis(); TD = getAnalysisIfAvailable(); + TLI = &getAnalysis(); + + // If we don't have at least memset and memcpy, there is little point of doing + // anything here. These are required by a freestanding implementation, so if + // even they are disabled, there is no point in trying hard. + if (!TLI->has(LibFunc::memset) || !TLI->has(LibFunc::memcpy)) + return false; + while (1) { if (!iterateOnFunction(F)) break; From clattner at apple.com Sun May 1 14:31:57 2011 From: clattner at apple.com (Chris Lattner) Date: Sun, 01 May 2011 12:31:57 -0700 Subject: [llvm-commits] [llvm] r130611 - /llvm/trunk/lib/MC/MCAsmStreamer.cpp In-Reply-To: <20110430163457.CB27A2A6C138@llvm.org> References: <20110430163457.CB27A2A6C138@llvm.org> Message-ID: <281BED74-657D-4615-9F0F-C3654FA64166@apple.com> On Apr 30, 2011, at 9:34 AM, Rafael Espindola wrote: > Author: rafael > Date: Sat Apr 30 11:34:57 2011 > New Revision: 130611 > > URL: http://llvm.org/viewvc/llvm-project?rev=130611&view=rev > Log: > Implement MCAsmStreamer::EmitEHSymAttributes. Doing this in the asm streamer > is a bit ugly, but doing it on the base MCStreamer would be redundant > with the object streamer which does it using SD. Hey Rafael, I'm loving your work on the CFI directives. Can you add a verbose-asm comment to directives that makes sense? It would be great to print out the register name in ".cfi_offset" etc. Thanks again for working on this! -Chris From clattner at apple.com Sun May 1 14:40:25 2011 From: clattner at apple.com (Chris Lattner) Date: Sun, 01 May 2011 12:40:25 -0700 Subject: [llvm-commits] [llvm] r130485 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll In-Reply-To: <5F0816C4-4FC4-4F02-8B7E-51858107AC6D@googlemail.com> References: <20110429081541.B7F422A6C138@llvm.org> <1B93035B-15A4-47B0-8E78-2D0F8A6B1701@apple.com> <5F0816C4-4FC4-4F02-8B7E-51858107AC6D@googlemail.com> Message-ID: On Apr 30, 2011, at 3:22 AM, Benjamin Kramer wrote: > > On 30.04.2011, at 00:00, Devang Patel wrote: > >> >> On Apr 29, 2011, at 2:50 PM, Benjamin Kramer wrote: >>> >>> Are you sure this specific transformation destroys the DebugLoc? When InstCombine simply replaces one >>> instruction with another it preserves debug information (InstructionCombining.cpp:1592). >> >> I added line 1592 however I am not sure that this particular transformation is covered by 1592 in all cases. I have seen "shl" without DebugLoc generated by instcombine before your patch landed in svn. If you're interested I can send you more info. > > There is a way this transform can lose a DebugLoc > > x = C1 << A # with DebugLoc > y = x << C2 # without DebugLoc > > InstCombine will then replace 'y' with a new instruction (but there's no DebugLoc to attach to it) and 'x' is DCE'd. > I think the only feasible way to improve here is to find out why 'y' has no debug info attached to it. > > If you have a test case where InstCombine introduces SHLs without DebugLocs, I'd be interested in seeing it. More generally, we don't want to sprinkle setDebugLoc calls into *every* instcombine xform. We need a better solution. -Chris From clattner at apple.com Sun May 1 14:42:41 2011 From: clattner at apple.com (Chris Lattner) Date: Sun, 01 May 2011 12:42:41 -0700 Subject: [llvm-commits] [llvm] r130528 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/PhiEliminate3.ll In-Reply-To: <20110429184738.7D4302A6C135@llvm.org> References: <20110429184738.7D4302A6C135@llvm.org> Message-ID: <0A6AA845-BA99-41BD-BD01-E179BD670261@apple.com> On Apr 29, 2011, at 11:47 AM, Peter Collingbourne wrote: > Author: pcc > Date: Fri Apr 29 13:47:38 2011 > New Revision: 130528 > > URL: http://llvm.org/viewvc/llvm-project?rev=130528&view=rev > Log: > SimplifyCFG: Expose phi node folding cost threshold as command line parameter Hi Peter, Why? -Chris > > Added: > llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll > Modified: > llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp > > Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=130528&r1=130527&r2=130528&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Apr 29 13:47:38 2011 > @@ -37,6 +37,10 @@ > #include > using namespace llvm; > > +static cl::opt > +PHINodeFoldingThreshold("phi-node-folding-threshold", cl::Hidden, cl::init(1), > + cl::desc("Control the amount of phi node folding to perform (default = 1)")); > + > static cl::opt > DupRet("simplifycfg-dup-ret", cl::Hidden, cl::init(false), > cl::desc("Duplicate return instructions into unconditional branches")); > @@ -1246,7 +1250,8 @@ > // instructions. While we are at it, keep track of the instructions > // that need to be moved to the dominating block. > SmallPtrSet AggressiveInsts; > - unsigned MaxCostVal0 = 1, MaxCostVal1 = 1; > + unsigned MaxCostVal0 = PHINodeFoldingThreshold, > + MaxCostVal1 = PHINodeFoldingThreshold; > > for (BasicBlock::iterator II = BB->begin(); isa(II);) { > PHINode *PN = cast(II++); > > Added: llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll?rev=130528&view=auto > ============================================================================== > --- llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll (added) > +++ llvm/trunk/test/Transforms/SimplifyCFG/PhiEliminate3.ll Fri Apr 29 13:47:38 2011 > @@ -0,0 +1,34 @@ > +; Test merging of blocks containing complex expressions, > +; with various folding thresholds > +; > +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=1 | grep N: > +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | not grep N: > +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=2 | grep M: > +; RUN: opt < %s -simplifycfg -S -phi-node-folding-threshold=7 | not grep M: > +; > + > +define i32 @test(i1 %a, i1 %b, i32 %i, i32 %j, i32 %k) { > +entry: > + br i1 %a, label %M, label %O > +O: > + br i1 %b, label %P, label %Q > +P: > + %iaj = add i32 %i, %j > + %iajak = add i32 %iaj, %k > + br label %N > +Q: > + %ixj = xor i32 %i, %j > + %ixjxk = xor i32 %ixj, %k > + br label %N > +N: > + ; This phi should be foldable if threshold >= 2 > + %Wp = phi i32 [ %iajak, %P ], [ %ixjxk, %Q ] > + %Wp2 = add i32 %Wp, %Wp > + br label %M > +M: > + ; This phi should be foldable if threshold >= 7 > + %W = phi i32 [ %Wp2, %N ], [ 2, %entry ] > + %R = add i32 %W, 1 > + ret i32 %R > +} > + > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
    %ΔN